PolyBridge to Nearest Prim

   5324   7   2
User Avatar
Member
8 posts
Joined: 3月 2017
Offline
Hi all,

I have a group of prims and I'd like to loop over them and PolyBridge to the nearest other prim in the group. Can anyone point me in the right direction as to how this might be achieved?

I appreciate this is probably straightforward (if not completely trivial) in VEX - but this more an exercise in the Nodes available to me in Houdini as opposed to reinventing the wheel every time in VEX.

Thanks

Dave
Edited by Calx - 2019年8月2日 16:16:34
User Avatar
Member
253 posts
Joined: 7月 2006
Offline
Can you post an example scene ?
User Avatar
Member
8 posts
Joined: 3月 2017
Offline
Sure, example scene attached.

And a bit of psuedocode to explain what I want to do in the loop.

Genuinely appreciate the help

Thanks

Dave


for (prim this_prim in Group_ENDS)
{
    prim closest_prim;
    float smallest_dist = BIG_NUMBER;

    for (prim that_prim in Group_ENDS)
    {
        if(this_prim != that_prim)
        {
            float this_dist = distance(this_prim, that_prim);

            if(this_dist < smallest_dist) 
            {
                smallest_dist = this_dist;
                closest_prim = that_prim;
            }
        }
    }

    polybridge(this_prim, closest_prim);
    remove_from_group(this_prim);
    remove_from_group(closest_prim);
}
Edited by Calx - 2019年8月4日 07:59:56

Attachments:
polybridge_pairs.hiplc (148.7 KB)

User Avatar
Member
253 posts
Joined: 7月 2006
Offline
Hey, this turned out a bit more complicated than I thought.

The first thing to note is that I stole the node “create_explicit_lines” from the Connect Adjacent Pieces sop. Then, it's a matter of creating the two groups and the attribute as the piece to loop over in the for-each.

Attachments:
polybridge_pairs_v02.hiplc (179.5 KB)

User Avatar
Member
8 posts
Joined: 3月 2017
Offline
A-OC
Hey, this turned out a bit more complicated than I thought.

The first thing to note is that I stole the node “create_explicit_lines” from the Connect Adjacent Pieces sop. Then, it's a matter of creating the two groups and the attribute as the piece to loop over in the for-each.


Thanks for spending time on this, really appreciated. Huge step forward for me.

In the example scene everything works perfectly, but when i dropped it into my actual work file, SOME of the faces bridge with the incorrect winding, so i suppose my next rabbithole is working out how to unify everything before running the approach you've outline as I have no way of specifying winding order per pair.

As you can see on the attached, the pairs in the blue box bridged perfectly, but the pairs in the yellow box need winding order reversing in order to get the correct result.

Attachments:
Capture.PNG (372.6 KB)

User Avatar
Member
253 posts
Joined: 7月 2006
Offline
Ok, so you do this by comparing the face pair normals. If the angle they form is less than 180, then flip the one pointing away. Technically, use the dot product function in vex.
User Avatar
Member
253 posts
Joined: 7月 2006
Offline
Now that I'm testing this further, it will work better if you compare the face normal to the vector defined by the face center pointing to the other face. To clarify, let's define:

n1 = face normal 1
n2 = face normal 2
fc1 = face center 1
fc2 = face center 2

vec1 = normalize( fc2 - fc1 );
vec2 = normalize( fc1 - fc2 );
dot_p1 = dot( n1, vec1 );
dot_p2 = dot( n2, vec2 );

if ( dot_p1 < 0 ) flip face 1
if ( dot_p2 < 0 ) flip face 2
User Avatar
Member
8 posts
Joined: 3月 2017
Offline
Thanks so much for this, so helpful - it's really appreciated. Will give it a try and come back with results.
  • Quick Links