0031650: Visualization - invalid picking of object with local transformation and...
authorkgv <kgv@opencascade.com>
Sat, 4 Jul 2020 11:37:05 +0000 (14:37 +0300)
committerbugmaster <bugmaster@opencascade.com>
Mon, 6 Jul 2020 15:31:14 +0000 (18:31 +0300)
SelectMgr_SelectingVolumeManager::SetViewClipping() now updates clipping range
using picking ray in world coordinates, as clipping planes are always defined in world space.

src/SelectMgr/SelectMgr_SelectingVolumeManager.cxx
src/SelectMgr/SelectMgr_SelectingVolumeManager.hxx
src/SelectMgr/SelectMgr_ViewerSelector.cxx
src/SelectMgr/SelectMgr_ViewerSelector3d.cxx
tests/bugs/vis/bug31650 [new file with mode: 0644]

index 89230c7..b72f45c 100644 (file)
@@ -453,14 +453,16 @@ gp_Pnt SelectMgr_SelectingVolumeManager::GetFarPickedPnt() const
 // purpose  :
 //=======================================================================
 void SelectMgr_SelectingVolumeManager::SetViewClipping (const Handle(Graphic3d_SequenceOfHClipPlane)& theViewPlanes,
-                                                        const Handle(Graphic3d_SequenceOfHClipPlane)& theObjPlanes)
+                                                        const Handle(Graphic3d_SequenceOfHClipPlane)& theObjPlanes,
+                                                        const SelectMgr_SelectingVolumeManager* theWorldSelMgr)
 {
   myViewClipPlanes   = theViewPlanes;
   myObjectClipPlanes = theObjPlanes;
   if (myActiveSelectionType != Point)
     return;
 
-  const SelectMgr_RectangularFrustum* aFrustum = reinterpret_cast<const SelectMgr_RectangularFrustum*>(mySelectingVolumes[Frustum].get());
+  const SelectMgr_SelectingVolumeManager* aWorldSelMgr = theWorldSelMgr != NULL ? theWorldSelMgr : this;
+  const SelectMgr_RectangularFrustum* aFrustum = reinterpret_cast<const SelectMgr_RectangularFrustum*>(aWorldSelMgr->mySelectingVolumes[Frustum].get());
   myViewClipRange.SetVoid();
   if (!theViewPlanes.IsNull()
    && !theViewPlanes->IsEmpty())
index 6b3fe78..12b4927 100644 (file)
@@ -172,10 +172,12 @@ public:
 
   //! Valid for point selection only!
   //! Computes depth range for clipping planes.
-  //! @param theViewPlanes global view planes
-  //! @param theObjPlanes  object planes
+  //! @param theViewPlanes  [in] global view planes
+  //! @param theObjPlanes   [in] object planes
+  //! @param theWorldSelMgr [in] selection volume in world space for computing clipping plane ranges
   Standard_EXPORT void SetViewClipping (const Handle(Graphic3d_SequenceOfHClipPlane)& theViewPlanes,
-                                        const Handle(Graphic3d_SequenceOfHClipPlane)& theObjPlanes);
+                                        const Handle(Graphic3d_SequenceOfHClipPlane)& theObjPlanes,
+                                        const SelectMgr_SelectingVolumeManager* theWorldSelMgr);
 
   //! Copy clipping planes from another volume manager.
   Standard_EXPORT void SetViewClipping (const SelectMgr_SelectingVolumeManager& theOther);
