Skip to content

Commit 403389c

Browse files
author
Unity Technologies
committed
com.unity.netcode@1.1.0-pre.3
## [1.1.0-pre.3] - 2023-10-17 ### Changed * the DefaultTranslationSmoothingAction.DefaultStaticUserParams is now public and can be used by user code (to either change the defaults or use them in their own custom smoothing methods). ### Fixed * issue when using prediction error smoothing, causing wrong component data retrieved from the backup buffer and consequently not making the smoothing function work as expected. * an issue in the reported elapsed time when executing the PredictedFixedStepSystemGroup in presence of partial ticks and PredictedFixedStepSimulationTickRatio grater than 1, causing problem with physics and character controller interpolation. * An issue with the change mask not read correctly when serializing/deserializing components with more than 32 fields. * `InvalidOperationException: Comparison function is incorrect` inside `GhostComponentSerializerCollectionSystemGroup` due to `ComponentTypeSerializationStrategy.DefaultType` being a `byte` flag enum (so it erroneously matched `128 - 0` the same as `0 - 128` due to wrapping).
1 parent a2764a0 commit 403389c

16 files changed

+420
-51
lines changed

.buginfo

Lines changed: 0 additions & 4 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
1+
---
2+
uid: changelog
3+
---
4+
15
# Changelog
26

7+
## [1.1.0-pre.3] - 2023-10-17
8+
9+
### Changed
10+
11+
* the DefaultTranslationSmoothingAction.DefaultStaticUserParams is now public and can be used by user code (to either change the defaults or use them in their own custom smoothing methods).
12+
13+
### Fixed
14+
15+
* issue when using prediction error smoothing, causing wrong component data retrieved from the backup buffer and consequently not making the smoothing function work as expected.
16+
* an issue in the reported elapsed time when executing the PredictedFixedStepSystemGroup in presence of partial ticks and PredictedFixedStepSimulationTickRatio grater than 1, causing problem with physics and character controller interpolation.
17+
* An issue with the change mask not read correctly when serializing/deserializing components with more than 32 fields.
18+
* `InvalidOperationException: Comparison function is incorrect` inside `GhostComponentSerializerCollectionSystemGroup` due to `ComponentTypeSerializationStrategy.DefaultType` being a `byte` flag enum (so it erroneously matched `128 - 0` the same as `0 - 128` due to wrapping).
19+
20+
321
## [1.1.0-exp.1] - 2023-09-18
422

523
### Added

Editor/Templates/GhostComponentSerializer.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -548,11 +548,10 @@ private static void CalculateChangeMask(ref Snapshot snapshot, in Snapshot basel
548548
#region __GHOST_CALCULATE_CHANGE_MASK__
549549
#endregion
550550
#region __GHOST_FLUSH_COMPONENT_CHANGE_MASK__
551-
GhostComponentSerializer.CopyToChangeMask(bits, changeMask, startOffset, 32);
552-
startOffset += 32;
551+
GhostComponentSerializer.CopyToChangeMask(bits, changeMask, startOffset + __GHOST_CURRENT_MASK_BITS__, 32);
553552
#endregion
554553
#region __GHOST_FLUSH_FINAL_COMPONENT_CHANGE_MASK__
555-
GhostComponentSerializer.CopyToChangeMask(bits, changeMask, startOffset, __GHOST_CHANGE_MASK_BITS__);
554+
GhostComponentSerializer.CopyToChangeMask(bits, changeMask, startOffset + __GHOST_CHANGE_MASK_BITS__, __GHOST_CURRENT_MASK_BITS__);
556555
#endregion
557556
#endif
558557
}

Runtime/Command/IInputComponentData.cs

Lines changed: 116 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System;
2+
using Unity.Burst;
23
using Unity.Collections;
34
using Unity.Entities;
5+
using Unity.NetCode.LowLevel.Unsafe;
46

