pcopen to add points based on distance
2548 3 1- AndyW
- Member
- 336 posts
- Joined: Dec. 2014
- Offline
- jlait
- Staff
- 6204 posts
- Joined: July 2005
- Offline
I strongly recommend using pcfind() instead. The pciterate loop is a bit odd, and pcimport doesn't help you with general attribute import problems, while the point() works everywhere.
Note the difference between len() and length().
// If closest point to us is farther than threshold,
// add point at midpoint
float threshold = 1;
int nearpts[] = pcfind(0, 'P', @P, /*maxdist*/1e20, /*numpt*/ 2);
// Nearest point is ourself, so we are interested in second
if (len(nearpts) > 1)
{
int pt = nearpts[1];
vector npos = point(0, 'P', pt);
if (length(@P - npos) > threshold)
{
// Too far, add a point.
vector midpoint = (npos + @P) / 2;
addpoint(geoself(), midpoint);
}
}
Note the difference between len() and length().
- animatrix_
- Member
- 4515 posts
- Joined: Feb. 2012
- Offline
One thing to note with pcopen though, there is a free pcfilter function which you will have to implement yourself for pcfind. SESI should provide one that works with arrays so pcfind can be used more often.
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 | animatrix2k7.gumroad.com
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
- AndyW
- Member
- 336 posts
- Joined: Dec. 2014
- Offline
-
- Quick Links