Jump to content
reeson

Cleaning up the geo

Recommended Posts

Hi, can someone help me with cleaning up the geo. The thing is, after dividing the geo, I get some reverse/clipping on primitives. Also when I try to render to disk with ROP Alembic, I get a yellow warning about collision. Also when I import the .abc file into Octane, the geo has some artifacts. Here's my hip file. Cheers!

geo_clean.hip

Share this post


Link to post
Share on other sites

Yeah, none of the standard cleanup nodes will work for your case. You'll have to write code to detect the overlapping primitives, use the measure sop to determine their area and follow up with a removeprim function to remove the overlapping primitive with the smaller area.

Edited by Atom

Share this post


Link to post
Share on other sites
47 minutes ago, Atom said:

Yeah, none of the standard cleanup nodes will work for your case. You'll have to write code to detect the overlapping primitives, use the measure sop to determine their area and follow up with a removeprim function to remove the overlapping primitive with the smaller area.

Oh boy, I have some basic coding skills, but this way out of my league.

Share this post


Link to post
Share on other sites

Here is some basic code that I got to work, I placed both  for loop nodes in single pass mode. So only one section of the ring is processed. I haven't figured out to successfully integrate this code to loop over all the primitives in the full object, however.

This GIF shows what happens when I toggle the correction code on an off.

duplicate_prims.gif.9dc466badadd1d4a4f83e8ca7be40368.gif

It's a two step process, one step detects the overlap and marks the offending primitives, then the second wrangle node removes the marked primitives.

int is_x_same = 0;
int is_y_same = 0;
int is_z_same = 0;

// Get all primitives
int primitives[] = expandprimgroup(0, "*");

//foreach (int currentPrim; primitives){
    int currentPrim =11;
    vector cur_bbox = getbbox_size(0, itoa(currentPrim));
    float cur_area = prim(0,"area",currentPrim);
    //foreach (int testPrim; primitives){
        int testPrim =3;
        if(currentPrim!=testPrim){
            is_x_same = 0;
            is_y_same = 0;
            is_z_same = 0;
            vector test_bbox = getbbox_size(0, itoa(currentPrim));
            float test_area = prim(0,"area",currentPrim);
            if (cur_bbox.x==test_bbox.x) {is_x_same = 1;}
            if (cur_bbox.y==test_bbox.y) {is_y_same = 1;}
            if (cur_bbox.z==test_bbox.z) {is_z_same = 1;}
            int i = is_x_same+is_y_same+is_z_same;

            if (i>1) {
                // This primitive shares a parallel plane with the current prim.
                if(cur_area>test_area) {
                    setprimattrib(0,"should_remove",testPrim,1,"set");
                } else {
                    setprimattrib(0,"should_remove",currentPrim,1,"set");
                }
                // We have found a match so stop looping over test primitives.
                //break;
            }
        } else {
            // Skip testing against self.
        }
    //}
//}

 

ap_geo_clean_v3.hiplc

Edited by Atom
  • Like 1

Share this post


Link to post
Share on other sites

Much appreciated!

Or I can just convert to VDB and then back to polygons.

Edited by reeson

Share this post


Link to post
Share on other sites

If you don't mind losing your crisp edge and increasing your poly count, yes. That will work.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×