Switch index/vertex count to UInt32
This commit is contained in:
parent
dc6ce8427c
commit
6b8be23fa0
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace Nz
|
|||
return m_endOffset;
|
||||
}
|
||||
|
||||
inline UInt64 IndexBuffer::GetIndexCount() const
|
||||
inline UInt32 IndexBuffer::GetIndexCount() const
|
||||
{
|
||||
return m_indexCount;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ namespace Nz
|
|||
return m_startOffset;
|
||||
}
|
||||
|
||||
inline UInt64 VertexBuffer::GetVertexCount() const
|
||||
inline UInt32 VertexBuffer::GetVertexCount() const
|
||||
{
|
||||
return m_vertexCount;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace Nz
|
|||
return m_mapper.GetBuffer();
|
||||
}
|
||||
|
||||
inline UInt64 VertexMapper::GetVertexCount() const
|
||||
inline UInt32 VertexMapper::GetVertexCount() const
|
||||
{
|
||||
return GetVertexBuffer()->GetVertexCount();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Nz::Int64>::min(), 0, std::numeric_limits<Nz::Int64>::max(), 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ namespace Nz
|
|||
}
|
||||
});
|
||||
|
||||
std::shared_ptr<VertexBuffer> colliderVB = std::make_shared<VertexBuffer>(VertexDeclaration::Get(VertexLayout::XYZ), colliderVertices.size(), BufferUsage::Write, SoftwareBufferFactory, colliderVertices.data());
|
||||
std::shared_ptr<VertexBuffer> colliderVB = std::make_shared<VertexBuffer>(VertexDeclaration::Get(VertexLayout::XYZ), SafeCast<UInt32>(colliderVertices.size()), BufferUsage::Write, SoftwareBufferFactory, colliderVertices.data());
|
||||
std::shared_ptr<IndexBuffer> colliderIB = std::make_shared<IndexBuffer>(IndexType::U16, colliderIndices.size(), BufferUsage::Write, SoftwareBufferFactory, colliderIndices.data());
|
||||
|
||||
std::shared_ptr<StaticMesh> colliderSubMesh = std::make_shared<StaticMesh>(std::move(colliderVB), std::move(colliderIB));
|
||||
|
|
|
|||
|
|
@ -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<int, 40> 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<const Vector3f> positionPtr, UInt64 vertexCount)
|
||||
Boxf ComputeAABB(SparsePtr<const Vector3f> 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>;
|
||||
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();
|
||||
|
|
|
|||
|
|
@ -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<UInt32>(md5Mesh.triangles.size() * 3);
|
||||
UInt32 vertexCount = SafeCast<UInt32>(md5Mesh.vertices.size());
|
||||
|
||||
bool largeIndices = (vertexCount > std::numeric_limits<UInt16>::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<UInt32>(md5Mesh.triangles.size() * 3);
|
||||
UInt32 vertexCount = SafeCast<UInt32>(md5Mesh.vertices.size());
|
||||
|
||||
// Index buffer
|
||||
bool largeIndices = (vertexCount > std::numeric_limits<UInt16>::max());
|
||||
|
|
|
|||
|
|
@ -246,7 +246,7 @@ namespace Nz
|
|||
// Création des buffers
|
||||
bool largeIndices = (vertexCount > std::numeric_limits<UInt16>::max());
|
||||
|
||||
std::shared_ptr<IndexBuffer> indexBuffer = std::make_shared<IndexBuffer>((largeIndices) ? IndexType::U32 : IndexType::U16, indices.size(), parameters.indexBufferFlags, parameters.bufferFactory);
|
||||
std::shared_ptr<IndexBuffer> indexBuffer = std::make_shared<IndexBuffer>((largeIndices) ? IndexType::U32 : IndexType::U16, SafeCast<UInt32>(indices.size()), parameters.indexBufferFlags, parameters.bufferFactory);
|
||||
std::shared_ptr<VertexBuffer> vertexBuffer = std::make_shared<VertexBuffer>(parameters.vertexDeclaration, vertexCount, parameters.vertexBufferFlags, parameters.bufferFactory);
|
||||
|
||||
// Remplissage des indices
|
||||
|
|
|
|||
|
|
@ -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<UInt32>(m_endOffset / GetStride());
|
||||
}
|
||||
|
||||
IndexBuffer::IndexBuffer(IndexType indexType, std::shared_ptr<Buffer> 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<UInt32>(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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<UInt16>::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<UInt16>::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<UInt16>::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<UInt16>::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<UInt16>::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<UInt16>::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();
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ namespace Nz
|
|||
return m_vertexBuffer;
|
||||
}
|
||||
|
||||
UInt64 SkeletalMesh::GetVertexCount() const
|
||||
UInt32 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);
|
||||
|
||||
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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,14 +22,14 @@ namespace Nz
|
|||
void SubMesh::GenerateNormals()
|
||||
{
|
||||
VertexMapper mapper(*this);
|
||||
UInt64 vertexCount = mapper.GetVertexCount();
|
||||
UInt32 vertexCount = mapper.GetVertexCount();
|
||||
|
||||
SparsePtr<Vector3f> normals = mapper.GetComponentPtr<Vector3f>(VertexComponent::Normal);
|
||||
SparsePtr<Vector3f> positions = mapper.GetComponentPtr<Vector3f>(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<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 (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<const IndexBuffer>& indexBuffer = GetIndexBuffer();
|
||||
UInt64 indexCount;
|
||||
UInt32 indexCount;
|
||||
if (indexBuffer)
|
||||
indexCount = indexBuffer->GetIndexCount();
|
||||
else
|
||||
|
|
|
|||
|
|
@ -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<UInt32>((m_vertexDeclaration) ? m_endOffset / m_vertexDeclaration->GetStride() : 0);
|
||||
}
|
||||
|
||||
VertexBuffer::VertexBuffer(std::shared_ptr<const VertexDeclaration> vertexDeclaration, std::shared_ptr<Buffer> 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<UInt32>((m_vertexDeclaration) ? m_endOffset / m_vertexDeclaration->GetStride() : 0);
|
||||
}
|
||||
|
||||
VertexBuffer::VertexBuffer(std::shared_ptr<const VertexDeclaration> vertexDeclaration, UInt64 vertexCount, BufferUsageFlags usage, const BufferFactory& bufferFactory, const void* initialData) :
|
||||
VertexBuffer::VertexBuffer(std::shared_ptr<const VertexDeclaration> 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<UInt32>((m_endOffset - m_startOffset) / vertexDeclaration->GetStride());
|
||||
m_vertexDeclaration = std::move(vertexDeclaration);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue