From 7a2a10b390e0f52f79828bd0fe22e9de29612d3d Mon Sep 17 00:00:00 2001 From: Lynix Date: Sun, 3 Aug 2014 20:58:09 +0200 Subject: [PATCH] Added VertexMapper constructor Removed useless headers Former-commit-id: e8925f48eec9c52dc4f2ad7bf6a61deb755bc0ee --- include/Nazara/Utility/VertexMapper.hpp | 6 +----- include/Nazara/Utility/VertexMapper.inl | 9 +++++++-- src/Nazara/Utility/VertexMapper.cpp | 13 ++++++++++--- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/include/Nazara/Utility/VertexMapper.hpp b/include/Nazara/Utility/VertexMapper.hpp index 446d1450d..a56ec0e3c 100644 --- a/include/Nazara/Utility/VertexMapper.hpp +++ b/include/Nazara/Utility/VertexMapper.hpp @@ -9,18 +9,15 @@ #include #include -#include -#include #include #include -#include -#include class NzSubMesh; class NAZARA_API NzVertexMapper { public: + NzVertexMapper(NzVertexBuffer* vertexBuffer, unsigned int vertexCount); NzVertexMapper(NzSubMesh* subMesh); ~NzVertexMapper(); @@ -31,7 +28,6 @@ class NAZARA_API NzVertexMapper private: NzBufferMapper m_mapper; - NzVertexDeclarationConstRef m_declaration; unsigned int m_vertexCount; }; diff --git a/include/Nazara/Utility/VertexMapper.inl b/include/Nazara/Utility/VertexMapper.inl index 19bfa18c6..cd7900430 100644 --- a/include/Nazara/Utility/VertexMapper.inl +++ b/include/Nazara/Utility/VertexMapper.inl @@ -3,19 +3,24 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include template NzSparsePtr NzVertexMapper::GetComponentPtr(nzVertexComponent component) { + // On récupère la déclaration depuis le buffer + const NzVertexDeclaration* declaration = m_mapper.GetBuffer()->GetVertexDeclaration(); + + // Ensuite le composant qui nous intéresse bool enabled; nzComponentType type; unsigned int offset; - m_declaration->GetComponent(component, &enabled, &type, &offset); + declaration->GetComponent(component, &enabled, &type, &offset); if (enabled) { ///TODO: Vérifier le rapport entre le type de l'attribut et le type template ? - return NzSparsePtr(static_cast(m_mapper.GetPointer()) + offset, m_declaration->GetStride()); + return NzSparsePtr(static_cast(m_mapper.GetPointer()) + offset, declaration->GetStride()); } else { diff --git a/src/Nazara/Utility/VertexMapper.cpp b/src/Nazara/Utility/VertexMapper.cpp index 08f257f2c..6b1b1ae42 100644 --- a/src/Nazara/Utility/VertexMapper.cpp +++ b/src/Nazara/Utility/VertexMapper.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include @@ -13,7 +12,8 @@ NzVertexMapper::NzVertexMapper(NzSubMesh* subMesh) { - NzErrorFlags flags(nzErrorFlag_ThrowException); + NzErrorFlags flags(nzErrorFlag_ThrowException, true); + NzVertexBuffer* buffer = nullptr; switch (subMesh->GetAnimationType()) { @@ -37,12 +37,19 @@ NzVertexMapper::NzVertexMapper(NzSubMesh* subMesh) NazaraInternalError("Animation type not handled (0x" + NzString::Number(subMesh->GetAnimationType(), 16) + ')'); } - m_declaration = buffer->GetVertexDeclaration(); m_vertexCount = subMesh->GetVertexCount(); m_mapper.Map(buffer, nzBufferAccess_ReadWrite); } +NzVertexMapper::NzVertexMapper(NzVertexBuffer* vertexBuffer, unsigned int vertexCount) +{ + NzErrorFlags flags(nzErrorFlag_ThrowException, true); + + m_mapper.Map(vertexBuffer, nzBufferAccess_ReadWrite); + m_vertexCount = vertexCount; +} + NzVertexMapper::~NzVertexMapper() = default; unsigned int NzVertexMapper::GetVertexCount() const