From d3a0a5e6a066c69821abc8c4f4b5c32e9aab7e10 Mon Sep 17 00:00:00 2001 From: Doprez <73259914+Doprez@users.noreply.github.com> Date: Fri, 22 Dec 2023 17:20:27 -0700 Subject: [PATCH] removed auto adding render feature --- .../Camera/BasicCameraControllerComponent.cs | 6 ++++-- .../Processors/ContainerProcessor.cs | 19 ++++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Stride.BepuPhysics.Demo/Components/Camera/BasicCameraControllerComponent.cs b/Stride.BepuPhysics.Demo/Components/Camera/BasicCameraControllerComponent.cs index 672c1f1..06073fb 100644 --- a/Stride.BepuPhysics.Demo/Components/Camera/BasicCameraControllerComponent.cs +++ b/Stride.BepuPhysics.Demo/Components/Camera/BasicCameraControllerComponent.cs @@ -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() diff --git a/Stride.BepuPhysics/Processors/ContainerProcessor.cs b/Stride.BepuPhysics/Processors/ContainerProcessor.cs index 2570a75..abff8f0 100644 --- a/Stride.BepuPhysics/Processors/ContainerProcessor.cs +++ b/Stride.BepuPhysics/Processors/ContainerProcessor.cs @@ -40,11 +40,6 @@ protected override void OnSystemAdd() { _wireframeRenderFeature = wireFramRender; } - else - { - _wireframeRenderFeature = new SinglePassWireframeRenderFeature(); - _game.GameSystems.OfType().First().GraphicsCompositor.RenderFeatures.Add(_wireframeRenderFeature); - } } protected override void OnEntityComponentAdding(Entity entity, [NotNull] ContainerComponent component, [NotNull] ContainerComponent data) @@ -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) @@ -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); } } }