]> OCCT Git - occt-copy.git/commitdiff
0027919: Visualization - support multiple transformation persistence groups within...
authormzernova <mzernova@opencascade.com>
Wed, 10 Jun 2020 09:18:47 +0000 (12:18 +0300)
committerNatalia Ermolaeva <natalia.ermolaeva@opencascade.com>
Tue, 22 Jun 2021 15:21:01 +0000 (18:21 +0300)
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

index 7f62d3107d587b5c5a7465b641551d01bbbc37df..ae64d632149fb869a58acdc466bcd9878f23f8b6 100644 (file)
@@ -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();
   }
 }