FIRE-17277: Allow entering animation loop parameters as frames rather than percent; patch by Sei Lisa

master
Ansariel 2015-11-13 08:59:27 +01:00
parent bf669a1a71
commit c2b51036a6
4 changed files with 199 additions and 4 deletions

View File

@ -296,6 +296,10 @@ public:
ELoadStatus getStatus() { return mStatus; }
// <FS:Sei> FIRE-17277: Allow entering Loop In/Loop Out as frames
S32 getNumFrames() { return mNumFrames; }
// </FS:Sei>
protected:
// Consumes one line of input from file.

View File

@ -176,6 +176,12 @@ void LLFloaterBvhPreview::setAnimCallbacks()
getChild<LLUICtrl>("loop_in_point")->setValidateBeforeCommit( boost::bind(&LLFloaterBvhPreview::validateLoopIn, this, _1));
getChild<LLUICtrl>("loop_out_point")->setCommitCallback(boost::bind(&LLFloaterBvhPreview::onCommitLoopOut, this));
getChild<LLUICtrl>("loop_out_point")->setValidateBeforeCommit( boost::bind(&LLFloaterBvhPreview::validateLoopOut, this, _1));
// <FS:Sei> FIRE-17277: Allow entering Loop In/Loop Out as frames
getChild<LLUICtrl>("loop_in_frames")->setCommitCallback(boost::bind(&LLFloaterBvhPreview::onCommitLoopInFrames, this));
getChild<LLUICtrl>("loop_in_frames")->setValidateBeforeCommit( boost::bind(&LLFloaterBvhPreview::validateLoopInFrames, this, _1));
getChild<LLUICtrl>("loop_out_frames")->setCommitCallback(boost::bind(&LLFloaterBvhPreview::onCommitLoopOutFrames, this));
getChild<LLUICtrl>("loop_out_frames")->setValidateBeforeCommit( boost::bind(&LLFloaterBvhPreview::validateLoopOutFrames, this, _1));
// </FS:Sei>
getChild<LLUICtrl>("hand_pose_combo")->setCommitCallback(boost::bind(&LLFloaterBvhPreview::onCommitHandPose, this));
@ -329,6 +335,20 @@ BOOL LLFloaterBvhPreview::loadBVH()
// motion will be returned, but it will be in a load-pending state, as this is a new motion
// this motion will not request an asset transfer until next update, so we have a chance to
// load the keyframe data locally
// <FS:Sei> FIRE-17277: Allow entering Loop In/Loop Out as frames
mNumFrames = loaderp->getNumFrames();
getChild<LLSpinCtrl>("loop_in_frames")->setMaxValue(LLSD((F32)mNumFrames));
getChild<LLSpinCtrl>("loop_out_frames")->setMaxValue(LLSD((F32)mNumFrames));
// (Re)assign loop frames spinners from loop percentages.
getChild<LLUICtrl>("loop_in_frames")->setValue(LLSD((F32)getChild<LLUICtrl>("loop_in_point")->getValue().asReal() / 100.f * (F32)mNumFrames));
getChild<LLUICtrl>("loop_out_frames")->setValue(LLSD((F32)getChild<LLUICtrl>("loop_out_point")->getValue().asReal() / 100.f * (F32)mNumFrames));
LLUIString out_str = getString("FS_report_frames");
out_str.setArg("[F]", llformat("%d", mNumFrames));
out_str.setArg("[S]", llformat("%.1f", loaderp->getDuration()));
out_str.setArg("[FPS]", llformat("%.1f", (F32)mNumFrames / loaderp->getDuration()));
getChild<LLUICtrl>("frames_label")->setValue(LLSD(out_str));
// </FS:Sei>
// <FS> Preview on own avatar
//motionp = (LLKeyframeMotion*)mAnimPreview->getDummyAvatar()->createMotion(mMotionID);
motionp = dynamic_cast<LLKeyframeMotion*>(mAnimPreview->getPreviewAvatar(this)->createMotion(mMotionID));
@ -869,7 +889,10 @@ void LLFloaterBvhPreview::onCommitLoopIn()
if (motionp)
{
motionp->setLoopIn((F32)getChild<LLUICtrl>("loop_in_point")->getValue().asReal() / 100.f);
// <FS:Sei> FIRE-17277: Allow entering Loop In/Loop Out as frames
//motionp->setLoopIn((F32)getChild<LLUICtrl>("loop_in_point")->getValue().asReal() / 100.f);
getChild<LLUICtrl>("loop_in_frames")->setValue(LLSD((F32)getChild<LLUICtrl>("loop_in_point")->getValue().asReal() / 100.f * (F32)mNumFrames));
// </FS:Sei>
resetMotion();
getChild<LLUICtrl>("loop_check")->setValue(LLSD(TRUE));
onCommitLoop();
@ -893,13 +916,61 @@ void LLFloaterBvhPreview::onCommitLoopOut()
if (motionp)
{
motionp->setLoopOut((F32)getChild<LLUICtrl>("loop_out_point")->getValue().asReal() * 0.01f * motionp->getDuration());
// <FS:Sei> FIRE-17277: Allow entering Loop In/Loop Out as frames
//motionp->setLoopOut((F32)getChild<LLUICtrl>("loop_out_point")->getValue().asReal() * 0.01f * motionp->getDuration());
getChild<LLUICtrl>("loop_out_frames")->setValue(LLSD((F32)getChild<LLUICtrl>("loop_out_point")->getValue().asReal() / 100.f * (F32)mNumFrames));
// </FS:Sei>
resetMotion();
getChild<LLUICtrl>("loop_check")->setValue(LLSD(TRUE));
onCommitLoop();
}
}
// <FS:Sei> FIRE-17277: Allow entering Loop In/Loop Out as frames
//-----------------------------------------------------------------------------
// onCommitLoopInFrames()
//-----------------------------------------------------------------------------
void LLFloaterBvhPreview::onCommitLoopInFrames()
{
if (!getEnabled() || !mAnimPreview)
return;
// Preview on own avatar
LLVOAvatar* avatarp = mAnimPreview->getPreviewAvatar(this);
LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(mMotionID);
if (motionp)
{
getChild<LLUICtrl>("loop_in_point")->setValue(LLSD(mNumFrames == 0 ? 0.f : 100.f * (F32)getChild<LLUICtrl>("loop_in_frames")->getValue().asReal() / (F32)mNumFrames));
resetMotion();
getChild<LLUICtrl>("loop_check")->setValue(LLSD(TRUE));
// The values are actually set here:
onCommitLoop();
}
}
//-----------------------------------------------------------------------------
// onCommitLoopOutFrames()
//-----------------------------------------------------------------------------
void LLFloaterBvhPreview::onCommitLoopOutFrames()
{
if (!getEnabled() || !mAnimPreview)
return;
// Preview on own avatar
LLVOAvatar* avatarp = mAnimPreview->getPreviewAvatar(this);
LLKeyframeMotion* motionp = (LLKeyframeMotion*)avatarp->findMotion(mMotionID);
if (motionp)
{
getChild<LLUICtrl>("loop_out_point")->setValue(LLSD(mNumFrames == 0 ? 100.f : 100.f * (F32)getChild<LLUICtrl>("loop_out_frames")->getValue().asReal() / (F32)mNumFrames));
resetMotion();
getChild<LLUICtrl>("loop_check")->setValue(LLSD(TRUE));
onCommitLoop();
}
}
// </FS:Sei>
//-----------------------------------------------------------------------------
// onCommitName()
//-----------------------------------------------------------------------------
@ -1083,6 +1154,9 @@ bool LLFloaterBvhPreview::validateLoopIn(const LLSD& data)
}
getChild<LLUICtrl>("loop_in_point")->setValue(LLSD(loop_in_value));
// <FS:Sei> FIRE-17277: Allow entering Loop In/Loop Out as frames
getChild<LLUICtrl>("loop_in_frames")->setValue(LLSD(loop_in_value / 100.f * (F32)mNumFrames));
// </FS:Sei>
return true;
}
@ -1111,10 +1185,74 @@ bool LLFloaterBvhPreview::validateLoopOut(const LLSD& data)
}
getChild<LLUICtrl>("loop_out_point")->setValue(LLSD(loop_out_value));
// <FS:Sei> FIRE-17277: Allow entering Loop In/Loop Out as frames
getChild<LLUICtrl>("loop_out_frames")->setValue(LLSD(loop_out_value / 100.f * (F32)mNumFrames));
// </FS:Sei>
return true;
}
// <FS:Sei> FIRE-17277: Allow entering Loop In/Loop Out as frames
//-----------------------------------------------------------------------------
// validateLoopInFrames()
//-----------------------------------------------------------------------------
bool LLFloaterBvhPreview::validateLoopInFrames(const LLSD& data)
{
if (!getEnabled())
return false;
F32 loop_in_value = (F32)getChild<LLUICtrl>("loop_in_frames")->getValue().asReal();
F32 loop_out_value = (F32)getChild<LLUICtrl>("loop_out_frames")->getValue().asReal();
if (loop_in_value < 0.f)
{
loop_in_value = 0.f;
}
else if (loop_in_value > 100.f)
{
loop_in_value = 100.f;
}
else if (loop_in_value > loop_out_value)
{
loop_in_value = loop_out_value;
}
getChild<LLUICtrl>("loop_in_frames")->setValue(LLSD(loop_in_value));
getChild<LLUICtrl>("loop_in_point")->setValue(LLSD(mNumFrames == 0 ? 0.f : 100.f * loop_in_value / (F32)mNumFrames));
return true;
}
//-----------------------------------------------------------------------------
// validateLoopOutFrames()
//-----------------------------------------------------------------------------
bool LLFloaterBvhPreview::validateLoopOutFrames(const LLSD& data)
{
if (!getEnabled())
return false;
F32 loop_out_value = (F32)getChild<LLUICtrl>("loop_out_frames")->getValue().asReal();
F32 loop_in_value = (F32)getChild<LLUICtrl>("loop_in_frames")->getValue().asReal();
if (loop_out_value < 0.f)
{
loop_out_value = 0.f;
}
else if (loop_out_value > 100.f)
{
loop_out_value = 100.f;
}
else if (loop_out_value < loop_in_value)
{
loop_out_value = loop_in_value;
}
getChild<LLUICtrl>("loop_out_frames")->setValue(LLSD(loop_out_value));
getChild<LLUICtrl>("loop_out_point")->setValue(LLSD(mNumFrames == 0 ? 100.f : 100.f * loop_out_value / (F32)mNumFrames));
return true;
}
// </FS:Sei>
//-----------------------------------------------------------------------------
// refresh()
//-----------------------------------------------------------------------------

