aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llcharacter/llkeyframewalkmotion.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llcharacter/llkeyframewalkmotion.cpp')
-rw-r--r--linden/indra/llcharacter/llkeyframewalkmotion.cpp47
1 files changed, 30 insertions, 17 deletions
diff --git a/linden/indra/llcharacter/llkeyframewalkmotion.cpp b/linden/indra/llcharacter/llkeyframewalkmotion.cpp
index 83c1c49..d5f6b81 100644
--- a/linden/indra/llcharacter/llkeyframewalkmotion.cpp
+++ b/linden/indra/llcharacter/llkeyframewalkmotion.cpp
@@ -12,12 +12,12 @@
12 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of 13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or 14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlife.com/developers/opensource/gplv2 15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 * 16 *
17 * There are special exceptions to the terms and conditions of the GPL as 17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception 18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or 19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlife.com/developers/opensource/flossexception 20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 * 21 *
22 * By copying, modifying or distributing this software, you acknowledge 22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above, 23 * that you have read and understood your obligations described above,
@@ -143,6 +143,8 @@ LLWalkAdjustMotion::LLWalkAdjustMotion(const LLUUID &id) : LLMotion(id)
143{ 143{
144 mLastTime = 0.f; 144 mLastTime = 0.f;
145 mName = "walk_adjust"; 145 mName = "walk_adjust";
146
147 mPelvisState = new LLJointState;
146} 148}
147 149
148//----------------------------------------------------------------------------- 150//-----------------------------------------------------------------------------
@@ -155,15 +157,15 @@ LLMotion::LLMotionInitStatus LLWalkAdjustMotion::onInitialize(LLCharacter *chara
155 mRightAnkleJoint = mCharacter->getJoint("mAnkleRight"); 157 mRightAnkleJoint = mCharacter->getJoint("mAnkleRight");
156 158
157 mPelvisJoint = mCharacter->getJoint("mPelvis"); 159 mPelvisJoint = mCharacter->getJoint("mPelvis");
158 mPelvisState.setJoint( mPelvisJoint ); 160 mPelvisState->setJoint( mPelvisJoint );
159 if ( !mPelvisJoint ) 161 if ( !mPelvisJoint )
160 { 162 {
161 llwarns << getName() << ": Can't get pelvis joint." << llendl; 163 llwarns << getName() << ": Can't get pelvis joint." << llendl;
162 return STATUS_FAILURE; 164 return STATUS_FAILURE;
163 } 165 }
164 166
165 mPelvisState.setUsage(LLJointState::POS); 167 mPelvisState->setUsage(LLJointState::POS);
166 addJointState( &mPelvisState ); 168 addJointState( mPelvisState );
167 169
168 return STATUS_SUCCESS; 170 return STATUS_SUCCESS;
169} 171}
@@ -178,7 +180,7 @@ BOOL LLWalkAdjustMotion::onActivate()
178 mAnimSpeed = 0.f; 180 mAnimSpeed = 0.f;
179 mAvgSpeed = 0.f; 181 mAvgSpeed = 0.f;
180 mRelativeDir = 1.f; 182 mRelativeDir = 1.f;
181 mPelvisState.setPosition(LLVector3::zero); 183 mPelvisState->setPosition(LLVector3::zero);
182 // store ankle positions for next frame 184 // store ankle positions for next frame
183 mLastLeftAnklePos = mCharacter->getPosGlobalFromAgent(mLeftAnkleJoint->getWorldPosition()); 185 mLastLeftAnklePos = mCharacter->getPosGlobalFromAgent(mLeftAnkleJoint->getWorldPosition());
184 mLastRightAnklePos = mCharacter->getPosGlobalFromAgent(mRightAnkleJoint->getWorldPosition()); 186 mLastRightAnklePos = mCharacter->getPosGlobalFromAgent(mRightAnkleJoint->getWorldPosition());
@@ -271,7 +273,7 @@ BOOL LLWalkAdjustMotion::onUpdate(F32 time, U8* joint_mask)
271 273
272 // calculate ideal pelvis offset so that foot is glued to ground and damp towards it 274 // calculate ideal pelvis offset so that foot is glued to ground and damp towards it
273 // the amount of foot slippage this frame + the offset applied last frame 275 // the amount of foot slippage this frame + the offset applied last frame
274 mPelvisOffset = mPelvisState.getPosition() + lerp(LLVector3::zero, footCorrection, LLCriticalDamp::getInterpolant(0.2f)); 276 mPelvisOffset = mPelvisState->getPosition() + lerp(LLVector3::zero, footCorrection, LLCriticalDamp::getInterpolant(0.2f));
275 277
276 // pelvis drift (along walk direction) 278 // pelvis drift (along walk direction)
277 mAvgCorrection = lerp(mAvgCorrection, footCorrection.mV[VX] * mRelativeDir, LLCriticalDamp::getInterpolant(0.1f)); 279 mAvgCorrection = lerp(mAvgCorrection, footCorrection.mV[VX] * mRelativeDir, LLCriticalDamp::getInterpolant(0.1f));
@@ -319,7 +321,7 @@ BOOL LLWalkAdjustMotion::onUpdate(F32 time, U8* joint_mask)
319 F32 drift_comp_max = llclamp(speed, 0.f, DRIFT_COMP_MAX_SPEED) / DRIFT_COMP_MAX_SPEED; 321 F32 drift_comp_max = llclamp(speed, 0.f, DRIFT_COMP_MAX_SPEED) / DRIFT_COMP_MAX_SPEED;
320 drift_comp_max *= DRIFT_COMP_MAX_TOTAL; 322 drift_comp_max *= DRIFT_COMP_MAX_TOTAL;
321 323
322 LLVector3 currentPelvisPos = mPelvisState.getJoint()->getPosition(); 324 LLVector3 currentPelvisPos = mPelvisState->getJoint()->getPosition();
323 325
324 // NB: this is an ADDITIVE amount that is accumulated every frame, so clamping it alone won't do the trick 326 // NB: this is an ADDITIVE amount that is accumulated every frame, so clamping it alone won't do the trick
325 // must clamp with absolute position of pelvis in mind 327 // must clamp with absolute position of pelvis in mind
@@ -328,7 +330,7 @@ BOOL LLWalkAdjustMotion::onUpdate(F32 time, U8* joint_mask)
328 mPelvisOffset.mV[VZ] = 0.f; 330 mPelvisOffset.mV[VZ] = 0.f;
329 331
330 // set position 332 // set position
331 mPelvisState.setPosition(mPelvisOffset); 333 mPelvisState->setPosition(mPelvisOffset);
332 334
333 mCharacter->setAnimationData("Pelvis Offset", &mPelvisOffset); 335 mCharacter->setAnimationData("Pelvis Offset", &mPelvisOffset);
334 336
@@ -344,6 +346,17 @@ void LLWalkAdjustMotion::onDeactivate()
344} 346}
345 347
346//----------------------------------------------------------------------------- 348//-----------------------------------------------------------------------------
349// LLFlyAdjustMotion::LLFlyAdjustMotion()
350//-----------------------------------------------------------------------------
351LLFlyAdjustMotion::LLFlyAdjustMotion(const LLUUID &id)
352 : LLMotion(id)
353{
354 mName = "fly_adjust";
355
356 mPelvisState = new LLJointState;
357}
358
359//-----------------------------------------------------------------------------
347// LLFlyAdjustMotion::onInitialize() 360// LLFlyAdjustMotion::onInitialize()
348//----------------------------------------------------------------------------- 361//-----------------------------------------------------------------------------
349LLMotion::LLMotionInitStatus LLFlyAdjustMotion::onInitialize(LLCharacter *character) 362LLMotion::LLMotionInitStatus LLFlyAdjustMotion::onInitialize(LLCharacter *character)
@@ -351,15 +364,15 @@ LLMotion::LLMotionInitStatus LLFlyAdjustMotion::onInitialize(LLCharacter *charac
351 mCharacter = character; 364 mCharacter = character;
352 365
353 LLJoint* pelvisJoint = mCharacter->getJoint("mPelvis"); 366 LLJoint* pelvisJoint = mCharacter->getJoint("mPelvis");
354 mPelvisState.setJoint( pelvisJoint ); 367 mPelvisState->setJoint( pelvisJoint );
355 if ( !pelvisJoint ) 368 if ( !pelvisJoint )
356 { 369 {
357 llwarns << getName() << ": Can't get pelvis joint." << llendl; 370 llwarns << getName() << ": Can't get pelvis joint." << llendl;
358 return STATUS_FAILURE; 371 return STATUS_FAILURE;
359 } 372 }
360 373
361 mPelvisState.setUsage(LLJointState::POS | LLJointState::ROT); 374 mPelvisState->setUsage(LLJointState::POS | LLJointState::ROT);
362 addJointState( &mPelvisState ); 375 addJointState( mPelvisState );
363 376
364 return STATUS_SUCCESS; 377 return STATUS_SUCCESS;
365} 378}
@@ -369,8 +382,8 @@ LLMotion::LLMotionInitStatus LLFlyAdjustMotion::onInitialize(LLCharacter *charac
369//----------------------------------------------------------------------------- 382//-----------------------------------------------------------------------------
370BOOL LLFlyAdjustMotion::onActivate() 383BOOL LLFlyAdjustMotion::onActivate()
371{ 384{
372 mPelvisState.setPosition(LLVector3::zero); 385 mPelvisState->setPosition(LLVector3::zero);
373 mPelvisState.setRotation(LLQuaternion::DEFAULT); 386 mPelvisState->setRotation(LLQuaternion::DEFAULT);
374 mRoll = 0.f; 387 mRoll = 0.f;
375 return TRUE; 388 return TRUE;
376} 389}
@@ -392,11 +405,11 @@ BOOL LLFlyAdjustMotion::onUpdate(F32 time, U8* joint_mask)
392// llinfos << mRoll << llendl; 405// llinfos << mRoll << llendl;
393 406
394 LLQuaternion roll(mRoll, LLVector3(0.f, 0.f, 1.f)); 407 LLQuaternion roll(mRoll, LLVector3(0.f, 0.f, 1.f));
395 mPelvisState.setRotation(roll); 408 mPelvisState->setRotation(roll);
396 409
397// F32 lerp_amt = LLCriticalDamp::getInterpolant(0.2f); 410// F32 lerp_amt = LLCriticalDamp::getInterpolant(0.2f);
398// 411//
399// LLVector3 pelvis_correction = mPelvisState.getPosition() - lerp(LLVector3::zero, mPelvisState.getJoint()->getPosition() + mPelvisState.getPosition(), lerp_amt); 412// LLVector3 pelvis_correction = mPelvisState->getPosition() - lerp(LLVector3::zero, mPelvisState->getJoint()->getPosition() + mPelvisState->getPosition(), lerp_amt);
400// mPelvisState.setPosition(pelvis_correction); 413// mPelvisState->setPosition(pelvis_correction);
401 return TRUE; 414 return TRUE;
402} 415}