From 19559a1b1e9813fbc945eb3c6373a321a202c42b Mon Sep 17 00:00:00 2001 From: Unreal Karaulov Date: Mon, 1 Jan 2024 13:41:05 +0300 Subject: [PATCH] Small fix --- src/editor/Gui.cpp | 36 +++++++++++++++++++++++------------- src/editor/Renderer.cpp | 9 +++++---- src/editor/Renderer.h | 2 +- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/editor/Gui.cpp b/src/editor/Gui.cpp index 04a13e73..3e8372bb 100644 --- a/src/editor/Gui.cpp +++ b/src/editor/Gui.cpp @@ -3331,7 +3331,8 @@ void Gui::drawMenuBar() if (ImGui::MenuItem(get_localized_string(LANG_0599).c_str(), "", showLightmapEditorWidget)) { showLightmapEditorWidget = !showLightmapEditorWidget; - FaceSelectPressed(); + app->pickMode = PICK_FACE; + pickCount++; showLightmapEditorUpdate = true; } if (ImGui::MenuItem(get_localized_string(LANG_0600).c_str(), "", showMergeMapWidget)) @@ -3457,10 +3458,13 @@ void Gui::drawToolbar() ImGui::PushStyleColor(ImGuiCol_Border, app->pickMode == PICK_OBJECT ? dimColor : selectColor); if (ImGui::ImageButton("##pickobj",(void*)(uint64_t)objectIconTexture->id, iconSize, ImVec2(0, 0), ImVec2(1, 1))) { - app->deselectFaces(); - app->deselectObject(); - app->pickMode = PICK_OBJECT; - showFaceEditWidget = false; + if (app->pickMode != PICK_OBJECT) + { + app->deselectFaces(); + app->deselectObject(); + app->pickMode = PICK_OBJECT; + showFaceEditWidget = false; + } } ImGui::PopStyleColor(2); if (ImGui::IsItemHovered() && g.HoveredIdTimer > g_tooltip_delay) @@ -3476,10 +3480,13 @@ void Gui::drawToolbar() ImGui::SameLine(); if (ImGui::ImageButton("##pickface", (ImTextureID)(uint64_t)faceIconTexture->id, iconSize, ImVec2(0, 0), ImVec2(1, 1))) { - app->deselectFaces(); - app->deselectObject(); - FaceSelectPressed(); + if (app->pickMode == PICK_OBJECT) + { + app->deselectObject(true); + pickCount++; + } showFaceEditWidget = true; + app->pickMode = PICK_FACE; } ImGui::PopStyleColor(2); if (ImGui::IsItemHovered() && g.HoveredIdTimer > g_tooltip_delay) @@ -3494,10 +3501,13 @@ void Gui::drawToolbar() ImGui::SameLine(); if (ImGui::ImageButton("##pickleaf", (void*)(uint64_t)leafIconTexture->id, iconSize, ImVec2(0, 0), ImVec2(1, 1))) { - app->deselectFaces(); - app->deselectObject(); - app->pickMode = PICK_FACE_LEAF; + if (app->pickMode == PICK_OBJECT) + { + app->deselectObject(true); + pickCount++; + } showFaceEditWidget = true; + app->pickMode = PICK_FACE_LEAF; } ImGui::PopStyleColor(1); if (ImGui::IsItemHovered() && g.HoveredIdTimer > g_tooltip_delay) @@ -3533,7 +3543,7 @@ void Gui::FaceSelectPressed() } } - if (app->pickMode != PICK_FACE) + if (app->pickMode == PICK_OBJECT) app->deselectObject(); app->pickMode = PICK_FACE; @@ -8719,7 +8729,7 @@ void Gui::drawFaceEditorWidget() static bool stylesChanged = false; Bsp* map = app->getSelectedMap(); - if (!map || app->pickMode != PICK_FACE || app->pickInfo.selectedFaces.empty()) + if (!map || app->pickMode == PICK_OBJECT || app->pickInfo.selectedFaces.empty()) { ImGui::Text(get_localized_string(LANG_1130).c_str()); ImGui::End(); diff --git a/src/editor/Renderer.cpp b/src/editor/Renderer.cpp index a2e70413..0489d26d 100644 --- a/src/editor/Renderer.cpp +++ b/src/editor/Renderer.cpp @@ -855,7 +855,7 @@ void Renderer::drawModelVerts() Bsp* map = SelectedMap; int entIdx = pickInfo.GetSelectedEnt(); - if (!map || entIdx < 0) + if (!map || entIdx < 0) return; BspRenderer* rend = map->getBspRender(); if (!rend) @@ -951,7 +951,7 @@ void Renderer::drawModelOrigin() glClear(GL_DEPTH_BUFFER_BIT); Bsp* map = SelectedMap; - if (!map ) + if (!map) return; BspRenderer* rend = map->getBspRender(); if (!rend) @@ -3650,11 +3650,12 @@ void Renderer::deleteEnts() } } -void Renderer::deselectObject() +void Renderer::deselectObject(bool onlyobject) { filterNeeded = true; pickInfo.selectedEnts.clear(); - pickInfo.selectedFaces.clear(); + if (onlyobject) + pickInfo.selectedFaces.clear(); isTransformableSolid = false; hoverVert = -1; hoverEdge = -1; diff --git a/src/editor/Renderer.h b/src/editor/Renderer.h index d977c841..a17bfc2e 100644 --- a/src/editor/Renderer.h +++ b/src/editor/Renderer.h @@ -302,7 +302,7 @@ class Renderer void scaleSelectedVerts(float x, float y, float z); vec3 getEdgeControlPoint(std::vector& hullVerts, HullEdge& edge); vec3 getCentroid(std::vector& hullVerts); - void deselectObject(); // keep map selected but unselect all objects + void deselectObject(bool onlyobject = false); // keep map selected but unselect all objects void selectFace(Bsp* map, int face, bool add = false); void deselectFaces(); void selectEnt(Bsp* map, int entIdx, bool add = false);