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);
        }
예제 #2
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);
         }
     }
 }
예제 #3
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);
        }