57
namespace Unity.NetCode
68
{
@@ -50,12 +52,124 @@ public void Set()
5052
/// Interface used to handle automatic input command data setup with the IInputComponentData
5153
/// style inputs. This is used internally by code generation, don't use this directly.
5254
/// </summary>
53-
[Obsolete("The IInputBufferData interface has been deprecated. It was meant for internal use and any reference to it is considered an error. Please always use ICommandData instead", true)]
55+
[Obsolete("The IInputBufferData interface has been deprecated. It was meant for internal use and any reference to it is considered an error. " +
56+
"Please always use ICommandData instead.", false)]
5457
public interface IInputBufferData : ICommandData
5558
{
59+
/// <summary>
60+
/// Take the stored input data we have and copy to the given input data pointed to. Decrement
61+
/// any event counters by the counter value in the previous command buffer data element.
62+
/// </summary>
63+
/// <param name="prevInputBufferDataPtr">Command data from the previous tick</param>
64+
/// <param name="inputPtr">Our stored input data will be copied over to this location</param>
65+
public void DecrementEventsAndAssignToInput(IntPtr prevInputBufferDataPtr, IntPtr inputPtr);
66+
/// <summary>
67+
/// Save the input data with any event counters incremented by the counter from the last stored
68+
/// input in the command buffer for the current tick. See <see cref="InputEvent"/>.
69+
/// </summary>
70+
/// <param name="lastInputBufferDataPtr">Pointer to the last command data in the buffer</param>
71+
/// <param name="inputPtr">Pointer to input data to be saved in this command data</param>
72+
public void IncrementEventsAndSetCurrentInputData(IntPtr lastInputBufferDataPtr, IntPtr inputPtr);
5673
}
5774

58-
/// <summary>
75+
/// <summary>
76+
/// For internal use only, helper struct that should be used to implement systems that copy the content of an
77+
/// <see cref="IInputComponentData"/> into the code-generated <see cref="ICommandData"/> buffer.
78+
/// </summary>
79+
/// <typeparam name="TInputBufferData"></typeparam>
80+
/// <typeparam name="TInputComponentData"></typeparam>
81+
[Obsolete("CopyInputToCommandBuffer has been deprecated. There is no replacement, being the method meant to be used only by code-generated systems.", false)]
82+
public partial struct CopyInputToCommandBuffer<TInputBufferData, TInputComponentData>
83+
where TInputBufferData : unmanaged, IInputBufferData
84+
where TInputComponentData : unmanaged, IInputComponentData
85+
{
86+
/// <summary>
87+
/// For internal use only, simplify the creation of system jobs that copies <see cref="IInputComponentData"/> data to the underlying <see cref="ICommandData"/> buffer.
88+
/// </summary>
89+
[Obsolete("CopyInputToBufferJob has been deprecated.", false)]
90+
public struct CopyInputToBufferJob
91+
{
92+
/// <summary>
93+
/// Implements the component copy and input event management.
94+
/// Should be called your job <see cref="Unity.Jobs.IJob.Execute"/> method.
95+
/// </summary>
96+
/// <param name="chunk"></param>
97+
/// <param name="orderIndex"></param>
98+
public void Execute(ArchetypeChunk chunk, int orderIndex)
99+
{
100+
}
101+
}
102+
103+
/// <summary>
104+
/// Initialize the CopyInputToCommandBuffer by updating all the component type handles and create a
105+
/// a new <see cref="CopyInputToBufferJob"/> instance.
106+
/// </summary>
107+
/// <param name="state"></param>
108+
/// <returns>a new <see cref="CopyInputToBufferJob"/> instance.</returns>
109+
public CopyInputToBufferJob InitJobData(ref SystemState state)
110+
{
111+
return default;
112+
}
113+
114+
/// <summary>
115+
/// Creates the internal component type handles, register to system state the component queries.
116+
/// Very important, add an implicity constraint for running the parent system only when the client
117+
/// is connected to the server, by requiring at least one connection with a <see cref="NetworkId"/> components.
118+
/// <remarks>
119+
/// Should be called inside your the system OnCreate method.
120+
/// </remarks>
121+
/// </summary>
122+
/// <param name="state"></param>
123+
/// <returns></returns>
124+
public EntityQuery Create(ref SystemState state)
125+
{
126+
return default;
127+
}
128+
}
129+
130+
/// <summary>
131+
/// For internal use only, helper struct that should be used to implements systems that copies
132+
/// commands from the <see cref="ICommandData"/> buffer to the <see cref="IInputComponentData"/> component
133+
/// present on the entity.
134+
/// </summary>
135+
/// <typeparam name="TInputBufferData"></typeparam>
136+
/// <typeparam name="TInputComponentData"></typeparam>
137+
[Obsolete("ApplyCurrentInputBufferElementToInputData has been deprecated. There is no replacement, being the method meant to be used only by code-generated systems.", false)]
138+
public partial struct ApplyCurrentInputBufferElementToInputData<TInputBufferData, TInputComponentData>
139+
where TInputBufferData : unmanaged, IInputBufferData
140+
where TInputComponentData : unmanaged, IInputComponentData
141+
{
142+
/// <summary>
143+
/// Helper struct that should be used to implement jobs that copies commands from an <see cref="ICommandData"/> buffer
144+
/// to the respective <see cref="IInputComponentData"/>.
145+
/// </summary>
146+
[Obsolete("ApplyInputDataFromBufferJob has been deprecated.", false)]
147+
public struct ApplyInputDataFromBufferJob
148+
{
149+
/// <summary>
150+
/// Copy the command for current server tick to the input component.
151+
/// Should be called your job <see cref="Unity.Jobs.IJob.Execute"/> method.
152+
/// </summary>
153+
/// <param name="chunk"></param>
154+
/// <param name="orderIndex"></param>
155+
public void Execute(ArchetypeChunk chunk, int orderIndex)
156+
{
157+
}
158+
}
159+
160+
/// <summary>
161+
/// Update the component type handles and create a new <see cref="ApplyInputDataFromBufferJob"/>
162+
/// that can be passed to your job.
163+
/// </summary>
164+
/// <param name="state"></param>
165+
/// <returns>a new <see cref="ApplyInputDataFromBufferJob"/> instance.</returns>
166+
public ApplyInputDataFromBufferJob InitJobData(ref SystemState state)
167+
{
168+
return default;
169+
}
170+
}
171+
172+
/// <summary>
59173
/// The underlying <see cref="ICommandData"/> buffer used to store the <see cref="IInputComponentData"/>.
60174
/// </summary>
61175
/// <remarks>

Runtime/Debug/DebugGhostDrawer.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System;
33
using System.Collections.Generic;
44
using JetBrains.Annotations;
5+
using Unity.Entities;
56

67
namespace Unity.NetCode
78
{
@@ -15,6 +16,12 @@ public class DebugGhostDrawer
1516
static DebugGhostDrawer s_Instance;
1617

1718
public static List<CustomDrawer> CustomDrawers = new List<CustomDrawer>(2);
19+
20+
[Obsolete("Use ClientServerBootstrap.ServerWorld instead. RemoveAfter Entities 1.x")]
21+
public static World FirstServerWorld => ClientServerBootstrap.ServerWorld;
22+
23+
[Obsolete("Use ClientServerBootstrap.ClientWorld instead. RemoveAfter Entities 1.x")]
24+
public static World FirstClientWorld => ClientServerBootstrap.ClientWorld;
1825

1926
static ulong s_LastNextSequenceNumber;
2027

@@ -29,6 +36,9 @@ public static void RegisterDrawAction(CustomDrawer newDrawAction)
2936
CustomDrawers.Add(newDrawAction);
3037
CustomDrawers.Sort();
3138
}
39+
40+
[Obsolete("This functionality is obsolete, worlds are no longer cached here. RemoveAfter Entities 1.x")]
41+
public static void RefreshWorldCaches() {}
3242

3343
public static bool HasRequiredWorlds => ClientServerBootstrap.ServerWorld != default && ClientServerBootstrap.ClientWorld != default;
3444

Runtime/Simulator/MultiplayerPlayModePreferences.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,10 @@ public static void ApplySimulatorPresetToPrefs(SimulatorPreset preset)
273273
/// <summary>For the PlayMode Tools Window.</summary>
274274
public enum SimulatorView
275275
{
276-
[Obsolete("RemovedAfter Entities 1.0")]
277-
Disabled = -1,
278-
PingView = 0,
279-
PerPacketView = 1,
276+
[Obsolete("Disabled is no longer supported. Use MultiplayerPlayModePreferences.SimulatorEnabled instead. RemovedAfter Entities 1.x")]
277+
Disabled = 0,
278+
PingView = 1,
279+
PerPacketView = 2,
280280
}
281281
}
282282
#endif

