Another tip:
When you are building the mesh edges, do NOT look for triangles that share vertices. You may have two different vertices in the same position, because of normals or texture mapping. Instead, look for triangles that share vertices that have an identical position. Compare the absolute value of the difference between each component of the vertex positions, and consider them the same if they less than a very small precision value, like 0.001:
Function VerticesMatch(surf,a,b)
If Abs(VertexX(surf,a)-VertexX(surf,b))<0.001
If Abs(VertexY(surf,a)-VertexY(surf,b))<0.001
If Abs(VertexZ(surf,a)-VertexZ(surf,b))<0.001
Return True
Endif
Endif
Endif
End Function
When you are building the mesh edges, do NOT look for triangles that share vertices. You may have two different vertices in the same position, because of normals or texture mapping. Instead, look for triangles that share vertices that have an identical position. Compare the absolute value of the difference between each component of the vertex positions, and consider them the same if they less than a very small precision value, like 0.001:
Function VerticesMatch(surf,a,b)
If Abs(VertexX(surf,a)-VertexX(surf,b))<0.001
If Abs(VertexY(surf,a)-VertexY(surf,b))<0.001
If Abs(VertexZ(surf,a)-VertexZ(surf,b))<0.001
Return True
Endif
Endif
Endif
End Function