Skip to content

Commit

Permalink
move firstupdate to actorframes only since its only used for oncommands
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed Dec 6, 2018
1 parent 592ade2 commit ea60f7b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
18 changes: 3 additions & 15 deletions src/Actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ Actor::Actor()
InitState();
m_pParent = nullptr;
m_FakeParent = nullptr;
m_bFirstUpdate = true;
m_tween_uses_effect_delta = false;
}

Expand Down Expand Up @@ -205,8 +204,6 @@ Actor::Actor(const Actor& cpy)
for (unsigned i = 0; i < cpy.m_Tweens.size(); ++i)
m_Tweens.push_back(new TweenStateAndInfo(*cpy.m_Tweens[i]));

CPY(m_bFirstUpdate);

CPY(m_fHorizAlign);
CPY(m_fVertAlign);
#if defined(SSC_FUTURES)
Expand Down Expand Up @@ -842,12 +839,6 @@ Actor::UpdateTweening(float fDeltaTime)
}
}

bool
Actor::IsFirstUpdate() const
{
return m_bFirstUpdate;
}

void
Actor::Update(float fDeltaTime)
{
Expand All @@ -864,9 +855,9 @@ Actor::Update(float fDeltaTime)
fDeltaTime = -m_fHibernateSecondsLeft;
m_fHibernateSecondsLeft = 0;
}
for (size_t i = 0; i < m_WrapperStates.size(); ++i) {
m_WrapperStates[i]->Update(fDeltaTime);
}
if (!m_WrapperStates.empty())
for (auto* w : m_WrapperStates)
w->Update(fDeltaTime);

this->UpdateInternal(fDeltaTime);
}
Expand All @@ -883,9 +874,6 @@ generic_global_timer_update(float new_time,
void
Actor::UpdateInternal(float delta_time)
{
if (m_bFirstUpdate)
m_bFirstUpdate = false;

switch (m_EffectClock) {
case CLOCK_TIMER:
m_fSecsIntoEffect += delta_time;
Expand Down
3 changes: 0 additions & 3 deletions src/Actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ class Actor : public MessageSubscriber

// TODO: make Update non virtual and change all classes to override
// UpdateInternal instead.
bool IsFirstUpdate() const;
virtual void Update(
float fDeltaTime); // this can short circuit UpdateInternal
virtual void UpdateInternal(float fDeltaTime); // override this
Expand Down Expand Up @@ -847,8 +846,6 @@ class Actor : public MessageSubscriber
/** @brief Temporary variables that are filled just before drawing */
TweenState* m_pTempState;

bool m_bFirstUpdate;

// Stuff for alignment
/** @brief The particular horizontal alignment.
*
Expand Down
10 changes: 10 additions & 0 deletions src/ActorFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ ActorFrame::ActorFrame()
m_fVanishY = SCREEN_CENTER_Y;
m_bOverrideLighting = false;
m_bLighting = false;
m_bFirstUpdate = true;
m_ambientColor = RageColor(1, 1, 1, 1);
m_diffuseColor = RageColor(1, 1, 1, 1);
m_specularColor = RageColor(1, 1, 1, 1);
Expand Down Expand Up @@ -66,6 +67,7 @@ ActorFrame::ActorFrame(const ActorFrame& cpy)
CPY(m_diffuseColor);
CPY(m_specularColor);
CPY(m_lightDirection);
CPY(m_bFirstUpdate);
#undef CPY

/* If m_bDeleteChildren, we own our children and it's up to us to copy
Expand Down Expand Up @@ -489,10 +491,18 @@ ActorFrame::RunCommandsOnLeaves(const LuaReference& cmds,
m_SubActors[i]->RunCommandsOnLeaves(cmds, pParamTable);
}

bool
ActorFrame::IsFirstUpdate() const
{
return m_bFirstUpdate;
}

void
ActorFrame::UpdateInternal(float fDeltaTime)
{
// LOG->Trace( "ActorFrame::Update( %f )", fDeltaTime );
if (m_bFirstUpdate)
m_bFirstUpdate = false;

fDeltaTime *= m_fUpdateRate;

Expand Down
4 changes: 2 additions & 2 deletions src/ActorFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class ActorFrame : public Actor
void RunCommandsOnLeaves(
const LuaReference& cmds,
const LuaReference* pParamTable = nullptr) override; /* but not on self */

bool IsFirstUpdate() const;
void UpdateInternal(float fDeltaTime) override;
void BeginDraw() override;
void DrawPrimitives() override;
Expand Down Expand Up @@ -167,7 +167,7 @@ class ActorFrame : public Actor
* If true, set lightning to m_bLightning. */
bool m_bOverrideLighting;
bool m_bLighting;

bool m_bFirstUpdate;
// lighting variables
RageColor m_ambientColor;
RageColor m_diffuseColor;
Expand Down

0 comments on commit ea60f7b

Please sign in to comment.