1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0031511: Point Cloud Rendering, Volume Rendering - reuse Graphic3d_CullingTool

Graphic3d_CullingTool::IsCulled() has been extended with theIsInside argument for full inclusion test.
Graphic3d_Layer::UpdateCulling() now avoids frustum culling tests for BVH children for parent nodes completely included into frustum.
Graphic3d_CullingTool::SetViewVolume() has been extended by optional model-world matrix.
This commit is contained in:
kgv
2020-04-19 21:42:42 +03:00
committed by bugmaster
parent 89fcfe1551
commit 9ad4ff93a0
5 changed files with 166 additions and 81 deletions

View File

@@ -34,12 +34,17 @@ Graphic3d_CullingTool::Graphic3d_CullingTool()
// =======================================================================
// function : SetViewVolume
// purpose : Retrieves view volume's planes equations and its vertices from projection and world-view matrices.
// purpose :
// =======================================================================
void Graphic3d_CullingTool::SetViewVolume (const Handle(Graphic3d_Camera)& theCamera)
void Graphic3d_CullingTool::SetViewVolume (const Handle(Graphic3d_Camera)& theCamera,
const Graphic3d_Mat4d& theModelWorld)
{
if (!myWorldViewProjState.IsChanged (theCamera->WorldViewProjState()))
const bool hasModelTrsf = !theModelWorld.IsIdentity();
if (!myWorldViewProjState.IsChanged (theCamera->WorldViewProjState())
&& !hasModelTrsf)
{
return;
}
myIsProjectionParallel = theCamera->IsOrthographic();
const gp_Dir aCamDir = theCamera->Direction();
@@ -50,12 +55,19 @@ void Graphic3d_CullingTool::SetViewVolume (const Handle(Graphic3d_Camera)& theCa
myWorldViewProjState = theCamera->WorldViewProjState();
myCamEye.SetValues (theCamera->Eye().X(), theCamera->Eye().Y(), theCamera->Eye().Z());
myCamDir.SetValues (aCamDir.X(), aCamDir.Y(), aCamDir.Z());
if (hasModelTrsf)
{
Graphic3d_Mat4d aModelInv;
theModelWorld.Inverted (aModelInv);
myCamEye = (aModelInv * Graphic3d_Vec4d (myCamEye, 1.0)).xyz();
myCamDir = (aModelInv * Graphic3d_Vec4d (myCamDir, 0.0)).xyz();
}
myCamScale = theCamera->IsOrthographic()
? theCamera->Scale()
: 2.0 * Tan (theCamera->FOVy() * M_PI / 360.0); // same as theCamera->Scale()/theCamera->Distance()
// Compute frustum points
theCamera->FrustumPoints (myClipVerts);
theCamera->FrustumPoints (myClipVerts, theModelWorld);
// Compute frustum planes
// Vertices go in order:
@@ -84,7 +96,7 @@ void Graphic3d_CullingTool::SetViewVolume (const Handle(Graphic3d_Camera)& theCa
myClipPlanes[aFaceIdx * 2 + i].Normal =
Graphic3d_Vec3d::Cross (aPlanePnts[1] - aPlanePnts[0],
aPlanePnts[2] - aPlanePnts[0]).Normalized() * (i == 0 ? -1.f : 1.f);
}
}
}
}