Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Backports:SLE-15-SP4
leocad
0004-Fixed-drawing-the-rotate-overlay-during-in...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0004-Fixed-drawing-the-rotate-overlay-during-in-place-sub.patch of Package leocad
From ccd9904c4cd7f305b168490750d94016a936a104 Mon Sep 17 00:00:00 2001 From: Leonardo Zide <leozide@gmail.com> Date: Sun, 25 Apr 2021 12:02:57 -0700 Subject: [PATCH 4/4] Fixed drawing the rotate overlay during in place submodel edits. --- common/lc_view.cpp | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/common/lc_view.cpp b/common/lc_view.cpp index 8a6abb13..133939f9 100644 --- a/common/lc_view.cpp +++ b/common/lc_view.cpp @@ -1489,6 +1489,11 @@ void lcView::DrawRotateOverlay() lcVector3 MouseToolDistance = ActiveModel->SnapRotation(ActiveModel->GetMouseToolDistance()); bool HasAngle = false; + lcMatrix44 WorldMatrix = lcMatrix44(RelativeRotation, OverlayCenter); + + if (ActiveModel != mModel) + WorldMatrix = lcMul(WorldMatrix, mActiveSubmodelTransform); + // Draw a disc showing the rotation amount. if (MouseToolDistance.LengthSquared() != 0.0f && (mTrackButton != lcTrackButton::None)) { @@ -1532,10 +1537,9 @@ void lcView::DrawRotateOverlay() if (fabsf(Angle) >= fabsf(Step)) { - lcMatrix44 WorldMatrix = lcMatrix44(RelativeRotation, OverlayCenter); - WorldMatrix = lcMul(lcMatrix44FromAxisAngle(lcVector3(Rotation[1], Rotation[2], Rotation[3]), Rotation[0] * LC_DTOR), WorldMatrix); + lcMatrix44 RotatedWorldMatrix = lcMul(lcMatrix44FromAxisAngle(lcVector3(Rotation[1], Rotation[2], Rotation[3]), Rotation[0] * LC_DTOR), WorldMatrix); - mContext->SetWorldMatrix(WorldMatrix); + mContext->SetWorldMatrix(RotatedWorldMatrix); glEnable(GL_BLEND); @@ -1587,7 +1591,7 @@ void lcView::DrawRotateOverlay() if (gMainWindow->GetTool() == lcTool::Rotate && !HasAngle && mTrackButton == lcTrackButton::None) { lcMatrix44 Mat = lcMatrix44AffineInverse(mCamera->mWorldView); - Mat.SetTranslation(OverlayCenter); + Mat.SetTranslation(WorldMatrix.GetTranslation()); lcVector3 Verts[32]; @@ -1615,9 +1619,9 @@ void lcView::DrawRotateOverlay() ViewDir.Normalize(); // Transform ViewDir to local space. - ViewDir = lcMul(ViewDir, lcMatrix33AffineInverse(RelativeRotation)); + ViewDir = lcMul(ViewDir, lcMatrix33AffineInverse(lcMatrix33(WorldMatrix))); - mContext->SetWorldMatrix(lcMatrix44(RelativeRotation, OverlayCenter)); + mContext->SetWorldMatrix(WorldMatrix); // Draw each axis circle. for (int i = 0; i < 3; i++) @@ -1712,9 +1716,8 @@ void lcView::DrawRotateOverlay() break; }; - lcMatrix44 WorldMatrix = lcMatrix44(RelativeRotation, OverlayCenter); - WorldMatrix = lcMul(lcMatrix44FromAxisAngle(lcVector3(Rotation[1], Rotation[2], Rotation[3]), Rotation[0] * LC_DTOR), WorldMatrix); - mContext->SetWorldMatrix(WorldMatrix); + lcMatrix44 RotatedWorldMatrix = lcMul(lcMatrix44FromAxisAngle(lcVector3(Rotation[1], Rotation[2], Rotation[3]), Rotation[0] * LC_DTOR), WorldMatrix); + mContext->SetWorldMatrix(RotatedWorldMatrix); mContext->SetColor(0.8f, 0.8f, 0.0f, 1.0f); @@ -1742,7 +1745,7 @@ void lcView::DrawRotateOverlay() } // Draw text. - lcVector3 ScreenPos = ProjectPoint(OverlayCenter); + lcVector3 ScreenPos = ProjectPoint(WorldMatrix.GetTranslation()); mContext->SetMaterial(lcMaterialType::UnlitTextureModulate); mContext->SetWorldMatrix(lcMatrix44Identity()); @@ -2165,11 +2168,16 @@ float lcView::GetOverlayScale() const lcModel* ActiveModel = GetActiveModel(); ActiveModel->GetMoveRotateTransform(OverlayCenter, RelativeRotation); - lcVector3 ScreenPos = ProjectPoint(OverlayCenter); + lcMatrix44 WorldMatrix = lcMatrix44(RelativeRotation, OverlayCenter); + + if (ActiveModel != mModel) + WorldMatrix = lcMul(WorldMatrix, mActiveSubmodelTransform); + + lcVector3 ScreenPos = ProjectPoint(WorldMatrix.GetTranslation()); ScreenPos[0] += 10.0f; lcVector3 Point = UnprojectPoint(ScreenPos); - lcVector3 Dist(Point - OverlayCenter); + lcVector3 Dist(Point - WorldMatrix.GetTranslation()); return Dist.Length() * 5.0f; } @@ -3605,7 +3613,7 @@ void lcView::OnMouseMove() else PlaneNormal = lcVector3(1.0f, 0.0f, 0.0f); - PlaneNormal = lcMul(PlaneNormal, RelativeRotation); + PlaneNormal = lcMul30(PlaneNormal, WorldMatrix); lcVector4 Plane(PlaneNormal, -lcDot(PlaneNormal, Center)); lcVector3 Intersection; @@ -3616,7 +3624,7 @@ void lcView::OnMouseMove() if (lcLineSegmentPlaneIntersection(&MoveStart, MouseDownStart, MouseDownEnd, Plane)) { lcVector3 Distance = Intersection - MoveStart; - Distance = lcMul(Distance, lcMatrix33AffineInverse(RelativeRotation)); + Distance = lcMul(Distance, lcMatrix33AffineInverse(lcMatrix33(WorldMatrix))); ActiveModel->UpdateMoveTool(Distance, true, mTrackButton != lcTrackButton::Left); } } @@ -3635,7 +3643,7 @@ void lcView::OnMouseMove() else Direction = lcVector3(-1.0f, 0.0f, 0.0f); - Direction = lcMul(Direction, RelativeRotation); + Direction = lcMul30(Direction, WorldMatrix); lcVector3 Intersection; lcClosestPointsBetweenLines(Center, Center + Direction, CurrentStart, CurrentEnd, &Intersection, nullptr); -- 2.31.1
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor