Has anyone used the new surfacedist vex function?

   2708   3   2
User Avatar
Member
79 posts
Joined: Feb. 2016
Offline
I'm not sure how to correctly set it up.

float surfacedist(<geometry>geometry, string ptgroup, string P_attribute, int search_pt, float max_radius, int &closest_pt, string distance_metric)
User Avatar
Member
670 posts
Joined: Sept. 2013
Offline
surfacedist() lets you measure the distance (f@dist) between a search point and a group of points ('to_be_found') on the same surface and also returns the closest point (i@pt_close) from that group to your search point within a certain radius (1.2).

int pt_search = 1004;
i@pt_close = -1;
f@dist = surfacedist(0, 'to_be_found', 'P', pt_search, 1.2, @pt_close, 'surface');

It can probably also measure between other attributes than position ('P') such as colors or UV coordinates. And it can either run over edges or across polygons ('surface').

Attachments:
surfacedist.hiplc (119.0 KB)

https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
User Avatar
Member
79 posts
Joined: Feb. 2016
Offline
Konstantin Magnus
returns the closest point (i@pt_close)

Hi thanks for the tip, I noticed that you pre-defined the pt_close as -1, why is that? According to the doc,&closest_pt returns
-1 if no closest point was found.
User Avatar
Member
1737 posts
Joined: May 2006
Offline
He could initialise it to anything, it doesn't really matter. This way at least if the surfacedist line is commented out, but he had some nodes or vex later on that was expecting pt_close to be a valid point number, it's guaranteed not to clash with any real point values and break things.
http://www.tokeru.com/cgwiki [www.tokeru.com]
https://www.patreon.com/mattestela [www.patreon.com]
  • Quick Links