Sdk/GraphicsComponent: Add Detach method

Former-commit-id: 16bcd7d8a3b50235cdd50443d8a1ed55e4b939f2 [formerly 93e838eebb955d5bbe17113ced86a247122bf522]
Former-commit-id: be3d0d2e8fb9a887eb903c6b17f16a56e5eee1c7
This commit is contained in:
Lynix
2016-06-20 13:11:31 +02:00
parent 84039cd78a
commit 04e52caa88
10 changed files with 56 additions and 12 deletions

View File

@@ -31,6 +31,8 @@ namespace Ndk
inline void Attach(Nz::InstancedRenderableRef renderable, int renderOrder = 0);
inline void Detach(Nz::InstancedRenderableRef renderable);
inline void EnsureBoundingVolumeUpdate() const;
inline void EnsureTransformMatrixUpdate() const;
@@ -63,6 +65,22 @@ namespace Ndk
{
}
Renderable(Renderable&& renderable) noexcept :
data(std::move(renderable.data)),
renderable(std::move(renderable.renderable)),
dataUpdated(renderable.dataUpdated)
{
}
Renderable& operator=(Renderable&& r) noexcept
{
data = std::move(r.data);
dataUpdated = r.dataUpdated;
renderable = std::move(r.renderable);
return *this;
}
NazaraSlot(Nz::InstancedRenderable, OnInstancedRenderableInvalidateData, renderableInvalidationSlot);
mutable Nz::InstancedRenderable::InstanceData data;

View File

@@ -3,6 +3,7 @@
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
#include <algorithm>
#include "GraphicsComponent.hpp"
namespace Ndk
{
@@ -46,6 +47,18 @@ namespace Ndk
InvalidateBoundingVolume();
}
inline void GraphicsComponent::Detach(Nz::InstancedRenderableRef renderable)
{
for (auto it = m_renderables.begin(); it != m_renderables.end(); ++it)
{
if (it->renderable == renderable)
{
m_renderables.erase(it);
break;
}
}
}
inline void GraphicsComponent::EnsureBoundingVolumeUpdate() const
{
if (!m_boundingVolumeUpdated)