Skip to content

Model animation duration fixes

kaldrum requested to merge kaldrum/model-features:interpolation-speed-fix into next

(this fix is already included in !2424 and !2489 , however, I thought the standalone fix and features would be good to have on its own)

One issue frequently seen with models is when interpolated frames break as the animation speed gets adjusted. This can be seen as you progress through the frames of a walk cycle and it gradually gets choppier, or when using speed shoes and interpolation on a run animation stops entirely. This is because the tic counter of the animation (mobj->tics) is being freely set as needed according to the speed adjustment rules, but the actual duration, which is used by models to help determine intermediates in interpolation frames, remains a copy of the state's tic value (mobj->state->tics). When an animation gradually speeds up, the frames get increasingly weighted towards the earlier frame between two interpolated ones, which leads to animations getting choppy and distorted.

This fixes this, applying the same rules that determine the animation speed in the first place to also determine the duration for models.

Old:

SRB2 v2.2.13 2024-07-08 16-08-22.mp4

New:

SRB2 v2.2.14 nightly 2024-07-08 16-06-41.mp4

However, because these values are all hardcoded, there still would be no way for lua to adjust this duration value if needed, despite being able to adjust mobj->tics manually. For example, multiple of Vector's animations use unique frame timings that work fine with sprites but get completely distorted If you force on interpolation. You can see for yourself if you look at Vector's wait or edge animations with interpolation forced on. If mobj->tics were set properly to the mods own tic counter, interpolation would still break because there would be no way to account for the modified duration.

Because of this, I reused the aptly named mobj->anim_duration, which is currently only used for FF_ANIMATE states, to serve as an override to the animation's duration if it's ever manually set on states without the frame flag. This way, a modder is able to set both the tics and duration of a modified animation to whatever they want, which should hopefully avoid issues with interpolation bugs.

Merge request reports

Loading