Example #1
0
        /// <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();
        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the RigidBody class.
 /// </summary>
 /// <param name="shape">The shape of the body.</param>
 public RigidBody(Shape shape, BodyMaterial material)
     : this(shape, material, false)
 {
 }
Example #3
0
 public MassPoint(Shape shape, SoftBody owner, BodyMaterial material)
     : base(shape, material, true)
 {
     this.SoftBody = owner;
 }