From 29f0d4ada51ff65c424398546e01e2884dba6ef3 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 14 Oct 2021 12:00:27 +0300 Subject: [PATCH] Adjust naming of instances in Scene loader I'm going to add inline nested scenes so a per-loader counter would get duplicates. --- source/render/scene.cpp | 7 ++++--- source/render/scene.h | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/source/render/scene.cpp b/source/render/scene.cpp index 75d1859b..4b7aee1a 100644 --- a/source/render/scene.cpp +++ b/source/render/scene.cpp @@ -89,10 +89,11 @@ Scene::GenericLoader::TypeRegistry &Scene::get_scene_registry() } +unsigned Scene::Loader::inline_counter = 0; + Scene::Loader::Loader(Scene &s, Collection &c, ContentMap *m): DataFile::CollectionObjectLoader(s, &c), - content(m), - inst_counter(0) + content(m) { add("object", &Loader::object); add("object", &Loader::object_tagged); @@ -108,7 +109,7 @@ void Scene::Loader::object_tagged(const string &n, const string &t) { RefPtr inst = new ObjectInstance(get_collection().get(n)); load_sub(*inst); - get_collection().add(format("%s/%d.inst", FS::basename(get_source()), inst_counter++), inst.get()); + get_collection().add(format("_scene_object_%d.inst", ++inline_counter), inst.get()); if(content && !t.empty()) (*content)[t] = inst.get(); obj.add(*inst.release()); diff --git a/source/render/scene.h b/source/render/scene.h index 80832393..96ecee97 100644 --- a/source/render/scene.h +++ b/source/render/scene.h @@ -25,7 +25,8 @@ protected: private: ContentMap *content; - unsigned inst_counter; + + static unsigned inline_counter; public: Loader(Scene &s, Collection &c): Loader(s, c, 0) { } -- 2.45.2