Skip to content

Commit 77f500c

Browse files
committed
Merge branch 'master' of git://github.com/Shyotl/SingularityViewer
2 parents d04a8fc + 347c2cb commit 77f500c

6 files changed

Lines changed: 50 additions & 19 deletions

File tree

indra/llmath/lloctree.h

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#endif
4646

4747
extern U32 gOctreeMaxCapacity;
48+
extern float gOctreeMinSize;
4849
extern U32 gOctreeReserveCapacity;
4950
#if LL_DEBUG
5051
#define LL_OCTREE_PARANOIA_CHECK 0
@@ -404,7 +405,7 @@ class LLOctreeNode : public LLTreeNode<T>
404405
F32 size = mSize[0];
405406
F32 p_size = size * 2.f;
406407

407-
return (radius <= 0.001f && size <= 0.001f) ||
408+
return (radius <= gOctreeMinSize && size <= gOctreeMinSize) ||
408409
(radius <= p_size && radius > size);
409410
}
410411

@@ -511,7 +512,7 @@ class LLOctreeNode : public LLTreeNode<T>
511512
//is it here?
512513
if (isInside(data->getPositionGroup()))
513514
{
514-
if (((getElementCount() < gOctreeMaxCapacity && contains(data->getBinRadius())) ||
515+
if ((((getElementCount() < gOctreeMaxCapacity || getSize()[0] <= gOctreeMinSize) && contains(data->getBinRadius())) ||
515516
(data->getBinRadius() > getSize()[0] && parent && parent->getElementCount() >= gOctreeMaxCapacity)))
516517
{ //it belongs here
517518
/*mElementCount++;
@@ -566,8 +567,9 @@ class LLOctreeNode : public LLTreeNode<T>
566567
LLVector4a val;
567568
val.setSub(center, getCenter());
568569
val.setAbs(val);
569-
570-
S32 lt = val.lessThan(LLVector4a::getEpsilon()).getGatheredBits() & 0x7;
570+
LLVector4a min_diff(gOctreeMinSize);
571+
572+
S32 lt = val.lessThan(min_diff).getGatheredBits() & 0x7;
571573

572574
if( lt == 0x7 )
573575
{
@@ -616,17 +618,15 @@ class LLOctreeNode : public LLTreeNode<T>
616618
}
617619
#endif
618620

621+
llassert(size[0] >= gOctreeMinSize*0.5f);
619622
//make the new kid
620623
child = new LLOctreeNode<T>(center, size, this);
621624
addChild(child);
622625

623626
child->insert(data);
624627
}
625628
}
626-
// Singu note: now that we allow wider range in octree, discard them here
627-
// if they fall out of range
628-
#if 0
629-
else
629+
else if (parent)
630630
{
631631
//it's not in here, give it to the root
632632
OCT_ERRS << "Octree insertion failed, starting over from root!" << LL_ENDL;
@@ -639,12 +639,15 @@ class LLOctreeNode : public LLTreeNode<T>
639639
parent = node->getOctParent();
640640
}
641641

642-
if(node != this)
643-
{
644-
node->insert(data);
645-
}
642+
node->insert(data);
643+
}
644+
else
645+
{
646+
// It's not in here, and we are root.
647+
// LLOctreeRoot::insert() should have expanded
648+
// root by now, something is wrong
649+
OCT_ERRS << "Octree insertion failed! Root expansion failed." << LL_ENDL;
646650
}
647-
#endif
648651

649652
return false;
650653
}
@@ -1050,10 +1053,15 @@ class LLOctreeRoot : public LLOctreeNode<T>
10501053
{
10511054
LLOctreeNode<T>::insert(data);
10521055
}
1053-
else
1056+
else if (node->isInside(data->getPositionGroup()))
10541057
{
10551058
node->insert(data);
10561059
}
1060+
else
1061+
{
1062+
// calling node->insert(data) will return us to root
1063+
OCT_ERRS << "Failed to insert data at child node" << LL_ENDL;
1064+
}
10571065
}
10581066
else if (this->getChildCount() == 0)
10591067
{
@@ -1088,6 +1096,8 @@ class LLOctreeRoot : public LLOctreeNode<T>
10881096
this->setSize(size2);
10891097
this->updateMinMax();
10901098

1099+
llassert(size[0] >= gOctreeMinSize);
1100+
10911101
//copy our children to a new branch
10921102
LLOctreeNode<T>* newnode = new LLOctreeNode<T>(center, size, this);
10931103

indra/newview/app_settings/settings.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12628,6 +12628,18 @@ This should be as low as possible, but too low may break functionality</string>
1262812628
<integer>128</integer>
1262912629
</map>
1263012630

12631+
<key>OctreeMinimumNodeSize</key>
12632+
<map>
12633+
<key>Comment</key>
12634+
<string>Minimum size of any octree node</string>
12635+
<key>Persist</key>
12636+
<integer>1</integer>
12637+
<key>Type</key>
12638+
<string>F32</string>
12639+
<key>Value</key>
12640+
<real>0.01</real>
12641+
</map>
12642+
1263112643
<key>OctreeReserveNodeCapacity</key>
1263212644
<map>
1263312645
<key>Comment</key>

indra/newview/llspatialpartition.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ static U32 sZombieGroups = 0;
7070
U32 LLSpatialGroup::sNodeCount = 0;
7171

7272
U32 gOctreeMaxCapacity;
73+
float gOctreeMinSize;
7374
U32 gOctreeReserveCapacity;
7475

7576
BOOL LLSpatialGroup::sNoDelete = FALSE;
@@ -1623,10 +1624,10 @@ void renderOctree(LLSpatialGroup* group)
16231624
gGL.diffuseColor4fv(col.mV);
16241625
LLVector4a fudge;
16251626
fudge.splat(0.001f);
1626-
const LLVector4a* bounds = group->getObjectBounds();
1627-
LLVector4a size = bounds[1];
1628-
size.mul(1.01f);
1629-
size.add(fudge);
1627+
//const LLVector4a* bounds = group->getObjectBounds();
1628+
//LLVector4a size = bounds[1];
1629+
//size.mul(1.01f);
1630+
//size.add(fudge);*/
16301631

16311632
//{
16321633
// LLGLDepthTest depth(GL_TRUE, GL_FALSE);

indra/newview/llviewercontrol.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ static bool handleRepartition(const LLSD&)
454454
if (gPipeline.isInit())
455455
{
456456
gOctreeMaxCapacity = gSavedSettings.getU32("OctreeMaxNodeCapacity");
457+
gOctreeMinSize = gSavedSettings.getF32("OctreeMinimumNodeSize");
457458
gOctreeReserveCapacity = llmin(gSavedSettings.getU32("OctreeReserveNodeCapacity"),U32(512));
458459
gObjectList.repartitionObjects();
459460
}
@@ -692,6 +693,7 @@ void settings_setup_listeners()
692693
gSavedSettings.getControl("OctreeStaticObjectSizeFactor")->getSignal()->connect(boost::bind(&handleRepartition, _2));
693694
gSavedSettings.getControl("OctreeDistanceFactor")->getSignal()->connect(boost::bind(&handleRepartition, _2));
694695
gSavedSettings.getControl("OctreeMaxNodeCapacity")->getSignal()->connect(boost::bind(&handleRepartition, _2));
696+
gSavedSettings.getControl("OctreeMinimumNodeSize")->getSignal()->connect(boost::bind(&handleRepartition, _2));
695697
gSavedSettings.getControl("OctreeReserveNodeCapacity")->getSignal()->connect(boost::bind(&handleRepartition, _2));
696698
gSavedSettings.getControl("OctreeAlphaDistanceFactor")->getSignal()->connect(boost::bind(&handleRepartition, _2));
697699
gSavedSettings.getControl("OctreeAttachmentSizeFactor")->getSignal()->connect(boost::bind(&handleRepartition, _2));

indra/newview/llvieweroctree.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,7 @@ BOOL LLOcclusionCullingGroup::earlyFail(LLCamera* camera, const LLVector4a* boun
10331033
LLVector4a fudge(vel*2.f);
10341034

10351035
const LLVector4a& c = bounds[0];
1036-
static LLVector4a r;
1036+
LLVector4a r;
10371037
r.setAdd(bounds[1], fudge);
10381038

10391039
/*if (r.magVecSquared() > 1024.0*1024.0)
@@ -1242,6 +1242,11 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector4a* sh
12421242
//static LLVector4a fudge(SG_OCCLUSION_FUDGE);
12431243
static LLCachedControl<F32> vel("SHOcclusionFudge",SG_OCCLUSION_FUDGE);
12441244
LLVector4a fudge(SG_OCCLUSION_FUDGE);
1245+
if (LLDrawPool::POOL_WATER == mSpatialPartition->mDrawableType)
1246+
{
1247+
fudge.getF32ptr()[2] = 1.f;
1248+
}
1249+
12451250
static LLVector4a fudged_bounds;
12461251
fudged_bounds.setAdd(fudge, bounds[1]);
12471252
shader->uniform3fv(LLShaderMgr::BOX_SIZE, 1, fudged_bounds.getF32ptr());

indra/newview/pipeline.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,7 @@ void LLPipeline::refreshCachedSettings()
958958
LLVOAvatar::sMaxVisible = (U32)gSavedSettings.getS32("RenderAvatarMaxVisible");
959959
//LLPipeline::sDelayVBUpdate = gSavedSettings.getBOOL("RenderDelayVBUpdate");
960960
gOctreeMaxCapacity = gSavedSettings.getU32("OctreeMaxNodeCapacity");
961+
gOctreeMinSize = gSavedSettings.getF32("OctreeMinimumNodeSize");
961962
gOctreeReserveCapacity = llmin(gSavedSettings.getU32("OctreeReserveNodeCapacity"), U32(512));
962963
LLPipeline::sDynamicLOD = gSavedSettings.getBOOL("RenderDynamicLOD");
963964
LLPipeline::sRenderBump = gSavedSettings.getBOOL("RenderObjectBump");

0 commit comments

Comments
 (0)