From 056bd0efdd47794a6ed6f9b1428f300dcd69bbff Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 6 Jun 2018 19:37:58 +0200 Subject: [PATCH] SDK/GraphicsComponent: Add ForEachRenderable method --- ChangeLog.md | 1 + SDK/include/NDK/Components/GraphicsComponent.hpp | 2 ++ SDK/include/NDK/Components/GraphicsComponent.inl | 12 ++++++++++++ 3 files changed, 15 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index d753cd450..dbf4dfa24 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -159,6 +159,7 @@ Nazara Development Kit: - ⚠️ TextAreaWidget::GetHoveredGlyph now returns a two-dimensional position instead of a single glyph position - Fixed Entity::OnEntityDestruction signal not being properly moved and thus not being called. - Fixed EntityOwner move assignment which was losing entity ownership +- Add GraphicsComponent:ForEachRenderable method # 0.4: diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NDK/Components/GraphicsComponent.hpp index e5dce0144..896e17c09 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NDK/Components/GraphicsComponent.hpp @@ -44,6 +44,8 @@ namespace Ndk inline bool DoesRequireRealTimeReflections() const; + template void ForEachRenderable(const Func& func) const; + 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 71b62f367..55e9706fb 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.inl +++ b/SDK/include/NDK/Components/GraphicsComponent.inl @@ -107,6 +107,18 @@ namespace Ndk return m_reflectiveMaterialCount != 0 && m_reflectionMap; } + /*! + * \brief Calls a function for every renderable attached to this component + * + * \param func Callback function which will be called with renderable data + */ + template + void GraphicsComponent::ForEachRenderable(const Func& func) const + { + for (const auto& renderableData : m_renderables) + func(renderableData.renderable, renderableData.data.localMatrix, renderableData.data.renderOrder); + } + /*! * \brief Ensures the bounding volume is up to date */