MeshCleanup

This post presents a generally useful code snippet. It deals with a fairly common problem of trying to clean up a potentially bad triangle mesh. Here is what it does:
(1) Detects duplicate triangles and removes them.
(2) Detects degenerate triangles and removes them.
(3) Detects double sided triangles and extrudes them into a solid shape.
The implementation is fast because it uses a hash_map to avoid having to iterate comparing every triangle winding order to every other triangle.
Simply pass it an indexed triangle mesh in and you get a cleaned up indexed triangle mesh back out.
Here is the source:
MeshCleanup.h
MeshCleanup.cpp
It requires a few of the snippets previously uploaded to compile. They are:
VertexLookup.h
VertexLookup.cpp
FloatMath.h
FloatMath.cpp
IntPtr.h

0 Comments:
Post a Comment
<< Home