procedural cleanup degenerate primitives

   11728   5   0
User Avatar
Member
21 posts
Joined: Feb. 2012
Offline
So I've been working through some SOPs to procedurally cleanup low polygon collision meshes that need to remain convex and cannot have degenerate prims. This kind of work could be done manually, but for my purposes I'm also generating the collision meshes procedurally so I'm trying to automate everything.

I have an example file I wouldn't mind some feedback on. I have a generated mesh where one triangle was degenerate, so my thinking was that I should procedurally merge the shortest edge of that triangle to collapse the triangle into the overall mesh. Because this is a low-poly collision mesh, losing a triangle like this isn't really a big deal for my application. I was able to figure out a way to do it with expressions and SOPs but it seems overly complex and messy. There has to be a better way than how I did it. I'm still fairly new at this and it seems like I took a sledgehammer to a simple issue. Any feedback is appreciated. Thanks!

Attachments:
degen_prims.zip (17.4 KB)

User Avatar
Member
606 posts
Joined: May 2007
Offline
Have you checked out the PolyDoctor and Clean SOPs?
User Avatar
Member
21 posts
Joined: Feb. 2012
Offline
Yeap, I've been using the clean sop to remove the degenerate primitives but that's really only part of the problem. If I remake the degen prims with a divide SOP, the new prim is still degenerate.

I've looked at polydoctor but I'm unsure how to use it to help with degenerate prims specifically. It doesn't act the same as Clean as far as I can tell. By that I mean if I use a Clean SOP it removes a triangle from my example but if I use Polydoctor and have it set to “Mark Ill-Formed” it does not mark the triangle that Clean removes.

So apparently Polydoctor does not believe that same triangle to be ‘ill-formed.’ So I'm a little confused there.
User Avatar
Member
1743 posts
Joined: March 2012
Offline
I don't know if this is useful in your case, but if you want a way to group the degenerate triangles (and some other bad polygons), try a Measure SOP with the Area option to compute the polygon area, then group by expression $AREA==0. If you need a scale-invariant way to group the nearly-degenerate triangles, measure the area, measure the perimeter, then group by something like $PERIMETER*$PERIMETER>=1e4*$AREA.

Edit: Had 1e-4 instead of 1e4.
Writing code for fun and profit since... 2005? Wow, I'm getting old.
https://www.youtube.com/channel/UC_HFmdvpe9U2G3OMNViKMEQ [www.youtube.com]
User Avatar
Member
7726 posts
Joined: July 2005
Online
mattv
By that I mean if I use a Clean SOP it removes a triangle from my example but if I use Polydoctor and have it set to “Mark Ill-Formed” it does not mark the triangle that Clean removes.

The Clean SOP uses the Delete SOP's Delete Zero Area Faces option to remove degenerate primitives. My guess is that the threshold it uses is different from the PolyDoctor. I think the PolyDoctor can be better because it exposes the tolerance parameter for what is considered degenerate.

I'm not quite sure from your example file that you even want to remove that particular triangle. If you do, then you can remove it via the “Locally Small Edges” criterion.
User Avatar
Member
21 posts
Joined: Feb. 2012
Offline
Thanks Edward, that makes sense. I should have actually looked inside the clean sop to see what was going on, didn't occur to me that they would be using different thresholds to delete degenerate prims.

Thanks Ndickson, that's a pretty cool trick. May or may not use that for exactly this, but I'm filing it away for future use!
  • Quick Links