public static NetVector3 AddDelta(NetVector3 from, NetVector3Delta delta) { if (delta.isRelative) { return(new NetVector3(from.x + delta.x, from.y + delta.y, from.z + delta.z, from.bits)); } return(new NetVector3(delta.x, delta.y, delta.z, from.bits)); }
public static NetVector3Delta WorstCaseDelta(NetVector3 from, NetVector3 to) { NetVector3Delta result = default(NetVector3Delta); result.isRelative = false; 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) { NetVector3 from = (state0 != null) ? NetVector3.Read(state0, fullBits) : NetVector3.Quantize(startPos, range, fullBits); if (delta == null || (readChanged && !delta.ReadBool())) { from.Write(result); return; } NetVector3Delta delta2 = NetVector3Delta.Read(delta, deltaSmall, deltaLarge, fullBits); NetVector3.AddDelta(from, delta2).Write(result); }
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); } } }
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); }
public static NetVector3Delta Read(NetStream stream, ushort bitsmall, ushort bitlarge, ushort bitfull) { NetVector3Delta netVector3Delta = default(NetVector3Delta); netVector3Delta.isRelative = stream.ReadBool(); NetVector3Delta result = netVector3Delta; 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); }
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 static NetVector3Delta Delta(NetVector3 from, NetVector3 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) { NetVector3Delta result = default(NetVector3Delta); result.isRelative = false; result.x = to.x; result.y = to.y; result.z = to.z; return(result); } NetVector3Delta result2 = default(NetVector3Delta); result2.isRelative = true; result2.x = num; result2.y = num2; result2.z = num3; return(result2); }
public int CalculateMaxDeltaSizeInBits() { return(NetVector3Delta.CalculateMaxDeltaSizeInBits(deltaSmall, deltaLarge, fullBits)); }