Jump to content

RaySOP behaving differently than VEX intersect()


spectronaut

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?

Link to comment
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
Link to comment
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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...