Skip to content

Commit

Permalink
Merge branch 'interp-visportals' into 'master'
Browse files Browse the repository at this point in the history
fix portal interp view positioning and camera reset

Closes STJr#14 and STJr#12

See merge request KartKrew/Kart-Public!293
  • Loading branch information
HybridEidolon committed Aug 20, 2022
2 parents a37ae53 + ca5884c commit 6514d3c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/p_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ typedef struct camera_s
// Camera demobjerization
// Info for drawing: position.
fixed_t x, y, z;
boolean reset;

//More drawing info: to determine current sprite.
angle_t angle; // orientation
Expand Down
1 change: 1 addition & 0 deletions src/p_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -7392,6 +7392,7 @@ void P_ResetCamera(player_t *player, camera_t *thiscam)
thiscam->x = x;
thiscam->y = y;
thiscam->z = z;
thiscam->reset = true;

if (!(thiscam == &camera[0] && (cv_cam_still.value || cv_analog.value))
&& !(thiscam == &camera[1] && (cv_cam2_still.value || cv_analog2.value))
Expand Down
38 changes: 29 additions & 9 deletions src/r_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1045,24 +1045,44 @@ void R_SetupFrame(player_t *player, boolean skybox)
thiscam = &camera[3];
chasecam = (cv_chasecam4.value != 0);
R_SetViewContext(VIEWCONTEXT_PLAYER4);
if (thiscam->reset)
{
R_ResetViewInterpolation(4);
thiscam->reset = false;
}
}
else if (splitscreen > 1 && player == &players[displayplayers[2]])
{
thiscam = &camera[2];
chasecam = (cv_chasecam3.value != 0);
R_SetViewContext(VIEWCONTEXT_PLAYER3);
if (thiscam->reset)
{
R_ResetViewInterpolation(3);
thiscam->reset = false;
}
}
else if (splitscreen && player == &players[displayplayers[1]])
{
thiscam = &camera[1];
chasecam = (cv_chasecam2.value != 0);
R_SetViewContext(VIEWCONTEXT_PLAYER2);
if (thiscam->reset)
{
R_ResetViewInterpolation(2);
thiscam->reset = false;
}
}
else
{
thiscam = &camera[0];
chasecam = (cv_chasecam.value != 0);
R_SetViewContext(VIEWCONTEXT_PLAYER1);
if (thiscam->reset)
{
R_ResetViewInterpolation(1);
thiscam->reset = false;
}
}

if (player->spectator) // no spectator chasecam
Expand Down Expand Up @@ -1175,11 +1195,11 @@ static void R_PortalFrame(line_t *start, line_t *dest, portal_pair *portal)
#endif

//R_SetupFrame(player, false);
newview->x = portal->viewx;
newview->y = portal->viewy;
newview->z = portal->viewz;
viewx = portal->viewx;
viewy = portal->viewy;
viewz = portal->viewz;

newview->angle = portal->viewangle;
viewangle = portal->viewangle;
// newview->sin = FINESINE(newview->angle>>ANGLETOFINESHIFT);
// newview->cos = FINECOSINE(newview->angle>>ANGLETOFINESHIFT);

Expand Down Expand Up @@ -1207,13 +1227,13 @@ static void R_PortalFrame(line_t *start, line_t *dest, portal_pair *portal)
if (dangle == 0)
#endif
{ // the entrance goes straight opposite the exit, so we just need to mess with the offset.
newview->x += dest_c.x - start_c.x;
newview->y += dest_c.y - start_c.y;
viewx += dest_c.x - start_c.x;
viewy += dest_c.y - start_c.y;
return;
}

#ifdef ANGLED_PORTALS
newview->angle += dangle;
viewangle += dangle;
// newview->sin = FINESINE(newview->angle>>ANGLETOFINESHIFT);
// newview->cos = FINECOSINE(newview->angle>>ANGLETOFINESHIFT);
//CONS_Printf("dangle == %u\n", AngleFixed(dangle)>>FRACBITS);
Expand All @@ -1227,8 +1247,8 @@ static void R_PortalFrame(line_t *start, line_t *dest, portal_pair *portal)
angtopoint = R_PointToAngle2(start_c.x, start_c.y, newview->x, newview->y);
angtopoint += dangle;

newview->x = dest_c.x+FixedMul(FINECOSINE(angtopoint>>ANGLETOFINESHIFT), disttopoint);
newview->y = dest_c.y+FixedMul(FINESINE(angtopoint>>ANGLETOFINESHIFT), disttopoint);
viewx = dest_c.x+FixedMul(FINECOSINE(angtopoint>>ANGLETOFINESHIFT), disttopoint);
viewy = dest_c.y+FixedMul(FINESINE(angtopoint>>ANGLETOFINESHIFT), disttopoint);
}
#endif
}
Expand Down

0 comments on commit 6514d3c

Please sign in to comment.