Runtime/Snapshot/DefaultTranslationSmoothingAction.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,16 @@ public unsafe struct DefaultTranslationSmoothingAction
5050
/// </summary>
5151
public sealed class DefaultStaticUserParams
5252
{
53-
internal static readonly SharedStatic<float> maxDist = SharedStatic<float>.GetOrCreate<DefaultStaticUserParams, MaxDistKey>();
54-
internal static readonly SharedStatic<float> delta = SharedStatic<float>.GetOrCreate<DefaultStaticUserParams, DeltaKey>();
53+
/// <summary>
54+
/// If the prediction error is larger than this value, the entity position is snapped to the new value.
55+
/// The default threshold is 10 units.
56+
/// </summary>
57+
public static readonly SharedStatic<float> maxDist = SharedStatic<float>.GetOrCreate<DefaultStaticUserParams, MaxDistKey>();
58+
/// <summary>
59+
/// If the prediction error is smaller than this value, the entity position is snapped to the new value.
60+
/// The default threshold is 1 units.
61+
/// </summary>
62+
public static readonly SharedStatic<float> delta = SharedStatic<float>.GetOrCreate<DefaultStaticUserParams, DeltaKey>();
5563

5664
static DefaultStaticUserParams()
5765
{
@@ -66,9 +74,7 @@ class DeltaKey {}
6674
/// Return a the burst compatible function pointer that can be used to register the smoothing action to the
6775
/// <see cref="GhostPredictionSmoothing"/> singleton.
6876
/// </summary>
69-
public static readonly PortableFunctionPointer<GhostPredictionSmoothing.SmoothingActionDelegate>
70-
Action =
71-
new PortableFunctionPointer<GhostPredictionSmoothing.SmoothingActionDelegate>(SmoothingAction);
77+
public static readonly PortableFunctionPointer<GhostPredictionSmoothing.SmoothingActionDelegate> Action = new PortableFunctionPointer<GhostPredictionSmoothing.SmoothingActionDelegate>(SmoothingAction);
7278

7379
[BurstCompile(DisableDirectCall = true)]
7480
[AOT.MonoPInvokeCallback(typeof(GhostPredictionSmoothing.SmoothingActionDelegate))]

Runtime/Snapshot/GhostComponentSerializerCollectionSystemGroup.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public int CompareTo(ComponentTypeSerializationStrategy other)
113113
if (IsSerialized != other.IsSerialized)
114114
return IsSerialized - other.IsSerialized;
115115
if (DefaultRule != other.DefaultRule)
116-
return DefaultRule - other.DefaultRule;
116+
return (int)DefaultRule - (int)other.DefaultRule;
117117
if (Hash != other.Hash)
118118
return Hash < other.Hash ? -1 : 1;
119119
return 0;
@@ -356,6 +356,20 @@ public void ThrowIfCollectionNotFinalized(in FixedString512Bytes context)
356356
#endif
357357
}
358358

359+
/// <summary>
360+
/// Lookup a component type to use as a buffer for a given IInputComponentData.
361+
/// </summary>
362+
/// <param name="inputType"></param>
363+
/// <param name="bufferType"></param>
364+
/// <returns>True if the component has an assosiated buffer to use, false if it does not.</returns>
365+
[Obsolete("TryGetBufferForInputComponent has been deprecated. In order to find the buffer associated with an IInputComponentData please just use" +
366+
"IInputBuffer<T> where T is the IInputComponentData type you are looking for.", false)]
367+
public bool TryGetBufferForInputComponent(ComponentType inputType, out ComponentType bufferType)
368+
{
369+
bufferType = default;
370+
return false;
371+
}
372+
359373
/// <summary>
360374
/// Used by code-generated systems and meant for internal use only.
361375
/// Adds a mapping from an IInputComponentData to the buffer it should use.

0 commit comments

Comments
 (0)