From 3d15f3578bb67c721bdaae5c00e2f28df5e1c27c Mon Sep 17 00:00:00 2001 From: SirLynix Date: Sat, 23 Apr 2022 23:12:40 +0200 Subject: [PATCH] Utility: Use UInt64 to store index/vertex instead of size_t --- include/Nazara/Utility/Mesh.hpp | 4 ++-- include/Nazara/Utility/SkeletalMesh.hpp | 2 +- include/Nazara/Utility/StaticMesh.hpp | 2 +- include/Nazara/Utility/SubMesh.hpp | 4 ++-- include/Nazara/Utility/VertexMapper.hpp | 2 +- include/Nazara/Utility/VertexMapper.inl | 2 +- src/Nazara/Utility/Mesh.cpp | 8 ++++---- src/Nazara/Utility/SkeletalMesh.cpp | 2 +- src/Nazara/Utility/StaticMesh.cpp | 6 +++--- src/Nazara/Utility/SubMesh.cpp | 14 +++++++------- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/include/Nazara/Utility/Mesh.hpp b/include/Nazara/Utility/Mesh.hpp index 0bc543320..f0b6902a2 100644 --- a/include/Nazara/Utility/Mesh.hpp +++ b/include/Nazara/Utility/Mesh.hpp @@ -121,8 +121,8 @@ namespace Nz const std::shared_ptr& GetSubMesh(std::size_t index) const; std::size_t GetSubMeshCount() const; std::size_t GetSubMeshIndex(const std::string& identifier) const; - std::size_t GetTriangleCount() const; - std::size_t GetVertexCount() const; + UInt64 GetTriangleCount() const; + UInt64 GetVertexCount() const; bool HasSubMesh(const std::string& identifier) const; bool HasSubMesh(std::size_t index = 0) const; diff --git a/include/Nazara/Utility/SkeletalMesh.hpp b/include/Nazara/Utility/SkeletalMesh.hpp index 68931758a..578d500ae 100644 --- a/include/Nazara/Utility/SkeletalMesh.hpp +++ b/include/Nazara/Utility/SkeletalMesh.hpp @@ -24,7 +24,7 @@ namespace Nz AnimationType GetAnimationType() const final; const std::shared_ptr& GetIndexBuffer() const override; const std::shared_ptr& GetVertexBuffer() const; - std::size_t GetVertexCount() const override; + UInt64 GetVertexCount() const override; bool IsAnimated() const final; bool IsValid() const; diff --git a/include/Nazara/Utility/StaticMesh.hpp b/include/Nazara/Utility/StaticMesh.hpp index 1531260eb..99ae804af 100644 --- a/include/Nazara/Utility/StaticMesh.hpp +++ b/include/Nazara/Utility/StaticMesh.hpp @@ -26,7 +26,7 @@ namespace Nz AnimationType GetAnimationType() const final; const std::shared_ptr& GetIndexBuffer() const override; const std::shared_ptr& GetVertexBuffer() const; - std::size_t GetVertexCount() const override; + UInt64 GetVertexCount() const override; bool IsAnimated() const final; bool IsValid() const; diff --git a/include/Nazara/Utility/SubMesh.hpp b/include/Nazara/Utility/SubMesh.hpp index a478c50bb..3d547e6e2 100644 --- a/include/Nazara/Utility/SubMesh.hpp +++ b/include/Nazara/Utility/SubMesh.hpp @@ -37,8 +37,8 @@ namespace Nz virtual const std::shared_ptr& GetIndexBuffer() const = 0; std::size_t GetMaterialIndex() const; PrimitiveMode GetPrimitiveMode() const; - std::size_t GetTriangleCount() const; - virtual std::size_t GetVertexCount() const = 0; + UInt64 GetTriangleCount() const; + virtual UInt64 GetVertexCount() const = 0; virtual bool IsAnimated() const = 0; diff --git a/include/Nazara/Utility/VertexMapper.hpp b/include/Nazara/Utility/VertexMapper.hpp index c478a1f17..779d24e44 100644 --- a/include/Nazara/Utility/VertexMapper.hpp +++ b/include/Nazara/Utility/VertexMapper.hpp @@ -26,7 +26,7 @@ namespace Nz template SparsePtr GetComponentPtr(VertexComponent component, std::size_t componentIndex = 0); inline const VertexBuffer* GetVertexBuffer() const; - inline std::size_t GetVertexCount() const; + inline UInt64 GetVertexCount() const; template bool HasComponentOfType(VertexComponent component) const; diff --git a/include/Nazara/Utility/VertexMapper.inl b/include/Nazara/Utility/VertexMapper.inl index ba7a9bb27..5d9f68f3c 100644 --- a/include/Nazara/Utility/VertexMapper.inl +++ b/include/Nazara/Utility/VertexMapper.inl @@ -26,7 +26,7 @@ namespace Nz return m_mapper.GetBuffer(); } - inline std::size_t VertexMapper::GetVertexCount() const + inline UInt64 VertexMapper::GetVertexCount() const { return GetVertexBuffer()->GetVertexCount(); } diff --git a/src/Nazara/Utility/Mesh.cpp b/src/Nazara/Utility/Mesh.cpp index ced9ab264..99ba9a502 100644 --- a/src/Nazara/Utility/Mesh.cpp +++ b/src/Nazara/Utility/Mesh.cpp @@ -446,22 +446,22 @@ namespace Nz return it->second; } - std::size_t Mesh::GetTriangleCount() const + UInt64 Mesh::GetTriangleCount() const { NazaraAssert(m_isValid, "Mesh should be created first"); - std::size_t triangleCount = 0; + UInt64 triangleCount = 0; for (const SubMeshData& data : m_subMeshes) triangleCount += data.subMesh->GetTriangleCount(); return triangleCount; } - std::size_t Mesh::GetVertexCount() const + UInt64 Mesh::GetVertexCount() const { NazaraAssert(m_isValid, "Mesh should be created first"); - std::size_t vertexCount = 0; + UInt64 vertexCount = 0; for (const SubMeshData& data : m_subMeshes) vertexCount += data.subMesh->GetVertexCount(); diff --git a/src/Nazara/Utility/SkeletalMesh.cpp b/src/Nazara/Utility/SkeletalMesh.cpp index cc1cab05f..fe7297e18 100644 --- a/src/Nazara/Utility/SkeletalMesh.cpp +++ b/src/Nazara/Utility/SkeletalMesh.cpp @@ -36,7 +36,7 @@ namespace Nz return m_vertexBuffer; } - std::size_t SkeletalMesh::GetVertexCount() const + UInt64 SkeletalMesh::GetVertexCount() const { return m_vertexBuffer->GetVertexCount(); } diff --git a/src/Nazara/Utility/StaticMesh.cpp b/src/Nazara/Utility/StaticMesh.cpp index 26529f8ae..12992c42f 100644 --- a/src/Nazara/Utility/StaticMesh.cpp +++ b/src/Nazara/Utility/StaticMesh.cpp @@ -25,8 +25,8 @@ namespace Nz VertexMapper mapper(*m_vertexBuffer); SparsePtr position = mapper.GetComponentPtr(VertexComponent::Position); - std::size_t vertexCount = m_vertexBuffer->GetVertexCount(); - for (std::size_t i = 0; i < vertexCount; ++i) + UInt64 vertexCount = m_vertexBuffer->GetVertexCount(); + for (UInt64 i = 0; i < vertexCount; ++i) *position++ -= offset; m_aabb.x -= offset.x; @@ -63,7 +63,7 @@ namespace Nz return m_vertexBuffer; } - std::size_t StaticMesh::GetVertexCount() const + UInt64 StaticMesh::GetVertexCount() const { return m_vertexBuffer->GetVertexCount(); } diff --git a/src/Nazara/Utility/SubMesh.cpp b/src/Nazara/Utility/SubMesh.cpp index fd8e7d689..adec00da9 100644 --- a/src/Nazara/Utility/SubMesh.cpp +++ b/src/Nazara/Utility/SubMesh.cpp @@ -22,14 +22,14 @@ namespace Nz void SubMesh::GenerateNormals() { VertexMapper mapper(*this); - std::size_t vertexCount = mapper.GetVertexCount(); + UInt64 vertexCount = mapper.GetVertexCount(); SparsePtr normals = mapper.GetComponentPtr(VertexComponent::Normal); SparsePtr positions = mapper.GetComponentPtr(VertexComponent::Position); if (!normals || !positions) return; - for (std::size_t i = 0; i < vertexCount; ++i) + for (UInt64 i = 0; i < vertexCount; ++i) normals[i].MakeZero(); TriangleIterator iterator(*this); @@ -48,14 +48,14 @@ namespace Nz } while (iterator.Advance()); - for (std::size_t i = 0; i < vertexCount; ++i) + for (UInt64 i = 0; i < vertexCount; ++i) normals[i].Normalize(); } void SubMesh::GenerateNormalsAndTangents() { VertexMapper mapper(*this); - std::size_t vertexCount = mapper.GetVertexCount(); + UInt64 vertexCount = mapper.GetVertexCount(); SparsePtr normals = mapper.GetComponentPtr(VertexComponent::Normal); SparsePtr positions = mapper.GetComponentPtr(VertexComponent::Position); @@ -64,7 +64,7 @@ namespace Nz if (!normals || !positions || !tangents || !texCoords) return; - for (std::size_t i = 0; i < vertexCount; ++i) + for (UInt64 i = 0; i < vertexCount; ++i) { normals[i].MakeZero(); tangents[i].MakeZero(); @@ -159,10 +159,10 @@ namespace Nz return m_primitiveMode; } - std::size_t SubMesh::GetTriangleCount() const + UInt64 SubMesh::GetTriangleCount() const { const std::shared_ptr& indexBuffer = GetIndexBuffer(); - std::size_t indexCount; + UInt64 indexCount; if (indexBuffer) indexCount = indexBuffer->GetIndexCount(); else