Beispiel #1
0
 void AddCollidableToBroadPhase(int bodyHandle, ref RigidPose pose, ref BodyInertia localInertia, ref Collidable collidable)
 {
     //This body has a collidable; stick it in the broadphase.
     //Note that we have to calculate an initial bounding box for the broad phase to be able to insert it efficiently.
     //(In the event of batch adds, you'll want to use batched AABB calculations or just use cached values.)
     //Note: the min and max here are in absolute coordinates, which means this is a spot that has to be updated in the event that positions use a higher precision representation.
     shapes.UpdateBounds(ref pose, ref collidable.Shape, out var bodyBounds);
     //Note that new body collidables are always assumed to be active.
     collidable.BroadPhaseIndex =
         broadPhase.AddActive(
             new CollidableReference(IsKinematic(ref localInertia) ? CollidableMobility.Kinematic : CollidableMobility.Dynamic, bodyHandle),
             ref bodyBounds);
 }