Cleanup pass
This commit is contained in:
@@ -91,8 +91,8 @@ namespace Nz
|
||||
|
||||
bool largeIndices = (vertexCount > std::numeric_limits<UInt16>::max());
|
||||
|
||||
IndexBufferRef indexBuffer = IndexBuffer::New(largeIndices, indexCount, parameters.storage, 0);
|
||||
VertexBufferRef vertexBuffer = VertexBuffer::New(VertexDeclaration::Get(VertexLayout_XYZ_Normal_UV_Tangent_Skinning), vertexCount, parameters.storage, 0);
|
||||
IndexBufferRef indexBuffer = IndexBuffer::New(largeIndices, UInt32(indexCount), parameters.storage, 0);
|
||||
VertexBufferRef vertexBuffer = VertexBuffer::New(VertexDeclaration::Get(VertexLayout_XYZ_Normal_UV_Tangent_Skinning), UInt32(vertexCount), parameters.storage, 0);
|
||||
|
||||
// Index buffer
|
||||
IndexMapper indexMapper(indexBuffer, BufferAccess_DiscardAndWrite);
|
||||
@@ -236,7 +236,7 @@ namespace Nz
|
||||
// Index buffer
|
||||
bool largeIndices = (vertexCount > std::numeric_limits<UInt16>::max());
|
||||
|
||||
IndexBufferRef indexBuffer = IndexBuffer::New(largeIndices, indexCount, parameters.storage, 0);
|
||||
IndexBufferRef indexBuffer = IndexBuffer::New(largeIndices, UInt32(indexCount), parameters.storage, 0);
|
||||
|
||||
IndexMapper indexMapper(indexBuffer, BufferAccess_DiscardAndWrite);
|
||||
IndexIterator index = indexMapper.begin();
|
||||
@@ -251,7 +251,7 @@ namespace Nz
|
||||
indexMapper.Unmap();
|
||||
|
||||
// Vertex buffer
|
||||
VertexBufferRef vertexBuffer = VertexBuffer::New(VertexDeclaration::Get(VertexLayout_XYZ_Normal_UV_Tangent), vertexCount, parameters.storage, 0);
|
||||
VertexBufferRef vertexBuffer = VertexBuffer::New(VertexDeclaration::Get(VertexLayout_XYZ_Normal_UV_Tangent), UInt32(vertexCount), parameters.storage, 0);
|
||||
BufferMapper<VertexBuffer> vertexMapper(vertexBuffer, BufferAccess_WriteOnly);
|
||||
|
||||
MeshVertex* vertices = static_cast<MeshVertex*>(vertexMapper.GetPointer());
|
||||
|
||||
@@ -233,8 +233,8 @@ namespace Nz
|
||||
}
|
||||
|
||||
// Création des buffers
|
||||
IndexBufferRef indexBuffer = IndexBuffer::New(vertexCount > std::numeric_limits<UInt16>::max(), indices.size(), parameters.storage, 0);
|
||||
VertexBufferRef vertexBuffer = VertexBuffer::New(VertexDeclaration::Get(VertexLayout_XYZ_Normal_UV_Tangent), vertexCount, parameters.storage, 0);
|
||||
IndexBufferRef indexBuffer = IndexBuffer::New(vertexCount > std::numeric_limits<UInt16>::max(), UInt32(indices.size()), parameters.storage, 0);
|
||||
VertexBufferRef vertexBuffer = VertexBuffer::New(VertexDeclaration::Get(VertexLayout_XYZ_Normal_UV_Tangent), UInt32(vertexCount), parameters.storage, 0);
|
||||
|
||||
// Remplissage des indices
|
||||
IndexMapper indexMapper(indexBuffer, BufferAccess_WriteOnly);
|
||||
|
||||
@@ -228,7 +228,7 @@ namespace Nz
|
||||
|
||||
if (p < 0)
|
||||
{
|
||||
p += m_positions.size() - 1;
|
||||
p += static_cast<int>(m_positions.size() - 1);
|
||||
if (p < 0)
|
||||
{
|
||||
Error("Vertex index out of range (" + String::Number(p) + " < 0");
|
||||
@@ -239,7 +239,7 @@ namespace Nz
|
||||
|
||||
if (n < 0)
|
||||
{
|
||||
n += m_normals.size() - 1;
|
||||
n += static_cast<int>(m_normals.size() - 1);
|
||||
if (n < 0)
|
||||
{
|
||||
Error("Normal index out of range (" + String::Number(n) + " < 0");
|
||||
@@ -250,7 +250,7 @@ namespace Nz
|
||||
|
||||
if (t < 0)
|
||||
{
|
||||
t += m_texCoords.size() - 1;
|
||||
t += static_cast<int>(m_texCoords.size() - 1);
|
||||
if (t < 0)
|
||||
{
|
||||
Error("Texture coordinates index out of range (" + String::Number(t) + " < 0");
|
||||
|
||||
@@ -12,38 +12,38 @@ namespace Nz
|
||||
{
|
||||
namespace
|
||||
{
|
||||
UInt32 GetterSequential(const void* buffer, unsigned int i)
|
||||
UInt32 GetterSequential(const void* buffer, std::size_t i)
|
||||
{
|
||||
NazaraUnused(buffer);
|
||||
|
||||
return i;
|
||||
return static_cast<UInt32>(i);
|
||||
}
|
||||
|
||||
UInt32 Getter16(const void* buffer, unsigned int i)
|
||||
UInt32 Getter16(const void* buffer, std::size_t i)
|
||||
{
|
||||
const UInt16* ptr = static_cast<const UInt16*>(buffer);
|
||||
return ptr[i];
|
||||
}
|
||||
|
||||
UInt32 Getter32(const void* buffer, unsigned int i)
|
||||
UInt32 Getter32(const void* buffer, std::size_t i)
|
||||
{
|
||||
const UInt32* ptr = static_cast<const UInt32*>(buffer);
|
||||
return ptr[i];
|
||||
}
|
||||
|
||||
void Setter16(void* buffer, unsigned int i, UInt32 value)
|
||||
void Setter16(void* buffer, std::size_t i, UInt32 value)
|
||||
{
|
||||
UInt16* ptr = static_cast<UInt16*>(buffer);
|
||||
ptr[i] = static_cast<UInt16>(value);
|
||||
}
|
||||
|
||||
void Setter32(void* buffer, unsigned int i, UInt32 value)
|
||||
void Setter32(void* buffer, std::size_t i, UInt32 value)
|
||||
{
|
||||
UInt32* ptr = static_cast<UInt32*>(buffer);
|
||||
ptr[i] = value;
|
||||
}
|
||||
|
||||
void SetterError(void*, unsigned int, UInt32)
|
||||
void SetterError(void*, std::size_t, UInt32)
|
||||
{
|
||||
NazaraError("Index buffer opened with read-only access");
|
||||
}
|
||||
@@ -113,15 +113,9 @@ namespace Nz
|
||||
{
|
||||
}
|
||||
|
||||
UInt32 IndexMapper::Get(unsigned int i) const
|
||||
UInt32 IndexMapper::Get(std::size_t i) const
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (i >= m_indexCount)
|
||||
{
|
||||
NazaraError("Index out of range (" + String::Number(i) + " >= " + String::Number(m_indexCount) + ')');
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
NazaraAssert(i < m_indexCount, "Index out of range");
|
||||
|
||||
return m_getter(m_mapper.GetPointer(), i);
|
||||
}
|
||||
@@ -131,20 +125,14 @@ namespace Nz
|
||||
return m_mapper.GetBuffer();
|
||||
}
|
||||
|
||||
unsigned int IndexMapper::GetIndexCount() const
|
||||
std::size_t IndexMapper::GetIndexCount() const
|
||||
{
|
||||
return m_indexCount;
|
||||
}
|
||||
|
||||
void IndexMapper::Set(unsigned int i, UInt32 value)
|
||||
void IndexMapper::Set(std::size_t i, UInt32 value)
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (i >= m_indexCount)
|
||||
{
|
||||
NazaraError("Index out of range (" + String::Number(i) + " >= " + String::Number(m_indexCount) + ')');
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
NazaraAssert(i < m_indexCount, "Index out of range");
|
||||
|
||||
m_setter(m_mapper.GetPointer(), i, value);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace Nz
|
||||
NazaraAssert(subMesh, "Invalid submesh");
|
||||
NazaraAssert(subMesh->GetAnimationType() == m_impl->animationType, "Submesh animation type doesn't match mesh animation type");
|
||||
|
||||
m_impl->subMeshes.push_back(subMesh);
|
||||
m_impl->subMeshes.emplace_back(subMesh);
|
||||
|
||||
InvalidateAABB();
|
||||
}
|
||||
@@ -92,10 +92,10 @@ namespace Nz
|
||||
NazaraAssert(subMesh, "Invalid submesh");
|
||||
NazaraAssert(subMesh->GetAnimationType() == m_impl->animationType, "Submesh animation type doesn't match mesh animation type");
|
||||
|
||||
UInt32 index = m_impl->subMeshes.size();
|
||||
std::size_t index = m_impl->subMeshes.size();
|
||||
|
||||
m_impl->subMeshes.push_back(subMesh);
|
||||
m_impl->subMeshMap[identifier] = index;
|
||||
m_impl->subMeshes.emplace_back(subMesh);
|
||||
m_impl->subMeshMap[identifier] = static_cast<UInt32>(index);
|
||||
|
||||
InvalidateAABB();
|
||||
}
|
||||
@@ -349,11 +349,11 @@ namespace Nz
|
||||
|
||||
if (!m_impl->aabbUpdated)
|
||||
{
|
||||
UInt32 subMeshCount = m_impl->subMeshes.size();
|
||||
std::size_t subMeshCount = m_impl->subMeshes.size();
|
||||
if (subMeshCount > 0)
|
||||
{
|
||||
m_impl->aabb.Set(m_impl->subMeshes[0]->GetAABB());
|
||||
for (UInt32 i = 1; i < subMeshCount; ++i)
|
||||
for (std::size_t i = 1; i < subMeshCount; ++i)
|
||||
m_impl->aabb.ExtendTo(m_impl->subMeshes[i]->GetAABB());
|
||||
}
|
||||
else
|
||||
@@ -407,7 +407,7 @@ namespace Nz
|
||||
{
|
||||
NazaraAssert(m_impl, "Mesh should be created first");
|
||||
|
||||
return m_impl->materialData.size();
|
||||
return static_cast<UInt32>(m_impl->materialData.size());
|
||||
}
|
||||
|
||||
Skeleton* Mesh::GetSkeleton()
|
||||
@@ -466,7 +466,7 @@ namespace Nz
|
||||
{
|
||||
NazaraAssert(m_impl, "Mesh should be created first");
|
||||
|
||||
return m_impl->subMeshes.size();
|
||||
return static_cast<UInt32>(m_impl->subMeshes.size());
|
||||
}
|
||||
|
||||
UInt32 Mesh::GetSubMeshIndex(const String& identifier) const
|
||||
|
||||
@@ -243,7 +243,7 @@ namespace Nz
|
||||
m_workingBounds.MakeZero(); //< Compute bounds as float to speedup bounds computation (as casting between floats and integers is costly)
|
||||
|
||||
if (m_font)
|
||||
m_lines.emplace_back(Line{Rectf(0.f, 0.f, 0.f, m_font->GetSizeInfo(m_characterSize).lineHeight), 0});
|
||||
m_lines.emplace_back(Line{Rectf(0.f, 0.f, 0.f, float(m_font->GetSizeInfo(m_characterSize).lineHeight)), 0});
|
||||
else
|
||||
m_lines.emplace_back(Line{Rectf::Zero(), 0});
|
||||
}
|
||||
@@ -354,7 +354,7 @@ namespace Nz
|
||||
{
|
||||
glyph.atlas = nullptr;
|
||||
|
||||
glyph.bounds.Set(m_drawPos.x, m_drawPos.y, float(advance), sizeInfo.lineHeight);
|
||||
glyph.bounds.Set(m_drawPos.x, m_drawPos.y, float(advance), float(sizeInfo.lineHeight));
|
||||
|
||||
glyph.corners[0].Set(glyph.bounds.GetCorner(RectCorner_LeftTop));
|
||||
glyph.corners[1].Set(glyph.bounds.GetCorner(RectCorner_RightTop));
|
||||
@@ -377,7 +377,7 @@ namespace Nz
|
||||
m_drawPos.x = 0;
|
||||
m_drawPos.y += sizeInfo.lineHeight;
|
||||
|
||||
m_lines.emplace_back(Line{Rectf(0.f, sizeInfo.lineHeight * m_lines.size(), 0.f, sizeInfo.lineHeight), m_glyphs.size() + 1});
|
||||
m_lines.emplace_back(Line{Rectf(0.f, float(sizeInfo.lineHeight * m_lines.size()), 0.f, float(sizeInfo.lineHeight)), m_glyphs.size() + 1});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,12 +72,12 @@ namespace Nz
|
||||
|
||||
if (!m_impl->aabbUpdated)
|
||||
{
|
||||
UInt32 jointCount = m_impl->joints.size();
|
||||
std::size_t jointCount = m_impl->joints.size();
|
||||
if (jointCount > 0)
|
||||
{
|
||||
Vector3f pos = m_impl->joints[0].GetPosition();
|
||||
m_impl->aabb.Set(pos.x, pos.y, pos.z, 0.f, 0.f, 0.f);
|
||||
for (UInt32 i = 1; i < jointCount; ++i)
|
||||
for (std::size_t i = 1; i < jointCount; ++i)
|
||||
m_impl->aabb.ExtendTo(m_impl->joints[i].GetPosition());
|
||||
}
|
||||
else
|
||||
@@ -219,7 +219,7 @@ namespace Nz
|
||||
}
|
||||
#endif
|
||||
|
||||
return m_impl->joints.size();
|
||||
return static_cast<UInt32>(m_impl->joints.size());
|
||||
}
|
||||
|
||||
int Skeleton::GetJointIndex(const String& jointName) const
|
||||
@@ -411,16 +411,9 @@ namespace Nz
|
||||
String name = m_impl->joints[i].GetName();
|
||||
if (!name.IsEmpty())
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
auto it = m_impl->jointMap.find(name);
|
||||
if (it != m_impl->jointMap.end())
|
||||
{
|
||||
NazaraWarning("Joint name \"" + name + "\" is already present in joint map for joint #" + String::Number(it->second));
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
NazaraAssert(m_impl->jointMap.find(name) == m_impl->jointMap.end(), "Joint name \"" + name + "\" is already present in joint map");
|
||||
|
||||
m_impl->jointMap[name] = i;
|
||||
m_impl->jointMap[name] = static_cast<UInt32>(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,18 +66,9 @@ namespace Nz
|
||||
return true;
|
||||
}
|
||||
|
||||
UInt32 TriangleIterator::operator[](unsigned int i) const
|
||||
UInt32 TriangleIterator::operator[](std::size_t i) const
|
||||
{
|
||||
#if NAZARA_UTILITY_SAFE
|
||||
if (i >= 3)
|
||||
{
|
||||
StringStream ss;
|
||||
ss << "Index out of range: (" << i << " >= 3)";
|
||||
|
||||
NazaraError(ss);
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
#endif
|
||||
NazaraAssert(i < 3, "Index out of range");
|
||||
|
||||
return m_triangleIndices[i];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user