From d0c3ed061c2e31b4428758ddb9572ee448abd8d6 Mon Sep 17 00:00:00 2001 From: lahm86 <33758420+lahm86@users.noreply.github.com> Date: Tue, 25 Feb 2025 19:21:18 +0000 Subject: [PATCH] interpolation: handle specific effect deltas This resolves the TR1 mutant missiles and TR2 flame blasts jittering. --- docs/tr1/CHANGELOG.md | 1 + src/libtrx/game/interpolation.c | 34 ++++++++++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/docs/tr1/CHANGELOG.md b/docs/tr1/CHANGELOG.md index bfa195605..cf1d61b65 100644 --- a/docs/tr1/CHANGELOG.md +++ b/docs/tr1/CHANGELOG.md @@ -1,6 +1,7 @@ ## [Unreleased](https://github.com/LostArtefacts/TRX/compare/tr1-4.8.3...develop) - ××××-××-×× - added support for custom levels to use `disable_floor` in the gameflow, similar to TR2's Floating Islands (#2541) - fixed issues with fixed cameras in 60 FPS shifting before settling on their target (#1186) +- fixed missiles from mutants/centaurs/Natla jittering in 60 FPS (#1314) ## [4.8.3](https://github.com/LostArtefacts/TRX/compare/tr1-4.8.2...tr1-4.8.3) - 2025-02-17 - fixed some of Lara's speech in the gym not playing in response to player action (#2514, regression from 4.8) diff --git a/src/libtrx/game/interpolation.c b/src/libtrx/game/interpolation.c index c6694a29d..7f2626493 100644 --- a/src/libtrx/game/interpolation.c +++ b/src/libtrx/game/interpolation.c @@ -88,6 +88,33 @@ static XYZ_32 M_GetItemMaxDelta(const ITEM *const item) return (XYZ_32) { .x = max_xz, .y = max_y, .z = max_xz }; } +static XYZ_32 M_GetEffectMaxDelta(const EFFECT *const effect) +{ + int32_t max_xz = 128; + int32_t max_y = MAX(128, effect->fall_speed * 2); + switch (effect->object_id) { +#if TR_VERSION == 1 + case O_MISSILE_1: + case O_MISSILE_3: +#else + case O_MISSILE_FLAME: +#endif + max_xz = 220; + break; + +#if TR_VERSION == 1 + case O_MISSILE_2: + max_xz = 64; + break; +#endif + + default: + break; + } + + return (XYZ_32) { .x = max_xz, .y = max_y, .z = max_xz }; +} + bool Interpolation_IsEnabled(void) { return m_IsEnabled && M_GetFPS() == 60; @@ -206,9 +233,10 @@ void Interpolation_Commit(void) int16_t effect_num = Effect_GetActiveNum(); while (effect_num != NO_EFFECT) { EFFECT *const effect = Effect_Get(effect_num); - INTERPOLATE(effect, pos.x, ratio, 128); - INTERPOLATE(effect, pos.y, ratio, MAX(128, effect->fall_speed * 2)); - INTERPOLATE(effect, pos.z, ratio, 128); + const XYZ_32 max_delta = M_GetEffectMaxDelta(effect); + INTERPOLATE(effect, pos.x, ratio, max_delta.x); + INTERPOLATE(effect, pos.y, ratio, max_delta.y); + INTERPOLATE(effect, pos.z, ratio, max_delta.z); INTERPOLATE_ROT(effect, rot.x, ratio, DEG_45); INTERPOLATE_ROT(effect, rot.y, ratio, DEG_45); INTERPOLATE_ROT(effect, rot.z, ratio, DEG_45);