diff options
| author | Dave Parks <davep@lindenlab.com> | 2022-11-11 13:48:51 -0600 | 
|---|---|---|
| committer | Dave Parks <davep@lindenlab.com> | 2022-11-11 13:48:51 -0600 | 
| commit | 70f249fbfbcae080aff3db72bf62e0643b342236 (patch) | |
| tree | 38a4762e4b8445eb19e03a84826efc5ceedabeb5 | |
| parent | 72884b29e5f84fb13879e826e8b1a3de9ce8fbbc (diff) | |
SL-18630 Fix for probes often ending up under the terrain.
| -rw-r--r-- | indra/newview/llreflectionmap.cpp | 138 | 
1 files changed, 52 insertions, 86 deletions
diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index ef611966ed..f346531bfd 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -63,20 +63,7 @@ void LLReflectionMap::autoAdjustOrigin()          const LLVector4a* bounds = mGroup->getBounds();          auto* node = mGroup->getOctreeNode(); -        if (mGroup->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_TERRAIN) -        { -            // for terrain, make probes float a couple meters above the highest point in the surface patch -            mOrigin = bounds[0]; -            mOrigin.getF32ptr()[2] += bounds[1].getF32ptr()[2] + 3.f; - -            // update radius to encompass bounding box -            LLVector4a d; -            d.setAdd(bounds[0], bounds[1]); -            d.sub(mOrigin); -            mRadius = d.getLength3().getF32(); -            mPriority = 1; -        } -        else if (mGroup->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_VOLUME) +        if (mGroup->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_VOLUME)          {              mPriority = 1;              // cast a ray towards 8 corners of bounding box @@ -87,92 +74,71 @@ void LLReflectionMap::autoAdjustOrigin()                  return;              } -            if (node->isLeaf() || node->getChildCount() > 1 || node->getElementCount() > 0) -            { // use center of object bounding box for leaf nodes or nodes with multiple child nodes -                mOrigin = bounds[0]; - -                LLVector4a start; -                LLVector4a end; - -                LLVector4a size = bounds[1]; +            mOrigin = bounds[0]; -                LLVector4a corners[] = -                { -                    { 1, 1, 1 }, -                    { -1, 1, 1 }, -                    { 1, -1, 1 }, -                    { -1, -1, 1 }, -                    { 1, 1, -1 }, -                    { -1, 1, -1 }, -                    { 1, -1, -1 }, -                    { -1, -1, -1 } -                }; - -                for (int i = 0; i < 8; ++i) -                { -                    corners[i].mul(size); -                    corners[i].add(bounds[0]); -                } +            LLVector4a size = bounds[1]; -                LLVector4a extents[2]; -                extents[0].setAdd(bounds[0], bounds[1]); -                extents[1].setSub(bounds[0], bounds[1]); +            LLVector4a corners[] = +            { +                { 1, 1, 1 }, +                { -1, 1, 1 }, +                { 1, -1, 1 }, +                { -1, -1, 1 }, +                { 1, 1, -1 }, +                { -1, 1, -1 }, +                { 1, -1, -1 }, +                { -1, -1, -1 } +            }; + +            for (int i = 0; i < 8; ++i) +            { +                corners[i].mul(size); +                corners[i].add(bounds[0]); +            } -                bool hit = false; -                for (int i = 0; i < 8; ++i) -                { -                    int face = -1; -                    LLVector4a intersection; -                    LLDrawable* drawable = mGroup->lineSegmentIntersect(bounds[0], corners[i], true, false, true, &face, &intersection); -                    if (drawable != nullptr) -                    { -                        hit = true; -                        update_min_max(extents[0], extents[1], intersection); -                    } -                    else -                    { -                        update_min_max(extents[0], extents[1], corners[i]); -                    } -                } +            LLVector4a extents[2]; +            extents[0].setAdd(bounds[0], bounds[1]); +            extents[1].setSub(bounds[0], bounds[1]); -                if (hit) +            bool hit = false; +            for (int i = 0; i < 8; ++i) +            { +                int face = -1; +                LLVector4a intersection; +                LLDrawable* drawable = mGroup->lineSegmentIntersect(bounds[0], corners[i], true, false, true, &face, &intersection); +                if (drawable != nullptr)                  { -                    mOrigin.setAdd(extents[0], extents[1]); -                    mOrigin.mul(0.5f); +                    hit = true; +                    update_min_max(extents[0], extents[1], intersection);                  } - -                // make sure radius encompasses all objects -                LLSimdScalar r2 = 0.0; -                for (int i = 0; i < 8; ++i) +                else                  { -                    LLVector4a v; -                    v.setSub(corners[i], mOrigin); - -                    LLSimdScalar d = v.dot3(v); - -                    if (d > r2) -                    { -                        r2 = d; -                    } +                    update_min_max(extents[0], extents[1], corners[i]);                  } - -                mRadius = llmax(sqrtf(r2.getF32()), 8.f);              } -            else -            { -                // user placed probe -                mPriority = 2; -                // use center of octree node volume for nodes that are just branches without data -                mOrigin = node->getCenter(); +            if (hit) +            { +                mOrigin.setAdd(extents[0], extents[1]); +                mOrigin.mul(0.5f); +            } -                // update radius to encompass entire octree node volume -                mRadius = node->getSize().getLength3().getF32(); +            // make sure radius encompasses all objects +            LLSimdScalar r2 = 0.0; +            for (int i = 0; i < 8; ++i) +            { +                LLVector4a v; +                v.setSub(corners[i], mOrigin); -                //mOrigin = bounds[0]; -                //mRadius = bounds[1].getLength3().getF32(); +                LLSimdScalar d = v.dot3(v); +                if (d > r2) +                { +                    r2 = d; +                }              } + +            mRadius = llmax(sqrtf(r2.getF32()), 8.f);          }      }      else if (mViewerObject)  | 
