From 943198e3251e6dffa3c007570e352d946c607f49 Mon Sep 17 00:00:00 2001 From: "florent.teppe" Date: Wed, 14 Sep 2022 13:20:35 +0200 Subject: [PATCH] Small changes --- components/debug/debugdraw.cpp | 13 ++++--------- components/debug/debugdraw.hpp | 3 ++- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/components/debug/debugdraw.cpp b/components/debug/debugdraw.cpp index ed16fbec08..6ee165c7ef 100644 --- a/components/debug/debugdraw.cpp +++ b/components/debug/debugdraw.cpp @@ -330,7 +330,7 @@ namespace Debug }; } -Debug::DebugDrawer::DebugDrawer(Shader::ShaderManager& shaderManager, osg::ref_ptr parentNode) +Debug::DebugDrawer::DebugDrawer(Shader::ShaderManager& shaderManager, osg::ref_ptr parentNode) : mParentNode(parentNode) { mCurrentFrame = 0; auto vertexShader = shaderManager.getShader("debug_vertex.glsl", Shader::ShaderManager::DefineMap(), osg::Shader::Type::VERTEX); @@ -376,17 +376,12 @@ Debug::DebugDrawer::DebugDrawer(Shader::ShaderManager& shaderManager, osg::ref_p } mDebugDrawSceneObjects->addCullCallback(new DebugDrawCallback(*this)); - parentNode->addChild(mDebugDrawSceneObjects); + mParentNode->addChild(mDebugDrawSceneObjects); } Debug::DebugDrawer::~DebugDrawer() { - auto parentsList = mDebugDrawSceneObjects->getParents(); - - for (auto parent : parentsList) - { - parent->removeChild(mDebugDrawSceneObjects); - } + mParentNode->removeChild(mDebugDrawSceneObjects); } void Debug::DebugDrawer::drawCube(osg::Vec3f mPosition, osg::Vec3f mDims, osg::Vec3f mColor) @@ -409,7 +404,7 @@ void Debug::DebugDrawer::addDrawCall(const DrawCall& draw) void Debug::DebugDrawer::addLine(const osg::Vec3& start, const osg::Vec3& end, const osg::Vec3 color) { const int indexWrite = getIdexBufferWriteFromFrame(mCurrentFrame); - auto lines = mCustomDebugDrawer[indexWrite]->mLinesToDraw; + const auto& lines = mCustomDebugDrawer[indexWrite]->mLinesToDraw; auto vertices = static_cast(lines->getVertexArray()); auto colors = static_cast(lines->getNormalArray()); diff --git a/components/debug/debugdraw.hpp b/components/debug/debugdraw.hpp index 7efbb1a373..842a1ab753 100644 --- a/components/debug/debugdraw.hpp +++ b/components/debug/debugdraw.hpp @@ -67,7 +67,7 @@ namespace Debug osg::ref_ptr mCylinderGeometry; osg::ref_ptr mWireCubeGeometry; - virtual void drawImplementation(osg::RenderInfo&) const; + virtual void drawImplementation(osg::RenderInfo&) const override; }; struct DebugDrawer @@ -87,6 +87,7 @@ namespace Debug std::array, 2> mCustomDebugDrawer; osg::ref_ptr mDebugDrawSceneObjects; + osg::ref_ptr mParentNode; }; } #endif // !