Switch index/vertex count to UInt32

This commit is contained in:
SirLynix
2022-10-31 19:54:25 +01:00
parent dc6ce8427c
commit 6b8be23fa0
28 changed files with 129 additions and 128 deletions

View File

@@ -50,32 +50,32 @@ namespace Nz
SparsePtr<Vector2f> uvPtr;
};
NAZARA_UTILITY_API Boxf ComputeAABB(SparsePtr<const Vector3f> positionPtr, UInt64 vertexCount);
NAZARA_UTILITY_API void ComputeBoxIndexVertexCount(const Vector3ui& subdivision, UInt64* indexCount, UInt64* vertexCount);
NAZARA_UTILITY_API UInt64 ComputeCacheMissCount(IndexIterator indices, UInt64 indexCount);
NAZARA_UTILITY_API void ComputeConeIndexVertexCount(unsigned int subdivision, UInt64* indexCount, UInt64* vertexCount);
NAZARA_UTILITY_API void ComputeCubicSphereIndexVertexCount(unsigned int subdivision, UInt64* indexCount, UInt64* vertexCount);
NAZARA_UTILITY_API void ComputeIcoSphereIndexVertexCount(unsigned int recursionLevel, UInt64* indexCount, UInt64* vertexCount);
NAZARA_UTILITY_API void ComputePlaneIndexVertexCount(const Vector2ui& subdivision, UInt64* indexCount, UInt64* vertexCount);
NAZARA_UTILITY_API void ComputeUvSphereIndexVertexCount(unsigned int sliceCount, unsigned int stackCount, UInt64* indexCount, UInt64* vertexCount);
NAZARA_UTILITY_API Boxf ComputeAABB(SparsePtr<const Vector3f> positionPtr, UInt32 vertexCount);
NAZARA_UTILITY_API void ComputeBoxIndexVertexCount(const Vector3ui& subdivision, UInt32* indexCount, UInt32* vertexCount);
NAZARA_UTILITY_API UInt32 ComputeCacheMissCount(IndexIterator indices, UInt32 indexCount);
NAZARA_UTILITY_API void ComputeConeIndexVertexCount(unsigned int subdivision, UInt32* indexCount, UInt32* vertexCount);
NAZARA_UTILITY_API void ComputeCubicSphereIndexVertexCount(unsigned int subdivision, UInt32* indexCount, UInt32* vertexCount);
NAZARA_UTILITY_API void ComputeIcoSphereIndexVertexCount(unsigned int recursionLevel, UInt32* indexCount, UInt32* vertexCount);
NAZARA_UTILITY_API void ComputePlaneIndexVertexCount(const Vector2ui& subdivision, UInt32* indexCount, UInt32* vertexCount);
NAZARA_UTILITY_API void ComputeUvSphereIndexVertexCount(unsigned int sliceCount, unsigned int stackCount, UInt32* indexCount, UInt32* vertexCount);
NAZARA_UTILITY_API void GenerateBox(const Vector3f& lengths, const Vector3ui& subdivision, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb = nullptr, UInt64 indexOffset = 0);
NAZARA_UTILITY_API void GenerateCone(float length, float radius, unsigned int subdivision, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb = nullptr, UInt64 indexOffset = 0);
NAZARA_UTILITY_API void GenerateCubicSphere(float size, unsigned int subdivision, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb = nullptr, UInt64 indexOffset = 0);
NAZARA_UTILITY_API void GenerateIcoSphere(float size, unsigned int recursionLevel, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb = nullptr, UInt64 indexOffset = 0);
NAZARA_UTILITY_API void GeneratePlane(const Vector2ui& subdivision, const Vector2f& size, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb = nullptr, UInt64 indexOffset = 0);
NAZARA_UTILITY_API void GenerateUvSphere(float size, unsigned int sliceCount, unsigned int stackCount, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb = nullptr, UInt64 indexOffset = 0);
NAZARA_UTILITY_API void GenerateBox(const Vector3f& lengths, const Vector3ui& subdivision, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb = nullptr, UInt32 indexOffset = 0);
NAZARA_UTILITY_API void GenerateCone(float length, float radius, unsigned int subdivision, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb = nullptr, UInt32 indexOffset = 0);
NAZARA_UTILITY_API void GenerateCubicSphere(float size, unsigned int subdivision, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb = nullptr, UInt32 indexOffset = 0);
NAZARA_UTILITY_API void GenerateIcoSphere(float size, unsigned int recursionLevel, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb = nullptr, UInt32 indexOffset = 0);
NAZARA_UTILITY_API void GeneratePlane(const Vector2ui& subdivision, const Vector2f& size, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb = nullptr, UInt32 indexOffset = 0);
NAZARA_UTILITY_API void GenerateUvSphere(float size, unsigned int sliceCount, unsigned int stackCount, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb = nullptr, UInt32 indexOffset = 0);
NAZARA_UTILITY_API void OptimizeIndices(IndexIterator indices, UInt64 indexCount);
NAZARA_UTILITY_API void OptimizeIndices(IndexIterator indices, UInt32 indexCount);
NAZARA_UTILITY_API void SkinLinearBlend(const SkinningData& data, UInt64 startVertex, UInt64 vertexCount);
NAZARA_UTILITY_API void SkinLinearBlend(const SkinningData& data, UInt32 startVertex, UInt32 vertexCount);
inline Vector3f TransformPositionTRS(const Vector3f& transformTranslation, const Quaternionf& transformRotation, const Vector3f& transformScale, const Vector3f& position);
inline Vector3f TransformNormalTRS(const Quaternionf& transformRotation, const Vector3f& transformScale, const Vector3f& normal);
inline Quaternionf TransformRotationTRS(const Quaternionf& transformRotation, const Vector3f& transformScale, const Quaternionf& rotation);
inline Vector3f TransformScaleTRS(const Vector3f& transformScale, const Vector3f& scale);
inline void TransformTRS(const Vector3f& transformTranslation, const Quaternionf& transformRotation, const Vector3f& transformScale, Vector3f& position, Quaternionf& rotation, Vector3f& scale);
inline void TransformVertices(VertexPointers vertexPointers, UInt64 vertexCount, const Matrix4f& matrix);
inline void TransformVertices(VertexPointers vertexPointers, UInt32 vertexCount, const Matrix4f& matrix);
template<typename T> constexpr ComponentType ComponentTypeId();
template<typename T> constexpr ComponentType GetComponentTypeOf();

