Skip to content

Commit 55362e1

Browse files
authored
fix: Bepu and InputSystem update order (#2848)
1 parent bf95874 commit 55362e1

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/Definitions/SystemsOrderHelper.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net)
22
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
33

4+
using Stride.Engine;
45
using Stride.Engine.Processors;
56

67
namespace Stride.BepuPhysics.Definitions;
78

89
internal static class SystemsOrderHelper
910
{
10-
1111
//Note : transform processor's Draw() is at -200;
1212

1313
/// <summary> Creation and management of constraints </summary>
1414
public const int ORDER_OF_CONSTRAINT_P = -900;
15-
/// <summary> Simulation Step(dt) & Transform Update() </summary>
16-
public const int ORDER_OF_GAME_SYSTEM = int.MaxValue;
15+
/// <summary> Simulation Step(dt) & Transform Update()</summary>
16+
/// <remarks>
17+
/// Must happen before <see cref="ScriptSystem.Update"/> to make sure interpolated bodies update their positions before users read them,
18+
/// but after <see cref="InputSystem.Update"/> otherwise users would be reading last frame's input in <see cref="Components.ISimulationUpdate"/>
19+
/// </remarks>
20+
public const int ORDER_OF_GAME_SYSTEM = InputSystem.DefaultUpdateOrder + 1;
1721
/// <summary> Drawing debug wireframe, must occur after <see cref="TransformProcessor.Draw"/> </summary>
1822
public const int ORDER_OF_DEBUG_P = 1000;
1923
/// <summary> Creation and management of collidable, rebuilds static meshes when they are moved, must occur after <see cref="TransformProcessor.Draw"/> </summary>

sources/engine/Stride.Engine/Engine/InputSystem.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ namespace Stride.Engine
1313
/// </summary>
1414
public sealed class InputSystem : GameSystemBase
1515
{
16+
public const int DefaultUpdateOrder = -50;
17+
1618
public InputSystem(IServiceRegistry registry) : base(registry)
1719
{
1820
Enabled = true;
1921
Manager = new InputManager().DisposeBy(this);
22+
UpdateOrder = DefaultUpdateOrder;
2023
}
2124

2225
public InputManager Manager { get; }

0 commit comments

Comments
 (0)