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

@@ -13,7 +13,6 @@
#include <utils/NameComponentManager.h>
#include "scene/GltfSceneAssetInstance.hpp"
#include "components/AnimationComponentManager.hpp"
#include "components/CollisionComponentManager.hpp"
@@ -49,6 +48,12 @@ namespace thermion
SceneAsset *createInstance(MaterialInstance **materialInstances = nullptr, size_t materialInstanceCount = 0) override;
void destroyInstance(SceneAsset *asset) override {
auto it = std::remove_if(_instances.begin(), _instances.end(), [=](auto &sceneAsset)
{ return sceneAsset.get() == asset; });
_instances.erase(it, _instances.end());
};
SceneAssetType getType() override
{
return SceneAsset::SceneAssetType::Gltf;
@@ -59,6 +64,10 @@ namespace thermion
return false;
}
SceneAsset *getInstanceOwner() override {
return std::nullptr_t();
}
utils::Entity getEntity() override
{
return _asset->getRoot();