Universe.Physics.BulletSPlugin.BSDynamics.ComputeAngularBanking C# (CSharp) Method

ComputeAngularBanking() public method

public ComputeAngularBanking ( ) : void
return void
        public void ComputeAngularBanking()
        {
            if (BSParam.VehicleEnableAngularBanking && m_bankingEfficiency != 0 &&
                m_verticalAttractionTimescale < m_verticalAttractionCutoff)
            {
                Vector3 bankingContributionV = Vector3.Zero;

                // Rotate a UnitZ vector (pointing up) to how the vehicle is oriented.
                // As the vehicle rolls to the right or left, the Y value will increase from
                //     zero (straight up) to 1 or -1 (full tilt right  or left)
                Vector3 rollComponents = Vector3.UnitZ * VehicleFrameOrientation;

                // Figure out the yaw value for this much roll.
                float yawAngle = m_angularMotorDirection.X * m_bankingEfficiency;
                //        actual error  =       static turn error            +           dynamic turn error
                float mixedYawAngle = (yawAngle * (1f - m_bankingMix)) + ((yawAngle * m_bankingMix) * VehicleForwardSpeed);

                // TODO: the banking effect should not go to infinity but what to limit it to?
                //     And what should happen when this is being added to a user defined yaw that is already PI*4?
                mixedYawAngle = ClampInRange(-FourPI, mixedYawAngle, FourPI);

                // Build the force vector to change rotation from what it is to what it should be
                bankingContributionV.Z = -mixedYawAngle;

                // Don't do it all at once. Fudge because 1 second is too fast with most user defined roll as PI*4.
                bankingContributionV /= m_bankingTimescale * BSParam.VehicleAngularBankingTimescaleFudge;

                //VehicleRotationalVelocity += bankingContributionV * VehicleFrameOrientation;
                VehicleRotationalVelocity += bankingContributionV;


                VDetailLog("{0},  MoveAngular,Banking,rollComp={1},speed={2},rollComp={3},yAng={4},mYAng={5},ret={6}",
                    ControllingPrim.LocalID, rollComponents, VehicleForwardSpeed, rollComponents, yawAngle,
                    mixedYawAngle, bankingContributionV);
            }
        }