Graphics/Model: Fix model not invalidating their bounding volume when their mesh AABB got updated

This commit is contained in:
Jérôme Leclercq
2018-05-03 13:32:53 +02:00
parent d94baf133b
commit d53c245c78
4 changed files with 26 additions and 6 deletions

View File

@@ -41,8 +41,8 @@ namespace Nz
public:
inline Model();
Model(const Model& model) = default;
Model(Model&& model) = default;
Model(const Model& model);
Model(Model&& model) = delete;
virtual ~Model();
void AddToRenderQueue(AbstractRenderQueue* renderQueue, const InstanceData& instanceData, const Recti& scissorRect) const override;
@@ -66,7 +66,7 @@ namespace Nz
virtual void SetMesh(Mesh* mesh);
Model& operator=(const Model& node) = default;
Model& operator=(Model&& node) = default;
Model& operator=(Model&& node) = delete;
template<typename... Args> static ModelRef New(Args&&... args);
@@ -75,6 +75,8 @@ namespace Nz
MeshRef m_mesh;
NazaraSlot(Mesh, OnMeshInvalidateAABB, m_meshAABBInvalidationSlot);
static ModelLoader::LoaderList s_loaders;
};
}

View File

@@ -2,6 +2,7 @@
// This file is part of the "Nazara Engine - Graphics module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Graphics/Model.hpp>
#include <memory>
#include <Nazara/Graphics/Debug.hpp>
@@ -10,11 +11,21 @@ namespace Nz
/*!
* \brief Constructs a Model object by default
*/
Model::Model()
inline Model::Model()
{
ResetMaterials(0);
}
/*!
* \brief Constructs a Model object by copying another
*
* \param model Model to copy
*/
inline Model::Model(const Model& model)
{
SetMesh(model.m_mesh);
}
/*!
* \brief Adds this model to a render queue, using user-specified transform matrix and render order
*
@@ -25,8 +36,8 @@ namespace Nz
* \param renderOrder Specify the render queue layer to be used
* \param scissorRect The Scissor rect to uses for rendering
*/
void Model::AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix, int renderOrder, const Recti& scissorRect) const
{
inline void Model::AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix, int renderOrder, const Recti& scissorRect) const
{
InstanceData instanceData(Nz::Matrix4f::Identity());
instanceData.renderOrder = renderOrder;
instanceData.transformMatrix = transformMatrix;