Skip to content

Commit

Permalink
In AssimpLoader::Implementation::CreateSubMesh check normal presence …
Browse files Browse the repository at this point in the history
…before reading

Signed-off-by: Qingyou Zhao <[email protected]>
  • Loading branch information
qingyouzhao committed Dec 6, 2024
1 parent 0c05864 commit 7303c04
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions graphics/src/AssimpLoader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -667,18 +667,20 @@ SubMesh AssimpLoader::Implementation::CreateSubMesh(
{
// Add the vertex
math::Vector3d vertex;
math::Vector3d normal;
vertex.X(_assimpMesh->mVertices[vertexIdx].x);
vertex.Y(_assimpMesh->mVertices[vertexIdx].y);
vertex.Z(_assimpMesh->mVertices[vertexIdx].z);
normal.X(_assimpMesh->mNormals[vertexIdx].x);
normal.Y(_assimpMesh->mNormals[vertexIdx].y);
normal.Z(_assimpMesh->mNormals[vertexIdx].z);
vertex = _transform * vertex;
normal = rot * normal;
normal.Normalize();
subMesh.AddVertex(vertex);
subMesh.AddNormal(normal);
if (_assimpMesh->HasNormals()) {
math::Vector3d normal;
normal.X(_assimpMesh->mNormals[vertexIdx].x);
normal.Y(_assimpMesh->mNormals[vertexIdx].y);
normal.Z(_assimpMesh->mNormals[vertexIdx].z);
normal = rot * normal;
normal.Normalize();
subMesh.AddNormal(normal);
}
// Iterate over sets of texture coordinates
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i)
{
Expand Down

0 comments on commit 7303c04

Please sign in to comment.