refactor state management and input handling into separate classes

This commit is contained in:
2026-02-21 22:00:33 +01:00
parent f8fe9e35d6
commit b98a1aeff1
11 changed files with 451 additions and 327 deletions

View File

@ -1,6 +1,7 @@
#ifndef __MASS_SPRINGS_HPP_
#define __MASS_SPRINGS_HPP_
#include "klotski.hpp"
#include <raylib.h>
#include <raymath.h>
#include <string>
@ -84,7 +85,7 @@ public:
};
class MassSpringSystem {
private:
public:
std::vector<Mass *> mass_vec;
std::vector<int> indices;
std::vector<int64_t> cell_ids;
@ -92,7 +93,6 @@ private:
int last_masses_count;
int last_springs_count;
public:
std::unordered_map<std::string, Mass> masses;
std::unordered_map<std::string, Spring> springs;
@ -110,14 +110,13 @@ private:
auto BuildGrid() -> void;
public:
auto AddMass(float mass, Vector3 position, bool fixed,
const std::string &state) -> void;
auto AddMass(float mass, Vector3 position, bool fixed, const State &state)
-> void;
auto GetMass(const std::string &state) -> Mass &;
auto GetMass(const State &state) -> Mass &;
auto AddSpring(const std::string &massA, const std::string &massB,
float spring_constant, float dampening_constant,
float rest_length) -> void;
auto AddSpring(const State &massA, const State &massB, float spring_constant,
float dampening_constant, float rest_length) -> void;
auto Clear() -> void;
@ -130,6 +129,8 @@ public:
auto EulerUpdate(float delta_time) -> void;
auto VerletUpdate(float delta_time) -> void;
auto InvalidateGrid() -> void;
};
#endif