Skip to content

Commit

Permalink
Fixed|Model Renderer|World: Defer triggering of state animations
Browse files Browse the repository at this point in the history
A mobj may change states multiple times per tick. For instance, an
Ettin's attack could be restarted immediately during the same state
when the previous attack has ended and the Ettin returns to chase.

The animations are now triggered based on what is the mobj state in
effect in the end of a tick.
  • Loading branch information
skyjake committed Sep 26, 2015
1 parent a3b7c31 commit 9c4e9e7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions doomsday/apps/client/src/world/clientmobjthinkerdata.cpp
Expand Up @@ -33,7 +33,8 @@ namespace internal
{
enum Flag
{
Initialized = 0x1 ///< Thinker data has been initialized.
Initialized = 0x1, ///< Thinker data has been initialized.
StateChanged = 0x2 ///< State has changed during the current tick.
};
Q_DECLARE_FLAGS(Flags, Flag)
Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Expand Down Expand Up @@ -193,6 +194,11 @@ ClientMobjThinkerData::ClientMobjThinkerData(ClientMobjThinkerData const &other)
void ClientMobjThinkerData::think()
{
d->initOnce();
if(d->flags.testFlag(StateChanged))
{
d->flags &= ~StateChanged;
d->triggerStateAnimations();
}
d->triggerMovementAnimations();
d->advanceAnimations(SECONDSPERTIC); // mobjs think only on sharp ticks
}
Expand Down Expand Up @@ -248,6 +254,6 @@ void ClientMobjThinkerData::stateChanged(state_t const *previousState)
bool const justSpawned = !previousState;

d->initOnce();
d->triggerStateAnimations();
d->flags |= StateChanged; // Will trigger animations during think.
d->triggerParticleGenerators(justSpawned);
}

0 comments on commit 9c4e9e7

Please sign in to comment.