From 347c2cbd8bc8bf4a2cb3f2e7ace95c2739a99e2d Mon Sep 17 00:00:00 2001 From: Shyotl Date: Tue, 31 Mar 2020 19:07:55 -0500 Subject: [PATCH] Fall in line with LL octree code. --- indra/llmath/lloctree.h | 38 ++++++++++++++++--------- indra/newview/app_settings/settings.xml | 12 ++++++++ indra/newview/llspatialpartition.cpp | 9 +++--- indra/newview/llviewercontrol.cpp | 2 ++ indra/newview/llvieweroctree.cpp | 7 ++++- indra/newview/pipeline.cpp | 1 + 6 files changed, 50 insertions(+), 19 deletions(-) diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h index 67a7c997e..f82a08f3e 100644 --- a/indra/llmath/lloctree.h +++ b/indra/llmath/lloctree.h @@ -45,6 +45,7 @@ #endif extern U32 gOctreeMaxCapacity; +extern float gOctreeMinSize; extern U32 gOctreeReserveCapacity; #if LL_DEBUG #define LL_OCTREE_PARANOIA_CHECK 0 @@ -404,7 +405,7 @@ public: F32 size = mSize[0]; F32 p_size = size * 2.f; - return (radius <= 0.001f && size <= 0.001f) || + return (radius <= gOctreeMinSize && size <= gOctreeMinSize) || (radius <= p_size && radius > size); } @@ -511,7 +512,7 @@ public: //is it here? 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))) { //it belongs here /*mElementCount++; @@ -566,8 +567,9 @@ public: LLVector4a val; val.setSub(center, getCenter()); val.setAbs(val); - - S32 lt = val.lessThan(LLVector4a::getEpsilon()).getGatheredBits() & 0x7; + LLVector4a min_diff(gOctreeMinSize); + + S32 lt = val.lessThan(min_diff).getGatheredBits() & 0x7; if( lt == 0x7 ) { @@ -616,6 +618,7 @@ public: } #endif + llassert(size[0] >= gOctreeMinSize*0.5f); //make the new kid child = new LLOctreeNode(center, size, this); addChild(child); @@ -623,10 +626,7 @@ public: child->insert(data); } } -// Singu note: now that we allow wider range in octree, discard them here -// if they fall out of range -#if 0 - else + else if (parent) { //it's not in here, give it to the root OCT_ERRS << "Octree insertion failed, starting over from root!" << LL_ENDL; @@ -639,12 +639,15 @@ public: 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; } @@ -1050,10 +1053,15 @@ public: { LLOctreeNode::insert(data); } - else + else if (node->isInside(data->getPositionGroup())) { 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) { @@ -1088,6 +1096,8 @@ public: this->setSize(size2); this->updateMinMax(); + llassert(size[0] >= gOctreeMinSize); + //copy our children to a new branch LLOctreeNode* newnode = new LLOctreeNode(center, size, this); diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 4189c9924..eefd44024 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -12628,6 +12628,18 @@ This should be as low as possible, but too low may break functionality 128 + OctreeMinimumNodeSize + + Comment + Minimum size of any octree node + Persist + 1 + Type + F32 + Value + 0.01 + + OctreeReserveNodeCapacity Comment diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index f07432fea..9e1066072 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -70,6 +70,7 @@ static U32 sZombieGroups = 0; U32 LLSpatialGroup::sNodeCount = 0; U32 gOctreeMaxCapacity; +float gOctreeMinSize; U32 gOctreeReserveCapacity; BOOL LLSpatialGroup::sNoDelete = FALSE; @@ -1623,10 +1624,10 @@ void renderOctree(LLSpatialGroup* group) gGL.diffuseColor4fv(col.mV); LLVector4a fudge; fudge.splat(0.001f); - const LLVector4a* bounds = group->getObjectBounds(); - LLVector4a size = bounds[1]; - size.mul(1.01f); - size.add(fudge); + //const LLVector4a* bounds = group->getObjectBounds(); + //LLVector4a size = bounds[1]; + //size.mul(1.01f); + //size.add(fudge);*/ //{ // LLGLDepthTest depth(GL_TRUE, GL_FALSE); diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index 1e4e210f2..e1a7a04ef 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -454,6 +454,7 @@ static bool handleRepartition(const LLSD&) if (gPipeline.isInit()) { gOctreeMaxCapacity = gSavedSettings.getU32("OctreeMaxNodeCapacity"); + gOctreeMinSize = gSavedSettings.getF32("OctreeMinimumNodeSize"); gOctreeReserveCapacity = llmin(gSavedSettings.getU32("OctreeReserveNodeCapacity"),U32(512)); gObjectList.repartitionObjects(); } @@ -692,6 +693,7 @@ void settings_setup_listeners() gSavedSettings.getControl("OctreeStaticObjectSizeFactor")->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("OctreeMinimumNodeSize")->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("OctreeAttachmentSizeFactor")->getSignal()->connect(boost::bind(&handleRepartition, _2)); diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index bbb57f3b9..4af787a8d 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -1033,7 +1033,7 @@ BOOL LLOcclusionCullingGroup::earlyFail(LLCamera* camera, const LLVector4a* boun LLVector4a fudge(vel*2.f); const LLVector4a& c = bounds[0]; - static LLVector4a r; + LLVector4a r; r.setAdd(bounds[1], fudge); /*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 LLCachedControl vel("SHOcclusionFudge",SG_OCCLUSION_FUDGE); LLVector4a fudge(SG_OCCLUSION_FUDGE); + if (LLDrawPool::POOL_WATER == mSpatialPartition->mDrawableType) + { + fudge.getF32ptr()[2] = 1.f; + } + static LLVector4a fudged_bounds; fudged_bounds.setAdd(fudge, bounds[1]); shader->uniform3fv(LLShaderMgr::BOX_SIZE, 1, fudged_bounds.getF32ptr()); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 887faf733..f8cedfcf9 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -958,6 +958,7 @@ void LLPipeline::refreshCachedSettings() LLVOAvatar::sMaxVisible = (U32)gSavedSettings.getS32("RenderAvatarMaxVisible"); //LLPipeline::sDelayVBUpdate = gSavedSettings.getBOOL("RenderDelayVBUpdate"); gOctreeMaxCapacity = gSavedSettings.getU32("OctreeMaxNodeCapacity"); + gOctreeMinSize = gSavedSettings.getF32("OctreeMinimumNodeSize"); gOctreeReserveCapacity = llmin(gSavedSettings.getU32("OctreeReserveNodeCapacity"), U32(512)); LLPipeline::sDynamicLOD = gSavedSettings.getBOOL("RenderDynamicLOD"); LLPipeline::sRenderBump = gSavedSettings.getBOOL("RenderObjectBump");