since neither the RTX Lidar nor the generic range sensor have the behaviour we need for our Lidar simulation, I would like to do some fast PhysX raycasting in my own C++ extension. Using the Python raycast command seems too slow to simulate multiple Lidars in an custom Python extension.
Could someone please point me to some sample code or docs on how to convert a UsdPhysicsScene into a PxScene?
Upon each ray intersection with an element in the PxScene I would like to get a pointer to the corresponding prim that got hit. Is that possible, and how? Reason: I would like to retrieve the material of that prim.
Once you have this interface you can translate between PhysX SDK and USD.
From USD to PhysX SDK you can use:
PxScene* scene = reinterpret_cast<PxScene*>(physxI->getPhysXPtr(physicsScenePath, ePTScene));
Then you can do what ever raycasting you need.
Now back from PhysX SDK to USD you can use its userData value to get translated to SdfPath, eventually you can use getName - thats the string version of the SdfPath but we treat it more of a debug information rather then fixed data. The userData have always in index into our internal database so we can return USD path:
I am not sure what all you need to do, but you can use the C++ interface on IPhysxSceneQuery, there is raycast/sweep etc exposed and it does return already translated values.
Hi AlesBorovicka,
many thanks for your reply. I might not necessarily need not use PhysX, maybe IPhysXSceneQuery is sufficient, I don’t know yet. I just did not came up in my searches. Do you happen to have some documentation you could link here?
Cheers,
Markus
We are in the process of open sourcing examples and environment how to access the omni physx interfaces, this will still take a while. Sorry about that.
Regards,
Ales
@AlesBorovicka Thank you. I plan to simply get the triangles from USD using UsdImagingMeshAdapter use the OptiX or CUDA libraries… Do you feel there is a conflict in linking to optix as an external library from Omniverse.
No I dont think there is a conflict, this is kind of exactly what we are planning to release (with PhysX SDK usage), to showcase how to use eventually directly PhysX SDK for raycasting, while leveraging already existing infrastructure that can for example cook PhysX SDK mesh data from USD. Again its in the process unfortunately, will be available later this year.
I am also interested in querying a USD scene heavily.
From what I gathered, PhysX raycasting runs on the CPU. If so, am I correct to presume that the built-in query that is currently being built won’t run on the GPU, and if I do want that capability I should do the same as usr39947 and link Optix?