summaryrefslogtreecommitdiff
path: root/indra/newview/llflexibleobject.cpp
diff options
context:
space:
mode:
authorOz Linden <oz@lindenlab.com>2012-09-11 08:47:33 -0400
committerOz Linden <oz@lindenlab.com>2012-09-11 08:47:33 -0400
commit5eb6614913b97963d185afe698e677c880399c78 (patch)
treec7e342b7b68192fc0eb4eba09ef52c17ac16ffa5 /indra/newview/llflexibleobject.cpp
parent8189b28d2247bf99f76ace63e78021a43b5e15a1 (diff)
parent2aadccd30843f3a29882d13ed2db50cebcba0374 (diff)
merge changes for DRTVWR-212
Diffstat (limited to 'indra/newview/llflexibleobject.cpp')
-rw-r--r--indra/newview/llflexibleobject.cpp130
1 files changed, 65 insertions, 65 deletions
diff --git a/indra/newview/llflexibleobject.cpp b/indra/newview/llflexibleobject.cpp
index 9745bb6d64..3d64ceb71d 100644
--- a/indra/newview/llflexibleobject.cpp
+++ b/indra/newview/llflexibleobject.cpp
@@ -65,7 +65,7 @@ LLVolumeImplFlexible::LLVolumeImplFlexible(LLViewerObject* vo, LLFlexibleObjectD
mFrameNum = 0;
mCollisionSphereRadius = 0.f;
mRenderRes = 1;
-
+
if(mVO->mDrawable.notNull())
{
mVO->mDrawable->makeActive() ;
@@ -255,28 +255,50 @@ void LLVolumeImplFlexible::onSetVolume(const LLVolumeParams &volume_params, cons
{
}
-
-void LLVolumeImplFlexible::updateRenderRes()
+//---------------------------------------------------------------------------------
+// This calculates the physics of the flexible object. Note that it has to be 0
+// updated every time step. In the future, perhaps there could be an
+// optimization similar to what Havok does for objects that are stationary.
+//---------------------------------------------------------------------------------
+static LLFastTimer::DeclareTimer FTM_FLEXIBLE_UPDATE("Update Flexies");
+BOOL LLVolumeImplFlexible::doIdleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
{
- LLDrawable* drawablep = mVO->mDrawable;
+ if (mVO->mDrawable.isNull())
+ {
+ // Don't do anything until we have a drawable
+ return FALSE; // (we are not initialized or updated)
+ }
- S32 new_res = mAttributes->getSimulateLOD();
+ BOOL force_update = mSimulateRes == 0 ? TRUE : FALSE;
-#if 1 //optimal approximation of previous behavior that doesn't rely on atan2
- F32 app_angle = mVO->getScale().mV[2]/drawablep->mDistanceWRTCamera;
+ //flexible objects never go static
+ mVO->mDrawable->mQuietCount = 0;
+ if (!mVO->mDrawable->isRoot())
+ {
+ LLViewerObject* parent = (LLViewerObject*) mVO->getParent();
+ parent->mDrawable->mQuietCount = 0;
+ }
+
+ LLFastTimer ftm(FTM_FLEXIBLE_UPDATE);
+
+ S32 new_res = mAttributes->getSimulateLOD();
- // Rendering sections increases with visible angle on the screen
- mRenderRes = (S32) (12.f*app_angle);
-#else //legacy behavior
//number of segments only cares about z axis
- F32 app_angle = llround((F32) atan2( mVO->getScale().mV[2]*2.f, drawablep->mDistanceWRTCamera) * RAD_TO_DEG, 0.01f);
+ F32 app_angle = llround((F32) atan2( mVO->getScale().mV[2]*2.f, mVO->mDrawable->mDistanceWRTCamera) * RAD_TO_DEG, 0.01f);
- // Rendering sections increases with visible angle on the screen
+ // Rendering sections increases with visible angle on the screen
mRenderRes = (S32)(FLEXIBLE_OBJECT_MAX_SECTIONS*4*app_angle*DEG_TO_RAD/LLViewerCamera::getInstance()->getView());
-#endif
-
- mRenderRes = llclamp(mRenderRes, new_res-1, (S32) FLEXIBLE_OBJECT_MAX_SECTIONS);
-
+ if (mRenderRes > FLEXIBLE_OBJECT_MAX_SECTIONS)
+ {
+ mRenderRes = FLEXIBLE_OBJECT_MAX_SECTIONS;
+ }
+
+
+ // Bottom cap at 1/4 the original number of sections
+ if (mRenderRes < mAttributes->getSimulateLOD()-1)
+ {
+ mRenderRes = mAttributes->getSimulateLOD()-1;
+ }
// Throttle back simulation of segments we're not rendering
if (mRenderRes < new_res)
{
@@ -289,65 +311,43 @@ void LLVolumeImplFlexible::updateRenderRes()
setAttributesOfAllSections();
mInitialized = TRUE;
}
-}
-//---------------------------------------------------------------------------------
-// This calculates the physics of the flexible object. Note that it has to be 0
-// updated every time step. In the future, perhaps there could be an
-// 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)
-{
- LLDrawable* drawablep = mVO->mDrawable;
+ if (!gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_FLEXIBLE))
+ {
+ return FALSE; // (we are not initialized or updated)
+ }
+
+ bool visible = mVO->mDrawable->isVisible();
- if (drawablep)
+ if (force_update && visible)
+ {
+ gPipeline.markRebuild(mVO->mDrawable, LLDrawable::REBUILD_POSITION, FALSE);
+ }
+ else if (visible &&
+ !mVO->mDrawable->isState(LLDrawable::IN_REBUILD_Q1) &&
+ mVO->getPixelArea() > 256.f)
{
- //LLFastTimer ftm(FTM_FLEXIBLE_UPDATE);
+ U32 id;
+ F32 pixel_area = mVO->getPixelArea();
- //flexible objects never go static
- drawablep->mQuietCount = 0;
- if (!drawablep->isRoot())
+ if (mVO->isRootEdit())
{
- LLViewerObject* parent = (LLViewerObject*) mVO->getParent();
- parent->mDrawable->mQuietCount = 0;
+ id = mID;
}
-
- if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_FLEXIBLE))
+ else
{
- bool visible = drawablep->isVisible();
-
- if ((mSimulateRes == 0) && visible)
- {
- updateRenderRes();
- gPipeline.markRebuild(drawablep, LLDrawable::REBUILD_POSITION, FALSE);
- }
- else if (visible &&
- !drawablep->isState(LLDrawable::IN_REBUILD_Q1) &&
- mVO->getPixelArea() > 256.f)
- {
- U32 id;
- F32 pixel_area = mVO->getPixelArea();
-
- if (mVO->isRootEdit())
- {
- id = mID;
- }
- else
- {
- LLVOVolume* parent = (LLVOVolume*) mVO->getParent();
- id = parent->getVolumeInterfaceID();
- }
+ LLVOVolume* parent = (LLVOVolume*) mVO->getParent();
+ id = parent->getVolumeInterfaceID();
+ }
- U32 update_period = (U32) (LLViewerCamera::getInstance()->getScreenPixelArea()*0.01f/(pixel_area*(sUpdateFactor+1.f)))+1;
+ 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);
- }
- }
+ if ((LLDrawable::getCurrentFrame()+id)%update_period == 0)
+ {
+ gPipeline.markRebuild(mVO->mDrawable, LLDrawable::REBUILD_POSITION, FALSE);
}
}
+
+ return force_update;
}
inline S32 log2(S32 x)