From 881d09f9bc33124924eb56d471f5098338a3dbe9 Mon Sep 17 00:00:00 2001 From: maelstrom Date: Sat, 29 Mar 2025 23:43:04 +0100 Subject: [PATCH] fix(editor): wrap move handles around aabb --- core/src/objects/handles.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/src/objects/handles.cpp b/core/src/objects/handles.cpp index 83526d6..303d0bc 100644 --- a/core/src/objects/handles.cpp +++ b/core/src/objects/handles.cpp @@ -44,7 +44,8 @@ Data::CFrame Handles::GetCFrameOfHandle(HandleFace face) { if (glm::abs(glm::dot(glm::vec3(localFrame.Rotation() * face.normal), upAxis)) > 0.9999f) upAxis = glm::vec3(0, 1, 0); - Data::Vector3 handlePos = localFrame * ((2.f + adornee->lock()->size * 0.5f) * face.normal); + Data::Vector3 handleOffset = this->worldMode ? ((Data::Vector3::ONE * 2.f) + adornee->lock()->GetAABB() * 0.5f) : Data::Vector3(2.f + adornee->lock()->size * 0.5f); + Data::Vector3 handlePos = localFrame * (handleOffset * face.normal); Data::CFrame cframe(handlePos, handlePos + localFrame.Rotation() * face.normal, upAxis); return cframe; @@ -55,11 +56,12 @@ Data::CFrame Handles::PartCFrameFromHandlePos(HandleFace face, Data::Vector3 new Data::CFrame localFrame = worldMode ? Data::CFrame::IDENTITY + adornee->lock()->position() : adornee->lock()->cframe; Data::CFrame inverseFrame = localFrame.Inverse(); + Data::Vector3 handleOffset = this->worldMode ? ((Data::Vector3::ONE * 2.f) + adornee->lock()->GetAABB() * 0.5f) : Data::Vector3(2.f + adornee->lock()->size * 0.5f); - Data::Vector3 handlePos = localFrame * ((2.f + adornee->lock()->size * 0.5f) * face.normal); + Data::Vector3 handlePos = localFrame * (handleOffset * face.normal); // glm::vec3 localPos = inverseFrame * newPos; - glm::vec3 newPartPos = newPos - localFrame.Rotation() * ((2.f + adornee->lock()->size * 0.5f) * face.normal); + glm::vec3 newPartPos = newPos - localFrame.Rotation() * (handleOffset * face.normal); return adornee->lock()->cframe.Rotation() + newPartPos; }