Skip to content

Commit 25ca971

Browse files
committed
Fix whitespace issue
1 parent 077a6ba commit 25ca971

File tree

1 file changed

+18
-77
lines changed

1 file changed

+18
-77
lines changed

com.unity.netcode.gameobjects/Runtime/Components/NetworkTransform.cs

Lines changed: 18 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public struct NetworkTransformState : INetworkSerializable
190190
/// <remarks>
191191
/// When quaternion synchronization is enabled all axis are always updated.
192192
/// </remarks>
193-
public bool HasRotAngleChange { get; internal set; }
193+
public bool HasRotAngleChange { get; internal set; }
194194

195195
// Scale
196196
/// <summary>
@@ -221,16 +221,19 @@ internal void MarkChanged(AxialType axialType, bool changed)
221221
HasPositionX = changed;
222222
HasPositionY = changed;
223223
HasPositionZ = changed;
224+
HasPositionChange = changed;
224225
break;
225226
case AxialType.Rotation:
226227
HasRotAngleX = changed;
227228
HasRotAngleY = changed;
228229
HasRotAngleZ = changed;
230+
HasRotAngleChange = changed;
229231
break;
230232
case AxialType.Scale:
231233
HasScaleX = changed;
232234
HasScaleY = changed;
233235
HasScaleZ = changed;
236+
HasScaleChange = changed;
234237
break;
235238
}
236239
}
@@ -587,11 +590,6 @@ public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReade
587590
bitSetAndTickSize = m_Writer.Position - positionStart;
588591
lastPosition = m_Writer.Position;
589592
}
590-
else
591-
{
592-
bitSetAndTickSize = m_Reader.Position - positionStart;
593-
lastPosition = m_Reader.Position;
594-
}
595593
#endif
596594

597595
// If debugging states and track by state identifier is enabled, serialize the current state identifier
@@ -668,13 +666,6 @@ public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReade
668666
{
669667
positionSize = m_Writer.Position - lastPosition;
670668
lastPosition = m_Writer.Position;
671-
Debug.Log($"[Write][bitsAndTick={bitSetAndTickSize}][position={positionSize}]");
672-
}
673-
else
674-
{
675-
positionSize = m_Reader.Position - lastPosition;
676-
lastPosition = m_Reader.Position;
677-
Debug.Log($"[Read][bitsAndTick={bitSetAndTickSize}][position={positionSize}]");
678669
}
679670
#endif
680671

@@ -794,11 +785,6 @@ public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReade
794785
rotationSize = m_Writer.Position - lastPosition;
795786
lastPosition = m_Writer.Position;
796787
}
797-
else
798-
{
799-
rotationSize = m_Reader.Position - lastPosition;
800-
lastPosition = m_Reader.Position;
801-
}
802788
#endif
803789

804790
// Synchronize Scale
@@ -877,11 +863,6 @@ public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReade
877863
scaleSize = m_Writer.Position - lastPosition;
878864
lastPosition = m_Writer.Position;
879865
}
880-
else
881-
{
882-
scaleSize = m_Reader.Position - lastPosition;
883-
lastPosition = m_Reader.Position;
884-
}
885866
#endif
886867

887868
// Only if we are receiving state
@@ -894,46 +875,27 @@ public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReade
894875
else
895876
{
896877
LastSerializedSize = m_Writer.Position - positionStart;
897-
}
898-
899878
#if NGO_NETWORKTRANSFORMSTATE_LOGWRITESIZE
900-
var type = isWriting ? "Write" : "Read";
901-
Debug.Log($"[NT-{type}][BitsAndTick: {bitSetAndTickSize}][position: {positionSize}][rotation: {rotationSize}][scale: {scaleSize}]");
879+
Debug.Log($"[NT-WriteSize][BitsAndTick: {bitSetAndTickSize}][position: {positionSize}][rotation: {rotationSize}][scale: {scaleSize}]");
902880
#endif
881+
}
903882
}
904883