View File

@@ -35,11 +35,11 @@ namespace Nz
scale = TransformScaleTRS(transformScale, scale);
}
inline void TransformVertices(VertexPointers vertexPointers, UInt64 vertexCount, const Matrix4f& matrix)
inline void TransformVertices(VertexPointers vertexPointers, UInt32 vertexCount, const Matrix4f& matrix)
{
if (vertexPointers.positionPtr)
{
for (UInt64 i = 0; i < vertexCount; ++i)
for (UInt32 i = 0; i < vertexCount; ++i)
*vertexPointers.positionPtr++ = matrix.Transform(*vertexPointers.positionPtr);
}

View File

@@ -18,7 +18,7 @@ namespace Nz
IndexBuffer() = default;
IndexBuffer(IndexType indexType, std::shared_ptr<Buffer> buffer);
IndexBuffer(IndexType indexType, std::shared_ptr<Buffer> buffer, UInt64 offset, UInt64 size);
IndexBuffer(IndexType indexType, UInt64 indexCount, BufferUsageFlags usage, const BufferFactory& bufferFactory, const void* initialData = nullptr);
IndexBuffer(IndexType indexType, UInt32 indexCount, BufferUsageFlags usage, const BufferFactory& bufferFactory, const void* initialData = nullptr);
IndexBuffer(const IndexBuffer&) = default;
IndexBuffer(IndexBuffer&&) noexcept = default;
~IndexBuffer() = default;
@@ -30,7 +30,7 @@ namespace Nz
inline const std::shared_ptr<Buffer>& GetBuffer() const;
inline UInt64 GetEndOffset() const;
inline UInt64 GetIndexCount() const;
inline UInt32 GetIndexCount() const;
inline IndexType GetIndexType() const;
inline UInt64 GetStride() const;
inline UInt64 GetStartOffset() const;
@@ -52,7 +52,7 @@ namespace Nz
private:
std::shared_ptr<Buffer> m_buffer;
IndexType m_indexType;
UInt64 m_indexCount;
UInt32 m_indexCount;
UInt64 m_endOffset;
UInt64 m_startOffset;
};

