Graphics/GraphicsComponent: Add visibility control
This commit is contained in:
@@ -7,7 +7,8 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
inline GraphicsComponent::GraphicsComponent()
|
||||
inline GraphicsComponent::GraphicsComponent(bool initialyVisible) :
|
||||
m_isVisible(initialyVisible)
|
||||
{
|
||||
m_worldInstance = std::make_shared<WorldInstance>(); //< FIXME: Use pools
|
||||
}
|
||||
@@ -21,6 +22,14 @@ namespace Nz
|
||||
OnRenderableAttached(this, m_renderables.back());
|
||||
}
|
||||
|
||||
inline void GraphicsComponent::Clear()
|
||||
{
|
||||
for (const auto& renderable : m_renderables)
|
||||
OnRenderableDetach(this, renderable);
|
||||
|
||||
m_renderables.clear();
|
||||
}
|
||||
|
||||
inline void GraphicsComponent::DetachRenderable(const std::shared_ptr<InstancedRenderable>& renderable)
|
||||
{
|
||||
auto it = std::find_if(m_renderables.begin(), m_renderables.end(), [&](const auto& renderableEntry) { return renderableEntry.renderable == renderable; });
|
||||
@@ -41,6 +50,25 @@ namespace Nz
|
||||
{
|
||||
return m_worldInstance;
|
||||
}
|
||||
|
||||
inline void GraphicsComponent::Hide()
|
||||
{
|
||||
return Show(false);
|
||||
}
|
||||
|
||||
inline bool GraphicsComponent::IsVisible() const
|
||||
{
|
||||
return m_isVisible;
|
||||
}
|
||||
|
||||
inline void GraphicsComponent::Show(bool show)
|
||||
{
|
||||
if (m_isVisible != show)
|
||||
{
|
||||
OnVisibilityUpdate(this, show);
|
||||
m_isVisible = show;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Graphics/DebugOff.hpp>
|
||||
|
||||
Reference in New Issue
Block a user