From 5b4185a4a63110766705b80d1f6e11a9188efd8c Mon Sep 17 00:00:00 2001 From: Lynix Date: Wed, 18 Oct 2017 00:20:38 +0200 Subject: [PATCH] Utility/VertexMapper: Add GetVertex[Buffer|Count] functions --- include/Nazara/Utility/VertexMapper.hpp | 3 +++ include/Nazara/Utility/VertexMapper.inl | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/include/Nazara/Utility/VertexMapper.hpp b/include/Nazara/Utility/VertexMapper.hpp index cfa27efe7..050bdf500 100644 --- a/include/Nazara/Utility/VertexMapper.hpp +++ b/include/Nazara/Utility/VertexMapper.hpp @@ -27,6 +27,9 @@ namespace Nz ~VertexMapper(); template SparsePtr GetComponentPtr(VertexComponent component); + inline const VertexBuffer* GetVertexBuffer() const; + inline UInt32 GetVertexCount() const; + template bool HasComponentOfType(VertexComponent component) const; void Unmap(); diff --git a/include/Nazara/Utility/VertexMapper.inl b/include/Nazara/Utility/VertexMapper.inl index 3c4a95959..93cc8c2d2 100644 --- a/include/Nazara/Utility/VertexMapper.inl +++ b/include/Nazara/Utility/VertexMapper.inl @@ -2,9 +2,10 @@ // This file is part of the "Nazara Engine - Utility module" // For conditions of distribution and use, see copyright notice in Config.hpp +#include +#include #include #include -#include namespace Nz { @@ -20,9 +21,10 @@ namespace Nz std::size_t offset; declaration->GetComponent(component, &enabled, &type, &offset); - if (enabled && GetComponentTypeOf() == type) + if (enabled) { - ///TODO: Vérifier le rapport entre le type de l'attribut et le type template ? + NazaraAssert(GetComponentTypeOf() == type, "Attribute type does not match template type"); + return SparsePtr(static_cast(m_mapper.GetPointer()) + offset, declaration->GetStride()); } else @@ -32,6 +34,16 @@ namespace Nz } } + inline const VertexBuffer* VertexMapper::GetVertexBuffer() const + { + return m_mapper.GetBuffer(); + } + + inline UInt32 VertexMapper::GetVertexCount() const + { + return GetVertexBuffer()->GetVertexCount(); + } + template bool VertexMapper::HasComponentOfType(VertexComponent component) const {