From 1b3cf51d6d2644ca520c8a29d890a3b1ea7715f5 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 7 Jul 2016 18:07:43 +0200 Subject: [PATCH 1/2] Ndk/GraphicsComponent: Add GetAttachedRenderables Former-commit-id: 8668ac5a0684b27740cf67caaedc0dad22b6489f [formerly 6a0ea4747d98b53aa30e8a68a0c1d752c902acfe] Former-commit-id: 9291bad16c33dc5fe117e63a2fcb459b38c70a65 --- SDK/include/NDK/Components/GraphicsComponent.hpp | 5 +++++ SDK/include/NDK/Components/GraphicsComponent.inl | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NDK/Components/GraphicsComponent.hpp index aed427105..4ea76d0d8 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NDK/Components/GraphicsComponent.hpp @@ -23,6 +23,8 @@ namespace Ndk friend class RenderSystem; public: + using RenderableList = std::vector; + GraphicsComponent() = default; inline GraphicsComponent(const GraphicsComponent& graphicsComponent); ~GraphicsComponent() = default; @@ -38,6 +40,9 @@ namespace Ndk inline void EnsureBoundingVolumeUpdate() const; inline void EnsureTransformMatrixUpdate() const; + inline void GetAttachedRenderables(Nz::InstancedRenderableRef* renderables) const; + inline std::size_t GetAttachedRenderableCount() const; + inline const Nz::BoundingVolumef& GetBoundingVolume() const; static ComponentIndex componentIndex; diff --git a/SDK/include/NDK/Components/GraphicsComponent.inl b/SDK/include/NDK/Components/GraphicsComponent.inl index 9ca100d0e..b38ce6dd6 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.inl +++ b/SDK/include/NDK/Components/GraphicsComponent.inl @@ -79,6 +79,20 @@ namespace Ndk UpdateTransformMatrix(); } + inline void GraphicsComponent::GetAttachedRenderables(RenderableList* renderables) const + { + NazaraAssert(renderables, "Invalid renderable list"); + + renderables->reserve(renderables->size() + m_renderables.size()); + for (const Renderable& r : m_renderables) + renderables->push_back(r.renderable); + } + + inline std::size_t GraphicsComponent::GetAttachedRenderableCount() const + { + return m_renderables.size(); + } + inline const Nz::BoundingVolumef& GraphicsComponent::GetBoundingVolume() const { EnsureBoundingVolumeUpdate(); From 5ba73bf379d4160ac145456f6f080b19617e77f3 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 7 Jul 2016 18:17:18 +0200 Subject: [PATCH 2/2] Fix typo Former-commit-id: 035f2fbce2bec447f0a1b08dd5e590de5a098a7c [formerly 970c0e10c43e7d0ea2e7818382ef2667e3bd61dc] Former-commit-id: ddc449ede5f389146a73e461542fc3779039b305 --- SDK/include/NDK/Components/GraphicsComponent.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SDK/include/NDK/Components/GraphicsComponent.hpp b/SDK/include/NDK/Components/GraphicsComponent.hpp index 4ea76d0d8..a7ac3ebc2 100644 --- a/SDK/include/NDK/Components/GraphicsComponent.hpp +++ b/SDK/include/NDK/Components/GraphicsComponent.hpp @@ -40,7 +40,7 @@ namespace Ndk inline void EnsureBoundingVolumeUpdate() const; inline void EnsureTransformMatrixUpdate() const; - inline void GetAttachedRenderables(Nz::InstancedRenderableRef* renderables) const; + inline void GetAttachedRenderables(RenderableList* renderables) const; inline std::size_t GetAttachedRenderableCount() const; inline const Nz::BoundingVolumef& GetBoundingVolume() const;