Skip to content

Commit

Permalink
camera: fix vibrations when teleporting
Browse files Browse the repository at this point in the history
This enforces a camera reset when Lara teleports to avoid large shifts
in values between the camera positions.

Resolves LostArtefacts#1274.
  • Loading branch information
lahm86 committed Apr 18, 2024
1 parent 9904e75 commit 93bb244
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## [Unreleased](https://github.com/LostArtefacts/TR1X/compare/stable...develop) - ××××-××-××
- fixed camera vibrations when using the teleport command in 60 FPS (#1274)

## [4.0.3](https://github.com/LostArtefacts/TR1X/compare/4.0.2...4.0.3) - 2024-04-14
- fixed flickering sprite pickups (#1298)
Expand Down
6 changes: 5 additions & 1 deletion src/game/camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ void Camera_Reset(void)
g_Camera.pos.room_number = NO_ROOM;
}

void Camera_Initialise(void)
void Camera_ResetPosition(void)
{
assert(g_LaraItem);
g_Camera.shift = g_LaraItem->pos.y - WALL_L;
Expand All @@ -435,7 +435,11 @@ void Camera_Initialise(void)
g_Camera.number = NO_CAMERA;
g_Camera.additional_angle = 0;
g_Camera.additional_elevation = 0;
}

void Camera_Initialise(void)
{
Camera_ResetPosition();
Camera_Update();
}

Expand Down
1 change: 1 addition & 0 deletions src/game/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

void Camera_Initialise(void);
void Camera_Reset(void);
void Camera_ResetPosition(void);
void Camera_Chase(ITEM_INFO *item);
void Camera_Combat(ITEM_INFO *item);
void Camera_Look(ITEM_INFO *item);
Expand Down
5 changes: 5 additions & 0 deletions src/game/items.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "config.h"
#include "game/anim.h"
#include "game/camera.h"
#include "game/carrier.h"
#include "game/clock.h"
#include "game/interpolation.h"
Expand Down Expand Up @@ -282,6 +283,10 @@ bool Item_Teleport(ITEM_INFO *item, int32_t x, int32_t y, int32_t z)
const int16_t item_num = item - g_Items;
Item_NewRoom(item_num, room_num);
}

if (item->object_number == O_LARA) {
Camera_ResetPosition();
}
return true;
}
return false;
Expand Down

0 comments on commit 93bb244

Please sign in to comment.