Skip to content

Commit

Permalink
interpolation: handle specific effect deltas
Browse files Browse the repository at this point in the history
This resolves various TR1 and TR2 effects jittering in 60fps.
  • Loading branch information
lahm86 committed Feb 28, 2025
1 parent 3607930 commit 93e723d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/tr1/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- changed the Controls screen to hide the reset and unbind texts when changing a key (#2103)
- fixed several instances of the camera going out of bounds (#1034)
- 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)
- fixed the bear AI fix option being applied in the Vilcabamba demo (#2559, regression from 4.8)

## [4.8.3](https://github.com/LostArtefacts/TRX/compare/tr1-4.8.2...tr1-4.8.3) - 2025-02-17
Expand Down
37 changes: 34 additions & 3 deletions src/libtrx/game/interpolation.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,36 @@ 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:
max_xz = 220;
break;
case O_MISSILE_2:
max_xz = 250;
break;
#else
case O_MISSILE_FLAME:
max_xz = 200;
break;
case O_MISSILE_KNIFE:
case O_MISSILE_HARPOON:
max_xz = 150;
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 @@ -204,9 +234,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 93e723d

Please sign in to comment.