public static NetQuaternionDelta Delta(NetQuaternion from, NetQuaternion to, ushort bitlarge)
        {
            int num  = to.x - from.x;
            int num2 = to.y - from.y;
            int num3 = to.z - from.z;
            int num4 = 1 << bitlarge - 1;

            if (num < -num4 || num >= num4 || num2 < -num4 || num2 >= num4 || num3 < -num4 || num3 >= num4)
            {
                NetQuaternionDelta result = default(NetQuaternionDelta);
                result.isRelative = false;
                result.sel        = to.sel;
                result.x          = to.x;
                result.y          = to.y;
                result.z          = to.z;
                return(result);
            }
            NetQuaternionDelta result2 = default(NetQuaternionDelta);

            result2.isRelative = true;
            result2.sel        = to.sel;
            result2.x          = num;
            result2.y          = num2;
            result2.z          = num3;
            return(result2);
        }
 public static NetQuaternion AddDelta(NetQuaternion from, NetQuaternionDelta delta)
 {
     if (delta.isRelative)
     {
         return(new NetQuaternion(delta.sel, from.x + delta.x, from.y + delta.y, from.z + delta.z, from.bits));
     }
     return(new NetQuaternion(delta.sel, delta.x, delta.y, delta.z, from.bits));
 }
        public static NetQuaternionDelta WorstCaseDelta(NetQuaternion from, NetQuaternion to)
        {
            NetQuaternionDelta result = default(NetQuaternionDelta);

            result.isRelative = false;
            result.sel        = to.sel;
            result.x          = to.x;
            result.y          = to.y;
            result.z          = to.z;
            return(result);
        }
        public void AddDelta(NetStream state0, NetStream delta, NetStream result, bool readChanged = true)
        {
            NetQuaternion from = (state0 != null) ? NetQuaternion.Read(state0, fullBits) : NetQuaternion.Quantize(startRot, fullBits);

            if (delta == null || (readChanged && !delta.ReadBool()))
            {
                from.Write(result);
                return;
            }
            NetQuaternionDelta delta2 = NetQuaternionDelta.Read(delta, deltaSmall, deltaLarge, fullBits);

            NetQuaternion.AddDelta(from, delta2).Write(result);
        }
示例#5
0
 public void AddDelta(NetStream state0, NetStream delta, NetStream result)
 {
     if (syncPosition == NetBodySyncPosition.Relative || syncPosition == NetBodySyncPosition.Absolute || syncPosition == NetBodySyncPosition.Local || syncPosition == NetBodySyncPosition.World || syncRotation == NetBodySyncRotation.Relative || syncRotation == NetBodySyncRotation.Absolute || syncRotation == NetBodySyncRotation.Local || syncRotation == NetBodySyncRotation.World)
     {
         if (delta.ReadBool())
         {
             if (syncPosition != 0)
             {
                 NetVector3      from   = (state0 != null) ? NetVector3.Read(state0, posfull) : zero;
                 NetVector3Delta delta2 = NetVector3Delta.Read(delta, possmall, poslarge, posfull);
                 NetVector3.AddDelta(from, delta2).Write(result);
             }
             if (syncRotation == NetBodySyncRotation.Relative || syncRotation == NetBodySyncRotation.Absolute || syncRotation == NetBodySyncRotation.Local || syncRotation == NetBodySyncRotation.World)
             {
                 NetQuaternion      from2  = (state0 != null) ? NetQuaternion.Read(state0, rotfull) : identity;
                 NetQuaternionDelta delta3 = NetQuaternionDelta.Read(delta, rotsmall, rotlarge, rotfull);
                 NetQuaternion.AddDelta(from2, delta3).Write(result);
             }
         }
         else
         {
             if (syncPosition != 0)
             {
                 ((state0 != null) ? NetVector3.Read(state0, posfull) : zero).Write(result);
             }
             if (syncRotation == NetBodySyncRotation.Relative || syncRotation == NetBodySyncRotation.Absolute || syncRotation == NetBodySyncRotation.Local || syncRotation == NetBodySyncRotation.World)
             {
                 ((state0 != null) ? NetQuaternion.Read(state0, rotfull) : identity).Write(result);
             }
         }
     }
     if (syncRotation == NetBodySyncRotation.EulerX || syncRotation == NetBodySyncRotation.EulerY || syncRotation == NetBodySyncRotation.EulerZ)
     {
         eulerEncoder.AddDelta(state0, delta, result);
     }
     if (syncLocalScale)
     {
         if (delta.ReadBool())
         {
             NetVector3      from3  = (state0 != null) ? NetVector3.Read(state0, posfull) : zero;
             NetVector3Delta delta4 = NetVector3Delta.Read(delta, possmall, poslarge, posfull);
             NetVector3.AddDelta(from3, delta4).Write(result);
         }
         else
         {
             ((state0 != null) ? NetVector3.Read(state0, posfull) : zero).Write(result);
         }
     }
 }