index 9ada79f..94b4769 100644 (file)
@@ -386,7 +386,7 @@ void SelectMgr_ViewerSelector::traverseObject (const Handle(SelectMgr_Selectable
   if (!theObject->ClipPlanes().IsNull()
     && theObject->ClipPlanes()->ToOverrideGlobal())
   {
-    aMgr.SetViewClipping (Handle(Graphic3d_SequenceOfHClipPlane)(), theObject->ClipPlanes());
+    aMgr.SetViewClipping (Handle(Graphic3d_SequenceOfHClipPlane)(), theObject->ClipPlanes(), &theMgr);
   }
   else if (!theObject->TransformPersistence().IsNull())
   {
@@ -414,12 +414,12 @@ void SelectMgr_ViewerSelector::traverseObject (const Handle(SelectMgr_Selectable
       }
     }
 
-    aMgr.SetViewClipping (Handle(Graphic3d_SequenceOfHClipPlane)(), theObject->ClipPlanes());
+    aMgr.SetViewClipping (Handle(Graphic3d_SequenceOfHClipPlane)(), theObject->ClipPlanes(), &theMgr);
   }
   else if (!theObject->ClipPlanes().IsNull()
         && !theObject->ClipPlanes()->IsEmpty())
   {
-    aMgr.SetViewClipping (theMgr.ViewClipping(), theObject->ClipPlanes());
+    aMgr.SetViewClipping (theMgr.ViewClipping(), theObject->ClipPlanes(), &theMgr);
   }
 
   if (!theMgr.ViewClipping().IsNull() &&
index 7c3f95c..f1600dc 100644 (file)
@@ -63,7 +63,7 @@ void SelectMgr_ViewerSelector3d::Pick (const Standard_Integer theXPix,
   gp_Pnt2d aMousePos (static_cast<Standard_Real> (theXPix),
                       static_cast<Standard_Real> (theYPix));
   mySelectingVolumeMgr.BuildSelectingVolume (aMousePos);
-  mySelectingVolumeMgr.SetViewClipping (theView->ClipPlanes(), Handle(Graphic3d_SequenceOfHClipPlane)());
+  mySelectingVolumeMgr.SetViewClipping (theView->ClipPlanes(), Handle(Graphic3d_SequenceOfHClipPlane)(), NULL);
 
   TraverseSensitives();
 }
@@ -91,7 +91,7 @@ void SelectMgr_ViewerSelector3d::Pick (const Standard_Integer theXPMin,
   mySelectingVolumeMgr.BuildSelectingVolume (aMinMousePos,
                                              aMaxMousePos);
 
-  mySelectingVolumeMgr.SetViewClipping (theView->ClipPlanes(), Handle(Graphic3d_SequenceOfHClipPlane)());
+  mySelectingVolumeMgr.SetViewClipping (theView->ClipPlanes(), Handle(Graphic3d_SequenceOfHClipPlane)(), NULL);
 
   TraverseSensitives();
 }
@@ -111,7 +111,7 @@ void SelectMgr_ViewerSelector3d::Pick (const TColgp_Array1OfPnt2d& thePolyline,
   mySelectingVolumeMgr.SetWindowSize (aWidth, aHeight);
   mySelectingVolumeMgr.BuildSelectingVolume (thePolyline);
 
-  mySelectingVolumeMgr.SetViewClipping (theView->ClipPlanes(), Handle(Graphic3d_SequenceOfHClipPlane)());
+  mySelectingVolumeMgr.SetViewClipping (theView->ClipPlanes(), Handle(Graphic3d_SequenceOfHClipPlane)(), NULL);
 
   TraverseSensitives();
 }
diff --git a/tests/bugs/vis/bug31650 b/tests/bugs/vis/bug31650
new file mode 100644 (file)
index 0000000..e59f0f8
--- /dev/null
@@ -0,0 +1,26 @@
+puts "============"
+puts "0031650: Visualization - invalid picking of object with local transformation and per-object clipping plane"
+puts "============"
+puts ""
+
+pload XDE MODELING VISUALIZATION
+vclear
+vinit View1
+vaxo
+box b -28 -11 -35 20 20 42
+vdisplay -dispMode 1 -highMode 1 b
+vsetlocation b 0 0 20
+vfit
+catch {vclipplane -delete p}
+
+# global clipping
+vclipplane p -equation 0 0 -1 -10 -set
+vmoveto 205 205
+if { [vreadpixel 205 320 -name -rgb] != "DARKGOLDENROD" } { puts "Error" }
+
+# local clipping
+vclipplane p -equation 0 0 -1 -10 -set b
+vmoveto 205 205
+if { [vreadpixel 205 320 -name -rgb] != "DARKGOLDENROD" } { puts "Error" }
+
+vdump ${imagedir}/${casename}.png