1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-26 15:39:51 +00:00

Use correct planes for the new matrix

This commit is contained in:
AnyOldName3 2023-05-24 00:02:13 +01:00
parent 61712168c6
commit c41befadfb

View File

@ -87,19 +87,10 @@ namespace MWRender
if (dNear < computedZNear || dFar > computedZFar) if (dNear < computedZNear || dFar > computedZFar)
{ {
osg::Polytope& frustum = cullVisitor.getCurrentCullingSet().getFrustum(); osg::Polytope frustum;
osg::Polytope::ClippingMask resultMask = frustum.getResultMask(); osg::Polytope::ClippingMask resultMask = cullVisitor.getCurrentCullingSet().getFrustum().getResultMask();
if (resultMask) 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) if (dNear < computedZNear)
{ {
dNear = computedZNear; dNear = computedZNear;
@ -121,6 +112,16 @@ namespace MWRender
if (instanceDFar < 0 || instanceDNear > dNear) if (instanceDFar < 0 || instanceDNear > dNear)
continue; 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 value_type newNear
= cullVisitor.computeNearestPointInFrustum(fullMatrix, planes, *drawable); = cullVisitor.computeNearestPointInFrustum(fullMatrix, planes, *drawable);
dNear = std::min(dNear, newNear); dNear = std::min(dNear, newNear);
@ -150,6 +151,16 @@ namespace MWRender
if (instanceDFar < 0 || instanceDFar < dFar) if (instanceDFar < 0 || instanceDFar < dFar)
continue; 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( value_type newFar = cullVisitor.computeFurthestPointInFrustum(
instanceMatrix * matrix, planes, *drawable); instanceMatrix * matrix, planes, *drawable);
dFar = std::max(dFar, newFar); dFar = std::max(dFar, newFar);