Sensor per shape #236
-
The way I see is shape should have a property to act as Sensor or not, Is it okay to do it using OnContactAdded() in the contact listener? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
In most cases you would create a body with mIsSensor = true to make it a sensor for all other bodies, but you can override OnContactAdded and OnContactPersisted to set ioSettings.mIsSensor = true to make a specific contact act as a sensor. Note that it is possible for contacts to be merged, so you may not get a callback for every (inBody1, inManifold.mSubShapeID1, inBody2, inManifold.mSubShapeID2) pair if the contacts have the same normal. Contact merging can be turned off with PhysicsSettings::mUseManifoldReduction = false, but this comes at a big performance cost. In general, if you want to have a sensor attached to a normal body, I would recommend to create a 2nd body that is a sensor and update its position/rotation every frame to match the position/rotation of the 1st body. |
Beta Was this translation helpful? Give feedback.
In most cases you would create a body with mIsSensor = true to make it a sensor for all other bodies, but you can override OnContactAdded and OnContactPersisted to set ioSettings.mIsSensor = true to make a specific contact act as a sensor.
Note that it is possible for contacts to be merged, so you may not get a callback for every (inBody1, inManifold.mSubShapeID1, inBody2, inManifold.mSubShapeID2) pair if the contacts have the same normal. Contact merging can be turned off with PhysicsSettings::mUseManifoldReduction = false, but this comes at a big performance cost.
In general, if you want to have a sensor attached to a normal body, I would recommend to create a 2nd body that is a sensor …