View File

@@ -19,7 +19,7 @@ namespace Nz
return m_endOffset;
}
inline UInt64 IndexBuffer::GetIndexCount() const
inline UInt32 IndexBuffer::GetIndexCount() const
{
return m_indexCount;
}

View File

@@ -26,15 +26,15 @@ namespace Nz
Reference operator*() const;
Reference operator[](std::size_t index) const;
Reference operator[](UInt32 index) const;
IndexIterator& operator=(const IndexIterator& iterator);
IndexIterator operator+(std::size_t indexCount) const;
IndexIterator operator-(std::size_t indexCount) const;
IndexIterator operator+(UInt32 indexCount) const;
IndexIterator operator-(UInt32 indexCount) const;
IndexIterator& operator+=(std::size_t indexCount);
IndexIterator& operator-=(std::size_t indexCount);
IndexIterator& operator+=(UInt32 indexCount);
IndexIterator& operator-=(UInt32 indexCount);
IndexIterator& operator++();
IndexIterator operator++(int);
@@ -50,10 +50,10 @@ namespace Nz
friend bool operator>=(const IndexIterator& lhs, const IndexIterator& rhs);
private:
IndexIterator(IndexMapper* mapper, std::size_t index);
IndexIterator(IndexMapper* mapper, UInt32 index);
IndexMapper* m_mapper;
std::size_t m_index;
UInt32 m_index;
};
class IndexIterator::Reference
@@ -70,10 +70,10 @@ namespace Nz
operator UInt32() const;
private:
Reference(IndexMapper* mapper, std::size_t index);
Reference(IndexMapper* mapper, UInt32 index);
IndexMapper* m_mapper;
std::size_t m_index;
UInt32 m_index;
};
}

View File

