Fall in line with LL octree code.

This commit is contained in:
Shyotl
2020-03-31 19:07:55 -05:00
parent 4de8c3a38e
commit 347c2cbd8b
6 changed files with 50 additions and 19 deletions

View File

@@ -45,6 +45,7 @@
#endif #endif
extern U32 gOctreeMaxCapacity; extern U32 gOctreeMaxCapacity;
extern float gOctreeMinSize;
extern U32 gOctreeReserveCapacity; extern U32 gOctreeReserveCapacity;
#if LL_DEBUG #if LL_DEBUG
#define LL_OCTREE_PARANOIA_CHECK 0 #define LL_OCTREE_PARANOIA_CHECK 0
@@ -404,7 +405,7 @@ public:
F32 size = mSize[0]; F32 size = mSize[0];
F32 p_size = size * 2.f; F32 p_size = size * 2.f;
return (radius <= 0.001f && size <= 0.001f) || return (radius <= gOctreeMinSize && size <= gOctreeMinSize) ||
(radius <= p_size && radius > size); (radius <= p_size && radius > size);
} }
@@ -511,7 +512,7 @@ public:
//is it here? //is it here?
if (isInside(data->getPositionGroup())) if (isInside(data->getPositionGroup()))
{ {
if (((getElementCount() < gOctreeMaxCapacity && contains(data->getBinRadius())) || if ((((getElementCount() < gOctreeMaxCapacity || getSize()[0] <= gOctreeMinSize) && contains(data->getBinRadius())) ||
(data->getBinRadius() > getSize()[0] && parent && parent->getElementCount() >= gOctreeMaxCapacity))) (data->getBinRadius() > getSize()[0] && parent && parent->getElementCount() >= gOctreeMaxCapacity)))
{ //it belongs here { //it belongs here
/*mElementCount++; /*mElementCount++;
@@ -566,8 +567,9 @@ public:
LLVector4a val; LLVector4a val;
val.setSub(center, getCenter()); val.setSub(center, getCenter());
val.setAbs(val); val.setAbs(val);
LLVector4a min_diff(gOctreeMinSize);
S32 lt = val.lessThan(LLVector4a::getEpsilon()).getGatheredBits() & 0x7;
S32 lt = val.lessThan(min_diff).getGatheredBits() & 0x7;
if( lt == 0x7 ) if( lt == 0x7 )
{ {
@@ -616,6 +618,7 @@ public:
} }
#endif #endif
llassert(size[0] >= gOctreeMinSize*0.5f);
//make the new kid //make the new kid
child = new LLOctreeNode<T>(center, size, this); child = new LLOctreeNode<T>(center, size, this);
addChild(child); addChild(child);
@@ -623,10 +626,7 @@ public:
child->insert(data); child->insert(data);
} }
} }
// Singu note: now that we allow wider range in octree, discard them here else if (parent)
// if they fall out of range
#if 0
else
{ {
//it's not in here, give it to the root //it's not in here, give it to the root
OCT_ERRS << "Octree insertion failed, starting over from root!" << LL_ENDL; OCT_ERRS << "Octree insertion failed, starting over from root!" << LL_ENDL;
@@ -639,12 +639,15 @@ public:
parent = node->getOctParent(); parent = node->getOctParent();
} }
if(node != this) node->insert(data);
{ }
node->insert(data); else
} {
// It's not in here, and we are root.
// LLOctreeRoot::insert() should have expanded
// root by now, something is wrong
OCT_ERRS << "Octree insertion failed! Root expansion failed." << LL_ENDL;
} }
#endif
return false; return false;
} }
@@ -1050,10 +1053,15 @@ public:
{ {
LLOctreeNode<T>::insert(data); LLOctreeNode<T>::insert(data);
} }
else else if (node->isInside(data->getPositionGroup()))
{ {
node->insert(data); node->insert(data);
} }
else
{
// calling node->insert(data) will return us to root
OCT_ERRS << "Failed to insert data at child node" << LL_ENDL;
}
} }
else if (this->getChildCount() == 0) else if (this->getChildCount() == 0)
{ {
@@ -1088,6 +1096,8 @@ public:
this->setSize(size2); this->setSize(size2);
this->updateMinMax(); this->updateMinMax();
llassert(size[0] >= gOctreeMinSize);
//copy our children to a new branch //copy our children to a new branch
LLOctreeNode<T>* newnode = new LLOctreeNode<T>(center, size, this); LLOctreeNode<T>* newnode = new LLOctreeNode<T>(center, size, this);

View File

@@ -12628,6 +12628,18 @@ This should be as low as possible, but too low may break functionality</string>
<integer>128</integer> <integer>128</integer>
</map> </map>
<key>OctreeMinimumNodeSize</key>
<map>
<key>Comment</key>
<string>Minimum size of any octree node</string>
<key>Persist</key>
<integer>1</integer>
<key>Type</key>
<string>F32</string>
<key>Value</key>
<real>0.01</real>
</map>
<key>OctreeReserveNodeCapacity</key> <key>OctreeReserveNodeCapacity</key>
<map> <map>
<key>Comment</key> <key>Comment</key>

View File

@@ -70,6 +70,7 @@ static U32 sZombieGroups = 0;
U32 LLSpatialGroup::sNodeCount = 0; U32 LLSpatialGroup::sNodeCount = 0;
U32 gOctreeMaxCapacity; U32 gOctreeMaxCapacity;
float gOctreeMinSize;
U32 gOctreeReserveCapacity; U32 gOctreeReserveCapacity;
BOOL LLSpatialGroup::sNoDelete = FALSE; BOOL LLSpatialGroup::sNoDelete = FALSE;
@@ -1623,10 +1624,10 @@ void renderOctree(LLSpatialGroup* group)
gGL.diffuseColor4fv(col.mV); gGL.diffuseColor4fv(col.mV);
LLVector4a fudge; LLVector4a fudge;
fudge.splat(0.001f); fudge.splat(0.001f);
const LLVector4a* bounds = group->getObjectBounds(); //const LLVector4a* bounds = group->getObjectBounds();
LLVector4a size = bounds[1]; //LLVector4a size = bounds[1];
size.mul(1.01f); //size.mul(1.01f);
size.add(fudge); //size.add(fudge);*/
//{ //{
// LLGLDepthTest depth(GL_TRUE, GL_FALSE); // LLGLDepthTest depth(GL_TRUE, GL_FALSE);

View File

@@ -454,6 +454,7 @@ static bool handleRepartition(const LLSD&)
if (gPipeline.isInit()) if (gPipeline.isInit())
{ {
gOctreeMaxCapacity = gSavedSettings.getU32("OctreeMaxNodeCapacity"); gOctreeMaxCapacity = gSavedSettings.getU32("OctreeMaxNodeCapacity");
gOctreeMinSize = gSavedSettings.getF32("OctreeMinimumNodeSize");
gOctreeReserveCapacity = llmin(gSavedSettings.getU32("OctreeReserveNodeCapacity"),U32(512)); gOctreeReserveCapacity = llmin(gSavedSettings.getU32("OctreeReserveNodeCapacity"),U32(512));
gObjectList.repartitionObjects(); gObjectList.repartitionObjects();
} }
@@ -692,6 +693,7 @@ void settings_setup_listeners()
gSavedSettings.getControl("OctreeStaticObjectSizeFactor")->getSignal()->connect(boost::bind(&handleRepartition, _2)); gSavedSettings.getControl("OctreeStaticObjectSizeFactor")->getSignal()->connect(boost::bind(&handleRepartition, _2));
gSavedSettings.getControl("OctreeDistanceFactor")->getSignal()->connect(boost::bind(&handleRepartition, _2)); gSavedSettings.getControl("OctreeDistanceFactor")->getSignal()->connect(boost::bind(&handleRepartition, _2));
gSavedSettings.getControl("OctreeMaxNodeCapacity")->getSignal()->connect(boost::bind(&handleRepartition, _2)); gSavedSettings.getControl("OctreeMaxNodeCapacity")->getSignal()->connect(boost::bind(&handleRepartition, _2));
gSavedSettings.getControl("OctreeMinimumNodeSize")->getSignal()->connect(boost::bind(&handleRepartition, _2));
gSavedSettings.getControl("OctreeReserveNodeCapacity")->getSignal()->connect(boost::bind(&handleRepartition, _2)); gSavedSettings.getControl("OctreeReserveNodeCapacity")->getSignal()->connect(boost::bind(&handleRepartition, _2));
gSavedSettings.getControl("OctreeAlphaDistanceFactor")->getSignal()->connect(boost::bind(&handleRepartition, _2)); gSavedSettings.getControl("OctreeAlphaDistanceFactor")->getSignal()->connect(boost::bind(&handleRepartition, _2));
gSavedSettings.getControl("OctreeAttachmentSizeFactor")->getSignal()->connect(boost::bind(&handleRepartition, _2)); gSavedSettings.getControl("OctreeAttachmentSizeFactor")->getSignal()->connect(boost::bind(&handleRepartition, _2));

View File

@@ -1033,7 +1033,7 @@ BOOL LLOcclusionCullingGroup::earlyFail(LLCamera* camera, const LLVector4a* boun
LLVector4a fudge(vel*2.f); LLVector4a fudge(vel*2.f);
const LLVector4a& c = bounds[0]; const LLVector4a& c = bounds[0];
static LLVector4a r; LLVector4a r;
r.setAdd(bounds[1], fudge); r.setAdd(bounds[1], fudge);
/*if (r.magVecSquared() > 1024.0*1024.0) /*if (r.magVecSquared() > 1024.0*1024.0)
@@ -1242,6 +1242,11 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector4a* sh
//static LLVector4a fudge(SG_OCCLUSION_FUDGE); //static LLVector4a fudge(SG_OCCLUSION_FUDGE);
static LLCachedControl<F32> vel("SHOcclusionFudge",SG_OCCLUSION_FUDGE); static LLCachedControl<F32> vel("SHOcclusionFudge",SG_OCCLUSION_FUDGE);
LLVector4a fudge(SG_OCCLUSION_FUDGE); LLVector4a fudge(SG_OCCLUSION_FUDGE);
if (LLDrawPool::POOL_WATER == mSpatialPartition->mDrawableType)
{
fudge.getF32ptr()[2] = 1.f;
}
static LLVector4a fudged_bounds; static LLVector4a fudged_bounds;
fudged_bounds.setAdd(fudge, bounds[1]); fudged_bounds.setAdd(fudge, bounds[1]);
shader->uniform3fv(LLShaderMgr::BOX_SIZE, 1, fudged_bounds.getF32ptr()); shader->uniform3fv(LLShaderMgr::BOX_SIZE, 1, fudged_bounds.getF32ptr());

View File

@@ -958,6 +958,7 @@ void LLPipeline::refreshCachedSettings()
LLVOAvatar::sMaxVisible = (U32)gSavedSettings.getS32("RenderAvatarMaxVisible"); LLVOAvatar::sMaxVisible = (U32)gSavedSettings.getS32("RenderAvatarMaxVisible");
//LLPipeline::sDelayVBUpdate = gSavedSettings.getBOOL("RenderDelayVBUpdate"); //LLPipeline::sDelayVBUpdate = gSavedSettings.getBOOL("RenderDelayVBUpdate");
gOctreeMaxCapacity = gSavedSettings.getU32("OctreeMaxNodeCapacity"); gOctreeMaxCapacity = gSavedSettings.getU32("OctreeMaxNodeCapacity");
gOctreeMinSize = gSavedSettings.getF32("OctreeMinimumNodeSize");
gOctreeReserveCapacity = llmin(gSavedSettings.getU32("OctreeReserveNodeCapacity"), U32(512)); gOctreeReserveCapacity = llmin(gSavedSettings.getU32("OctreeReserveNodeCapacity"), U32(512));
LLPipeline::sDynamicLOD = gSavedSettings.getBOOL("RenderDynamicLOD"); LLPipeline::sDynamicLOD = gSavedSettings.getBOOL("RenderDynamicLOD");
LLPipeline::sRenderBump = gSavedSettings.getBOOL("RenderObjectBump"); LLPipeline::sRenderBump = gSavedSettings.getBOOL("RenderObjectBump");