NVIDIAGameWorks / PhysX-3.4

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

PxActorFlag::eDISABLE_SIMULATION explanation #109

Closed Johann-Sch closed 5 years ago

Johann-Sch commented 5 years ago

Hello, I'm confused with the PxActorFlag::eDISABLE_SIMULATION flag.

The API says "[...] can be used to reduce the memory footprint when rigid actors are for scene queries only."

What I was expecting is that the actor and shape sort-of does not exist anymore in the scene while the flag is set, until it is cleared. Thus, "scene queries" like said in the API, if I understand correctly, correspond to raycast, overlap, etc.

The problem is that when raising this flag the physic simulation is correctly stopped, but the collider stays where it is, and when I move to it with my CharacterController, I'm climbing on it, instead of passing through.

So I think I misunderstood this flag, or perhaps that I made something else wrong (see picture of the PVD). disabled_shape

Also, when clearing this flag does the actor get woken up?

Johann-Sch commented 5 years ago

If I'm not mistaken, the fact is that the PxCharacterController uses the scene queries to compute the terrain and objects collision, so only disabling the simulation was not enough, it was also necessary to clear the flag PxShapeFlag::eSCENE_QUERY_SHAPE.

Clearing the flag eDISABLE_SIMULATION does not wake the actor, I have to do it manually with wakeUp() (for kinematic I do setKinematicTarget(getGlobalPose()) to wake an actor up. Dunno if it's the right way, but can't find a better way).