LengthXY() public static method

public static LengthXY ( v3f &v ) : float
v v3f
return float
コード例 #1
0
ファイル: ServerUser.cs プロジェクト: JakeSmokie/SharpQuake
        /// <summary>
        /// SV_UserFriction
        /// </summary>
        static void UserFriction()
        {
            float speed = Mathlib.LengthXY(ref _Player.v.velocity);

            if (speed == 0)
            {
                return;
            }

            // if the leading edge is over a dropoff, increase friction
            Vector3 start, stop;

            start.X = stop.X = _Player.v.origin.x + _Player.v.velocity.x / speed * 16;
            start.Y = stop.Y = _Player.v.origin.y + _Player.v.velocity.y / speed * 16;
            start.Z = _Player.v.origin.z + _Player.v.mins.z;
            stop.Z  = start.Z - 34;

            trace_t trace    = Move(ref start, ref Common.ZeroVector, ref Common.ZeroVector, ref stop, 1, _Player);
            float   friction = _Friction.Value;

            if (trace.fraction == 1.0)
            {
                friction *= _EdgeFriction.Value;
            }

            // apply friction
            float control  = speed < _StopSpeed.Value ? _StopSpeed.Value : speed;
            float newspeed = (float)(speed - Host.FrameTime * control * friction);

            if (newspeed < 0)
            {
                newspeed = 0;
            }

            newspeed /= speed;

            Mathlib.VectorScale(ref _Player.v.velocity, newspeed, out _Player.v.velocity);
        }