From 63ed1aaa51d9a1eaa632ad280a590ece398ff4a7 Mon Sep 17 00:00:00 2001 From: Lynix Date: Tue, 21 Jun 2016 19:14:29 +0200 Subject: [PATCH] Sdk/GraphicsComponent: Add Clear method Former-commit-id: dfa7a9813fe3e15212c16103763cb185e1d8df30 [formerly ead9d5788df957502aa22c526fa272f797348599] Former-commit-id: 74ce601066d7ab1d28609d6a859495e4626c7a18 --- SDK/include/NDK/Components/GraphicsComponent.hpp | 4 +++- SDK/include/NDK/Components/GraphicsComponent.inl | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NDK/Components/GraphicsComponent.hpp index f079303b8..aed427105 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NDK/Components/GraphicsComponent.hpp @@ -31,7 +31,9 @@ namespace Ndk inline void Attach(Nz::InstancedRenderableRef renderable, int renderOrder = 0); - inline void Detach(Nz::InstancedRenderableRef renderable); + inline void Clear(); + + inline void Detach(const Nz::InstancedRenderableRef& renderable); inline void EnsureBoundingVolumeUpdate() const; inline void EnsureTransformMatrixUpdate() const; diff --git a/SDK/include/NDK/Components/GraphicsComponent.inl b/SDK/include/NDK/Components/GraphicsComponent.inl index c736ecc48..9ca100d0e 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.inl +++ b/SDK/include/NDK/Components/GraphicsComponent.inl @@ -47,12 +47,20 @@ namespace Ndk InvalidateBoundingVolume(); } - inline void GraphicsComponent::Detach(Nz::InstancedRenderableRef renderable) + inline void GraphicsComponent::Clear() + { + m_renderables.clear(); + + InvalidateBoundingVolume(); + } + + inline void GraphicsComponent::Detach(const Nz::InstancedRenderableRef& renderable) { for (auto it = m_renderables.begin(); it != m_renderables.end(); ++it) { if (it->renderable == renderable) { + InvalidateBoundingVolume(); m_renderables.erase(it); break; }