aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden
diff options
context:
space:
mode:
authorArmin Weatherwax2010-08-30 14:21:00 +0200
committerMcCabe Maxsted2010-09-01 09:40:35 -0700
commitf15b542c19437670f7f0b6303ec7c259f778c43b (patch)
tree8183b007ea80245e50642e282080d06e5b826dad /linden
parentquick hack: preview animation locally on own avatar when uploading. (diff)
downloadmeta-impy-f15b542c19437670f7f0b6303ec7c259f778c43b.zip
meta-impy-f15b542c19437670f7f0b6303ec7c259f778c43b.tar.gz
meta-impy-f15b542c19437670f7f0b6303ec7c259f778c43b.tar.bz2
meta-impy-f15b542c19437670f7f0b6303ec7c259f778c43b.tar.xz
Henri Beauchamp: polish up of the animation preview when uploading
Diffstat (limited to 'linden')
-rw-r--r--linden/indra/newview/app_settings/settings.xml25
-rw-r--r--linden/indra/newview/llfloateranimpreview.cpp459
-rw-r--r--linden/indra/newview/llfloateranimpreview.h12
-rw-r--r--linden/indra/newview/skins/default/xui/en-us/floater_animation_preview.xml9
4 files changed, 406 insertions, 99 deletions
diff --git a/linden/indra/newview/app_settings/settings.xml b/linden/indra/newview/app_settings/settings.xml
index b1917ec..7071de2 100644
--- a/linden/indra/newview/app_settings/settings.xml
+++ b/linden/indra/newview/app_settings/settings.xml
@@ -518,6 +518,17 @@
518 <key>Value</key> 518 <key>Value</key>
519 <integer>0</integer> 519 <integer>0</integer>
520 </map> 520 </map>
521 <key>PreviewAnimInWorld</key>
522 <map>
523 <key>Comment</key>
524 <string>Play animation preview in-world when uploading</string>
525 <key>Persist</key>
526 <integer>1</integer>
527 <key>Type</key>
528 <string>Boolean</string>
529 <key>Value</key>
530 <integer>0</integer>
531 </map>
521 <key>PrivateLookAtTarget</key> 532 <key>PrivateLookAtTarget</key>
522 <map> 533 <map>
523 <key>Comment</key> 534 <key>Comment</key>
@@ -8243,10 +8254,10 @@
8243 <string>Rect</string> 8254 <string>Rect</string>
8244 <key>Value</key> 8255 <key>Value</key>
8245 <array> 8256 <array>
8246 <integer>11</integer> 8257 <integer>0</integer>
8247 <integer>459</integer> 8258 <integer>85</integer>
8248 <integer>311</integer> 8259 <integer>300</integer>
8249 <integer>173</integer> 8260 <integer>0</integer>
8250 </array> 8261 </array>
8251 </map> 8262 </map>
8252 <key>PreviewClassifiedRect</key> 8263 <key>PreviewClassifiedRect</key>
@@ -8307,9 +8318,9 @@
8307 <string>Rect</string> 8318 <string>Rect</string>
8308 <key>Value</key> 8319 <key>Value</key>
8309 <array> 8320 <array>
8310 <integer>0</integer> 8321 <integer>0</integer>
8311 <integer>530</integer> 8322 <integer>85</integer>
8312 <integer>420</integer> 8323 <integer>300</integer>
8313 <integer>0</integer> 8324 <integer>0</integer>
8314 </array> 8325 </array>
8315 </map> 8326 </map>
diff --git a/linden/indra/newview/llfloateranimpreview.cpp b/linden/indra/newview/llfloateranimpreview.cpp
index ce7737d..da1d5fc 100644
--- a/linden/indra/newview/llfloateranimpreview.cpp
+++ b/linden/indra/newview/llfloateranimpreview.cpp
@@ -162,12 +162,27 @@ BOOL LLFloaterAnimPreview::postBuild()
162 return FALSE; 162 return FALSE;
163 } 163 }
164 164
165 mInWorld = gSavedSettings.getBOOL("PreviewAnimInWorld");
166
165 childSetCommitCallback("name_form", onCommitName, this); 167 childSetCommitCallback("name_form", onCommitName, this);
166 168
167 childSetLabelArg("ok_btn", "[UPLOADFEE]", gHippoGridManager->getConnectedGrid()->getUploadFee()); 169 childSetLabelArg("ok_btn", "[UPLOADFEE]", gHippoGridManager->getConnectedGrid()->getUploadFee());
168 childSetAction("ok_btn", onBtnOK, this); 170 childSetAction("ok_btn", onBtnOK, this);
169 setDefaultBtn(); 171 setDefaultBtn();
170 172
173 if (mInWorld)
174 {
175 r = getRect();
176 translate(0, 230);
177 reshape(r.getWidth(), r.getHeight() - 230);
178 childSetValue("bad_animation_text", getString("in_world"));
179 childShow("bad_animation_text");
180 }
181 else
182 {
183 childHide("bad_animation_text");
184 }
185
171 mPreviewRect.set(PREVIEW_HPAD, 186 mPreviewRect.set(PREVIEW_HPAD,
172 PREVIEW_TEXTURE_HEIGHT, 187 PREVIEW_TEXTURE_HEIGHT,
173 getRect().getWidth() - PREVIEW_HPAD, 188 getRect().getWidth() - PREVIEW_HPAD,
@@ -209,8 +224,6 @@ BOOL LLFloaterAnimPreview::postBuild()
209 r.set(r.mRight + PREVIEW_HPAD, y, getRect().getWidth() - PREVIEW_HPAD, y - BTN_HEIGHT); 224 r.set(r.mRight + PREVIEW_HPAD, y, getRect().getWidth() - PREVIEW_HPAD, y - BTN_HEIGHT);
210 //childSetCommitCallback("playback_slider", onSliderMove, this); 225 //childSetCommitCallback("playback_slider", onSliderMove, this);
211 226
212 childHide("bad_animation_text");
213
214 //childSetCommitCallback("preview_base_anim", onCommitBaseAnim, this); 227 //childSetCommitCallback("preview_base_anim", onCommitBaseAnim, this);
215 //childSetValue("preview_base_anim", "Standing"); 228 //childSetValue("preview_base_anim", "Standing");
216 229
@@ -275,7 +288,14 @@ BOOL LLFloaterAnimPreview::postBuild()
275 // motion will be returned, but it will be in a load-pending state, as this is a new motion 288 // motion will be returned, but it will be in a load-pending state, as this is a new motion
276 // this motion will not request an asset transfer until next update, so we have a chance to 289 // this motion will not request an asset transfer until next update, so we have a chance to
277 // load the keyframe data locally 290 // load the keyframe data locally
278 motionp = (LLKeyframeMotion*)mAnimPreview->getDummyAvatar()->createMotion(mMotionID); 291 if (mInWorld)
292 {
293 motionp = (LLKeyframeMotion*)gAgent.getAvatarObject()->createMotion(mMotionID);
294 }
295 else
296 {
297 motionp = (LLKeyframeMotion*)mAnimPreview->getDummyAvatar()->createMotion(mMotionID);
298 }
279 299
280 // create data buffer for keyframe initialization 300 // create data buffer for keyframe initialization
281 S32 buffer_size = loaderp->getOutputSize(); 301 S32 buffer_size = loaderp->getOutputSize();
@@ -293,24 +313,30 @@ BOOL LLFloaterAnimPreview::postBuild()
293 if (success) 313 if (success)
294 { 314 {
295 setAnimCallbacks() ; 315 setAnimCallbacks() ;
296
297 const LLBBoxLocal &pelvis_bbox = motionp->getPelvisBBox();
298 316
299 LLVector3 temp = pelvis_bbox.getCenter(); 317 if (!mInWorld)
300 // only consider XY? 318 {
301 //temp.mV[VZ] = 0.f; 319 const LLBBoxLocal &pelvis_bbox = motionp->getPelvisBBox();
302 F32 pelvis_offset = temp.magVec();
303 320
304 temp = pelvis_bbox.getExtent(); 321 LLVector3 temp = pelvis_bbox.getCenter();
305 //temp.mV[VZ] = 0.f; 322 // only consider XY?
306 F32 pelvis_max_displacement = pelvis_offset + (temp.magVec() * 0.5f) + 1.f; 323 //temp.mV[VZ] = 0.f;
307 324 F32 pelvis_offset = temp.magVec();
308 F32 camera_zoom = LLViewerCamera::getInstance()->getDefaultFOV() / (2.f * atan(pelvis_max_displacement / PREVIEW_CAMERA_DISTANCE)); 325
309 326 temp = pelvis_bbox.getExtent();
310 mAnimPreview->setZoom(camera_zoom); 327 //temp.mV[VZ] = 0.f;
328 F32 pelvis_max_displacement = pelvis_offset + (temp.magVec() * 0.5f) + 1.f;
329
330 F32 camera_zoom = LLViewerCamera::getInstance()->getDefaultFOV() / (2.f * atan(pelvis_max_displacement / PREVIEW_CAMERA_DISTANCE));
331
332 mAnimPreview->setZoom(camera_zoom);
333 }
311 334
312 motionp->setName(childGetValue("name_form").asString()); 335 motionp->setName(childGetValue("name_form").asString());
313 mAnimPreview->getDummyAvatar()->startMotion(mMotionID); 336 if (!mInWorld)
337 {
338 mAnimPreview->getDummyAvatar()->startMotion(mMotionID);
339 }
314 childSetMinValue("playback_slider", 0.0); 340 childSetMinValue("playback_slider", 0.0);
315 childSetMaxValue("playback_slider", 1.0); 341 childSetMaxValue("playback_slider", 1.0);
316 342
@@ -326,7 +352,6 @@ BOOL LLFloaterAnimPreview::postBuild()
326 seconds_string = llformat(" - %.2f seconds", motionp->getDuration()); 352 seconds_string = llformat(" - %.2f seconds", motionp->getDuration());
327 353
328 setTitle(mFilename + std::string(seconds_string)); 354 setTitle(mFilename + std::string(seconds_string));
329
330 } 355 }
331 else 356 else
332 { 357 {
@@ -372,13 +397,26 @@ BOOL LLFloaterAnimPreview::postBuild()
372//----------------------------------------------------------------------------- 397//-----------------------------------------------------------------------------
373LLFloaterAnimPreview::~LLFloaterAnimPreview() 398LLFloaterAnimPreview::~LLFloaterAnimPreview()
374{ 399{
375 if (mMotionID.notNull() && mAnimPreview) 400 if (mInWorld)
376 { 401 {
377 mAnimPreview->getDummyAvatar()->deactivateAllMotions(); 402 LLVOAvatar* avatarp = gAgent.getAvatarObject();
378 mAnimPreview->getDummyAvatar()->removeMotion(mMotionID); 403 if (avatarp)
379 LLKeyframeDataCache::removeKeyframeData(mMotionID); 404 {
405 if (mMotionID.notNull())
406 {
407 avatarp->stopMotion(mMotionID, TRUE);
408 avatarp->removeMotion(mMotionID);
409 }
410 avatarp->deactivateAllMotions();
411 avatarp->startMotion(ANIM_AGENT_HEAD_ROT);
412 avatarp->startMotion(ANIM_AGENT_EYE);
413 avatarp->startMotion(ANIM_AGENT_BODY_NOISE);
414 avatarp->startMotion(ANIM_AGENT_BREATHE_ROT);
415 avatarp->startMotion(ANIM_AGENT_HAND_MOTION);
416 avatarp->startMotion(ANIM_AGENT_PELVIS_FIX);
417 avatarp->startMotion(ANIM_AGENT_STAND, BASE_ANIM_TIME_OFFSET);
418 }
380 } 419 }
381
382 delete mAnimPreview; 420 delete mAnimPreview;
383 mAnimPreview = NULL; 421 mAnimPreview = NULL;
384 422
@@ -395,9 +433,9 @@ void LLFloaterAnimPreview::draw()
395 433
396 refresh(); 434 refresh();
397 435
398 if (mMotionID.notNull() && mAnimPreview) 436 if (mMotionID.notNull() && mAnimPreview && !mInWorld)
399 { 437 {
400/* gGL.color3f(1.f, 1.f, 1.f); 438 gGL.color3f(1.f, 1.f, 1.f);
401 439
402 gGL.getTexUnit(0)->bind(mAnimPreview->getTexture()); 440 gGL.getTexUnit(0)->bind(mAnimPreview->getTexture());
403 441
@@ -415,7 +453,7 @@ void LLFloaterAnimPreview::draw()
415 gGL.end(); 453 gGL.end();
416 454
417 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); 455 gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
418*/ 456
419 LLVOAvatar* avatarp = mAnimPreview->getDummyAvatar(); 457 LLVOAvatar* avatarp = mAnimPreview->getDummyAvatar();
420 if (!avatarp->areAnimationsPaused()) 458 if (!avatarp->areAnimationsPaused())
421 { 459 {
@@ -429,7 +467,20 @@ void LLFloaterAnimPreview::draw()
429//----------------------------------------------------------------------------- 467//-----------------------------------------------------------------------------
430void LLFloaterAnimPreview::resetMotion() 468void LLFloaterAnimPreview::resetMotion()
431{ 469{
432 LLVOAvatar* avatarp = mAnimPreview->getDummyAvatar(); 470 LLVOAvatar* avatarp;
471 if (mInWorld)
472 {
473 avatarp = gAgent.getAvatarObject();
474 }
475 else
476 {
477 avatarp = mAnimPreview->getDummyAvatar();
478 }
479 if (!avatarp)
480 {
481 return;
482 }
483
433 BOOL paused = avatarp->areAnimationsPaused(); 484 BOOL paused = avatarp->areAnimationsPaused();
434 485
435 // *TODO: Fix awful casting hack 486 // *TODO: Fix awful casting hack
@@ -459,13 +510,13 @@ void LLFloaterAnimPreview::resetMotion()
459 mPauseRequest = NULL; 510 mPauseRequest = NULL;
460 } 511 }
461} 512}
462/* 513
463//----------------------------------------------------------------------------- 514//-----------------------------------------------------------------------------
464// handleMouseDown() 515// handleMouseDown()
465//----------------------------------------------------------------------------- 516//-----------------------------------------------------------------------------
466BOOL LLFloaterAnimPreview::handleMouseDown(S32 x, S32 y, MASK mask) 517BOOL LLFloaterAnimPreview::handleMouseDown(S32 x, S32 y, MASK mask)
467{ 518{
468 if (mPreviewRect.pointInRect(x, y)) 519 if (!mInWorld && mPreviewRect.pointInRect(x, y))
469 { 520 {
470 bringToFront( x, y ); 521 bringToFront( x, y );
471 gFocusMgr.setMouseCapture(this); 522 gFocusMgr.setMouseCapture(this);
@@ -483,8 +534,11 @@ BOOL LLFloaterAnimPreview::handleMouseDown(S32 x, S32 y, MASK mask)
483//----------------------------------------------------------------------------- 534//-----------------------------------------------------------------------------
484BOOL LLFloaterAnimPreview::handleMouseUp(S32 x, S32 y, MASK mask) 535BOOL LLFloaterAnimPreview::handleMouseUp(S32 x, S32 y, MASK mask)
485{ 536{
486 gFocusMgr.setMouseCapture(FALSE); 537 if (!mInWorld)
487 gViewerWindow->showCursor(); 538 {
539 gFocusMgr.setMouseCapture(FALSE);
540 gViewerWindow->showCursor();
541 }
488 return LLFloater::handleMouseUp(x, y, mask); 542 return LLFloater::handleMouseUp(x, y, mask);
489} 543}
490 544
@@ -493,6 +547,11 @@ BOOL LLFloaterAnimPreview::handleMouseUp(S32 x, S32 y, MASK mask)
493//----------------------------------------------------------------------------- 547//-----------------------------------------------------------------------------
494BOOL LLFloaterAnimPreview::handleHover(S32 x, S32 y, MASK mask) 548BOOL LLFloaterAnimPreview::handleHover(S32 x, S32 y, MASK mask)
495{ 549{
550 if (mInWorld)
551 {
552 return TRUE;
553 }
554
496 MASK local_mask = mask & ~MASK_ALT; 555 MASK local_mask = mask & ~MASK_ALT;
497 556
498 if (mAnimPreview && hasMouseCapture()) 557 if (mAnimPreview && hasMouseCapture())
@@ -548,9 +607,11 @@ BOOL LLFloaterAnimPreview::handleHover(S32 x, S32 y, MASK mask)
548//----------------------------------------------------------------------------- 607//-----------------------------------------------------------------------------
549BOOL LLFloaterAnimPreview::handleScrollWheel(S32 x, S32 y, S32 clicks) 608BOOL LLFloaterAnimPreview::handleScrollWheel(S32 x, S32 y, S32 clicks)
550{ 609{
551 mAnimPreview->zoom((F32)clicks * -0.2f); 610 if (!mInWorld)
552 mAnimPreview->requestUpdate(); 611 {
553 612 mAnimPreview->zoom((F32)clicks * -0.2f);
613 mAnimPreview->requestUpdate();
614 }
554 return TRUE; 615 return TRUE;
555} 616}
556 617
@@ -559,9 +620,12 @@ BOOL LLFloaterAnimPreview::handleScrollWheel(S32 x, S32 y, S32 clicks)
559//----------------------------------------------------------------------------- 620//-----------------------------------------------------------------------------
560void LLFloaterAnimPreview::onMouseCaptureLost() 621void LLFloaterAnimPreview::onMouseCaptureLost()
561{ 622{
562 gViewerWindow->showCursor(); 623 if (!mInWorld)
624 {
625 gViewerWindow->showCursor();
626 }
563} 627}
564*/ 628
565//----------------------------------------------------------------------------- 629//-----------------------------------------------------------------------------
566// onBtnPlay() 630// onBtnPlay()
567//----------------------------------------------------------------------------- 631//-----------------------------------------------------------------------------
@@ -571,9 +635,25 @@ void LLFloaterAnimPreview::onBtnPlay(void* user_data)
571 if (!previewp->getEnabled()) 635 if (!previewp->getEnabled())
572 return; 636 return;
573 637
574 if (previewp->mMotionID.notNull() && previewp->mAnimPreview) 638 if (previewp->mMotionID.notNull())
575 { 639 {
576 LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar(); 640 LLVOAvatar* avatarp;
641 if (previewp->mInWorld)
642 {
643 if (!gAgent.getAvatarObject())
644 {
645 return;
646 }
647 avatarp = gAgent.getAvatarObject();
648 }
649 else
650 {
651 if (!previewp->mAnimPreview)
652 {
653 return;
654 }
655 avatarp = previewp->mAnimPreview->getDummyAvatar();
656 }
577 657
578 if(!avatarp->isMotionActive(previewp->mMotionID)) 658 if(!avatarp->isMotionActive(previewp->mMotionID))
579 { 659 {
@@ -603,9 +683,25 @@ void LLFloaterAnimPreview::onBtnStop(void* user_data)
603 if (!previewp->getEnabled()) 683 if (!previewp->getEnabled())
604 return; 684 return;
605 685
606 if (previewp->mMotionID.notNull() && previewp->mAnimPreview) 686 if (previewp->mMotionID.notNull())
607 { 687 {
608 LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar(); 688 LLVOAvatar* avatarp;
689 if (previewp->mInWorld)
690 {
691 if (!gAgent.getAvatarObject())
692 {
693 return;
694 }
695 avatarp = gAgent.getAvatarObject();
696 }
697 else
698 {
699 if (!previewp->mAnimPreview)
700 {
701 return;
702 }
703 avatarp = previewp->mAnimPreview->getDummyAvatar();
704 }
609 previewp->resetMotion(); 705 previewp->resetMotion();
610 previewp->mPauseRequest = avatarp->requestPause(); 706 previewp->mPauseRequest = avatarp->requestPause();
611 } 707 }
@@ -620,21 +716,33 @@ void LLFloaterAnimPreview::onSliderMove(LLUICtrl* ctrl, void*user_data)
620 if (!previewp->getEnabled()) 716 if (!previewp->getEnabled())
621 return; 717 return;
622 718
623 if (previewp->mAnimPreview) 719 LLVOAvatar* avatarp;
624 { 720 if (previewp->mInWorld)
625 LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar(); 721 {
626 F32 slider_value = (F32)previewp->childGetValue("playback_slider").asReal(); 722 if (!gAgent.getAvatarObject())
627 LLUUID base_id = previewp->mIDList[previewp->childGetValue("preview_base_anim").asString()]; 723 {
628 LLMotion* motionp = avatarp->findMotion(previewp->mMotionID); 724 return;
629 F32 duration = motionp->getDuration();// + motionp->getEaseOutDuration(); 725 }
630 F32 delta_time = duration * slider_value; 726 avatarp = gAgent.getAvatarObject();
631 avatarp->deactivateAllMotions();
632 avatarp->startMotion(base_id, delta_time + BASE_ANIM_TIME_OFFSET);
633 avatarp->startMotion(previewp->mMotionID, delta_time);
634 previewp->mPauseRequest = avatarp->requestPause();
635 previewp->refresh();
636 } 727 }
637 728 else
729 {
730 if (!previewp->mAnimPreview)
731 {
732 return;
733 }
734 avatarp = previewp->mAnimPreview->getDummyAvatar();
735 }
736 F32 slider_value = (F32)previewp->childGetValue("playback_slider").asReal();
737 LLUUID base_id = previewp->mIDList[previewp->childGetValue("preview_base_anim").asString()];
738 LLMotion* motionp = avatarp->findMotion(previewp->mMotionID);
739 F32 duration = motionp->getDuration();// + motionp->getEaseOutDuration();
740 F32 delta_time = duration * slider_value;
741 avatarp->deactivateAllMotions();
742 avatarp->startMotion(base_id, delta_time + BASE_ANIM_TIME_OFFSET);
743 avatarp->startMotion(previewp->mMotionID, delta_time);
744 previewp->mPauseRequest = avatarp->requestPause();
745 previewp->refresh();
638} 746}
639 747
640//----------------------------------------------------------------------------- 748//-----------------------------------------------------------------------------
@@ -646,24 +754,37 @@ void LLFloaterAnimPreview::onCommitBaseAnim(LLUICtrl* ctrl, void* data)
646 if (!previewp->getEnabled()) 754 if (!previewp->getEnabled())
647 return; 755 return;
648 756
649 if (previewp->mAnimPreview) 757 LLVOAvatar* avatarp;
758 if (previewp->mInWorld)
650 { 759 {
651 LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar(); 760 if (!gAgent.getAvatarObject())
761 {
762 return;
763 }
764 avatarp = gAgent.getAvatarObject();
765 }
766 else
767 {
768 if (!previewp->mAnimPreview)
769 {
770 return;
771 }
772 avatarp = previewp->mAnimPreview->getDummyAvatar();
773 }
652 774
653 BOOL paused = avatarp->areAnimationsPaused(); 775 BOOL paused = avatarp->areAnimationsPaused();
654 776
655 // stop all other possible base motions 777 // stop all other possible base motions
656 avatarp->stopMotion(ANIM_AGENT_STAND, TRUE); 778 avatarp->stopMotion(ANIM_AGENT_STAND, TRUE);
657 avatarp->stopMotion(ANIM_AGENT_WALK, TRUE); 779 avatarp->stopMotion(ANIM_AGENT_WALK, TRUE);
658 avatarp->stopMotion(ANIM_AGENT_SIT, TRUE); 780 avatarp->stopMotion(ANIM_AGENT_SIT, TRUE);
659 avatarp->stopMotion(ANIM_AGENT_HOVER, TRUE); 781 avatarp->stopMotion(ANIM_AGENT_HOVER, TRUE);
660 782
661 previewp->resetMotion(); 783 previewp->resetMotion();
662 784
663 if (!paused) 785 if (!paused)
664 { 786 {
665 previewp->mPauseRequest = NULL; 787 previewp->mPauseRequest = NULL;
666 }
667 } 788 }
668} 789}
669 790
@@ -676,7 +797,23 @@ void LLFloaterAnimPreview::onCommitLoop(LLUICtrl* ctrl, void* data)
676 if (!previewp->getEnabled()) 797 if (!previewp->getEnabled())
677 return; 798 return;
678 799
679 LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar(); 800 LLVOAvatar* avatarp;
801 if (previewp->mInWorld)
802 {
803 if (!gAgent.getAvatarObject())
804 {
805 return;
806 }
807 avatarp = gAgent.getAvatarObject();
808 }
809 else
810 {
811 if (!previewp->mAnimPreview)
812 {
813 return;
814 }
815 avatarp = previewp->mAnimPreview->getDummyAvatar();
816 }
680 LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID); 817 LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID);
681 818
682 if (motionp) 819 if (motionp)
@@ -696,7 +833,23 @@ void LLFloaterAnimPreview::onCommitLoopIn(LLUICtrl* ctrl, void* data)
696 if (!previewp->getEnabled()) 833 if (!previewp->getEnabled())
697 return; 834 return;
698 835
699 LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar(); 836 LLVOAvatar* avatarp;
837 if (previewp->mInWorld)
838 {
839 if (!gAgent.getAvatarObject())
840 {
841 return;
842 }
843 avatarp = gAgent.getAvatarObject();
844 }
845 else
846 {
847 if (!previewp->mAnimPreview)
848 {
849 return;
850 }
851 avatarp = previewp->mAnimPreview->getDummyAvatar();
852 }
700 LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID); 853 LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID);
701 854
702 if (motionp) 855 if (motionp)
@@ -717,7 +870,23 @@ void LLFloaterAnimPreview::onCommitLoopOut(LLUICtrl* ctrl, void* data)
717 if (!previewp->getEnabled()) 870 if (!previewp->getEnabled())
718 return; 871 return;
719 872
720 LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar(); 873 LLVOAvatar* avatarp;
874 if (previewp->mInWorld)
875 {
876 if (!gAgent.getAvatarObject())
877 {
878 return;
879 }
880 avatarp = gAgent.getAvatarObject();
881 }
882 else
883 {
884 if (!previewp->mAnimPreview)
885 {
886 return;
887 }
888 avatarp = previewp->mAnimPreview->getDummyAvatar();
889 }
721 LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID); 890 LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID);
722 891
723 if (motionp) 892 if (motionp)
@@ -738,7 +907,23 @@ void LLFloaterAnimPreview::onCommitName(LLUICtrl* ctrl, void* data)
738 if (!previewp->getEnabled()) 907 if (!previewp->getEnabled())
739 return; 908 return;
740 909
741 LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar(); 910 LLVOAvatar* avatarp;
911 if (previewp->mInWorld)
912 {
913 if (!gAgent.getAvatarObject())
914 {
915 return;
916 }
917 avatarp = gAgent.getAvatarObject();
918 }
919 else
920 {
921 if (!previewp->mAnimPreview)
922 {
923 return;
924 }
925 avatarp = previewp->mAnimPreview->getDummyAvatar();
926 }
742 LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID); 927 LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID);
743 928
744 if (motionp) 929 if (motionp)
@@ -782,7 +967,23 @@ void LLFloaterAnimPreview::onCommitPriority(LLUICtrl* ctrl, void* data)
782 if (!previewp->getEnabled()) 967 if (!previewp->getEnabled())
783 return; 968 return;
784 969
785 LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar(); 970 LLVOAvatar* avatarp;
971 if (previewp->mInWorld)
972 {
973 if (!gAgent.getAvatarObject())
974 {
975 return;
976 }
977 avatarp = gAgent.getAvatarObject();
978 }
979 else
980 {
981 if (!previewp->mAnimPreview)
982 {
983 return;
984 }
985 avatarp = previewp->mAnimPreview->getDummyAvatar();
986 }
786 LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID); 987 LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID);
787 988
788 motionp->setPriority(llfloor((F32)previewp->childGetValue("priority").asReal())); 989 motionp->setPriority(llfloor((F32)previewp->childGetValue("priority").asReal()));
@@ -797,7 +998,23 @@ void LLFloaterAnimPreview::onCommitEaseIn(LLUICtrl* ctrl, void* data)
797 if (!previewp->getEnabled()) 998 if (!previewp->getEnabled())
798 return; 999 return;
799 1000
800 LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar(); 1001 LLVOAvatar* avatarp;
1002 if (previewp->mInWorld)
1003 {
1004 if (!gAgent.getAvatarObject())
1005 {
1006 return;
1007 }
1008 avatarp = gAgent.getAvatarObject();
1009 }
1010 else
1011 {
1012 if (!previewp->mAnimPreview)
1013 {
1014 return;
1015 }
1016 avatarp = previewp->mAnimPreview->getDummyAvatar();
1017 }
801 LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID); 1018 LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID);
802 1019
803 motionp->setEaseIn((F32)previewp->childGetValue("ease_in_time").asReal()); 1020 motionp->setEaseIn((F32)previewp->childGetValue("ease_in_time").asReal());
@@ -813,7 +1030,23 @@ void LLFloaterAnimPreview::onCommitEaseOut(LLUICtrl* ctrl, void* data)
813 if (!previewp->getEnabled()) 1030 if (!previewp->getEnabled())
814 return; 1031 return;
815 1032
816 LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar(); 1033 LLVOAvatar* avatarp;
1034 if (previewp->mInWorld)
1035 {
1036 if (!gAgent.getAvatarObject())
1037 {
1038 return;
1039 }
1040 avatarp = gAgent.getAvatarObject();
1041 }
1042 else
1043 {
1044 if (!previewp->mAnimPreview)
1045 {
1046 return;
1047 }
1048 avatarp = previewp->mAnimPreview->getDummyAvatar();
1049 }
817 LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID); 1050 LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID);
818 1051
819 motionp->setEaseOut((F32)previewp->childGetValue("ease_out_time").asReal()); 1052 motionp->setEaseOut((F32)previewp->childGetValue("ease_out_time").asReal());
@@ -829,7 +1062,23 @@ BOOL LLFloaterAnimPreview::validateEaseIn(LLUICtrl* spin, void* data)
829 if (!previewp->getEnabled()) 1062 if (!previewp->getEnabled())
830 return FALSE; 1063 return FALSE;
831 1064
832 LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar(); 1065 LLVOAvatar* avatarp;
1066 if (previewp->mInWorld)
1067 {
1068 if (!gAgent.getAvatarObject())
1069 {
1070 return FALSE;
1071 }
1072 avatarp = gAgent.getAvatarObject();
1073 }
1074 else
1075 {
1076 if (!previewp->mAnimPreview)
1077 {
1078 return FALSE;
1079 }
1080 avatarp = previewp->mAnimPreview->getDummyAvatar();
1081 }
833 LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID); 1082 LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID);
834 1083
835 if (!motionp->getLoop()) 1084 if (!motionp->getLoop())
@@ -851,7 +1100,23 @@ BOOL LLFloaterAnimPreview::validateEaseOut(LLUICtrl* spin, void* data)
851 if (!previewp->getEnabled()) 1100 if (!previewp->getEnabled())
852 return FALSE; 1101 return FALSE;
853 1102
854 LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar(); 1103 LLVOAvatar* avatarp;
1104 if (previewp->mInWorld)
1105 {
1106 if (!gAgent.getAvatarObject())
1107 {
1108 return FALSE;
1109 }
1110 avatarp = gAgent.getAvatarObject();
1111 }
1112 else
1113 {
1114 if (!previewp->mAnimPreview)
1115 {
1116 return FALSE;
1117 }
1118 avatarp = previewp->mAnimPreview->getDummyAvatar();
1119 }
855 LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID); 1120 LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID);
856 1121
857 if (!motionp->getLoop()) 1122 if (!motionp->getLoop())
@@ -936,9 +1201,20 @@ void LLFloaterAnimPreview::refresh()
936 } 1201 }
937 else 1202 else
938 { 1203 {
939 childHide("bad_animation_text"); 1204 if (!mInWorld)
1205 {
1206 childHide("bad_animation_text");
1207 }
940 mPlayButton->setEnabled(TRUE); 1208 mPlayButton->setEnabled(TRUE);
941 LLVOAvatar* avatarp = mAnimPreview->getDummyAvatar(); 1209 LLVOAvatar* avatarp;
1210 if (mInWorld)
1211 {
1212 avatarp = gAgent.getAvatarObject();
1213 }
1214 else
1215 {
1216 avatarp = mAnimPreview->getDummyAvatar();
1217 }
942 if (avatarp->isMotionActive(mMotionID)) 1218 if (avatarp->isMotionActive(mMotionID))
943 { 1219 {
944 mStopButton->setEnabled(TRUE); 1220 mStopButton->setEnabled(TRUE);
@@ -971,7 +1247,10 @@ void LLFloaterAnimPreview::refresh()
971 mStopButton->setEnabled(TRUE); // stop also resets, leave enabled. 1247 mStopButton->setEnabled(TRUE); // stop also resets, leave enabled.
972 } 1248 }
973 childEnable("ok_btn"); 1249 childEnable("ok_btn");
974 mAnimPreview->requestUpdate(); 1250 if (!mInWorld)
1251 {
1252 mAnimPreview->requestUpdate();
1253 }
975 } 1254 }
976} 1255}
977 1256
@@ -983,9 +1262,17 @@ void LLFloaterAnimPreview::onBtnOK(void* userdata)
983 LLFloaterAnimPreview* floaterp = (LLFloaterAnimPreview*)userdata; 1262 LLFloaterAnimPreview* floaterp = (LLFloaterAnimPreview*)userdata;
984 if (!floaterp->getEnabled()) return; 1263 if (!floaterp->getEnabled()) return;
985 1264
986 if (floaterp->mAnimPreview) 1265 if ((!floaterp->mInWorld && floaterp->mAnimPreview) || (floaterp->mInWorld && gAgent.getAvatarObject()))
987 { 1266 {
988 LLKeyframeMotion* motionp = (LLKeyframeMotion*)floaterp->mAnimPreview->getDummyAvatar()->findMotion(floaterp->mMotionID); 1267 LLKeyframeMotion* motionp;
1268 if (floaterp->mInWorld)
1269 {
1270 motionp = (LLKeyframeMotion*)gAgent.getAvatarObject()->findMotion(floaterp->mMotionID);
1271 }
1272 else
1273 {
1274 motionp = (LLKeyframeMotion*)floaterp->mAnimPreview->getDummyAvatar()->findMotion(floaterp->mMotionID);
1275 }
989 1276
990 S32 file_size = motionp->getFileSize(); 1277 S32 file_size = motionp->getFileSize();
991 U8* buffer = new U8[file_size]; 1278 U8* buffer = new U8[file_size];
@@ -1024,7 +1311,15 @@ void LLFloaterAnimPreview::onBtnOK(void* userdata)
1024 1311
1025 delete [] buffer; 1312 delete [] buffer;
1026 // clear out cache for motion data 1313 // clear out cache for motion data
1027 floaterp->mAnimPreview->getDummyAvatar()->removeMotion(floaterp->mMotionID); 1314 if (floaterp->mInWorld)
1315 {
1316 gAgent.getAvatarObject()->removeMotion(floaterp->mMotionID);
1317 gAgent.getAvatarObject()->deactivateAllMotions();
1318 }
1319 else
1320 {
1321 floaterp->mAnimPreview->getDummyAvatar()->removeMotion(floaterp->mMotionID);
1322 }
1028 LLKeyframeDataCache::removeKeyframeData(floaterp->mMotionID); 1323 LLKeyframeDataCache::removeKeyframeData(floaterp->mMotionID);
1029 } 1324 }
1030 1325
diff --git a/linden/indra/newview/llfloateranimpreview.h b/linden/indra/newview/llfloateranimpreview.h
index eaab186..e8f79e2 100644
--- a/linden/indra/newview/llfloateranimpreview.h
+++ b/linden/indra/newview/llfloateranimpreview.h
@@ -32,7 +32,7 @@
32 32
33#ifndef LL_LLFLOATERANIMPREVIEW_H 33#ifndef LL_LLFLOATERANIMPREVIEW_H
34#define LL_LLFLOATERANIMPREVIEW_H 34#define LL_LLFLOATERANIMPREVIEW_H
35#include "llagent.h" 35
36#include "llfloaternamedesc.h" 36#include "llfloaternamedesc.h"
37#include "lldynamictexture.h" 37#include "lldynamictexture.h"
38#include "llcharacter.h" 38#include "llcharacter.h"
@@ -55,10 +55,7 @@ public:
55 void pan(F32 right, F32 up); 55 void pan(F32 right, F32 up);
56 virtual BOOL needsUpdate() { return mNeedsUpdate; } 56 virtual BOOL needsUpdate() { return mNeedsUpdate; }
57 57
58// LLVOAvatar* getDummyAvatar() { return mDummyAvatar; } 58 LLVOAvatar* getDummyAvatar() { return mDummyAvatar; }
59// HACK:don't get a dummy...
60 LLVOAvatar* getDummyAvatar() { return gAgent.getAvatarObject();}
61
62 59
63protected: 60protected:
64 BOOL mNeedsUpdate; 61 BOOL mNeedsUpdate;
@@ -78,13 +75,13 @@ public:
78 virtual ~LLFloaterAnimPreview(); 75 virtual ~LLFloaterAnimPreview();
79 76
80 BOOL postBuild(); 77 BOOL postBuild();
81/* 78
82 BOOL handleMouseDown(S32 x, S32 y, MASK mask); 79 BOOL handleMouseDown(S32 x, S32 y, MASK mask);
83 BOOL handleMouseUp(S32 x, S32 y, MASK mask); 80 BOOL handleMouseUp(S32 x, S32 y, MASK mask);
84 BOOL handleHover(S32 x, S32 y, MASK mask); 81 BOOL handleHover(S32 x, S32 y, MASK mask);
85 BOOL handleScrollWheel(S32 x, S32 y, S32 clicks); 82 BOOL handleScrollWheel(S32 x, S32 y, S32 clicks);
86 void onMouseCaptureLost(); 83 void onMouseCaptureLost();
87*/ 84
88 void refresh(); 85 void refresh();
89 86
90 static void onBtnPlay(void*); 87 static void onBtnPlay(void*);
@@ -127,6 +124,7 @@ protected:
127 LLAssetID mMotionID; 124 LLAssetID mMotionID;
128 LLTransactionID mTransactionID; 125 LLTransactionID mTransactionID;
129 BOOL mEnabled; 126 BOOL mEnabled;
127 BOOL mInWorld;
130 LLAnimPauseRequest mPauseRequest; 128 LLAnimPauseRequest mPauseRequest;
131 129
132 std::map<std::string, LLUUID> mIDList; 130 std::map<std::string, LLUUID> mIDList;
diff --git a/linden/indra/newview/skins/default/xui/en-us/floater_animation_preview.xml b/linden/indra/newview/skins/default/xui/en-us/floater_animation_preview.xml
index e710d41..f2c5d34 100644
--- a/linden/indra/newview/skins/default/xui/en-us/floater_animation_preview.xml
+++ b/linden/indra/newview/skins/default/xui/en-us/floater_animation_preview.xml
@@ -1,7 +1,7 @@
1<?xml version="1.0" encoding="utf-8" standalone="yes" ?> 1<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
2<floater can_close="true" can_drag_on_left="false" can_minimize="false" 2<floater can_close="true" can_drag_on_left="false" can_minimize="false"
3 can_resize="false" height="286" min_height="286" min_width="300" 3 can_resize="false" height="556" min_height="256" min_width="300"
4 name="Animation Preview" rect_control="PreviewAnimRect" title="" width="300"> 4 name="Animation Preview" title="" width="300">
5 <pad height="12" /> 5 <pad height="12" />
6 <text follows="top|left" height="15" left="10" name="name_label"> 6 <text follows="top|left" height="15" left="10" name="name_label">
7 Name: 7 Name:
@@ -180,7 +180,7 @@
180 <slider bottom_delta="0" follows="top|right" height="20" increment="0.0001" 180 <slider bottom_delta="0" follows="top|right" height="20" increment="0.0001"
181 initial_val="0" label="" label_width="0" left="80" max_val="1" min_val="0" 181 initial_val="0" label="" label_width="0" left="80" max_val="1" min_val="0"
182 name="playback_slider" right="290" show_text="false" /> 182 name="playback_slider" right="290" show_text="false" />
183 <text bottom="250" follows="top|left" left="10" name="bad_animation_text"> 183 <text bottom="280" follows="top|left" left="20" name="bad_animation_text">
184 Unable to read animation file. 184 Unable to read animation file.
185 185
186We recommend BVH files exported from Poser 4. 186We recommend BVH files exported from Poser 4.
@@ -202,4 +202,7 @@ Maximum animation length is [MAX_LENGTH] seconds.
202 202
203[STATUS] 203[STATUS]
204 </string> 204 </string>
205 <string name="in_world">
206 The animation preview is played on your avatar.
207 </string>
205</floater> 208</floater>