Do fast culling inside precise culling
This commit is contained in:
parent
39b8f79f9f
commit
891330a8f3
@ -173,30 +173,24 @@ bool isCulledPrecise(const scene::ICameraSceneNode *cam, const scene::ISceneNode
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
const core::matrix4 &trans = node->getAbsoluteTransformation();
|
const core::matrix4 &trans = node->getAbsoluteTransformation();
|
||||||
|
const scene::SViewFrustum &frust = *cam->getViewFrustum();
|
||||||
|
|
||||||
|
core::aabbox3d<f32> tbox = node->getBoundingBox();
|
||||||
|
trans.transformBoxEx(tbox);
|
||||||
|
if (!(tbox.intersectsWithBox(frust.getBoundingBox())))
|
||||||
|
return true;
|
||||||
|
|
||||||
core::vector3df edges[8];
|
core::vector3df edges[8];
|
||||||
node->getBoundingBox().getEdges(edges);
|
node->getBoundingBox().getEdges(edges);
|
||||||
for (unsigned i = 0; i < 8; i++)
|
for (unsigned i = 0; i < 8; i++)
|
||||||
trans.transformVect(edges[i]);
|
trans.transformVect(edges[i]);
|
||||||
|
|
||||||
scene::SViewFrustum frust = *cam->getViewFrustum();
|
|
||||||
for (s32 i = 0; i < scene::SViewFrustum::VF_PLANE_COUNT; ++i)
|
for (s32 i = 0; i < scene::SViewFrustum::VF_PLANE_COUNT; ++i)
|
||||||
if (isBoxInFrontOfPlane(frust.planes[i], edges))
|
if (isBoxInFrontOfPlane(frust.planes[i], edges))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
|
||||||
bool isCulledFast(const scene::ICameraSceneNode *cam, const scene::ISceneNode *node)
|
|
||||||
{
|
|
||||||
if (!node->getAutomaticCulling())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
core::aabbox3d<f32> tbox = node->getBoundingBox();
|
|
||||||
node->getAbsoluteTransformation().transformBoxEx(tbox);
|
|
||||||
return !(tbox.intersectsWithBox(cam->getViewFrustum()->getBoundingBox()));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
handleSTKCommon(scene::ISceneNode *Node, std::vector<scene::ISceneNode *> *ImmediateDraw,
|
handleSTKCommon(scene::ISceneNode *Node, std::vector<scene::ISceneNode *> *ImmediateDraw,
|
||||||
const scene::ICameraSceneNode *cam, scene::ICameraSceneNode *shadowcam[4], const scene::ICameraSceneNode *rsmcam)
|
const scene::ICameraSceneNode *cam, scene::ICameraSceneNode *shadowcam[4], const scene::ICameraSceneNode *rsmcam)
|
||||||
@ -283,7 +277,7 @@ handleSTKCommon(scene::ISceneNode *Node, std::vector<scene::ISceneNode *> *Immed
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (isCulledFast(cam, Node))
|
if (isCulledPrecise(cam, Node))
|
||||||
continue;
|
continue;
|
||||||
core::matrix4 ModelMatrix = Node->getAbsoluteTransformation(), InvModelMatrix;
|
core::matrix4 ModelMatrix = Node->getAbsoluteTransformation(), InvModelMatrix;
|
||||||
ModelMatrix.getInverse(InvModelMatrix);
|
ModelMatrix.getInverse(InvModelMatrix);
|
||||||
@ -328,7 +322,7 @@ handleSTKCommon(scene::ISceneNode *Node, std::vector<scene::ISceneNode *> *Immed
|
|||||||
{
|
{
|
||||||
if (!irr_driver->hasARB_draw_indirect())
|
if (!irr_driver->hasARB_draw_indirect())
|
||||||
{
|
{
|
||||||
if (isCulledFast(shadowcam[cascade], Node))
|
if (isCulledPrecise(shadowcam[cascade], Node))
|
||||||
continue;
|
continue;
|
||||||
core::matrix4 ModelMatrix = Node->getAbsoluteTransformation(), InvModelMatrix;
|
core::matrix4 ModelMatrix = Node->getAbsoluteTransformation(), InvModelMatrix;
|
||||||
ModelMatrix.getInverse(InvModelMatrix);
|
ModelMatrix.getInverse(InvModelMatrix);
|
||||||
@ -381,7 +375,7 @@ handleSTKCommon(scene::ISceneNode *Node, std::vector<scene::ISceneNode *> *Immed
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (isCulledFast(rsmcam, Node))
|
if (isCulledPrecise(rsmcam, Node))
|
||||||
continue;
|
continue;
|
||||||
core::matrix4 ModelMatrix = Node->getAbsoluteTransformation(), InvModelMatrix;
|
core::matrix4 ModelMatrix = Node->getAbsoluteTransformation(), InvModelMatrix;
|
||||||
ModelMatrix.getInverse(InvModelMatrix);
|
ModelMatrix.getInverse(InvModelMatrix);
|
||||||
|
Loading…
Reference in New Issue
Block a user