summaryrefslogtreecommitdiff
path: root/indra/llcharacter/llmotioncontroller.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcharacter/llmotioncontroller.cpp')
-rwxr-xr-x[-rw-r--r--]indra/llcharacter/llmotioncontroller.cpp114
1 files changed, 74 insertions, 40 deletions
diff --git a/indra/llcharacter/llmotioncontroller.cpp b/indra/llcharacter/llmotioncontroller.cpp
index bb9625b2bd..e02b139608 100644..100755
--- a/indra/llcharacter/llmotioncontroller.cpp
+++ b/indra/llcharacter/llmotioncontroller.cpp
@@ -2,31 +2,25 @@
* @file llmotioncontroller.cpp
* @brief Implementation of LLMotionController 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.
*
- * 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$
*/
@@ -35,9 +29,8 @@
//-----------------------------------------------------------------------------
#include "linden_common.h"
-#include "llmemtype.h"
-
#include "llmotioncontroller.h"
+#include "llfasttimer.h"
#include "llkeyframemotion.h"
#include "llmath.h"
#include "lltimer.h"
@@ -50,6 +43,7 @@ const U32 MAX_MOTION_INSTANCES = 32;
//-----------------------------------------------------------------------------
// Constants and statics
//-----------------------------------------------------------------------------
+F32 LLMotionController::sCurrentTimeFactor = 1.f;
LLMotionRegistry LLMotionController::sRegistry;
//-----------------------------------------------------------------------------
@@ -83,7 +77,7 @@ LLMotionRegistry::~LLMotionRegistry()
//-----------------------------------------------------------------------------
BOOL LLMotionRegistry::registerMotion( const LLUUID& id, LLMotionConstructor constructor )
{
- // llinfos << "Registering motion: " << name << llendl;
+ // LL_INFOS() << "Registering motion: " << name << LL_ENDL;
if (!is_in_map(mMotionTable, id))
{
mMotionTable[id] = constructor;
@@ -133,7 +127,7 @@ LLMotion *LLMotionRegistry::createMotion( const LLUUID &id )
// Class Constructor
//-----------------------------------------------------------------------------
LLMotionController::LLMotionController()
- : mTimeFactor(1.f),
+ : mTimeFactor(sCurrentTimeFactor),
mCharacter(NULL),
mAnimTime(0.f),
mPrevTimerElapsed(0.f),
@@ -143,7 +137,8 @@ LLMotionController::LLMotionController()
mPauseTime(0.f),
mTimeStep(0.f),
mTimeStepCount(0),
- mLastInterp(0.f)
+ mLastInterp(0.f),
+ mIsSelf(FALSE)
{
}
@@ -177,6 +172,13 @@ void LLMotionController::deleteAllMotions()
for_each(mAllMotions.begin(), mAllMotions.end(), DeletePairedPointer());
mAllMotions.clear();
+
+ // stinson 05/12/20014 : Ownership of the LLMotion pointers is transferred from
+ // mAllMotions to mDeprecatedMotions in method
+ // LLMotionController::deprecateMotionInstance(). Thus, we should also clean
+ // up the mDeprecatedMotions list as well.
+ for_each(mDeprecatedMotions.begin(), mDeprecatedMotions.end(), DeletePointer());
+ mDeprecatedMotions.clear();
}
//-----------------------------------------------------------------------------
@@ -237,7 +239,7 @@ void LLMotionController::purgeExcessMotions()
if (mLoadedMotions.size() > 2*MAX_MOTION_INSTANCES)
{
- LL_WARNS_ONCE("Animation") << "> " << 2*MAX_MOTION_INSTANCES << " Loaded Motions" << llendl;
+ LL_WARNS_ONCE("Animation") << "> " << 2*MAX_MOTION_INSTANCES << " Loaded Motions" << LL_ENDL;
}
}
@@ -340,7 +342,6 @@ void LLMotionController::removeMotionInstance(LLMotion* motionp)
//-----------------------------------------------------------------------------
LLMotion* LLMotionController::createMotion( const LLUUID &id )
{
- LLMemType mt(LLMemType::MTYPE_ANIMATION);
// do we have an instance of this motion for this character?
LLMotion *motion = findMotion(id);
@@ -366,7 +367,7 @@ LLMotion* LLMotionController::createMotion( const LLUUID &id )
switch(stat)
{
case LLMotion::STATUS_FAILURE:
- llinfos << "Motion " << id << " init failed." << llendl;
+ LL_INFOS() << "Motion " << id << " init failed." << LL_ENDL;
sRegistry.markBad(id);
delete motion;
return NULL;
@@ -378,7 +379,7 @@ LLMotion* LLMotionController::createMotion( const LLUUID &id )
mLoadedMotions.insert(motion);
break;
default:
- llerrs << "Invalid initialization status" << llendl;
+ LL_ERRS() << "Invalid initialization status" << LL_ENDL;
break;
}
@@ -424,7 +425,7 @@ BOOL LLMotionController::startMotion(const LLUUID &id, F32 start_offset)
return TRUE;
}
-// llinfos << "Starting motion " << name << llendl;
+// LL_INFOS() << "Starting motion " << name << LL_ENDL;
return activateMotionInstance(motion, mAnimTime - start_offset);
}
@@ -446,6 +447,7 @@ BOOL LLMotionController::stopMotionInstance(LLMotion* motion, BOOL stop_immediat
return FALSE;
}
+
// If on active list, stop it
if (isMotionActive(motion) && !motion->isStopped())
{
@@ -546,6 +548,8 @@ void LLMotionController::updateIdleActiveMotions()
//-----------------------------------------------------------------------------
// updateMotionsByType()
//-----------------------------------------------------------------------------
+static LLTrace::BlockTimerStatHandle FTM_MOTION_ON_UPDATE("Motion onUpdate");
+
void LLMotionController::updateMotionsByType(LLMotion::LLMotionBlendType anim_type)
{
BOOL update_result = TRUE;
@@ -703,7 +707,10 @@ void LLMotionController::updateMotionsByType(LLMotion::LLMotionBlendType anim_ty
}
// perform motion update
- update_result = motionp->onUpdate(mAnimTime - motionp->mActivationTimestamp, last_joint_signature);
+ {
+ LL_RECORD_BLOCK_TIME(FTM_MOTION_ON_UPDATE);
+ update_result = motionp->onUpdate(mAnimTime - motionp->mActivationTimestamp, last_joint_signature);
+ }
}
//**********************
@@ -781,7 +788,7 @@ void LLMotionController::updateLoadingMotions()
}
else if (status == LLMotion::STATUS_FAILURE)
{
- llinfos << "Motion " << motionp->getID() << " init failed." << llendl;
+ LL_INFOS() << "Motion " << motionp->getID() << " init failed." << LL_ENDL;
sRegistry.markBad(motionp->getID());
mLoadingMotions.erase(curiter);
motion_set_t::iterator found_it = mDeprecatedMotions.find(motionp);
@@ -814,7 +821,7 @@ void LLMotionController::updateMotions(bool force_update)
// Always cap the number of loaded motions
purgeExcessMotions();
-
+
// Update timing info for this time step.
if (!mPaused)
{
@@ -836,6 +843,7 @@ void LLMotionController::updateMotions(bool force_update)
}
updateLoadingMotions();
+
return;
}
@@ -854,7 +862,7 @@ void LLMotionController::updateMotions(bool force_update)
}
updateLoadingMotions();
-
+
resetJointSignatures();
if (mPaused && !force_update)
@@ -865,11 +873,12 @@ void LLMotionController::updateMotions(bool force_update)
{
// update additive motions
updateAdditiveMotions();
+
resetJointSignatures();
-
+
// update all regular motions
updateRegularMotions();
-
+
if (use_quantum)
{
mPoseBlender.blendAndCache(TRUE);
@@ -881,7 +890,7 @@ void LLMotionController::updateMotions(bool force_update)
}
mHasRunOnce = TRUE;
-// llinfos << "Motion controller time " << motionTimer.getElapsedTimeF32() << llendl;
+// LL_INFOS() << "Motion controller time " << motionTimer.getElapsedTimeF32() << LL_ENDL;
}
//-----------------------------------------------------------------------------
@@ -1033,6 +1042,31 @@ LLMotion* LLMotionController::findMotion(const LLUUID& id) const
}
//-----------------------------------------------------------------------------
+// dumpMotions()
+//-----------------------------------------------------------------------------
+void LLMotionController::dumpMotions()
+{
+ LL_INFOS() << "=====================================" << LL_ENDL;
+ for (motion_map_t::iterator iter = mAllMotions.begin();
+ iter != mAllMotions.end(); iter++)
+ {
+ LLUUID id = iter->first;
+ std::string state_string;
+ LLMotion *motion = iter->second;
+ if (mLoadingMotions.find(motion) != mLoadingMotions.end())
+ state_string += std::string("l");
+ if (mLoadedMotions.find(motion) != mLoadedMotions.end())
+ state_string += std::string("L");
+ if (std::find(mActiveMotions.begin(), mActiveMotions.end(), motion)!=mActiveMotions.end())
+ state_string += std::string("A");
+ if (mDeprecatedMotions.find(motion) != mDeprecatedMotions.end())
+ state_string += std::string("D");
+ LL_INFOS() << gAnimLibrary.animationName(id) << " " << state_string << LL_ENDL;
+
+ }
+}
+
+//-----------------------------------------------------------------------------
// deactivateAllMotions()
//-----------------------------------------------------------------------------
void LLMotionController::deactivateAllMotions()
@@ -1086,7 +1120,7 @@ void LLMotionController::pauseAllMotions()
{
if (!mPaused)
{
- //llinfos << "Pausing animations..." << llendl;
+ //LL_INFOS() << "Pausing animations..." << LL_ENDL;
mPaused = TRUE;
}
@@ -1099,7 +1133,7 @@ void LLMotionController::unpauseAllMotions()
{
if (mPaused)
{
- //llinfos << "Unpausing animations..." << llendl;
+ //LL_INFOS() << "Unpausing animations..." << LL_ENDL;
mPaused = FALSE;
}
}