mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-01-10 08:44:25 +00:00
Merge branch 'camtilt' into 'master'
Add camera pitching when driving on downhill slopes See merge request KartKrew/Kart!210
This commit is contained in:
commit
27a7f020d3
4 changed files with 52 additions and 7 deletions
|
|
@ -139,6 +139,8 @@ enum cameraf {
|
|||
camera_momx,
|
||||
camera_momy,
|
||||
camera_momz,
|
||||
camera_pan,
|
||||
camera_pitch,
|
||||
camera_pnum
|
||||
};
|
||||
|
||||
|
|
@ -158,6 +160,8 @@ static const char *const camera_opt[] = {
|
|||
"momx",
|
||||
"momy",
|
||||
"momz",
|
||||
"pan",
|
||||
"pitch",
|
||||
"pnum",
|
||||
NULL};
|
||||
|
||||
|
|
@ -314,6 +318,12 @@ static int camera_get(lua_State *L)
|
|||
case camera_momz:
|
||||
lua_pushinteger(L, cam->momz);
|
||||
break;
|
||||
case camera_pan:
|
||||
lua_pushinteger(L, cam->pan);
|
||||
break;
|
||||
case camera_pitch:
|
||||
lua_pushinteger(L, cam->pitch);
|
||||
break;
|
||||
case camera_pnum:
|
||||
lua_pushinteger(L, camnum);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -107,6 +107,8 @@ typedef struct camera_s
|
|||
|
||||
// SRB2Kart: camera pans while drifting
|
||||
fixed_t pan;
|
||||
// SRB2Kart: camera pitches on slopes
|
||||
angle_t pitch;
|
||||
} camera_t;
|
||||
|
||||
extern camera_t camera[MAXSPLITSCREENPLAYERS];
|
||||
|
|
|
|||
45
src/p_user.c
45
src/p_user.c
|
|
@ -7234,8 +7234,8 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
|
|||
{
|
||||
static UINT8 lookbackdelay[4] = {0,0,0,0};
|
||||
UINT8 num;
|
||||
angle_t angle = 0, focusangle = 0, focusaiming = 0;
|
||||
fixed_t x, y, z, dist, height, viewpointx, viewpointy, camspeed, camdist, camheight, pviewheight;
|
||||
angle_t angle = 0, focusangle = 0, focusaiming = 0, pitch = 0;
|
||||
fixed_t x, y, z, dist, distxy, distz, height, viewpointx, viewpointy, camspeed, camdist, camheight, pviewheight;
|
||||
fixed_t pan, xpan, ypan;
|
||||
INT32 camrotate;
|
||||
boolean camstill, lookback;
|
||||
|
|
@ -7487,8 +7487,32 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
|
|||
height -= FixedMul(height, player->karthud[khud_boostcam]);
|
||||
}
|
||||
|
||||
x = mo->x - FixedMul(FINECOSINE((angle>>ANGLETOFINESHIFT) & FINEMASK), dist);
|
||||
y = mo->y - FixedMul(FINESINE((angle>>ANGLETOFINESHIFT) & FINEMASK), dist);
|
||||
if (mo->standingslope)
|
||||
{
|
||||
pitch = (angle_t)FixedMul(P_ReturnThrustX(mo, player->frameangle - mo->standingslope->xydirection, FRACUNIT), (fixed_t)mo->standingslope->zangle);
|
||||
if (mo->eflags & MFE_VERTICALFLIP)
|
||||
{
|
||||
if (pitch >= ANGLE_180)
|
||||
pitch = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pitch < ANGLE_180)
|
||||
pitch = 0;
|
||||
}
|
||||
}
|
||||
pitch = thiscam->pitch + (angle_t)FixedMul(pitch - thiscam->pitch, camspeed/4);
|
||||
|
||||
if (rendermode == render_opengl && !cv_grshearing.value)
|
||||
distxy = FixedMul(dist, FINECOSINE((pitch>>ANGLETOFINESHIFT) & FINEMASK));
|
||||
else
|
||||
distxy = dist;
|
||||
distz = -FixedMul(dist, FINESINE((pitch>>ANGLETOFINESHIFT) & FINEMASK));
|
||||
if (splitscreen == 1) // 2 player is weird, this helps keep players on screen
|
||||
distz = 3*distz/5;
|
||||
|
||||
x = mo->x - FixedMul(FINECOSINE((angle>>ANGLETOFINESHIFT) & FINEMASK), distxy);
|
||||
y = mo->y - FixedMul(FINESINE((angle>>ANGLETOFINESHIFT) & FINEMASK), distxy);
|
||||
|
||||
// SRB2Kart: set camera panning
|
||||
if (camstill || resetcalled || player->playerstate == PST_DEAD)
|
||||
|
|
@ -7519,9 +7543,9 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
|
|||
pviewheight = FixedMul(32<<FRACBITS, mo->scale);
|
||||
|
||||
if (mo->eflags & MFE_VERTICALFLIP)
|
||||
z = mo->z + mo->height - pviewheight - camheight;
|
||||
z = mo->z + mo->height - pviewheight - camheight + distz;
|
||||
else
|
||||
z = mo->z + pviewheight + camheight;
|
||||
z = mo->z + pviewheight + camheight + distz;
|
||||
|
||||
#ifndef NOCLIPCAM // Disable all z-clipping for noclip cam
|
||||
// move camera down to move under lower ceilings
|
||||
|
|
@ -7756,6 +7780,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
|
|||
}
|
||||
|
||||
thiscam->pan = pan;
|
||||
thiscam->pitch = pitch;
|
||||
|
||||
// compute aming to look the viewed point
|
||||
f1 = viewpointx-thiscam->x;
|
||||
|
|
@ -7763,9 +7788,17 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
|
|||
dist = FixedHypot(f1, f2);
|
||||
|
||||
if (mo->eflags & MFE_VERTICALFLIP)
|
||||
{
|
||||
angle = R_PointToAngle2(0, thiscam->z + thiscam->height, dist, mo->z + mo->height - P_GetPlayerHeight(player));
|
||||
if (thiscam->pitch < ANGLE_180 && thiscam->pitch > angle)
|
||||
angle = thiscam->pitch;
|
||||
}
|
||||
else
|
||||
{
|
||||
angle = R_PointToAngle2(0, thiscam->z, dist, mo->z + P_GetPlayerHeight(player));
|
||||
if (thiscam->pitch >= ANGLE_180 && thiscam->pitch < angle)
|
||||
angle = thiscam->pitch;
|
||||
}
|
||||
|
||||
if (player->playerstate != PST_DEAD && !((player->pflags & PF_NIGHTSMODE) && player->exiting))
|
||||
angle += (focusaiming < ANGLE_180 ? focusaiming/2 : InvAngle(InvAngle(focusaiming)/2)); // overcomplicated version of '((signed)focusaiming)/2;'
|
||||
|
|
|
|||
|
|
@ -833,7 +833,7 @@ static void R_SetupFreelook(void)
|
|||
// clip it in the case we are looking a hardware 90 degrees full aiming
|
||||
// (lmps, network and use F12...)
|
||||
G_SoftwareClipAimingPitch((INT32 *)&aimingangle);
|
||||
dy = AIMINGTODY(aimingangle) * viewwidth/BASEVIDWIDTH;
|
||||
dy = AIMINGTODY(aimingangle) * viewheight/BASEVIDHEIGHT;
|
||||
yslope = &yslopetab[viewheight*8 - (viewheight/2 + dy)];
|
||||
}
|
||||
centery = (viewheight/2) + dy;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue