Skip to content

Commit a8824db

Browse files
committed
Small naming changes
1 parent e9fd51d commit a8824db

File tree

4 files changed

+58
-67
lines changed

4 files changed

+58
-67
lines changed

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

Lines changed: 44 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ internal struct FlagStates
104104
internal bool ReliableSequenced;
105105
internal bool UseUnreliableDeltas;
106106
internal bool UnreliableFrameSync;
107+
107108
/// <summary>
108109
/// When set, non-authority instances will smoothly transition between
109110
/// world and local space.
@@ -202,7 +203,7 @@ internal bool HasScale(Axis axis)
202203
}
203204

204205
[MethodImpl(MethodImplOptions.AggressiveInlining)]
205-
internal uint GetFlags()
206+
internal uint GetBitsetRepresentation()
206207
{
207208
uint bitset = 0;
208209
if (InLocalSpace) { bitset |= k_InLocalSpaceBit; }
@@ -233,7 +234,7 @@ internal uint GetFlags()
233234
}
234235

235236
[MethodImpl(MethodImplOptions.AggressiveInlining)]
236-
internal void SetFlags(uint bitset)
237+
internal void SetStateFromBitset(uint bitset)
237238
{
238239
InLocalSpace = (bitset & k_InLocalSpaceBit) != 0;
239240
SetHasPosition(Axis.X, (bitset & k_PositionXBit) != 0);
@@ -263,10 +264,10 @@ internal void SetFlags(uint bitset)
263264

264265
/// <summary>
265266
/// Clear everything but flags that should persist between state updates until changed by authority.
266-
/// Persistent (non-cleared) flags are <see cref="InLocalSpace"/>, <see cref="UseInterpolation"/>, <see cref="QuaternionSync"/>, <see cref="QuaternionCompressed"/>,
267+
/// Persistent (non-cleared) flags are <see cref="InLocalSpace"/>, <see cref="UseInterpolation"/>, <see cref="QuaternionSync"/>, <see cref="QuaternionCompression"/>,
267268
/// <see cref="UseHalfFloatPrecision"/> <see cref="UsePositionSlerp"/>, <see cref="UseUnreliableDeltas"/>, <see cref="SwitchTransformSpaceWhenParented"/>
268269
/// </summary>
269-
internal void ClearBitSetForNextTick()
270+
internal void ClearForNextTick()
270271
{
271272
HasPositionX = false;
272273
HasPositionY = false;
@@ -353,7 +354,7 @@ public struct NetworkTransformState : INetworkSerializable
353354
public bool InLocalSpace
354355
{
355356
[MethodImpl(MethodImplOptions.AggressiveInlining)]
356-
get { return FlagStates.InLocalSpace; }
357+
get => FlagStates.InLocalSpace;
357358
}
358359

359360
// Position
@@ -363,7 +364,7 @@ public bool InLocalSpace
363364
public bool HasPositionX
364365
{
365366
[MethodImpl(MethodImplOptions.AggressiveInlining)]
366-
get { return FlagStates.HasPositionX; }
367+
get => FlagStates.HasPositionX;
367368
}
368369

369370
/// <summary>
@@ -372,7 +373,7 @@ public bool HasPositionX
372373
public bool HasPositionY
373374
{
374375
[MethodImpl(MethodImplOptions.AggressiveInlining)]
375-
get { return FlagStates.HasPositionY; }
376+
get => FlagStates.HasPositionY;
376377
}
377378

378379
/// <summary>
@@ -381,7 +382,7 @@ public bool HasPositionY
381382
public bool HasPositionZ
382383
{
383384
[MethodImpl(MethodImplOptions.AggressiveInlining)]
384-
get { return FlagStates.HasPositionZ; }
385+
get => FlagStates.HasPositionZ;
385386
}
386387

387388
/// <summary>
@@ -390,7 +391,7 @@ public bool HasPositionZ
390391
public bool HasPositionChange
391392
{
392393
[MethodImpl(MethodImplOptions.AggressiveInlining)]
393-
get { return FlagStates.HasPositionChange; }
394+
get => FlagStates.HasPositionChange;
394395
}
395396

396397
// RotAngles
@@ -403,7 +404,7 @@ public bool HasPositionChange
403404
public bool HasRotAngleX
404405
{
405406
[MethodImpl(MethodImplOptions.AggressiveInlining)]
406-
get { return FlagStates.HasRotAngleX; }
407+
get => FlagStates.HasRotAngleX;
407408
}
408409

409410
/// <summary>
@@ -415,7 +416,7 @@ public bool HasRotAngleX
415416
public bool HasRotAngleY
416417
{
417418
[MethodImpl(MethodImplOptions.AggressiveInlining)]
418-
get { return FlagStates.HasRotAngleY; }
419+
get => FlagStates.HasRotAngleY;
419420
}
420421

421422
/// <summary>
@@ -427,7 +428,7 @@ public bool HasRotAngleY
427428
public bool HasRotAngleZ
428429
{
429430
[MethodImpl(MethodImplOptions.AggressiveInlining)]
430-
get { return FlagStates.HasRotAngleZ; }
431+
get => FlagStates.HasRotAngleZ;
431432
}
432433

433434
/// <summary>
@@ -439,7 +440,7 @@ public bool HasRotAngleZ
439440
public bool HasRotAngleChange
440441
{
441442
[MethodImpl(MethodImplOptions.AggressiveInlining)]
442-
get { return FlagStates.HasRotAngleChange; }
443+
get => FlagStates.HasRotAngleChange;
443444
}
444445

445446
// Scale
@@ -449,7 +450,7 @@ public bool HasRotAngleChange
449450
public bool HasScaleX
450451
{
451452
[MethodImpl(MethodImplOptions.AggressiveInlining)]
452-
get { return FlagStates.HasScaleX; }
453+
get => FlagStates.HasScaleX;
453454
}
454455

455456
/// <summary>
@@ -458,7 +459,7 @@ public bool HasScaleX
458459
public bool HasScaleY
459460
{
460461
[MethodImpl(MethodImplOptions.AggressiveInlining)]
461-
get { return FlagStates.HasScaleY; }
462+
get => FlagStates.HasScaleY;
462463
}
463464

464465
/// <summary>
@@ -467,7 +468,7 @@ public bool HasScaleY
467468
public bool HasScaleZ
468469
{
469470
[MethodImpl(MethodImplOptions.AggressiveInlining)]
470-
get { return FlagStates.HasScaleZ; }
471+
get => FlagStates.HasScaleZ;
471472
}
472473

473474
/// <summary>
@@ -476,7 +477,7 @@ public bool HasScaleZ
476477
public bool HasScaleChange
477478
{
478479
[MethodImpl(MethodImplOptions.AggressiveInlining)]
479-
get { return FlagStates.HasScaleChange; }
480+
get => FlagStates.HasScaleChange;
480481
}
481482

482483
/// <summary>
@@ -491,7 +492,7 @@ public bool HasScaleChange
491492
public bool IsTeleportingNextFrame
492493
{
493494
[MethodImpl(MethodImplOptions.AggressiveInlining)]
494-
get { return FlagStates.IsTeleportingNextFrame; }
495+
get => FlagStates.IsTeleportingNextFrame;
495496
}
496497

497498
/// <summary>
@@ -503,7 +504,7 @@ public bool IsTeleportingNextFrame
503504
public bool WasTeleported
504505
{
505506
[MethodImpl(MethodImplOptions.AggressiveInlining)]
506-
get { return FlagStates.WasTeleported; }
507+
get => FlagStates.WasTeleported;
507508
}
508509

509510
/// <summary>
@@ -516,7 +517,7 @@ public bool WasTeleported
516517
public bool UseInterpolation
517518
{
518519
[MethodImpl(MethodImplOptions.AggressiveInlining)]
519-
get { return FlagStates.UseInterpolation; }
520+
get => FlagStates.UseInterpolation;
520521
}
521522

522523
/// <summary>
@@ -530,7 +531,7 @@ public bool UseInterpolation
530531
public bool QuaternionSync
531532
{
532533
[MethodImpl(MethodImplOptions.AggressiveInlining)]
533-
get { return FlagStates.QuaternionSync; }
534+
get => FlagStates.QuaternionSync;
534535
}
535536

536537
/// <summary>
@@ -545,7 +546,7 @@ public bool QuaternionSync
545546
public bool QuaternionCompression
546547
{
547548
[MethodImpl(MethodImplOptions.AggressiveInlining)]
548-
get { return FlagStates.QuaternionCompression; }
549+
get => FlagStates.QuaternionCompression;
549550
}
550551

551552
/// <summary>
@@ -558,7 +559,7 @@ public bool QuaternionCompression
558559
public bool UseHalfFloatPrecision
559560
{
560561
[MethodImpl(MethodImplOptions.AggressiveInlining)]
561-
get { return FlagStates.UseHalfFloatPrecision; }
562+
get => FlagStates.UseHalfFloatPrecision;
562563
}
563564

564565
/// <summary>
@@ -568,7 +569,7 @@ public bool UseHalfFloatPrecision
568569
public bool IsSynchronizing
569570
{
570571
[MethodImpl(MethodImplOptions.AggressiveInlining)]
571-
get { return FlagStates.IsSynchronizing; }
572+
get => FlagStates.IsSynchronizing;
572573
}
573574

574575
/// <summary>
@@ -578,7 +579,7 @@ public bool IsSynchronizing
578579
public bool UsePositionSlerp
579580
{
580581
[MethodImpl(MethodImplOptions.AggressiveInlining)]
581-
get { return FlagStates.UsePositionSlerp; }
582+
get => FlagStates.UsePositionSlerp;
582583
}
583584

584585
/// <summary>
@@ -619,10 +620,8 @@ public Quaternion GetRotation()
619620
{
620621
return Rotation;
621622
}
622-
else
623-
{
624-
return Quaternion.Euler(RotAngleX, RotAngleY, RotAngleZ);
625-
}
623+
624+
return Quaternion.Euler(RotAngleX, RotAngleY, RotAngleZ);
626625
}
627626
return Quaternion.identity;
628627
}
@@ -650,15 +649,11 @@ public Vector3 GetPosition()
650649
{
651650
return CurrentPosition;
652651
}
653-
else
654-
{
655-
return NetworkDeltaPosition.GetFullPosition();
656-
}
657-
}
658-
else
659-
{
660-
return new Vector3(PositionX, PositionY, PositionZ);
652+
653+
return NetworkDeltaPosition.GetFullPosition();
661654
}
655+
656+
return new Vector3(PositionX, PositionY, PositionZ);
662657
}
663658
return Vector3.zero;
664659
}
@@ -682,15 +677,11 @@ public Vector3 GetScale()
682677
{
683678
return Scale;
684679
}
685-
else
686-
{
687-
return HalfVectorScale.ToVector3();
688-
}
689-
}
690-
else
691-
{
692-
return new Vector3(ScaleX, ScaleY, ScaleZ);
680+
681+
return HalfVectorScale.ToVector3();
693682
}
683+
684+
return new Vector3(ScaleX, ScaleY, ScaleZ);
694685
}
695686
return Vector3.zero;
696687
}
@@ -754,7 +745,7 @@ public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReade
754745
}
755746

756747
// Serialize the flags as an unsigned int
757-
BytePacker.WriteValueBitPacked(m_Writer, FlagStates.GetFlags());
748+
BytePacker.WriteValueBitPacked(m_Writer, FlagStates.GetBitsetRepresentation());
758749

759750
// We use network ticks as opposed to absolute time as the authoritative
760751
// side updates on every new tick.
@@ -765,7 +756,7 @@ public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReade
765756
// Deserialize the flags
766757
ByteUnpacker.ReadValueBitPacked(m_Reader, out uint bitset);
767758
// Set the flags
768-
FlagStates.SetFlags(bitset);
759+
FlagStates.SetStateFromBitset(bitset);
769760

770761
// We use network ticks as opposed to absolute time as the authoritative
771762
// side updates on every new tick.
@@ -1645,8 +1636,8 @@ internal bool SynchronizeScale
16451636
/// </summary>
16461637
/// <remarks>
16471638
/// <list type="bullet">
1648-
/// <item><description>If InLocalSpace is <see cref="true"/> then it returns the transform.localPosition.</description></item>
1649-
/// <item><description>If InLocalSpace is <see cref="false"/> then it returns the transform.position.</description></item>
1639+
/// <item><description>If InLocalSpace is true then it returns the transform.localPosition.</description></item>
1640+
/// <item><description>If InLocalSpace is false then it returns the transform.position.</description></item>
16501641
/// </list>
16511642
/// <list type="bullet">
16521643
/// <item>
@@ -1695,8 +1686,8 @@ public Vector3 GetSpaceRelativePosition(bool getCurrentState = false)
16951686
/// </summary>
16961687
/// <remarks>
16971688
/// <list type="bullet">
1698-
/// <item><description>If InLocalSpace is <see cref="true"/> then it returns the transform.localRotation.</description></item>
1699-
/// <item><description>If InLocalSpace is <see cref="false"/> then it returns the transform.rotation.</description></item>
1689+
/// <item><description>If InLocalSpace is true then it returns the transform.localRotation.</description></item>
1690+
/// <item><description>If InLocalSpace is false then it returns the transform.rotation.</description></item>
17001691
/// </list>
17011692
/// <list type="bullet">
17021693
/// <item>
@@ -2138,7 +2129,7 @@ internal NetworkTransformState ApplyLocalNetworkState(Transform transform)
21382129
{
21392130
// Since we never commit these changes, we need to simulate that any changes were committed previously and the bitset
21402131
// value would already be reset prior to having the state applied
2141-
m_LocalAuthoritativeNetworkState.FlagStates.ClearBitSetForNextTick();
2132+
m_LocalAuthoritativeNetworkState.FlagStates.ClearForNextTick();
21422133

21432134
// Now check the transform for any threshold value changes
21442135
CheckForStateChange(ref m_LocalAuthoritativeNetworkState);
@@ -3511,7 +3502,7 @@ internal void OnUpdateAuthoritativeState(bool settingState = false)
35113502
if (!m_LocalAuthoritativeNetworkState.ExplicitSet && m_LocalAuthoritativeNetworkState.FlagStates.IsDirty && !m_LocalAuthoritativeNetworkState.IsTeleportingNextFrame)
35123503
{
35133504
// Now clear our bitset and prepare for next network tick state update
3514-
m_LocalAuthoritativeNetworkState.FlagStates.ClearBitSetForNextTick();
3505+
m_LocalAuthoritativeNetworkState.FlagStates.ClearForNextTick();
35153506
if (TrackByStateId)
35163507
{
35173508
m_LocalAuthoritativeNetworkState.FlagStates.TrackByStateId = true;

com.unity.netcode.gameobjects/Tests/Runtime/NetworkTransform/NetworkTransformBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ public enum Axis
114114

115115
protected enum ChildrenTransformCheckType
116116
{
117-
Connected_Clients,
118-
Late_Join_Client
117+
ConnectedClients,
118+
LateJoinClient
119119
}
120120

121121
protected override int NumberOfClients => OnNumberOfClients();

com.unity.netcode.gameobjects/Tests/Runtime/NetworkTransform/NetworkTransformStateTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ private void InlinedBitmathSerialization(ref int numFlags, ref uint[] indexValue
8686
};
8787

8888
writer = new FastBufferWriter(64, Allocator.Temp);
89-
BytePacker.WriteValueBitPacked(writer, transformState.FlagStates.GetFlags());
89+
BytePacker.WriteValueBitPacked(writer, transformState.FlagStates.GetBitsetRepresentation());
9090

9191
// Test the bitset representation of the serialization matches the pre-refactor serialization
9292
reader = new FastBufferReader(writer, Allocator.None);
@@ -101,7 +101,7 @@ private void InlinedBitmathSerialization(ref int numFlags, ref uint[] indexValue
101101
// Test the deserialized values match the original values
102102
var deserialized = new NetworkTransformState();
103103
// Set the flags
104-
deserialized.FlagStates.SetFlags(bitFlags);
104+
deserialized.FlagStates.SetStateFromBitset(bitFlags);
105105

106106
AssertTransformStateEquals(boolSet, deserialized, "Flag serialization");
107107
}
@@ -139,7 +139,7 @@ private void InlinedBitmathSerialization(ref int numFlags, ref uint[] indexValue
139139
};
140140

141141
writer = new FastBufferWriter(64, Allocator.Temp);
142-
BytePacker.WriteValueBitPacked(writer, transformState.FlagStates.GetFlags());
142+
BytePacker.WriteValueBitPacked(writer, transformState.FlagStates.GetBitsetRepresentation());
143143

144144
var serializedBuffer = writer.ToArray();
145145

@@ -161,7 +161,7 @@ private void InlinedBitmathSerialization(ref int numFlags, ref uint[] indexValue
161161
// Test the deserialized values match the original values
162162
var deserializedState = new NetworkTransformState();
163163
// Set the flags
164-
deserializedState.FlagStates.SetFlags(bitFlagsState);
164+
deserializedState.FlagStates.SetStateFromBitset(bitFlagsState);
165165

166166
Array.Fill(boolSet, true);
167167
AssertTransformStateEquals(boolSet, deserializedState, "Read bitset");

0 commit comments

Comments
 (0)