Graphics/ModelInstance: Add UpdateWorldMatrix method
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#define NAZARA_MODELINSTANCE_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
#include <Nazara/Graphics/Config.hpp>
|
||||
#include <Nazara/Renderer/ShaderBinding.hpp>
|
||||
#include <memory>
|
||||
@@ -15,7 +16,9 @@
|
||||
namespace Nz
|
||||
{
|
||||
class AbstractBuffer;
|
||||
class CommandBufferBuilder;
|
||||
class MaterialSettings;
|
||||
class UploadPool;
|
||||
|
||||
class NAZARA_GRAPHICS_API ModelInstance
|
||||
{
|
||||
@@ -29,12 +32,19 @@ namespace Nz
|
||||
inline const std::shared_ptr<AbstractBuffer>& GetInstanceBuffer() const;
|
||||
inline ShaderBinding& GetShaderBinding();
|
||||
|
||||
void UpdateBuffers(UploadPool& uploadPool, CommandBufferBuilder& builder);
|
||||
inline void UpdateWorldMatrix(const Matrix4f& worldMatrix);
|
||||
inline void UpdateWorldMatrix(const Matrix4f& worldMatrix, const Matrix4f& invWorldMatrix);
|
||||
|
||||
ModelInstance& operator=(const ModelInstance&) = delete;
|
||||
ModelInstance& operator=(ModelInstance&&) noexcept = default;
|
||||
|
||||
private:
|
||||
std::shared_ptr<AbstractBuffer> m_instanceDataBuffer;
|
||||
Matrix4f m_invWorldMatrix;
|
||||
Matrix4f m_worldMatrix;
|
||||
ShaderBindingPtr m_shaderBinding;
|
||||
bool m_dataInvalided;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Graphics/ModelInstance.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Graphics/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
@@ -21,6 +22,22 @@ namespace Nz
|
||||
{
|
||||
return *m_shaderBinding;
|
||||
}
|
||||
|
||||
inline void ModelInstance::UpdateWorldMatrix(const Matrix4f& worldMatrix)
|
||||
{
|
||||
m_worldMatrix = worldMatrix;
|
||||
if (!m_worldMatrix.GetInverseAffine(&m_invWorldMatrix))
|
||||
NazaraError("failed to inverse world matrix");
|
||||
|
||||
m_dataInvalided = true;
|
||||
}
|
||||
|
||||
inline void ModelInstance::UpdateWorldMatrix(const Matrix4f& worldMatrix, const Matrix4f& invWorldMatrix)
|
||||
{
|
||||
m_worldMatrix = worldMatrix;
|
||||
m_invWorldMatrix = invWorldMatrix;
|
||||
m_dataInvalided = true;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Graphics/DebugOff.hpp>
|
||||
|
||||
Reference in New Issue
Block a user