From b63b499b019b53be22bf3e5bc9063d218cc87763 Mon Sep 17 00:00:00 2001 From: altalk23 <45172705+altalk23@users.noreply.github.com> Date: Fri, 19 Jul 2024 02:24:38 +0300 Subject: [PATCH] prevent scale reset --- changelog.md | 1 + src/util/EditorUtilities.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 4a78240..6b05e26 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,7 @@ ## v0.3.2-alpha * Added Custom Keybinds as a dependency for all platforms + * Prevent scale resetting by not generating tiny scaled objects (< 0.001) ## v0.3.1-alpha * Fixed the touch prio in support popup diff --git a/src/util/EditorUtilities.cpp b/src/util/EditorUtilities.cpp index 91d9a40..7e83182 100644 --- a/src/util/EditorUtilities.cpp +++ b/src/util/EditorUtilities.cpp @@ -22,12 +22,14 @@ void EditorUtilities::addRectangle(cocos2d::CCPoint const& p1, cocos2d::CCPoint auto const center = (p1 + p3) / 2.0f; auto const angle = std::atan2(p2.y - p1.y, p2.x - p1.x); - auto object = LevelEditorLayer::get()->createObject(SQUARE_OBJECT_ID, center, false); - object->setRotation(-angle * 180.0f / M_PI); - auto scaleX = p1.getDistance(p2) / SQUARE_OBJECT_SCALE; auto scaleY = p1.getDistance(p4) / SQUARE_OBJECT_SCALE; + if (scaleX < 0.001f || scaleY < 0.001f) return; // Prevent scale reset + + auto object = LevelEditorLayer::get()->createObject(SQUARE_OBJECT_ID, center, false); + object->setRotation(-angle * 180.0f / M_PI); + object->updateCustomScaleX(scaleX); object->updateCustomScaleY(scaleY);