diff --git a/engine/src/fixedstep/plugin.cpp b/engine/src/fixedstep/plugin.cpp index e2d02f44a..4505761b3 100644 --- a/engine/src/fixedstep/plugin.cpp +++ b/engine/src/fixedstep/plugin.cpp @@ -1,26 +1,24 @@ -#include #include - +#include using namespace cubos::engine; -const float frametime = 1/60; - - +const float frametime = 0.01F; void cubos::engine::fixedStepPlugin(Cubos& cubos) { cubos.addResource(); - cubos.system("accumulate time resource").call([](AccumulatedTime& timer, const DeltaTime& dt) { - timer.value += dt.value; - }); + cubos.system("accumulate time resource") + .tagged("accumulator") + .call([](AccumulatedTime& timer, const DeltaTime& dt) { timer.value += dt.value; }); cubos.tag("cubos.fixedStep").repeatWhile([](AccumulatedTime& timer) { - if (timer.value >= frametime) { - timer.value -= frametime; - return true; - } - return false; - }); + if (timer.value >= frametime) + { + timer.value -= frametime; + return true; + } + return false; + }); } \ No newline at end of file diff --git a/engine/src/physics/physics_accumulator.hpp b/engine/src/physics/physics_accumulator.hpp deleted file mode 100644 index 655e43d5f..000000000 --- a/engine/src/physics/physics_accumulator.hpp +++ /dev/null @@ -1,15 +0,0 @@ -/// @file -/// @brief Resource @ref cubos::engine::Accumulator. -/// @ingroup physics-plugin - -#pragma once - -namespace cubos::engine -{ - /// @brief Resource which holds the progress to the next integration. - /// @ingroup physics-plugin - struct PhysicsAccumulator - { - float value = 0.0F; - }; -} // namespace cubos::engine diff --git a/engine/src/physics/plugin.cpp b/engine/src/physics/plugin.cpp index c09edc4c2..1704ae13d 100644 --- a/engine/src/physics/plugin.cpp +++ b/engine/src/physics/plugin.cpp @@ -1,13 +1,11 @@ #include #include +#include #include #include #include #include -#include - -#include "physics_accumulator.hpp" using namespace cubos::engine; @@ -62,12 +60,10 @@ CUBOS_REFLECT_IMPL(PhysicsBundle) .build(); } - void cubos::engine::physicsPlugin(Cubos& cubos) { cubos.addResource(); cubos.addResource(); - cubos.addResource(); cubos.addResource(); cubos.addComponent(); @@ -106,10 +102,7 @@ void cubos::engine::physicsPlugin(Cubos& cubos) } }); - - cubos.tag("cubos.physics.apply_forces") - .after("cubos.physics.simulation.prepare") - .before("cubos.physics.simulation.substeps.integrate"); + cubos.tag("cubos.physics.apply_forces").after("accumulator").before("cubos.physics.simulation.substeps.integrate"); cubos.system("apply impulses") .tagged("cubos.physics.simulation.apply_impulses") @@ -125,7 +118,7 @@ void cubos::engine::physicsPlugin(Cubos& cubos) cubos.system("integrate position") .tagged("cubos.physics.simulation.substeps.integrate") - .after("cubos.physics.simulation.prepare") + .after("accumulator") .tagged("cubos.fixedStep") .call([](Query query, const Damping& damping, const FixedDeltaTime& fixedDeltaTime, const Substeps& substeps) { @@ -202,12 +195,4 @@ void cubos::engine::physicsPlugin(Cubos& cubos) impulse.clear(); } }); - - cubos.system("decrease fixed-step accumulator") - .tagged("cubos.physics.simulation.decrease_accumulator") - .after("cubos.physics.simulation.clear_forces") - .tagged("cubos.fixedStep") - .call([](PhysicsAccumulator& accumulator, const FixedDeltaTime& fixedDeltaTime) { - accumulator.value -= fixedDeltaTime.value; - }); }