@@ -2171,6 +2171,8 @@ internal bool ApplyTransformToNetworkState(ref NetworkTransformState networkStat
21712171 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
21722172 private bool CheckForStateChange ( ref NetworkTransformState networkState , bool isSynchronization = false , ulong targetClientId = 0 , bool forceState = false )
21732173 {
2174+ var flagStates = networkState . FlagStates ;
2175+
21742176 // As long as we are not doing our first synchronization and we are sending unreliable deltas, each
21752177 // NetworkTransform will stagger its full transfom synchronization over a 1 second period based on the
21762178 // assigned tick slot (m_TickSync).
@@ -2183,18 +2185,17 @@ private bool CheckForStateChange(ref NetworkTransformState networkState, bool is
21832185 // We compare against the NetworkTickSystem version since ServerTime is set when updating ticks
21842186 if ( UseUnreliableDeltas && ! isSynchronization && m_DeltaSynch && m_NextTickSync <= CurrentTick )
21852187 {
2188+ // TODO-CACHE: m_CachedNetworkManager.NetworkConfig.TickRate value
21862189 // Increment to the next frame synch tick position for this instance
21872190 m_NextTickSync += ( int ) m_CachedNetworkManager . NetworkConfig . TickRate ;
21882191 // If we are teleporting, we do not need to send a frame synch for this tick slot
21892192 // as a "frame synch" really is effectively just a teleport.
2190- isAxisSync = ! networkState . IsTeleportingNextFrame ;
2193+ isAxisSync = ! flagStates . IsTeleportingNextFrame ;
21912194 // Reset our delta synch trigger so we don't send another frame synch until we
21922195 // send at least 1 unreliable state update after this fame synch or teleport
21932196 m_DeltaSynch = false ;
21942197 }
21952198
2196- var flagStates = networkState . FlagStates ;
2197-
21982199 // This is used to determine if we need to send the state update reliably (if we are doing an axial sync)
21992200 flagStates . UnreliableFrameSync = isAxisSync ;
22002201
@@ -2213,15 +2214,15 @@ private bool CheckForStateChange(ref NetworkTransformState networkState, bool is
22132214#if COM_UNITY_MODULES_PHYSICS || COM_UNITY_MODULES_PHYSICS2D
22142215 if ( ( InLocalSpace != flagStates . InLocalSpace || isSynchronization ) && ! m_UseRigidbodyForMotion )
22152216#else
2216- if ( InLocalSpace != networkState . InLocalSpace )
2217+ if ( InLocalSpace != flagStates . InLocalSpace )
22172218#endif
22182219 {
22192220 // When SwitchTransformSpaceWhenParented is set we automatically set our local space based on whether
22202221 // we are parented or not.
22212222 flagStates . InLocalSpace = SwitchTransformSpaceWhenParented ? transform . parent != null : InLocalSpace ;
22222223 if ( SwitchTransformSpaceWhenParented )
22232224 {
2224- InLocalSpace = networkState . InLocalSpace ;
2225+ InLocalSpace = flagStates . InLocalSpace ;
22252226 }
22262227 isDirty = true ;
22272228
@@ -2252,8 +2253,8 @@ private bool CheckForStateChange(ref NetworkTransformState networkState, bool is
22522253 // rotationThreshold = m_NetworkRigidbodyInternal.GetAdjustedRotationThreshold();
22532254 //}
22542255#else
2255- var position = InLocalSpace ? transformToUse . localPosition : transformToUse . position ;
2256- var rotation = InLocalSpace ? transformToUse . localRotation : transformToUse . rotation ;
2256+ var position = InLocalSpace ? CachedTransform . localPosition : CachedTransform . position ;
2257+ var rotation = InLocalSpace ? CachedTransform . localRotation : CachedTransform . rotation ;
22572258 var positionThreshold = Vector3 . one * PositionThreshold ;
22582259 var rotationThreshold = Vector3 . one * RotAngleThreshold ;
22592260#endif
@@ -2521,9 +2522,9 @@ private bool CheckForStateChange(ref NetworkTransformState networkState, bool is
25212522 {
25222523 // If we are synchronizing and the associated NetworkObject has a parent then we want to send the
25232524 // LossyScale if the NetworkObject has a parent since NetworkObject spawn order is not guaranteed
2524- if ( networkState . FlagStates . IsParented )
2525+ if ( flagStates . IsParented )
25252526 {
2526- networkState . LossyScale = transform . lossyScale ;
2527+ networkState . LossyScale = CachedTransform . lossyScale ;
25272528 }
25282529 }
25292530
@@ -2570,15 +2571,17 @@ private bool CheckForStateChange(ref NetworkTransformState networkState, bool is
25702571 else // Just apply the full local scale when synchronizing
25712572 if ( SynchronizeScale )
25722573 {
2574+ var localScale = CachedTransform . localScale ;
25732575 if ( ! UseHalfFloatPrecision )
25742576 {
2575- networkState . ScaleX = transform . localScale . x ;
2576- networkState . ScaleY = transform . localScale . y ;
2577- networkState . ScaleZ = transform . localScale . z ;
2577+
2578+ networkState . ScaleX = localScale . x ;
2579+ networkState . ScaleY = localScale . y ;
2580+ networkState . ScaleZ = localScale . z ;
25782581 }
25792582 else
25802583 {
2581- networkState . Scale = transform . localScale ;
2584+ networkState . Scale = localScale ;
25822585 }
25832586 flagStates . MarkChanged ( AxialType . Scale , true ) ;
25842587 isScaleDirty = true ;
@@ -2599,7 +2602,7 @@ private bool CheckForStateChange(ref NetworkTransformState networkState, bool is
25992602 // Mark the state dirty for the next network tick update to clear out the bitset values
26002603 flagStates . IsDirty |= isDirty ;
26012604
2602- // Apply any changes to the flag states once
2605+ // Apply any flag state changes
26032606 networkState . FlagStates = flagStates ;
26042607 return isDirty ;
26052608 }
0 commit comments