Skip to content

Commit

Permalink
fixed normal calculation with draco meshes
Browse files Browse the repository at this point in the history
  • Loading branch information
pfcDorn authored and hybridherbst committed Jul 16, 2023
1 parent 644e631 commit 752c581
Showing 1 changed file with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -233,16 +233,6 @@ protected async Task ConstructUnityMesh(GLTFMesh gltfMesh,DracoMeshLoader.Decode
}
}

if (decodeResults[0].calculateNormals)
{
mesh.RecalculateNormals();
}

if (requireTangents)
{
mesh.RecalculateTangents();
}

await YieldOnTimeoutAndThrowOnLowMemory();

verticesLength = (uint) mesh.vertexCount;
Expand Down Expand Up @@ -299,11 +289,16 @@ protected async Task ConstructUnityMesh(GLTFMesh gltfMesh,DracoMeshLoader.Decode
}
await YieldOnTimeoutAndThrowOnLowMemory();

if (mesh.normals != null && mesh.normals.Length > 0 && mesh.GetTopology(0) == MeshTopology.Triangles)
if (decodeResults[0].calculateNormals && mesh.normals != null && mesh.normals.Length > 0 && mesh.GetTopology(0) == MeshTopology.Triangles)
{
mesh.RecalculateNormals();
}

if (requireTangents)
{
mesh.RecalculateTangents();
}

if (!KeepCPUCopyOfMesh)
{
mesh.UploadMeshData(true);
Expand Down

0 comments on commit 752c581

Please sign in to comment.