Skip to content

Commit

Permalink
Clamp input to animEffect()
Browse files Browse the repository at this point in the history
Fixes #1913.

animEffect() seems to expect a value between 0 and 1, and #1913 is caused by the surf coverFade animation lerping past 1, which feeds values greater than 256 into fadePalette(), causing the flashing colors. This PR clamps movie ticks for each item ensuring animEffect won't receive values > 1.

This could create issues if any animation items rely on playing past their end. I didn't notice any while visually checking the editor and surf menu animations, but I could easily have missed something.

It might be better to move this clamp directly to the start of animEffect().

Alternative fixes for #1913 include clamping the fadePalette() value between 0 and 256, or stopping the animation at the right time.
  • Loading branch information
Madadog authored Mar 2, 2023
1 parent ecbcae5 commit e9f68eb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/studio/studio.c
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,10 @@ static inline float animEffect(AnimEffect effect, float x)
static void animTick(Movie* movie)
{
for(Anim* it = movie->items, *end = it + movie->count; it != end; ++it)
*it->value = lerp(it->start, it->end, animEffect(it->effect, (float)movie->tick / it->time));
{
float tick = (float)(movie->tick < it->time ? movie->tick : it->time);
*it->value = lerp(it->start, it->end, animEffect(it->effect, tick / it->time));
}
}

void processAnim(Movie* movie, void* data)
Expand Down

0 comments on commit e9f68eb

Please sign in to comment.