mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-05-21 10:55:33 +03:00
0025063: Visualization - 2D objects are not displayed at some camera positions
Minimum thresolds introduced to zfit operation and to camera SetDistance() method. Test case for issue CR25063
This commit is contained in:
parent
0272e74033
commit
3c64852756
@ -36,6 +36,9 @@ namespace
|
|||||||
|
|
||||||
// atomic state counter
|
// atomic state counter
|
||||||
static volatile Standard_Integer THE_STATE_COUNTER = 0;
|
static volatile Standard_Integer THE_STATE_COUNTER = 0;
|
||||||
|
|
||||||
|
// minimum camera distance
|
||||||
|
static const Standard_Real MIN_DISTANCE = Pow (0.1, ShortRealDigits() - 2);
|
||||||
};
|
};
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
@ -165,7 +168,9 @@ void Graphic3d_Camera::SetDistance (const Standard_Real theDistance)
|
|||||||
{
|
{
|
||||||
gp_Vec aCenter2Eye (Direction());
|
gp_Vec aCenter2Eye (Direction());
|
||||||
aCenter2Eye.Reverse();
|
aCenter2Eye.Reverse();
|
||||||
aCenter2Eye.Scale (theDistance);
|
|
||||||
|
// Camera should have non-zero distance.
|
||||||
|
aCenter2Eye.Scale (Max (theDistance, MIN_DISTANCE));
|
||||||
SetEye (Center().Translated (aCenter2Eye));
|
SetEye (Center().Translated (aCenter2Eye));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,6 +163,10 @@ Standard_ShortReal OpenGl_BVHTreeSelector::SignedPlanePointDistance (const OpenG
|
|||||||
const Standard_ShortReal aNormLength = std::sqrt (theNormal.x() * theNormal.x()
|
const Standard_ShortReal aNormLength = std::sqrt (theNormal.x() * theNormal.x()
|
||||||
+ theNormal.y() * theNormal.y()
|
+ theNormal.y() * theNormal.y()
|
||||||
+ theNormal.z() * theNormal.z());
|
+ theNormal.z() * theNormal.z());
|
||||||
|
|
||||||
|
if (aNormLength < FLT_EPSILON)
|
||||||
|
return 0.0f;
|
||||||
|
|
||||||
const Standard_ShortReal anInvNormLength = 1.0f / aNormLength;
|
const Standard_ShortReal anInvNormLength = 1.0f / aNormLength;
|
||||||
const Standard_ShortReal aD = theNormal.w() * anInvNormLength;
|
const Standard_ShortReal aD = theNormal.w() * anInvNormLength;
|
||||||
const Standard_ShortReal anA = theNormal.x() * anInvNormLength;
|
const Standard_ShortReal anA = theNormal.x() * anInvNormLength;
|
||||||
|
@ -1665,13 +1665,13 @@ void V3d_View::ZFitAll (const Standard_Real theScaleFactor)
|
|||||||
// ShortReal precision factor used to add meaningful tolerance to
|
// ShortReal precision factor used to add meaningful tolerance to
|
||||||
// ZNear, ZFar values in order to avoid equality after type conversion
|
// ZNear, ZFar values in order to avoid equality after type conversion
|
||||||
// to ShortReal matrices type.
|
// to ShortReal matrices type.
|
||||||
const Standard_Real aPrecision = 1.0 / Pow (10.0, ShortRealDigits() - 1);
|
const Standard_Real aPrecision = Pow (0.1, ShortRealDigits() - 2);
|
||||||
|
|
||||||
// Compute enlarged or shrank near and far z ranges
|
// Compute enlarged or shrank near and far z ranges
|
||||||
Standard_Real aZNear = aMidDepth - aHalfDepth * theScaleFactor;
|
Standard_Real aZNear = aMidDepth - aHalfDepth * theScaleFactor;
|
||||||
Standard_Real aZFar = aMidDepth + aHalfDepth * theScaleFactor;
|
Standard_Real aZFar = aMidDepth + aHalfDepth * theScaleFactor;
|
||||||
aZNear -= Abs (aZNear) * aPrecision;
|
aZNear -= aPrecision * 0.5;
|
||||||
aZFar += Abs (aZFar) * aPrecision;
|
aZFar += aPrecision * 0.5;
|
||||||
|
|
||||||
if (!myCamera->IsOrthographic())
|
if (!myCamera->IsOrthographic())
|
||||||
{
|
{
|
||||||
@ -3329,7 +3329,7 @@ Standard_Boolean V3d_View::FitMinMax (const Handle(Graphic3d_Camera)& theCamera,
|
|||||||
gp_Trsf aCenterTrsf;
|
gp_Trsf aCenterTrsf;
|
||||||
aCenterTrsf.SetTranslation (theCamera->Center(), aNewCenter);
|
aCenterTrsf.SetTranslation (theCamera->Center(), aNewCenter);
|
||||||
theCamera->Transform (aCenterTrsf);
|
theCamera->Transform (aCenterTrsf);
|
||||||
theCamera->SetDistance (Max (aMatchDistance[5] + aMatchDistance[4], Precision::Confusion()));
|
theCamera->SetDistance (aMatchDistance[5] + aMatchDistance[4]);
|
||||||
|
|
||||||
// Bounding box collapses to a point or thin line going in depth of the screen
|
// Bounding box collapses to a point or thin line going in depth of the screen
|
||||||
if (aViewSizeXv < theResolution && aViewSizeYv < theResolution)
|
if (aViewSizeXv < theResolution && aViewSizeYv < theResolution)
|
||||||
|
14
tests/bugs/vis/bug25063
Normal file
14
tests/bugs/vis/bug25063
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
puts "==========="
|
||||||
|
puts "OCC25063"
|
||||||
|
puts "==========="
|
||||||
|
puts ""
|
||||||
|
##########################################################################
|
||||||
|
# Visualization - 2D objects are not displayed at some camera positions
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
|
vinit
|
||||||
|
vtop
|
||||||
|
vline 1 -90 -90 130 90 90 130
|
||||||
|
vfit
|
||||||
|
|
||||||
|
set only_screen 1
|
Loading…
x
Reference in New Issue
Block a user