summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authornyx@NyxTop <nyx@NyxTop>2009-10-29 15:13:27 -0400
committernyx@NyxTop <nyx@NyxTop>2009-10-29 15:13:27 -0400
commit65f534899740018b8efb662f8154030edb07fc0f (patch)
tree5a9697d4fb5a6004a80545804db11c51e1bdfc4c /indra
parentbc9808a01710ab21d60df3b6652b500f31f1c40e (diff)
EXT-1945 visual parameter animations broken
First round of fixes for trying to fix the visual param animations Code reviewed by Seraph
Diffstat (limited to 'indra')
-rw-r--r--indra/llcharacter/llvisualparam.cpp10
-rw-r--r--indra/llcharacter/llvisualparam.h6
-rw-r--r--indra/newview/llagentwearables.cpp11
-rw-r--r--indra/newview/llagentwearables.h2
-rw-r--r--indra/newview/lltexlayerparams.cpp17
-rw-r--r--indra/newview/lltexlayerparams.h1
-rw-r--r--indra/newview/llvoavatar.cpp47
-rw-r--r--indra/newview/llvoavatar.h5
-rw-r--r--indra/newview/llvoavatarself.cpp40
-rw-r--r--indra/newview/llvoavatarself.h2
-rw-r--r--indra/newview/llwearable.cpp11
-rw-r--r--indra/newview/llwearable.h1
12 files changed, 117 insertions, 36 deletions
diff --git a/indra/llcharacter/llvisualparam.cpp b/indra/llcharacter/llvisualparam.cpp
index 9e4957342c..6232c7588b 100644
--- a/indra/llcharacter/llvisualparam.cpp
+++ b/indra/llcharacter/llvisualparam.cpp
@@ -173,7 +173,8 @@ LLVisualParam::LLVisualParam()
mTargetWeight( 0.f ),
mIsAnimating( FALSE ),
mID( -1 ),
- mInfo( 0 )
+ mInfo( 0 ),
+ mIsDummy(FALSE)
{
}
@@ -251,6 +252,13 @@ void LLVisualParam::setWeight(F32 weight, BOOL set_by_user)
//-----------------------------------------------------------------------------
void LLVisualParam::setAnimationTarget(F32 target_value, BOOL set_by_user)
{
+ // don't animate dummy parameters
+ if (mIsDummy)
+ {
+ setWeight(target_value, set_by_user);
+ return;
+ }
+
if (mInfo)
{
if (getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE)
diff --git a/indra/llcharacter/llvisualparam.h b/indra/llcharacter/llvisualparam.h
index 0b516b9374..affc49debf 100644
--- a/indra/llcharacter/llvisualparam.h
+++ b/indra/llcharacter/llvisualparam.h
@@ -148,15 +148,19 @@ public:
LLVisualParam* getNextParam() { return mNext; }
void setNextParam( LLVisualParam *next );
- virtual void setAnimating(BOOL is_animating) { mIsAnimating = is_animating; }
+ virtual void setAnimating(BOOL is_animating) { mIsAnimating = is_animating && !mIsDummy; }
BOOL getAnimating() const { return mIsAnimating; }
+ void setIsDummy(BOOL is_self) { mIsDummy = is_self; }
+
protected:
F32 mCurWeight; // current weight
F32 mLastWeight; // last weight
LLVisualParam* mNext; // next param in a shared chain
F32 mTargetWeight; // interpolation target
BOOL mIsAnimating; // this value has been given an interpolation target
+ BOOL mIsDummy; // this is used to prevent dummy visual params from animating
+
S32 mID; // id for storing weight/morphtarget compares compactly
LLVisualParamInfo *mInfo;
diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp
index b9a0b4293d..d764dc4f3a 100644
--- a/indra/newview/llagentwearables.cpp
+++ b/indra/newview/llagentwearables.cpp
@@ -1985,6 +1985,17 @@ bool LLAgentWearables::canWearableBeRemoved(const LLWearable* wearable) const
return !(((type == WT_SHAPE) || (type == WT_SKIN) || (type == WT_HAIR) || (type == WT_EYES))
&& (getWearableCount(type) <= 1) );
}
+void LLAgentWearables::animateAllWearableParams(F32 delta, BOOL set_by_user)
+{
+ for( S32 type = 0; type < WT_COUNT; ++type )
+ {
+ for (S32 count = 0; count < getWearableCount((EWearableType)type); ++count)
+ {
+ LLWearable *wearable = getWearable((EWearableType)type,count);
+ wearable->animateParams(delta, set_by_user);
+ }
+ }
+}
void LLAgentWearables::updateServer()
{
diff --git a/indra/newview/llagentwearables.h b/indra/newview/llagentwearables.h
index 667cb94552..97de785c87 100644
--- a/indra/newview/llagentwearables.h
+++ b/indra/newview/llagentwearables.h
@@ -79,6 +79,8 @@ public:
// Note: False for shape, skin, eyes, and hair, unless you have MORE than 1.
bool canWearableBeRemoved(const LLWearable* wearable) const;
+
+ void animateAllWearableParams(F32 delta, BOOL set_by_user);
//--------------------------------------------------------------------
// Accessors
diff --git a/indra/newview/lltexlayerparams.cpp b/indra/newview/lltexlayerparams.cpp
index e1643af71d..74e0fa077e 100644
--- a/indra/newview/lltexlayerparams.cpp
+++ b/indra/newview/lltexlayerparams.cpp
@@ -42,8 +42,7 @@
//-----------------------------------------------------------------------------
LLTexLayerParam::LLTexLayerParam(LLTexLayerInterface *layer) :
mTexLayer(layer),
- mAvatar(NULL),
- mIsWearableParam(TRUE)
+ mAvatar(NULL)
{
if (mTexLayer != NULL)
{
@@ -56,8 +55,7 @@ LLTexLayerParam::LLTexLayerParam(LLTexLayerInterface *layer) :
}
LLTexLayerParam::LLTexLayerParam(LLVOAvatar *avatar) :
- mTexLayer(NULL),
- mIsWearableParam(FALSE)
+ mTexLayer(NULL)
{
mAvatar = avatar;
}
@@ -177,7 +175,7 @@ void LLTexLayerParamAlpha::setWeight(F32 weight, BOOL set_by_user)
{
mCurWeight = new_weight;
- if ((mAvatar->getSex() & getSex()) && !mIsWearableParam) // only trigger a baked texture update if we're changing a wearable's visual param.
+ if ((mAvatar->getSex() & getSex()) && (mAvatar->isSelf() && !mIsDummy)) // only trigger a baked texture update if we're changing a wearable's visual param.
{
if (gAgent.cameraCustomizeAvatar())
{
@@ -192,6 +190,13 @@ void LLTexLayerParamAlpha::setWeight(F32 weight, BOOL set_by_user)
void LLTexLayerParamAlpha::setAnimationTarget(F32 target_value, BOOL set_by_user)
{
+ // do not animate dummy parameters
+ if (mIsDummy)
+ {
+ setWeight(target_value, set_by_user);
+ return;
+ }
+
mTargetWeight = target_value;
setWeight(target_value, set_by_user);
mIsAnimating = TRUE;
@@ -468,7 +473,7 @@ void LLTexLayerParamColor::setWeight(F32 weight, BOOL set_by_user)
return;
}
- if ((mAvatar->getSex() & getSex()) && !mIsWearableParam) // only trigger a baked texture update if we're changing a wearable's visual param.
+ if ((mAvatar->getSex() & getSex()) && (mAvatar->isSelf() && !mIsDummy)) // only trigger a baked texture update if we're changing a wearable's visual param.
{
onGlobalColorChanged(set_by_user);
if (mTexLayer)
diff --git a/indra/newview/lltexlayerparams.h b/indra/newview/lltexlayerparams.h
index dcb108bbf6..98365864f9 100644
--- a/indra/newview/lltexlayerparams.h
+++ b/indra/newview/lltexlayerparams.h
@@ -49,7 +49,6 @@ public:
protected:
LLTexLayerInterface* mTexLayer;
LLVOAvatar* mAvatar;
- BOOL mIsWearableParam;
};
//-----------------------------------------------------------------------------
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index f9c95afc31..4bf66ba17e 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -2448,28 +2448,20 @@ void LLVOAvatar::idleUpdateAppearanceAnimation()
}
else
{
- F32 blend_frac = calc_bouncy_animation(appearance_anim_time / APPEARANCE_MORPH_TIME);
- F32 last_blend_frac = calc_bouncy_animation(mLastAppearanceBlendTime / APPEARANCE_MORPH_TIME);
- F32 morph_amt;
- if (last_blend_frac == 1.f)
- {
- morph_amt = 1.f;
- }
- else
- {
- morph_amt = (blend_frac - last_blend_frac) / (1.f - last_blend_frac);
- }
-
+ F32 morph_amt = calcMorphAmount();
LLVisualParam *param;
- // animate only top level params
- for (param = getFirstVisualParam();
- param;
- param = getNextVisualParam())
+ if (!isSelf())
{
- if (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE)
+ // animate only top level params for non-self avatars
+ for (param = getFirstVisualParam();
+ param;
+ param = getNextVisualParam())
{
- param->animate(morph_amt, mAppearanceAnimSetByUser);
+ if (param->getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE)
+ {
+ param->animate(morph_amt, mAppearanceAnimSetByUser);
+ }
}
}
@@ -2487,6 +2479,25 @@ void LLVOAvatar::idleUpdateAppearanceAnimation()
}
}
+F32 LLVOAvatar::calcMorphAmount()
+{
+ F32 appearance_anim_time = mAppearanceMorphTimer.getElapsedTimeF32();
+ F32 blend_frac = calc_bouncy_animation(appearance_anim_time / APPEARANCE_MORPH_TIME);
+ F32 last_blend_frac = calc_bouncy_animation(mLastAppearanceBlendTime / APPEARANCE_MORPH_TIME);
+
+ F32 morph_amt;
+ if (last_blend_frac == 1.f)
+ {
+ morph_amt = 1.f;
+ }
+ else
+ {
+ morph_amt = (blend_frac - last_blend_frac) / (1.f - last_blend_frac);
+ }
+
+ return morph_amt;
+}
+
void LLVOAvatar::idleUpdateLipSync(bool voice_enabled)
{
// Use the Lipsync_Ooh and Lipsync_Aah morphs for lip sync
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index e3add8aa78..f7c794defe 100644
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -205,7 +205,7 @@ public:
virtual BOOL updateCharacter(LLAgent &agent);
void idleUpdateVoiceVisualizer(bool voice_enabled);
void idleUpdateMisc(bool detailed_update);
- void idleUpdateAppearanceAnimation();
+ virtual void idleUpdateAppearanceAnimation();
void idleUpdateLipSync(bool voice_enabled);
void idleUpdateLoadingEffect();
void idleUpdateWindEffect();
@@ -250,6 +250,7 @@ protected:
virtual BOOL updateIsFullyLoaded();
BOOL processFullyLoadedChange(bool loading);
void updateRuthTimer(bool loading);
+ F32 calcMorphAmount();
private:
BOOL mFullyLoaded;
BOOL mPreviousFullyLoaded;
@@ -276,7 +277,7 @@ public:
protected:
static BOOL parseSkeletonFile(const std::string& filename);
void buildCharacter();
- BOOL loadAvatar();
+ virtual BOOL loadAvatar();
BOOL setupBone(const LLVOAvatarBoneInfo* info, LLViewerJoint* parent, S32 &current_volume_num, S32 &current_joint_num);
BOOL buildSkeleton(const LLVOAvatarSkeletonInfo *info);
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index 4760d5a472..758db538a2 100644
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -193,6 +193,25 @@ void LLVOAvatarSelf::markDead()
LLVOAvatar::markDead();
}
+/*virtual*/ BOOL LLVOAvatarSelf::loadAvatar()
+{
+ BOOL success = LLVOAvatar::loadAvatar();
+
+ // set all parameters sotred directly in the avatar to have
+ // the isSelfParam to be TRUE - this is used to prevent
+ // them from being animated or trigger accidental rebakes
+ // when we copy params from the wearable to the base avatar.
+ for (LLViewerVisualParam* param = (LLViewerVisualParam*) getFirstVisualParam();
+ param;
+ param = (LLViewerVisualParam*) getNextVisualParam())
+ {
+ param->setIsDummy(TRUE);
+ }
+
+ return success;
+}
+
+
BOOL LLVOAvatarSelf::loadAvatarSelf()
{
BOOL success = TRUE;
@@ -704,16 +723,23 @@ void LLVOAvatarSelf::updateVisualParams()
}
}
- LLWearable *shape = gAgentWearables.getWearable(WT_SHAPE,0);
- if (shape)
- {
- F32 gender = shape->getVisualParamWeight(80); // param 80 == gender
- setVisualParamWeight("male",gender ,TRUE);
- }
-
LLVOAvatar::updateVisualParams();
}
+/*virtual*/
+void LLVOAvatarSelf::idleUpdateAppearanceAnimation()
+{
+ // Animate all top-level wearable visual parameters
+ gAgentWearables.animateAllWearableParams(calcMorphAmount(), mAppearanceAnimSetByUser);
+
+ // apply wearable visual params to avatar
+ updateVisualParams();
+
+ //allow avatar to process updates
+ LLVOAvatar::idleUpdateAppearanceAnimation();
+
+}
+
// virtual
void LLVOAvatarSelf::requestStopMotion(LLMotion* motion)
{
diff --git a/indra/newview/llvoavatarself.h b/indra/newview/llvoavatarself.h
index a555d04a63..6e52b33634 100644
--- a/indra/newview/llvoavatarself.h
+++ b/indra/newview/llvoavatarself.h
@@ -57,6 +57,7 @@ public:
virtual void markDead();
virtual void initInstance(); // Called after construction to initialize the class.
protected:
+ /*virtual*/ BOOL loadAvatar();
BOOL loadAvatarSelf();
BOOL buildSkeletonSelf(const LLVOAvatarSkeletonInfo *info);
BOOL buildMenus();
@@ -89,6 +90,7 @@ public:
/*virtual*/ BOOL setVisualParamWeight(const char* param_name, F32 weight, BOOL set_by_user = FALSE );
/*virtual*/ BOOL setVisualParamWeight(S32 index, F32 weight, BOOL set_by_user = FALSE );
/*virtual*/ void updateVisualParams();
+ /*virtual*/ void idleUpdateAppearanceAnimation();
private:
// helper function. Passed in param is assumed to be in avatar's parameter list.
diff --git a/indra/newview/llwearable.cpp b/indra/newview/llwearable.cpp
index d70b3a26a9..ebb9b0c13d 100644
--- a/indra/newview/llwearable.cpp
+++ b/indra/newview/llwearable.cpp
@@ -921,6 +921,17 @@ void LLWearable::getVisualParams(visual_param_vec_t &list)
}
}
+void LLWearable::animateParams(F32 delta, BOOL set_by_user)
+{
+ for(visual_param_index_map_t::iterator iter = mVisualParamIndexMap.begin();
+ iter != mVisualParamIndexMap.end();
+ ++iter)
+ {
+ LLVisualParam *param = (LLVisualParam*) iter->second;
+ param->animate(delta, set_by_user);
+ }
+}
+
LLColor4 LLWearable::getClothesColor(S32 te) const
{
LLColor4 color;
diff --git a/indra/newview/llwearable.h b/indra/newview/llwearable.h
index 01bd9652a5..96631811c5 100644
--- a/indra/newview/llwearable.h
+++ b/indra/newview/llwearable.h
@@ -119,6 +119,7 @@ public:
F32 getVisualParamWeight(S32 index) const;
LLVisualParam* getVisualParam(S32 index) const;
void getVisualParams(visual_param_vec_t &list);
+ void animateParams(F32 delta, BOOL set_by_user);
LLColor4 getClothesColor(S32 te) const;
void setClothesColor( S32 te, const LLColor4& new_color, BOOL set_by_user );