Fixed infinite loop on non-manifold geometry
Geometry that had strange non-manifold faces could cause the normal calculation to enter an infinite loop. Instead we now correctly detect which faces to scan over.pull/1210/head
parent
209e972762
commit
d1c7d905e8
|
@ -391,7 +391,7 @@ static void ConnectFaces(SIBMesh* mesh)
|
|||
// with non-2-manifold surfaces, but then so does Silo to begin with.
|
||||
if (edge.faceA == 0xffffffff)
|
||||
edge.faceA = static_cast<uint32_t>(faceIdx);
|
||||
else
|
||||
else if (edge.faceB == 0xffffffff)
|
||||
edge.faceB = static_cast<uint32_t>(faceIdx);
|
||||
|
||||
prev = next;
|
||||
|
@ -435,6 +435,10 @@ static aiVector3D CalculateVertexNormal(SIBMesh* mesh, uint32_t faceIdx, uint32_
|
|||
{
|
||||
SIBEdge& edge = GetEdge(mesh, posA, posB);
|
||||
|
||||
// Non-manifold meshes can produce faces which share
|
||||
// positions but have no edge entry, so check it.
|
||||
if (edge.faceA == faceIdx || edge.faceB == faceIdx)
|
||||
{
|
||||
// Move to whichever side we didn't just come from.
|
||||
if (!edge.creased) {
|
||||
if (edge.faceA != prevFaceIdx && edge.faceA != faceIdx && edge.faceA != 0xffffffff)
|
||||
|
@ -443,6 +447,7 @@ static aiVector3D CalculateVertexNormal(SIBMesh* mesh, uint32_t faceIdx, uint32_
|
|||
nextFaceIdx = edge.faceB;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
posA = posB;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue