Skip to content

Commit

Permalink
tr2/output: fix drawing certain rooms
Browse files Browse the repository at this point in the history
Regression from 6c36549, related to centering the 3d pickups in the UI.
Resolves #1853.
  • Loading branch information
rr- committed Nov 11, 2024
1 parent f0f7edc commit 5cf6c42
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
1 change: 1 addition & 0 deletions docs/tr2/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## [Unreleased](https://github.com/LostArtefacts/TRX/compare/tr2-0.6...develop) - ××××-××-××
- added support for custom levels to enforce values for any config setting (#1846)
- fixed depth problems when drawing certain rooms (#1853, regression from 0.6)

## [0.6](https://github.com/LostArtefacts/TRX/compare/tr2-0.5...tr2-0.6) - 2024-11-06
- added a fly cheat key (#1642)
Expand Down
21 changes: 21 additions & 0 deletions src/tr2/game/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,13 @@ void __cdecl Output_Init(

void __cdecl Output_InsertPolygons(const int16_t *obj_ptr, const int32_t clip)
{
g_FltWinLeft = g_PhdWinMinX + g_PhdWinLeft;
g_FltWinTop = g_PhdWinMinY + g_PhdWinTop;
g_FltWinRight = g_PhdWinRight + g_PhdWinMinX + 1;
g_FltWinBottom = g_PhdWinBottom + g_PhdWinMinY + 1;
g_FltWinCenterX = g_PhdWinMinX + g_PhdWinCenterX;
g_FltWinCenterY = g_PhdWinMinY + g_PhdWinCenterY;

obj_ptr = Output_CalcObjectVertices(obj_ptr + 4);
if (obj_ptr) {
obj_ptr = Output_CalcVerticeLight(obj_ptr);
Expand All @@ -424,6 +431,13 @@ void __cdecl Output_InsertPolygons_I(

void __cdecl Output_InsertRoom(const int16_t *obj_ptr, int32_t is_outside)
{
g_FltWinLeft = g_PhdWinMinX + g_PhdWinLeft;
g_FltWinTop = g_PhdWinMinY + g_PhdWinTop;
g_FltWinRight = g_PhdWinRight + g_PhdWinMinX + 1;
g_FltWinBottom = g_PhdWinBottom + g_PhdWinMinY + 1;
g_FltWinCenterX = g_PhdWinMinX + g_PhdWinCenterX;
g_FltWinCenterY = g_PhdWinMinY + g_PhdWinCenterY;

const int16_t *const old_obj_ptr = obj_ptr;
obj_ptr = Output_CalcRoomVertices(obj_ptr, is_outside ? 0 : 16);

Expand All @@ -449,6 +463,13 @@ void __cdecl Output_InsertRoom(const int16_t *obj_ptr, int32_t is_outside)

void __cdecl Output_InsertSkybox(const int16_t *obj_ptr)
{
g_FltWinLeft = g_PhdWinMinX + g_PhdWinLeft;
g_FltWinTop = g_PhdWinMinY + g_PhdWinTop;
g_FltWinRight = g_PhdWinRight + g_PhdWinMinX + 1;
g_FltWinBottom = g_PhdWinBottom + g_PhdWinMinY + 1;
g_FltWinCenterX = g_PhdWinMinX + g_PhdWinCenterX;
g_FltWinCenterY = g_PhdWinMinY + g_PhdWinCenterY;

obj_ptr = Output_CalcObjectVertices(obj_ptr + 4);
if (obj_ptr) {
if (g_SavedAppSettings.render_mode == RM_HARDWARE) {
Expand Down
4 changes: 2 additions & 2 deletions src/tr2/game/overlay.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,8 @@ static void M_DrawPickup3D(const DISPLAY_PICKUP *const pickup)
const int32_t vp_x = vp_src_x + (vp_dst_x - vp_src_x) * ease;
const int32_t vp_y = vp_src_y + (vp_dst_y - vp_src_y) * ease;

g_FltWinCenterX = vp_x;
g_FltWinCenterY = vp_y;
g_PhdWinCenterX = vp_x;
g_PhdWinCenterY = vp_y;

Matrix_PushUnit();
Matrix_TranslateRel(0, 0, scale);
Expand Down
10 changes: 0 additions & 10 deletions src/tr2/game/viewport.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@ static void M_Apply(void)
g_PhdWinMaxY = m_Viewport.height - 1;
g_PhdWinWidth = m_Viewport.width;
g_PhdWinHeight = m_Viewport.height;

g_PhdWinCenterX = m_Viewport.width / 2;
g_PhdWinCenterY = m_Viewport.height / 2;
g_FltWinCenterX = m_Viewport.width / 2;
g_FltWinCenterY = m_Viewport.height / 2;

g_PhdWinLeft = 0;
g_PhdWinTop = 0;
Expand All @@ -38,13 +35,6 @@ static void M_Apply(void)
g_PhdNearZ = m_Viewport.near_z << W2V_SHIFT;
g_PhdFarZ = m_Viewport.far_z << W2V_SHIFT;

g_FltWinLeft = g_PhdWinMinX + g_PhdWinLeft;
g_FltWinTop = g_PhdWinMinY + g_PhdWinTop;
g_FltWinRight = g_PhdWinRight + g_PhdWinMinX + 1;
g_FltWinBottom = g_PhdWinBottom + g_PhdWinMinY + 1;
g_FltWinCenterX = g_PhdWinMinX + g_PhdWinCenterX;
g_FltWinCenterY = g_PhdWinMinY + g_PhdWinCenterY;

g_FltNearZ = g_PhdNearZ;
g_FltFarZ = g_PhdFarZ;

Expand Down

0 comments on commit 5cf6c42

Please sign in to comment.