summaryrefslogtreecommitdiff
path: root/indra/llcharacter/llvisualparam.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcharacter/llvisualparam.cpp')
-rwxr-xr-x[-rw-r--r--]indra/llcharacter/llvisualparam.cpp137
1 files changed, 97 insertions, 40 deletions
diff --git a/indra/llcharacter/llvisualparam.cpp b/indra/llcharacter/llvisualparam.cpp
index c4763c6331..2235496ac5 100644..100755
--- a/indra/llcharacter/llvisualparam.cpp
+++ b/indra/llcharacter/llvisualparam.cpp
@@ -2,31 +2,25 @@
* @file llvisualparam.cpp
* @brief Implementation of LLPolyMesh class.
*
- * $LicenseInfo:firstyear=2001&license=viewergpl$
- *
- * Copyright (c) 2001-2009, Linden Research, Inc.
- *
+ * $LicenseInfo:firstyear=2001&license=viewerlgpl$
* Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * Copyright (C) 2010, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
*
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -85,7 +79,7 @@ BOOL LLVisualParamInfo::parseXml(LLXmlTreeNode *node)
mDefaultWeight = llclamp( default_weight, mMinWeight, mMaxWeight );
if( default_weight != mDefaultWeight )
{
- llwarns << "value_default attribute is out of range in node " << mName << " " << default_weight << llendl;
+ LL_WARNS() << "value_default attribute is out of range in node " << mName << " " << default_weight << LL_ENDL;
}
}
@@ -107,7 +101,7 @@ BOOL LLVisualParamInfo::parseXml(LLXmlTreeNode *node)
}
else
{
- llwarns << "Avatar file: <param> has invalid sex attribute: " << sex << llendl;
+ LL_WARNS() << "Avatar file: <param> has invalid sex attribute: " << sex << LL_ENDL;
return FALSE;
}
@@ -115,7 +109,7 @@ BOOL LLVisualParamInfo::parseXml(LLXmlTreeNode *node)
static LLStdStringHandle name_string = LLXmlTree::addAttributeString("name");
if( !node->getFastAttributeString( name_string, mName ) )
{
- llwarns << "Avatar file: <param> is missing name attribute" << llendl;
+ LL_WARNS() << "Avatar file: <param> is missing name attribute" << LL_ENDL;
return FALSE;
}
@@ -165,15 +159,32 @@ void LLVisualParamInfo::toStream(std::ostream &out)
//-----------------------------------------------------------------------------
// LLVisualParam()
//-----------------------------------------------------------------------------
-LLVisualParam::LLVisualParam()
- :
- mCurWeight( 0.f ),
+LLVisualParam::LLVisualParam()
+ : mCurWeight( 0.f ),
mLastWeight( 0.f ),
mNext( NULL ),
mTargetWeight( 0.f ),
mIsAnimating( FALSE ),
+ mIsDummy(FALSE),
mID( -1 ),
- mInfo( 0 )
+ mInfo( 0 ),
+ mParamLocation(LOC_UNKNOWN)
+{
+}
+
+//-----------------------------------------------------------------------------
+// LLVisualParam()
+//-----------------------------------------------------------------------------
+LLVisualParam::LLVisualParam(const LLVisualParam& pOther)
+ : mCurWeight(pOther.mCurWeight),
+ mLastWeight(pOther.mLastWeight),
+ mNext(pOther.mNext),
+ mTargetWeight(pOther.mTargetWeight),
+ mIsAnimating(pOther.mIsAnimating),
+ mIsDummy(pOther.mIsDummy),
+ mID(pOther.mID),
+ mInfo(pOther.mInfo),
+ mParamLocation(pOther.mParamLocation)
{
}
@@ -183,6 +194,7 @@ LLVisualParam::LLVisualParam()
LLVisualParam::~LLVisualParam()
{
delete mNext;
+ mNext = NULL;
}
/*
@@ -224,7 +236,7 @@ BOOL LLVisualParam::parseData(LLXmlTreeNode *node)
//-----------------------------------------------------------------------------
// setWeight()
//-----------------------------------------------------------------------------
-void LLVisualParam::setWeight(F32 weight, BOOL set_by_user)
+void LLVisualParam::setWeight(F32 weight)
{
if (mIsAnimating)
{
@@ -242,18 +254,26 @@ void LLVisualParam::setWeight(F32 weight, BOOL set_by_user)
if (mNext)
{
- mNext->setWeight(weight, set_by_user);
+ mNext->setWeight(weight);
}
}
//-----------------------------------------------------------------------------
// setAnimationTarget()
//-----------------------------------------------------------------------------
-void LLVisualParam::setAnimationTarget(F32 target_value, BOOL set_by_user)
+void LLVisualParam::setAnimationTarget(F32 target_value)
{
+ // don't animate dummy parameters
+ if (mIsDummy)
+ {
+ setWeight(target_value);
+ mTargetWeight = mCurWeight;
+ return;
+ }
+
if (mInfo)
{
- if (getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE)
+ if (isTweakable())
{
mTargetWeight = llclamp(target_value, mInfo->mMinWeight, mInfo->mMaxWeight);
}
@@ -266,7 +286,7 @@ void LLVisualParam::setAnimationTarget(F32 target_value, BOOL set_by_user)
if (mNext)
{
- mNext->setAnimationTarget(target_value, set_by_user);
+ mNext->setAnimationTarget(target_value);
}
}
@@ -276,36 +296,44 @@ void LLVisualParam::setAnimationTarget(F32 target_value, BOOL set_by_user)
void LLVisualParam::setNextParam( LLVisualParam *next )
{
llassert(!mNext);
-
+ llassert(getWeight() == getDefaultWeight()); // need to establish mNext before we start changing values on this, else initial value won't get mirrored (we can fix that, but better to forbid this pattern)
mNext = next;
}
//-----------------------------------------------------------------------------
+// clearNextParam()
+//-----------------------------------------------------------------------------
+void LLVisualParam::clearNextParam()
+{
+ mNext = NULL;
+}
+
+//-----------------------------------------------------------------------------
// animate()
//-----------------------------------------------------------------------------
-void LLVisualParam::animate( F32 delta, BOOL set_by_user )
+void LLVisualParam::animate( F32 delta)
{
if (mIsAnimating)
{
F32 new_weight = ((mTargetWeight - mCurWeight) * delta) + mCurWeight;
- setWeight(new_weight, set_by_user);
+ setWeight(new_weight);
}
}
//-----------------------------------------------------------------------------
// stopAnimating()
//-----------------------------------------------------------------------------
-void LLVisualParam::stopAnimating(BOOL set_by_user)
+void LLVisualParam::stopAnimating()
{
- if (mIsAnimating && getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE)
+ if (mIsAnimating && isTweakable())
{
mIsAnimating = FALSE;
- setWeight(mTargetWeight, set_by_user);
+ setWeight(mTargetWeight);
}
}
//virtual
-BOOL LLVisualParam::linkDrivenParams(visual_param_mapper mapper, bool only_cross_params)
+BOOL LLVisualParam::linkDrivenParams(visual_param_mapper mapper, BOOL only_cross_params)
{
// nothing to do for non-driver parameters
return TRUE;
@@ -317,3 +345,32 @@ void LLVisualParam::resetDrivenParams()
// nothing to do for non-driver parameters
return;
}
+
+const std::string param_location_name(const EParamLocation& loc)
+{
+ switch (loc)
+ {
+ case LOC_UNKNOWN: return "unknown";
+ case LOC_AV_SELF: return "self";
+ case LOC_AV_OTHER: return "other";
+ case LOC_WEARABLE: return "wearable";
+ default: return "error";
+ }
+}
+
+void LLVisualParam::setParamLocation(EParamLocation loc)
+{
+ if (mParamLocation == LOC_UNKNOWN || loc == LOC_UNKNOWN)
+ {
+ mParamLocation = loc;
+ }
+ else if (mParamLocation == loc)
+ {
+ // no action
+ }
+ else
+ {
+ LL_DEBUGS() << "param location is already " << mParamLocation << ", not slamming to " << loc << LL_ENDL;
+ }
+}
+