MAINT-1560 : Make Slow Motion Animations affect all avatars. Added new menu.

Reviewed by Kelly
master
simon@Simon-PC.lindenlab.com 2012-10-31 15:05:52 -07:00
parent 58a73b4fc1
commit 2126cdb9a2
4 changed files with 94 additions and 12 deletions

View File

@ -42,6 +42,7 @@ const U32 MAX_MOTION_INSTANCES = 32;
//-----------------------------------------------------------------------------
// Constants and statics
//-----------------------------------------------------------------------------
F32 LLMotionController::sCurrentTimeFactor = 1.f;
LLMotionRegistry LLMotionController::sRegistry;
//-----------------------------------------------------------------------------
@ -125,7 +126,7 @@ LLMotion *LLMotionRegistry::createMotion( const LLUUID &id )
// Class Constructor
//-----------------------------------------------------------------------------
LLMotionController::LLMotionController()
: mTimeFactor(1.f),
: mTimeFactor(sCurrentTimeFactor),
mCharacter(NULL),
mAnimTime(0.f),
mPrevTimerElapsed(0.f),

View File

@ -168,6 +168,9 @@ public:
const LLFrameTimer& getFrameTimer() { return mTimer; }
static F32 getCurrentTimeFactor() { return sCurrentTimeFactor; };
static void setCurrentTimeFactor(F32 factor) { sCurrentTimeFactor = factor; };
protected:
// internal operations act on motion instances directly
// as there can be duplicate motions per id during blending overlap
@ -187,7 +190,8 @@ protected:
void deactivateStoppedMotions();
protected:
F32 mTimeFactor;
F32 mTimeFactor; // 1.f for normal speed
static F32 sCurrentTimeFactor; // Value to use for initialization
static LLMotionRegistry sRegistry;
LLPoseBlender mPoseBlender;

View File

@ -1638,6 +1638,54 @@ class LLAdvancedForceParamsToDefault : public view_listener_t
};
//////////////////////////
// ANIMATION SPEED //
//////////////////////////
// Utility function to set all AV time factors to the same global value
static void set_all_animation_time_factors(F32 time_factor)
{
LLMotionController::setCurrentTimeFactor(time_factor);
for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin();
iter != LLCharacter::sInstances.end(); ++iter)
{
(*iter)->setAnimTimeFactor(time_factor);
}
}
class LLAdvancedAnimTenFaster : public view_listener_t
{
bool handleEvent(const LLSD& userdata)
{
//llinfos << "LLAdvancedAnimTenFaster" << llendl;
F32 time_factor = LLMotionController::getCurrentTimeFactor();
time_factor = llmin(time_factor + 0.1f, 2.f); // Upper limit is 200% speed
set_all_animation_time_factors(time_factor);
return true;
}
};
class LLAdvancedAnimTenSlower : public view_listener_t
{
bool handleEvent(const LLSD& userdata)
{
//llinfos << "LLAdvancedAnimTenSlower" << llendl;
F32 time_factor = LLMotionController::getCurrentTimeFactor();
time_factor = llmax(time_factor - 0.1f, 0.1f); // Lower limit is at 10% of normal speed
set_all_animation_time_factors(time_factor);
return true;
}
};
class LLAdvancedAnimResetAll : public view_listener_t
{
bool handleEvent(const LLSD& userdata)
{
set_all_animation_time_factors(1.f);
return true;
}
};
//////////////////////////
// RELOAD VERTEX SHADER //
@ -8407,6 +8455,11 @@ void initialize_menus()
view_listener_t::addMenu(new LLAdvancedTestMale(), "Advanced.TestMale");
view_listener_t::addMenu(new LLAdvancedTestFemale(), "Advanced.TestFemale");
// Advanced > Character > Animation Speed
view_listener_t::addMenu(new LLAdvancedAnimTenFaster(), "Advanced.AnimTenFaster");
view_listener_t::addMenu(new LLAdvancedAnimTenSlower(), "Advanced.AnimTenSlower");
view_listener_t::addMenu(new LLAdvancedAnimResetAll(), "Advanced.AnimResetAll");
// Advanced > Character (toplevel)
view_listener_t::addMenu(new LLAdvancedForceParamsToDefault(), "Advanced.ForceParamsToDefault");
view_listener_t::addMenu(new LLAdvancedReloadVertexShader(), "Advanced.ReloadVertexShader");

View File

@ -3178,6 +3178,40 @@
parameter="AllowSelectAvatar" />
</menu_item_check>
</menu>
<menu
create_jump_keys="true"
label="Animation Speed"
name="Animation Speed"
tear_off="true">
<menu_item_call
label="All Animations 10% Faster"
name="All Animations 10 Faster">
<menu_item_call.on_click
function="Advanced.AnimTenFaster" />
</menu_item_call>
<menu_item_call
label="All Animations 10% Slower"
name="All Animations 10 Slower">
<menu_item_call.on_click
function="Advanced.AnimTenSlower" />
</menu_item_call>
<menu_item_call
label="Reset All Animation Speed"
name="Reset All Animation Speed">
<menu_item_call.on_click
function="Advanced.AnimResetAll" />
</menu_item_call>
<menu_item_check
label="Slow Motion Animations"
name="Slow Motion Animations">
<menu_item_check.on_check
function="CheckControl"
parameter="SlowMotionAnimation" />
<menu_item_check.on_click
function="ToggleControl"
parameter="SlowMotionAnimation" />
</menu_item_check>
</menu>
<menu_item_call
label="Force Params to Default"
name="Force Params to Default">
@ -3194,16 +3228,6 @@
function="Advanced.ToggleAnimationInfo"
parameter="" />
</menu_item_check>
<menu_item_check
label="Slow Motion Animations"
name="Slow Motion Animations">
<menu_item_check.on_check
function="CheckControl"
parameter="SlowMotionAnimation" />
<menu_item_check.on_click
function="ToggleControl"
parameter="SlowMotionAnimation" />
</menu_item_check>
<menu_item_check
label="Show Look At"
name="Show Look At">