From e3514db87fe1bd2dd64c60178aff7055cb8c0019 Mon Sep 17 00:00:00 2001 From: Lynix Date: Sat, 22 Apr 2017 17:11:42 +0200 Subject: [PATCH] Sdk/GraphicsComponent: Add methods to update local matrix and render order --- .../NDK/Components/GraphicsComponent.hpp | 3 +++ .../NDK/Components/GraphicsComponent.inl | 26 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NDK/Components/GraphicsComponent.hpp index cd62f9b2f..68961b99a 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NDK/Components/GraphicsComponent.hpp @@ -51,6 +51,9 @@ namespace Ndk inline void RemoveFromCullingList(GraphicsComponentCullingList* cullingList) const; + inline void UpdateLocalMatrix(const Nz::InstancedRenderable* instancedRenderable, const Nz::Matrix4f& localMatrix); + inline void UpdateRenderOrder(const Nz::InstancedRenderable* instancedRenderable, int renderOrder); + static ComponentIndex componentIndex; private: diff --git a/SDK/include/NDK/Components/GraphicsComponent.inl b/SDK/include/NDK/Components/GraphicsComponent.inl index e67b6f323..34bd57dd9 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.inl +++ b/SDK/include/NDK/Components/GraphicsComponent.inl @@ -142,6 +142,32 @@ namespace Ndk } } + inline void GraphicsComponent::UpdateLocalMatrix(const Nz::InstancedRenderable* instancedRenderable, const Nz::Matrix4f& localMatrix) + { + for (auto& renderable : m_renderables) + { + if (renderable.renderable == instancedRenderable) + { + renderable.data.localMatrix = localMatrix; + + InvalidateBoundingVolume(); + break; + } + } + } + + inline void GraphicsComponent::UpdateRenderOrder(const Nz::InstancedRenderable* instancedRenderable, int renderOrder) + { + for (auto& renderable : m_renderables) + { + if (renderable.renderable == instancedRenderable) + { + renderable.data.renderOrder = renderOrder; + break; + } + } + } + /*! * \brief Invalidates the bounding volume */