From f06afc210f658a330aba1f17b7bfa36a33d9a61f Mon Sep 17 00:00:00 2001 From: Christoph Urlacher Date: Sun, 22 Feb 2026 14:17:55 +0100 Subject: [PATCH] make naming more consistent + rename some files --- CMakeLists.txt | 4 ++-- include/{mass_springs.hpp => physics.hpp} | 6 +++--- include/presets.hpp | 2 +- include/{klotski.hpp => puzzle.hpp} | 4 ++-- include/renderer.hpp | 4 ++-- include/state.hpp | 4 ++-- src/main.cpp | 2 +- src/{mass_springs.cpp => physics.cpp} | 2 +- src/{klotski.cpp => puzzle.cpp} | 2 +- src/renderer.cpp | 24 +++++++++++------------ 10 files changed, 27 insertions(+), 27 deletions(-) rename include/{mass_springs.hpp => physics.hpp} (97%) rename include/{klotski.hpp => puzzle.hpp} (99%) rename src/{mass_springs.cpp => physics.cpp} (99%) rename src/{klotski.cpp => puzzle.cpp} (99%) diff --git a/CMakeLists.txt b/CMakeLists.txt index ddfacf5..0206cce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,8 +12,8 @@ include_directories(include) add_executable(masssprings src/main.cpp src/renderer.cpp - src/mass_springs.cpp - src/klotski.cpp + src/physics.cpp + src/puzzle.cpp src/state.cpp src/input.cpp ) diff --git a/include/mass_springs.hpp b/include/physics.hpp similarity index 97% rename from include/mass_springs.hpp rename to include/physics.hpp index 3bea1c0..4b90e5d 100644 --- a/include/mass_springs.hpp +++ b/include/physics.hpp @@ -1,8 +1,8 @@ -#ifndef __MASS_SPRINGS_HPP_ -#define __MASS_SPRINGS_HPP_ +#ifndef __PHYSICS_HPP_ +#define __PHYSICS_HPP_ #include "config.hpp" -#include "klotski.hpp" +#include "puzzle.hpp" #include #include #include diff --git a/include/presets.hpp b/include/presets.hpp index f805563..d2ebc5f 100644 --- a/include/presets.hpp +++ b/include/presets.hpp @@ -4,7 +4,7 @@ #include #include -#include "klotski.hpp" +#include "puzzle.hpp" using StateGenerator = std::function; diff --git a/include/klotski.hpp b/include/puzzle.hpp similarity index 99% rename from include/klotski.hpp rename to include/puzzle.hpp index 3e54937..a98992a 100644 --- a/include/klotski.hpp +++ b/include/puzzle.hpp @@ -1,5 +1,5 @@ -#ifndef __KLOTSKI_HPP_ -#define __KLOTSKI_HPP_ +#ifndef __PUZZLE_HPP_ +#define __PUZZLE_HPP_ #include #include diff --git a/include/renderer.hpp b/include/renderer.hpp index 8beafe1..fab6235 100644 --- a/include/renderer.hpp +++ b/include/renderer.hpp @@ -7,8 +7,8 @@ #include #include "config.hpp" -#include "klotski.hpp" -#include "mass_springs.hpp" +#include "puzzle.hpp" +#include "physics.hpp" class OrbitCamera3D { friend class Renderer; diff --git a/include/state.hpp b/include/state.hpp index dc7e3e9..e34139e 100644 --- a/include/state.hpp +++ b/include/state.hpp @@ -2,8 +2,8 @@ #define __STATE_HPP_ #include "config.hpp" -#include "klotski.hpp" -#include "mass_springs.hpp" +#include "puzzle.hpp" +#include "physics.hpp" #include "presets.hpp" #include diff --git a/src/main.cpp b/src/main.cpp index d27022a..d93db1a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,7 +4,7 @@ #include "config.hpp" #include "input.hpp" -#include "mass_springs.hpp" +#include "physics.hpp" #include "renderer.hpp" #include "state.hpp" diff --git a/src/mass_springs.cpp b/src/physics.cpp similarity index 99% rename from src/mass_springs.cpp rename to src/physics.cpp index 9b6ecf6..1c1d823 100644 --- a/src/mass_springs.cpp +++ b/src/physics.cpp @@ -1,4 +1,4 @@ -#include "mass_springs.hpp" +#include "physics.hpp" #include "config.hpp" #include diff --git a/src/klotski.cpp b/src/puzzle.cpp similarity index 99% rename from src/klotski.cpp rename to src/puzzle.cpp index 58d2497..4d91958 100644 --- a/src/klotski.cpp +++ b/src/puzzle.cpp @@ -1,4 +1,4 @@ -#include "klotski.hpp" +#include "puzzle.hpp" auto Block::Hash() const -> int { std::string s = std::format("{},{},{},{}", x, y, width, height); diff --git a/src/renderer.cpp b/src/renderer.cpp index 0ba3852..4851e6e 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -8,8 +8,8 @@ #include #include "config.hpp" -#include "klotski.hpp" -#include "mass_springs.hpp" +#include "puzzle.hpp" +#include "physics.hpp" #ifdef BATCHING #include @@ -94,9 +94,9 @@ auto OrbitCamera3D::Update(const Mass ¤t_mass) -> void { camera.target = target; } -auto Renderer::UpdateCamera(const MassSpringSystem &masssprings, +auto Renderer::UpdateCamera(const MassSpringSystem &mass_springs, const State ¤t) -> void { - const Mass &c = masssprings.masses.at(current); + const Mass &c = mass_springs.masses.at(current); camera.Update(c); } @@ -180,11 +180,6 @@ auto Renderer::DrawMassSprings(const MassSpringSystem &mass_springs, DrawMeshInstanced(cube_instance, vertex_mat, transforms, mass_springs.masses.size()); - // Mark current state - const Mass ¤t_mass = mass_springs.GetMass(current_state); - DrawCube(current_mass.position, VERTEX_SIZE * 2, VERTEX_SIZE * 2, - VERTEX_SIZE * 2, RED); - // Mark winning states if (mark_solutions || connect_solutions) { for (const auto &state : winning_states) { @@ -201,6 +196,11 @@ auto Renderer::DrawMassSprings(const MassSpringSystem &mass_springs, } } + // Mark current state + const Mass ¤t_mass = mass_springs.GetMass(current_state); + DrawCube(current_mass.position, VERTEX_SIZE * 2, VERTEX_SIZE * 2, + VERTEX_SIZE * 2, RED); + // DrawGrid(10, 1.0); // DrawSphere(camera.target, VERTEX_SIZE, ORANGE); EndMode3D(); @@ -293,8 +293,8 @@ auto Renderer::DrawKlotski(const State &state, int hov_x, int hov_y, int sel_x, EndTextureMode(); } -auto Renderer::DrawMenu(const MassSpringSystem &masssprings, int current_preset, - const State ¤t_state, +auto Renderer::DrawMenu(const MassSpringSystem &mass_springs, + int current_preset, const State ¤t_state, const std::unordered_set &winning_states) -> void { BeginTextureMode(menu_target); @@ -318,7 +318,7 @@ auto Renderer::DrawMenu(const MassSpringSystem &masssprings, int current_preset, draw_btn(0, 0, std::format("States: {}, Transitions: {}, Winning: {}", - masssprings.masses.size(), masssprings.springs.size(), + mass_springs.masses.size(), mass_springs.springs.size(), winning_states.size()), DARKGREEN); draw_btn(