Sign in to follow this  

Odd ray intersect behavior

This topic is 2533 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

EDIT: Of course after fighting it for 3 days I figure it out 5 minutes after I post. The correct way to do it was to calculate a direction based off the source and taget vectors.

public Ray CalculateRay(Vector3 src, Vector3 tar)
Vector3 direction = (tar - src);
return new Ray(src,direction);

It looks like a mess but it works on every test I threw at it. Posted this solution incase someone has a similar problem.

............ Original Post:

Hi there, I'm having some odd ray to bounding box intersection issues. I have working picking code and its pixel perfect but when I use rays in this manor, it claims collisions where it shouldn't and doesn't where it should. (Box one the end of the top row should be shadowed by the one to its left)

I'm working on some basic lights and using rays to determine shadows etc.


As you can see in this one, the rays start at the top of the box only and goes directly to the light source:
(I am not checking for collision on the origin squares bounding box)


Now to me it looks like the ray intersect is calculating it as if the ray were pointing straight up in the air with no angle. The ones below the top layer collide with the cube above it but ones at the top don't collide with the ones next to them.

I have verified that the bounding boxes are perfectly aligned to each cube and the only thing i can see is that the picking code uses matrix data to align itself. Do i need to adjust the rays for the world matrix or some such? Right now I'm making rays by simply Ray ry = new Ray(SourceVector3, TargetVector3) and that's it.

Share this post

Link to post
Share on other sites
Sign in to follow this