Utility: First code cleaning pass
Former-commit-id: a73d38ce2db2e780ad5b02cdae1c590606081650 [formerly 3d21c0fa44481bf91418a15012fa187a210fc9ad] [formerly b80263df8e91b85f3fd091724c54dec7f05bc535 [formerly 7dcaabaabf74fbdf840289bfc435fdd8e88969d7]] Former-commit-id: a669a933edd2364d9ee487c7d1bb38e28ad87a2d [formerly b8c5c09df10ce2f831635f460393216799d44056] Former-commit-id: 6bbd5af22e30cc7fd4b4478162ae89e69b3d274e
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
bool OBJParser::Parse(Nz::Stream& stream, std::size_t reservedVertexCount)
|
||||
bool OBJParser::Parse(Nz::Stream& stream, UInt32 reservedVertexCount)
|
||||
{
|
||||
m_currentStream = &stream;
|
||||
|
||||
@@ -50,8 +50,8 @@ namespace Nz
|
||||
using MatPair = std::pair<Mesh, unsigned int>;
|
||||
std::unordered_map<String, std::unordered_map<String, MatPair>> meshesByName;
|
||||
|
||||
std::size_t faceReserve = 0;
|
||||
std::size_t vertexReserve = 0;
|
||||
UInt32 faceReserve = 0;
|
||||
UInt32 vertexReserve = 0;
|
||||
unsigned int matCount = 0;
|
||||
auto GetMaterial = [&] (const String& meshName, const String& matName) -> Mesh*
|
||||
{
|
||||
@@ -79,16 +79,16 @@ namespace Nz
|
||||
{
|
||||
case '#': //< Comment
|
||||
// Some softwares write comments to gives the number of vertex/faces an importer can expect
|
||||
std::size_t data;
|
||||
if (std::sscanf(m_currentLine.GetConstBuffer(), "# position count: %zu", &data) == 1)
|
||||
unsigned int data;
|
||||
if (std::sscanf(m_currentLine.GetConstBuffer(), "# position count: %u", &data) == 1)
|
||||
m_positions.reserve(data);
|
||||
else if (std::sscanf(m_currentLine.GetConstBuffer(), "# normal count: %zu", &data) == 1)
|
||||
else if (std::sscanf(m_currentLine.GetConstBuffer(), "# normal count: %u", &data) == 1)
|
||||
m_normals.reserve(data);
|
||||
else if (std::sscanf(m_currentLine.GetConstBuffer(), "# texcoords count: %zu", &data) == 1)
|
||||
else if (std::sscanf(m_currentLine.GetConstBuffer(), "# texcoords count: %u", &data) == 1)
|
||||
m_texCoords.reserve(data);
|
||||
else if (std::sscanf(m_currentLine.GetConstBuffer(), "# face count: %zu", &data) == 1)
|
||||
else if (std::sscanf(m_currentLine.GetConstBuffer(), "# face count: %u", &data) == 1)
|
||||
faceReserve = data;
|
||||
else if (std::sscanf(m_currentLine.GetConstBuffer(), "# vertex count: %zu", &data) == 1)
|
||||
else if (std::sscanf(m_currentLine.GetConstBuffer(), "# vertex count: %u", &data) == 1)
|
||||
vertexReserve = data;
|
||||
|
||||
break;
|
||||
@@ -118,8 +118,8 @@ namespace Nz
|
||||
currentMesh = GetMaterial(meshName, matName);
|
||||
|
||||
Face face;
|
||||
face.firstVertex = currentMesh->vertices.size();
|
||||
face.vertexCount = vertexCount;
|
||||
face.firstVertex = static_cast<UInt32>(currentMesh->vertices.size());
|
||||
face.vertexCount = static_cast<UInt32>(vertexCount);
|
||||
|
||||
currentMesh->vertices.resize(face.firstVertex + vertexCount, FaceVertex{0, 0, 0});
|
||||
|
||||
@@ -203,9 +203,9 @@ namespace Nz
|
||||
break;
|
||||
}
|
||||
|
||||
currentMesh->vertices[face.firstVertex + i].normal = static_cast<std::size_t>(n);
|
||||
currentMesh->vertices[face.firstVertex + i].position = static_cast<std::size_t>(p);
|
||||
currentMesh->vertices[face.firstVertex + i].texCoord = static_cast<std::size_t>(t);
|
||||
currentMesh->vertices[face.firstVertex + i].normal = static_cast<UInt32>(n);
|
||||
currentMesh->vertices[face.firstVertex + i].position = static_cast<UInt32>(p);
|
||||
currentMesh->vertices[face.firstVertex + i].texCoord = static_cast<UInt32>(t);
|
||||
|
||||
pos += offset;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user