Use correct planes for the new matrix

revert-6246b479
AnyOldName3 2 years ago
parent 61712168c6
commit c41befadfb

@ -87,19 +87,10 @@ namespace MWRender
if (dNear < computedZNear || dFar > computedZFar)
{
osg::Polytope& frustum = cullVisitor.getCurrentCullingSet().getFrustum();
osg::Polytope::ClippingMask resultMask = frustum.getResultMask();
osg::Polytope frustum;
osg::Polytope::ClippingMask resultMask = cullVisitor.getCurrentCullingSet().getFrustum().getResultMask();
if (resultMask)
{
osg::Polytope::PlaneList planes;
osg::Polytope::ClippingMask selectorMask = 0x1;
for (const auto& plane : frustum.getPlaneList())
{
if (resultMask & selectorMask)
planes.push_back(plane);
selectorMask <<= 1;
}
if (dNear < computedZNear)
{
dNear = computedZNear;
@ -121,6 +112,16 @@ namespace MWRender
if (instanceDFar < 0 || instanceDNear > dNear)
continue;
frustum.setAndTransformProvidingInverse(cullVisitor.getProjectionCullingStack().back().getFrustum(), fullMatrix);
osg::Polytope::PlaneList planes;
osg::Polytope::ClippingMask selectorMask = 0x1;
for (const auto& plane : frustum.getPlaneList())
{
if (resultMask & selectorMask)
planes.push_back(plane);
selectorMask <<= 1;
}
value_type newNear
= cullVisitor.computeNearestPointInFrustum(fullMatrix, planes, *drawable);
dNear = std::min(dNear, newNear);
@ -150,6 +151,16 @@ namespace MWRender
if (instanceDFar < 0 || instanceDFar < dFar)
continue;
frustum.setAndTransformProvidingInverse(cullVisitor.getProjectionCullingStack().back().getFrustum(), fullMatrix);
osg::Polytope::PlaneList planes;
osg::Polytope::ClippingMask selectorMask = 0x1;
for (const auto& plane : frustum.getPlaneList())
{
if (resultMask & selectorMask)
planes.push_back(plane);
selectorMask <<= 1;
}
value_type newFar = cullVisitor.computeFurthestPointInFrustum(
instanceMatrix * matrix, planes, *drawable);
dFar = std::max(dFar, newFar);

Loading…
Cancel
Save