closest point - ray SOP in VEX

   7226   4   2
User Avatar
Member
581 posts
Joined: July 2005
Offline
Hi houdiniks.
As an excersise I am trying to create a ray SOP but in VEX.
I manage to get all the ray intersecting stuff done.
But now I am trying to mimic the closest point mode from the ray SOP.
At the moment I made a try with brute force, basically I loop every point from the destination geometry and compare the distance against my current point, finally I get the point closer to the current point.
Theorically this should work, but I get weird results. Maybe cos VEX is executed in SIMD and then the variable storing the minimum distance is writted by several sampled points at a time?
Not sure, somebody have tried this before?
I have attached a file with the VOP SOP I am using.
thx

Attachments:
vex_ray.hipnc (820.8 KB)

Un saludo
Best Regards

Pablo Giménez
User Avatar
Member
2199 posts
Joined: July 2005
Offline
In theory that should work, but will be painfully slow except in very simple cases.
You should look at doing this will a point cloud as that can automatically return the closest point. Of course the ray sop will actually return the closest point on a poly but once you have the closest point you could loop through the connected points and find the actually closest point on the surface.
The trick is finding just the right hammer for every screw
User Avatar
Member
581 posts
Joined: July 2005
Offline
Simon
In theory that should work, but will be painfully slow except in very simple cases.
You should look at doing this will a point cloud as that can automatically return the closest point. Of course the ray sop will actually return the closest point on a poly but once you have the closest point you could loop through the connected points and find the actually closest point on the surface.
Yes I have though about using a point cloud.
Can I use a regular .bgeo file as a point cloud?
Or I have to save the geometry with the .pc extension?
Still, only for curiosity, if anybody can tell me why the VOP SOP I made is not working correctly will be great.
cheers
Un saludo
Best Regards

Pablo Giménez
User Avatar
Member
2199 posts
Joined: July 2005
Offline
You can point straight to a bgeo, or use the op: syntax to point straight to a sop
Edited by - Oct. 29, 2008 05:08:36
The trick is finding just the right hammer for every screw
User Avatar
Member
581 posts
Joined: July 2005
Offline
Simon
You can point straight to a bgeo, or use the op: syntax to point staright to a sop
Thanks Simon it worked really well.
Are amazing th things you can do with point clouds.
Un saludo
Best Regards

Pablo Giménez
  • Quick Links