Jump to content
Sign in to follow this  
Masoud

It seems that point wrangle doesn't execute codes line by line, right?

Recommended Posts

Hi Guys;

In point wrangle SOP, when I select some points (in group tab) to apply the codes, the last selected point always overwrite the other ones. It seems that point wrangle doesn't execute codes line by line, right?

When I apply codes to points, one by one  (I mean a point wrangle for each selected point) it works fine.

Please take a look at my files (to visualize it, I applied my attribute to P.y ) :

A.jpg

B.jpg

Attribute Ramp_02.hip

Share this post


Link to post
Share on other sites
Posted (edited)

The point wrangle runs once for every point, in order. So, your foreach is redundant.

The current point number is i@ptnum (an integer), the current points position is v@P (a vector), the current points floating point attribute named blahblah is f@blahblah.

If you want to set the y value in the P you can
 

float var = rand(i@ptnum);
v@P = set(v@P.x, var, v@P.z);

 

Edited by kleer001
clarity

Share this post


Link to post
Share on other sites

Thank you "kleer001", So, how could I handle situations like this?

Share this post


Link to post
Share on other sites

functions that write to not current point like setpointattrib() or create new geometry like addpoint() etc. Are queued in point order and executed on a single thread after all multithreaded code 

However that doesn't really matter in your case as much as the fact that in the single wrangle point() function will never read the updated "y" attribute, it will always read it from the input from so that's why 2 wrangles work for you

You can always flip your code to be other way around and therefore more multithread friendly

Like make all points look within the certain radius for points 17 and 306 and in the loop of found points they will change @y accordingly,  as each point will only change its own value it'll be able to read it back using @y within the for look as expected 

  • Thanks 1

Share this post


Link to post
Share on other sites

Thank you "anim";

Very good points. Honestly, I'm not that good at VEX to solve this. :(

Share this post


Link to post
Share on other sites

something like this:

vector P = @P;
string ptgrp = "17 306";
float radius = chf("MaxDist");
int pts[] = nearpoints(0, ptgrp, P, radius);

foreach(int pt; pts)
{
    vector ptP = point(0, "P", pt);
    float dist = distance(ptP, P);
    float invdist = fit( dist , 0, radius, 2, f@y);  
    f@y = invdist;
}

Attribute Ramp_03_fix.hip

  • Thanks 1

Share this post


Link to post
Share on other sites

Wow, I learned a lot of new things.

Thank you.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×