SL-18630 Fix for probes often ending up under the terrain.
parent
72884b29e5
commit
70f249fbfb
|
|
@ -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];
|
||||
mOrigin = bounds[0];
|
||||
|
||||
LLVector4a start;
|
||||
LLVector4a end;
|
||||
LLVector4a size = bounds[1];
|
||||
|
||||
LLVector4a size = 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]);
|
||||
}
|
||||
|
||||
LLVector4a extents[2];
|
||||
extents[0].setAdd(bounds[0], bounds[1]);
|
||||
extents[1].setSub(bounds[0], bounds[1]);
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
if (hit)
|
||||
{
|
||||
mOrigin.setAdd(extents[0], extents[1]);
|
||||
mOrigin.mul(0.5f);
|
||||
}
|
||||
|
||||
// make sure radius encompasses all objects
|
||||
LLSimdScalar r2 = 0.0;
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
LLVector4a v;
|
||||
v.setSub(corners[i], mOrigin);
|
||||
|
||||
LLSimdScalar d = v.dot3(v);
|
||||
|
||||
if (d > r2)
|
||||
{
|
||||
r2 = d;
|
||||
}
|
||||
}
|
||||
|
||||
mRadius = llmax(sqrtf(r2.getF32()), 8.f);
|
||||
}
|
||||
else
|
||||
LLVector4a corners[] =
|
||||
{
|
||||
// user placed probe
|
||||
mPriority = 2;
|
||||
|
||||
// use center of octree node volume for nodes that are just branches without data
|
||||
mOrigin = node->getCenter();
|
||||
|
||||
// update radius to encompass entire octree node volume
|
||||
mRadius = node->getSize().getLength3().getF32();
|
||||
|
||||
//mOrigin = bounds[0];
|
||||
//mRadius = bounds[1].getLength3().getF32();
|
||||
{ 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 extents[2];
|
||||
extents[0].setAdd(bounds[0], bounds[1]);
|
||||
extents[1].setSub(bounds[0], bounds[1]);
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
if (hit)
|
||||
{
|
||||
mOrigin.setAdd(extents[0], extents[1]);
|
||||
mOrigin.mul(0.5f);
|
||||
}
|
||||
|
||||
// make sure radius encompasses all objects
|
||||
LLSimdScalar r2 = 0.0;
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
LLVector4a v;
|
||||
v.setSub(corners[i], mOrigin);
|
||||
|
||||
LLSimdScalar d = v.dot3(v);
|
||||
|
||||
if (d > r2)
|
||||
{
|
||||
r2 = d;
|
||||
}
|
||||
}
|
||||
|
||||
mRadius = llmax(sqrtf(r2.getF32()), 8.f);
|
||||
}
|
||||
}
|
||||
else if (mViewerObject)
|
||||
|
|
|
|||
Loading…
Reference in New Issue