Jump to content

a faster ray SOP


Recommended Posts

Hio, I'm finding that I love love love the ray SOP, but it's too slow.

The Point Wrangle SOP, lovely as it is, is a little opaque to me. I don't have a lot of VEX experience.

But what I think I need is the "rayhittest" function, but I can't seem to get it to work. I get the error "Call to undefined function 'rayhittest'..."


See attached.




Link to comment
Share on other sites

In an effort to learn some VEX I figured out how to use Intersect in a Point Wrangle. It's a bit different than using the same in a VOPSOP where it is very straightforward in my opinion. It got very basic functionality versus the Ray SOP, and it may not be very clean, but I'm sharing my result anyway:

int hitprim;
int input;
vector pos;
float hitu;
float hitv;
vector dist;
vector lift;
float maxdist;
vector scale;
input = 1; //which input to collide with
dist = @N * 1; //the length of N is distance of the ray, so multiply to increase distance
lift = @N * 0; //the amount to lift after points have been rayed
maxdist = clamp(length(@N), 0, 1); //if you want a max distance
scale = 1; //scale of the operation
i@hitprim = intersect(input, @P, dist * maxdist, v@pos, f@hitu, f@hitv);
@P = (((@pos + lift) - @P)*scale)+@P;
  • Like 2
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.

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...