@@ -21,7 +21,7 @@ namespace Nz
{
}
inline IndexIterator::IndexIterator(IndexMapper* mapper, std::size_t index) :
inline IndexIterator::IndexIterator(IndexMapper* mapper, UInt32 index) :
m_mapper(mapper),
m_index(index)
{
@@ -32,7 +32,7 @@ namespace Nz
return Reference(m_mapper, m_index);
}
inline IndexIterator::Reference IndexIterator::operator[](std::size_t index) const
inline IndexIterator::Reference IndexIterator::operator[](UInt32 index) const
{
return Reference(m_mapper, m_index+index);
}
@@ -45,24 +45,24 @@ namespace Nz
return *this;
}
inline IndexIterator IndexIterator::operator+(std::size_t indexCount) const
inline IndexIterator IndexIterator::operator+(UInt32 indexCount) const
{
return IndexIterator(m_mapper, m_index + indexCount);
}
inline IndexIterator IndexIterator::operator-(std::size_t indexCount) const
inline IndexIterator IndexIterator::operator-(UInt32 indexCount) const
{
return IndexIterator(m_mapper, m_index - indexCount);
}
inline IndexIterator& IndexIterator::operator+=(std::size_t indexCount)
inline IndexIterator& IndexIterator::operator+=(UInt32 indexCount)
{
m_index += indexCount;
return *this;
}
inline IndexIterator& IndexIterator::operator-=(std::size_t indexCount)
inline IndexIterator& IndexIterator::operator-=(UInt32 indexCount)
{
m_index += indexCount;
@@ -134,7 +134,7 @@ namespace Nz
/**************************IndexIterator::Reference*************************/
inline IndexIterator::Reference::Reference(IndexMapper* mapper, std::size_t index) :
inline IndexIterator::Reference::Reference(IndexMapper* mapper, UInt32 index) :
m_mapper(mapper),
m_index(index)
{

View File

@@ -19,13 +19,13 @@ namespace Nz
class NAZARA_UTILITY_API IndexMapper
{
public:
IndexMapper(IndexBuffer& indexBuffer, std::size_t indexCount = 0);
IndexMapper(IndexBuffer& indexBuffer, UInt32 indexCount = 0);
IndexMapper(SubMesh& subMes);
~IndexMapper() = default;
UInt32 Get(std::size_t i) const;
const IndexBuffer* GetBuffer() const;
std::size_t GetIndexCount() const;
UInt32 GetIndexCount() const;
void Set(std::size_t i, UInt32 value);
@@ -45,7 +45,7 @@ namespace Nz
BufferMapper<IndexBuffer> m_mapper;
Getter m_getter;
Setter m_setter;
std::size_t m_indexCount;
UInt32 m_indexCount;
};
}

View File

@@ -125,8 +125,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;
UInt64 GetTriangleCount() const;
UInt64 GetVertexCount() const;
UInt32 GetTriangleCount() const;
UInt32 GetVertexCount() const;
bool HasSubMesh(const std::string& identifier) const;
bool HasSubMesh(std::size_t index = 0) const;

View File

@@ -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;
UInt64 GetVertexCount() const override;
UInt32 GetVertexCount() const override;
bool IsAnimated() const final;
bool IsValid() const;

View File

@@ -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;
UInt64 GetVertexCount() const override;
UInt32 GetVertexCount() const override;
bool IsAnimated() const final;
bool IsValid() const;

View File

@@ -38,8 +38,8 @@ namespace Nz
virtual const std::shared_ptr<IndexBuffer>& GetIndexBuffer() const = 0;
std::size_t GetMaterialIndex() const;
PrimitiveMode GetPrimitiveMode() const;
UInt64 GetTriangleCount() const;
virtual UInt64 GetVertexCount() const = 0;
UInt32 GetTriangleCount() const;
virtual UInt32 GetVertexCount() const = 0;
virtual bool IsAnimated() const = 0;

View File

@@ -19,7 +19,7 @@ namespace Nz
VertexBuffer() = default;
VertexBuffer(std::shared_ptr<const VertexDeclaration> vertexDeclaration, std::shared_ptr<Buffer> buffer);
VertexBuffer(std::shared_ptr<const VertexDeclaration> vertexDeclaration, std::shared_ptr<Buffer> buffer, UInt64 offset, UInt64 size);
VertexBuffer(std::shared_ptr<const VertexDeclaration> vertexDeclaration, UInt64 vertexCount, BufferUsageFlags usage, const BufferFactory& bufferFactory, const void* initialData = nullptr);
VertexBuffer(std::shared_ptr<const VertexDeclaration> vertexDeclaration, UInt32 vertexCount, BufferUsageFlags usage, const BufferFactory& bufferFactory, const void* initialData = nullptr);
VertexBuffer(const VertexBuffer&) = default;
VertexBuffer(VertexBuffer&&) noexcept = default;
~VertexBuffer() = default;
@@ -31,7 +31,7 @@ namespace Nz
inline UInt64 GetEndOffset() const;
inline UInt64 GetStartOffset() const;
inline UInt64 GetStride() const;
inline UInt64 GetVertexCount() const;
inline UInt32 GetVertexCount() const;
inline const std::shared_ptr<const VertexDeclaration>& GetVertexDeclaration() const;
inline bool IsValid() const;
@@ -51,9 +51,9 @@ namespace Nz
private:
std::shared_ptr<Buffer> m_buffer;
std::shared_ptr<const VertexDeclaration> m_vertexDeclaration;
UInt32 m_vertexCount;
UInt64 m_endOffset;
UInt64 m_startOffset;
UInt64 m_vertexCount;
};
}

View File

@@ -28,7 +28,7 @@ namespace Nz
return m_startOffset;
}
inline UInt64 VertexBuffer::GetVertexCount() const
inline UInt32 VertexBuffer::GetVertexCount() const
{
return m_vertexCount;
}

View File

@@ -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 UInt64 GetVertexCount() const;
inline UInt32 GetVertexCount() const;
template<typename T> bool HasComponentOfType(VertexComponent component) const;

View File

@@ -26,7 +26,7 @@ namespace Nz
return m_mapper.GetBuffer();
}
inline UInt64 VertexMapper::GetVertexCount() const
inline UInt32 VertexMapper::GetVertexCount() const
{
return GetVertexBuffer()->GetVertexCount();
}