mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Add camera pitching when driving on downhill slopes
This commit is contained in:
parent
b3a1bb6064
commit
f0c98697dc
3 changed files with 41 additions and 6 deletions
|
|
@ -139,6 +139,8 @@ enum cameraf {
|
||||||
camera_momx,
|
camera_momx,
|
||||||
camera_momy,
|
camera_momy,
|
||||||
camera_momz,
|
camera_momz,
|
||||||
|
camera_pan,
|
||||||
|
camera_pitch,
|
||||||
camera_pnum
|
camera_pnum
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -158,6 +160,8 @@ static const char *const camera_opt[] = {
|
||||||
"momx",
|
"momx",
|
||||||
"momy",
|
"momy",
|
||||||
"momz",
|
"momz",
|
||||||
|
"pan",
|
||||||
|
"pitch",
|
||||||
"pnum",
|
"pnum",
|
||||||
NULL};
|
NULL};
|
||||||
|
|
||||||
|
|
@ -314,6 +318,12 @@ static int camera_get(lua_State *L)
|
||||||
case camera_momz:
|
case camera_momz:
|
||||||
lua_pushinteger(L, cam->momz);
|
lua_pushinteger(L, cam->momz);
|
||||||
break;
|
break;
|
||||||
|
case camera_pan:
|
||||||
|
lua_pushinteger(L, cam->pan);
|
||||||
|
break;
|
||||||
|
case camera_pitch:
|
||||||
|
lua_pushinteger(L, cam->pitch);
|
||||||
|
break;
|
||||||
case camera_pnum:
|
case camera_pnum:
|
||||||
lua_pushinteger(L, camnum);
|
lua_pushinteger(L, camnum);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,8 @@ typedef struct camera_s
|
||||||
|
|
||||||
// SRB2Kart: camera pans while drifting
|
// SRB2Kart: camera pans while drifting
|
||||||
fixed_t pan;
|
fixed_t pan;
|
||||||
|
// SRB2Kart: camera pitches on slopes
|
||||||
|
angle_t pitch;
|
||||||
} camera_t;
|
} camera_t;
|
||||||
|
|
||||||
extern camera_t camera[MAXSPLITSCREENPLAYERS];
|
extern camera_t camera[MAXSPLITSCREENPLAYERS];
|
||||||
|
|
|
||||||
35
src/p_user.c
35
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};
|
static UINT8 lookbackdelay[4] = {0,0,0,0};
|
||||||
UINT8 num;
|
UINT8 num;
|
||||||
angle_t angle = 0, focusangle = 0, focusaiming = 0;
|
angle_t angle = 0, focusangle = 0, focusaiming = 0, pitch = 0;
|
||||||
fixed_t x, y, z, dist, height, viewpointx, viewpointy, camspeed, camdist, camheight, pviewheight;
|
fixed_t x, y, z, dist, distxy, distz, height, viewpointx, viewpointy, camspeed, camdist, camheight, pviewheight;
|
||||||
fixed_t pan, xpan, ypan;
|
fixed_t pan, xpan, ypan;
|
||||||
INT32 camrotate;
|
INT32 camrotate;
|
||||||
boolean camstill, lookback;
|
boolean camstill, lookback;
|
||||||
|
|
@ -7487,8 +7487,30 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
|
||||||
height -= FixedMul(height, player->karthud[khud_boostcam]);
|
height -= FixedMul(height, player->karthud[khud_boostcam]);
|
||||||
}
|
}
|
||||||
|
|
||||||
x = mo->x - FixedMul(FINECOSINE((angle>>ANGLETOFINESHIFT) & FINEMASK), dist);
|
if (mo->standingslope)
|
||||||
y = mo->y - FixedMul(FINESINE((angle>>ANGLETOFINESHIFT) & FINEMASK), dist);
|
{
|
||||||
|
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)
|
||||||
|
distxy = FixedMul(dist, FINECOSINE((pitch>>ANGLETOFINESHIFT) & FINEMASK));
|
||||||
|
else
|
||||||
|
distxy = dist;
|
||||||
|
distz = -FixedMul(dist, FINESINE((pitch>>ANGLETOFINESHIFT) & FINEMASK));
|
||||||
|
|
||||||
|
x = mo->x - FixedMul(FINECOSINE((angle>>ANGLETOFINESHIFT) & FINEMASK), distxy);
|
||||||
|
y = mo->y - FixedMul(FINESINE((angle>>ANGLETOFINESHIFT) & FINEMASK), distxy);
|
||||||
|
|
||||||
// SRB2Kart: set camera panning
|
// SRB2Kart: set camera panning
|
||||||
if (camstill || resetcalled || player->playerstate == PST_DEAD)
|
if (camstill || resetcalled || player->playerstate == PST_DEAD)
|
||||||
|
|
@ -7519,9 +7541,9 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
|
||||||
pviewheight = FixedMul(32<<FRACBITS, mo->scale);
|
pviewheight = FixedMul(32<<FRACBITS, mo->scale);
|
||||||
|
|
||||||
if (mo->eflags & MFE_VERTICALFLIP)
|
if (mo->eflags & MFE_VERTICALFLIP)
|
||||||
z = mo->z + mo->height - pviewheight - camheight;
|
z = mo->z + mo->height - pviewheight - camheight + distz;
|
||||||
else
|
else
|
||||||
z = mo->z + pviewheight + camheight;
|
z = mo->z + pviewheight + camheight + distz;
|
||||||
|
|
||||||
#ifndef NOCLIPCAM // Disable all z-clipping for noclip cam
|
#ifndef NOCLIPCAM // Disable all z-clipping for noclip cam
|
||||||
// move camera down to move under lower ceilings
|
// move camera down to move under lower ceilings
|
||||||
|
|
@ -7756,6 +7778,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
|
||||||
}
|
}
|
||||||
|
|
||||||
thiscam->pan = pan;
|
thiscam->pan = pan;
|
||||||
|
thiscam->pitch = pitch;
|
||||||
|
|
||||||
// compute aming to look the viewed point
|
// compute aming to look the viewed point
|
||||||
f1 = viewpointx-thiscam->x;
|
f1 = viewpointx-thiscam->x;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue