diff --git a/examples/RenderTest/main.cpp b/examples/RenderTest/main.cpp index 429ab4abb..be9c4d324 100644 --- a/examples/RenderTest/main.cpp +++ b/examples/RenderTest/main.cpp @@ -284,7 +284,7 @@ int main() case Nz::WindowEventType::Resized: { - Nz::Vector2ui windowSize = window.GetSize(); + windowSize = window.GetSize(); ubo.projectionMatrix = Nz::Matrix4f::Perspective(Nz::DegreeAnglef(70.f), float(windowSize.x) / windowSize.y, 0.1f, 1000.f); uboUpdate = true; break; diff --git a/include/Nazara/Utility/Algorithm.hpp b/include/Nazara/Utility/Algorithm.hpp index 6b4587d10..02cc5af4b 100644 --- a/include/Nazara/Utility/Algorithm.hpp +++ b/include/Nazara/Utility/Algorithm.hpp @@ -50,32 +50,32 @@ namespace Nz SparsePtr uvPtr; }; - NAZARA_UTILITY_API Boxf ComputeAABB(SparsePtr 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 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 constexpr ComponentType ComponentTypeId(); template constexpr ComponentType GetComponentTypeOf(); diff --git a/include/Nazara/Utility/Algorithm.inl b/include/Nazara/Utility/Algorithm.inl index 896b23d50..2a39b109b 100644 --- a/include/Nazara/Utility/Algorithm.inl +++ b/include/Nazara/Utility/Algorithm.inl @@ -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); } diff --git a/include/Nazara/Utility/IndexBuffer.hpp b/include/Nazara/Utility/IndexBuffer.hpp index a9c95f6b9..e87202930 100644 --- a/include/Nazara/Utility/IndexBuffer.hpp +++ b/include/Nazara/Utility/IndexBuffer.hpp @@ -18,7 +18,7 @@ namespace Nz IndexBuffer() = default; IndexBuffer(IndexType indexType, std::shared_ptr buffer); IndexBuffer(IndexType indexType, std::shared_ptr 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& 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 m_buffer; IndexType m_indexType; - UInt64 m_indexCount; + UInt32 m_indexCount; UInt64 m_endOffset; UInt64 m_startOffset; }; diff --git a/include/Nazara/Utility/IndexBuffer.inl b/include/Nazara/Utility/IndexBuffer.inl index 699ff816d..c0ae587bc 100644 --- a/include/Nazara/Utility/IndexBuffer.inl +++ b/include/Nazara/Utility/IndexBuffer.inl @@ -19,7 +19,7 @@ namespace Nz return m_endOffset; } - inline UInt64 IndexBuffer::GetIndexCount() const + inline UInt32 IndexBuffer::GetIndexCount() const { return m_indexCount; } diff --git a/include/Nazara/Utility/IndexIterator.hpp b/include/Nazara/Utility/IndexIterator.hpp index 0db02f5d6..4f61f8100 100644 --- a/include/Nazara/Utility/IndexIterator.hpp +++ b/include/Nazara/Utility/IndexIterator.hpp @@ -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; }; } diff --git a/include/Nazara/Utility/IndexIterator.inl b/include/Nazara/Utility/IndexIterator.inl index 316e2a696..7d653704d 100644 --- a/include/Nazara/Utility/IndexIterator.inl +++ b/include/Nazara/Utility/IndexIterator.inl @@ -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) { diff --git a/include/Nazara/Utility/IndexMapper.hpp b/include/Nazara/Utility/IndexMapper.hpp index be1f81ba6..cc0c0f9d7 100644 --- a/include/Nazara/Utility/IndexMapper.hpp +++ b/include/Nazara/Utility/IndexMapper.hpp @@ -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 m_mapper; Getter m_getter; Setter m_setter; - std::size_t m_indexCount; + UInt32 m_indexCount; }; } diff --git a/include/Nazara/Utility/Mesh.hpp b/include/Nazara/Utility/Mesh.hpp index 928a08eba..6286e5849 100644 --- a/include/Nazara/Utility/Mesh.hpp +++ b/include/Nazara/Utility/Mesh.hpp @@ -125,8 +125,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; - 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; diff --git a/include/Nazara/Utility/SkeletalMesh.hpp b/include/Nazara/Utility/SkeletalMesh.hpp index 578d500ae..1d2e45f50 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; - UInt64 GetVertexCount() const override; + UInt32 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 99ae804af..0f001d0c9 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; - UInt64 GetVertexCount() const override; + UInt32 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 1b5815086..72acfe5e8 100644 --- a/include/Nazara/Utility/SubMesh.hpp +++ b/include/Nazara/Utility/SubMesh.hpp @@ -38,8 +38,8 @@ namespace Nz virtual const std::shared_ptr& 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; diff --git a/include/Nazara/Utility/VertexBuffer.hpp b/include/Nazara/Utility/VertexBuffer.hpp index 0f0d064ca..e6aaaa845 100644 --- a/include/Nazara/Utility/VertexBuffer.hpp +++ b/include/Nazara/Utility/VertexBuffer.hpp @@ -19,7 +19,7 @@ namespace Nz VertexBuffer() = default; VertexBuffer(std::shared_ptr vertexDeclaration, std::shared_ptr buffer); VertexBuffer(std::shared_ptr vertexDeclaration, std::shared_ptr buffer, UInt64 offset, UInt64 size); - VertexBuffer(std::shared_ptr vertexDeclaration, UInt64 vertexCount, BufferUsageFlags usage, const BufferFactory& bufferFactory, const void* initialData = nullptr); + VertexBuffer(std::shared_ptr 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& GetVertexDeclaration() const; inline bool IsValid() const; @@ -51,9 +51,9 @@ namespace Nz private: std::shared_ptr m_buffer; std::shared_ptr m_vertexDeclaration; + UInt32 m_vertexCount; UInt64 m_endOffset; UInt64 m_startOffset; - UInt64 m_vertexCount; }; } diff --git a/include/Nazara/Utility/VertexBuffer.inl b/include/Nazara/Utility/VertexBuffer.inl index 45dc92abb..1593ae09c 100644 --- a/include/Nazara/Utility/VertexBuffer.inl +++ b/include/Nazara/Utility/VertexBuffer.inl @@ -28,7 +28,7 @@ namespace Nz return m_startOffset; } - inline UInt64 VertexBuffer::GetVertexCount() const + inline UInt32 VertexBuffer::GetVertexCount() const { return m_vertexCount; } diff --git a/include/Nazara/Utility/VertexMapper.hpp b/include/Nazara/Utility/VertexMapper.hpp index 7387e48fa..c7ccfea5a 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 UInt64 GetVertexCount() const; + inline UInt32 GetVertexCount() const; template bool HasComponentOfType(VertexComponent component) const; diff --git a/include/Nazara/Utility/VertexMapper.inl b/include/Nazara/Utility/VertexMapper.inl index 5d9f68f3c..f94bcd7f5 100644 --- a/include/Nazara/Utility/VertexMapper.inl +++ b/include/Nazara/Utility/VertexMapper.inl @@ -26,7 +26,7 @@ namespace Nz return m_mapper.GetBuffer(); } - inline UInt64 VertexMapper::GetVertexCount() const + inline UInt32 VertexMapper::GetVertexCount() const { return GetVertexBuffer()->GetVertexCount(); } diff --git a/plugins/FFmpeg/Plugin.cpp b/plugins/FFmpeg/Plugin.cpp index 0a6c03e64..adaa1f037 100644 --- a/plugins/FFmpeg/Plugin.cpp +++ b/plugins/FFmpeg/Plugin.cpp @@ -276,6 +276,7 @@ namespace void Seek(Nz::UInt64 frameIndex) override { + // TODO avio_seek(m_ioContext, 0, SEEK_SET); avformat_seek_file(m_formatContext, m_videoStream, std::numeric_limits::min(), 0, std::numeric_limits::max(), 0); } diff --git a/src/Nazara/Physics3D/Collider3D.cpp b/src/Nazara/Physics3D/Collider3D.cpp index 3e2a68882..8afe475b6 100644 --- a/src/Nazara/Physics3D/Collider3D.cpp +++ b/src/Nazara/Physics3D/Collider3D.cpp @@ -169,7 +169,7 @@ namespace Nz } }); - std::shared_ptr colliderVB = std::make_shared(VertexDeclaration::Get(VertexLayout::XYZ), colliderVertices.size(), BufferUsage::Write, SoftwareBufferFactory, colliderVertices.data()); + std::shared_ptr colliderVB = std::make_shared(VertexDeclaration::Get(VertexLayout::XYZ), SafeCast(colliderVertices.size()), BufferUsage::Write, SoftwareBufferFactory, colliderVertices.data()); std::shared_ptr colliderIB = std::make_shared(IndexType::U16, colliderIndices.size(), BufferUsage::Write, SoftwareBufferFactory, colliderIndices.data()); std::shared_ptr colliderSubMesh = std::make_shared(std::move(colliderVB), std::move(colliderIB)); diff --git a/src/Nazara/Utility/AlgorithmUtility.cpp b/src/Nazara/Utility/AlgorithmUtility.cpp index bc979c840..4a5cde493 100644 --- a/src/Nazara/Utility/AlgorithmUtility.cpp +++ b/src/Nazara/Utility/AlgorithmUtility.cpp @@ -217,11 +217,11 @@ namespace Nz Clear(); } - VertexCache(IndexIterator indices, UInt64 indexCount) + VertexCache(IndexIterator indices, UInt32 indexCount) { Clear(); - for (UInt64 i = 0; i < indexCount; ++i) + for (UInt32 i = 0; i < indexCount; ++i) AddVertex(*indices++); } @@ -252,7 +252,7 @@ namespace Nz m_misses = 0; } - UInt64 GetMissCount() const + UInt32 GetMissCount() const { return m_misses; } @@ -281,7 +281,7 @@ namespace Nz } std::array m_cache; - UInt64 m_misses; // cache miss count + UInt32 m_misses; // cache miss count }; class VertexCacheOptimizer @@ -306,7 +306,7 @@ namespace Nz } // stores new indices in place - Result Optimize(IndexIterator indices, UInt64 indexCount) + Result Optimize(IndexIterator indices, UInt32 indexCount) { if (indexCount == 0) return Fail_NoVerts; @@ -426,7 +426,7 @@ namespace Nz return Success; } - Result Init(IndexIterator indices, UInt64 indexCount, UInt64 vertexCount) + Result Init(IndexIterator indices, UInt32 indexCount, UInt32 vertexCount) { // clear the draw list m_drawList.clear(); @@ -436,7 +436,7 @@ namespace Nz m_vertices.resize(vertexCount); m_triangles.clear(); - for (UInt64 i = 0; i < indexCount; i += 3) + for (UInt32 i = 0; i < indexCount; i += 3) { TriangleCacheData dat; for (unsigned int j = 0; j < 3; ++j) @@ -447,7 +447,7 @@ namespace Nz // copy the indices m_indices.resize(indexCount); - for (UInt64 i = 0; i < indexCount; ++i) + for (UInt32 i = 0; i < indexCount; ++i) m_indices[i] = indices[i]; m_vertexCache.Clear(); @@ -633,7 +633,7 @@ namespace Nz /**********************************Compute**********************************/ - Boxf ComputeAABB(SparsePtr positionPtr, UInt64 vertexCount) + Boxf ComputeAABB(SparsePtr positionPtr, UInt32 vertexCount) { Boxf aabb; if (vertexCount > 0) @@ -641,7 +641,7 @@ namespace Nz aabb.Set(positionPtr->x, positionPtr->y, positionPtr->z, 0.f, 0.f, 0.f); ++positionPtr; - for (UInt64 i = 1; i < vertexCount; ++i) + for (UInt32 i = 1; i < vertexCount; ++i) aabb.ExtendTo(*positionPtr++); } else @@ -650,10 +650,10 @@ namespace Nz return aabb; } - void ComputeBoxIndexVertexCount(const Vector3ui& subdivision, UInt64* indexCount, UInt64* vertexCount) + void ComputeBoxIndexVertexCount(const Vector3ui& subdivision, UInt32* indexCount, UInt32* vertexCount) { - UInt64 xIndexCount, yIndexCount, zIndexCount; - UInt64 xVertexCount, yVertexCount, zVertexCount; + UInt32 xIndexCount, yIndexCount, zIndexCount; + UInt32 xVertexCount, yVertexCount, zVertexCount; ComputePlaneIndexVertexCount(Vector2ui(subdivision.y, subdivision.z), &xIndexCount, &xVertexCount); ComputePlaneIndexVertexCount(Vector2ui(subdivision.x, subdivision.z), &yIndexCount, &yVertexCount); @@ -666,7 +666,7 @@ namespace Nz *vertexCount = xVertexCount*2 + yVertexCount*2 + zVertexCount*2; } - UInt64 ComputeCacheMissCount(IndexIterator indices, UInt64 indexCount) + UInt32 ComputeCacheMissCount(IndexIterator indices, UInt32 indexCount) { NAZARA_USE_ANONYMOUS_NAMESPACE @@ -674,7 +674,7 @@ namespace Nz return cache.GetMissCount(); } - void ComputeConeIndexVertexCount(unsigned int subdivision, UInt64* indexCount, UInt64* vertexCount) + void ComputeConeIndexVertexCount(unsigned int subdivision, UInt32* indexCount, UInt32* vertexCount) { if (indexCount) *indexCount = (subdivision-1)*6; @@ -683,7 +683,7 @@ namespace Nz *vertexCount = subdivision + 2; } - void ComputeCubicSphereIndexVertexCount(unsigned int subdivision, UInt64* indexCount, UInt64* vertexCount) + void ComputeCubicSphereIndexVertexCount(unsigned int subdivision, UInt32* indexCount, UInt32* vertexCount) { // Comme tous nos plans sont identiques, on peut optimiser un peu ComputePlaneIndexVertexCount(Vector2ui(subdivision), indexCount, vertexCount); @@ -695,7 +695,7 @@ namespace Nz *vertexCount *= 6; } - void ComputeIcoSphereIndexVertexCount(unsigned int recursionLevel, UInt64* indexCount, UInt64* vertexCount) + void ComputeIcoSphereIndexVertexCount(unsigned int recursionLevel, UInt32* indexCount, UInt32* vertexCount) { if (indexCount) *indexCount = 3 * 20 * IntegralPow(4, recursionLevel); @@ -704,7 +704,7 @@ namespace Nz *vertexCount = IntegralPow(4, recursionLevel)*10 + 2; } - void ComputePlaneIndexVertexCount(const Vector2ui& subdivision, UInt64* indexCount, UInt64* vertexCount) + void ComputePlaneIndexVertexCount(const Vector2ui& subdivision, UInt32* indexCount, UInt32* vertexCount) { // Le nombre de faces appartenant à un axe est équivalent à 2 exposant la subdivision (1,2,4,8,16,32,...) unsigned int horizontalFaceCount = (1 << subdivision.x); @@ -721,7 +721,7 @@ namespace Nz *vertexCount = horizontalVertexCount*verticalVertexCount; } - void ComputeUvSphereIndexVertexCount(unsigned int sliceCount, unsigned int stackCount, UInt64* indexCount, UInt64* vertexCount) + void ComputeUvSphereIndexVertexCount(unsigned int sliceCount, unsigned int stackCount, UInt32* indexCount, UInt32* vertexCount) { if (indexCount) *indexCount = (sliceCount-1) * (stackCount-1) * 6; @@ -732,12 +732,12 @@ namespace Nz /**********************************Generate*********************************/ - void GenerateBox(const Vector3f& lengths, const Vector3ui& subdivision, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb, UInt64 indexOffset) + void GenerateBox(const Vector3f& lengths, const Vector3ui& subdivision, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb, UInt32 indexOffset) { NAZARA_USE_ANONYMOUS_NAMESPACE - UInt64 xIndexCount, yIndexCount, zIndexCount; - UInt64 xVertexCount, yVertexCount, zVertexCount; + UInt32 xIndexCount, yIndexCount, zIndexCount; + UInt32 xVertexCount, yVertexCount, zVertexCount; ComputePlaneIndexVertexCount(Vector2ui(subdivision.y, subdivision.z), &xIndexCount, &xVertexCount); ComputePlaneIndexVertexCount(Vector2ui(subdivision.x, subdivision.z), &yIndexCount, &yVertexCount); @@ -855,7 +855,7 @@ namespace Nz } } - void GenerateCone(float length, float radius, unsigned int subdivision, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb, UInt64 indexOffset) + void GenerateCone(float length, float radius, unsigned int subdivision, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb, UInt32 indexOffset) { constexpr float round = 2.f * Pi; float delta = round/subdivision; @@ -903,10 +903,10 @@ namespace Nz } } - void GenerateCubicSphere(float size, unsigned int subdivision, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb, UInt64 indexOffset) + void GenerateCubicSphere(float size, unsigned int subdivision, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb, UInt32 indexOffset) { ///DOC: Cette fonction va accéder aux pointeurs en écriture ET en lecture - UInt64 vertexCount; + UInt32 vertexCount; ComputeBoxIndexVertexCount(Vector3ui(subdivision), nullptr, &vertexCount); // On envoie une matrice identité de sorte à ce que la boîte ne subisse aucune transformation (rendant plus facile l'étape suivante) @@ -931,7 +931,7 @@ namespace Nz } } - void GenerateIcoSphere(float size, unsigned int recursionLevel, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb, UInt64 indexOffset) + void GenerateIcoSphere(float size, unsigned int recursionLevel, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb, UInt32 indexOffset) { NAZARA_USE_ANONYMOUS_NAMESPACE @@ -939,7 +939,7 @@ namespace Nz builder.Generate(size, recursionLevel, textureCoords, vertexPointers, indices, aabb, indexOffset); } - void GeneratePlane(const Vector2ui& subdivision, const Vector2f& size, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb, UInt64 indexOffset) + void GeneratePlane(const Vector2ui& subdivision, const Vector2f& size, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb, UInt32 indexOffset) { // Pour plus de facilité, on va construire notre plan en considérant que la normale est de 0,1,0 // Et appliquer ensuite une matrice "finissant le travail" @@ -998,7 +998,7 @@ namespace Nz aabb->Set(matrix.Transform(Vector3f(-halfSizeX, 0.f, -halfSizeY), 0.f), matrix.Transform(Vector3f(halfSizeX, 0.f, halfSizeY), 0.f)); } - void GenerateUvSphere(float size, unsigned int sliceCount, unsigned int stackCount, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb, UInt64 indexOffset) + void GenerateUvSphere(float size, unsigned int sliceCount, unsigned int stackCount, const Matrix4f& matrix, const Rectf& textureCoords, VertexPointers vertexPointers, IndexIterator indices, Boxf* aabb, UInt32 indexOffset) { // http://stackoverflow.com/questions/14080932/implementing-opengl-sphere-example-code float invSliceCount = 1.f / (sliceCount-1); @@ -1054,7 +1054,7 @@ namespace Nz /**********************************Optimize*********************************/ - void OptimizeIndices(IndexIterator indices, UInt64 indexCount) + void OptimizeIndices(IndexIterator indices, UInt32 indexCount) { NAZARA_USE_ANONYMOUS_NAMESPACE @@ -1065,12 +1065,12 @@ namespace Nz /************************************Skin***********************************/ - void SkinLinearBlend(const SkinningData& skinningInfos, UInt64 startVertex, UInt64 vertexCount) + void SkinLinearBlend(const SkinningData& skinningInfos, UInt32 startVertex, UInt32 vertexCount) { NazaraAssert(skinningInfos.inputJointIndices, "missing input joint indices"); NazaraAssert(skinningInfos.inputJointWeights, "missing input joint weights"); - UInt64 endVertex = startVertex + vertexCount - 1; + UInt32 endVertex = startVertex + vertexCount - 1; if (skinningInfos.outputPositions || skinningInfos.outputNormals || skinningInfos.outputTangents) { NazaraAssert(skinningInfos.joints, "missing skeleton joints"); @@ -1088,7 +1088,7 @@ namespace Nz bool hasNormals = skinningInfos.inputNormals && skinningInfos.outputNormals; bool hasTangents = skinningInfos.inputTangents && skinningInfos.outputTangents; - for (UInt64 i = startVertex; i <= endVertex; ++i) + for (UInt32 i = startVertex; i <= endVertex; ++i) { Vector3f finalPosition = Vector3f::Zero(); Vector3f finalNormal = Vector3f::Zero(); diff --git a/src/Nazara/Utility/Formats/MD5MeshLoader.cpp b/src/Nazara/Utility/Formats/MD5MeshLoader.cpp index 256662e6d..a553de555 100644 --- a/src/Nazara/Utility/Formats/MD5MeshLoader.cpp +++ b/src/Nazara/Utility/Formats/MD5MeshLoader.cpp @@ -94,8 +94,8 @@ namespace Nz { const MD5MeshParser::Mesh& md5Mesh = meshes[i]; - UInt64 indexCount = md5Mesh.triangles.size() * 3; - UInt64 vertexCount = md5Mesh.vertices.size(); + UInt32 indexCount = SafeCast(md5Mesh.triangles.size() * 3); + UInt32 vertexCount = SafeCast(md5Mesh.vertices.size()); bool largeIndices = (vertexCount > std::numeric_limits::max()); @@ -257,8 +257,8 @@ namespace Nz for (UInt32 i = 0; i < meshCount; ++i) { const MD5MeshParser::Mesh& md5Mesh = meshes[i]; - UInt64 indexCount = md5Mesh.triangles.size() * 3; - UInt64 vertexCount = md5Mesh.vertices.size(); + UInt32 indexCount = SafeCast(md5Mesh.triangles.size() * 3); + UInt32 vertexCount = SafeCast(md5Mesh.vertices.size()); // Index buffer bool largeIndices = (vertexCount > std::numeric_limits::max()); diff --git a/src/Nazara/Utility/Formats/OBJLoader.cpp b/src/Nazara/Utility/Formats/OBJLoader.cpp index 15149e90d..837f91912 100644 --- a/src/Nazara/Utility/Formats/OBJLoader.cpp +++ b/src/Nazara/Utility/Formats/OBJLoader.cpp @@ -246,7 +246,7 @@ namespace Nz // Création des buffers bool largeIndices = (vertexCount > std::numeric_limits::max()); - std::shared_ptr indexBuffer = std::make_shared((largeIndices) ? IndexType::U32 : IndexType::U16, indices.size(), parameters.indexBufferFlags, parameters.bufferFactory); + std::shared_ptr indexBuffer = std::make_shared((largeIndices) ? IndexType::U32 : IndexType::U16, SafeCast(indices.size()), parameters.indexBufferFlags, parameters.bufferFactory); std::shared_ptr vertexBuffer = std::make_shared(parameters.vertexDeclaration, vertexCount, parameters.vertexBufferFlags, parameters.bufferFactory); // Remplissage des indices diff --git a/src/Nazara/Utility/IndexBuffer.cpp b/src/Nazara/Utility/IndexBuffer.cpp index 014c9723a..512dfb012 100644 --- a/src/Nazara/Utility/IndexBuffer.cpp +++ b/src/Nazara/Utility/IndexBuffer.cpp @@ -23,7 +23,7 @@ namespace Nz NazaraAssert(m_buffer->GetType() == BufferType::Index, "buffer must be an index buffer"); m_endOffset = m_buffer->GetSize(); - m_indexCount = m_endOffset / GetStride(); + m_indexCount = SafeCast(m_endOffset / GetStride()); } IndexBuffer::IndexBuffer(IndexType indexType, std::shared_ptr buffer, UInt64 offset, UInt64 size) : @@ -36,10 +36,10 @@ namespace Nz NazaraAssert(m_buffer->GetType() == BufferType::Index, "buffer must be an index buffer"); NazaraAssert(size > 0, "invalid buffer size"); - m_indexCount = size / GetStride(); + m_indexCount = SafeCast(size / GetStride()); } - IndexBuffer::IndexBuffer(IndexType indexType, UInt64 indexCount, BufferUsageFlags usage, const BufferFactory& bufferFactory, const void* initialData) : + IndexBuffer::IndexBuffer(IndexType indexType, UInt32 indexCount, BufferUsageFlags usage, const BufferFactory& bufferFactory, const void* initialData) : m_indexType(indexType), m_indexCount(indexCount), m_startOffset(0) diff --git a/src/Nazara/Utility/IndexMapper.cpp b/src/Nazara/Utility/IndexMapper.cpp index ec4354035..b944c8fd2 100644 --- a/src/Nazara/Utility/IndexMapper.cpp +++ b/src/Nazara/Utility/IndexMapper.cpp @@ -67,7 +67,7 @@ namespace Nz } } - IndexMapper::IndexMapper(IndexBuffer& indexBuffer, std::size_t indexCount) : + IndexMapper::IndexMapper(IndexBuffer& indexBuffer, UInt32 indexCount) : m_indexCount((indexCount != 0) ? indexCount : indexBuffer.GetIndexCount()) { NAZARA_USE_ANONYMOUS_NAMESPACE @@ -127,7 +127,7 @@ namespace Nz return m_mapper.GetBuffer(); } - std::size_t IndexMapper::GetIndexCount() const + UInt32 IndexMapper::GetIndexCount() const { return m_indexCount; } diff --git a/src/Nazara/Utility/Mesh.cpp b/src/Nazara/Utility/Mesh.cpp index 862a48465..a3fe9aa88 100644 --- a/src/Nazara/Utility/Mesh.cpp +++ b/src/Nazara/Utility/Mesh.cpp @@ -89,8 +89,8 @@ namespace Nz { case PrimitiveType::Box: { - UInt64 indexCount; - UInt64 vertexCount; + UInt32 indexCount; + UInt32 vertexCount; ComputeBoxIndexVertexCount(primitive.box.subdivision, &indexCount, &vertexCount); bool largeIndices = (vertexCount > std::numeric_limits::max()); @@ -113,8 +113,8 @@ namespace Nz case PrimitiveType::Cone: { - UInt64 indexCount; - UInt64 vertexCount; + UInt32 indexCount; + UInt32 vertexCount; ComputeConeIndexVertexCount(primitive.cone.subdivision, &indexCount, &vertexCount); bool largeIndices = (vertexCount > std::numeric_limits::max()); @@ -137,8 +137,8 @@ namespace Nz case PrimitiveType::Plane: { - UInt64 indexCount; - UInt64 vertexCount; + UInt32 indexCount; + UInt32 vertexCount; ComputePlaneIndexVertexCount(primitive.plane.subdivision, &indexCount, &vertexCount); bool largeIndices = (vertexCount > std::numeric_limits::max()); @@ -165,8 +165,8 @@ namespace Nz { case SphereType::Cubic: { - UInt64 indexCount; - UInt64 vertexCount; + UInt32 indexCount; + UInt32 vertexCount; ComputeCubicSphereIndexVertexCount(primitive.sphere.cubic.subdivision, &indexCount, &vertexCount); bool largeIndices = (vertexCount > std::numeric_limits::max()); @@ -189,8 +189,8 @@ namespace Nz case SphereType::Ico: { - UInt64 indexCount; - UInt64 vertexCount; + UInt32 indexCount; + UInt32 vertexCount; ComputeIcoSphereIndexVertexCount(primitive.sphere.ico.recursionLevel, &indexCount, &vertexCount); bool largeIndices = (vertexCount > std::numeric_limits::max()); @@ -213,8 +213,8 @@ namespace Nz case SphereType::UV: { - UInt64 indexCount; - UInt64 vertexCount; + UInt32 indexCount; + UInt32 vertexCount; ComputeUvSphereIndexVertexCount(primitive.sphere.uv.sliceCount, primitive.sphere.uv.stackCount, &indexCount, &vertexCount); bool largeIndices = (vertexCount > std::numeric_limits::max()); @@ -439,22 +439,22 @@ namespace Nz return it->second; } - UInt64 Mesh::GetTriangleCount() const + UInt32 Mesh::GetTriangleCount() const { NazaraAssert(m_isValid, "Mesh should be created first"); - UInt64 triangleCount = 0; + UInt32 triangleCount = 0; for (const SubMeshData& data : m_subMeshes) triangleCount += data.subMesh->GetTriangleCount(); return triangleCount; } - UInt64 Mesh::GetVertexCount() const + UInt32 Mesh::GetVertexCount() const { NazaraAssert(m_isValid, "Mesh should be created first"); - UInt64 vertexCount = 0; + UInt32 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 fe7297e18..0135ead63 100644 --- a/src/Nazara/Utility/SkeletalMesh.cpp +++ b/src/Nazara/Utility/SkeletalMesh.cpp @@ -36,7 +36,7 @@ namespace Nz return m_vertexBuffer; } - UInt64 SkeletalMesh::GetVertexCount() const + UInt32 SkeletalMesh::GetVertexCount() const { return m_vertexBuffer->GetVertexCount(); } diff --git a/src/Nazara/Utility/StaticMesh.cpp b/src/Nazara/Utility/StaticMesh.cpp index 12992c42f..75bb97492 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); - UInt64 vertexCount = m_vertexBuffer->GetVertexCount(); - for (UInt64 i = 0; i < vertexCount; ++i) + UInt32 vertexCount = m_vertexBuffer->GetVertexCount(); + for (UInt32 i = 0; i < vertexCount; ++i) *position++ -= offset; m_aabb.x -= offset.x; @@ -63,7 +63,7 @@ namespace Nz return m_vertexBuffer; } - UInt64 StaticMesh::GetVertexCount() const + UInt32 StaticMesh::GetVertexCount() const { return m_vertexBuffer->GetVertexCount(); } diff --git a/src/Nazara/Utility/SubMesh.cpp b/src/Nazara/Utility/SubMesh.cpp index 5a71ad88b..9e706fe89 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); - UInt64 vertexCount = mapper.GetVertexCount(); + UInt32 vertexCount = mapper.GetVertexCount(); SparsePtr normals = mapper.GetComponentPtr(VertexComponent::Normal); SparsePtr positions = mapper.GetComponentPtr(VertexComponent::Position); if (!normals || !positions) return; - for (UInt64 i = 0; i < vertexCount; ++i) + for (UInt32 i = 0; i < vertexCount; ++i) normals[i].MakeZero(); TriangleIterator iterator(*this); @@ -55,7 +55,7 @@ namespace Nz void SubMesh::GenerateNormalsAndTangents() { VertexMapper mapper(*this); - UInt64 vertexCount = mapper.GetVertexCount(); + UInt32 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 (UInt64 i = 0; i < vertexCount; ++i) + for (UInt32 i = 0; i < vertexCount; ++i) { normals[i].MakeZero(); tangents[i].MakeZero(); @@ -159,10 +159,10 @@ namespace Nz return m_primitiveMode; } - UInt64 SubMesh::GetTriangleCount() const + UInt32 SubMesh::GetTriangleCount() const { const std::shared_ptr& indexBuffer = GetIndexBuffer(); - UInt64 indexCount; + UInt32 indexCount; if (indexBuffer) indexCount = indexBuffer->GetIndexCount(); else diff --git a/src/Nazara/Utility/VertexBuffer.cpp b/src/Nazara/Utility/VertexBuffer.cpp index f5db01a92..bb5ccfa67 100644 --- a/src/Nazara/Utility/VertexBuffer.cpp +++ b/src/Nazara/Utility/VertexBuffer.cpp @@ -18,7 +18,7 @@ namespace Nz NazaraAssert(m_buffer->GetType() == BufferType::Vertex, "buffer must be an vertex buffer"); m_endOffset = m_buffer->GetSize(); - m_vertexCount = (m_vertexDeclaration) ? m_endOffset / m_vertexDeclaration->GetStride() : 0; + m_vertexCount = SafeCast((m_vertexDeclaration) ? m_endOffset / m_vertexDeclaration->GetStride() : 0); } VertexBuffer::VertexBuffer(std::shared_ptr vertexDeclaration, std::shared_ptr buffer, UInt64 offset, UInt64 size) : @@ -30,10 +30,10 @@ namespace Nz NazaraAssert(m_buffer, "invalid buffer"); NazaraAssert(m_buffer->GetType() == BufferType::Vertex, "buffer must be an vertex buffer"); - m_vertexCount = (m_vertexDeclaration) ? m_endOffset / m_vertexDeclaration->GetStride() : 0; + m_vertexCount = SafeCast((m_vertexDeclaration) ? m_endOffset / m_vertexDeclaration->GetStride() : 0); } - VertexBuffer::VertexBuffer(std::shared_ptr vertexDeclaration, UInt64 vertexCount, BufferUsageFlags usage, const BufferFactory& bufferFactory, const void* initialData) : + VertexBuffer::VertexBuffer(std::shared_ptr vertexDeclaration, UInt32 vertexCount, BufferUsageFlags usage, const BufferFactory& bufferFactory, const void* initialData) : m_vertexDeclaration(std::move(vertexDeclaration)), m_startOffset(0), m_vertexCount(vertexCount) @@ -96,7 +96,7 @@ namespace Nz { NazaraAssert(vertexDeclaration, "Invalid vertex declaration"); - m_vertexCount = (m_endOffset - m_startOffset) / vertexDeclaration->GetStride(); + m_vertexCount = SafeCast((m_endOffset - m_startOffset) / vertexDeclaration->GetStride()); m_vertexDeclaration = std::move(vertexDeclaration); }