From ddbdb77368321a19e26a9fde4b14f464e41210b3 Mon Sep 17 00:00:00 2001 From: "Ben \"root\" Anderson" Date: Fri, 13 Dec 2013 12:10:11 -0600 Subject: [PATCH] Split Actor::BeginDraw() into Actor::PreDraw() which does tweening calculations and Actor::BeginDraw() now only sets up the matrix. Skip setting up the matrix if the Actor is fully transparent. --- src/Actor.cpp | 22 ++++++++++++++-------- src/Actor.h | 2 ++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/Actor.cpp b/src/Actor.cpp index eea8c8d9f5..b65cee2e4d 100644 --- a/src/Actor.cpp +++ b/src/Actor.cpp @@ -281,12 +281,15 @@ void Actor::LoadFromNode( const XNode* pNode ) void Actor::Draw() { - if( !m_bVisible ) + if( !m_bVisible || + m_fHibernateSecondsLeft > 0 || + this->EarlyAbortDraw() ) + return; // early abort + + this->PreDraw(); + ASSERT( m_pTempState != NULL ); + if( m_pTempState->diffuse[0].a == 0 && m_pTempState->diffuse[1].a == 0 && m_pTempState->diffuse[2].a == 0 && m_pTempState->diffuse[3].a == 0 ) // This Actor is fully transparent return; // early abort - if( m_fHibernateSecondsLeft > 0 ) - return; // early abort - if( this->EarlyAbortDraw() ) - return; // call the most-derived versions this->BeginDraw(); @@ -294,10 +297,8 @@ void Actor::Draw() this->EndDraw(); } -void Actor::BeginDraw() // set the world matrix and calculate actor properties +void Actor::PreDraw() // calculate actor properties { - DISPLAY->PushMatrix(); // we're actually going to do some drawing in this function - // Somthing below may set m_pTempState to tempState m_pTempState = &m_current; @@ -480,6 +481,11 @@ void Actor::BeginDraw() // set the world matrix and calculate actor properties tempState.glow = tempState.glow + m_internalGlow - m_internalGlow * tempState.glow; m_internalGlow.a = 0; } +} + +void Actor::BeginDraw() // set the world matrix +{ + DISPLAY->PushMatrix(); if( m_pTempState->pos.x != 0 || m_pTempState->pos.y != 0 || m_pTempState->pos.z != 0 ) { diff --git a/src/Actor.h b/src/Actor.h index 13220c63cd..fe3aaaaaa5 100644 --- a/src/Actor.h +++ b/src/Actor.h @@ -242,6 +242,8 @@ public: * aborted actors. * @return false, as by default Actors shouldn't be aborted on drawing. */ virtual bool EarlyAbortDraw() const { return false; } + /** @brief Calculate values that may be needed for drawing. */ + virtual void PreDraw(); /** @brief Start the drawing and push the transform on the world matrix stack. */ virtual void BeginDraw(); /**