move postimg flags to camera struct

- also dont let water and heat be applied on top of each other since it does not look good (water postimg takes priority over heat)
- also save a little time in opengl splitscreen since it does not support heat or wöter effects
This commit is contained in:
Alug committed 2025-01-03 18:18:20 +01:00
1 parent a77aa11e36
commit ea484e4aec
10 files changed
+151 -126

No files matched your search

+1 -1
View File
@@ -559,7 +559,7 @@ static boolean D_Display(void)
for (i = 0; i <= splitscreen; i++)
{
V_DoPostProcessor(i, &players[displayplayers[i]], postimgparam[i]);
V_DoPostProcessor(i, postimgparam[i]);
}
}
-2
View File
@@ -412,8 +412,6 @@ typedef struct player_s
// See pflags_t, above.
pflags_t pflags;
UINT16 postimgflags;
// playing animation.
panim_t panim;
+15 -8
View File
@@ -5217,8 +5217,11 @@ static void HWR_SetTransformAiming(FTransform *trans)
trans->anglex = (float)(gl_aimingangle>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES);
}
void HWR_SetTransform(float fpov, player_t *player)
void HWR_SetTransform(float fpov)
{
UINT8 viewnum = R_GetViewNumber();
camera_t *thiscam = &camera[viewnum];
gl_viewx = FIXED_TO_FLOAT(viewx);
gl_viewy = FIXED_TO_FLOAT(viewy);
gl_viewz = FIXED_TO_FLOAT(viewz);
@@ -5248,15 +5251,15 @@ void HWR_SetTransform(float fpov, player_t *player)
atransform.splitscreen = splitscreen;
atransform.flip = false;
if ((player->postimgflags & POSTIMG_FLIP) && !(player->postimgflags & POSTIMG_MIRROR))
if ((thiscam->postimg & POSTIMG_FLIP) && !(thiscam->postimg & POSTIMG_MIRROR))
atransform.flip = true;
atransform.mirror = false;
if ((player->postimgflags & POSTIMG_MIRROR) && !(player->postimgflags & POSTIMG_FLIP))
if ((thiscam->postimg & POSTIMG_MIRROR) && !(thiscam->postimg & POSTIMG_FLIP))
atransform.mirror = true;
atransform.mirrorflip = false;
if ((player->postimgflags & POSTIMG_FLIP) && (player->postimgflags & POSTIMG_MIRROR))
if ((thiscam->postimg & POSTIMG_FLIP) && (thiscam->postimg & POSTIMG_MIRROR))
atransform.mirrorflip = true;
// Set transform.
@@ -5323,7 +5326,7 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl
// draw normal things in current frame in current incremented stencil buffer area
HWR_SetStencilState(HWR_STENCIL_NORMAL, stencil_level);
HWR_SetTransform(fpov, player);
HWR_SetTransform(fpov);
HWR_ClearSprites();
HWR_ClearClipper();
@@ -5380,7 +5383,7 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl
HWR_DrawSkyBackground();
HWR_SetStencilState(HWR_STENCIL_NORMAL, 0);
GL_ClearBuffer(false, false, true, 0);// clear skywall markings from the stencil buffer
HWR_SetTransform(fpov, player);// restore transform
HWR_SetTransform(fpov);// restore transform
}
gl_collect_skywalls = false;
@@ -5837,8 +5840,12 @@ static void HWR_DoPostProcessor(player_t *player)
if (splitscreen) // Not supported in splitscreen - someone want to add support?
return;
//UINT8 viewnum = R_GetViewNumber(); // see above
//camera_t *thiscam = &camera[viewnum];
camera_t *thiscam = &camera[0];
// Drunken vision! WooOOooo~
if (player->postimgflags & POSTIMG_WATER || player->postimgflags & POSTIMG_HEAT)
if (thiscam->postimg & POSTIMG_WATER || thiscam->postimg & POSTIMG_HEAT)
{
// 10 by 10 grid. 2 coordinates (xy)
float v[SCREENVERTS][SCREENVERTS][2];
@@ -5850,7 +5857,7 @@ static void HWR_DoPostProcessor(player_t *player)
INT32 FREQUENCY;
// Modifies the wave.
if (player->postimgflags & POSTIMG_WATER)
if (thiscam->postimg & POSTIMG_WATER)
{
WAVELENGTH = 5;
AMPLITUDE = 20;
+1 -1
View File
@@ -113,7 +113,7 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl
void HWR_ClearSkyDome(void);
void HWR_BuildSkyDome(void);
void HWR_SetTransform(float fpov, player_t *player);
void HWR_SetTransform(float fpov);
void HWR_ClearClipper(void);
void HWR_SetStencilState(int state, int level);
+2 -2
View File
@@ -160,7 +160,7 @@ static void HWR_RenderPortalSeg(gl_portal_t* portal, SINT8 state)
void HWR_RenderPortal(gl_portal_t* portal, gl_portal_t* rootportal, const float fpov, player_t *player, int stencil_level)
{
// draw portal seg to stencil buffer with increment
HWR_SetTransform(fpov, player);
HWR_SetTransform(fpov);
HWR_ClearClipper();
HWR_SetStencilState(HWR_STENCIL_BEGIN, stencil_level);
@@ -180,7 +180,7 @@ void HWR_RenderPortal(gl_portal_t* portal, gl_portal_t* rootportal, const float
}
// remove portal seg from stencil buffer
HWR_SetTransform(fpov, player);
HWR_SetTransform(fpov);
HWR_ClearClipper();
HWR_SetStencilState(HWR_STENCIL_REVERSE, stencil_level);
+3
View File
@@ -123,6 +123,9 @@ typedef struct camera_s
// SRB2Kart: camera pans while drifting
fixed_t pan;
// postproccess effects
UINT16 postimg;
} camera_t;
extern camera_t camera[MAXSPLITSCREENPLAYERS];
+18 -18
View File
@@ -3317,13 +3317,20 @@ void P_DestroyRobots(void)
static void P_CalcChasePostImg(player_t *player, camera_t *thiscam)
{
const boolean flipcam = (player->pflags & PF_FLIPCAM && !(player->pflags & PF_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP);
UINT16 postimgflags = 0;
UINT8 i;
UINT16 postimgtype = 0;
if (encoremode)
postimgflags |= POSTIMG_MIRROR;
postimgtype |= POSTIMG_MIRROR;
if (flipcam)
postimgflags |= POSTIMG_FLIP;
postimgtype |= POSTIMG_FLIP;
#ifdef HWRENDER
if (rendermode == render_opengl && splitscreen)
{
thiscam->postimg = postimgtype;
return;
}
#endif
if (player->awayviewtics && player->awayviewmobj && !P_MobjWasRemoved(player->awayviewmobj)) // Camera must obviously exist
{
@@ -3338,27 +3345,20 @@ static void P_CalcChasePostImg(player_t *player, camera_t *thiscam)
// Are we in water?
if (P_CameraCheckWater(&dummycam))
postimgflags |= POSTIMG_WATER;
if (P_CameraCheckHeat(&dummycam))
postimgflags |= POSTIMG_HEAT;
postimgtype |= POSTIMG_WATER;
else if (P_CameraCheckHeat(&dummycam))
postimgtype |= POSTIMG_HEAT;
}
else
{
// Are we in water?
if (P_CameraCheckWater(thiscam))
postimgflags |= POSTIMG_WATER;
if (P_CameraCheckHeat(thiscam))
postimgflags |= POSTIMG_HEAT;
postimgtype |= POSTIMG_WATER;
else if (P_CameraCheckHeat(thiscam))
postimgtype |= POSTIMG_HEAT;
}
for (i = 0; i <= splitscreen; i++)
{
if (player != &players[displayplayers[i]])
continue;
players[displayplayers[i]].postimgflags = postimgflags;
break;
}
thiscam->postimg = postimgtype;
}
// P_CameraThinker
+87 -71
View File
@@ -3317,7 +3317,7 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num)
boolean moving = false;
if (encoremode)
players[displayplayers[num]].postimgflags |= POSTIMG_MIRROR;
cam->postimg |= POSTIMG_MIRROR;
cam->localangle = cam->angle;
cam->localaiming = cam->aiming;
@@ -4149,26 +4149,66 @@ boolean P_SpectatorJoinGame(player_t *player)
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 boolean P_CameraCheckHeatFirstperson(player_t *player, sector_t *sector, fixed_t pviewheight)
{
sector_t *sector = player->mo->subsector->sector;
INT16 typeflag = 0;
//INT32 *param;
fixed_t pviewheight;
UINT8 i;
if (P_FindSpecialLineFromTag(13, sector->tag, -1) != -1)
return true;
if (player->mo->eflags & MFE_VERTICALFLIP)
pviewheight = player->mo->z + player->mo->height - player->viewheight;
else
pviewheight = player->mo->z + player->viewheight;
if (player->awayviewtics && player->awayviewmobj && !P_MobjWasRemoved(player->awayviewmobj))
if (sector->ffloors)
{
sector = player->awayviewmobj->subsector->sector;
pviewheight = player->awayviewmobj->z + 20*FRACUNIT;
ffloor_t *rover;
for (rover = sector->ffloors; rover; rover = rover->next)
{
if (!(rover->flags & FF_EXISTS))
continue;
if (pviewheight >= P_GetFFloorTopZAt(rover, player->mo->x, player->mo->y))
continue;
if (pviewheight <= P_GetFFloorBottomZAt(rover, player->mo->x, player->mo->y))
continue;
if (P_FindSpecialLineFromTag(13, rover->master->frontsector->tag, -1) != -1)
return true;
}
}
return false;
}
static boolean P_CameraCheckWaterFirstperson(player_t *player, sector_t *sector, fixed_t pviewheight)
{
if (sector->ffloors)
{
ffloor_t *rover;
for (rover = sector->ffloors; rover; rover = rover->next)
{
if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_SWIMMABLE) || rover->flags & FF_BLOCKPLAYER)
continue;
if (pviewheight >= P_GetFFloorTopZAt(rover, player->mo->x, player->mo->y))
continue;
if (pviewheight <= P_GetFFloorBottomZAt(rover, player->mo->x, player->mo->y))
continue;
return true;
}
}
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, camera_t *thiscam)
{
sector_t *sector = NULL;
INT16 postimgtype = 0;
//INT32 *param;
fixed_t pviewheight = 0;
/*for (i = 0; i <= splitscreen; i++)
{
if (player == &players[displayplayers[i]])
@@ -4178,79 +4218,55 @@ static void P_CalcPostImg(player_t *player)
}
}*/
// see if we are in heat (no, not THAT kind of heat...)
if (encoremode) // srb2kart
postimgtype |= POSTIMG_MIRROR;
if (P_FindSpecialLineFromTag(13, sector->tag, -1) != -1)
typeflag |= POSTIMG_HEAT;
else if (sector->ffloors)
if (player->mo->eflags & MFE_VERTICALFLIP)
postimgtype |= POSTIMG_FLIP;
#ifdef HWRENDER
if (rendermode == render_opengl && splitscreen)
{
ffloor_t *rover;
fixed_t topheight;
fixed_t bottomheight;
thiscam->postimg = postimgtype;
return;
}
#endif
for (rover = sector->ffloors; rover; rover = rover->next)
sector = player->mo->subsector->sector;
if (sector->ffloors)
{
if (player->mo->eflags & MFE_VERTICALFLIP)
pviewheight = player->mo->z + player->mo->height - player->viewheight;
else
pviewheight = player->mo->z + player->viewheight;
if (player->awayviewtics && player->awayviewmobj && !P_MobjWasRemoved(player->awayviewmobj))
{
if (!(rover->flags & FF_EXISTS))
continue;
topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y) : *rover->topheight;
bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight;
if (pviewheight >= topheight || pviewheight <= bottomheight)
continue;
if (P_FindSpecialLineFromTag(13, rover->master->frontsector->tag, -1) != -1)
typeflag |= POSTIMG_HEAT;
sector = player->awayviewmobj->subsector->sector;
pviewheight = player->awayviewmobj->z + 20*FRACUNIT;
}
}
// see if we are in water (water trumps heat)
if (sector->ffloors)
{
ffloor_t *rover;
fixed_t topheight;
fixed_t bottomheight;
for (rover = sector->ffloors; rover; rover = rover->next)
{
if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_SWIMMABLE) || rover->flags & FF_BLOCKPLAYER)
continue;
topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y) : *rover->topheight;
bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight;
if (pviewheight >= topheight || pviewheight <= bottomheight)
continue;
typeflag |= POSTIMG_WATER;
}
}
if (encoremode) // srb2kart
typeflag |= POSTIMG_MIRROR;
if (player->mo->eflags & MFE_VERTICALFLIP)
typeflag |= POSTIMG_FLIP;
if (P_CameraCheckWaterFirstperson(player, sector, pviewheight))
postimgtype |= POSTIMG_WATER;
// see if we are in heat (no, not THAT kind of heat...)
else if (P_CameraCheckHeatFirstperson(player, sector, pviewheight))
postimgtype |= POSTIMG_HEAT;
// Motion blur
// unused
/*if (player->speed > (35<<FRACBITS))
{
typeflag |= POSTIMG_MOTION;
postimgtype |= POSTIMG_MOTION;
*param = (player->speed - 32)/4;
if (*param > 5)
*param = 5;
}*/
for (i = 0; i <= splitscreen; i++)
{
if (player != &players[displayplayers[i]])
continue;
players[displayplayers[i]].postimgflags = typeflag;
break;
}
thiscam->postimg = postimgtype;
}
void P_DoTimeOver(player_t *player)
@@ -5033,7 +5049,7 @@ void P_PlayerAfterThink(player_t *player)
if (!thiscam->chase) // bob view only if looking through the player's eyes
{
P_CalcHeight(player);
P_CalcPostImg(player);
P_CalcPostImg(player, thiscam);
}
else
{
+23 -22
View File
@@ -3305,7 +3305,7 @@ INT32 heatindex[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0};
// Perform a particular image postprocessing function.
//
void V_DoPostProcessor(INT32 view, player_t *player, INT32 param)
void V_DoPostProcessor(INT32 view, INT32 param)
{
#if NUMSCREENS < 5
// do not enable image post processing for ARM, SH and MIPS CPUs
@@ -3324,7 +3324,9 @@ void V_DoPostProcessor(INT32 view, player_t *player, INT32 param)
if (view < 0 || view > 3 || view > splitscreen)
return;
if (!player->postimgflags)
camera_t *thiscam = &camera[view];
if (!thiscam->postimg)
return;
if ((view == 1 && splitscreen == 1) || view >= 2)
@@ -3340,7 +3342,7 @@ void V_DoPostProcessor(INT32 view, player_t *player, INT32 param)
UINT8 *tmpscr = screens[4];
UINT8 *srcscr = screens[0];
if (player->postimgflags & POSTIMG_WATER)
if (thiscam->postimg & POSTIMG_WATER)
{
INT32 y;
// Set disStart to a range from 0 to FINEANGLE, incrementing by 128 per tic
@@ -3399,22 +3401,7 @@ void V_DoPostProcessor(INT32 view, player_t *player, INT32 param)
tmpscr = srcscr;
srcscr = tmp;
}
/*if (player->postimgflags & POSTIMG_MOTION) // Motion Blur!
{
INT32 x, y;
// TODO: Add a postimg_param so that we can pick the translucency level...
UINT8 *transme = transtables + ((param-1)<<FF_TRANSSHIFT);
for (y = yoffset; y < yoffset+viewheight; y++)
{
for (x = xoffset; x < xoffset+viewwidth; x++)
tmpscr[y*vid.width + x] = colormaps[*(transme + (srcscr [(y*vid.width)+x ] <<8) + (tmpscr[(y*vid.width)+x]))];
}
}*/
if (player->postimgflags & POSTIMG_HEAT) // Heat wave
else if (thiscam->postimg & POSTIMG_HEAT) // Heat wave
{
INT32 y;
@@ -3461,7 +3448,21 @@ void V_DoPostProcessor(INT32 view, player_t *player, INT32 param)
srcscr = tmp;
}
if ((player->postimgflags & POSTIMG_FLIP) && !(player->postimgflags & POSTIMG_MIRROR)) // Flip the screen upside-down
/*if (thiscam->postimg & POSTIMG_MOTION) // Motion Blur!
{
INT32 x, y;
// TODO: Add a postimg_param so that we can pick the translucency level...
UINT8 *transme = transtables + ((param-1)<<FF_TRANSSHIFT);
for (y = yoffset; y < yoffset+viewheight; y++)
{
for (x = xoffset; x < xoffset+viewwidth; x++)
tmpscr[y*vid.width + x] = colormaps[*(transme + (srcscr [(y*vid.width)+x ] <<8) + (tmpscr[(y*vid.width)+x]))];
}
}*/
if ((thiscam->postimg & POSTIMG_FLIP) && !(thiscam->postimg & POSTIMG_MIRROR)) // Flip the screen upside-down
{
INT32 y, y2;
@@ -3472,7 +3473,7 @@ void V_DoPostProcessor(INT32 view, player_t *player, INT32 param)
tmpscr = srcscr;
srcscr = tmp;
}
else if ((player->postimgflags & POSTIMG_MIRROR) && !(player->postimgflags & POSTIMG_FLIP)) // Flip the screen on the x axis
else if ((thiscam->postimg & POSTIMG_MIRROR) && !(thiscam->postimg & POSTIMG_FLIP)) // Flip the screen on the x axis
{
INT32 y, x, x2;
@@ -3484,7 +3485,7 @@ void V_DoPostProcessor(INT32 view, player_t *player, INT32 param)
tmpscr = srcscr;
srcscr = tmp;
}
else if ((player->postimgflags & POSTIMG_MIRROR) && (player->postimgflags & POSTIMG_FLIP)) // Flip the screen upside-down and on the x axis
else if ((thiscam->postimg & POSTIMG_MIRROR) && (thiscam->postimg & POSTIMG_FLIP)) // Flip the screen upside-down and on the x axis
{
INT32 y, x;
+1 -1
View File
@@ -258,7 +258,7 @@ INT32 V_SkinColorToHighlightcolor(skincolors_t color);
typedef struct player_s player_t;
void V_DoPostProcessor(INT32 view, player_t *player, INT32 param);
void V_DoPostProcessor(INT32 view, INT32 param);
void V_DrawPatchFill(patch_t *pat);