/// <summary> /// Initializes a new instance of the RigidBody class. /// </summary> /// <param name="shape">The shape of the body.</param> /// <param name="isParticle">If set to true the body doesn't rotate. /// Also contacts are only solved for the linear motion part.</param> public RigidBody(Shape shape, BodyMaterial material, bool isParticle) { readOnlyArbiters = new ReadOnlyHashset <Arbiter>(arbiters); readOnlyConstraints = new ReadOnlyHashset <Constraint>(constraints); instanceCount++; instance = instanceCount; hashCode = CalculateHash(instance); this.Shape = shape; orientation = TSMatrix.Identity; if (!isParticle) { updatedHandler = new ShapeUpdatedHandler(ShapeUpdated); this.Shape.ShapeUpdated += updatedHandler; SetMassProperties(); } else { this.inertia = TSMatrix.Zero; this.invInertia = this.invInertiaWorld = TSMatrix.Zero; this.invOrientation = this.orientation = TSMatrix.Identity; inverseMass = FP.One; } AllowDeactivation = true; EnableSpeculativeContacts = false; this.isParticle = isParticle; Update(); }
/// Constructor of CollisionIsland class. /// </summary> public CollisionIsland() { readOnlyBodies = new ReadOnlyHashset <RigidBody>(bodies); readOnlyArbiter = new ReadOnlyHashset <Arbiter>(arbiter); readOnlyConstraints = new ReadOnlyHashset <Constraint>(constraints); }