summaryrefslogtreecommitdiff
path: root/indra/newview/llspatialpartition.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llspatialpartition.cpp')
-rw-r--r--indra/newview/llspatialpartition.cpp196
1 files changed, 74 insertions, 122 deletions
diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp
index 78c905f6ff..325a2d3004 100644
--- a/indra/newview/llspatialpartition.cpp
+++ b/indra/newview/llspatialpartition.cpp
@@ -68,7 +68,6 @@ const F32 SG_OCCLUSION_FUDGE = 0.25f;
#define assert_states_valid(x)
#endif
-extern bool gShiftFrame;
static U32 sZombieGroups = 0;
U32 LLSpatialGroup::sNodeCount = 0;
@@ -530,7 +529,6 @@ void LLSpatialGroup::setVisible()
void LLSpatialGroup::validate()
{
- ll_assert_aligned(this,64);
#if LL_OCTREE_PARANOIA_CHECK
sg_assert(!isState(DIRTY));
@@ -543,7 +541,7 @@ void LLSpatialGroup::validate()
validateDrawMap();
- for (element_iter i = getDataBegin(); i != getDataEnd(); ++i)
+ for (element_iter i = getData().begin(); i != getData().end(); ++i)
{
LLDrawable* drawable = *i;
sg_assert(drawable->getSpatialGroup() == this);
@@ -760,7 +758,7 @@ BOOL LLSpatialGroup::boundObjects(BOOL empty, LLVector4a& minOut, LLVector4a& ma
{
const OctreeNode* node = mOctreeNode;
- if (node->isEmpty())
+ if (node->getData().empty())
{ //don't do anything if there are no objects
if (empty && mOctreeNode->getParent())
{ //only root is allowed to be empty
@@ -777,14 +775,14 @@ BOOL LLSpatialGroup::boundObjects(BOOL empty, LLVector4a& minOut, LLVector4a& ma
clearState(OBJECT_DIRTY);
//initialize bounding box to first element
- OctreeNode::const_element_iter i = node->getDataBegin();
+ OctreeNode::const_element_iter i = node->getData().begin();
LLDrawable* drawablep = *i;
const LLVector4a* minMax = drawablep->getSpatialExtents();
newMin = minMax[0];
newMax = minMax[1];
- for (++i; i != node->getDataEnd(); ++i)
+ for (++i; i != node->getData().end(); ++i)
{
drawablep = *i;
minMax = drawablep->getSpatialExtents();
@@ -925,10 +923,7 @@ void LLSpatialGroup::shift(const LLVector4a &offset)
mObjectExtents[0].add(offset);
mObjectExtents[1].add(offset);
- if (!mSpatialPartition->mRenderByGroup &&
- mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_TREE &&
- mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_TERRAIN &&
- mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_BRIDGE)
+ //if (!mSpatialPartition->mRenderByGroup)
{
setState(GEOM_DIRTY);
gPipeline.markRebuild(this, TRUE);
@@ -1200,8 +1195,6 @@ LLSpatialGroup::LLSpatialGroup(OctreeNode* node, LLSpatialPartition* part) :
mCurUpdatingSlotp(NULL),
mCurUpdatingTexture (NULL)
{
- ll_assert_aligned(this,16);
-
sNodeCount++;
LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION);
@@ -1245,18 +1238,13 @@ void LLSpatialGroup::updateDistance(LLCamera &camera)
return;
}
- if (gShiftFrame)
- {
- return;
- }
-
#if !LL_RELEASE_FOR_DOWNLOAD
if (isState(LLSpatialGroup::OBJECT_DIRTY))
{
llerrs << "Spatial group dirty on distance update." << llendl;
}
#endif
- if (!isEmpty())
+ if (!getData().empty())
{
mRadius = mSpatialPartition->mRenderByGroup ? mObjectBounds[1].getLength3().getF32() :
(F32) mOctreeNode->getSize().getLength3().getF32();
@@ -1407,7 +1395,7 @@ void LLSpatialGroup::handleDestruction(const TreeNode* node)
LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION);
setState(DEAD);
- for (element_iter i = getDataBegin(); i != getDataEnd(); ++i)
+ for (element_iter i = getData().begin(); i != getData().end(); ++i)
{
LLDrawable* drawable = *i;
if (drawable->getSpatialGroup() == this)
@@ -1494,7 +1482,7 @@ void LLSpatialGroup::destroyGL(bool keep_occlusion)
}
- for (LLSpatialGroup::element_iter i = getDataBegin(); i != getDataEnd(); ++i)
+ for (LLSpatialGroup::element_iter i = getData().begin(); i != getData().end(); ++i)
{
LLDrawable* drawable = *i;
for (S32 j = 0; j < drawable->getNumFaces(); j++)
@@ -1850,14 +1838,12 @@ BOOL LLSpatialPartition::remove(LLDrawable *drawablep, LLSpatialGroup *curp)
{
LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION);
+ drawablep->setSpatialGroup(NULL);
+
if (!curp->removeObject(drawablep))
{
OCT_ERRS << "Failed to remove drawable from octree!" << llendl;
}
- else
- {
- drawablep->setSpatialGroup(NULL);
- }
assert_octree_valid(mOctree);
@@ -2128,7 +2114,7 @@ public:
virtual void processGroup(LLSpatialGroup* group)
{
- llassert(!group->isState(LLSpatialGroup::DIRTY) && !group->isEmpty())
+ llassert(!group->isState(LLSpatialGroup::DIRTY) && !group->getData().empty())
if (mRes < 2)
{
@@ -2195,7 +2181,7 @@ public:
{
LLSpatialGroup::OctreeNode* branch = group->mOctreeNode;
- for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getDataBegin(); i != branch->getDataEnd(); ++i)
+ for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getData().begin(); i != branch->getData().end(); ++i)
{
LLDrawable* drawable = *i;
@@ -2319,7 +2305,7 @@ public:
LLSpatialGroup* group = (LLSpatialGroup*) state->getListener(0);
group->destroyGL();
- for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
+ for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
{
LLDrawable* drawable = *i;
if (drawable->getVObj().notNull() && !group->mSpatialPartition->mRenderByGroup)
@@ -2629,7 +2615,7 @@ void renderOctree(LLSpatialGroup* group)
gGL.flush();
glLineWidth(1.f);
gGL.flush();
- for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
+ for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
{
LLDrawable* drawable = *i;
if (!group->mSpatialPartition->isBridge())
@@ -2675,7 +2661,7 @@ void renderOctree(LLSpatialGroup* group)
}
else
{
- if (group->mBufferUsage == GL_STATIC_DRAW_ARB && !group->isEmpty()
+ if (group->mBufferUsage == GL_STATIC_DRAW_ARB && !group->getData().empty()
&& group->mSpatialPartition->mRenderByGroup)
{
col.setVec(0.8f, 0.4f, 0.1f, 0.1f);
@@ -2743,7 +2729,7 @@ void renderVisibility(LLSpatialGroup* group, LLCamera* camera)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
BOOL render_objects = (!LLPipeline::sUseOcclusion || !group->isOcclusionState(LLSpatialGroup::OCCLUDED)) && group->isVisible() &&
- !group->isEmpty();
+ !group->getData().empty();
if (render_objects)
{
@@ -3474,7 +3460,7 @@ void renderPhysicsShape(LLDrawable* drawable, LLVOVolume* volume)
void renderPhysicsShapes(LLSpatialGroup* group)
{
- for (LLSpatialGroup::OctreeNode::const_element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
+ for (LLSpatialGroup::OctreeNode::const_element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
{
LLDrawable* drawable = *i;
LLVOVolume* volume = drawable->getVOVolume();
@@ -3823,7 +3809,7 @@ public:
LLVector3 center, size;
- if (branch->isEmpty())
+ if (branch->getData().empty())
{
gGL.diffuseColor3f(1.f,0.2f,0.f);
center.set(branch->getCenter().getF32ptr());
@@ -3859,8 +3845,8 @@ public:
}
gGL.begin(LLRender::TRIANGLES);
- for (LLOctreeNode<LLVolumeTriangle>::const_element_iter iter = branch->getDataBegin();
- iter != branch->getDataEnd();
+ for (LLOctreeNode<LLVolumeTriangle>::const_element_iter iter = branch->getData().begin();
+ iter != branch->getData().end();
++iter)
{
const LLVolumeTriangle* tri = *iter;
@@ -4097,7 +4083,7 @@ public:
if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_BBOXES))
{
- if (!group->isEmpty())
+ if (!group->getData().empty())
{
gGL.diffuseColor3f(0,0,1);
drawBoxOutline(group->mObjectBounds[0],
@@ -4105,7 +4091,7 @@ public:
}
}
- for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getDataBegin(); i != branch->getDataEnd(); ++i)
+ for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getData().begin(); i != branch->getData().end(); ++i)
{
LLDrawable* drawable = *i;
@@ -4191,7 +4177,7 @@ public:
{
if (index < 255)
{
- if (facep->mDrawInfo->mTextureList.size()<= index)
+ if (facep->mDrawInfo->mTextureList.size() <= index)
{
llerrs << "Face texture index out of bounds." << llendl;
}
@@ -4294,7 +4280,7 @@ public:
return;
}
- for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getDataBegin(); i != branch->getDataEnd(); ++i)
+ for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getData().begin(); i != branch->getData().end(); ++i)
{
LLDrawable* drawable = *i;
@@ -4518,7 +4504,7 @@ public:
virtual void visit(const LLSpatialGroup::OctreeNode* branch)
{
- for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getDataBegin(); i != branch->getDataEnd(); ++i)
+ for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getData().begin(); i != branch->getData().end(); ++i)
{
check(*i);
}
@@ -4704,62 +4690,28 @@ LLVertexBuffer* LLGeometryManager::createVertexBuffer(U32 type_mask, U32 usage)
LLCullResult::LLCullResult()
{
- mVisibleGroupsAllocated = 0;
- mAlphaGroupsAllocated = 0;
- mOcclusionGroupsAllocated = 0;
- mDrawableGroupsAllocated = 0;
- mVisibleListAllocated = 0;
- mVisibleBridgeAllocated = 0;
-
- mVisibleGroups = NULL;
- mVisibleGroupsEnd = NULL;
- mAlphaGroups = NULL;
- mAlphaGroupsEnd = NULL;
- mOcclusionGroups = NULL;
- mOcclusionGroupsEnd = NULL;
- mDrawableGroups = NULL;
- mDrawableGroupsEnd = NULL;
- mVisibleList = NULL;
- mVisibleListEnd = NULL;
- mVisibleBridge = NULL;
- mVisibleBridgeEnd = NULL;
-
- for (U32 i = 0; i < LLRenderPass::NUM_RENDER_TYPES; i++)
- {
- mRenderMap[i] = NULL;
- mRenderMapEnd[i] = NULL;
- mRenderMapAllocated[i] = 0;
- }
-
clear();
}
-void LLCullResult::pushBack(void**& head, U32& count, void* val)
-{
- count++;
- head = (void**) realloc((void*) head, sizeof(void*) * count);
- head[count-1] = val;
-}
-
void LLCullResult::clear()
{
mVisibleGroupsSize = 0;
- mVisibleGroupsEnd = mVisibleGroups;
+ mVisibleGroupsEnd = mVisibleGroups.begin();
mAlphaGroupsSize = 0;
- mAlphaGroupsEnd = mAlphaGroups;
+ mAlphaGroupsEnd = mAlphaGroups.begin();
mOcclusionGroupsSize = 0;
- mOcclusionGroupsEnd = mOcclusionGroups;
+ mOcclusionGroupsEnd = mOcclusionGroups.begin();
mDrawableGroupsSize = 0;
- mDrawableGroupsEnd = mDrawableGroups;
+ mDrawableGroupsEnd = mDrawableGroups.begin();
mVisibleListSize = 0;
- mVisibleListEnd = mVisibleList;
+ mVisibleListEnd = mVisibleList.begin();
mVisibleBridgeSize = 0;
- mVisibleBridgeEnd = mVisibleBridge;
+ mVisibleBridgeEnd = mVisibleBridge.begin();
for (U32 i = 0; i < LLRenderPass::NUM_RENDER_TYPES; i++)
@@ -4769,176 +4721,176 @@ void LLCullResult::clear()
mRenderMap[i][j] = 0;
}
mRenderMapSize[i] = 0;
- mRenderMapEnd[i] = mRenderMap[i];
+ mRenderMapEnd[i] = mRenderMap[i].begin();
}
}
-LLCullResult::sg_iterator LLCullResult::beginVisibleGroups()
+LLCullResult::sg_list_t::iterator LLCullResult::beginVisibleGroups()
{
- return mVisibleGroups;
+ return mVisibleGroups.begin();
}
-LLCullResult::sg_iterator LLCullResult::endVisibleGroups()
+LLCullResult::sg_list_t::iterator LLCullResult::endVisibleGroups()
{
return mVisibleGroupsEnd;
}
-LLCullResult::sg_iterator LLCullResult::beginAlphaGroups()
+LLCullResult::sg_list_t::iterator LLCullResult::beginAlphaGroups()
{
- return mAlphaGroups;
+ return mAlphaGroups.begin();
}
-LLCullResult::sg_iterator LLCullResult::endAlphaGroups()
+LLCullResult::sg_list_t::iterator LLCullResult::endAlphaGroups()
{
return mAlphaGroupsEnd;
}
-LLCullResult::sg_iterator LLCullResult::beginOcclusionGroups()
+LLCullResult::sg_list_t::iterator LLCullResult::beginOcclusionGroups()
{
- return mOcclusionGroups;
+ return mOcclusionGroups.begin();
}
-LLCullResult::sg_iterator LLCullResult::endOcclusionGroups()
+LLCullResult::sg_list_t::iterator LLCullResult::endOcclusionGroups()
{
return mOcclusionGroupsEnd;
}
-LLCullResult::sg_iterator LLCullResult::beginDrawableGroups()
+LLCullResult::sg_list_t::iterator LLCullResult::beginDrawableGroups()
{
- return mDrawableGroups;
+ return mDrawableGroups.begin();
}
-LLCullResult::sg_iterator LLCullResult::endDrawableGroups()
+LLCullResult::sg_list_t::iterator LLCullResult::endDrawableGroups()
{
return mDrawableGroupsEnd;
}
-LLCullResult::drawable_iterator LLCullResult::beginVisibleList()
+LLCullResult::drawable_list_t::iterator LLCullResult::beginVisibleList()
{
- return mVisibleList;
+ return mVisibleList.begin();
}
-LLCullResult::drawable_iterator LLCullResult::endVisibleList()
+LLCullResult::drawable_list_t::iterator LLCullResult::endVisibleList()
{
return mVisibleListEnd;
}
-LLCullResult::bridge_iterator LLCullResult::beginVisibleBridge()
+LLCullResult::bridge_list_t::iterator LLCullResult::beginVisibleBridge()
{
- return mVisibleBridge;
+ return mVisibleBridge.begin();
}
-LLCullResult::bridge_iterator LLCullResult::endVisibleBridge()
+LLCullResult::bridge_list_t::iterator LLCullResult::endVisibleBridge()
{
return mVisibleBridgeEnd;
}
-LLCullResult::drawinfo_iterator LLCullResult::beginRenderMap(U32 type)
+LLCullResult::drawinfo_list_t::iterator LLCullResult::beginRenderMap(U32 type)
{
- return mRenderMap[type];
+ return mRenderMap[type].begin();
}
-LLCullResult::drawinfo_iterator LLCullResult::endRenderMap(U32 type)
+LLCullResult::drawinfo_list_t::iterator LLCullResult::endRenderMap(U32 type)
{
return mRenderMapEnd[type];
}
void LLCullResult::pushVisibleGroup(LLSpatialGroup* group)
{
- if (mVisibleGroupsSize < mVisibleGroupsAllocated)
+ if (mVisibleGroupsSize < mVisibleGroups.size())
{
mVisibleGroups[mVisibleGroupsSize] = group;
}
else
{
- pushBack((void**&) mVisibleGroups, mVisibleGroupsAllocated, (void*) group);
+ mVisibleGroups.push_back(group);
}
++mVisibleGroupsSize;
- mVisibleGroupsEnd = mVisibleGroups+mVisibleGroupsSize;
+ mVisibleGroupsEnd = mVisibleGroups.begin()+mVisibleGroupsSize;
}
void LLCullResult::pushAlphaGroup(LLSpatialGroup* group)
{
- if (mAlphaGroupsSize < mAlphaGroupsAllocated)
+ if (mAlphaGroupsSize < mAlphaGroups.size())
{
mAlphaGroups[mAlphaGroupsSize] = group;
}
else
{
- pushBack((void**&) mAlphaGroups, mAlphaGroupsAllocated, (void*) group);
+ mAlphaGroups.push_back(group);
}
++mAlphaGroupsSize;
- mAlphaGroupsEnd = mAlphaGroups+mAlphaGroupsSize;
+ mAlphaGroupsEnd = mAlphaGroups.begin()+mAlphaGroupsSize;
}
void LLCullResult::pushOcclusionGroup(LLSpatialGroup* group)
{
- if (mOcclusionGroupsSize < mOcclusionGroupsAllocated)
+ if (mOcclusionGroupsSize < mOcclusionGroups.size())
{
mOcclusionGroups[mOcclusionGroupsSize] = group;
}
else
{
- pushBack((void**&) mOcclusionGroups, mOcclusionGroupsAllocated, (void*) group);
+ mOcclusionGroups.push_back(group);
}
++mOcclusionGroupsSize;
- mOcclusionGroupsEnd = mOcclusionGroups+mOcclusionGroupsSize;
+ mOcclusionGroupsEnd = mOcclusionGroups.begin()+mOcclusionGroupsSize;
}
void LLCullResult::pushDrawableGroup(LLSpatialGroup* group)
{
- if (mDrawableGroupsSize < mDrawableGroupsAllocated)
+ if (mDrawableGroupsSize < mDrawableGroups.size())
{
mDrawableGroups[mDrawableGroupsSize] = group;
}
else
{
- pushBack((void**&) mDrawableGroups, mDrawableGroupsAllocated, (void*) group);
+ mDrawableGroups.push_back(group);
}
++mDrawableGroupsSize;
- mDrawableGroupsEnd = mDrawableGroups+mDrawableGroupsSize;
+ mDrawableGroupsEnd = mDrawableGroups.begin()+mDrawableGroupsSize;
}
void LLCullResult::pushDrawable(LLDrawable* drawable)
{
- if (mVisibleListSize < mVisibleListAllocated)
+ if (mVisibleListSize < mVisibleList.size())
{
mVisibleList[mVisibleListSize] = drawable;
}
else
{
- pushBack((void**&) mVisibleList, mVisibleListAllocated, (void*) drawable);
+ mVisibleList.push_back(drawable);
}
++mVisibleListSize;
- mVisibleListEnd = mVisibleList+mVisibleListSize;
+ mVisibleListEnd = mVisibleList.begin()+mVisibleListSize;
}
void LLCullResult::pushBridge(LLSpatialBridge* bridge)
{
- if (mVisibleBridgeSize < mVisibleBridgeAllocated)
+ if (mVisibleBridgeSize < mVisibleBridge.size())
{
mVisibleBridge[mVisibleBridgeSize] = bridge;
}
else
{
- pushBack((void**&) mVisibleBridge, mVisibleBridgeAllocated, (void*) bridge);
+ mVisibleBridge.push_back(bridge);
}
++mVisibleBridgeSize;
- mVisibleBridgeEnd = mVisibleBridge+mVisibleBridgeSize;
+ mVisibleBridgeEnd = mVisibleBridge.begin()+mVisibleBridgeSize;
}
void LLCullResult::pushDrawInfo(U32 type, LLDrawInfo* draw_info)
{
- if (mRenderMapSize[type] < mRenderMapAllocated[type])
+ if (mRenderMapSize[type] < mRenderMap[type].size())
{
mRenderMap[type][mRenderMapSize[type]] = draw_info;
}
else
{
- pushBack((void**&) mRenderMap[type], mRenderMapAllocated[type], (void*) draw_info);
+ mRenderMap[type].push_back(draw_info);
}
++mRenderMapSize[type];
- mRenderMapEnd[type] = mRenderMap[type] + mRenderMapSize[type];
+ mRenderMapEnd[type] = mRenderMap[type].begin() + mRenderMapSize[type];
}