905884
[MethodImpl(MethodImplOptions.AggressiveInlining)]
906885
internal void SerializeBitset(ref FastBufferWriter writer)
907886
{
908887
uint bitset = 0;
909888

910-
Debug.Log($"[NT] Serializing has changes: HasPositionChange: {HasPositionChange}, HasRotAngleChange: {HasRotAngleChange}, HasScaleChange: {HasScaleChange}");
911-
Debug.Log($"[NT] Serializing: HasRotAngleX: {HasRotAngleX}, HasRotAngleY: {HasRotAngleY}, HasRotAngleZ: {HasRotAngleZ}");
912-
913889
if (InLocalSpace) { bitset |= k_InLocalSpaceBit; }
914-
915-
// if (HasPositionChange)
916-
// {
917-
if (HasPositionX) { bitset |= k_PositionXBit; }
918-
if (HasPositionY) { bitset |= k_PositionYBit; }
919-
if (HasPositionZ) { bitset |= k_PositionZBit; }
920-
// }
921-
//
922-
// if (HasRotAngleChange)
923-
// {
924-
if (HasRotAngleX) { bitset |= k_RotAngleXBit; }
925-
if (HasRotAngleY) { bitset |= k_RotAngleYBit; }
926-
if (HasRotAngleZ) { bitset |= k_RotAngleZBit; }
927-
// }
928-
//
929-
// if (HasScaleChange)
930-
// {
931-
if (HasScaleX) { bitset |= k_ScaleXBit; }
932-
if (HasScaleY) { bitset |= k_ScaleYBit; }
933-
if (HasScaleZ) { bitset |= k_ScaleZBit; }
934-
935-
// }
936-
890+
if (HasPositionX) { bitset |= k_PositionXBit; }
891+
if (HasPositionY) { bitset |= k_PositionYBit; }
892+
if (HasPositionZ) { bitset |= k_PositionZBit; }
893+
if (HasRotAngleX) { bitset |= k_RotAngleXBit; }
894+
if (HasRotAngleY) { bitset |= k_RotAngleYBit; }
895+
if (HasRotAngleZ) { bitset |= k_RotAngleZBit; }
896+
if (HasScaleX) { bitset |= k_ScaleXBit; }
897+
if (HasScaleY) { bitset |= k_ScaleYBit; }
898+
if (HasScaleZ) { bitset |= k_ScaleZBit; }
937899
if (IsTeleportingNextFrame) { bitset |= k_TeleportingBit; }
938900
if (UseInterpolation) { bitset |= k_Interpolate; }
939901
if (QuaternionSync) { bitset |= k_QuaternionSync; }
@@ -981,9 +943,6 @@ internal void DeserializeBitset(ref FastBufferReader reader)
981943
UnreliableFrameSync = (bitset & k_UnreliableFrameSync) != 0;
982944
SwitchTransformSpaceWhenParented = (bitset & k_SwitchTransformSpaceWhenParented) != 0;
983945
TrackByStateId = (bitset & k_TrackStateId) != 0;
984-
985-
Debug.Log($"Deserialized has changes: HasPositionChange: {HasPositionChange}, HasRotAngleChange: {HasRotAngleChange}, HasScaleChange: {HasScaleChange}");
986-
987946
}
988947
}
989948
#endregion
@@ -1825,7 +1784,6 @@ protected override void OnSynchronize<T>(ref BufferSerializer<T> serializer)
18251784
var transformToCommit = transform;
18261785
// If we are using Half Float Precision, then we want to only synchronize the authority's m_HalfPositionState.FullPosition in order for
18271786
// for the non-authority side to be able to properly synchronize delta position updates.
1828-
Debug.Log($"[Object-{NetworkObjectId}][CheckForStateChange][OnSynchronize] HasRotAngleX: {SynchronizeState.HasRotAngleX}, HasRotAngleChange: {SynchronizeState.HasRotAngleChange}");
18291787
CheckForStateChange(ref SynchronizeState, ref transformToCommit, true, targetClientId);
18301788
SynchronizeState.NetworkSerialize(serializer);
18311789
LastTickSync = SynchronizeState.GetNetworkTick();
@@ -1948,7 +1906,6 @@ private void TryCommitTransform(ref Transform transformToCommit, bool synchroniz
19481906
}
19491907
#endif
19501908
// If the transform has deltas (returns dirty) or if an explicitly set state is pending
1951-
Debug.Log($"[Object-{NetworkObjectId}][CheckForStateChange][TryCommitTransform][#1] HasRotAngleX: {m_LocalAuthoritativeNetworkState.HasRotAngleX}, HasRotAngleChange: {m_LocalAuthoritativeNetworkState.HasRotAngleChange}");
19521909
if (m_LocalAuthoritativeNetworkState.ExplicitSet || CheckForStateChange(ref m_LocalAuthoritativeNetworkState, ref transformToCommit, synchronize, forceState: settingState))
19531910
{
19541911
// If the state was explicitly set, then update the network tick to match the locally calculate tick
@@ -1961,7 +1918,6 @@ private void TryCommitTransform(ref Transform transformToCommit, bool synchroniz
19611918
if (SwitchTransformSpaceWhenParented && m_LocalAuthoritativeNetworkState.ExplicitSet && m_LocalAuthoritativeNetworkState.IsDirty && transform.parent != null && !m_LocalAuthoritativeNetworkState.InLocalSpace)
19621919
{
19631920
InLocalSpace = true;
1964-
Debug.Log($"[Object-{NetworkObjectId}][CheckForStateChange][TryCommitTransform][#2] HasRotAngleX: {m_LocalAuthoritativeNetworkState.HasRotAngleX}, HasRotAngleChange: {m_LocalAuthoritativeNetworkState.HasRotAngleChange}");
19651921
CheckForStateChange(ref m_LocalAuthoritativeNetworkState, ref transformToCommit, synchronize, forceState: true);
19661922
}
19671923
}
@@ -2060,7 +2016,6 @@ internal NetworkTransformState ApplyLocalNetworkState(Transform transform)
20602016
m_LocalAuthoritativeNetworkState.ClearBitSetForNextTick();
20612017

20622018
// Now check the transform for any threshold value changes
2063-
Debug.Log($"[Object-{NetworkObjectId}][CheckForStateChange][ApplyLocalNetworkState] HasRotAngleX: {m_LocalAuthoritativeNetworkState.HasRotAngleX}, HasRotAngleChange: {m_LocalAuthoritativeNetworkState.HasRotAngleChange}");
20642019
CheckForStateChange(ref m_LocalAuthoritativeNetworkState, ref transform);
20652020

20662021
// Return the entire state to be used by the integration test
@@ -2081,7 +2036,6 @@ internal bool ApplyTransformToNetworkState(ref NetworkTransformState networkStat
20812036
networkState.UseUnreliableDeltas = UseUnreliableDeltas;
20822037
m_HalfPositionState = new NetworkDeltaPosition(Vector3.zero, 0, math.bool3(SyncPositionX, SyncPositionY, SyncPositionZ));
20832038

2084-
Debug.Log($"[Object-{NetworkObjectId}][CheckForStateChange][ApplyTransformToNetworkState] HasRotAngleX: {networkState.HasRotAngleX}, HasRotAngleChange: {networkState.HasRotAngleChange}");
20852039
return CheckForStateChange(ref networkState, ref transformToUse);
20862040
}
20872041

@@ -2117,19 +2071,9 @@ private bool CheckForStateChange(ref NetworkTransformState networkState, ref Tra
21172071

21182072
var isTeleportingAndNotSynchronizing = networkState.IsTeleportingNextFrame && !isSynchronization;
21192073
var isDirty = false;
2120-
2121-
var isPositionDirty = networkState.HasPositionChange;
2122-
var isRotationDirty = networkState.HasRotAngleChange;
2123-
var isScaleDirty = networkState.HasScaleChange;
2124-
if (!isTeleportingAndNotSynchronizing)
2125-
{
2126-
isPositionDirty = false;
2127-
isRotationDirty = false;
2128-
isScaleDirty = false;
2129-
networkState.MarkChanged(AxialType.Position,false);
2130-
networkState.MarkChanged(AxialType.Rotation,false);
2131-
networkState.MarkChanged(AxialType.Scale,false);
2132-
}
2074+
var isPositionDirty = isTeleportingAndNotSynchronizing ? networkState.HasPositionChange : false;
2075+
var isRotationDirty = isTeleportingAndNotSynchronizing ? networkState.HasRotAngleChange : false;
2076+
var isScaleDirty = isTeleportingAndNotSynchronizing ? networkState.HasScaleChange : false;
21332077
networkState.SwitchTransformSpaceWhenParented = SwitchTransformSpaceWhenParented;
21342078

21352079
// All of the checks below, up to the delta position checking portion, are to determine if the
@@ -4075,10 +4019,7 @@ private void SetStateInternal(Vector3 pos, Quaternion rot, Vector3 scale, bool s
40754019
var explicitState = m_LocalAuthoritativeNetworkState.ExplicitSet;
40764020

40774021
// Apply any delta states to the m_LocalAuthoritativeNetworkState
4078-
Debug.Log($"[Object-{NetworkObjectId}][CheckForStateChange][SetStateInternal] HasRotAngleX: {m_LocalAuthoritativeNetworkState.HasRotAngleX}, HasRotAngleChange: {m_LocalAuthoritativeNetworkState.HasRotAngleChange}");
40794022
var isDirty = CheckForStateChange(ref m_LocalAuthoritativeNetworkState, ref transformToCommit);
4080-
Debug.Log($"[After][Object-{NetworkObjectId}][CheckForStateChange][SetStateInternal] HasRotAngleX: {m_LocalAuthoritativeNetworkState.HasRotAngleX}, HasRotAngleChange: {m_LocalAuthoritativeNetworkState.HasRotAngleChange}");
4081-
40824023

40834024
// If we were dirty and the explicit state was set (prior to checking for deltas) or the current explicit state is dirty,
40844025
// then we set the explicit state flag.

0 commit comments

Comments
 (0)