wip: integrating threaded decoupled physics

Current Issues:
- HUGE memory leak
- HUGE amount of needles copying
- FillGraph() does thousands of lock_guards instead of one
- Can no longer rely on new states appearing immediately - have to check
each access
- Physics run as fast as possible, no constant sim speed`
- Irregular long freezes
This commit is contained in:
2026-02-24 02:00:15 +01:00
parent 39c0b58f3f
commit 550970f8a1
7 changed files with 140 additions and 87 deletions

View File

@ -1,7 +1,6 @@
#ifndef __STATE_HPP_
#define __STATE_HPP_
#include "config.hpp"
#include "physics.hpp"
#include "presets.hpp"
#include "puzzle.hpp"
@ -10,7 +9,7 @@
class StateManager {
public:
MassSpringSystem &mass_springs;
ThreadedPhysics &physics;
int current_preset;
State starting_state;
@ -23,12 +22,12 @@ public:
std::unordered_set<State> visited_states;
public:
StateManager(MassSpringSystem &_mass_springs)
: mass_springs(_mass_springs), current_preset(0),
StateManager(ThreadedPhysics &_physics)
: physics(_physics), current_preset(0),
starting_state(generators[current_preset]()),
current_state(starting_state), previous_state(starting_state),
edited(false) {
mass_springs.AddMass(MASS, false, current_state);
physics.AddMassCmd(current_state);
}
StateManager(const StateManager &copy) = delete;