Utility: Use UInt64 to store index/vertex instead of size_t
This commit is contained in:
parent
8cd1f2d590
commit
3d15f3578b
|
|
@ -121,8 +121,8 @@ namespace Nz
|
|||
const std::shared_ptr<SubMesh>& 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;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ namespace Nz
|
|||
AnimationType GetAnimationType() const final;
|
||||
const std::shared_ptr<IndexBuffer>& GetIndexBuffer() const override;
|
||||
const std::shared_ptr<VertexBuffer>& GetVertexBuffer() const;
|
||||
std::size_t GetVertexCount() const override;
|
||||
UInt64 GetVertexCount() const override;
|
||||
|
||||
bool IsAnimated() const final;
|
||||
bool IsValid() const;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace Nz
|
|||
AnimationType GetAnimationType() const final;
|
||||
const std::shared_ptr<IndexBuffer>& GetIndexBuffer() const override;
|
||||
const std::shared_ptr<VertexBuffer>& GetVertexBuffer() const;
|
||||
std::size_t GetVertexCount() const override;
|
||||
UInt64 GetVertexCount() const override;
|
||||
|
||||
bool IsAnimated() const final;
|
||||
bool IsValid() const;
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@ namespace Nz
|
|||
virtual const std::shared_ptr<IndexBuffer>& 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;
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace Nz
|
|||
|
||||
template<typename T> SparsePtr<T> GetComponentPtr(VertexComponent component, std::size_t componentIndex = 0);
|
||||
inline const VertexBuffer* GetVertexBuffer() const;
|
||||
inline std::size_t GetVertexCount() const;
|
||||
inline UInt64 GetVertexCount() const;
|
||||
|
||||
template<typename T> bool HasComponentOfType(VertexComponent component) const;
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ namespace Nz
|
|||
return m_vertexBuffer;
|
||||
}
|
||||
|
||||
std::size_t SkeletalMesh::GetVertexCount() const
|
||||
UInt64 SkeletalMesh::GetVertexCount() const
|
||||
{
|
||||
return m_vertexBuffer->GetVertexCount();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ namespace Nz
|
|||
VertexMapper mapper(*m_vertexBuffer);
|
||||
SparsePtr<Vector3f> position = mapper.GetComponentPtr<Vector3f>(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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,14 +22,14 @@ namespace Nz
|
|||
void SubMesh::GenerateNormals()
|
||||
{
|
||||
VertexMapper mapper(*this);
|
||||
std::size_t vertexCount = mapper.GetVertexCount();
|
||||
UInt64 vertexCount = mapper.GetVertexCount();
|
||||
|
||||
SparsePtr<Vector3f> normals = mapper.GetComponentPtr<Vector3f>(VertexComponent::Normal);
|
||||
SparsePtr<Vector3f> positions = mapper.GetComponentPtr<Vector3f>(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<Vector3f> normals = mapper.GetComponentPtr<Vector3f>(VertexComponent::Normal);
|
||||
SparsePtr<Vector3f> positions = mapper.GetComponentPtr<Vector3f>(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<const IndexBuffer>& indexBuffer = GetIndexBuffer();
|
||||
std::size_t indexCount;
|
||||
UInt64 indexCount;
|
||||
if (indexBuffer)
|
||||
indexCount = indexBuffer->GetIndexCount();
|
||||
else
|
||||
|
|
|
|||
Loading…
Reference in New Issue