示例#6
0
        public int CalculateMaxDeltaSizeInBits()
        {
            int num = 0;

            if (syncPosition == NetBodySyncPosition.Relative || syncPosition == NetBodySyncPosition.Absolute || syncPosition == NetBodySyncPosition.Local || syncPosition == NetBodySyncPosition.World || syncRotation == NetBodySyncRotation.Relative || syncRotation == NetBodySyncRotation.Absolute || syncRotation == NetBodySyncRotation.Local || syncRotation == NetBodySyncRotation.World)
            {
                num++;
                num += NetVector3Delta.CalculateMaxDeltaSizeInBits(possmall, poslarge, posfull);
                num += NetQuaternionDelta.CalculateMaxDeltaSizeInBits(rotsmall, rotlarge, rotfull);
            }
            if (syncRotation == NetBodySyncRotation.EulerX || syncRotation == NetBodySyncRotation.EulerY || syncRotation == NetBodySyncRotation.EulerZ)
            {
                num += eulerEncoder.CalculateMaxDeltaSizeInBits();
            }
            if (syncLocalScale)
            {
                num++;
                num += NetVector3Delta.CalculateMaxDeltaSizeInBits(possmall, poslarge, posfull);
            }
            return(num);
        }
示例#7
0
        public static NetQuaternionDelta Read(NetStream stream, ushort bitsmall, ushort bitlarge, ushort bitfull)
        {
            NetQuaternionDelta netQuaternionDelta = default(NetQuaternionDelta);

            netQuaternionDelta.isRelative = stream.ReadBool();
            netQuaternionDelta.sel        = (byte)(stream.ReadInt32(2) & 3);
            NetQuaternionDelta result = netQuaternionDelta;

            if (result.isRelative)
            {
                result.x = stream.ReadInt32(bitsmall, bitlarge);
                result.y = stream.ReadInt32(bitsmall, bitlarge);
                result.z = stream.ReadInt32(bitsmall, bitlarge);
            }
            else
            {
                result.x = stream.ReadInt32(bitfull);
                result.y = stream.ReadInt32(bitfull);
                result.z = stream.ReadInt32(bitfull);
            }
            return(result);
        }
示例#8
0
        public void ReadDelta(NetStream stream, NetStream reference, NetStream fullStream)
        {
            bool          flag          = stream.ReadBool();
            NetVector3    netVector     = (reference != null) ? NetVector3.Read(reference, 18) : default(NetVector3);
            NetQuaternion netQuaternion = (reference != null) ? NetQuaternion.Read(reference, 9) : default(NetQuaternion);
            NetVector3    netVector2;
            NetQuaternion netQuaternion2;

            if (flag)
            {
                NetVector3Delta delta = NetVector3Delta.Read(stream, 5, 9, 18);
                netVector2 = NetVector3.AddDelta(netVector, delta);
                NetQuaternionDelta delta2 = NetQuaternionDelta.Read(stream, 5, 8, 9);
                netQuaternion2 = NetQuaternion.AddDelta(netQuaternion, delta2);
            }
            else
            {
                netVector2     = netVector;
                netQuaternion2 = netQuaternion;
            }
            netVector2.Write(fullStream);
            netQuaternion2.Write(fullStream);
        }
 public int CalculateMaxDeltaSizeInBits()
 {
     return(NetQuaternionDelta.CalculateMaxDeltaSizeInBits(deltaSmall, deltaLarge, fullBits));
 }