fix: allow destroying instances independently of owner

This commit is contained in:
Nick Fisher
2025-01-02 16:46:44 +08:00
parent 8e0ba8ac4e
commit 3e181b6aff
13 changed files with 141 additions and 91 deletions

View File

@@ -16,18 +16,20 @@ namespace thermion
class GeometrySceneAsset : public SceneAsset
{
public:
GeometrySceneAsset(bool isInstance,
Engine *engine,
GeometrySceneAsset(Engine *engine,
VertexBuffer *vertexBuffer,
IndexBuffer *indexBuffer,
MaterialInstance **materialInstances,
size_t materialInstanceCount,
RenderableManager::PrimitiveType primitiveType,
Box boundingBox);
Box boundingBox,
GeometrySceneAsset *instanceParent = std::nullptr_t());
~GeometrySceneAsset();
SceneAsset *createInstance(MaterialInstance **materialInstances = nullptr, size_t materialInstanceCount = 0) override;
void destroyInstance(SceneAsset *sceneAsset) override;
SceneAssetType getType() override
{
return SceneAsset::SceneAssetType::Geometry;
@@ -35,7 +37,11 @@ namespace thermion
bool isInstance() override
{
return _isInstance;
return _instanceOwner;
}
SceneAsset *getInstanceOwner() override {
return _instanceOwner;
}
utils::Entity getEntity() override
@@ -132,7 +138,7 @@ namespace thermion
MaterialInstance **_materialInstances = nullptr;
size_t _materialInstanceCount = 0;
Box _boundingBox;
bool _isInstance = false;
GeometrySceneAsset *_instanceOwner = std::nullptr_t();
utils::Entity _entity;
RenderableManager::PrimitiveType _primitiveType;
std::vector<std::unique_ptr<GeometrySceneAsset>> _instances;