MAINT-646: Factor std::set out of lloctree https://bitbucket.org/davep/viewer-development/changeset/52b6c9168974
This commit is contained in:
@@ -89,9 +89,9 @@ public:
|
||||
|
||||
typedef LLOctreeTraveler<T> oct_traveler;
|
||||
typedef LLTreeTraveler<T> tree_traveler;
|
||||
typedef typename std::set<LLPointer<T> > element_list;
|
||||
typedef typename element_list::iterator element_iter;
|
||||
typedef typename element_list::const_iterator const_element_iter;
|
||||
typedef LLPointer<T>* element_list;
|
||||
typedef LLPointer<T>* element_iter;
|
||||
typedef const LLPointer<T>* const_element_iter;
|
||||
typedef typename std::vector<LLTreeListener<T>*>::iterator tree_listener_iter;
|
||||
typedef typename std::vector<LLOctreeNode<T>* > child_list;
|
||||
typedef LLTreeNode<T> BaseType;
|
||||
@@ -115,6 +115,9 @@ public:
|
||||
: mParent((oct_node*)parent),
|
||||
mOctant(octant)
|
||||
{
|
||||
mData = NULL;
|
||||
mDataEnd = NULL;
|
||||
|
||||
mCenter = center;
|
||||
mSize = size;
|
||||
|
||||
@@ -133,6 +136,16 @@ public:
|
||||
{
|
||||
BaseType::destroyListeners();
|
||||
|
||||
for (U32 i = 0; i < mElementCount; ++i)
|
||||
{
|
||||
mData[i]->setBinIndex(-1);
|
||||
mData[i] = NULL;
|
||||
}
|
||||
|
||||
free(mData);
|
||||
mData = NULL;
|
||||
mDataEnd = NULL;
|
||||
|
||||
for (U32 i = 0; i < getChildCount(); i++)
|
||||
{
|
||||
delete getChild(i);
|
||||
@@ -232,9 +245,14 @@ public:
|
||||
virtual bool isLeaf() const { return mChild.empty(); }
|
||||
|
||||
U32 getElementCount() const { return mElementCount; }
|
||||
bool isEmpty() const { return mElementCount == 0; }
|
||||
element_list& getData() { return mData; }
|
||||
const element_list& getData() const { return mData; }
|
||||
|
||||
element_iter getDataBegin() { return mData; }
|
||||
element_iter getDataEnd() { return mDataEnd; }
|
||||
const_element_iter getDataBegin() const { return mData; }
|
||||
const_element_iter getDataEnd() const { return mDataEnd; }
|
||||
|
||||
U32 getChildCount() const { return mChildCount; }
|
||||
oct_node* getChild(U32 index) { return mChild[index]; }
|
||||
const oct_node* getChild(U32 index) const { return mChild[index]; }
|
||||
@@ -299,7 +317,7 @@ public:
|
||||
|
||||
virtual bool insert(T* data)
|
||||
{
|
||||
if (data == NULL)
|
||||
if (data == NULL || data->getBinIndex() != -1)
|
||||
{
|
||||
OCT_ERRS << "!!! INVALID ELEMENT ADDED TO OCTREE BRANCH !!!" << llendl;
|
||||
return false;
|
||||
@@ -309,22 +327,19 @@ public:
|
||||
//is it here?
|
||||
if (isInside(data->getPositionGroup()))
|
||||
{
|
||||
if (((getElementCount() < gOctreeMaxCapacity && contains(data->getBinRadius())) ||
|
||||
if ((getElementCount() < gOctreeMaxCapacity && contains(data->getBinRadius()) ||
|
||||
(data->getBinRadius() > getSize()[0] && parent && parent->getElementCount() >= gOctreeMaxCapacity)))
|
||||
{ //it belongs here
|
||||
#if LL_OCTREE_PARANOIA_CHECK
|
||||
//if this is a redundant insertion, error out (should never happen)
|
||||
if (mData.find(data) != mData.end())
|
||||
{
|
||||
llwarns << "Redundant octree insertion detected. " << data << llendl;
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
mElementCount++;
|
||||
mData = (element_list) realloc(mData, sizeof(LLPointer<T>)*mElementCount);
|
||||
|
||||
mData.insert(data);
|
||||
//avoid unref on uninitialized memory
|
||||
memset(mData+mElementCount-1, 0, sizeof(LLPointer<T>));
|
||||
|
||||
mData[mElementCount-1] = data;
|
||||
mDataEnd = mData + mElementCount;
|
||||
data->setBinIndex(mElementCount-1);
|
||||
BaseType::insert(data);
|
||||
|
||||
mElementCount = mData.size();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -358,10 +373,16 @@ public:
|
||||
|
||||
if( lt == 0x7 )
|
||||
{
|
||||
mData.insert(data);
|
||||
BaseType::insert(data);
|
||||
mElementCount++;
|
||||
mData = (element_list) realloc(mData, sizeof(LLPointer<T>)*mElementCount);
|
||||
|
||||
mElementCount = mData.size();
|
||||
//avoid unref on uninitialized memory
|
||||
memset(mData+mElementCount-1, 0, sizeof(LLPointer<T>));
|
||||
|
||||
mData[mElementCount-1] = data;
|
||||
mDataEnd = mData + mElementCount;
|
||||
data->setBinIndex(mElementCount-1);
|
||||
BaseType::insert(data);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -410,23 +431,59 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
void _remove(T* data, S32 i)
|
||||
{ //precondition -- mElementCount > 0, idx is in range [0, mElementCount)
|
||||
|
||||
mElementCount--;
|
||||
data->setBinIndex(-1);
|
||||
|
||||
if (mElementCount > 0)
|
||||
{
|
||||
if (mElementCount != i)
|
||||
{
|
||||
mData[i] = mData[mElementCount]; //might unref data, do not access data after this point
|
||||
mData[i]->setBinIndex(i);
|
||||
}
|
||||
|
||||
mData[mElementCount] = NULL; //needed for unref
|
||||
mData = (element_list) realloc(mData, sizeof(LLPointer<T>)*mElementCount);
|
||||
mDataEnd = mData+mElementCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
mData[0] = NULL; //needed for unref
|
||||
free(mData);
|
||||
mData = NULL;
|
||||
mDataEnd = NULL;
|
||||
}
|
||||
|
||||
notifyRemoval(data);
|
||||
checkAlive();
|
||||
}
|
||||
|
||||
bool remove(T* data)
|
||||
{
|
||||
if (mData.find(data) != mData.end())
|
||||
{ //we have data
|
||||
mData.erase(data);
|
||||
mElementCount = mData.size();
|
||||
this->notifyRemoval(data);
|
||||
checkAlive();
|
||||
return true;
|
||||
S32 i = data->getBinIndex();
|
||||
|
||||
if (i >= 0 && i < (S32)mElementCount)
|
||||
{
|
||||
if (mData[i] == data)
|
||||
{ //found it
|
||||
_remove(data, i);
|
||||
llassert(data->getBinIndex() == -1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (isInside(data))
|
||||
|
||||
if (isInside(data))
|
||||
{
|
||||
oct_node* dest = getNodeAt(data);
|
||||
|
||||
if (dest != this)
|
||||
{
|
||||
return dest->remove(data);
|
||||
bool ret = dest->remove(data);
|
||||
llassert(data->getBinIndex() == -1);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,19 +502,20 @@ public:
|
||||
//node is now root
|
||||
llwarns << "!!! OCTREE REMOVING FACE BY ADDRESS, SEVERE PERFORMANCE PENALTY |||" << llendl;
|
||||
node->removeByAddress(data);
|
||||
llassert(data->getBinIndex() == -1);
|
||||
return true;
|
||||
}
|
||||
|
||||
void removeByAddress(T* data)
|
||||
{
|
||||
if (mData.find(data) != mData.end())
|
||||
for (U32 i = 0; i < mElementCount; ++i)
|
||||
{
|
||||
mData.erase(data);
|
||||
mElementCount = mData.size();
|
||||
this->notifyRemoval(data);
|
||||
llwarns << "FOUND!" << llendl;
|
||||
checkAlive();
|
||||
return;
|
||||
if (mData[i] == data)
|
||||
{ //we have data
|
||||
_remove(data, i);
|
||||
llwarns << "FOUND!" << llendl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (U32 i = 0; i < getChildCount(); i++)
|
||||
@@ -624,6 +682,7 @@ protected:
|
||||
U32 mChildCount;
|
||||
|
||||
element_list mData;
|
||||
element_iter mDataEnd;
|
||||
U32 mElementCount;
|
||||
|
||||
};
|
||||
|
||||
@@ -324,16 +324,16 @@ public:
|
||||
LLVector4a& min = node->mExtents[0];
|
||||
LLVector4a& max = node->mExtents[1];
|
||||
|
||||
if (!branch->getData().empty())
|
||||
if (!branch->isEmpty())
|
||||
{ //node has data, find AABB that binds data set
|
||||
const LLVolumeTriangle* tri = *(branch->getData().begin());
|
||||
const LLVolumeTriangle* tri = *(branch->getDataBegin());
|
||||
|
||||
//initialize min/max to first available vertex
|
||||
min = *(tri->mV[0]);
|
||||
max = *(tri->mV[0]);
|
||||
|
||||
for (LLOctreeNode<LLVolumeTriangle>::const_element_iter iter =
|
||||
branch->getData().begin(); iter != branch->getData().end(); ++iter)
|
||||
branch->getDataBegin(); iter != branch->getDataEnd(); ++iter)
|
||||
{ //for each triangle in node
|
||||
|
||||
//stretch by triangles in node
|
||||
|
||||
@@ -131,7 +131,7 @@ void LLOctreeTriangleRayIntersect::traverse(const LLOctreeNode<LLVolumeTriangle>
|
||||
void LLOctreeTriangleRayIntersect::visit(const LLOctreeNode<LLVolumeTriangle>* node)
|
||||
{
|
||||
for (LLOctreeNode<LLVolumeTriangle>::const_element_iter iter =
|
||||
node->getData().begin(); iter != node->getData().end(); ++iter)
|
||||
node->getDataBegin(); iter != node->getDataEnd(); ++iter)
|
||||
{
|
||||
const LLVolumeTriangle* tri = *iter;
|
||||
|
||||
@@ -236,8 +236,8 @@ void LLVolumeOctreeValidate::visit(const LLOctreeNode<LLVolumeTriangle>* branch)
|
||||
}
|
||||
|
||||
//children fit, check data
|
||||
for (LLOctreeNode<LLVolumeTriangle>::const_element_iter iter = branch->getData().begin();
|
||||
iter != branch->getData().end(); ++iter)
|
||||
for (LLOctreeNode<LLVolumeTriangle>::const_element_iter iter = branch->getDataBegin();
|
||||
iter != branch->getDataEnd(); ++iter)
|
||||
{
|
||||
const LLVolumeTriangle* tri = *iter;
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ class LLVolumeTriangle : public LLRefCount
|
||||
public:
|
||||
LLVolumeTriangle()
|
||||
{
|
||||
|
||||
mBinIndex = -1;
|
||||
}
|
||||
|
||||
LLVolumeTriangle(const LLVolumeTriangle& rhs)
|
||||
@@ -64,9 +64,14 @@ public:
|
||||
U16 mIndex[3];
|
||||
|
||||
F32 mRadius;
|
||||
mutable S32 mBinIndex;
|
||||
|
||||
|
||||
virtual const LLVector4a& getPositionGroup() const;
|
||||
virtual const F32& getBinRadius() const;
|
||||
|
||||
S32 getBinIndex() const { return mBinIndex; }
|
||||
void setBinIndex(S32 idx) const { mBinIndex = idx; }
|
||||
};
|
||||
|
||||
class LLVolumeOctreeListener : public LLOctreeListener<LLVolumeTriangle>
|
||||
|
||||
@@ -113,6 +113,7 @@ void LLDrawable::init()
|
||||
|
||||
mGeneration = -1;
|
||||
mBinRadius = 1.f;
|
||||
mBinIndex = -1;
|
||||
mSpatialBridge = NULL;
|
||||
}
|
||||
|
||||
@@ -963,6 +964,12 @@ void LLDrawable::updateUVMinMax()
|
||||
{
|
||||
}
|
||||
|
||||
LLSpatialGroup* LLDrawable::getSpatialGroup() const
|
||||
{
|
||||
llassert((mSpatialGroupp == NULL) ? getBinIndex() == -1 : getBinIndex() != -1);
|
||||
return mSpatialGroupp;
|
||||
}
|
||||
|
||||
void LLDrawable::setSpatialGroup(LLSpatialGroup *groupp)
|
||||
{
|
||||
/*if (mSpatialGroupp && (groupp != mSpatialGroupp))
|
||||
@@ -985,6 +992,8 @@ void LLDrawable::setSpatialGroup(LLSpatialGroup *groupp)
|
||||
}
|
||||
|
||||
mSpatialGroupp = groupp;
|
||||
|
||||
llassert((mSpatialGroupp == NULL) ? getBinIndex() == -1 : getBinIndex() != -1);
|
||||
}
|
||||
|
||||
LLSpatialPartition* LLDrawable::getSpatialPartition()
|
||||
@@ -1107,6 +1116,8 @@ LLSpatialBridge::LLSpatialBridge(LLDrawable* root, BOOL render_by_group, U32 dat
|
||||
mDrawable = root;
|
||||
root->setSpatialBridge(this);
|
||||
|
||||
mBinIndex = -1;
|
||||
|
||||
mRenderType = mDrawable->mRenderType;
|
||||
mDrawableType = mDrawable->mRenderType;
|
||||
|
||||
@@ -1500,7 +1511,13 @@ void LLSpatialBridge::cleanupReferences()
|
||||
LLDrawable::cleanupReferences();
|
||||
if (mDrawable)
|
||||
{
|
||||
mDrawable->setSpatialGroup(NULL);
|
||||
LLSpatialGroup* group = mDrawable->getSpatialGroup();
|
||||
if (group)
|
||||
{
|
||||
group->mOctreeNode->remove(mDrawable);
|
||||
mDrawable->setSpatialGroup(NULL);
|
||||
}
|
||||
|
||||
if (mDrawable->getVObj())
|
||||
{
|
||||
LLViewerObject::const_child_list_t& child_list = mDrawable->getVObj()->getChildren();
|
||||
@@ -1511,7 +1528,12 @@ void LLSpatialBridge::cleanupReferences()
|
||||
LLDrawable* drawable = child->mDrawable;
|
||||
if (drawable)
|
||||
{
|
||||
drawable->setSpatialGroup(NULL);
|
||||
LLSpatialGroup* group = drawable->getSpatialGroup();
|
||||
if (group)
|
||||
{
|
||||
group->mOctreeNode->remove(drawable);
|
||||
drawable->setSpatialGroup(NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,6 +115,9 @@ public:
|
||||
F32 getIntensity() const { return llmin(mXform.getScale().mV[0], 4.f); }
|
||||
S32 getLOD() const { return mVObjp ? mVObjp->getLOD() : 1; }
|
||||
F32 getBinRadius() const { return mBinRadius; }
|
||||
S32 getBinIndex() const { return mBinIndex; }
|
||||
void setBinIndex(S32 index) const { mBinIndex = index; }
|
||||
|
||||
void getMinMax(LLVector3& min,LLVector3& max) const { mXform.getMinMax(min,max); }
|
||||
LLXformMatrix* getXform() { return &mXform; }
|
||||
|
||||
@@ -200,7 +203,7 @@ public:
|
||||
S32 findReferences(LLDrawable *drawablep); // Not const because of @#$! iterators...
|
||||
|
||||
void setSpatialGroup(LLSpatialGroup *groupp);
|
||||
LLSpatialGroup *getSpatialGroup() const { return mSpatialGroupp; }
|
||||
LLSpatialGroup *getSpatialGroup() const;
|
||||
LLSpatialPartition* getSpatialPartition();
|
||||
|
||||
// Statics
|
||||
@@ -321,6 +324,7 @@ private:
|
||||
mutable U32 mVisible;
|
||||
F32 mRadius;
|
||||
F32 mBinRadius;
|
||||
mutable S32 mBinIndex;
|
||||
S32 mGeneration;
|
||||
|
||||
LLVector3 mCurrentScale;
|
||||
|
||||
@@ -1209,19 +1209,25 @@ BOOL LLFace::getGeometryVolume(const LLVolume& volume,
|
||||
{
|
||||
if (num_indices + (S32) mIndicesIndex > mVertexBuffer->getNumIndices())
|
||||
{
|
||||
llwarns << "Index buffer overflow!" << llendl;
|
||||
llwarns << "Indices Count: " << mIndicesCount
|
||||
<< " VF Num Indices: " << num_indices
|
||||
<< " Indices Index: " << mIndicesIndex
|
||||
<< " VB Num Indices: " << mVertexBuffer->getNumIndices() << llendl;
|
||||
llwarns << " Face Index: " << f
|
||||
<< " Pool Type: " << mPoolType << llendl;
|
||||
if (gDebugGL)
|
||||
{
|
||||
llwarns << "Index buffer overflow!" << llendl;
|
||||
llwarns << "Indices Count: " << mIndicesCount
|
||||
<< " VF Num Indices: " << num_indices
|
||||
<< " Indices Index: " << mIndicesIndex
|
||||
<< " VB Num Indices: " << mVertexBuffer->getNumIndices() << llendl;
|
||||
llwarns << " Face Index: " << f
|
||||
<< " Pool Type: " << mPoolType << llendl;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (num_vertices + mGeomIndex > mVertexBuffer->getNumVerts())
|
||||
{
|
||||
llwarns << "Vertex buffer overflow!" << llendl;
|
||||
if (gDebugGL)
|
||||
{
|
||||
llwarns << "Vertex buffer overflow!" << llendl;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -424,7 +424,7 @@ void LLSpatialGroup::validate()
|
||||
|
||||
validateDrawMap();
|
||||
|
||||
for (element_iter i = getData().begin(); i != getData().end(); ++i)
|
||||
for (element_iter i = getDataBegin(); i != getDataEnd(); ++i)
|
||||
{
|
||||
LLDrawable* drawable = *i;
|
||||
sg_assert(drawable->getSpatialGroup() == this);
|
||||
@@ -640,7 +640,7 @@ BOOL LLSpatialGroup::boundObjects(BOOL empty, LLVector4a& minOut, LLVector4a& ma
|
||||
{
|
||||
const OctreeNode* node = mOctreeNode;
|
||||
|
||||
if (node->getData().empty())
|
||||
if (node->isEmpty())
|
||||
{ //don't do anything if there are no objects
|
||||
if (empty && mOctreeNode->getParent())
|
||||
{ //only root is allowed to be empty
|
||||
@@ -657,14 +657,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->getData().begin();
|
||||
OctreeNode::const_element_iter i = node->getDataBegin();
|
||||
LLDrawable* drawablep = *i;
|
||||
const LLVector4a* minMax = drawablep->getSpatialExtents();
|
||||
|
||||
newMin = minMax[0];
|
||||
newMax = minMax[1];
|
||||
|
||||
for (++i; i != node->getData().end(); ++i)
|
||||
for (++i; i != node->getDataEnd(); ++i)
|
||||
{
|
||||
drawablep = *i;
|
||||
minMax = drawablep->getSpatialExtents();
|
||||
@@ -1124,7 +1124,7 @@ void LLSpatialGroup::updateDistance(LLCamera &camera)
|
||||
llerrs << "Spatial group dirty on distance update." << llendl;
|
||||
}
|
||||
#endif
|
||||
if (!getData().empty() /*&& !LLSpatialPartition::sFreezeState*/)
|
||||
if (!isEmpty() /*&& !LLSpatialPartition::sFreezeState*/)
|
||||
{
|
||||
mRadius = mSpatialPartition->mRenderByGroup ? mObjectBounds[1].getLength3().getF32() :
|
||||
(F32) mOctreeNode->getSize().getLength3().getF32();
|
||||
@@ -1276,7 +1276,7 @@ void LLSpatialGroup::handleDestruction(const TreeNode* node)
|
||||
LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION);
|
||||
setState(DEAD);
|
||||
|
||||
for (element_iter i = getData().begin(); i != getData().end(); ++i)
|
||||
for (element_iter i = getDataBegin(); i != getDataEnd(); ++i)
|
||||
{
|
||||
LLDrawable* drawable = *i;
|
||||
if (drawable->getSpatialGroup() == this)
|
||||
@@ -1363,7 +1363,7 @@ void LLSpatialGroup::destroyGL(bool keep_occlusion)
|
||||
}
|
||||
|
||||
|
||||
for (LLSpatialGroup::element_iter i = getData().begin(); i != getData().end(); ++i)
|
||||
for (LLSpatialGroup::element_iter i = getDataBegin(); i != getDataEnd(); ++i)
|
||||
{
|
||||
LLDrawable* drawable = *i;
|
||||
for (S32 j = 0; j < drawable->getNumFaces(); j++)
|
||||
@@ -1720,12 +1720,14 @@ 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);
|
||||
|
||||
@@ -1996,7 +1998,7 @@ public:
|
||||
|
||||
virtual void processGroup(LLSpatialGroup* group)
|
||||
{
|
||||
llassert(!group->isState(LLSpatialGroup::DIRTY) && !group->getData().empty())
|
||||
llassert(!group->isState(LLSpatialGroup::DIRTY) && !group->isEmpty())
|
||||
|
||||
if (mRes < 2)
|
||||
{
|
||||
@@ -2063,7 +2065,7 @@ public:
|
||||
{
|
||||
LLSpatialGroup::OctreeNode* branch = group->mOctreeNode;
|
||||
|
||||
for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getData().begin(); i != branch->getData().end(); ++i)
|
||||
for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getDataBegin(); i != branch->getDataEnd(); ++i)
|
||||
{
|
||||
LLDrawable* drawable = *i;
|
||||
|
||||
@@ -2187,7 +2189,7 @@ public:
|
||||
LLSpatialGroup* group = (LLSpatialGroup*) state->getListener(0);
|
||||
group->destroyGL();
|
||||
|
||||
for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
|
||||
for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
|
||||
{
|
||||
LLDrawable* drawable = *i;
|
||||
if (drawable->getVObj().notNull() && !group->mSpatialPartition->mRenderByGroup)
|
||||
@@ -2500,7 +2502,7 @@ void renderOctree(LLSpatialGroup* group)
|
||||
gGL.flush();
|
||||
glLineWidth(1.f);
|
||||
gGL.flush();
|
||||
for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
|
||||
for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
|
||||
{
|
||||
LLDrawable* drawable = *i;
|
||||
if (!group->mSpatialPartition->isBridge())
|
||||
@@ -2546,7 +2548,7 @@ void renderOctree(LLSpatialGroup* group)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (group->mBufferUsage == GL_STATIC_DRAW_ARB && !group->getData().empty()
|
||||
if (group->mBufferUsage == GL_STATIC_DRAW_ARB && !group->isEmpty()
|
||||
&& group->mSpatialPartition->mRenderByGroup)
|
||||
{
|
||||
col.setVec(0.8f, 0.4f, 0.1f, 0.1f);
|
||||
@@ -2614,7 +2616,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->getData().empty();
|
||||
!group->isEmpty();
|
||||
|
||||
if (render_objects)
|
||||
{
|
||||
@@ -3356,7 +3358,7 @@ void renderPhysicsShape(LLDrawable* drawable, LLVOVolume* volume)
|
||||
|
||||
void renderPhysicsShapes(LLSpatialGroup* group)
|
||||
{
|
||||
for (LLSpatialGroup::OctreeNode::const_element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
|
||||
for (LLSpatialGroup::OctreeNode::const_element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
|
||||
{
|
||||
LLDrawable* drawable = *i;
|
||||
LLVOVolume* volume = drawable->getVOVolume();
|
||||
@@ -3601,7 +3603,7 @@ public:
|
||||
|
||||
LLVector3 center, size;
|
||||
|
||||
if (branch->getData().empty())
|
||||
if (branch->isEmpty())
|
||||
{
|
||||
gGL.diffuseColor3f(1.f,0.2f,0.f);
|
||||
center.set(branch->getCenter().getF32ptr());
|
||||
@@ -3637,8 +3639,8 @@ public:
|
||||
}
|
||||
|
||||
gGL.begin(LLRender::TRIANGLES);
|
||||
for (LLOctreeNode<LLVolumeTriangle>::const_element_iter iter = branch->getData().begin();
|
||||
iter != branch->getData().end();
|
||||
for (LLOctreeNode<LLVolumeTriangle>::const_element_iter iter = branch->getDataBegin();
|
||||
iter != branch->getDataEnd();
|
||||
++iter)
|
||||
{
|
||||
const LLVolumeTriangle* tri = *iter;
|
||||
@@ -3875,7 +3877,7 @@ public:
|
||||
|
||||
if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_BBOXES))
|
||||
{
|
||||
if (!group->getData().empty())
|
||||
if (!group->isEmpty())
|
||||
{
|
||||
gGL.diffuseColor3f(0,0,1);
|
||||
drawBoxOutline(group->mObjectBounds[0],
|
||||
@@ -3883,7 +3885,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getData().begin(); i != branch->getData().end(); ++i)
|
||||
for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getDataBegin(); i != branch->getDataEnd(); ++i)
|
||||
{
|
||||
LLDrawable* drawable = *i;
|
||||
|
||||
@@ -4068,7 +4070,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getData().begin(); i != branch->getData().end(); ++i)
|
||||
for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getDataBegin(); i != branch->getDataEnd(); ++i)
|
||||
{
|
||||
LLDrawable* drawable = *i;
|
||||
|
||||
@@ -4291,7 +4293,7 @@ public:
|
||||
|
||||
virtual void visit(const LLSpatialGroup::OctreeNode* branch)
|
||||
{
|
||||
for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getData().begin(); i != branch->getData().end(); ++i)
|
||||
for (LLSpatialGroup::OctreeNode::const_element_iter i = branch->getDataBegin(); i != branch->getDataEnd(); ++i)
|
||||
{
|
||||
check(*i);
|
||||
}
|
||||
|
||||
@@ -330,8 +330,13 @@ public:
|
||||
|
||||
void dirtyGeom() { setState(GEOM_DIRTY); }
|
||||
void dirtyMesh() { setState(MESH_DIRTY); }
|
||||
|
||||
//octree wrappers to make code more readable
|
||||
element_list& getData() { return mOctreeNode->getData(); }
|
||||
element_iter getDataBegin() { return mOctreeNode->getDataBegin(); }
|
||||
element_iter getDataEnd() { return mOctreeNode->getDataEnd(); }
|
||||
U32 getElementCount() const { return mOctreeNode->getElementCount(); }
|
||||
bool isEmpty() const { return mOctreeNode->isEmpty(); }
|
||||
|
||||
void drawObjectBox(LLColor4 col);
|
||||
|
||||
|
||||
@@ -645,7 +645,7 @@ void LLGrassPartition::addGeometryCount(LLSpatialGroup* group, U32& vertex_count
|
||||
mFaceList.clear();
|
||||
|
||||
LLViewerCamera* camera = LLViewerCamera::getInstance();
|
||||
for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
|
||||
for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
|
||||
{
|
||||
LLDrawable* drawablep = *i;
|
||||
|
||||
|
||||
@@ -582,7 +582,7 @@ void LLParticlePartition::addGeometryCount(LLSpatialGroup* group, U32& vertex_co
|
||||
mFaceList.clear();
|
||||
|
||||
LLViewerCamera* camera = LLViewerCamera::getInstance();
|
||||
for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
|
||||
for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
|
||||
{
|
||||
LLDrawable* drawablep = *i;
|
||||
|
||||
|
||||
@@ -2390,7 +2390,7 @@ U32 LLVOVolume::getRenderCost(texture_cost_t &textures) const
|
||||
produces_light = 1;
|
||||
}
|
||||
|
||||
for (S32 i = 0; i < num_faces; ++i)
|
||||
for (S32 i = 0; i < (S32)num_faces; ++i)
|
||||
{
|
||||
const LLFace* face = drawablep->getFace(i);
|
||||
if (!face) continue;
|
||||
@@ -3481,7 +3481,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
|
||||
LLFastTimer t(FTM_REBUILD_VOLUME_FACE_LIST);
|
||||
|
||||
//get all the faces into a list
|
||||
for (LLSpatialGroup::element_iter drawable_iter = group->getData().begin(); drawable_iter != group->getData().end(); ++drawable_iter)
|
||||
for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter)
|
||||
{
|
||||
LLDrawable* drawablep = *drawable_iter;
|
||||
|
||||
@@ -3887,7 +3887,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
|
||||
if (!LLPipeline::sDelayVBUpdate)
|
||||
{
|
||||
//drawables have been rebuilt, clear rebuild status
|
||||
for (LLSpatialGroup::element_iter drawable_iter = group->getData().begin(); drawable_iter != group->getData().end(); ++drawable_iter)
|
||||
for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter)
|
||||
{
|
||||
LLDrawable* drawablep = *drawable_iter;
|
||||
drawablep->clearState(LLDrawable::REBUILD_ALL);
|
||||
@@ -3927,7 +3927,7 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
|
||||
|
||||
std::set<LLVertexBuffer*> mapped_buffers;
|
||||
|
||||
for (LLSpatialGroup::element_iter drawable_iter = group->getData().begin(); drawable_iter != group->getData().end(); ++drawable_iter)
|
||||
for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter)
|
||||
{
|
||||
LLDrawable* drawablep = *drawable_iter;
|
||||
|
||||
@@ -3951,8 +3951,14 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
|
||||
if (buff)
|
||||
{
|
||||
llassert(!face->isState(LLFace::RIGGED));
|
||||
face->getGeometryVolume(*volume, face->getTEOffset(),
|
||||
vobj->getRelativeXform(), vobj->getRelativeXformInvTrans(), face->getGeomIndex());
|
||||
|
||||
if (!face->getGeometryVolume(*volume, face->getTEOffset(),
|
||||
vobj->getRelativeXform(), vobj->getRelativeXformInvTrans(), face->getGeomIndex()))
|
||||
{ //something's gone wrong with the vertex buffer accounting, rebuild this group
|
||||
group->dirtyGeom();
|
||||
gPipeline.markRebuild(group, TRUE);
|
||||
}
|
||||
|
||||
|
||||
if (buff->isLocked())
|
||||
{
|
||||
@@ -3993,7 +3999,7 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group)
|
||||
llwarns << "Not all mapped vertex buffers are unmapped!" << llendl ;
|
||||
warningsCount = 1;
|
||||
}
|
||||
for (LLSpatialGroup::element_iter drawable_iter = group->getData().begin(); drawable_iter != group->getData().end(); ++drawable_iter)
|
||||
for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter)
|
||||
{
|
||||
LLDrawable* drawablep = *drawable_iter;
|
||||
for (S32 i = 0; i < drawablep->getNumFaces(); ++i)
|
||||
@@ -4294,8 +4300,11 @@ void LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, std::
|
||||
|
||||
llassert(!facep->isState(LLFace::RIGGED));
|
||||
|
||||
facep->getGeometryVolume(*volume, te_idx,
|
||||
vobj->getRelativeXform(), vobj->getRelativeXformInvTrans(), index_offset,true);
|
||||
if (!facep->getGeometryVolume(*volume, te_idx,
|
||||
vobj->getRelativeXform(), vobj->getRelativeXformInvTrans(), index_offset,true))
|
||||
{
|
||||
llwarns << "Failed to get geometry for face!" << llendl;
|
||||
}
|
||||
|
||||
if (drawablep->isState(LLDrawable::ANIMATED_CHILD))
|
||||
{
|
||||
@@ -4464,7 +4473,7 @@ void LLGeometryManager::addGeometryCount(LLSpatialGroup* group, U32 &vertex_coun
|
||||
|
||||
//for each drawable
|
||||
|
||||
for (LLSpatialGroup::element_iter drawable_iter = group->getData().begin(); drawable_iter != group->getData().end(); ++drawable_iter)
|
||||
for (LLSpatialGroup::element_iter drawable_iter = group->getDataBegin(); drawable_iter != group->getDataEnd(); ++drawable_iter)
|
||||
{
|
||||
LLDrawable* drawablep = *drawable_iter;
|
||||
|
||||
|
||||
@@ -1174,7 +1174,7 @@ public:
|
||||
{
|
||||
LLSpatialGroup* group = (LLSpatialGroup*) node->getListener(0);
|
||||
|
||||
if (!group->isState(LLSpatialGroup::GEOM_DIRTY) && !group->getData().empty())
|
||||
if (!group->isState(LLSpatialGroup::GEOM_DIRTY) && !group->isEmpty())
|
||||
{
|
||||
for (LLSpatialGroup::draw_map_t::iterator i = group->mDrawMap.begin(); i != group->mDrawMap.end(); ++i)
|
||||
{
|
||||
@@ -1781,7 +1781,7 @@ void LLPipeline::clearReferences()
|
||||
|
||||
void check_references(LLSpatialGroup* group, LLDrawable* drawable)
|
||||
{
|
||||
for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
|
||||
for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
|
||||
{
|
||||
if (drawable == *i)
|
||||
{
|
||||
@@ -1803,7 +1803,7 @@ void check_references(LLDrawable* drawable, LLFace* face)
|
||||
|
||||
void check_references(LLSpatialGroup* group, LLFace* face)
|
||||
{
|
||||
for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
|
||||
for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
|
||||
{
|
||||
LLDrawable* drawable = *i;
|
||||
check_references(drawable, face);
|
||||
@@ -2179,7 +2179,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl
|
||||
|
||||
void LLPipeline::markNotCulled(LLSpatialGroup* group, LLCamera& camera)
|
||||
{
|
||||
if (group->getData().empty())
|
||||
if (group->isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -2827,7 +2827,7 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result)
|
||||
else
|
||||
{
|
||||
group->setVisible();
|
||||
for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
|
||||
for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
|
||||
{
|
||||
markVisible(*i, camera);
|
||||
}
|
||||
@@ -2915,7 +2915,7 @@ void LLPipeline::stateSort(LLSpatialGroup* group, LLCamera& camera)
|
||||
LLMemType mt(LLMemType::MTYPE_PIPELINE_STATE_SORT);
|
||||
if (!sSkipUpdate && group->changeLOD())
|
||||
{
|
||||
for (LLSpatialGroup::element_iter i = group->getData().begin(); i != group->getData().end(); ++i)
|
||||
for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
|
||||
{
|
||||
LLDrawable* drawablep = *i;
|
||||
stateSort(drawablep, camera);
|
||||
@@ -3051,7 +3051,7 @@ void forAllDrawables(LLCullResult::sg_iterator begin,
|
||||
{
|
||||
for (LLCullResult::sg_iterator i = begin; i != end; ++i)
|
||||
{
|
||||
for (LLSpatialGroup::element_iter j = (*i)->getData().begin(); j != (*i)->getData().end(); ++j)
|
||||
for (LLSpatialGroup::element_iter j = (*i)->getDataBegin(); j != (*i)->getDataEnd(); ++j)
|
||||
{
|
||||
func(*j);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user