@@ -177,6 +177,7 @@ struct OverlappingObjectSensor : public btCollisionWorld::ContactResultCallback
177
177
std::string object_id_;
178
178
double total_intersecting_volume_;
179
179
double total_penetration_depth_;
180
+ double bounding_box_volume_;
180
181
181
182
// ! Called with each contact for your own processing (e.g. test if contacts fall in within sensor parameters)
182
183
virtual btScalar addSingleResult (btManifoldPoint& cp,
@@ -188,25 +189,30 @@ struct OverlappingObjectSensor : public btCollisionWorld::ContactResultCallback
188
189
189
190
btVector3 pt; // will be set to point of collision relative to body
190
191
std::string other_id;
192
+ bool other_object_is_1;
191
193
if (colObj0->m_collisionObject ==&body_)
192
194
{
193
195
pt = cp.m_localPointA ;
196
+ other_object_is_1 = true ;
194
197
other_id = getObjectIDFromCollisionObject (obj_1);
195
198
}
196
199
else
197
200
{
198
201
assert (colObj1->m_collisionObject ==&body_ && " body does not match either collision object" );
199
202
pt = cp.m_localPointB ;
203
+ other_object_is_1 = false ;
200
204
other_id = getObjectIDFromCollisionObject (obj_0);
201
205
}
202
206
207
+ btAABB shapeAABB_0 = getCollisionAABB (colObj0->getCollisionObject (), cp, true , index0);
208
+ btAABB shapeAABB_1 = getCollisionAABB (colObj1->getCollisionObject (), cp, false , index1);
209
+ bounding_box_volume_ = other_object_is_1 ? getBoundingBoxVolume (shapeAABB_0) : getBoundingBoxVolume (shapeAABB_1);
203
210
if (other_id == " unrecognized_object" || other_id == " background" || other_id == object_id_) return 0 ;
204
211
205
212
// do stuff with the collision point
206
213
total_penetration_depth_ += cp.getDistance () < 0 ? -cp.getDistance () : 0 ;
207
- btAABB shapeAABB_0 = getCollisionAABB (colObj0->getCollisionObject (), cp, true , index0);
208
- btAABB shapeAABB_1 = getCollisionAABB (colObj1->getCollisionObject (), cp, false , index1);
209
-
214
+
215
+
210
216
total_intersecting_volume_ += getIntersectingVolume (shapeAABB_0,shapeAABB_1);
211
217
212
218
return 0 ; // There was a planned purpose for the return value of addSingleResult, but it is not used so you can ignore it.
0 commit comments