Jump to content
  • Advertisement
Sign in to follow this  
Tang of the Mountain

PhysX Ray Cast issue

This topic is 4149 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

Ok, so I'm using PhysX and Ogre. I've started using raycasts in my scene for random queries etc. All is wroking fine(for the most part). Entities are being hit, the collision points are working properly etc etc. Heres the problem. I have 1 NxRay for each direction for debugging purposes. Lets say I have a concave building or a piece of terrain or something in which one ray cast should intersect with several faces of one enity. Im seeing a problem where after one collision is detected for an entity, in this case we will use a building, the raycast returns no more collision points for the rest of the ray on that entity. If i hav a 'U' shaped building and cast from the left side through the right, i have one collision for the initial point of contact, and the next point shows nothing. Is this a limitation? I wouldnt think so because it would be incredibly limiting and thus I believe I am doing something wrong. However, the documentation is lacking with specifics and it mentions nothing of the inability to raycast multiple points on one entity in the caveats. Ill post code if the problem isnt caused by a known issue, or a common mistake. Any help would be terrific. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
This is the usual behaviour. If you need further intersection points, just recast the ray from a point a little behind the last intersection

Share this post


Link to post
Share on other sites
Thanks for the heads up.

I implemented the modified ray cast, however, an anomaly has come up, or maybe a tiny sliver of inconcise programming.

Psuedo code:


store max ray distance
cast ray

while (valid shape hit)
add data to list
subtract distance to that point from max ray cast distance
move ray cast orgin to collision point
nudge the new origin by direction * 0.001 //else infinite loop
recast ray


The problem lies in the accuracy. The further away I get from the original cast, the more the rendered ray cast line differes from the actual rendered collision point. Eventually, across my entire scene the ray is a good 5-15 units off, left to right, never up and down. The error can be seen starting from roughly 2-5 units from the entity im casting from.

Does this have something to do with cooking the meshes changing the faces? or Is my nudging the new position having an adverse effect on my direction?


Any help is appreciated as always.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!