wip: implement a smaller data model to reduce copying from physics to main thread

This commit is contained in:
2026-02-24 17:05:24 +01:00
parent 1347abad34
commit c4222c783c
13 changed files with 312 additions and 470 deletions

View File

@ -6,11 +6,17 @@
#include "puzzle.hpp"
#include <raymath.h>
#include <unordered_map>
#include <unordered_set>
class StateManager {
public:
ThreadedPhysics &physics;
std::unordered_map<State, std::size_t> states;
std::unordered_set<State> winning_states;
std::unordered_set<State> visited_states;
int current_preset;
State starting_state;
State current_state;
@ -18,16 +24,13 @@ public:
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);
ClearGraph();
}
StateManager(const StateManager &copy) = delete;
@ -54,9 +57,11 @@ public:
auto FindWinningStates() -> void;
auto CurrentGenerator() -> StateGenerator;
auto CurrentGenerator() const -> StateGenerator;
auto CurrentWinCondition() -> WinCondition;
auto CurrentWinCondition() const -> WinCondition;
auto CurrentMassIndex() const -> std::size_t;
};
#endif