summaryrefslogtreecommitdiff
path: root/indra/newview/llflexibleobject.cpp
diff options
context:
space:
mode:
authorOz Linden <oz@lindenlab.com>2012-08-14 09:01:56 -0400
committerOz Linden <oz@lindenlab.com>2012-08-14 09:01:56 -0400
commit24c1b62e27e066dc62e7681593ce7c93ee84d5a8 (patch)
tree76d5b8a1c4eb43073e85156d74e8f3eac11dfe74 /indra/newview/llflexibleobject.cpp
parent2c2167229eac3efd7e7b1c5eafde8ee2e66184cd (diff)
parent337976096530729a7d671df68907cd59a7986972 (diff)
merge back beta fixes
Diffstat (limited to 'indra/newview/llflexibleobject.cpp')
-rw-r--r--indra/newview/llflexibleobject.cpp100
1 files changed, 74 insertions, 26 deletions
diff --git a/indra/newview/llflexibleobject.cpp b/indra/newview/llflexibleobject.cpp
index 9745bb6d64..56dc0b4157 100644
--- a/indra/newview/llflexibleobject.cpp
+++ b/indra/newview/llflexibleobject.cpp
@@ -44,6 +44,8 @@
#include "llvoavatar.h"
/*static*/ F32 LLVolumeImplFlexible::sUpdateFactor = 1.0f;
+std::vector<LLVolumeImplFlexible*> LLVolumeImplFlexible::sInstanceList;
+std::vector<S32> LLVolumeImplFlexible::sUpdateDelay;
static LLFastTimer::DeclareTimer FTM_FLEXIBLE_REBUILD("Rebuild");
static LLFastTimer::DeclareTimer FTM_DO_FLEXIBLE_UPDATE("Update");
@@ -70,8 +72,45 @@ LLVolumeImplFlexible::LLVolumeImplFlexible(LLViewerObject* vo, LLFlexibleObjectD
{
mVO->mDrawable->makeActive() ;
}
+
+ mInstanceIndex = sInstanceList.size();
+ sInstanceList.push_back(this);
+ sUpdateDelay.push_back(0);
}//-----------------------------------------------
+LLVolumeImplFlexible::~LLVolumeImplFlexible()
+{
+ S32 end_idx = sInstanceList.size()-1;
+
+ if (end_idx != mInstanceIndex)
+ {
+ sInstanceList[mInstanceIndex] = sInstanceList[end_idx];
+ sInstanceList[mInstanceIndex]->mInstanceIndex = mInstanceIndex;
+ sUpdateDelay[mInstanceIndex] = sUpdateDelay[end_idx];
+ }
+
+ sInstanceList.pop_back();
+ sUpdateDelay.pop_back();
+}
+
+//static
+void LLVolumeImplFlexible::updateClass()
+{
+ std::vector<S32>::iterator delay_iter = sUpdateDelay.begin();
+
+ for (std::vector<LLVolumeImplFlexible*>::iterator iter = sInstanceList.begin();
+ iter != sInstanceList.end();
+ ++iter)
+ {
+ --(*delay_iter);
+ if (*delay_iter <= 0)
+ {
+ (*iter)->doIdleUpdate();
+ }
+ ++delay_iter;
+ }
+}
+
LLVector3 LLVolumeImplFlexible::getFramePosition() const
{
return mVO->getRenderPosition();
@@ -296,22 +335,17 @@ void LLVolumeImplFlexible::updateRenderRes()
// optimization similar to what Havok does for objects that are stationary.
//---------------------------------------------------------------------------------
static LLFastTimer::DeclareTimer FTM_FLEXIBLE_UPDATE("Update Flexies");
-void LLVolumeImplFlexible::doIdleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
+void LLVolumeImplFlexible::doIdleUpdate()
{
LLDrawable* drawablep = mVO->mDrawable;
if (drawablep)
{
//LLFastTimer ftm(FTM_FLEXIBLE_UPDATE);
-
- //flexible objects never go static
- drawablep->mQuietCount = 0;
- if (!drawablep->isRoot())
- {
- LLViewerObject* parent = (LLViewerObject*) mVO->getParent();
- parent->mDrawable->mQuietCount = 0;
- }
-
+
+ //ensure drawable is active
+ drawablep->makeActive();
+
if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_FLEXIBLE))
{
bool visible = drawablep->isVisible();
@@ -321,31 +355,45 @@ void LLVolumeImplFlexible::doIdleUpdate(LLAgent &agent, LLWorld &world, const F6
updateRenderRes();
gPipeline.markRebuild(drawablep, LLDrawable::REBUILD_POSITION, FALSE);
}
- else if (visible &&
- !drawablep->isState(LLDrawable::IN_REBUILD_Q1) &&
- mVO->getPixelArea() > 256.f)
+ else
{
- U32 id;
F32 pixel_area = mVO->getPixelArea();
- if (mVO->isRootEdit())
+ U32 update_period = (U32) (LLViewerCamera::getInstance()->getScreenPixelArea()*0.01f/(pixel_area*(sUpdateFactor+1.f)))+1;
+
+ if (visible)
{
- id = mID;
+ if (!drawablep->isState(LLDrawable::IN_REBUILD_Q1) &&
+ mVO->getPixelArea() > 256.f)
+ {
+ U32 id;
+
+ if (mVO->isRootEdit())
+ {
+ id = mID;
+ }
+ else
+ {
+ LLVOVolume* parent = (LLVOVolume*) mVO->getParent();
+ id = parent->getVolumeInterfaceID();
+ }
+
+ if ((LLDrawable::getCurrentFrame()+id)%update_period == 0)
+ {
+ sUpdateDelay[mInstanceIndex] = (S32) update_period-1;
+
+ updateRenderRes();
+
+ gPipeline.markRebuild(drawablep, LLDrawable::REBUILD_POSITION, FALSE);
+ }
+ }
}
else
{
- LLVOVolume* parent = (LLVOVolume*) mVO->getParent();
- id = parent->getVolumeInterfaceID();
- }
-
- U32 update_period = (U32) (LLViewerCamera::getInstance()->getScreenPixelArea()*0.01f/(pixel_area*(sUpdateFactor+1.f)))+1;
-
- if ((LLDrawable::getCurrentFrame()+id)%update_period == 0)
- {
- updateRenderRes();
- gPipeline.markRebuild(drawablep, LLDrawable::REBUILD_POSITION, FALSE);
+ sUpdateDelay[mInstanceIndex] = (S32) update_period;
}
}
+
}
}
}