1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0033551: Visualization - Add new transform persistence mode to force orthographic projection on object.

The new transform persistence mode, with flag `Graphic3d_TMF_OrthoPers`, can be combined (bitwise OR operation) with the other persistence modes (2D, Trihedron or Zoom/Rotate Persistence) to make objects be rendered with orthographic projection when it is on a view with perspective projection.

If the view already uses orthographic projection, there will be no difference.

This feature was implemented to fix ViewCube being distorted when view with perspective projection changes size.
This commit is contained in:
rodrlyra
2023-12-11 16:37:36 +00:00
committed by vglukhik
parent cb290cc932
commit f035e0718b
20 changed files with 432 additions and 102 deletions

View File

@@ -42,11 +42,22 @@ public:
//! needs to be updated only when camera's projection changes. Bounding volumes for this object subclass
//! is represented directly in eye space coordinates.
//! This subset uses linear BVH builder with 32 levels of depth and 1 element per leaf.
//! - BVHSubset_ortho3dPersistent refers to the subset of 3D persistent selectable objects (rotate, pan, zoom persistence)
//! that contains `Graphic3d_TMF_OrthoPers` persistence mode.
//! Associated BVH tree needs to be updated when either the camera's projection and position change.
//! This subset uses linear BVH builder with 32 levels of depth and 1 element per leaf.
//! - BVHSubset_ortho2dPersistent refers to the subset of 2D persistent selectable objects
//! that contains `Graphic3d_TMF_OrthoPers` persistence mode. Associated BVH tree
//! needs to be updated only when camera's projection changes. Bounding volumes for this object subclass
//! is represented directly in eye space coordinates.
//! This subset uses linear BVH builder with 32 levels of depth and 1 element per leaf.
enum BVHSubset
{
BVHSubset_3d,
BVHSubset_3dPersistent,
BVHSubset_2dPersistent,
BVHSubset_ortho3dPersistent,
BVHSubset_ortho2dPersistent,
BVHSubsetNb
};
@@ -140,7 +151,9 @@ public:
{
return myObjects[BVHSubset_3d].Contains (theObject)
|| myObjects[BVHSubset_3dPersistent].Contains (theObject)
|| myObjects[BVHSubset_2dPersistent].Contains (theObject);
|| myObjects[BVHSubset_2dPersistent].Contains (theObject)
|| myObjects[BVHSubset_ortho3dPersistent].Contains (theObject)
|| myObjects[BVHSubset_ortho2dPersistent].Contains (theObject);
}
//! Returns true if the object set does not contain any selectable objects.
@@ -148,7 +161,9 @@ public:
{
return myObjects[BVHSubset_3d].IsEmpty()
&& myObjects[BVHSubset_3dPersistent].IsEmpty()
&& myObjects[BVHSubset_2dPersistent].IsEmpty();
&& myObjects[BVHSubset_2dPersistent].IsEmpty()
&& myObjects[BVHSubset_ortho3dPersistent].IsEmpty()
&& myObjects[BVHSubset_ortho2dPersistent].IsEmpty();
}
//! Returns true if the specified object subset is empty.
@@ -192,10 +207,18 @@ private:
}
return SelectMgr_SelectableObjectSet::BVHSubset_3d;
}
else if (theObject->TransformPersistence()->Mode() == Graphic3d_TMF_2d)
else if ((theObject->TransformPersistence()->Mode() & Graphic3d_TMF_2d) != 0)
{
if (theObject->TransformPersistence()->IsOrthoPers())
{
return SelectMgr_SelectableObjectSet::BVHSubset_ortho2dPersistent;
}
return SelectMgr_SelectableObjectSet::BVHSubset_2dPersistent;
}
else if (theObject->TransformPersistence()->IsOrthoPers())
{
return SelectMgr_SelectableObjectSet::BVHSubset_ortho3dPersistent;
}
else
{
return SelectMgr_SelectableObjectSet::BVHSubset_3dPersistent;