Example #1
0
        private void RemoveRigidBody(RigidBody body, BodyCustomData cdata)
        {
            this.dynamicsWorld.DeleteAndDisposeBody(body);

            if (this.RigidBodyDeleted != null)
            {
                this.RigidBodyDeleted(body, cdata.Id);
            }
        }
        public static Tuple <RigidBody, int> CreateRigidBody(this IRigidBodyContainer world, CollisionShape collisionShape, ref RigidBodyPose initialPose, ref RigidBodyProperties bodyProperties, ref BulletSharp.Vector3 localInertia, float mass)
        {
            DefaultMotionState motionState = new DefaultMotionState((BulletSharp.Matrix)initialPose);

            RigidBodyConstructionInfo constructionInfo = new RigidBodyConstructionInfo(mass, motionState, collisionShape, localInertia);

            constructionInfo.ApplyRigidBodyProperties(ref bodyProperties);

            RigidBody rigidBody = new RigidBody(constructionInfo);

            rigidBody.CollisionFlags = CollisionFlags.None;
            rigidBody.ApplyProperties(ref bodyProperties);

            BodyCustomData customData = new BodyCustomData(world.GetNewBodyId());

            rigidBody.UserObject = customData;

            world.Register(rigidBody);
            return(new Tuple <RigidBody, int>(rigidBody, customData.Id));
        }