Skip to content

Commit

Permalink
interpolation: handle specific effect deltas
Browse files Browse the repository at this point in the history
This resolves the TR1 mutant missiles and TR2 flame blasts jittering.
  • Loading branch information
lahm86 committed Feb 25, 2025
1 parent 1ccadc4 commit d0c3ed0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/tr1/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
34 changes: 31 additions & 3 deletions src/libtrx/game/interpolation.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit d0c3ed0

Please # to comment.