NVIDIAGameWorks/PhysX

Distance to Ground

Closed this issue · 1 comments

What would be the best way for a game entity to detect its distance from the ground in PhysX?

Several of the dynamic objects in my engine rely on their distance to the ground to change their behavior. Up until PhysX, I had been polling for this information by using a Y-axis-aligned ray cast directly down, every frame. I used my own optimized method to test for this (a lot of optimizations can be made when the ray always points directly down).

Now that I'm relying on PhysX for everything, I'd like to not have to keep my own versions of collision meshes and etc. What would be the most performance friendly way to check for ground distance for several objects in a scene? Would it be a normal scene raycast? Or is there a simpler or more efficient method to achieve the same result?

Thanks for any advice!

If scene raycasts work for you in your current engine, I see no reason why they wouldn't work with PhysX. Raycasts shouldn't be too slow. You can either raycast the full scene, raycast only the static scene or raycast against a specific geometry that you want to query against (you can do this using PxGeometryQuery rather than scene query API).