Пример #1
0
    public static LVector3 Slerp(LVector3 from, LVector3 to, LFloat t)
    {
        t = LMath.Clamp(t, 0, 1);
        LFloat diff   = Angle(from, to) * LMath.DegToRad;
        LFloat sind   = LMath.Sin(diff);
        LFloat sintd  = LMath.Sin(t * diff);
        LFloat sin1td = LMath.Sin((1 - t) * diff);

        return((sin1td / sind) * from + (sintd / sind) * to);
    }
Пример #2
0
        /// <summary>
        /// Constructor for the bounds octree.
        /// </summary>
        /// <param name="initialWorldSize">Size of the sides of the initial node, in metres. The octree will never shrink smaller than this.</param>
        /// <param name="initialWorldPos">Position of the centre of the initial node.</param>
        /// <param name="minNodeSize">Nodes will stop splitting if the new nodes would be smaller than this (metres).</param>
        /// <param name="loosenessVal">Clamped between 1 and 2. Values > 1 let nodes overlap.</param>
        public BoundsQuadTree(LFloat initialWorldSize, LVector2 initialWorldPos, LFloat minNodeSize, LFloat loosenessVal)
        {
            if (minNodeSize > initialWorldSize)
            {
                Debug.LogWarning("Minimum node size must be at least as big as the initial world size. Was: " +
                                 minNodeSize + " Adjusted to: " + initialWorldSize);
                minNodeSize = initialWorldSize;
            }

            Count       = 0;
            initialSize = initialWorldSize;
            minSize     = minNodeSize;
            looseness   = LMath.Clamp(loosenessVal, 1.ToLFloat(), 2.ToLFloat());
            rootNode    = new BoundsQuadTreeNode(null, initialSize, minSize, looseness, initialWorldPos);
        }
Пример #3
0
            public void DoUpdate(float deltaTime)
            {
                _timer += deltaTime;
                if (_timer > _checkInterval)
                {
                    _timer = 0;
                    if (!hasMissTick)
                    {
                        var preSend = _cmdBuffer._maxPing * 1.0f / NetworkDefine.UPDATE_DELTATIME;
                        _targetPreSendTick = _targetPreSendTick * _oldPercent + preSend * (1 - _oldPercent);

                        var targetPreSendTick = LMath.Clamp((int)System.Math.Ceiling(_targetPreSendTick), 1, 60);
#if UNITY_EDITOR
                        //if (targetPreSendTick != _simulatorService.PreSendInputCount)
                        {
                            Debug.LogWarning(
                                $"Shrink preSend buffer old:{_simulatorService.PreSendInputCount} new:{_targetPreSendTick} " +
                                $"PING: min:{_cmdBuffer._minPing} max:{_cmdBuffer._maxPing} avg:{_cmdBuffer.PingVal}");
                        }
#endif
                        _simulatorService.PreSendInputCount = targetPreSendTick;
                    }

                    hasMissTick = false;
                }

                if (missTick != -1)
                {
                    var delayTick         = _simulatorService.TargetTick - missTick;
                    var targetPreSendTick =
                        _simulatorService.PreSendInputCount + (int)System.Math.Ceiling(delayTick * _incPercent);
                    targetPreSendTick = LMath.Clamp(targetPreSendTick, 1, 60);
#if UNITY_EDITOR
                    Debug.LogWarning(
                        $"Expend preSend buffer old:{_simulatorService.PreSendInputCount} new:{targetPreSendTick}");
#endif
                    _simulatorService.PreSendInputCount = targetPreSendTick;
                    nextCheckMissTick = _simulatorService.TargetTick;
                    missTick          = -1;
                    hasMissTick       = true;
                }
            }
Пример #4
0
            public void DoUpdate(float deltaTime)
            {
                this._timer += deltaTime;
                bool flag = this._timer > this._checkInterval;

                if (flag)
                {
                    this._timer = 0f;
                    bool flag2 = !this.hasMissTick;
                    if (flag2)
                    {
                        float num = (float)this._cmdBuffer._maxPing * 1f / 30f;
                        this._targetPreSendTick = this._targetPreSendTick * this._oldPercent + num * (1f - this._oldPercent);
                        int  num2  = LMath.Clamp((int)System.Math.Ceiling((double)this._targetPreSendTick), 1, 60);
                        bool flag3 = num2 != this._simulatorService.PreSendInputCount;
                        if (flag3)
                        {
                            Debug.LogWarning(string.Format("Shrink preSend buffer old:{0} new:{1} ", this._simulatorService.PreSendInputCount, this._targetPreSendTick) + string.Format("PING: min:{0} max:{1} avg:{2}", this._cmdBuffer._minPing, this._cmdBuffer._maxPing, this._cmdBuffer.PingVal), Array.Empty <object>());
                        }
                        this._simulatorService.PreSendInputCount = num2;
                    }
                    this.hasMissTick = false;
                }
                bool flag4 = this.missTick != -1;

                if (flag4)
                {
                    int num3 = this._simulatorService.TargetTick - this.missTick;
                    int num4 = this._simulatorService.PreSendInputCount + (int)System.Math.Ceiling((double)((float)num3 * this._incPercent));
                    num4 = LMath.Clamp(num4, 1, 60);
                    Debug.LogWarning(string.Format("Expend preSend buffer old:{0} new:{1}", this._simulatorService.PreSendInputCount, num4), Array.Empty <object>());
                    this._simulatorService.PreSendInputCount = num4;
                    this.nextCheckMissTick = this._simulatorService.TargetTick;
                    this.missTick          = -1;
                    this.hasMissTick       = true;
                }
            }
Пример #5
0
 private LFloat(long val)
 {
     value = LMath.Clamp(val, RateNegativeInfinity, RatePositiveInfinity);
 }
Пример #6
0
 public static LQuaternion Lerp(LQuaternion from, LQuaternion to, LFloat t)
 {
     t = LMath.Clamp(t, 0, 1);
     return((1 - t) * from + t * to);
 }