View File

@ -116,6 +116,12 @@ public:
LLAssetType::EType type,
void* user_data,
S32 status, LLExtStat ext_status);
// <FS:Sei> FIRE-17277: Allow entering Loop In/Loop Out as frames
void onCommitLoopInFrames();
void onCommitLoopOutFrames();
bool validateLoopInFrames(const LLSD& data);
bool validateLoopOutFrames(const LLSD& data);
// </FS:Sei>
private:
void setAnimCallbacks() ;
// <FS> Reload animation from disk
@ -146,6 +152,9 @@ protected:
// <FS:Ansariel> FIRE-2083: Slider in upload animation floater doesn't work
LLFrameTimer mTimer;
// <FS:Sei> FIRE-17277: Allow entering Loop In/Loop Out as frames
S32 mNumFrames;
};
#endif // LL_LLFLOATERBVHPREVIEW_H

View File

@ -2,7 +2,7 @@
<floater
legacy_header_height="18"
can_minimize="false"
height="415"
height="450"
left="30"
layout="topleft"
name="Animation Preview"
@ -150,6 +150,10 @@ Maximum animation length is [MAX_LENGTH] seconds.
name="E_ST_BAD_ROOT">
Incorrect root joint name, use "hip".
</floater.string>
<floater.string
name="FS_report_frames">
[F] frm. [S] s. [FPS] fps
</floater.string>
<text
type="string"
length="1"
@ -204,7 +208,7 @@ Maximum animation length is [MAX_LENGTH] seconds.
width="160" />
<check_box
top_pad="0"
height="14"
height="23"
label="Loop"
layout="topleft"
left="10"
@ -212,6 +216,19 @@ Maximum animation length is [MAX_LENGTH] seconds.
initial_value="false"
name="loop_check"
tool_tip="Makes this animation loop" />
<text
type="string"
length="1"
top_pad="5"
follows="top|left"
height="23"
layout="topleft"
left_pad="5"
bottom_delta="8"
width="160"
name="frames_label">
300 frm. 30 s. 10 fps
</text>
<spinner
follows="left|top"
height="23"
@ -240,6 +257,32 @@ Maximum animation length is [MAX_LENGTH] seconds.
tool_tip="Sets point in animation that ends a loop"
label_width="60"
width="120" />
<spinner
follows="left|top"
height="23"
increment="1"
label="In(frm)"
label_width="70"
layout="topleft"
top_pad="5"
left="15"
max_val="1000"
name="loop_in_frames"
tool_tip="Sets point in animation that looping returns to, in frames"
width="130" />
<spinner
bottom_delta="0"
follows="left|top"
height="23"
increment="1"
label="Out(frm)"
layout="topleft"
left_pad="10"
max_val="1000"
name="loop_out_frames"
tool_tip="Sets point in animation that ends a loop, in frames"
label_width="60"
width="120" />
<text
type="string"
length="1"
@ -553,6 +596,7 @@ Maximum animation length is [MAX_LENGTH] seconds.
follows="top|left"
layout="topleft"
left="70"
width="200"
name="bad_animation_text">
Unable to read animation file.
We recommend BVH files exported from Poser 4.