Graphics: Improve WorldInstance handling

This commit is contained in:
Jérôme Leclercq 2021-06-20 13:31:49 +02:00
parent 3ef3580ee7
commit 6f87a01fb2
5 changed files with 9 additions and 3 deletions

View File

@ -23,7 +23,7 @@ namespace Nz
InstancedRenderable(InstancedRenderable&&) noexcept = default; InstancedRenderable(InstancedRenderable&&) noexcept = default;
~InstancedRenderable(); ~InstancedRenderable();
virtual void Draw(CommandBufferBuilder& commandBuffer, WorldInstance& instance) const = 0; virtual void Draw(CommandBufferBuilder& commandBuffer, const WorldInstance& instance) const = 0;
InstancedRenderable& operator=(const InstancedRenderable&) = delete; InstancedRenderable& operator=(const InstancedRenderable&) = delete;
InstancedRenderable& operator=(InstancedRenderable&&) noexcept = default; InstancedRenderable& operator=(InstancedRenderable&&) noexcept = default;

View File

@ -28,7 +28,7 @@ namespace Nz
Model(Model&&) noexcept = default; Model(Model&&) noexcept = default;
~Model() = default; ~Model() = default;
void Draw(CommandBufferBuilder& commandBuffer, WorldInstance& instance) const override; void Draw(CommandBufferBuilder& commandBuffer, const WorldInstance& instance) const override;
const std::shared_ptr<AbstractBuffer>& GetIndexBuffer(std::size_t subMeshIndex) const; const std::shared_ptr<AbstractBuffer>& GetIndexBuffer(std::size_t subMeshIndex) const;
std::size_t GetIndexCount(std::size_t subMeshIndex) const; std::size_t GetIndexCount(std::size_t subMeshIndex) const;

View File

@ -31,6 +31,7 @@ namespace Nz
inline std::shared_ptr<AbstractBuffer>& GetInstanceBuffer(); inline std::shared_ptr<AbstractBuffer>& GetInstanceBuffer();
inline const std::shared_ptr<AbstractBuffer>& GetInstanceBuffer() const; inline const std::shared_ptr<AbstractBuffer>& GetInstanceBuffer() const;
inline ShaderBinding& GetShaderBinding(); inline ShaderBinding& GetShaderBinding();
inline const ShaderBinding& GetShaderBinding() const;
void UpdateBuffers(UploadPool& uploadPool, CommandBufferBuilder& builder); void UpdateBuffers(UploadPool& uploadPool, CommandBufferBuilder& builder);
inline void UpdateWorldMatrix(const Matrix4f& worldMatrix); inline void UpdateWorldMatrix(const Matrix4f& worldMatrix);

View File

@ -23,6 +23,11 @@ namespace Nz
return *m_shaderBinding; return *m_shaderBinding;
} }
inline const ShaderBinding& WorldInstance::GetShaderBinding() const
{
return *m_shaderBinding;
}
inline void WorldInstance::UpdateWorldMatrix(const Matrix4f& worldMatrix) inline void WorldInstance::UpdateWorldMatrix(const Matrix4f& worldMatrix)
{ {
m_worldMatrix = worldMatrix; m_worldMatrix = worldMatrix;

View File

@ -29,7 +29,7 @@ namespace Nz
} }
} }
void Model::Draw(CommandBufferBuilder& commandBuffer, WorldInstance& instance) const void Model::Draw(CommandBufferBuilder& commandBuffer, const WorldInstance& instance) const
{ {
commandBuffer.BindShaderBinding(Graphics::WorldBindingSet, instance.GetShaderBinding()); commandBuffer.BindShaderBinding(Graphics::WorldBindingSet, instance.GetShaderBinding());