Behavior of PhysX Scene Queries with Actors Having Multiple Geometries #258
-
Hey 👋 I'm currently working with PhysX in a project where some actors in the scene are composed of multiple geometries (e.g., both a convex mesh and a triangle mesh attached to the same actor). I'm trying to understand how PhysX handles scene queries (raycasts, spherecasts, etc.) in these situations and what the best practices are for managing actors with multiple geometries. Questions:
Any advice, insights, or references to documentation/examples would be greatly appreciated. I'm particularly interested in understanding the best practices for managing actors with multiple geometries to optimize for both performance and accuracy. Thank you in advance for your help! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
When performing scene queries like raycasts or spherecasts against actors with multiple geometries, does PhysX test all geometries attached to the actor by default? Yes. How does PhysX determine which geometry to use in these queries? Is the first hit geometry always chosen, or are all geometries considered? All geometries are considered. Without extra information the scene query does not know if the geometries are used to model a complex shape as part of a compound actor, or if the geometries are used to model the same simple shape but for different sub-systems. So by default it considers all of them. It first tests their (axis-aligned) bounding boxes, and if the query touches these, it tests the actual shapes. Generally speaking you can use the PxShapeFlag::eSCENE_QUERY_SHAPE flag to enable or disable scene-queries as a whole for each shape. In cases where an actor has both a convex mesh and a triangle mesh, what is the recommended approach to ensure the most appropriate geometry is used for different types of scene queries? For example, if I prefer the convex mesh to be used in sweeps but the triangle mesh for raycasting, how can I best manage this? The best way to do that is probably with filtering. This sounds like a job for what used to be called "active groups", see this section: You could use PxShape::setQueryFilterData and set different PxFilterData values for convex meshes and triangle meshes. Then you would use different PxQueryFilterData input parameters in the raycasts & sweeps to filter out either convexes or triangle meshes. If the hardcoded PxFilterData filtering is not enough, you can also use a filter callback (PxQueryFilterCallback) to implement custom filtering there. This is slower but more flexible, as you can access the PxShape object directly there. I can also imagine cases where you could perhaps even have the two sets in different scenes, and perform raycasts against one scene, and sweeps against another scene (but I suspect this is only practical for static geometries). Could anyone share insights or examples on how to effectively implement custom filtering to selectively choose geometries during scene queries based on specific criteria (e.g., preferring one geometry type over another)? I see that we do not have a snippet to demonstrate this. If the above information is not enough we can maybe add one. |
Beta Was this translation helpful? Give feedback.
When performing scene queries like raycasts or spherecasts against actors with multiple geometries, does PhysX test all geometries attached to the actor by default?
Yes.
How does PhysX determine which geometry to use in these queries? Is the first hit geometry always chosen, or are all geometries considered?
All geometries are considered. Without extra information the scene query does not know if the geometries are used to model a complex shape as part of a compound actor, or if the geometries are used to model the same simple shape but for different sub-systems. So by default it considers all of them. It first tests their (axis-aligned) bounding boxes, and if the query touches these, it …