Jump to content
Sign in to follow this  
spectronaut

RaySOP behaving differently than VEX intersect()

Recommended Posts

I have a RaySOP that is doing exactly what I want. It is shooting rays per point along a direction defined by point attribute 'rdir' and is returning the hitprims I'd expect. Hitprims are the green numbers in the images below, yellow lines are visualisation of attribute 'rdir' (raySop shown below)


 raySOP.jpg

 

I want to be better about doing things with VEX so I tried doing the same thing with the same set of points, with the same 'rdir' attribute and same collision geo. I get wildly different results for my hitprims as shown below.
heres the tiny bit of VEX I've got: 

vector p;
vector hitprimuvw;
vector dir = @rdir;
int hitted;

hitted = intersect(1, @P, dir, p, hitprimuvw);
@hitprim = hitted;

vexIntersect.jpg

 

What am I missing?

Share this post


Link to post
Share on other sites

2 things

when you reference your own attributes for the first time in a wrangle you need to declare the type

  v@rdir instead of @rdir, which actually evaluates to (@rdir.x, @rdir.x, @rdir.x)

and then the length of the direction function parameter dictates the max distance that the ray can look for collisions, so in this case you need to multiply it by some scalar so that it can travel far enough to reach your obj. 

 

  • Like 1

Share this post


Link to post
Share on other sites
14 minutes ago, dchow1992 said:

2 things

when you reference your own attributes for the first time in a wrangle you need to declare the type

  v@rdir instead of @rdir, which actually evaluates to (@rdir.x, @rdir.x, @rdir.x)

and then the length of the direction function parameter dictates the max distance that the ray can look for collisions, so in this case you need to multiply it by some scalar so that it can travel far enough to reach your obj. 

 

Yep works now, I knew about the vector length being trace distance (also realize in this example the vector was too short :p) BUT.... I was not aware of the v@derpyderp, good to know. Thank you much.

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  

×