Skip to content

Commit

Permalink
added ActorMultiVertex
Browse files Browse the repository at this point in the history
AMV is an actor which can have a variable number of vertices that can
each be given their own pos, color, and coords. They can be drawn using
any of the RageSpriteVertex draw functions in RageDisplay.cpp. The
vertex properties can be tweened.
  • Loading branch information
sigatrev committed Apr 15, 2014
1 parent 0263b11 commit 70c5209
Show file tree
Hide file tree
Showing 6 changed files with 878 additions and 14 deletions.
24 changes: 12 additions & 12 deletions src/Actor.cpp
Expand Up @@ -84,7 +84,7 @@ void Actor::SetBGMLight( int iLightNumber, float fCabinetLights )

void Actor::InitState()
{
StopTweening();
this->StopTweening();

m_pTempState = NULL;

Expand Down Expand Up @@ -615,14 +615,9 @@ void Actor::EndDraw()

void Actor::UpdateTweening( float fDeltaTime )
{
while( 1 )
while( !m_Tweens.empty() // something to do
&& fDeltaTime > 0 ) // something will change
{
if( m_Tweens.empty() ) // nothing to do
return;

if( fDeltaTime == 0 ) // nothing will change
return;

// update current tween state
// earliest tween
TweenState &TS = m_Tweens[0]->state;
Expand All @@ -636,7 +631,10 @@ void Actor::UpdateTweening( float fDeltaTime )

RString sCommand = TI.m_sCommandName;
if( bBeginning ) // we are just beginning this tween
{
m_start = m_current; // set the start position
SetCurrentTweenStart();
}

if( TI.m_fTimeLeftInTween == 0 ) // Current tween is over. Stop.
{
Expand All @@ -645,6 +643,7 @@ void Actor::UpdateTweening( float fDeltaTime )
// delete the head tween
delete m_Tweens.front();
m_Tweens.erase( m_Tweens.begin() );
EraseHeadTween();
}
else // in the middle of tweening. Recalcute the current position.
{
Expand All @@ -653,6 +652,7 @@ void Actor::UpdateTweening( float fDeltaTime )
// distort the percentage if appropriate
float fPercentAlongPath = TI.m_pTween->Tween( fPercentThroughTween );
TweenState::MakeWeightedAverage( m_current, m_start, TS, fPercentAlongPath );
UpdatePercentThroughTween(fPercentAlongPath);
}

if( bBeginning )
Expand Down Expand Up @@ -772,7 +772,7 @@ void Actor::UpdateInternal( float fDeltaTime )
default: break;
}

UpdateTweening( fDeltaTime );
this->UpdateTweening( fDeltaTime );
}

RString Actor::GetLineage() const
Expand All @@ -797,7 +797,7 @@ void Actor::BeginTweening( float time, ITween *pTween )

LOG->Warn( "%s", sError.c_str() );
Dialog::OK( sError );
FinishTweening();
this->FinishTweening();
}

// add a new TweenState to the tail, and initialize it
Expand Down Expand Up @@ -829,7 +829,7 @@ void Actor::BeginTweening( float time, TweenType tt )
ASSERT( time >= 0 );

ITween *pTween = ITween::CreateFromType( tt );
BeginTweening( time, pTween );
this->BeginTweening( time, pTween );
}

void Actor::StopTweening()
Expand All @@ -843,7 +843,7 @@ void Actor::FinishTweening()
{
if( !m_Tweens.empty() )
m_current = DestTweenState();
StopTweening();
this->StopTweening();
}

void Actor::HurryTweening( float factor )
Expand Down
8 changes: 6 additions & 2 deletions src/Actor.h
Expand Up @@ -270,6 +270,10 @@ class Actor : public MessageSubscriber
virtual void Update( float fDeltaTime ); // this can short circuit UpdateInternal
virtual void UpdateInternal( float fDeltaTime ); // override this
void UpdateTweening( float fDeltaTime );
// These next functions should all be overridden by a derived class that has its own tweening states to handl.
virtual void SetCurrentTweenStart() {}
virtual void EraseHeadTween() {}
virtual void UpdatePercentThroughTween( float PercentThroughTween ) {}

/**
* @brief Retrieve the Actor's name.
Expand Down Expand Up @@ -449,9 +453,9 @@ class Actor : public MessageSubscriber
void SetAux( float f ) { DestTweenState().aux = f; }
float GetAux() const { return m_current.aux; }

void BeginTweening( float time, ITween *pInterp );
virtual void BeginTweening( float time, ITween *pInterp );
void BeginTweening( float time, TweenType tt = TWEEN_LINEAR );
void StopTweening();
virtual void StopTweening();
void Sleep( float time );
void QueueCommand( const RString& sCommandName );
void QueueMessage( const RString& sMessageName );
Expand Down

0 comments on commit 70c5209

Please sign in to comment.