How to delete primitive based on distance from one another?

   885   6   1
User Avatar
Member
6 posts
Joined: 8月 2015
Offline
Is there a way delete primitives based on a distance threshold from other primitives. I have a DNA sphere and it's almost working except there are some single letters primitives (ex like the ones highlighted) still floating around that I'd like to remove with an attribute wrangle. Thanks.
Edited by cpinto - 2023年12月17日 02:38:10

Attachments:
Screenshot 2023-12-17 022831.jpg (206.8 KB)

User Avatar
Member
4544 posts
Joined: 2月 2012
Offline
Hi,

If you don't need to use connectivity, you can create a point per primitive and then perform a point cloud look up like this:

create_pts_per_prim (Primitive Wrangle):

addpoint ( 0, @P );
removeprim ( 0, @primnum, 1 );


id (Point Wrangle):

@id = @ptnum;


pcfind (Point Wrangle):

int pts [ ] = pcfind ( 0, "P", @P, ch("radius"), chi("maxpts") );
if ( len ( pts ) > 1 )
    removepoint ( 0, @ptnum );


delete_prims (Primitive Wrangle):

int index = findattribval ( 1, "point", "id", @primnum );
if ( index == -1 )
    removeprim ( 0, @primnum, 1 );


Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
User Avatar
Member
6 posts
Joined: 8月 2015
Offline
animatrix_
Hi,

If you don't need to use connectivity, you can create a point per primitive and then perform a point cloud look up like this:

create_pts_per_prim (Primitive Wrangle):

addpoint ( 0, @P );
removeprim ( 0, @primnum, 1 );


id (Point Wrangle):

@id = @ptnum;


pcfind (Point Wrangle):

int pts [ ] = pcfind ( 0, "P", @P, ch("radius"), chi("maxpts") );
if ( len ( pts ) > 1 )
    removepoint ( 0, @ptnum );


delete_prims (Primitive Wrangle):

int index = findattribval ( 1, "point", "id", @primnum );
if ( index == -1 )
    removeprim ( 0, @primnum, 1 );



Heya Animatrix_,

Thanks for that, I tried it and it looks like it does the inverse? So it removed everything but the floating circle letter primitives. Is there a way in vex to say do the opposite. Thanks again.

Attachments:
Screenshot 2023-12-17 022832.jpg (102.3 KB)

User Avatar
Member
6 posts
Joined: 8月 2015
Offline
Oh wait, sorry I found it.

I just change the delete_prims wrangle from

"int index = findattribval ( 1, "point", "id", @primnum );
if ( index == -1 )
removeprim ( 0, @primnum, 1 );"

to

"int index = findattribval ( 1, "point", "id", @primnum );
if ( index > -1 )
removeprim ( 0, @primnum, 1 );"
User Avatar
Member
8623 posts
Joined: 7月 2007
Offline
either that or also
if ( len ( pts ) > 1 )
to
if ( len ( pts ) == 1 )

this would delete only points that find only themselves within the radius and therefore are isolated
which may be easier for visualization as it would delete points whose corresponding primitives you want to delete rather than deleting all other points and then delete prims for remaining points
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
4544 posts
Joined: 2月 2012
Offline
cpinto
Oh wait, sorry I found it.

I just change the delete_prims wrangle from

"int index = findattribval ( 1, "point", "id", @primnum );
if ( index == -1 )
removeprim ( 0, @primnum, 1 );"

to

"int index = findattribval ( 1, "point", "id", @primnum );
if ( index > -1 )
removeprim ( 0, @primnum, 1 );"

Oh yes sorry I didn't realize you wanted the inverse. So you could just do it like you did or tamte but in your example, the proper inversion is:

int index = findattribval ( 1, "point", "id", @primnum );
if ( index != -1 )
    removeprim ( 0, @primnum, 1 );
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
User Avatar
Member
6 posts
Joined: 8月 2015
Offline
Ah ok, thanks for the help folks and explanations.
  • Quick Links