diff --git a/include/openspace/scene/scene.h b/include/openspace/scene/scene.h index 8458d33ec3..3f9f5e6d7e 100644 --- a/include/openspace/scene/scene.h +++ b/include/openspace/scene/scene.h @@ -81,12 +81,12 @@ public: /** * Attach node to the root */ - void attachNode(std::unique_ptr node); + void attachNode(ghoul::mm_unique_ptr node); /** * Detach node from the root */ - std::unique_ptr detachNode(SceneGraphNode& node); + ghoul::mm_unique_ptr detachNode(SceneGraphNode& node); /** * Set the camera of the scene diff --git a/include/openspace/scene/scenegraphnode.h b/include/openspace/scene/scenegraphnode.h index 67cb8add12..25a35417d7 100644 --- a/include/openspace/scene/scenegraphnode.h +++ b/include/openspace/scene/scenegraphnode.h @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -88,7 +89,7 @@ public: SceneGraphNode(); ~SceneGraphNode(); - static std::unique_ptr createFromDictionary( + static ghoul::mm_unique_ptr createFromDictionary( const ghoul::Dictionary& dictionary); void initialize(); @@ -101,8 +102,8 @@ public: void update(const UpdateData& data); void render(const RenderData& data, RendererTasks& tasks); - void attachChild(std::unique_ptr child); - std::unique_ptr detachChild(SceneGraphNode& child); + void attachChild(ghoul::mm_unique_ptr child); + ghoul::mm_unique_ptr detachChild(SceneGraphNode& child); void clearChildren(); void setParent(SceneGraphNode& parent); @@ -156,7 +157,7 @@ private: void computeScreenSpaceData(RenderData& newData); std::atomic _state = State::Loaded; - std::vector> _children; + std::vector> _children; SceneGraphNode* _parent = nullptr; std::vector _dependencies; std::vector _dependentNodes; diff --git a/include/openspace/util/memorymanager.h b/include/openspace/util/memorymanager.h index bf455be04d..94f42e55d8 100644 --- a/include/openspace/util/memorymanager.h +++ b/include/openspace/util/memorymanager.h @@ -31,7 +31,7 @@ namespace openspace { class MemoryManager { public: - ghoul::MemoryPool<10 * 1024, false> PersistentMemory; + ghoul::MemoryPool<2 * 1024 * 1024, false> PersistentMemory; ghoul::MemoryPool<10 * 1024, false> TemporaryMemory; }; diff --git a/modules/imgui/src/guimemorycomponent.cpp b/modules/imgui/src/guimemorycomponent.cpp index 5d1192aef6..edec044174 100644 --- a/modules/imgui/src/guimemorycomponent.cpp +++ b/modules/imgui/src/guimemorycomponent.cpp @@ -37,7 +37,14 @@ namespace { ImGui::Text("Number of Buckets: %i", p.nBuckets()); const std::vector& occupancies = p.occupancies(); for (size_t i = 0; i < occupancies.size(); ++i) { - ImGui::Text(" %i: %i/%i", i, occupancies[i], p.BucketSize); + ImGui::Text( + " %i: %i/%i (%.2f/%.2f kiB)", + i, + occupancies[i], + p.BucketSize, + occupancies[i] / 1024.f, + p.BucketSize / 1024.f + ); } } } // namespace diff --git a/src/scene/scene.cpp b/src/scene/scene.cpp index cbfed9a5b9..2878614a5d 100644 --- a/src/scene/scene.cpp +++ b/src/scene/scene.cpp @@ -90,11 +90,11 @@ Scene::~Scene() { _rootDummy.setScene(nullptr); } -void Scene::attachNode(std::unique_ptr node) { +void Scene::attachNode(ghoul::mm_unique_ptr node) { _rootDummy.attachChild(std::move(node)); } -std::unique_ptr Scene::detachNode(SceneGraphNode& node) { +ghoul::mm_unique_ptr Scene::detachNode(SceneGraphNode& node) { return _rootDummy.detachChild(node); } @@ -419,7 +419,7 @@ SceneGraphNode* Scene::loadNode(const ghoul::Dictionary& nodeDictionary) { } } - std::unique_ptr node = SceneGraphNode::createFromDictionary( + ghoul::mm_unique_ptr node = SceneGraphNode::createFromDictionary( nodeDictionary ); if (!node) { diff --git a/src/scene/scene_lua.inl b/src/scene/scene_lua.inl index 37aa928996..67ed7b2991 100644 --- a/src/scene/scene_lua.inl +++ b/src/scene/scene_lua.inl @@ -594,7 +594,9 @@ int removeSceneGraphNode(lua_State* L) { [&removeNode, &markedList](SceneGraphNode* localNode) { std::vector children = localNode->children(); - std::unique_ptr n = localNode->parent()->detachChild(*localNode); + ghoul::mm_unique_ptr n = localNode->parent()->detachChild( + *localNode + ); ghoul_assert(n.get() == localNode, "Wrong node returned from detaching"); for (SceneGraphNode* c : children) { diff --git a/src/scene/scenegraphnode.cpp b/src/scene/scenegraphnode.cpp index 3c9cffdd6e..ae6176981c 100644 --- a/src/scene/scenegraphnode.cpp +++ b/src/scene/scenegraphnode.cpp @@ -136,7 +136,7 @@ namespace openspace { int SceneGraphNode::nextIndex = 0; #endif // Debugging_Core_SceneGraphNode_Indices -std::unique_ptr SceneGraphNode::createFromDictionary( +ghoul::mm_unique_ptr SceneGraphNode::createFromDictionary( const ghoul::Dictionary& dictionary) { openspace::documentation::testSpecificationAndThrow( @@ -145,9 +145,9 @@ std::unique_ptr SceneGraphNode::createFromDictionary( "SceneGraphNode" ); - //SceneGraphNode* n = global::memoryManager.PersistentMemory.alloc(); - SceneGraphNode* n = new SceneGraphNode; - std::unique_ptr result = std::unique_ptr(n); + SceneGraphNode* n = global::memoryManager.PersistentMemory.alloc(); + //SceneGraphNode* n = new SceneGraphNode; + ghoul::mm_unique_ptr result = ghoul::mm_unique_ptr(n); #ifdef Debugging_Core_SceneGraphNode_Indices result->index = nextIndex++; @@ -420,13 +420,13 @@ void SceneGraphNode::deinitializeGL() { void SceneGraphNode::traversePreOrder(const std::function& fn) { fn(this); - for (std::unique_ptr& child : _children) { + for (ghoul::mm_unique_ptr& child : _children) { child->traversePreOrder(fn); } } void SceneGraphNode::traversePostOrder(const std::function& fn) { - for (std::unique_ptr& child : _children) { + for (ghoul::mm_unique_ptr& child : _children) { child->traversePostOrder(fn); } fn(this); @@ -588,7 +588,7 @@ void SceneGraphNode::setParent(SceneGraphNode& parent) { parent.attachChild(_parent->detachChild(*this)); } -void SceneGraphNode::attachChild(std::unique_ptr child) { +void SceneGraphNode::attachChild(ghoul::mm_unique_ptr child) { ghoul_assert(child != nullptr, "Child may not be null"); ghoul_assert(child->parent() == nullptr, "Child may not already have a parent"); @@ -601,7 +601,7 @@ void SceneGraphNode::attachChild(std::unique_ptr child) { childRaw->setScene(_scene); } -std::unique_ptr SceneGraphNode::detachChild(SceneGraphNode& child) { +ghoul::mm_unique_ptr SceneGraphNode::detachChild(SceneGraphNode& child) { ghoul_assert( child._dependentNodes.empty(), "Nodes cannot depend on a node being detached" @@ -611,7 +611,7 @@ std::unique_ptr SceneGraphNode::detachChild(SceneGraphNode& chil const auto iter = std::find_if( _children.begin(), _children.end(), - [&child] (const std::unique_ptr& c) { + [&child] (const ghoul::mm_unique_ptr& c) { return &child == c.get(); } ); @@ -631,7 +631,7 @@ std::unique_ptr SceneGraphNode::detachChild(SceneGraphNode& chil // Remove link between parent and child child._parent = nullptr; - std::unique_ptr c = std::move(*iter); + ghoul::mm_unique_ptr c = std::move(*iter); _children.erase(iter); return c; @@ -641,7 +641,7 @@ void SceneGraphNode::clearChildren() { traversePreOrder([](SceneGraphNode* node) { node->clearDependencies(); }); - for (const std::unique_ptr& c : _children) { + for (const ghoul::mm_unique_ptr& c : _children) { if (_scene) { c->setScene(nullptr); } @@ -934,7 +934,7 @@ void SceneGraphNode::setScene(Scene* scene) { std::vector SceneGraphNode::children() const { std::vector nodes; - for (const std::unique_ptr& child : _children) { + for (const ghoul::mm_unique_ptr& child : _children) { nodes.push_back(child.get()); } return nodes; @@ -962,7 +962,7 @@ SceneGraphNode* SceneGraphNode::childNode(const std::string& id) { return this; } else { - for (std::unique_ptr& it : _children) { + for (ghoul::mm_unique_ptr& it : _children) { SceneGraphNode* tmp = it->childNode(id); if (tmp) { return tmp;