Files
cpp-masssprings/include/state.hpp
Christoph Urlacher 550970f8a1 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
2026-02-24 02:05:09 +01:00

63 lines
1.3 KiB
C++

#ifndef __STATE_HPP_
#define __STATE_HPP_
#include "physics.hpp"
#include "presets.hpp"
#include "puzzle.hpp"
#include <raymath.h>
class StateManager {
public:
ThreadedPhysics &physics;
int current_preset;
State starting_state;
State current_state;
State previous_state;
bool edited = false;
std::unordered_set<State> winning_states;
std::unordered_set<State> visited_states;
public:
StateManager(ThreadedPhysics &_physics)
: physics(_physics), current_preset(0),
starting_state(generators[current_preset]()),
current_state(starting_state), previous_state(starting_state),
edited(false) {
physics.AddMassCmd(current_state);
}
StateManager(const StateManager &copy) = delete;
StateManager &operator=(const StateManager &copy) = delete;
StateManager(StateManager &&move) = delete;
StateManager &operator=(StateManager &&move) = delete;
~StateManager() {}
public:
auto LoadPreset(int preset) -> void;
auto ResetState() -> void;
auto PreviousPreset() -> void;
auto NextPreset() -> void;
auto FillGraph() -> void;
auto UpdateGraph() -> void;
auto ClearGraph() -> void;
auto FindWinningStates() -> void;
auto CurrentGenerator() -> StateGenerator;
auto CurrentWinCondition() -> WinCondition;
};
#endif