Merge branch 'campokes' into 'master'

Camera pokes (resolves #359, #363, and #383).

Closes #359, #363, and #383

See merge request STJr/SRB2Internal!566
This commit is contained in:
MascaraSnake 2019-11-28 14:21:18 -05:00
commit 2495e58bdb
3 changed files with 44 additions and 22 deletions

View File

@ -323,6 +323,7 @@ SINT8 P_MobjFlip(mobj_t *mobj);
fixed_t P_GetMobjGravity(mobj_t *mo); fixed_t P_GetMobjGravity(mobj_t *mo);
FUNCMATH boolean P_WeaponOrPanel(mobjtype_t type); FUNCMATH boolean P_WeaponOrPanel(mobjtype_t type);
void P_CalcChasePostImg(player_t *player, camera_t *thiscam);
boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled); boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled);
void P_Attract(mobj_t *source, mobj_t *enemy, boolean nightsgrab); void P_Attract(mobj_t *source, mobj_t *enemy, boolean nightsgrab);

View File

@ -3724,17 +3724,10 @@ void P_DestroyRobots(void)
} }
} }
// P_CameraThinker // the below is chasecam only, if you're curious. check out P_CalcPostImg in p_user.c for first person
// void P_CalcChasePostImg(player_t *player, camera_t *thiscam)
// Process the mobj-ish required functions of the camera
boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled)
{ {
boolean itsatwodlevel = false;
postimg_t postimg = postimg_none; postimg_t postimg = postimg_none;
if (twodlevel
|| (thiscam == &camera && players[displayplayer].mo && (players[displayplayer].mo->flags2 & MF2_TWOD))
|| (thiscam == &camera2 && players[secondarydisplayplayer].mo && (players[secondarydisplayplayer].mo->flags2 & MF2_TWOD)))
itsatwodlevel = true;
if (player->pflags & PF_FLIPCAM && !(player->powers[pw_carry] == CR_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP) if (player->pflags & PF_FLIPCAM && !(player->powers[pw_carry] == CR_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP)
postimg = postimg_flip; postimg = postimg_flip;
@ -3762,13 +3755,27 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled
postimg = postimg_heat; postimg = postimg_heat;
} }
if (postimg != postimg_none) if (postimg == postimg_none)
{ return;
if (splitscreen && player == &players[secondarydisplayplayer])
postimgtype2 = postimg; if (splitscreen && player == &players[secondarydisplayplayer])
else postimgtype2 = postimg;
postimgtype = postimg; else
} postimgtype = postimg;
}
// P_CameraThinker
//
// Process the mobj-ish required functions of the camera
boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled)
{
boolean itsatwodlevel = false;
if (twodlevel
|| (thiscam == &camera && players[displayplayer].mo && (players[displayplayer].mo->flags2 & MF2_TWOD))
|| (thiscam == &camera2 && players[secondarydisplayplayer].mo && (players[secondarydisplayplayer].mo->flags2 & MF2_TWOD)))
itsatwodlevel = true;
P_CalcChasePostImg(player, thiscam);
if (thiscam->momx || thiscam->momy) if (thiscam->momx || thiscam->momy)
{ {

View File

@ -9669,11 +9669,17 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
fixed_t f1, f2; fixed_t f1, f2;
// We probably shouldn't move the camera if there is no player or player mobj somehow // We probably shouldn't move the camera if there is no player or player mobj somehow
if (!player || !player->mo || player->playerstate == PST_REBORN) if (!player || !player->mo)
return true; return true;
mo = player->mo; mo = player->mo;
if (player->playerstate == PST_REBORN)
{
P_CalcChasePostImg(player, thiscam);
return true;
}
if (player->exiting) if (player->exiting)
{ {
if (mo->target && mo->target->type == MT_SIGN && mo->target->spawnpoint if (mo->target && mo->target->type == MT_SIGN && mo->target->spawnpoint
@ -9682,7 +9688,10 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
else if ((player->powers[pw_carry] == CR_NIGHTSMODE) else if ((player->powers[pw_carry] == CR_NIGHTSMODE)
&& !(player->mo->state >= &states[S_PLAY_NIGHTS_TRANS1] && !(player->mo->state >= &states[S_PLAY_NIGHTS_TRANS1]
&& player->mo->state <= &states[S_PLAY_NIGHTS_TRANS6])) && player->mo->state <= &states[S_PLAY_NIGHTS_TRANS6]))
{
P_CalcChasePostImg(player, thiscam);
return true; return true;
}
} }
cameranoclip = (player->powers[pw_carry] == CR_NIGHTSMODE || player->pflags & PF_NOCLIP) || (mo->flags & (MF_NOCLIP|MF_NOCLIPHEIGHT)); // Noclipping player camera noclips too!! cameranoclip = (player->powers[pw_carry] == CR_NIGHTSMODE || player->pflags & PF_NOCLIP) || (mo->flags & (MF_NOCLIP|MF_NOCLIPHEIGHT)); // Noclipping player camera noclips too!!
@ -9763,7 +9772,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
camorbit = (!stricmp(cv_cam_orbit.defaultvalue, "off")) ? false : true; camorbit = (!stricmp(cv_cam_orbit.defaultvalue, "off")) ? false : true;
camrotate = atoi(cv_cam_rotate.defaultvalue); camrotate = atoi(cv_cam_rotate.defaultvalue);
camdist = FixedMul((INT32)(atof(cv_cam_dist.defaultvalue) * FRACUNIT), mo->scale); camdist = FixedMul((INT32)(atof(cv_cam_dist.defaultvalue) * FRACUNIT), mo->scale);
camheight = FixedMul((INT32)(atof(cv_cam_height.defaultvalue) * FRACUNIT), FixedMul(player->camerascale, mo->scale)); camheight = FixedMul((INT32)(atof(cv_cam_height.defaultvalue) * FRACUNIT), mo->scale);
} }
else if (thiscam == &camera) else if (thiscam == &camera)
{ {
@ -9772,7 +9781,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
camorbit = cv_cam_orbit.value; camorbit = cv_cam_orbit.value;
camrotate = cv_cam_rotate.value; camrotate = cv_cam_rotate.value;
camdist = FixedMul(cv_cam_dist.value, mo->scale); camdist = FixedMul(cv_cam_dist.value, mo->scale);
camheight = FixedMul(cv_cam_height.value, FixedMul(player->camerascale, mo->scale)); camheight = FixedMul(cv_cam_height.value, mo->scale);
} }
else // Camera 2 else // Camera 2
{ {
@ -9781,9 +9790,12 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
camorbit = cv_cam2_orbit.value; camorbit = cv_cam2_orbit.value;
camrotate = cv_cam2_rotate.value; camrotate = cv_cam2_rotate.value;
camdist = FixedMul(cv_cam2_dist.value, mo->scale); camdist = FixedMul(cv_cam2_dist.value, mo->scale);
camheight = FixedMul(cv_cam2_height.value, FixedMul(player->camerascale, mo->scale)); camheight = FixedMul(cv_cam2_height.value, mo->scale);
} }
if (!(twodlevel || (mo->flags2 & MF2_TWOD)) && !(player->powers[pw_carry] == CR_NIGHTSMODE))
camheight = FixedMul(camheight, player->camerascale);
#ifdef REDSANALOG #ifdef REDSANALOG
if (P_AnalogMove(player) && (player->cmd.buttons & (BT_CAMLEFT|BT_CAMRIGHT)) == (BT_CAMLEFT|BT_CAMRIGHT)) { if (P_AnalogMove(player) && (player->cmd.buttons & (BT_CAMLEFT|BT_CAMRIGHT)) == (BT_CAMLEFT|BT_CAMRIGHT)) {
camstill = true; camstill = true;
@ -9894,9 +9906,10 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
dist <<= 1; dist <<= 1;
} }
if (!(twodlevel || (mo->flags2 & MF2_TWOD)) && !(player->powers[pw_carry] == CR_NIGHTSMODE))
dist = FixedMul(dist, player->camerascale);
checkdist = dist;
checkdist = (dist = FixedMul(dist, player->camerascale));
if (checkdist < 128*FRACUNIT) if (checkdist < 128*FRACUNIT)
checkdist = 128*FRACUNIT; checkdist = 128*FRACUNIT;
@ -10419,6 +10432,7 @@ boolean P_SpectatorJoinGame(player_t *player)
return false; return false;
} }
// the below is first person only, if you're curious. check out P_CalcChasePostImg in p_mobj.c for chasecam
static void P_CalcPostImg(player_t *player) static void P_CalcPostImg(player_t *player)
{ {
sector_t *sector = player->mo->subsector->sector; sector_t *sector = player->mo->subsector->sector;