mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-06 18:26:22 +03:00
0029602: Visualization, TKOpenGl - Size Culling is not properly handled within Perspective projection
OpenGl_BVHTreeSelector::isTooSmall() now takes into account distance the distance between camera Eye and object Center within perspective projection.
This commit is contained in:
parent
6ca66a7dea
commit
f29de68237
@ -25,7 +25,7 @@
|
|||||||
// =======================================================================
|
// =======================================================================
|
||||||
OpenGl_BVHTreeSelector::OpenGl_BVHTreeSelector()
|
OpenGl_BVHTreeSelector::OpenGl_BVHTreeSelector()
|
||||||
: myIsProjectionParallel (Standard_True),
|
: myIsProjectionParallel (Standard_True),
|
||||||
myCamScaleInv (1.0),
|
myCamScale (1.0),
|
||||||
myPixelSize (1.0)
|
myPixelSize (1.0)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@ -41,13 +41,17 @@ void OpenGl_BVHTreeSelector::SetViewVolume (const Handle(Graphic3d_Camera)& theC
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
myIsProjectionParallel = theCamera->IsOrthographic();
|
myIsProjectionParallel = theCamera->IsOrthographic();
|
||||||
|
const gp_Dir aCamDir = theCamera->Direction();
|
||||||
|
|
||||||
myCamera = theCamera;
|
myCamera = theCamera;
|
||||||
myProjectionMat = theCamera->ProjectionMatrix();
|
myProjectionMat = theCamera->ProjectionMatrix();
|
||||||
myWorldViewMat = theCamera->OrientationMatrix();
|
myWorldViewMat = theCamera->OrientationMatrix();
|
||||||
myWorldViewProjState = theCamera->WorldViewProjState();
|
myWorldViewProjState = theCamera->WorldViewProjState();
|
||||||
myCamEye.SetValues (theCamera->Eye().X(), theCamera->Eye().Y(), theCamera->Eye().Z());
|
myCamEye.SetValues (theCamera->Eye().X(), theCamera->Eye().Y(), theCamera->Eye().Z());
|
||||||
myCamScaleInv = 1.0 / myCamera->Scale();
|
myCamDir.SetValues (aCamDir.X(), aCamDir.Y(), aCamDir.Z());
|
||||||
|
myCamScale = theCamera->IsOrthographic()
|
||||||
|
? theCamera->Scale()
|
||||||
|
: 2.0 * Tan (theCamera->FOVy() * M_PI / 360.0); // same as theCamera->Scale()/theCamera->Distance()
|
||||||
|
|
||||||
Standard_Real nLeft = 0.0, nRight = 0.0, nTop = 0.0, nBottom = 0.0;
|
Standard_Real nLeft = 0.0, nRight = 0.0, nTop = 0.0, nBottom = 0.0;
|
||||||
Standard_Real fLeft = 0.0, fRight = 0.0, fTop = 0.0, fBottom = 0.0;
|
Standard_Real fLeft = 0.0, fRight = 0.0, fTop = 0.0, fBottom = 0.0;
|
||||||
@ -186,7 +190,8 @@ void OpenGl_BVHTreeSelector::SetCullingSize (CullingContext& theCtx,
|
|||||||
theCtx.SizeCull2 = -1.0;
|
theCtx.SizeCull2 = -1.0;
|
||||||
if (theSize > 0.0 && !Precision::IsInfinite (theSize))
|
if (theSize > 0.0 && !Precision::IsInfinite (theSize))
|
||||||
{
|
{
|
||||||
theCtx.SizeCull2 = (myPixelSize * theSize) / myCamScaleInv;
|
theCtx.SizeCull2 = myPixelSize * theSize;
|
||||||
|
theCtx.SizeCull2 *= myCamScale;
|
||||||
theCtx.SizeCull2 *= theCtx.SizeCull2;
|
theCtx.SizeCull2 *= theCtx.SizeCull2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,18 @@ protected:
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return (theMaxPt - theMinPt).SquareModulus() < theCtx.SizeCull2;
|
|
||||||
|
const Standard_Real aBoxDiag2 = (theMaxPt - theMinPt).SquareModulus();
|
||||||
|
if (myIsProjectionParallel)
|
||||||
|
{
|
||||||
|
return aBoxDiag2 < theCtx.SizeCull2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// note that distances behind the Eye (aBndDist < 0) are not scaled correctly here,
|
||||||
|
// but majority of such objects should be culled by frustum
|
||||||
|
const OpenGl_Vec3d aBndCenter = (theMinPt + theMaxPt) * 0.5;
|
||||||
|
const Standard_Real aBndDist = (aBndCenter - myCamEye).Dot (myCamDir);
|
||||||
|
return aBoxDiag2 < theCtx.SizeCull2 * aBndDist * aBndDist;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -255,7 +266,8 @@ protected:
|
|||||||
Graphic3d_WorldViewProjState myWorldViewProjState; //!< State of world view projection matrices.
|
Graphic3d_WorldViewProjState myWorldViewProjState; //!< State of world view projection matrices.
|
||||||
|
|
||||||
Graphic3d_Vec3d myCamEye; //!< camera eye position for distance culling
|
Graphic3d_Vec3d myCamEye; //!< camera eye position for distance culling
|
||||||
Standard_Real myCamScaleInv; //!< inverted camera scale for size culling
|
Graphic3d_Vec3d myCamDir; //!< camera direction for size culling
|
||||||
|
Standard_Real myCamScale; //!< camera scale for size culling
|
||||||
Standard_Real myPixelSize; //!< pixel size for size culling
|
Standard_Real myPixelSize; //!< pixel size for size culling
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -9,6 +9,7 @@ set THE_PICK_PNTS1O { { 10 165 } { 100 200 } { 170 250 } { 250 250 } { 350 300
|
|||||||
set THE_PICK_PNTS1P { { 40 170 } { 100 200 } { 170 250 } { 250 250 } { 380 350 } }
|
set THE_PICK_PNTS1P { { 40 170 } { 100 200 } { 170 250 } { 250 250 } { 380 350 } }
|
||||||
set THE_PICK_PNTS2O { { 148 192 } { 175 200 } { 190 200 } { 200 220 } { 250 230 } }
|
set THE_PICK_PNTS2O { { 148 192 } { 175 200 } { 190 200 } { 200 220 } { 250 230 } }
|
||||||
set THE_PICK_PNTS2P { { 152 192 } { 175 200 } { 190 200 } { 220 220 } { 250 230 } }
|
set THE_PICK_PNTS2P { { 152 192 } { 175 200 } { 190 200 } { 220 220 } { 250 230 } }
|
||||||
|
set THE_PICK_PNTS3P { { 90 155 } { 105 160 } { 125 170 } { 140 175 } { 160 180 } }
|
||||||
|
|
||||||
pload MODELING VISUALIZATION
|
pload MODELING VISUALIZATION
|
||||||
vclear
|
vclear
|
||||||
@ -49,3 +50,8 @@ vcamera -persp
|
|||||||
for { set x 2 } { $x < $THE_NB_BOXES } { incr x } { if { [vreadpixel {*}[lindex $THE_PICK_PNTS2P $x] rgb name] == "BLACK" } { puts "Error: object $x is culled" } }
|
for { set x 2 } { $x < $THE_NB_BOXES } { incr x } { if { [vreadpixel {*}[lindex $THE_PICK_PNTS2P $x] rgb name] == "BLACK" } { puts "Error: object $x is culled" } }
|
||||||
for { set x 0 } { $x < 2 } { incr x } { if { [vreadpixel {*}[lindex $THE_PICK_PNTS2P $x] rgb name] != "BLACK" } { puts "Error: object $x is NOT culled" } }
|
for { set x 0 } { $x < 2 } { incr x } { if { [vreadpixel {*}[lindex $THE_PICK_PNTS2P $x] rgb name] != "BLACK" } { puts "Error: object $x is NOT culled" } }
|
||||||
vdump $::imagedir/${::casename}_30p.png
|
vdump $::imagedir/${::casename}_30p.png
|
||||||
|
|
||||||
|
vviewparams -eye 16.8333 -9.08333 10.0833 -at 7.5 0.25 0.75
|
||||||
|
for { set x 3 } { $x < $THE_NB_BOXES } { incr x } { if { [vreadpixel {*}[lindex $THE_PICK_PNTS3P $x] rgb name] == "BLACK" } { puts "Error: object $x is culled" } }
|
||||||
|
for { set x 0 } { $x < 3 } { incr x } { if { [vreadpixel {*}[lindex $THE_PICK_PNTS3P $x] rgb name] != "BLACK" } { puts "Error: object $x is NOT culled" } }
|
||||||
|
vdump $::imagedir/${::casename}_30p2.png
|
||||||
|
Loading…
x
Reference in New Issue
Block a user