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 */