public override void ReportProximities(ChProximityContainer mproximitycontainer) { mproximitycontainer.BeginAddProximities(); /* * int numManifolds = bt_collision_world->getDispatcher()->getNumManifolds(); * for (int i = 0; i < numManifolds; i++) { * btPersistentManifold* contactManifold = bt_collision_world->getDispatcher()->getManifoldByIndexInternal(i); * btCollisionObject* obA = static_cast<btCollisionObject*>(contactManifold->getBody0()); * btCollisionObject* obB = static_cast<btCollisionObject*>(contactManifold->getBody1()); * contactManifold->refreshContactPoints(obA->getWorldTransform(), obB->getWorldTransform()); * * ChCollisionModel* modelA = (ChCollisionModel*)obA->getUserPointer(); * ChCollisionModel* modelB = (ChCollisionModel*)obB->getUserPointer(); * * // Add to proximity container * mproximitycontainer->AddProximity(modelA, modelB); * } */ int numPairs = bt_collision_world.GetBroadphase().GetOverlappingPairCache().GetNumOverlappingPairs(); for (int i = 0; i < numPairs; i++) { BroadphasePair mp = bt_collision_world.GetBroadphase().GetOverlappingPairCache().GetOverlappingPairArray()[i]; CollisionObject obA = (CollisionObject)(mp.m_pProxy0.GetClientObject()); CollisionObject obB = (CollisionObject)(mp.m_pProxy1.GetClientObject()); ChCollisionModel modelA = (ChCollisionModel)obA.GetUserPointer(); ChCollisionModel modelB = (ChCollisionModel)obB.GetUserPointer(); // Add to proximity container mproximitycontainer.AddProximity(modelA, modelB); } mproximitycontainer.EndAddProximities(); }
/// After the Run() has completed, you can call this function to /// fill a 'proximity container' (container of narrow phase pairs), that is /// an object inherited from class ChProximityContainer. For instance ChSystem, after each Run() /// collision detection, calls this method multiple times for all proximity containers in the system, /// Children classes _must_ implement this. /// The basic behavior of the implementation should be the following: collision system /// will call in sequence the functions BeginAddProximities(), AddProximity() (x n times), /// EndAddProximities() of the proximity container. /// In case a specialized implementation (ex. a GPU parallel collision engine) /// finds that the proximity container is a specialized one (ex with a GPU buffer) /// it can call more performant methods to add directly the proximities in batches, for instance /// by recognizing that he can call, say, some special AddAllProximitiesAsGpuBuffer() instead of many /// AddProximity(). public abstract void ReportProximities(ChProximityContainer mproximitycontainer);