diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index a7378b093c..9c0205765b 100755
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -166,8 +166,6 @@ void LLFace::init(LLDrawable* drawablep, LLViewerObject* objp)
mBoundingSphereRadius = 0.0f ;
mHasMedia = FALSE ;
-
- mParticleGeneration = 0; // Default = no particle
}
void LLFace::destroy()
@@ -185,14 +183,9 @@ void LLFace::destroy()
}
}
- // Make sure we released any allocated VB index if this was a particle
- // if (isState(LLFace::PARTICLE))
- if (isState(LLFace::PARTICLE) || mParticleGeneration )
- //
+ if (isState(LLFace::PARTICLE))
{
- LLVOPartGroup::freeVBSlot(getGeomIndex()/4,mParticleGeneration);
- mParticleGeneration = 0;
-
+ LLVOPartGroup::freeVBSlot(getGeomIndex()/4);
clearState(LLFace::PARTICLE);
}
@@ -421,16 +414,8 @@ void LLFace::setSize(S32 num_vertices, S32 num_indices, bool align)
llassert(verify());
}
-// Pass another flag to mark this index as from LLVOPartGroup, in that case it needs to be freed with LLVOPartGroup::LLVOPartGroup
-// void LLFace::setGeomIndex(U16 idx)
-void LLFace::setGeomIndex(U16 idx, U32 aParticleGeneration )
-//
+void LLFace::setGeomIndex(U16 idx)
{
- if( mParticleGeneration && mGeomIndex != idx )
- LLVOPartGroup::freeVBSlot(getGeomIndex()/4,mParticleGeneration);
-
- mParticleGeneration = aParticleGeneration;
-
if (mGeomIndex != idx)
{
mGeomIndex = idx;
diff --git a/indra/newview/llface.h b/indra/newview/llface.h
index b780322823..d3a561facc 100755
--- a/indra/newview/llface.h
+++ b/indra/newview/llface.h
@@ -207,11 +207,7 @@ public:
BOOL verify(const U32* indices_array = NULL) const;
void printDebugInfo() const;
- // Pass another flag to mark this index as from LLVOPartGroup, in that case it needs to be freed with LLVOPartGroup::LLVOPartGroup
- // void setGeomIndex(U16 idx);
- void setGeomIndex(U16 idx, U32 aParticleGeneration = 0);
- //
-
+ void setGeomIndex(U16 idx);
void setIndicesIndex(S32 idx);
void setDrawInfo(LLDrawInfo* draw_info);
@@ -363,9 +359,6 @@ public:
lhs->getTexture() < rhs->getTexture();
}
};
-
-private:
- U32 mParticleGeneration;
};
#endif // LL_LLFACE_H
diff --git a/indra/newview/llviewerpartsim.cpp b/indra/newview/llviewerpartsim.cpp
index 73f85c161d..f7eb7df46c 100755
--- a/indra/newview/llviewerpartsim.cpp
+++ b/indra/newview/llviewerpartsim.cpp
@@ -284,36 +284,16 @@ void LLViewerPartGroup::updateParticles(const F32 lastdt)
LLViewerCamera* camera = LLViewerCamera::getInstance();
LLViewerRegion *regionp = getRegion();
S32 end = (S32) mParticles.size();
-
- // Instead of walking the current particles back to front, we first make a copy, then sort by adress and refill mParticles as needed.
- mParticlesTemp.swap( mParticles );
- mParticles.erase( mParticles.begin(), mParticles.end() );
- std::sort( mParticlesTemp.begin(), mParticlesTemp.end() );
-
- // for (S32 i = 0 ; i < (S32)mParticles.size(); )
- for (S32 i = 0 ; i < (S32)mParticlesTemp.size(); ++i )
- //
+ for (S32 i = 0 ; i < (S32)mParticles.size();)
{
- // LLVector3 a(0.f, 0.f, 0.f); // Unused
- LLViewerPart* part = mParticlesTemp[i] ;
+ LLVector3 a(0.f, 0.f, 0.f);
+ LLViewerPart* part = mParticles[i] ;
dt = lastdt + mSkippedTime - part->mSkipOffset;
part->mSkipOffset = 0.f;
// Update current time
const F32 cur_time = part->mLastUpdateTime + dt;
-
- // Bail out as soon as possible to avoid all the complicated work down.
- if( cur_time > part->mMaxAge || LLViewerPart::LL_PART_DEAD_MASK == part->mFlags )
- {
- if (part->mVPCallback)
- (*part->mVPCallback)(*part, dt);
-
- delete part ;
- continue;
- }
- //
-
const F32 frac = cur_time / part->mMaxAge;
// "Drift" the object based on the source object
@@ -417,34 +397,26 @@ void LLViewerPartGroup::updateParticles(const F32 lastdt)
part->mLastUpdateTime = cur_time;
- // We did that above
// Kill dead particles (either flagged dead, or too old)
- // if ((part->mLastUpdateTime > part->mMaxAge) || (LLViewerPart::LL_PART_DEAD_MASK == part->mFlags))
- // {
- // mParticles[i] = mParticles.back() ;
- // mParticles.pop_back() ;
- // delete part ;
- // }
- // else
- //
+ if ((part->mLastUpdateTime > part->mMaxAge) || (LLViewerPart::LL_PART_DEAD_MASK == part->mFlags))
+ {
+ mParticles[i] = mParticles.back() ;
+ mParticles.pop_back() ;
+ delete part ;
+ }
+ else
{
F32 desired_size = calc_desired_size(camera, part->mPosAgent, part->mScale);
if (!posInGroup(part->mPosAgent, desired_size))
{
// Transfer particles between groups
LLViewerPartSim::getInstance()->put(part) ;
-
- // No need for any transfer, just to not add to mParticles.
- // mParticles[i] = mParticles.back() ;
- // mParticles.pop_back() ;
- //
+ mParticles[i] = mParticles.back() ;
+ mParticles.pop_back() ;
}
else
{
- // Keep current particle in this group.
- // i++ ;
- mParticles.push_back( part );
- //
+ i++ ;
}
}
}
@@ -920,76 +892,3 @@ void LLViewerPartSim::clearParticlesByOwnerID(const LLUUID& task_id)
}
}
-// Object pool for LLViewerPart
-U8 *sParts;
-U8 *sPartsEnd;
-U32 sFree[ LL_MAX_PARTICLE_COUNT/32 ];
-U32 sPartSize;
-
-S32 findFreeIndex()
-{
- for( int i = 0; i < LL_MAX_PARTICLE_COUNT/32; ++i )
- {
- if( sFree[i] )
- {
- U32 val = sFree[i];
- U32 mask = 1;
- int j(0);
- for( j = 0; j < 32; ++j )
- {
- if( mask & val )
- {
- mask = ~mask;
- break;
- }
-
- mask <<= 1;
- }
-
- sFree[ i ] = val & mask;
- return i*32+j;
- }
- }
- return -1;
-}
-
-void* LLViewerPart::operator new(size_t size)
-{
- if( !sParts )
- {
- sPartSize = sizeof( LLViewerPart );
- sPartSize += 0xF;
- sPartSize &= ~0xF;
- sParts = reinterpret_cast( ll_aligned_malloc<16>( sPartSize * LL_MAX_PARTICLE_COUNT ) );
- for( int i = 0; i < LL_MAX_PARTICLE_COUNT/32; ++i )
- sFree[ i ] = 0xFFFFFFFF;
-
- sPartsEnd = sParts + sPartSize * LL_MAX_PARTICLE_COUNT;
- }
-
- S32 i = findFreeIndex();
- if( i < 0 )
- return new char[ size ];
-
- return reinterpret_cast< void* >( sParts + sPartSize*i );
-}
-
-void LLViewerPart::operator delete(void* ptr)
-{
- if( ptr < sParts || ptr >= sPartsEnd )
- {
- delete [] (char*)ptr;
- return;
- }
-
- U32 diff = static_cast( reinterpret_cast(ptr) - sParts );
- diff /= sPartSize;
-
- U32 i = (diff & ~0x0000001F) / 32;
- U32 j = diff & 0x0000001F;
-
- U32 mask = 1 << j;
-
- sFree[ i ] |= mask;
-}
-//
diff --git a/indra/newview/llviewerpartsim.h b/indra/newview/llviewerpartsim.h
index 501fe9b24b..40e8e1d45d 100755
--- a/indra/newview/llviewerpartsim.h
+++ b/indra/newview/llviewerpartsim.h
@@ -81,10 +81,6 @@ public:
static U32 sNextPartID;
- // Object pool for LLViewerPart
- void* operator new(size_t size);
- void operator delete(void* ptr);
- //
};
@@ -112,7 +108,6 @@ public:
typedef std::vector part_list_t;
part_list_t mParticles;
- part_list_t mParticlesTemp; // Temporary list for iteration in updateParticles
const LLVector3 &getCenterAgent() const { return mCenterAgent; }
S32 getCount() const { return (S32) mParticles.size(); }
diff --git a/indra/newview/llvopartgroup.cpp b/indra/newview/llvopartgroup.cpp
index 27d54c58e5..f90d827827 100755
--- a/indra/newview/llvopartgroup.cpp
+++ b/indra/newview/llvopartgroup.cpp
@@ -50,8 +50,6 @@ extern U64MicrosecondsImplicit gFrameTime;
LLPointer LLVOPartGroup::sVB = NULL;
S32 LLVOPartGroup::sVBSlotCursor = 0;
-U32 sFreeIndex[LL_MAX_PARTICLE_COUNT/32] = {0};
-U32 sIndexGeneration = 1;
void LLVOPartGroup::initClass()
{
@@ -61,11 +59,6 @@ void LLVOPartGroup::initClass()
//static
void LLVOPartGroup::restoreGL()
{
- sIndexGeneration += 2;
-
- for( int i = 0; i < LL_MAX_PARTICLE_COUNT/32; ++i )
- sFreeIndex[i] = 0xFFFFFFFF;
-
//TODO: optimize out binormal mask here. Specular and normal coords as well.
sVB = new LLVertexBuffer(VERTEX_DATA_MASK | LLVertexBuffer::MAP_TANGENT | LLVertexBuffer::MAP_TEXCOORD1 | LLVertexBuffer::MAP_TEXCOORD2, GL_STREAM_DRAW_ARB);
@@ -125,37 +118,12 @@ void LLVOPartGroup::destroyGL()
//static
S32 LLVOPartGroup::findAvailableVBSlot()
{
- for( int i = 0; i < LL_MAX_PARTICLE_COUNT/32; ++i )
- {
- if( sFreeIndex[i] != 0 )
- {
- U32 val = sFreeIndex[i];
- U32 mask = 1;
- int j(0);
- for( j = 0; j < 32; ++j )
- {
- if( mask & val )
- {
- mask = ~mask;
- break;
- }
-
- mask <<= 1;
- }
-
- sFreeIndex[ i ] = val & mask;
- return i*32+j;
- }
+ if (sVBSlotCursor >= LL_MAX_PARTICLE_COUNT)
+ { //no more available slots
+ return -1;
}
- return -1;
-
-// if (sVBSlotCursor >= LL_MAX_PARTICLE_COUNT)
-// { //no more available slots
-// return -1;
-// }
-//
-// return sVBSlotCursor++;
+ return sVBSlotCursor++;
}
bool ll_is_part_idx_allocated(S32 idx, S32* start, S32* end)
@@ -174,8 +142,7 @@ bool ll_is_part_idx_allocated(S32 idx, S32* start, S32* end)
}
//static
-// void LLVOPartGroup::freeVBSlot(S32 idx)
-void LLVOPartGroup::freeVBSlot(S32 idx, U32 generation )
+void LLVOPartGroup::freeVBSlot(S32 idx)
{
/*llassert(idx < LL_MAX_PARTICLE_COUNT && idx >= 0);
//llassert(sVBSlotCursor > sVBSlotFree);
@@ -186,16 +153,6 @@ void LLVOPartGroup::freeVBSlot(S32 idx, U32 generation )
sVBSlotCursor--;
*sVBSlotCursor = idx;
}*/
-
- if( sIndexGeneration != generation || idx < 0 || idx >= LL_MAX_PARTICLE_COUNT )
- return;
-
- U32 i = (idx & ~0x0000001F) / 32;
- U32 j = idx & 0x0000001F;
-
- U32 mask = 1 << j;
-
- sFreeIndex[ i ] |= mask;
}
LLVOPartGroup::LLVOPartGroup(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp)
@@ -912,11 +869,7 @@ void LLParticlePartition::getGeometry(LLSpatialGroup* group)
S32 idx = LLVOPartGroup::findAvailableVBSlot();
if (idx >= 0)
{
- // Face needs to release the index when it gets destroyed.
- // facep->setGeomIndex(idx*4);
- facep->setGeomIndex(idx*4, sIndexGeneration);
- //
-
+ facep->setGeomIndex(idx*4);
facep->setIndicesIndex(idx*6);
facep->setVertexBuffer(LLVOPartGroup::sVB);
facep->setPoolType(LLDrawPool::POOL_ALPHA);
diff --git a/indra/newview/llvopartgroup.h b/indra/newview/llvopartgroup.h
index e245a2bc16..2ef8b1c848 100755
--- a/indra/newview/llvopartgroup.h
+++ b/indra/newview/llvopartgroup.h
@@ -48,9 +48,7 @@ public:
static void restoreGL();
static void destroyGL();
static S32 findAvailableVBSlot();
-
- // static void freeVBSlot(S32 idx);
- static void freeVBSlot(S32 idx, U32 generation);
+ static void freeVBSlot(S32 idx);
enum
{