Added flag for making an actor use the effect delta for tweening. Updated changelog.

This commit is contained in:
Kyzentun Keeslala
2016-03-17 19:37:27 -06:00
parent 89738c68c9
commit a4ecf15ce3
5 changed files with 56 additions and 8 deletions
+24 -6
View File
@@ -723,8 +723,25 @@ void Actor::EndDraw()
}
void Actor::CalcPercentThroughTween()
{
TweenState &TS = m_Tweens[0]->state;
TweenInfo &TI = m_Tweens[0]->info;
const float percent_through = 1-(TI.m_fTimeLeftInTween / TI.m_fTweenTime);
// distort the percentage if appropriate
float percent_along = TI.m_pTween->Tween(percent_through);
TweenState::MakeWeightedAverage(m_current, m_start, TS, percent_along);
UpdatePercentThroughTween(percent_along);
}
void Actor::UpdateTweening( float fDeltaTime )
{
if(fDeltaTime < 0.0 && !m_Tweens.empty())
{
m_Tweens[0]->info.m_fTimeLeftInTween-= fDeltaTime;
CalcPercentThroughTween();
return;
}
while( !m_Tweens.empty() // something to do
&& fDeltaTime > 0 ) // something will change
{
@@ -757,12 +774,7 @@ void Actor::UpdateTweening( float fDeltaTime )
}
else // in the middle of tweening. Recalcute the current position.
{
const float fPercentThroughTween = 1-(TI.m_fTimeLeftInTween / TI.m_fTweenTime);
// distort the percentage if appropriate
float fPercentAlongPath = TI.m_pTween->Tween( fPercentThroughTween );
TweenState::MakeWeightedAverage( m_current, m_start, TS, fPercentAlongPath );
UpdatePercentThroughTween(fPercentAlongPath);
CalcPercentThroughTween();
}
if( bBeginning )
@@ -884,6 +896,10 @@ void Actor::UpdateInternal(float delta_time)
default: break;
}
if(m_tween_uses_effect_delta)
{
delta_time= m_fEffectDelta;
}
this->UpdateTweening(delta_time);
}
@@ -1739,6 +1755,7 @@ public:
static int effectclock( T* p, lua_State *L ) { p->SetEffectClockString(SArg(1)); COMMON_RETURN_SELF; }
static int effectmagnitude( T* p, lua_State *L ) { p->SetEffectMagnitude( RageVector3(FArg(1),FArg(2),FArg(3)) ); COMMON_RETURN_SELF; }
static int geteffectmagnitude( T* p, lua_State *L ) { RageVector3 v = p->GetEffectMagnitude(); lua_pushnumber(L, v[0]); lua_pushnumber(L, v[1]); lua_pushnumber(L, v[2]); return 3; }
GETTER_SETTER_BOOL_METHOD(tween_uses_effect_delta);
static int scaletocover( T* p, lua_State *L ) { p->ScaleToCover( RectF(FArg(1), FArg(2), FArg(3), FArg(4)) ); COMMON_RETURN_SELF; }
static int scaletofit( T* p, lua_State *L ) { p->ScaleToFitInside( RectF(FArg(1), FArg(2), FArg(3), FArg(4)) ); COMMON_RETURN_SELF; }
static int animate( T* p, lua_State *L ) { p->EnableAnimation(BIArg(1)); COMMON_RETURN_SELF; }
@@ -2023,6 +2040,7 @@ public:
ADD_METHOD( effectclock );
ADD_METHOD( effectmagnitude );
ADD_METHOD( geteffectmagnitude );
ADD_GET_SET_METHODS(tween_uses_effect_delta);
ADD_METHOD( scaletocover );
ADD_METHOD( scaletofit );
ADD_METHOD( animate );
+4
View File
@@ -281,10 +281,13 @@ public:
virtual void Update( float fDeltaTime ); // this can short circuit UpdateInternal
virtual void UpdateInternal( float fDeltaTime ); // override this
void UpdateTweening( float fDeltaTime );
void CalcPercentThroughTween();
// These next functions should all be overridden by a derived class that has its own tweening states to handle.
virtual void SetCurrentTweenStart() {}
virtual void EraseHeadTween() {}
virtual void UpdatePercentThroughTween( float PercentThroughTween ) {}
bool get_tween_uses_effect_delta() { return m_tween_uses_effect_delta; }
void set_tween_uses_effect_delta(bool t) { m_tween_uses_effect_delta= t; }
/**
* @brief Retrieve the Actor's name.
@@ -700,6 +703,7 @@ protected:
// -Kyz
float m_effect_period;
EffectClock m_EffectClock;
bool m_tween_uses_effect_delta;
/* This can be used in lieu of the fDeltaTime parameter to Update() to
* follow the effect clock. Actor::Update must be called first. */