From ef6a5da4d6a90a8757e4b3d7464d6b0bbb542b18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20=C5=A0toura=C4=8D?= <525032@mail.muni.cz> Date: Tue, 21 May 2024 19:30:11 +0200 Subject: [PATCH] add reset of variables when new rofiworld is loaded --- src/edit/include/edit/editor.hpp | 2 ++ src/edit/src/editor.cpp | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/edit/include/edit/editor.hpp b/src/edit/include/edit/editor.hpp index 7d84ebc..82b58d4 100644 --- a/src/edit/include/edit/editor.hpp +++ b/src/edit/include/edit/editor.hpp @@ -359,6 +359,8 @@ public: bool checkModuleExport(const voxel_graph_ptr &voxel_graph, const build_mode_I build_mode); + void resetBuildModeIIVariables(); + state &getControlState() { return control_state; } bool isObjectMoving() const { return object_moving; } diff --git a/src/edit/src/editor.cpp b/src/edit/src/editor.cpp index 6f14a98..b339c03 100644 --- a/src/edit/src/editor.cpp +++ b/src/edit/src/editor.cpp @@ -179,6 +179,7 @@ void Editor::manageUIImportRofiWorld() ui.import_file_error = false; ui.name_buffer[0] = '\0'; + resetBuildModeIIVariables(); } else { @@ -210,6 +211,25 @@ bool Editor::checkModuleExport(const voxel_graph_ptr &voxel_graph, const build_m return false; } +void Editor::resetBuildModeIIVariables() +{ + selected_module = nullptr; + selected_add_module = nullptr; + prev_selected_add_module = nullptr; + prev_rebuild_node = nullptr; + can_rotate_component = true; + rotation_locked_module = nullptr; + collided_modules = {}; + selected_connectors = {nullptr, nullptr}; + first_connector_highlights = {glm::vec3(0.0f), nullptr}; + second_connector_highlights = {glm::vec3(0.0f), nullptr}; + selected_modules_connect = { nullptr, nullptr }; + can_connect_modules = true; + selected_space_joints = {}; + + scene->manageSelection(nullptr); +} + void Editor::update() { // WARNING: Not tested when placed here, before the rest of the methods -- GitLab