From bf078695f081da8f2bd381929c0ed46daa8ff71e Mon Sep 17 00:00:00 2001 From: mzernova Date: Wed, 10 Jun 2020 12:18:47 +0300 Subject: [PATCH] 0027919: Visualization - support multiple transformation persistence groups within single presentation added AnchorPoint transformation in accordance with local transformation (cherry picked from commit de18833ce2e8e83d84bdc25e441a4f55f50f3b7f) (cherry picked from commit 88201b5418170634d740fdfe9fa1d5f5775ae97b) (cherry picked from commit e0d6884df321c7d5750ee2c45f96d5e0b4166e01) (cherry picked from commit acd78717b153e7f1e913a411d9278bfdabf2017a) (cherry picked from commit e39441eccd178b578032c1ebd6b3b08ad8724502) (cherry picked from commit 19c38dc1987650795faaa4edce4a853b5c107a20) (cherry picked from commit 0ade81efd00d909f4736ef61b9c6c90dd33e6667) (cherry picked from commit 737d5218fb0d2c902de00873ce818224b0cd9114) # Conflicts: # src/OpenGl/OpenGl_Structure.cxx (cherry picked from commit 20db9abb373494afe2ef90bab03e1b60f8fad60f) --- src/OpenGl/OpenGl_Structure.cxx | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/OpenGl/OpenGl_Structure.cxx b/src/OpenGl/OpenGl_Structure.cxx index 7f62d3107d..ae64d63214 100644 --- a/src/OpenGl/OpenGl_Structure.cxx +++ b/src/OpenGl/OpenGl_Structure.cxx @@ -397,11 +397,23 @@ void OpenGl_Structure::renderGeometry (const Handle(OpenGl_Workspace)& theWorksp const Handle(OpenGl_Context)& aCtx = theWorkspace->GetGlContext(); for (OpenGl_Structure::GroupIterator aGroupIter (myGroups); aGroupIter.More(); aGroupIter.Next()) { - Handle(Graphic3d_TransformPers) aTrsfPersistence = aGroupIter.Value()->TransformPersistence(); + const Handle(Graphic3d_TransformPers)& aTrsfPersistence = aGroupIter.Value()->TransformPersistence(); Standard_Boolean anOldCastShadows; + gp_Pnt aStartPnt; + if (!aTrsfPersistence.IsNull()) { + if (aTrsfPersistence->IsZoomOrRotate()) + { + aCtx->ModelWorldState.Push(); + OpenGl_Mat4& aModelWorld = aCtx->ModelWorldState.ChangeCurrent(); + aStartPnt = aTrsfPersistence->AnchorPoint(); + Graphic3d_Vec4 anAnchorPoint = aModelWorld * Graphic3d_Vec4 (aStartPnt.X(), aStartPnt.Y(), aStartPnt.Z(), 1.0); + aModelWorld.InitIdentity(); + aTrsfPersistence->SetAnchorPoint (gp_Pnt (anAnchorPoint.x(), anAnchorPoint.y(), anAnchorPoint.z())); + } applyPersistence (aCtx, aTrsfPersistence, anOldCastShadows, Standard_True); + aCtx->ApplyModelViewMatrix(); } theHasClosed = theHasClosed || aGroupIter.Value()->IsClosed(); @@ -409,7 +421,13 @@ void OpenGl_Structure::renderGeometry (const Handle(OpenGl_Workspace)& theWorksp if (!aTrsfPersistence.IsNull()) { + if (aTrsfPersistence->IsZoomOrRotate()) + { + aTrsfPersistence->SetAnchorPoint (aStartPnt); + aCtx->ModelWorldState.Pop(); + } applyPersistence (aCtx, aTrsfPersistence, anOldCastShadows, Standard_False); + aCtx->ApplyModelViewMatrix(); } } } @@ -696,6 +714,7 @@ void OpenGl_Structure::applyPersistence (const Handle(OpenGl_Context)& theContex { theContext->WorldViewState.Pop(); theContext->ShaderManager()->SetCastShadows (theOldCastShadows); + theContext->ApplyModelViewMatrix(); } } -- 2.39.5