Beispiel #1
0
        public virtual Vector3 AdjustRawSteeringForce(Vector3 force)
        {
            float num = 0.2f * base.MaxSpeed;

            if (base.Speed > num || force == Vector3.get_zero())
            {
                return(force);
            }
            float num2 = base.Speed / num;
            float cosineOfConeAngle = Mathf.Lerp(1f, -1f, Mathf.Pow(num2, 20f));

            return(OpenSteerUtility.limitMaxDeviationAngle(force, cosineOfConeAngle, base.Forward));
        }
Beispiel #2
0
        // ----------------------------------------------------------------------------
        // adjust the steering force passed to applySteeringForce.
        //
        // allows a specific vehicle class to redefine this adjustment.
        // default is to disallow backward-facing steering at low speed.
        //
        // xxx should the default be this ad-hocery, or no adjustment?
        // xxx experimental 8-20-02
        //
        // parameter names commented out to prevent compiler warning from "-W"
        //
        // NOTE RJM: Upon profiling, this seems to be about 25% of what
        // applySteeringForce is doing. It might be worth reviewing if it
        // should be kept around, considering that CWR was unsure if this
        // "ad-hocery" should remain as default.
        //
        // This sort of adjustment is definitely useful for vehicles such
        // as the lightning chain, but might not need to be on the base
        // class.
        public virtual Vector3 AdjustRawSteeringForce(Vector3 force)
        {
            // Do force adjustment only if the speed is a fifth of our
            // maximum valid speed
            float maxAdjustedSpeed = 0.2f * MaxSpeed;

            if ((Speed > maxAdjustedSpeed) || (force == Vector3.zero))
            {
                return(force);
            }
            else
            {
                float   range  = Speed / maxAdjustedSpeed;
                float   cosine = Mathf.Lerp(1.0f, -1.0f, Mathf.Pow(range, 20));
                Vector3 angle  = OpenSteerUtility.limitMaxDeviationAngle(force, cosine, Forward);
                return(angle);
            }
        }