private void CheckDeactivation() { // A body deactivation DOESN'T kill the contacts - they are stored in // the arbitermap within the arbiters. So, waking up ist STABLE - old // contacts are reused. Also the collisionislands build every frame (based // on the contacts) keep the same. for (int i = 0; i < islands.Count; i++) { CollisionIsland island = islands[i]; bool deactivateIsland = true; // global allowdeactivation if (!this.AllowDeactivation) { deactivateIsland = false; } else { foreach (RigidBody body in island.bodies) { // body allowdeactivation if (body.AllowDeactivation && (body.angularVelocity.LengthSquared() < inactiveAngularThresholdSq && (body.linearVelocity.LengthSquared() < inactiveLinearThresholdSq))) { body.inactiveTime += timestep; if (body.inactiveTime < deactivationTime) { deactivateIsland = false; } } else { body.inactiveTime = 0.0f; deactivateIsland = false; } } } foreach (RigidBody body in island.bodies) { if (body.isActive == deactivateIsland) { if (body.isActive) { body.IsActive = false; events.RaiseDeactivatedBody(body); } else { body.IsActive = true; events.RaiseActivatedBody(body); } } } } }
private void CheckDeactivation() { if (!AllowDeactivation) { return; } // A body deactivation DOESN'T kill the contacts - they are stored in // the arbitermap within the arbiters. So, waking up ist STABLE - old // contacts are reused. Also the collisionislands build every frame (based // on the contacts) keep the same. foreach (CollisionIsland island in islands) { bool deactivateIsland = true; // global allowdeactivation if (!this.AllowDeactivation) { deactivateIsland = false; } else { for (int index = 0, length = island.bodies.Count; index < length; index++) { RigidBody body = island.bodies[index]; // body allowdeactivation if (body.AllowDeactivation && (body.angularVelocity.sqrMagnitude < inactiveAngularThresholdSq && (body.linearVelocity.sqrMagnitude < inactiveLinearThresholdSq))) { body.inactiveTime += timestep; if (body.inactiveTime < deactivationTime) { deactivateIsland = false; } } else { body.inactiveTime = FP.Zero; deactivateIsland = false; } } } for (int index = 0, length = island.bodies.Count; index < length; index++) { RigidBody body = island.bodies[index]; if (body.isActive == deactivateIsland) { if (body.isActive) { body.IsActive = false; events.RaiseDeactivatedBody(body); } else { body.IsActive = true; events.RaiseActivatedBody(body); } } } } }