summaryrefslogtreecommitdiff
path: root/indra/newview/llfloateranimpreview.cpp
diff options
context:
space:
mode:
authorSteven Bennetts <steve@lindenlab.com>2008-06-27 21:02:01 +0000
committerSteven Bennetts <steve@lindenlab.com>2008-06-27 21:02:01 +0000
commit926ea0b39afd04cab469ca17b28f95ebf969e669 (patch)
tree40d5653e19160f72e7a0b80fadb9bdb93ef3575c /indra/newview/llfloateranimpreview.cpp
parent41877d457ab9542dca22b99f3eddb1bfcfe7c1d6 (diff)
QAR-669 1.20 Viewer RC11
QAR-648 1.20 Viewer RC10 merge Branch_1-20-Viewer-2 -r 88724:90511 -> release
Diffstat (limited to 'indra/newview/llfloateranimpreview.cpp')
-rw-r--r--indra/newview/llfloateranimpreview.cpp191
1 files changed, 81 insertions, 110 deletions
diff --git a/indra/newview/llfloateranimpreview.cpp b/indra/newview/llfloateranimpreview.cpp
index 6d4ff5a1a7..417ac0e868 100644
--- a/indra/newview/llfloateranimpreview.cpp
+++ b/indra/newview/llfloateranimpreview.cpp
@@ -76,13 +76,14 @@ const F32 PREVIEW_CAMERA_DISTANCE = 4.f;
const F32 MIN_CAMERA_ZOOM = 0.5f;
const F32 MAX_CAMERA_ZOOM = 10.f;
+const F32 BASE_ANIM_TIME_OFFSET = 5.f;
+
//-----------------------------------------------------------------------------
// LLFloaterAnimPreview()
//-----------------------------------------------------------------------------
LLFloaterAnimPreview::LLFloaterAnimPreview(const std::string& filename) :
LLFloaterNameDesc(filename)
{
- mLastSliderValue = 0.f;
mLastMouseX = 0;
mLastMouseY = 0;
@@ -414,20 +415,32 @@ void LLFloaterAnimPreview::resetMotion()
LLVOAvatar* avatarp = mAnimPreview->getDummyAvatar();
BOOL paused = avatarp->areAnimationsPaused();
- mPauseRequest = NULL;
+ // *TODO: Fix awful casting hack
+ LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(mMotionID);
+
+ // Set emotion
+ std::string emote = childGetValue("emote_combo").asString();
+ motionp->setEmote(mIDList[emote]);
- LLUUID anim_id = mIDList[childGetValue("preview_base_anim").asString()];
- avatarp->stopMotion(anim_id, TRUE);
- avatarp->stopMotion(mMotionID, TRUE);
- avatarp->startMotion(anim_id, 5.f);
- avatarp->startMotion(mMotionID);
- childSetValue("playback_slider", 0.0);
- mLastSliderValue = 0.0f;
+ LLUUID base_id = mIDList[childGetValue("preview_base_anim").asString()];
+ avatarp->deactivateAllMotions();
+ avatarp->startMotion(base_id, BASE_ANIM_TIME_OFFSET);
+ avatarp->startMotion(mMotionID, 0.0f);
+ childSetValue("playback_slider", 0.0f);
+
+ // Set pose
+ std::string handpose = childGetValue("hand_pose_combo").asString();
+ avatarp->startMotion( ANIM_AGENT_HAND_MOTION, 0.0f );
+ motionp->setHandPose(LLHandMotion::getHandPose(handpose));
if (paused)
{
mPauseRequest = avatarp->requestPause();
}
+ else
+ {
+ mPauseRequest = NULL;
+ }
}
//-----------------------------------------------------------------------------
@@ -538,7 +551,8 @@ void LLFloaterAnimPreview::onMouseCaptureLost()
void LLFloaterAnimPreview::onBtnPlay(void* user_data)
{
LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)user_data;
- if (!previewp->getEnabled()) return;
+ if (!previewp->getEnabled())
+ return;
if (previewp->mMotionID.notNull() && previewp->mAnimPreview)
{
@@ -569,22 +583,14 @@ void LLFloaterAnimPreview::onBtnPlay(void* user_data)
void LLFloaterAnimPreview::onBtnStop(void* user_data)
{
LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)user_data;
- if (!previewp->getEnabled()) return;
+ if (!previewp->getEnabled())
+ return;
if (previewp->mMotionID.notNull() && previewp->mAnimPreview)
{
LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar();
-
- // is the motion looping and have we passed the loop in point?
- if (previewp->childGetValue("loop_check").asBoolean() &&
- (F32)previewp->childGetValue("loop_in_point").asReal() <= (F32)previewp->childGetValue("playback_slider").asReal() * 100.f)
- {
- avatarp->stopMotion(previewp->mMotionID, FALSE);
- }
- else
- {
- avatarp->stopMotion(previewp->mMotionID, FALSE);
- }
+ previewp->resetMotion();
+ previewp->mPauseRequest = avatarp->requestPause();
}
}
@@ -594,43 +600,24 @@ void LLFloaterAnimPreview::onBtnStop(void* user_data)
void LLFloaterAnimPreview::onSliderMove(LLUICtrl* ctrl, void*user_data)
{
LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)user_data;
- if (!previewp->getEnabled()) return;
+ if (!previewp->getEnabled())
+ return;
if (previewp->mAnimPreview)
{
LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar();
+ F32 slider_value = (F32)previewp->childGetValue("playback_slider").asReal();
+ LLUUID base_id = previewp->mIDList[previewp->childGetValue("preview_base_anim").asString()];
LLMotion* motionp = avatarp->findMotion(previewp->mMotionID);
- LLMotion* base_motionp =
- avatarp->findMotion(previewp->mIDList[previewp->childGetValue("preview_base_anim").asString()]);
-
- if (motionp && base_motionp)
- {
- if (!avatarp->isMotionActive(previewp->mMotionID))
- {
- previewp->resetMotion();
- }
-
- previewp->mPauseRequest = avatarp->requestPause();
- F32 original_activation_time = motionp->mActivationTimestamp;
- motionp->mActivationTimestamp -= ((F32)previewp->childGetValue("playback_slider").asReal() - previewp->mLastSliderValue) *
- motionp->getDuration();
- base_motionp->mActivationTimestamp -= ((F32)previewp->childGetValue("playback_slider").asReal() - previewp->mLastSliderValue) *
- base_motionp->getDuration();
-
- if (motionp->mSendStopTimestamp != F32_MIN)
- {
- motionp->mSendStopTimestamp = motionp->mSendStopTimestamp - original_activation_time + motionp->mActivationTimestamp;
- }
-
- if (motionp->mStopTimestamp != F32_MIN)
- {
- motionp->mStopTimestamp = motionp->mStopTimestamp - original_activation_time + motionp->mActivationTimestamp;
- }
- previewp->refresh();
- }
+ F32 duration = motionp->getDuration();// + motionp->getEaseOutDuration();
+ F32 delta_time = duration * slider_value;
+ avatarp->deactivateAllMotions();
+ avatarp->startMotion(base_id, delta_time + BASE_ANIM_TIME_OFFSET);
+ avatarp->startMotion(previewp->mMotionID, delta_time);
+ previewp->mPauseRequest = avatarp->requestPause();
+ previewp->refresh();
}
- previewp->mLastSliderValue = (F32)previewp->childGetValue("playback_slider").asReal();
}
//-----------------------------------------------------------------------------
@@ -639,8 +626,8 @@ void LLFloaterAnimPreview::onSliderMove(LLUICtrl* ctrl, void*user_data)
void LLFloaterAnimPreview::onCommitBaseAnim(LLUICtrl* ctrl, void* data)
{
LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data;
-
- if (!previewp->getEnabled()) return;
+ if (!previewp->getEnabled())
+ return;
if (previewp->mAnimPreview)
{
@@ -669,8 +656,9 @@ void LLFloaterAnimPreview::onCommitBaseAnim(LLUICtrl* ctrl, void* data)
void LLFloaterAnimPreview::onCommitLoop(LLUICtrl* ctrl, void* data)
{
LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data;
-
- if (!previewp->getEnabled()) return;
+ if (!previewp->getEnabled())
+ return;
+
LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar();
LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID);
@@ -688,7 +676,8 @@ void LLFloaterAnimPreview::onCommitLoop(LLUICtrl* ctrl, void* data)
void LLFloaterAnimPreview::onCommitLoopIn(LLUICtrl* ctrl, void* data)
{
LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data;
- if (!previewp->getEnabled()) return;
+ if (!previewp->getEnabled())
+ return;
LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar();
LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID);
@@ -708,7 +697,8 @@ void LLFloaterAnimPreview::onCommitLoopIn(LLUICtrl* ctrl, void* data)
void LLFloaterAnimPreview::onCommitLoopOut(LLUICtrl* ctrl, void* data)
{
LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data;
- if (!previewp->getEnabled()) return;
+ if (!previewp->getEnabled())
+ return;
LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar();
LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID);
@@ -728,7 +718,8 @@ void LLFloaterAnimPreview::onCommitLoopOut(LLUICtrl* ctrl, void* data)
void LLFloaterAnimPreview::onCommitName(LLUICtrl* ctrl, void* data)
{
LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data;
- if (!previewp->getEnabled()) return;
+ if (!previewp->getEnabled())
+ return;
LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar();
LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID);
@@ -747,13 +738,10 @@ void LLFloaterAnimPreview::onCommitName(LLUICtrl* ctrl, void* data)
void LLFloaterAnimPreview::onCommitHandPose(LLUICtrl* ctrl, void* data)
{
LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data;
- if (!previewp->getEnabled()) return;
-
- LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar();
- LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID);
+ if (!previewp->getEnabled())
+ return;
- motionp->setHandPose(LLHandMotion::getHandPose(previewp->childGetValue("hand_pose_combo").asString()));
- previewp->resetMotion();
+ previewp->resetMotion(); // sets hand pose
}
//-----------------------------------------------------------------------------
@@ -762,13 +750,10 @@ void LLFloaterAnimPreview::onCommitHandPose(LLUICtrl* ctrl, void* data)
void LLFloaterAnimPreview::onCommitEmote(LLUICtrl* ctrl, void* data)
{
LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data;
- if (!previewp->getEnabled()) return;
+ if (!previewp->getEnabled())
+ return;
- LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar();
- LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID);
-
- motionp->setEmote(previewp->mIDList[previewp->childGetValue("emote_combo").asString()]);
- previewp->resetMotion();
+ previewp->resetMotion(); // ssts emote
}
//-----------------------------------------------------------------------------
@@ -777,7 +762,8 @@ void LLFloaterAnimPreview::onCommitEmote(LLUICtrl* ctrl, void* data)
void LLFloaterAnimPreview::onCommitPriority(LLUICtrl* ctrl, void* data)
{
LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data;
- if (!previewp->getEnabled()) return;
+ if (!previewp->getEnabled())
+ return;
LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar();
LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID);
@@ -791,7 +777,8 @@ void LLFloaterAnimPreview::onCommitPriority(LLUICtrl* ctrl, void* data)
void LLFloaterAnimPreview::onCommitEaseIn(LLUICtrl* ctrl, void* data)
{
LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data;
- if (!previewp->getEnabled()) return;
+ if (!previewp->getEnabled())
+ return;
LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar();
LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID);
@@ -806,7 +793,8 @@ void LLFloaterAnimPreview::onCommitEaseIn(LLUICtrl* ctrl, void* data)
void LLFloaterAnimPreview::onCommitEaseOut(LLUICtrl* ctrl, void* data)
{
LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data;
- if (!previewp->getEnabled()) return;
+ if (!previewp->getEnabled())
+ return;
LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar();
LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID);
@@ -820,9 +808,9 @@ void LLFloaterAnimPreview::onCommitEaseOut(LLUICtrl* ctrl, void* data)
//-----------------------------------------------------------------------------
BOOL LLFloaterAnimPreview::validateEaseIn(LLUICtrl* spin, void* data)
{
- LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data;
-
- if (!previewp->getEnabled()) return FALSE;
+ LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data;
+ if (!previewp->getEnabled())
+ return FALSE;
LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar();
LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID);
@@ -843,7 +831,8 @@ BOOL LLFloaterAnimPreview::validateEaseOut(LLUICtrl* spin, void* data)
{
LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data;
- if (!previewp->getEnabled()) return FALSE;
+ if (!previewp->getEnabled())
+ return FALSE;
LLVOAvatar* avatarp = previewp->mAnimPreview->getDummyAvatar();
LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(previewp->mMotionID);
@@ -863,8 +852,8 @@ BOOL LLFloaterAnimPreview::validateEaseOut(LLUICtrl* spin, void* data)
BOOL LLFloaterAnimPreview::validateLoopIn(LLUICtrl* ctrl, void* data)
{
LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data;
-
- if (!previewp->getEnabled()) return FALSE;
+ if (!previewp->getEnabled())
+ return FALSE;
F32 loop_in_value = (F32)previewp->childGetValue("loop_in_point").asReal();
F32 loop_out_value = (F32)previewp->childGetValue("loop_out_point").asReal();
@@ -892,8 +881,8 @@ BOOL LLFloaterAnimPreview::validateLoopIn(LLUICtrl* ctrl, void* data)
BOOL LLFloaterAnimPreview::validateLoopOut(LLUICtrl* spin, void* data)
{
LLFloaterAnimPreview* previewp = (LLFloaterAnimPreview*)data;
-
- if (!previewp->getEnabled()) return FALSE;
+ if (!previewp->getEnabled())
+ return FALSE;
F32 loop_out_value = (F32)previewp->childGetValue("loop_out_point").asReal();
F32 loop_in_value = (F32)previewp->childGetValue("loop_in_point").asReal();
@@ -948,11 +937,8 @@ void LLFloaterAnimPreview::refresh()
{
if (motionp)
{
- F32 fraction_complete;
- fraction_complete = motionp->getLastUpdateTime() / motionp->getDuration();
-
+ F32 fraction_complete = motionp->getLastUpdateTime() / motionp->getDuration();
childSetValue("playback_slider", fraction_complete);
- mLastSliderValue = fraction_complete;
}
mPlayButton->setImages(std::string("button_anim_pause.tga"),
std::string("button_anim_pause_selected.tga"));
@@ -965,7 +951,7 @@ void LLFloaterAnimPreview::refresh()
mPlayButton->setImages(std::string("button_anim_play.tga"),
std::string("button_anim_play_selected.tga"));
- mStopButton->setEnabled(FALSE);
+ mStopButton->setEnabled(TRUE); // stop also resets, leave enabled.
}
childEnable("ok_btn");
mAnimPreview->requestUpdate();
@@ -1038,12 +1024,12 @@ LLPreviewAnimation::LLPreviewAnimation(S32 width, S32 height) : LLDynamicTexture
mDummyAvatar = (LLVOAvatar*)gObjectList.createObjectViewer(LL_PCODE_LEGACY_AVATAR, gAgent.getRegion());
mDummyAvatar->createDrawable(&gPipeline);
mDummyAvatar->mIsDummy = TRUE;
- mDummyAvatar->mSpecialRenderMode = 2;
+ mDummyAvatar->mSpecialRenderMode = 1;
mDummyAvatar->setPositionAgent(LLVector3::zero);
mDummyAvatar->slamPosition();
mDummyAvatar->updateJointLODs();
mDummyAvatar->updateGeometry(mDummyAvatar->mDrawable);
- mDummyAvatar->startMotion(ANIM_AGENT_STAND, 5.f);
+ mDummyAvatar->startMotion(ANIM_AGENT_STAND, BASE_ANIM_TIME_OFFSET);
mDummyAvatar->mSkirtLOD.setVisible(FALSE, TRUE);
gPipeline.markVisible(mDummyAvatar->mDrawable, *LLViewerCamera::getInstance());
@@ -1111,30 +1097,15 @@ BOOL LLPreviewAnimation::render()
//avatarp->setAnimationData("LookAtPoint", (void *)&mCameraRelPos);
- //RN: timestep must be zero, because paused animations will never initialize
- // av skeleton otherwise
- avatarp->setTimeStep(0.f);
- if (avatarp->areAnimationsPaused())
- {
- avatarp->updateMotion(TRUE);
- }
- else
- {
- avatarp->updateMotion();
- }
+ //SJB: Animation is updated in LLVOAvatar::updateCharacter
- LLVertexBuffer::unbind();
- avatarp->updateLOD();
-
-
- avatarp->mRoot.updateWorldMatrixChildren();
-
- stop_glerror();
-
- LLGLDepthTest gls_depth(GL_TRUE);
-
if (avatarp->mDrawable.notNull())
{
+ avatarp->updateLOD();
+
+ LLVertexBuffer::unbind();
+ LLGLDepthTest gls_depth(GL_TRUE);
+
LLDrawPoolAvatar *avatarPoolp = (LLDrawPoolAvatar *)avatarp->mDrawable->getFace(0)->getPool();
avatarp->dirtyMesh();
avatarPoolp->renderAvatars(avatarp); // renders only one avatar