Universe.Physics.BulletSPlugin.BSPrim.UpdatePhysicalMassProperties C# (CSharp) Method

UpdatePhysicalMassProperties() public method

public UpdatePhysicalMassProperties ( float physMass, bool inWorld ) : void
physMass float
inWorld bool
return void
        public override void UpdatePhysicalMassProperties(float physMass, bool inWorld)
        {
            if (PhysBody.HasPhysicalBody && PhysShape.HasPhysicalShape)
            {
                if (IsStatic)
                {
                    PhysicsScene.PE.SetGravity(PhysBody, PhysicsScene.DefaultGravity);
                    Inertia = OMV.Vector3.Zero;
                    PhysicsScene.PE.SetMassProps(PhysBody, 0.1f, Inertia);    // 20160601 - greythane - was 0f for mass which will always error
                    PhysicsScene.PE.UpdateInertiaTensor(PhysBody);
                }
                else
                {
                    if (inWorld)
                    {
                        // Changing interesting properties doesn't change proxy and collision cache
                        //    information. The Bullet solution is to re-add the object to the world
                        //    after parameters are changed.
                        PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, PhysBody);
                    }

                    // The computation of mass props requires gravity to be set on the object.
                    Gravity = ComputeGravity(Buoyancy);
                    PhysicsScene.PE.SetGravity(PhysBody, Gravity);

                    Inertia = PhysicsScene.PE.CalculateLocalInertia(PhysShape.physShapeInfo, physMass);
                    PhysicsScene.PE.SetMassProps(PhysBody, physMass, Inertia);
                    PhysicsScene.PE.UpdateInertiaTensor(PhysBody);

                    DetailLog("{0},BSPrim.UpdateMassProperties,mass={1},localInertia={2},grav={3},inWorld={4}",
                        LocalID, physMass, Inertia, Gravity, inWorld);

                    if (inWorld)
                    {
                        AddObjectToPhysicalWorld();
                    }
                }
            }
        }