From 995dfddafade30be02a1acc385d619418bd39639 Mon Sep 17 00:00:00 2001 From: Lynix Date: Thu, 19 Oct 2017 21:05:48 +0200 Subject: [PATCH] Utility/MeshParam: Use constref instead of pointer --- ChangeLog.md | 1 + include/Nazara/Utility/Mesh.hpp | 2 +- src/Nazara/Utility/Mesh.cpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 37b8811de..a3648ad14 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,6 +2,7 @@ Nazara Engine: - VertexMapper:GetComponentPtr no longer throw an error if component is disabled or incompatible with template type, instead a null pointer is returned. +- MeshParams now hold a ConstRef to the VertexDeclaration (preventing it to be freed before usage) # 0.4: diff --git a/include/Nazara/Utility/Mesh.hpp b/include/Nazara/Utility/Mesh.hpp index ca0971aa2..ebbb8130f 100644 --- a/include/Nazara/Utility/Mesh.hpp +++ b/include/Nazara/Utility/Mesh.hpp @@ -48,7 +48,7 @@ namespace Nz * If the declaration has a Vector3f Normals component enabled, Normals are generated. * If the declaration has a Vector3f Tangents component enabled, Tangents are generated. */ - VertexDeclaration* vertexDeclaration = VertexDeclaration::Get(VertexLayout_XYZ_Normal_UV_Tangent); + VertexDeclarationConstRef vertexDeclaration = VertexDeclaration::Get(VertexLayout_XYZ_Normal_UV_Tangent); bool IsValid() const; }; diff --git a/src/Nazara/Utility/Mesh.cpp b/src/Nazara/Utility/Mesh.cpp index 404330d3f..3861e389b 100644 --- a/src/Nazara/Utility/Mesh.cpp +++ b/src/Nazara/Utility/Mesh.cpp @@ -41,7 +41,7 @@ namespace Nz return false; } - if (vertexDeclaration == nullptr) + if (!vertexDeclaration) { NazaraError("The vertex declaration can't be null"); return false;