summaryrefslogtreecommitdiff
path: root/indra/llcharacter/llbvhloader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcharacter/llbvhloader.cpp')
-rwxr-xr-x[-rw-r--r--]indra/llcharacter/llbvhloader.cpp93
1 files changed, 44 insertions, 49 deletions
diff --git a/indra/llcharacter/llbvhloader.cpp b/indra/llcharacter/llbvhloader.cpp
index 3dd54b4760..0d558aeaa2 100644..100755
--- a/indra/llcharacter/llbvhloader.cpp
+++ b/indra/llcharacter/llbvhloader.cpp
@@ -2,31 +2,25 @@
* @file llbvhloader.cpp
* @brief Translates a BVH files to LindenLabAnimation format.
*
- * $LicenseInfo:firstyear=2004&license=viewergpl$
- *
- * Copyright (c) 2004-2009, Linden Research, Inc.
- *
+ * $LicenseInfo:firstyear=2004&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.
*
- * 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 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.
*
- * 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.
+ * 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.
*
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
+ * 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
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -48,10 +42,10 @@ using namespace std;
#define INCHES_TO_METERS 0.02540005f
-const F32 POSITION_KEYFRAME_THRESHOLD = 0.03f;
+const F32 POSITION_KEYFRAME_THRESHOLD_SQUARED = 0.03f * 0.03f;
const F32 ROTATION_KEYFRAME_THRESHOLD = 0.01f;
-const F32 POSITION_MOTION_THRESHOLD = 0.001f;
+const F32 POSITION_MOTION_THRESHOLD_SQUARED = 0.001f * 0.001f;
const F32 ROTATION_MOTION_THRESHOLD = 0.001f;
char gInFile[1024]; /* Flawfinder: ignore */
@@ -136,14 +130,14 @@ LLQuaternion::Order bvhStringToOrder( char *str )
if (mStatus == LLBVHLoader::ST_NO_XLT_FILE)
{
- llwarns << "NOTE: No translation table found." << llendl;
+ LL_WARNS() << "NOTE: No translation table found." << LL_ENDL;
return;
}
else
{
if (mStatus != LLBVHLoader::ST_OK)
{
- llwarns << "ERROR: [line: " << getLineNumber() << "] " << mStatus << llendl;
+ LL_WARNS() << "ERROR: [line: " << getLineNumber() << "] " << mStatus << LL_ENDL;
return;
}
}
@@ -153,7 +147,7 @@ LLQuaternion::Order bvhStringToOrder( char *str )
mStatus = loadBVHFile(buffer, error_text, error_line);
if (mStatus != LLBVHLoader::ST_OK)
{
- llwarns << "ERROR: [line: " << getLineNumber() << "] " << mStatus << llendl;
+ LL_WARNS() << "ERROR: [line: " << getLineNumber() << "] " << mStatus << LL_ENDL;
return;
}
@@ -169,10 +163,10 @@ LLBVHLoader::LLBVHLoader(const char* buffer, ELoadStatus &loadStatus, S32 &error
errorLine = 0;
mStatus = loadTranslationTable("anim.ini");
loadStatus = mStatus;
- llinfos<<"Load Status 00 : "<< loadStatus << llendl;
+ LL_INFOS()<<"Load Status 00 : "<< loadStatus << LL_ENDL;
if (mStatus == E_ST_NO_XLT_FILE)
{
- //llwarns << "NOTE: No translation table found." << llendl;
+ //LL_WARNS() << "NOTE: No translation table found." << LL_ENDL;
loadStatus = mStatus;
return;
}
@@ -180,7 +174,7 @@ LLBVHLoader::LLBVHLoader(const char* buffer, ELoadStatus &loadStatus, S32 &error
{
if (mStatus != E_ST_OK)
{
- //llwarns << "ERROR: [line: " << getLineNumber() << "] " << mStatus << llendl;
+ //LL_WARNS() << "ERROR: [line: " << getLineNumber() << "] " << mStatus << LL_ENDL;
errorLine = getLineNumber();
loadStatus = mStatus;
return;
@@ -193,7 +187,7 @@ LLBVHLoader::LLBVHLoader(const char* buffer, ELoadStatus &loadStatus, S32 &error
if (mStatus != E_ST_OK)
{
- //llwarns << "ERROR: [line: " << getLineNumber() << "] " << mStatus << llendl;
+ //LL_WARNS() << "ERROR: [line: " << getLineNumber() << "] " << mStatus << LL_ENDL;
loadStatus = mStatus;
errorLine = getLineNumber();
return;
@@ -209,6 +203,7 @@ LLBVHLoader::LLBVHLoader(const char* buffer, ELoadStatus &loadStatus, S32 &error
LLBVHLoader::~LLBVHLoader()
{
std::for_each(mJoints.begin(),mJoints.end(),DeletePointer());
+ mJoints.clear();
}
//------------------------------------------------------------------------
@@ -231,7 +226,7 @@ ELoadStatus LLBVHLoader::loadTranslationTable(const char *fileName)
if (!fp)
return E_ST_NO_XLT_FILE;
- llinfos << "NOTE: Loading translation table: " << fileName << llendl;
+ LL_INFOS() << "NOTE: Loading translation table: " << fileName << LL_ENDL;
//--------------------------------------------------------------------
// register file to be closed on function exit
@@ -295,7 +290,7 @@ ELoadStatus LLBVHLoader::loadTranslationTable(const char *fileName)
return E_ST_NO_XLT_EMOTE;
mEmoteName.assign( emote_str );
-// llinfos << "NOTE: Emote: " << mEmoteName.c_str() << llendl;
+// LL_INFOS() << "NOTE: Emote: " << mEmoteName.c_str() << LL_ENDL;
continue;
}
@@ -310,7 +305,7 @@ ELoadStatus LLBVHLoader::loadTranslationTable(const char *fileName)
return E_ST_NO_XLT_PRIORITY;
mPriority = priority;
-// llinfos << "NOTE: Priority: " << mPriority << llendl;
+// LL_INFOS() << "NOTE: Priority: " << mPriority << LL_ENDL;
continue;
}
@@ -703,7 +698,7 @@ ELoadStatus LLBVHLoader::loadBVHFile(const char *buffer, char* error_text, S32 &
if ( !strstr(line.c_str(), "HIERARCHY") )
{
-// llinfos << line << llendl;
+// LL_INFOS() << line << LL_ENDL;
return E_ST_NO_HIER;
}
@@ -1050,7 +1045,7 @@ void LLBVHLoader::applyTranslations()
//----------------------------------------------------------------
if ( trans.mIgnore )
{
- //llinfos << "NOTE: Ignoring " << joint->mName.c_str() << llendl;
+ //LL_INFOS() << "NOTE: Ignoring " << joint->mName.c_str() << LL_ENDL;
joint->mIgnore = TRUE;
continue;
}
@@ -1060,7 +1055,7 @@ void LLBVHLoader::applyTranslations()
//----------------------------------------------------------------
if ( ! trans.mOutName.empty() )
{
- //llinfos << "NOTE: Changing " << joint->mName.c_str() << " to " << trans.mOutName.c_str() << llendl;
+ //LL_INFOS() << "NOTE: Changing " << joint->mName.c_str() << " to " << trans.mOutName.c_str() << LL_ENDL;
joint->mOutName = trans.mOutName;
}
@@ -1077,25 +1072,25 @@ void LLBVHLoader::applyTranslations()
//----------------------------------------------------------------
if ( trans.mRelativePositionKey )
{
-// llinfos << "NOTE: Removing 1st position offset from all keys for " << joint->mOutName.c_str() << llendl;
+// LL_INFOS() << "NOTE: Removing 1st position offset from all keys for " << joint->mOutName.c_str() << LL_ENDL;
joint->mRelativePositionKey = TRUE;
}
if ( trans.mRelativeRotationKey )
{
-// llinfos << "NOTE: Removing 1st rotation from all keys for " << joint->mOutName.c_str() << llendl;
+// LL_INFOS() << "NOTE: Removing 1st rotation from all keys for " << joint->mOutName.c_str() << LL_ENDL;
joint->mRelativeRotationKey = TRUE;
}
if ( trans.mRelativePosition.magVec() > 0.0f )
{
joint->mRelativePosition = trans.mRelativePosition;
-// llinfos << "NOTE: Removing " <<
+// LL_INFOS() << "NOTE: Removing " <<
// joint->mRelativePosition.mV[0] << " " <<
// joint->mRelativePosition.mV[1] << " " <<
// joint->mRelativePosition.mV[2] <<
// " from all position keys in " <<
-// joint->mOutName.c_str() << llendl;
+// joint->mOutName.c_str() << LL_ENDL;
}
//----------------------------------------------------------------
@@ -1109,9 +1104,9 @@ void LLBVHLoader::applyTranslations()
//----------------------------------------------------------------
if ( ! trans.mMergeParentName.empty() )
{
-// llinfos << "NOTE: Merging " << joint->mOutName.c_str() <<
+// LL_INFOS() << "NOTE: Merging " << joint->mOutName.c_str() <<
// " with parent " <<
-// trans.mMergeParentName.c_str() << llendl;
+// trans.mMergeParentName.c_str() << LL_ENDL;
joint->mMergeParentName = trans.mMergeParentName;
}
@@ -1120,8 +1115,8 @@ void LLBVHLoader::applyTranslations()
//----------------------------------------------------------------
if ( ! trans.mMergeChildName.empty() )
{
-// llinfos << "NOTE: Merging " << joint->mName.c_str() <<
-// " with child " << trans.mMergeChildName.c_str() << llendl;
+// LL_INFOS() << "NOTE: Merging " << joint->mName.c_str() <<
+// " with child " << trans.mMergeChildName.c_str() << LL_ENDL;
joint->mMergeChildName = trans.mMergeChildName;
}
@@ -1202,7 +1197,7 @@ void LLBVHLoader::optimize()
if (ki_prev == ki_last_good_pos)
{
joint->mNumPosKeys++;
- if (dist_vec(LLVector3(ki_prev->mPos), first_frame_pos) > POSITION_MOTION_THRESHOLD)
+ if (dist_vec_squared(LLVector3(ki_prev->mPos), first_frame_pos) > POSITION_MOTION_THRESHOLD_SQUARED)
{
pos_changed = TRUE;
}
@@ -1215,12 +1210,12 @@ void LLBVHLoader::optimize()
LLVector3 current_pos(ki->mPos);
LLVector3 interp_pos = lerp(current_pos, last_good_pos, 1.f / (F32)numPosFramesConsidered);
- if (dist_vec(current_pos, first_frame_pos) > POSITION_MOTION_THRESHOLD)
+ if (dist_vec_squared(current_pos, first_frame_pos) > POSITION_MOTION_THRESHOLD_SQUARED)
{
pos_changed = TRUE;
}
- if (dist_vec(interp_pos, test_pos) < POSITION_KEYFRAME_THRESHOLD)
+ if (dist_vec_squared(interp_pos, test_pos) < POSITION_KEYFRAME_THRESHOLD_SQUARED)
{
ki_prev->mIgnorePos = TRUE;
numPosFramesConsidered++;
@@ -1316,7 +1311,7 @@ void LLBVHLoader::optimize()
// don't output joints with no motion
if (!(pos_changed || rot_changed))
{
- //llinfos << "Ignoring joint " << joint->mName << llendl;
+ //LL_INFOS() << "Ignoring joint " << joint->mName << LL_ENDL;
joint->mIgnore = TRUE;
}
}
@@ -1576,7 +1571,7 @@ BOOL LLBVHLoader::serialize(LLDataPacker& dp)
constraint_it++)
{
U8 byte = constraint_it->mChainLength;
- dp.packU8(byte, "chain_lenght");
+ dp.packU8(byte, "chain_length");
byte = constraint_it->mConstraintType;
dp.packU8(byte, "constraint_type");