Skip to content

Commit 63cc269

Browse files
all shapes in MitsubaLoader must be geometry collections
actually use Geometry Transforms
1 parent 0136b63 commit 63cc269

3 files changed

Lines changed: 157 additions & 215 deletions

File tree

include/nbl/ext/MitsubaLoader/CMitsubaMetadata.h

Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,21 @@ class CMitsubaMetadata : public asset::IAssetMetadata
2525
public:
2626
std::string m_id;
2727
};
28-
class IGeometry : public CID
29-
{
30-
public:
31-
inline IGeometry() : CID(), type(CElementShape::Type::INVALID) {}
32-
inline ~IGeometry() = default;
33-
34-
CElementShape::Type type;
35-
};
36-
class CPolygonGeometry final : public asset::IPolygonGeometryMetadata, public IGeometry
28+
class CGeometryCollection final : public asset::IGeometryCollectionMetadata, public CID
3729
{
3830
public:
39-
inline CPolygonGeometry() : asset::IPolygonGeometryMetadata(), IGeometry() {}
40-
inline CPolygonGeometry(CPolygonGeometry&& other) : CPolygonGeometry() {operator=(std::move(other));}
41-
inline ~CPolygonGeometry() = default;
31+
inline CGeometryCollection() : asset::IGeometryCollectionMetadata(), CID(), type(CElementShape::Type::INVALID) {}
32+
inline CGeometryCollection(CGeometryCollection&& other) : CGeometryCollection() {operator=(std::move(other));}
33+
inline ~CGeometryCollection() = default;
4234

43-
inline CPolygonGeometry& operator=(CPolygonGeometry&& other)
35+
inline CGeometryCollection& operator=(CGeometryCollection&& other)
4436
{
45-
asset::IPolygonGeometryMetadata::operator=(std::move(other));
46-
IGeometry::operator=(std::move(other));
37+
asset::IGeometryCollectionMetadata::operator=(std::move(other));
38+
CID::operator=(std::move(other));
4739
return *this;
4840
}
49-
};
50-
class CGeometryCollection final : public asset::IGeometryCollectionMetadata, public CID
51-
{
52-
public:
53-
inline CGeometryCollection() : asset::IGeometryCollectionMetadata(), CID() {}
54-
inline ~CGeometryCollection() = default;
41+
42+
CElementShape::Type type;
5543
};
5644

5745
struct SGlobal
@@ -69,32 +57,33 @@ class CMitsubaMetadata : public asset::IAssetMetadata
6957
const char* getLoaderName() const override {return LoaderName;}
7058

7159
// add more overloads when more asset implementations of IGeometry<ICPUBuffer> exist
72-
inline const CPolygonGeometry* getAssetSpecificMetadata(const asset::ICPUPolygonGeometry* asset) const
60+
inline const CGeometryCollection* getAssetSpecificMetadata(const asset::ICPUGeometryCollection* asset) const
7361
{
7462
const auto found = IAssetMetadata::getAssetSpecificMetadata(asset);
75-
return static_cast<const CPolygonGeometry*>(found);
63+
return static_cast<const CGeometryCollection*>(found);
7664
}
7765

7866
private:
7967
friend struct SContext;
80-
struct SGeometryMetaPair
68+
struct SGeometryCollectionMetaPair
8169
{
82-
core::smart_refctd_ptr<asset::ICPUPolygonGeometry> geom;
83-
CMitsubaMetadata::CPolygonGeometry meta;
70+
core::smart_refctd_ptr<asset::ICPUGeometryCollection> collection;
71+
CMitsubaMetadata::CGeometryCollection meta;
8472
};
85-
inline void setPolygonGeometryMeta(core::unordered_map<const CElementShape*,SGeometryMetaPair>&& container)
73+
template<typename Key>
74+
inline void setGeometryCollectionMeta(core::unordered_map<Key,SGeometryCollectionMetaPair>&& container)
8675
{
8776
const uint32_t count = container.size();
88-
m_metaPolygonGeometryStorage = IAssetMetadata::createContainer<CPolygonGeometry>(count);
77+
m_metaPolygonGeometryStorage = IAssetMetadata::createContainer<CGeometryCollection>(count);
8978
auto outIt = m_metaPolygonGeometryStorage->begin();
9079
for (auto& el : container)
9180
{
9281
*outIt = std::move(el.second.meta);
93-
IAssetMetadata::insertAssetSpecificMetadata(el.second.geom.get(),outIt++);
82+
IAssetMetadata::insertAssetSpecificMetadata(el.second.collection.get(),outIt++);
9483
}
9584
}
9685

97-
meta_container_t<CPolygonGeometry> m_metaPolygonGeometryStorage;
86+
meta_container_t<CGeometryCollection> m_metaPolygonGeometryStorage;
9887
};
9988

10089
}

include/nbl/ext/MitsubaLoader/SContext.h

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,35 +19,32 @@ struct SContext final
1919
{
2020
public:
2121
SContext(
22-
// const asset::IGeometryCreator* _geomCreator,
23-
// const asset::IMeshManipulator* _manipulator,
2422
const asset::IAssetLoader::SAssetLoadContext& _params,
2523
asset::IAssetLoader::IAssetLoaderOverride* _override,
2624
CMitsubaMetadata* _metadata
2725
);
2826

29-
using shape_ass_type = core::smart_refctd_ptr<asset::ICPUPolygonGeometry>;
27+
using shape_ass_type = core::smart_refctd_ptr<const asset::ICPUGeometryCollection>;
3028
shape_ass_type loadBasicShape(const uint32_t hierarchyLevel, const CElementShape* shape);
31-
using group_ass_type = core::smart_refctd_ptr<asset::ICPUGeometryCollection>;
32-
group_ass_type loadShapeGroup(const uint32_t hierarchyLevel, const CElementShape::ShapeGroup* shapegroup);
29+
// the `shape` will have to be `Type::SHAPEGROUP`
30+
shape_ass_type loadShapeGroup(const uint32_t hierarchyLevel, const CElementShape* shape);
3331

3432
inline void transferMetadata()
3533
{
36-
meta->setPolygonGeometryMeta(std::move(shapeCache));
34+
meta->setGeometryCollectionMeta(std::move(shapeCache));
35+
meta->setGeometryCollectionMeta(std::move(groupCache));
3736
}
3837

39-
// const asset::IGeometryCreator* creator;
40-
// const asset::IMeshManipulator* manipulator;
4138
const asset::IAssetLoader::SAssetLoadContext inner;
4239
asset::IAssetLoader::IAssetLoaderOverride* override_;
4340
CMitsubaMetadata* meta;
4441
core::smart_refctd_ptr<asset::ICPUScene> scene;
4542

4643
private:
4744
//
48-
core::unordered_map<const CElementShape::ShapeGroup*,group_ass_type> groupCache;
45+
core::unordered_map<const CElementShape*,CMitsubaMetadata::SGeometryCollectionMetaPair> shapeCache;
4946
//
50-
core::unordered_map<const CElementShape*,CMitsubaMetadata::SGeometryMetaPair> shapeCache;
47+
core::unordered_map<const CElementShape::ShapeGroup*,CMitsubaMetadata::SGeometryCollectionMetaPair> groupCache;
5148

5249
#if 0 // stuff that belongs in the Material Compiler backend
5350
//image, sampler

0 commit comments

Comments
 (0)