diff options
author | Jacek Antonelli | 2008-08-15 23:45:04 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:04 -0500 |
commit | 117e22047c5752352342d64e3fb7ce00a4eb8113 (patch) | |
tree | e32de2cfba0dda8705ae528fcd1fbe23ba075685 /linden/indra/llcharacter | |
parent | Second Life viewer sources 1.18.0.6 (diff) | |
download | meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.zip meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.gz meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.bz2 meta-impy-117e22047c5752352342d64e3fb7ce00a4eb8113.tar.xz |
Second Life viewer sources 1.18.1.2
Diffstat (limited to 'linden/indra/llcharacter')
-rw-r--r-- | linden/indra/llcharacter/lljoint.cpp | 33 | ||||
-rw-r--r-- | linden/indra/llcharacter/lljoint.h | 5 | ||||
-rw-r--r-- | linden/indra/llcharacter/llmotion.cpp | 11 | ||||
-rw-r--r-- | linden/indra/llcharacter/llmotion.h | 8 | ||||
-rw-r--r-- | linden/indra/llcharacter/llmotioncontroller.cpp | 157 | ||||
-rw-r--r-- | linden/indra/llcharacter/llmotioncontroller.h | 15 | ||||
-rw-r--r-- | linden/indra/llcharacter/llpose.cpp | 20 | ||||
-rw-r--r-- | linden/indra/llcharacter/llpose.h | 2 |
8 files changed, 144 insertions, 107 deletions
diff --git a/linden/indra/llcharacter/lljoint.cpp b/linden/indra/llcharacter/lljoint.cpp index 6141cc0..07c34a8 100644 --- a/linden/indra/llcharacter/lljoint.cpp +++ b/linden/indra/llcharacter/lljoint.cpp | |||
@@ -485,39 +485,6 @@ void LLJoint::setSkinOffset( const LLVector3& offset ) | |||
485 | mSkinOffset = offset; | 485 | mSkinOffset = offset; |
486 | } | 486 | } |
487 | 487 | ||
488 | //----------------------------------------------------------------------------- | ||
489 | // setConstraintSilhouette() | ||
490 | //----------------------------------------------------------------------------- | ||
491 | void LLJoint::setConstraintSilhouette(LLDynamicArray<LLVector3>& silhouette) | ||
492 | { | ||
493 | S32 i; | ||
494 | |||
495 | mConstraintSilhouette.reset(); | ||
496 | for (i = 0; i < silhouette.count(); i++) | ||
497 | { | ||
498 | if (i % 2 == 1) | ||
499 | { | ||
500 | // skip normals | ||
501 | continue; | ||
502 | } | ||
503 | mConstraintSilhouette[i / 2] = silhouette[i]; | ||
504 | } | ||
505 | LLQuaternion inv_parent_rotation = LLQuaternion::DEFAULT; | ||
506 | |||
507 | if (getParent()) | ||
508 | { | ||
509 | inv_parent_rotation = ~getParent()->getWorldRotation(); | ||
510 | } | ||
511 | |||
512 | for (i = 0; i < mConstraintSilhouette.count(); i++) | ||
513 | { | ||
514 | LLVector3 vert = mConstraintSilhouette[i]; | ||
515 | |||
516 | vert -= getWorldPosition(); | ||
517 | vert.normVec(); | ||
518 | vert = vert * inv_parent_rotation; | ||
519 | } | ||
520 | } | ||
521 | 488 | ||
522 | //----------------------------------------------------------------------------- | 489 | //----------------------------------------------------------------------------- |
523 | // clampRotation() | 490 | // clampRotation() |
diff --git a/linden/indra/llcharacter/lljoint.h b/linden/indra/llcharacter/lljoint.h index f188968..d1e0107 100644 --- a/linden/indra/llcharacter/lljoint.h +++ b/linden/indra/llcharacter/lljoint.h | |||
@@ -85,7 +85,6 @@ protected: | |||
85 | 85 | ||
86 | public: | 86 | public: |
87 | U32 mDirtyFlags; | 87 | U32 mDirtyFlags; |
88 | BOOL mWorldRotationDirty; | ||
89 | BOOL mUpdateXform; | 88 | BOOL mUpdateXform; |
90 | 89 | ||
91 | // describes the skin binding pose | 90 | // describes the skin binding pose |
@@ -93,8 +92,6 @@ public: | |||
93 | 92 | ||
94 | S32 mJointNum; | 93 | S32 mJointNum; |
95 | 94 | ||
96 | LLDynamicArray<LLVector3> mConstraintSilhouette; | ||
97 | |||
98 | // child joints | 95 | // child joints |
99 | typedef std::list<LLJoint*> child_list_t; | 96 | typedef std::list<LLJoint*> child_list_t; |
100 | child_list_t mChildren; | 97 | child_list_t mChildren; |
@@ -171,8 +168,6 @@ public: | |||
171 | 168 | ||
172 | LLXformMatrix *getXform() { return &mXform; } | 169 | LLXformMatrix *getXform() { return &mXform; } |
173 | 170 | ||
174 | void setConstraintSilhouette(LLDynamicArray<LLVector3>& silhouette); | ||
175 | |||
176 | void clampRotation(LLQuaternion old_rot, LLQuaternion new_rot); | 171 | void clampRotation(LLQuaternion old_rot, LLQuaternion new_rot); |
177 | 172 | ||
178 | virtual BOOL isAnimatable() { return TRUE; } | 173 | virtual BOOL isAnimatable() { return TRUE; } |
diff --git a/linden/indra/llcharacter/llmotion.cpp b/linden/indra/llcharacter/llmotion.cpp index b13ea60..40a30a4 100644 --- a/linden/indra/llcharacter/llmotion.cpp +++ b/linden/indra/llcharacter/llmotion.cpp | |||
@@ -126,6 +126,11 @@ void LLMotion::setDeactivateCallback( void (*cb)(void *), void* userdata ) | |||
126 | mDeactivateCallbackUserData = userdata; | 126 | mDeactivateCallbackUserData = userdata; |
127 | } | 127 | } |
128 | 128 | ||
129 | BOOL LLMotion::isBlending() | ||
130 | { | ||
131 | return mPose.getWeight() < 1.f; | ||
132 | } | ||
133 | |||
129 | //----------------------------------------------------------------------------- | 134 | //----------------------------------------------------------------------------- |
130 | // activate() | 135 | // activate() |
131 | //----------------------------------------------------------------------------- | 136 | //----------------------------------------------------------------------------- |
@@ -142,10 +147,16 @@ void LLMotion::activate() | |||
142 | void LLMotion::deactivate() | 147 | void LLMotion::deactivate() |
143 | { | 148 | { |
144 | mActive = FALSE; | 149 | mActive = FALSE; |
150 | mPose.setWeight(0.f); | ||
145 | 151 | ||
146 | if (mDeactivateCallback) (*mDeactivateCallback)(mDeactivateCallbackUserData); | 152 | if (mDeactivateCallback) (*mDeactivateCallback)(mDeactivateCallbackUserData); |
147 | 153 | ||
148 | onDeactivate(); | 154 | onDeactivate(); |
149 | } | 155 | } |
150 | 156 | ||
157 | BOOL LLMotion::canDeprecate() | ||
158 | { | ||
159 | return TRUE; | ||
160 | } | ||
161 | |||
151 | // End | 162 | // End |
diff --git a/linden/indra/llcharacter/llmotion.h b/linden/indra/llcharacter/llmotion.h index 48d402a..e60b0c0 100644 --- a/linden/indra/llcharacter/llmotion.h +++ b/linden/indra/llcharacter/llmotion.h | |||
@@ -99,13 +99,14 @@ public: | |||
99 | 99 | ||
100 | void setStopped(BOOL stopped) { mStopped = stopped; } | 100 | void setStopped(BOOL stopped) { mStopped = stopped; } |
101 | 101 | ||
102 | BOOL isBlending(); | ||
103 | |||
102 | void activate(); | 104 | void activate(); |
103 | 105 | ||
104 | void deactivate(); | 106 | void deactivate(); |
105 | 107 | ||
106 | BOOL isActive() { return mActive; } | 108 | BOOL isActive() { return mActive; } |
107 | 109 | ||
108 | |||
109 | public: | 110 | public: |
110 | //------------------------------------------------------------------------- | 111 | //------------------------------------------------------------------------- |
111 | // animation callbacks to be implemented by subclasses | 112 | // animation callbacks to be implemented by subclasses |
@@ -145,6 +146,11 @@ public: | |||
145 | // called when a motion is deactivated | 146 | // called when a motion is deactivated |
146 | virtual void onDeactivate() = 0; | 147 | virtual void onDeactivate() = 0; |
147 | 148 | ||
149 | // can we crossfade this motion with a new instance when restarted? | ||
150 | // should ultimately always be TRUE, but lack of emote blending, etc | ||
151 | // requires this | ||
152 | virtual BOOL canDeprecate(); | ||
153 | |||
148 | // optional callback routine called when animation deactivated. | 154 | // optional callback routine called when animation deactivated. |
149 | void setDeactivateCallback( void (*cb)(void *), void* userdata ); | 155 | void setDeactivateCallback( void (*cb)(void *), void* userdata ); |
150 | 156 | ||
diff --git a/linden/indra/llcharacter/llmotioncontroller.cpp b/linden/indra/llcharacter/llmotioncontroller.cpp index 2427fd8..aebfaf6 100644 --- a/linden/indra/llcharacter/llmotioncontroller.cpp +++ b/linden/indra/llcharacter/llmotioncontroller.cpp | |||
@@ -194,34 +194,44 @@ void LLMotionController::deleteAllMotions() | |||
194 | //----------------------------------------------------------------------------- | 194 | //----------------------------------------------------------------------------- |
195 | void LLMotionController::addLoadedMotion(LLMotion* motionp) | 195 | void LLMotionController::addLoadedMotion(LLMotion* motionp) |
196 | { | 196 | { |
197 | std::set<LLUUID> motions_to_kill; | ||
198 | |||
199 | // gather all inactive, loaded motions | ||
197 | if (mLoadedMotions.size() > MAX_MOTION_INSTANCES) | 200 | if (mLoadedMotions.size() > MAX_MOTION_INSTANCES) |
198 | { | 201 | { |
199 | // too many motions active this frame, kill all blenders | 202 | // too many motions active this frame, kill all blenders |
200 | mPoseBlender.clearBlenders(); | 203 | mPoseBlender.clearBlenders(); |
201 | 204 | ||
202 | for (U32 i = 0; i < mLoadedMotions.size(); i++) | 205 | for (motion_list_t::iterator loaded_motion_it = mLoadedMotions.begin(); |
206 | loaded_motion_it != mLoadedMotions.end(); | ||
207 | ++loaded_motion_it) | ||
203 | { | 208 | { |
204 | LLMotion* cur_motionp = mLoadedMotions.front(); | 209 | LLMotion* cur_motionp = *loaded_motion_it; |
205 | mLoadedMotions.pop_front(); | ||
206 | 210 | ||
207 | // motion isn't playing, delete it | 211 | // motion isn't playing, delete it |
208 | if (!isMotionActive(cur_motionp)) | 212 | if (!isMotionActive(cur_motionp)) |
209 | { | 213 | { |
210 | mCharacter->requestStopMotion(cur_motionp); | 214 | motions_to_kill.insert(cur_motionp->getID()); |
211 | mAllMotions.erase(cur_motionp->getID()); | ||
212 | delete cur_motionp; | ||
213 | if (mLoadedMotions.size() <= MAX_MOTION_INSTANCES) | ||
214 | { | ||
215 | break; | ||
216 | } | ||
217 | } | ||
218 | else | ||
219 | { | ||
220 | // put active motion on back | ||
221 | mLoadedMotions.push_back(cur_motionp); | ||
222 | } | 215 | } |
223 | } | 216 | } |
224 | } | 217 | } |
218 | |||
219 | // clean up all inactive, loaded motions | ||
220 | for (std::set<LLUUID>::iterator motion_it = motions_to_kill.begin(); | ||
221 | motion_it != motions_to_kill.end(); | ||
222 | ++motion_it) | ||
223 | { | ||
224 | // look up the motion again by ID to get canonical instance | ||
225 | // and kill it only if that one is inactive | ||
226 | LLUUID motion_id = *motion_it; | ||
227 | LLMotion* motionp = findMotion(motion_id); | ||
228 | if (motionp && !isMotionActive(motionp)) | ||
229 | { | ||
230 | removeMotion(motion_id); | ||
231 | } | ||
232 | } | ||
233 | |||
234 | // add new motion to loaded list | ||
225 | mLoadedMotions.push_back(motionp); | 235 | mLoadedMotions.push_back(motionp); |
226 | } | 236 | } |
227 | 237 | ||
@@ -280,14 +290,24 @@ BOOL LLMotionController::addMotion( const LLUUID& id, LLMotionConstructor constr | |||
280 | void LLMotionController::removeMotion( const LLUUID& id) | 290 | void LLMotionController::removeMotion( const LLUUID& id) |
281 | { | 291 | { |
282 | LLMotion* motionp = findMotion(id); | 292 | LLMotion* motionp = findMotion(id); |
293 | |||
294 | removeMotionInstance(motionp); | ||
295 | |||
296 | mAllMotions.erase(id); | ||
297 | } | ||
298 | |||
299 | // removes instance of a motion from all runtime structures, but does | ||
300 | // not erase entry by ID, as this could be a duplicate instance | ||
301 | // use removeMotion(id) to remove all references to a given motion by id. | ||
302 | void LLMotionController::removeMotionInstance(LLMotion* motionp) | ||
303 | { | ||
283 | if (motionp) | 304 | if (motionp) |
284 | { | 305 | { |
285 | stopMotionLocally(id, TRUE); | 306 | stopMotionInstance(motionp, TRUE); |
286 | 307 | ||
287 | mLoadingMotions.erase(motionp); | 308 | mLoadingMotions.erase(motionp); |
288 | mLoadedMotions.remove(motionp); | 309 | mLoadedMotions.remove(motionp); |
289 | mActiveMotions.remove(motionp); | 310 | mActiveMotions.remove(motionp); |
290 | mAllMotions.erase(id); | ||
291 | delete motionp; | 311 | delete motionp; |
292 | } | 312 | } |
293 | } | 313 | } |
@@ -348,28 +368,39 @@ LLMotion* LLMotionController::createMotion( const LLUUID &id ) | |||
348 | //----------------------------------------------------------------------------- | 368 | //----------------------------------------------------------------------------- |
349 | BOOL LLMotionController::startMotion(const LLUUID &id, F32 start_offset) | 369 | BOOL LLMotionController::startMotion(const LLUUID &id, F32 start_offset) |
350 | { | 370 | { |
351 | // look for motion in our list of created motions | 371 | // do we have an instance of this motion for this character? |
352 | LLMotion *motion = createMotion(id); | 372 | LLMotion *motion = findMotion(id); |
373 | |||
374 | // motion that is stopping will be allowed to stop but | ||
375 | // replaced by a new instance of that motion | ||
376 | if (motion | ||
377 | && motion->canDeprecate() | ||
378 | && motion->getFadeWeight() > 0.01f // not LOD-ed out | ||
379 | && (motion->isBlending() || motion->getStopTime() != 0.f)) | ||
380 | { | ||
381 | deprecateMotionInstance(motion); | ||
382 | // force creation of new instance | ||
383 | motion = NULL; | ||
384 | } | ||
385 | |||
386 | // create new motion instance | ||
387 | if (!motion) | ||
388 | { | ||
389 | motion = createMotion(id); | ||
390 | } | ||
353 | 391 | ||
354 | if (!motion) | 392 | if (!motion) |
355 | { | 393 | { |
356 | return FALSE; | 394 | return FALSE; |
357 | } | 395 | } |
358 | //if the motion is already active, then we're done | 396 | //if the motion is already active and allows deprecation, then let it keep playing |
359 | else if (isMotionActive(motion)) // motion is playing and... | 397 | else if (motion->canDeprecate() && isMotionActive(motion)) |
360 | { | 398 | { |
361 | if (motion->isStopped()) // motion has been stopped | 399 | return TRUE; |
362 | { | ||
363 | deactivateMotion(motion, false); | ||
364 | } | ||
365 | else if (mTime < motion->mSendStopTimestamp) // motion is still active | ||
366 | { | ||
367 | return TRUE; | ||
368 | } | ||
369 | } | 400 | } |
370 | 401 | ||
371 | // llinfos << "Starting motion " << name << llendl; | 402 | // llinfos << "Starting motion " << name << llendl; |
372 | return activateMotion(motion, mTime - start_offset); | 403 | return activateMotionInstance(motion, mTime - start_offset); |
373 | } | 404 | } |
374 | 405 | ||
375 | 406 | ||
@@ -380,6 +411,12 @@ BOOL LLMotionController::stopMotionLocally(const LLUUID &id, BOOL stop_immediate | |||
380 | { | 411 | { |
381 | // if already inactive, return false | 412 | // if already inactive, return false |
382 | LLMotion *motion = findMotion(id); | 413 | LLMotion *motion = findMotion(id); |
414 | |||
415 | return stopMotionInstance(motion, stop_immediate); | ||
416 | } | ||
417 | |||
418 | BOOL LLMotionController::stopMotionInstance(LLMotion* motion, BOOL stop_immediate) | ||
419 | { | ||
383 | if (!motion) | 420 | if (!motion) |
384 | { | 421 | { |
385 | return FALSE; | 422 | return FALSE; |
@@ -396,7 +433,7 @@ BOOL LLMotionController::stopMotionLocally(const LLUUID &id, BOOL stop_immediate | |||
396 | 433 | ||
397 | if (stop_immediate) | 434 | if (stop_immediate) |
398 | { | 435 | { |
399 | deactivateMotion(motion, false); | 436 | deactivateMotionInstance(motion); |
400 | } | 437 | } |
401 | return TRUE; | 438 | return TRUE; |
402 | } | 439 | } |
@@ -492,7 +529,7 @@ void LLMotionController::updateMotionsByType(LLMotion::LLMotionBlendType anim_ty | |||
492 | { | 529 | { |
493 | if (motionp->isStopped() && mTime > motionp->getStopTime() + motionp->getEaseOutDuration()) | 530 | if (motionp->isStopped() && mTime > motionp->getStopTime() + motionp->getEaseOutDuration()) |
494 | { | 531 | { |
495 | deactivateMotion(motionp, false); | 532 | deactivateMotionInstance(motionp); |
496 | } | 533 | } |
497 | else if (motionp->isStopped() && mTime > motionp->getStopTime()) | 534 | else if (motionp->isStopped() && mTime > motionp->getStopTime()) |
498 | { | 535 | { |
@@ -510,7 +547,7 @@ void LLMotionController::updateMotionsByType(LLMotion::LLMotionBlendType anim_ty | |||
510 | if (mLastTime <= motionp->mSendStopTimestamp) | 547 | if (mLastTime <= motionp->mSendStopTimestamp) |
511 | { | 548 | { |
512 | mCharacter->requestStopMotion( motionp ); | 549 | mCharacter->requestStopMotion( motionp ); |
513 | stopMotionLocally(motionp->getID(), FALSE); | 550 | stopMotionInstance(motionp, FALSE); |
514 | } | 551 | } |
515 | } | 552 | } |
516 | else if (mTime >= motionp->mActivationTimestamp) | 553 | else if (mTime >= motionp->mActivationTimestamp) |
@@ -538,7 +575,7 @@ void LLMotionController::updateMotionsByType(LLMotion::LLMotionBlendType anim_ty | |||
538 | if (mLastTime <= motionp->mSendStopTimestamp) | 575 | if (mLastTime <= motionp->mSendStopTimestamp) |
539 | { | 576 | { |
540 | mCharacter->requestStopMotion( motionp ); | 577 | mCharacter->requestStopMotion( motionp ); |
541 | stopMotionLocally(motionp->getID(), FALSE); | 578 | stopMotionInstance(motionp, FALSE); |
542 | } | 579 | } |
543 | } | 580 | } |
544 | 581 | ||
@@ -546,7 +583,8 @@ void LLMotionController::updateMotionsByType(LLMotion::LLMotionBlendType anim_ty | |||
546 | { | 583 | { |
547 | if (motionp->isStopped() && mTime > motionp->getStopTime() + motionp->getEaseOutDuration()) | 584 | if (motionp->isStopped() && mTime > motionp->getStopTime() + motionp->getEaseOutDuration()) |
548 | { | 585 | { |
549 | deactivateMotion(motionp, true); | 586 | posep->setWeight(0.f); |
587 | deactivateMotionInstance(motionp); | ||
550 | } | 588 | } |
551 | continue; | 589 | continue; |
552 | } | 590 | } |
@@ -572,7 +610,8 @@ void LLMotionController::updateMotionsByType(LLMotion::LLMotionBlendType anim_ty | |||
572 | } | 610 | } |
573 | else | 611 | else |
574 | { | 612 | { |
575 | deactivateMotion(motionp, true); | 613 | posep->setWeight(0.f); |
614 | deactivateMotionInstance(motionp); | ||
576 | continue; | 615 | continue; |
577 | } | 616 | } |
578 | } | 617 | } |
@@ -617,7 +656,7 @@ void LLMotionController::updateMotionsByType(LLMotion::LLMotionBlendType anim_ty | |||
617 | if (mLastTime <= motionp->mSendStopTimestamp) | 656 | if (mLastTime <= motionp->mSendStopTimestamp) |
618 | { | 657 | { |
619 | mCharacter->requestStopMotion( motionp ); | 658 | mCharacter->requestStopMotion( motionp ); |
620 | stopMotionLocally(motionp->getID(), FALSE); | 659 | stopMotionInstance(motionp, FALSE); |
621 | } | 660 | } |
622 | } | 661 | } |
623 | 662 | ||
@@ -661,7 +700,7 @@ void LLMotionController::updateMotionsByType(LLMotion::LLMotionBlendType anim_ty | |||
661 | // propagate this to the network | 700 | // propagate this to the network |
662 | // as not all viewers are guaranteed to have access to the same logic | 701 | // as not all viewers are guaranteed to have access to the same logic |
663 | mCharacter->requestStopMotion( motionp ); | 702 | mCharacter->requestStopMotion( motionp ); |
664 | stopMotionLocally(motionp->getID(), FALSE); | 703 | stopMotionInstance(motionp, FALSE); |
665 | } | 704 | } |
666 | 705 | ||
667 | } | 706 | } |
@@ -733,7 +772,7 @@ void LLMotionController::updateMotion() | |||
733 | // this motion should be playing | 772 | // this motion should be playing |
734 | if (!motionp->isStopped()) | 773 | if (!motionp->isStopped()) |
735 | { | 774 | { |
736 | activateMotion(motionp, mTime); | 775 | activateMotionInstance(motionp, mTime); |
737 | } | 776 | } |
738 | } | 777 | } |
739 | else if (status == LLMotion::STATUS_FAILURE) | 778 | else if (status == LLMotion::STATUS_FAILURE) |
@@ -741,6 +780,7 @@ void LLMotionController::updateMotion() | |||
741 | llinfos << "Motion " << motionp->getID() << " init failed." << llendl; | 780 | llinfos << "Motion " << motionp->getID() << " init failed." << llendl; |
742 | sRegistry.markBad(motionp->getID()); | 781 | sRegistry.markBad(motionp->getID()); |
743 | mLoadingMotions.erase(curiter); | 782 | mLoadingMotions.erase(curiter); |
783 | |||
744 | mAllMotions.erase(motionp->getID()); | 784 | mAllMotions.erase(motionp->getID()); |
745 | delete motionp; | 785 | delete motionp; |
746 | } | 786 | } |
@@ -773,9 +813,9 @@ void LLMotionController::updateMotion() | |||
773 | 813 | ||
774 | 814 | ||
775 | //----------------------------------------------------------------------------- | 815 | //----------------------------------------------------------------------------- |
776 | // activateMotion() | 816 | // activateMotionInstance() |
777 | //----------------------------------------------------------------------------- | 817 | //----------------------------------------------------------------------------- |
778 | BOOL LLMotionController::activateMotion(LLMotion *motion, F32 time) | 818 | BOOL LLMotionController::activateMotionInstance(LLMotion *motion, F32 time) |
779 | { | 819 | { |
780 | if (mLoadingMotions.find(motion) != mLoadingMotions.end()) | 820 | if (mLoadingMotions.find(motion) != mLoadingMotions.end()) |
781 | { | 821 | { |
@@ -818,23 +858,38 @@ BOOL LLMotionController::activateMotion(LLMotion *motion, F32 time) | |||
818 | } | 858 | } |
819 | 859 | ||
820 | //----------------------------------------------------------------------------- | 860 | //----------------------------------------------------------------------------- |
821 | // deactivateMotion() | 861 | // deactivateMotionInstance() |
822 | //----------------------------------------------------------------------------- | 862 | //----------------------------------------------------------------------------- |
823 | BOOL LLMotionController::deactivateMotion(LLMotion *motion, bool remove_weight) | 863 | BOOL LLMotionController::deactivateMotionInstance(LLMotion *motion) |
824 | { | 864 | { |
825 | if( remove_weight ) | 865 | motion->deactivate(); |
866 | |||
867 | motion_set_t::iterator found_it = mDeprecatedMotions.find(motion); | ||
868 | if (found_it != mDeprecatedMotions.end()) | ||
826 | { | 869 | { |
827 | // immediately remove pose weighting instead of letting it time out | 870 | // deprecated motions need to be completely excised |
828 | LLPose *posep = motion->getPose(); | 871 | removeMotionInstance(motion); |
829 | posep->setWeight(0.f); | 872 | mDeprecatedMotions.erase(found_it); |
873 | } | ||
874 | else | ||
875 | { | ||
876 | // for motions that we are keeping, simply remove from active queue | ||
877 | mActiveMotions.remove(motion); | ||
830 | } | 878 | } |
831 | |||
832 | motion->deactivate(); | ||
833 | mActiveMotions.remove(motion); | ||
834 | 879 | ||
835 | return TRUE; | 880 | return TRUE; |
836 | } | 881 | } |
837 | 882 | ||
883 | void LLMotionController::deprecateMotionInstance(LLMotion* motion) | ||
884 | { | ||
885 | mDeprecatedMotions.insert(motion); | ||
886 | |||
887 | //fade out deprecated motion | ||
888 | stopMotionInstance(motion, FALSE); | ||
889 | //no longer canonical | ||
890 | mAllMotions.erase(motion->getID()); | ||
891 | } | ||
892 | |||
838 | //----------------------------------------------------------------------------- | 893 | //----------------------------------------------------------------------------- |
839 | // isMotionActive() | 894 | // isMotionActive() |
840 | //----------------------------------------------------------------------------- | 895 | //----------------------------------------------------------------------------- |
@@ -857,7 +912,7 @@ bool LLMotionController::isMotionLoading(LLMotion* motion) | |||
857 | //----------------------------------------------------------------------------- | 912 | //----------------------------------------------------------------------------- |
858 | LLMotion *LLMotionController::findMotion(const LLUUID& id) | 913 | LLMotion *LLMotionController::findMotion(const LLUUID& id) |
859 | { | 914 | { |
860 | return mAllMotions[id]; | 915 | return get_if_there<LLUUID, LLMotion*>(mAllMotions, id, NULL); |
861 | } | 916 | } |
862 | 917 | ||
863 | //----------------------------------------------------------------------------- | 918 | //----------------------------------------------------------------------------- |
diff --git a/linden/indra/llcharacter/llmotioncontroller.h b/linden/indra/llcharacter/llmotioncontroller.h index 959a16a..efc12d5 100644 --- a/linden/indra/llcharacter/llmotioncontroller.h +++ b/linden/indra/llcharacter/llmotioncontroller.h | |||
@@ -179,16 +179,21 @@ public: | |||
179 | LLMotion *findMotion( const LLUUID& id ); | 179 | LLMotion *findMotion( const LLUUID& id ); |
180 | 180 | ||
181 | protected: | 181 | protected: |
182 | // internal operations act on motion instances directly | ||
183 | // as there can be duplicate motions per id during blending overlap | ||
182 | void deleteAllMotions(); | 184 | void deleteAllMotions(); |
183 | void addLoadedMotion(LLMotion *motion); | 185 | void addLoadedMotion(LLMotion *motion); |
184 | BOOL activateMotion(LLMotion *motion, F32 time); | 186 | BOOL activateMotionInstance(LLMotion *motion, F32 time); |
185 | BOOL deactivateMotion(LLMotion *motion, bool remove_weight); | 187 | BOOL deactivateMotionInstance(LLMotion *motion); |
188 | void deprecateMotionInstance(LLMotion* motion); | ||
189 | BOOL stopMotionInstance(LLMotion *motion, BOOL stop_imemdiate); | ||
190 | void removeMotionInstance(LLMotion* motion); | ||
186 | void updateRegularMotions(); | 191 | void updateRegularMotions(); |
187 | void updateAdditiveMotions(); | 192 | void updateAdditiveMotions(); |
188 | void resetJointSignatures(); | 193 | void resetJointSignatures(); |
189 | void updateMotionsByType(LLMotion::LLMotionBlendType motion_type); | 194 | void updateMotionsByType(LLMotion::LLMotionBlendType motion_type); |
190 | protected: | ||
191 | 195 | ||
196 | protected: | ||
192 | F32 mTimeFactor; | 197 | F32 mTimeFactor; |
193 | static LLMotionRegistry sRegistry; | 198 | static LLMotionRegistry sRegistry; |
194 | LLPoseBlender mPoseBlender; | 199 | LLPoseBlender mPoseBlender; |
@@ -203,11 +208,13 @@ protected: | |||
203 | // Once an animations is loaded, it will be initialized and put on the mLoadedMotions deque. | 208 | // Once an animations is loaded, it will be initialized and put on the mLoadedMotions deque. |
204 | // Any animation that is currently playing also sits in the mActiveMotions list. | 209 | // Any animation that is currently playing also sits in the mActiveMotions list. |
205 | 210 | ||
206 | std::map<LLUUID, LLMotion*> mAllMotions; | 211 | typedef std::map<LLUUID, LLMotion*> motion_map_t; |
212 | motion_map_t mAllMotions; | ||
207 | 213 | ||
208 | motion_set_t mLoadingMotions; | 214 | motion_set_t mLoadingMotions; |
209 | motion_list_t mLoadedMotions; | 215 | motion_list_t mLoadedMotions; |
210 | motion_list_t mActiveMotions; | 216 | motion_list_t mActiveMotions; |
217 | motion_set_t mDeprecatedMotions; | ||
211 | 218 | ||
212 | LLFrameTimer mTimer; | 219 | LLFrameTimer mTimer; |
213 | F32 mTime; | 220 | F32 mTime; |
diff --git a/linden/indra/llcharacter/llpose.cpp b/linden/indra/llcharacter/llpose.cpp index ccedc1e..a07cd58 100644 --- a/linden/indra/llcharacter/llpose.cpp +++ b/linden/indra/llcharacter/llpose.cpp | |||
@@ -275,9 +275,9 @@ void LLJointStateBlender::blendJointStates(BOOL apply_now) | |||
275 | joint_state_index < JSB_NUM_JOINT_STATES && mJointStates[joint_state_index] != NULL; | 275 | joint_state_index < JSB_NUM_JOINT_STATES && mJointStates[joint_state_index] != NULL; |
276 | joint_state_index++) | 276 | joint_state_index++) |
277 | { | 277 | { |
278 | U32 current_usage = mJointStates[joint_state_index]->getUsage(); | ||
279 | F32 current_weight = mJointStates[joint_state_index]->getWeight(); | ||
280 | LLJointState* jsp = mJointStates[joint_state_index]; | 278 | LLJointState* jsp = mJointStates[joint_state_index]; |
279 | U32 current_usage = jsp->getUsage(); | ||
280 | F32 current_weight = jsp->getWeight(); | ||
281 | 281 | ||
282 | if (current_weight == 0.f) | 282 | if (current_weight == 0.f) |
283 | { | 283 | { |
@@ -292,17 +292,14 @@ void LLJointStateBlender::blendJointStates(BOOL apply_now) | |||
292 | 292 | ||
293 | // add in pos for this jointstate modulated by weight | 293 | // add in pos for this jointstate modulated by weight |
294 | added_pos += jsp->getPosition() * (new_weight_sum - sum_weights[POS_WEIGHT]); | 294 | added_pos += jsp->getPosition() * (new_weight_sum - sum_weights[POS_WEIGHT]); |
295 | //sum_weights[POS_WEIGHT] = new_weight_sum; | ||
296 | } | 295 | } |
297 | 296 | ||
298 | // now do scale | ||
299 | if(current_usage & LLJointState::SCALE) | 297 | if(current_usage & LLJointState::SCALE) |
300 | { | 298 | { |
301 | F32 new_weight_sum = llmin(1.f, current_weight + sum_weights[SCALE_WEIGHT]); | 299 | F32 new_weight_sum = llmin(1.f, current_weight + sum_weights[SCALE_WEIGHT]); |
302 | 300 | ||
303 | // add in scale for this jointstate modulated by weight | 301 | // add in scale for this jointstate modulated by weight |
304 | added_scale += jsp->getScale() * (new_weight_sum - sum_weights[SCALE_WEIGHT]); | 302 | added_scale += jsp->getScale() * (new_weight_sum - sum_weights[SCALE_WEIGHT]); |
305 | //sum_weights[SCALE_WEIGHT] = new_weight_sum; | ||
306 | } | 303 | } |
307 | 304 | ||
308 | if (current_usage & LLJointState::ROT) | 305 | if (current_usage & LLJointState::ROT) |
@@ -311,7 +308,6 @@ void LLJointStateBlender::blendJointStates(BOOL apply_now) | |||
311 | 308 | ||
312 | // add in rotation for this jointstate modulated by weight | 309 | // add in rotation for this jointstate modulated by weight |
313 | added_rot = nlerp((new_weight_sum - sum_weights[ROT_WEIGHT]), added_rot, jsp->getRotation()) * added_rot; | 310 | added_rot = nlerp((new_weight_sum - sum_weights[ROT_WEIGHT]), added_rot, jsp->getRotation()) * added_rot; |
314 | //sum_weights[ROT_WEIGHT] = new_weight_sum; | ||
315 | } | 311 | } |
316 | } | 312 | } |
317 | else | 313 | else |
@@ -326,13 +322,13 @@ void LLJointStateBlender::blendJointStates(BOOL apply_now) | |||
326 | F32 new_weight_sum = llmin(1.f, current_weight + sum_weights[POS_WEIGHT]); | 322 | F32 new_weight_sum = llmin(1.f, current_weight + sum_weights[POS_WEIGHT]); |
327 | 323 | ||
328 | // blend positions from both | 324 | // blend positions from both |
329 | blended_pos = lerp(mJointStates[joint_state_index]->getPosition(), blended_pos, sum_weights[POS_WEIGHT] / new_weight_sum); | 325 | blended_pos = lerp(jsp->getPosition(), blended_pos, sum_weights[POS_WEIGHT] / new_weight_sum); |
330 | sum_weights[POS_WEIGHT] = new_weight_sum; | 326 | sum_weights[POS_WEIGHT] = new_weight_sum; |
331 | } | 327 | } |
332 | else | 328 | else |
333 | { | 329 | { |
334 | // copy position from current | 330 | // copy position from current |
335 | blended_pos = mJointStates[joint_state_index]->getPosition(); | 331 | blended_pos = jsp->getPosition(); |
336 | sum_weights[POS_WEIGHT] = current_weight; | 332 | sum_weights[POS_WEIGHT] = current_weight; |
337 | } | 333 | } |
338 | } | 334 | } |
@@ -345,13 +341,13 @@ void LLJointStateBlender::blendJointStates(BOOL apply_now) | |||
345 | F32 new_weight_sum = llmin(1.f, current_weight + sum_weights[SCALE_WEIGHT]); | 341 | F32 new_weight_sum = llmin(1.f, current_weight + sum_weights[SCALE_WEIGHT]); |
346 | 342 | ||
347 | // blend scales from both | 343 | // blend scales from both |
348 | blended_scale = lerp(mJointStates[joint_state_index]->getScale(), blended_scale, sum_weights[SCALE_WEIGHT] / new_weight_sum); | 344 | blended_scale = lerp(jsp->getScale(), blended_scale, sum_weights[SCALE_WEIGHT] / new_weight_sum); |
349 | sum_weights[SCALE_WEIGHT] = new_weight_sum; | 345 | sum_weights[SCALE_WEIGHT] = new_weight_sum; |
350 | } | 346 | } |
351 | else | 347 | else |
352 | { | 348 | { |
353 | // copy scale from current | 349 | // copy scale from current |
354 | blended_scale = mJointStates[joint_state_index]->getScale(); | 350 | blended_scale = jsp->getScale(); |
355 | sum_weights[SCALE_WEIGHT] = current_weight; | 351 | sum_weights[SCALE_WEIGHT] = current_weight; |
356 | } | 352 | } |
357 | } | 353 | } |
@@ -364,13 +360,13 @@ void LLJointStateBlender::blendJointStates(BOOL apply_now) | |||
364 | F32 new_weight_sum = llmin(1.f, current_weight + sum_weights[ROT_WEIGHT]); | 360 | F32 new_weight_sum = llmin(1.f, current_weight + sum_weights[ROT_WEIGHT]); |
365 | 361 | ||
366 | // blend rotations from both | 362 | // blend rotations from both |
367 | blended_rot = nlerp(sum_weights[ROT_WEIGHT] / new_weight_sum, mJointStates[joint_state_index]->getRotation(), blended_rot); | 363 | blended_rot = nlerp(sum_weights[ROT_WEIGHT] / new_weight_sum, jsp->getRotation(), blended_rot); |
368 | sum_weights[ROT_WEIGHT] = new_weight_sum; | 364 | sum_weights[ROT_WEIGHT] = new_weight_sum; |
369 | } | 365 | } |
370 | else | 366 | else |
371 | { | 367 | { |
372 | // copy rotation from current | 368 | // copy rotation from current |
373 | blended_rot = mJointStates[joint_state_index]->getRotation(); | 369 | blended_rot = jsp->getRotation(); |
374 | sum_weights[ROT_WEIGHT] = current_weight; | 370 | sum_weights[ROT_WEIGHT] = current_weight; |
375 | } | 371 | } |
376 | } | 372 | } |
diff --git a/linden/indra/llcharacter/llpose.h b/linden/indra/llcharacter/llpose.h index f57f7de..4e1bb64 100644 --- a/linden/indra/llcharacter/llpose.h +++ b/linden/indra/llcharacter/llpose.h | |||
@@ -81,7 +81,7 @@ public: | |||
81 | S32 getNumJointStates() const; | 81 | S32 getNumJointStates() const; |
82 | }; | 82 | }; |
83 | 83 | ||
84 | const S32 JSB_NUM_JOINT_STATES = 4; | 84 | const S32 JSB_NUM_JOINT_STATES = 6; |
85 | 85 | ||
86 | class LLJointStateBlender | 86 | class LLJointStateBlender |
87 | { | 87 | { |