Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed auto adding render feature #36

Merged
merged 2 commits into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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