Graphics: Fix WorldInstance removal while being in use
This commit is contained in:
@@ -28,8 +28,7 @@ namespace Nz
|
||||
inline void DetachRenderable(const std::shared_ptr<InstancedRenderable>& renderable);
|
||||
|
||||
inline const std::vector<std::shared_ptr<InstancedRenderable>>& GetRenderables() const;
|
||||
inline WorldInstance& GetWorldInstance();
|
||||
inline const WorldInstance& GetWorldInstance() const;
|
||||
inline const WorldInstancePtr& GetWorldInstance() const;
|
||||
|
||||
GraphicsComponent& operator=(const GraphicsComponent&) = default;
|
||||
GraphicsComponent& operator=(GraphicsComponent&&) = default;
|
||||
@@ -39,7 +38,7 @@ namespace Nz
|
||||
|
||||
private:
|
||||
std::vector<std::shared_ptr<InstancedRenderable>> m_renderables;
|
||||
std::unique_ptr<WorldInstance> m_worldInstance;
|
||||
WorldInstancePtr m_worldInstance;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Nz
|
||||
{
|
||||
inline GraphicsComponent::GraphicsComponent()
|
||||
{
|
||||
m_worldInstance = std::make_unique<WorldInstance>(); //< FIXME
|
||||
m_worldInstance = std::make_shared<WorldInstance>(); //< FIXME: Use pools
|
||||
}
|
||||
|
||||
inline void GraphicsComponent::AttachRenderable(std::shared_ptr<InstancedRenderable> renderable)
|
||||
@@ -35,13 +35,8 @@ namespace Nz
|
||||
return m_renderables;
|
||||
}
|
||||
|
||||
inline WorldInstance& GraphicsComponent::GetWorldInstance()
|
||||
inline const WorldInstancePtr& GraphicsComponent::GetWorldInstance() const
|
||||
{
|
||||
return *m_worldInstance;
|
||||
}
|
||||
|
||||
inline const WorldInstance& GraphicsComponent::GetWorldInstance() const
|
||||
{
|
||||
return *m_worldInstance;
|
||||
return m_worldInstance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,12 +36,12 @@ namespace Nz
|
||||
void InvalidateViewer(AbstractViewer* viewerInstance) override;
|
||||
void InvalidateWorldInstance(WorldInstance* worldInstance) override;
|
||||
|
||||
void RegisterInstancedDrawable(WorldInstance* worldInstance, const InstancedRenderable* instancedRenderable) override;
|
||||
void RegisterInstancedDrawable(WorldInstancePtr worldInstance, const InstancedRenderable* instancedRenderable) override;
|
||||
void RegisterViewer(AbstractViewer* viewerInstance) override;
|
||||
|
||||
void Render(RenderFrame& renderFrame) override;
|
||||
|
||||
void UnregisterInstancedDrawable(WorldInstance* worldInstance, const InstancedRenderable* instancedRenderable) override;
|
||||
void UnregisterInstancedDrawable(const WorldInstancePtr& worldInstance, const InstancedRenderable* instancedRenderable) override;
|
||||
void UnregisterViewer(AbstractViewer* viewerInstance) override;
|
||||
|
||||
ForwardFramePipeline& operator=(const ForwardFramePipeline&) = delete;
|
||||
@@ -75,10 +75,11 @@ namespace Nz
|
||||
|
||||
std::unordered_map<AbstractViewer*, ViewerData> m_viewers;
|
||||
std::unordered_map<MaterialPass*, MaterialData> m_materials;
|
||||
std::unordered_map<WorldInstance*, std::unordered_map<const InstancedRenderable*, RenderableData>> m_renderables;
|
||||
std::unordered_map<WorldInstancePtr, std::unordered_map<const InstancedRenderable*, RenderableData>> m_renderables;
|
||||
std::unordered_set<AbstractViewer*> m_invalidatedViewerInstances;
|
||||
std::unordered_set<MaterialPass*> m_invalidatedMaterials;
|
||||
std::unordered_set<WorldInstance*> m_invalidatedWorldInstances;
|
||||
std::unordered_set<WorldInstancePtr> m_removedWorldInstances;
|
||||
std::vector<std::unique_ptr<RenderElement>> m_depthPrepassRenderElements;
|
||||
std::vector<std::unique_ptr<RenderElement>> m_forwardRenderElements;
|
||||
std::vector<std::unique_ptr<ElementRenderer>> m_elementRenderers;
|
||||
|
||||
@@ -9,13 +9,13 @@
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Graphics/Config.hpp>
|
||||
#include <Nazara/Graphics/WorldInstance.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class AbstractViewer;
|
||||
class InstancedRenderable;
|
||||
class RenderFrame;
|
||||
class WorldInstance;
|
||||
|
||||
class NAZARA_GRAPHICS_API FramePipeline
|
||||
{
|
||||
@@ -28,12 +28,12 @@ namespace Nz
|
||||
virtual void InvalidateViewer(AbstractViewer* viewerInstance) = 0;
|
||||
virtual void InvalidateWorldInstance(WorldInstance* worldInstance) = 0;
|
||||
|
||||
virtual void RegisterInstancedDrawable(WorldInstance* worldInstance, const InstancedRenderable* instancedRenderable) = 0;
|
||||
virtual void RegisterInstancedDrawable(WorldInstancePtr worldInstance, const InstancedRenderable* instancedRenderable) = 0;
|
||||
virtual void RegisterViewer(AbstractViewer* viewerInstance) = 0;
|
||||
|
||||
virtual void Render(RenderFrame& renderFrame) = 0;
|
||||
|
||||
virtual void UnregisterInstancedDrawable(WorldInstance* worldInstance, const InstancedRenderable* instancedRenderable) = 0;
|
||||
virtual void UnregisterInstancedDrawable(const WorldInstancePtr& worldInstance, const InstancedRenderable* instancedRenderable) = 0;
|
||||
virtual void UnregisterViewer(AbstractViewer* viewerInstance) = 0;
|
||||
|
||||
FramePipeline& operator=(const FramePipeline&) = delete;
|
||||
|
||||
@@ -19,6 +19,9 @@ namespace Nz
|
||||
class CommandBufferBuilder;
|
||||
class MaterialSettings;
|
||||
class UploadPool;
|
||||
class WorldInstance;
|
||||
|
||||
using WorldInstancePtr = std::shared_ptr<WorldInstance>;
|
||||
|
||||
class NAZARA_GRAPHICS_API WorldInstance
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user