NVIDIAGameWorks / PhysX-3.4

NVIDIA PhysX SDK 3.4
https://www.nvidia.com/
2.34k stars 275 forks source link

Some questions about collision callback #106

Open xinyue89 opened 5 years ago

xinyue89 commented 5 years ago

Hello, everyone, my requirement is: there is a dynamic ball in the scene, an approximate plane composed of several smaller static balls, and the dynamic ball rolls on this approximate plane. When the dynamic ball rolls, I hope to get the static ball ID of each collision and the dynamic ball speed after each collision. Is it possible to achieve this requirement in PhysX? I am a student and new to PhysX, and I need to achieve this requirement as soon as possible, so I cannot learn PhysX systematically. I hope to get your help, thank you!

kstorey-nvidia commented 5 years ago

The contact callback happens in fetchResults() before the bodies' velocities and poses have been synchronized with the internal simulation state. Therefore, you can get access to colliding shapes/actor pointers, the bodies' velocities before collision response and the forces applied by each contact. After the contact callbacks have finished, the bodies' velocities are updated to match the internal simulated state.