Skip to content

Commit

Permalink
Merge pull request #36 from Doprez/master
Browse files Browse the repository at this point in the history
removed auto adding render feature
  • Loading branch information
Doprez authored Dec 23, 2023
2 parents f84f37a + 37770a6 commit bf57a76
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ public override void Update()

private void UpdateDebugShapes()
{
if(Input.IsKeyPressed(Keys.F))
wireframeRenderFeature.IsEnabled(!wireframeRenderFeature.Enable);
if (Input.IsKeyPressed(Keys.F) && wireframeRenderFeature != null)
{
wireframeRenderFeature.IsEnabled(!wireframeRenderFeature.Enable);
}
}

private void ProcessInput()
Expand Down
19 changes: 10 additions & 9 deletions Stride.BepuPhysics/Processors/ContainerProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ protected override void OnSystemAdd()
{
_wireframeRenderFeature = wireFramRender;
}
else
{
_wireframeRenderFeature = new SinglePassWireframeRenderFeature();
_game.GameSystems.OfType<SceneSystem>().First().GraphicsCompositor.RenderFeatures.Add(_wireframeRenderFeature);
}
}

protected override void OnEntityComponentAdding(Entity entity, [NotNull] ContainerComponent component, [NotNull] ContainerComponent data)
Expand Down Expand Up @@ -75,12 +70,18 @@ protected override void OnEntityComponentRemoved(Entity entity, [NotNull] Contai

public override void Update(GameTime time)
{
base.Update(time);

var dt = (float)time.Elapsed.TotalMilliseconds;
if (dt == 0f)
return;

bool updateDebugRender = false;

if(_wireframeRenderFeature != null)
{
updateDebugRender = _wireframeRenderFeature.Enable;

}

foreach (var bepuSim in _bepuConfiguration.BepuSimulations)
{
if (!bepuSim.Enabled)
Expand Down Expand Up @@ -108,13 +109,13 @@ public override void Update(GameTime time)
//Nicogo : a performance test on a smallScene would be nice to be sure
if (bepuSim.ParallelUpdate)
{
Dispatcher.For(0, bepuSim.Simulation.Bodies.ActiveSet.Count, (i) => UpdateBodiesPositionFunction(bepuSim.Simulation.Bodies.ActiveSet.IndexToHandle[i], bepuSim, _wireframeRenderFeature.Enable));
Dispatcher.For(0, bepuSim.Simulation.Bodies.ActiveSet.Count, (i) => UpdateBodiesPositionFunction(bepuSim.Simulation.Bodies.ActiveSet.IndexToHandle[i], bepuSim, updateDebugRender));
}
else
{
for (int i = 0; i < bepuSim.Simulation.Bodies.ActiveSet.Count; i++)
{
UpdateBodiesPositionFunction(bepuSim.Simulation.Bodies.ActiveSet.IndexToHandle[i], bepuSim, _wireframeRenderFeature.Enable);
UpdateBodiesPositionFunction(bepuSim.Simulation.Bodies.ActiveSet.IndexToHandle[i], bepuSim, updateDebugRender);
}
}
}
Expand Down

0 comments on commit bf57a76

Please sign in to comment.