implement graph node mouse collisions (unoptimized iterating over all masses for now)

This commit is contained in:
2026-03-06 13:25:35 +01:00
parent 6bfe217fee
commit fe9a54a8da
5 changed files with 965 additions and 19 deletions

View File

@ -87,6 +87,9 @@ public:
Vector2 mouse = Vector2Zero();
Vector2 last_mouse = Vector2Zero();
// State selection from graph
size_t collision_mass = -1;
public:
input_handler(state_manager& _state, orbit_camera& _camera) : state(_state), camera(_camera)
{
@ -123,6 +126,7 @@ public:
auto add_block() -> void;
auto remove_block() -> void;
auto place_goal() const -> void;
auto select_state() const -> void;
// Key actions
auto toggle_camera_lock() -> void;

View File

@ -14,16 +14,14 @@ class renderer
{
private:
const state_manager& state;
const input_handler& input;
input_handler& input;
user_interface& gui;
const orbit_camera& camera;
RenderTexture graph_target =
LoadRenderTexture(GetScreenWidth() / 2, GetScreenHeight() - MENU_HEIGHT);
RenderTexture graph_target = LoadRenderTexture(GetScreenWidth() / 2, GetScreenHeight() - MENU_HEIGHT);
// TODO: Those should be moved to the user_interface.h
RenderTexture klotski_target =
LoadRenderTexture(GetScreenWidth() / 2, GetScreenHeight() - MENU_HEIGHT);
RenderTexture klotski_target = LoadRenderTexture(GetScreenWidth() / 2, GetScreenHeight() - MENU_HEIGHT);
RenderTexture menu_target = LoadRenderTexture(GetScreenWidth(), MENU_HEIGHT);
// Batching
@ -35,21 +33,21 @@ private:
std::vector<Color> colors;
Material vertex_mat = LoadMaterialDefault();
Mesh cube_instance = GenMeshCube(VERTEX_SIZE, VERTEX_SIZE, VERTEX_SIZE);
Shader instancing_shader =
LoadShader("shader/instancing_vertex.glsl", "shader/instancing_fragment.glsl");
Shader instancing_shader = LoadShader("shader/instancing_vertex.glsl", "shader/instancing_fragment.glsl");
unsigned int color_vbo_id = 0;
public:
renderer(const orbit_camera& _camera, const state_manager& _state, const input_handler& _input,
renderer(const orbit_camera& _camera,
const state_manager& _state,
input_handler& _input,
user_interface& _gui)
: state(_state), input(_input), gui(_gui), camera(_camera)
{
instancing_shader.locs[SHADER_LOC_MATRIX_MVP] = GetShaderLocation(instancing_shader, "mvp");
instancing_shader.locs[SHADER_LOC_MATRIX_MODEL] =
GetShaderLocationAttrib(instancing_shader, "instanceTransform");
instancing_shader.locs[SHADER_LOC_VECTOR_VIEW] =
GetShaderLocation(instancing_shader, "viewPos");
instancing_shader.locs[SHADER_LOC_MATRIX_MODEL] = GetShaderLocationAttrib(
instancing_shader,
"instanceTransform");
instancing_shader.locs[SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(instancing_shader, "viewPos");
// infoln("LOC vertexPosition: {}",
// rlGetLocationAttrib(instancing_shader.id, "vertexPosition"));
@ -102,8 +100,7 @@ private:
auto draw_textures(int fps, int ups, size_t mass_count, size_t spring_count) const -> void;
public:
auto render(const std::vector<Vector3>& masses, int fps, int ups, size_t mass_count,
size_t spring_count) -> void;
auto render(const std::vector<Vector3>& masses, int fps, int ups, size_t mass_count, size_t spring_count) -> void;
};
#endif