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 2025-01-03 18:18:20 +01:00 committed by NepDisk
parent c63d596533
commit 6b1de73341
8 changed files with 165 additions and 149 deletions

View file

@ -367,7 +367,7 @@ static void D_RenderLevel(void)
{
R_ApplyViewMorph(i);
V_DoPostProcessor(i, &players[displayplayers[i]], postimgparam[i]);
V_DoPostProcessor(i, postimgparam[i]);
}
}

View file

@ -505,8 +505,6 @@ struct player_t
// See pflags_t, above.
pflags_t pflags;
UINT16 postimgflags;
// playing animation.
panim_t panim;

View file

@ -5657,6 +5657,8 @@ void HWR_BuildSkyDome(void)
static void HWR_DrawSkyBackground(player_t *player)
{
UINT8 viewnum = R_GetViewNumber();
camera_t *thiscam = &camera[viewnum];
HWD.pfnSetBlend(PF_Translucent|PF_NoDepthTest|PF_Modulated);
if (cv_glskydome.value)
@ -5672,15 +5674,15 @@ static void HWR_DrawSkyBackground(player_t *player)
dometransform.angley = (float)((viewangle-ANGLE_270)>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES);
dometransform.flip = false;
if ((player->postimgflags & POSTIMG_FLIP) && !(player->postimgflags & POSTIMG_MIRROR))
if ((thiscam->postimgflags & POSTIMG_FLIP) && !(thiscam->postimgflags & POSTIMG_MIRROR))
dometransform.flip = true;
dometransform.mirror = false;
if ((player->postimgflags & POSTIMG_MIRROR) && !(player->postimgflags & POSTIMG_FLIP))
if ((thiscam->postimgflags & POSTIMG_MIRROR) && !(thiscam->postimgflags & POSTIMG_FLIP))
dometransform.mirror = true;
dometransform.mirrorflip = false;
if ((player->postimgflags & POSTIMG_FLIP) && (player->postimgflags & POSTIMG_MIRROR))
if ((thiscam->postimgflags & POSTIMG_FLIP) && (thiscam->postimgflags & POSTIMG_MIRROR))
dometransform.mirrorflip = true;
dometransform.scalex = 1;
@ -5926,6 +5928,8 @@ static void HWR_ClearClipper(void)
// ==========================================================================
void HWR_RenderSkyboxView(player_t *player)
{
UINT8 viewnum = R_GetViewNumber();
camera_t *thiscam = &camera[viewnum];
const float fpov = FIXED_TO_FLOAT(cv_fov[viewssnum].value+player->fovadd);
{
@ -5968,15 +5972,15 @@ void HWR_RenderSkyboxView(player_t *player)
gl_viewludcos = FIXED_TO_FLOAT(-FINESINE(gl_aimingangle>>ANGLETOFINESHIFT));
atransform.flip = false;
if ((player->postimgflags & POSTIMG_FLIP) && !(player->postimgflags & POSTIMG_MIRROR))
if ((thiscam->postimgflags & POSTIMG_FLIP) && !(thiscam->postimgflags & POSTIMG_MIRROR))
atransform.flip = true;
atransform.mirror = false;
if ((player->postimgflags & POSTIMG_MIRROR) && !(player->postimgflags & POSTIMG_FLIP))
if ((thiscam->postimgflags & POSTIMG_MIRROR) && !(thiscam->postimgflags & POSTIMG_FLIP))
atransform.mirror = true;
atransform.mirrorflip = false;
if ((player->postimgflags & POSTIMG_FLIP) && (player->postimgflags & POSTIMG_MIRROR))
if ((thiscam->postimgflags & POSTIMG_FLIP) && (thiscam->postimgflags & POSTIMG_MIRROR))
atransform.mirrorflip = true;
atransform.x = gl_viewx; // FIXED_TO_FLOAT(viewx)
@ -6075,6 +6079,8 @@ static void HWR_RollTransform(FTransform *tr, angle_t roll)
void HWR_RenderPlayerView(void)
{
player_t * player = &players[displayplayers[viewssnum]];
UINT8 viewnum = R_GetViewNumber();
camera_t *thiscam = &camera[viewnum];
const float fpov = FIXED_TO_FLOAT(cv_fov[viewssnum].value+player->fovadd);
@ -6153,15 +6159,15 @@ void HWR_RenderPlayerView(void)
gl_viewludcos = FIXED_TO_FLOAT(-FINESINE(gl_aimingangle>>ANGLETOFINESHIFT));
atransform.flip = false;
if ((player->postimgflags & POSTIMG_FLIP) && !(player->postimgflags & POSTIMG_MIRROR))
if ((thiscam->postimgflags & POSTIMG_FLIP) && !(thiscam->postimgflags & POSTIMG_MIRROR))
atransform.flip = true;
atransform.mirror = false;
if ((player->postimgflags & POSTIMG_MIRROR) && !(player->postimgflags & POSTIMG_FLIP))
if ((thiscam->postimgflags & POSTIMG_MIRROR) && !(thiscam->postimgflags & POSTIMG_FLIP))
atransform.mirror = true;
atransform.mirrorflip = false;
if ((player->postimgflags & POSTIMG_FLIP) && (player->postimgflags & POSTIMG_MIRROR))
if ((thiscam->postimgflags & POSTIMG_FLIP) && (thiscam->postimgflags & POSTIMG_MIRROR))
atransform.mirrorflip = true;
atransform.x = gl_viewx; // FIXED_TO_FLOAT(viewx)
@ -6562,8 +6568,12 @@ void HWR_DoPostProcessor(player_t *player)
if (r_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->postimgflags & POSTIMG_WATER || thiscam->postimgflags & POSTIMG_HEAT)
{
// 10 by 10 grid. 2 coordinates (xy)
float v[SCREENVERTS][SCREENVERTS][2];
@ -6575,7 +6585,7 @@ void HWR_DoPostProcessor(player_t *player)
INT32 FREQUENCY;
// Modifies the wave.
if (player->postimgflags & POSTIMG_WATER)
if (thiscam->postimgflags & POSTIMG_WATER)
{
WAVELENGTH = 5;
AMPLITUDE = 40;

View file

@ -131,6 +131,9 @@ struct camera_t
// Interpolation data
fixed_t old_x, old_y, old_z;
angle_t old_angle, old_aiming;
// postproccess effects
UINT16 postimgflags;
};
// demo freecam or something before i commit die

View file

@ -3546,18 +3546,25 @@ void P_DestroyRobots(void)
// 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)
{
boolean flipcam = (player->pflags & PF_FLIPCAM && player->mo->eflags & MFE_VERTICALFLIP);
UINT16 postimgflags = 0;
UINT8 i;
const boolean flipcam = (player->pflags & PF_FLIPCAM && player->mo->eflags & MFE_VERTICALFLIP);
UINT16 postimgtype = 0;
// This can happen when joining
if (thiscam->subsector == NULL || thiscam->subsector->sector == NULL)
return;
if (encoremode)
postimgflags |= POSTIMG_MIRROR;
postimgtype |= POSTIMG_MIRROR;
if (flipcam)
postimgflags |= POSTIMG_FLIP;
postimgtype |= POSTIMG_FLIP;
#ifdef HWRENDER
if (rendermode == render_opengl && splitscreen)
{
thiscam->postimgflags = postimgtype;
return;
}
#endif
if (player->awayviewtics && player->awayviewmobj && !P_MobjWasRemoved(player->awayviewmobj)) // Camera must obviously exist
{
@ -3572,26 +3579,20 @@ 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;
}
thiscam->postimgflags = postimgtype;
}
// P_CameraThinker

View file

@ -2661,6 +2661,9 @@ void P_DemoCameraMovement(camera_t *cam)
boolean moving = false;
if (encoremode)
cam->postimgflags |= POSTIMG_MIRROR;
// first off we need to get button input
G_BuildTiccmd(cmd, 1, UINT8_MAX);
@ -3361,27 +3364,71 @@ boolean P_SpectatorJoinGame(player_t *player)
return true; // no more player->mo, cannot continue.
}
// 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;
size_t i;
mtag_t sectag = Tag_FGet(&sector->tags);
if (player->mo->eflags & MFE_VERTICALFLIP)
pviewheight = player->mo->z + player->mo->height - player->viewheight;
else
pviewheight = player->mo->z + player->viewheight;
if (Tag_FindLineSpecial(13, sectag))
return true;
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->fofflags & FOF_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;
sectag = Tag_FGet(&rover->master->frontsector->tags);
if (Tag_FindLineSpecial(13, sectag))
return true;
}
}
/*for (i = 0; i <= (unsigned)r_splitscreen; i++)
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->fofflags & FOF_EXISTS) || !(rover->fofflags & FOF_SWIMMABLE) || rover->fofflags & FOF_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]])
{
@ -3390,96 +3437,55 @@ static void P_CalcPostImg(player_t *player)
}
}*/
// see if we are in heat (no, not THAT kind of heat...)
for (i = 0; i < sector->tags.count; i++)
if (encoremode) // srb2kart
postimgtype |= POSTIMG_MIRROR;
if (player->mo->eflags & MFE_VERTICALFLIP)
postimgtype |= POSTIMG_FLIP;
#ifdef HWRENDER
if (rendermode == render_opengl && splitscreen)
{
if (Tag_FindLineSpecial(13, sector->tags.tags[i]) != -1)
thiscam->postimgflags = postimgtype;
return;
}
#endif
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))
{
typeflag |= POSTIMG_HEAT;
break;
}
else if (sector->ffloors)
{
ffloor_t *rover;
fixed_t topheight;
fixed_t bottomheight;
boolean gotres = false;
for (rover = sector->ffloors; rover; rover = rover->next)
{
size_t j;
if (!(rover->fofflags & FOF_EXISTS))
continue;
topheight = P_GetFFloorTopZAt (rover, player->mo->x, player->mo->y);
bottomheight = P_GetFFloorBottomZAt(rover, player->mo->x, player->mo->y);
if (pviewheight >= topheight || pviewheight <= bottomheight)
continue;
for (j = 0; j < rover->master->frontsector->tags.count; j++)
{
if (Tag_FindLineSpecial(13, rover->master->frontsector->tags.tags[j]) != -1)
{
typeflag |= POSTIMG_HEAT;
gotres = true;
break;
}
}
}
if (gotres)
break;
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->fofflags & FOF_EXISTS) || !(rover->fofflags & FOF_SWIMMABLE) || rover->fofflags & FOF_BLOCKPLAYER)
continue;
topheight = P_GetFFloorTopZAt (rover, player->mo->x, player->mo->y);
bottomheight = P_GetFFloorBottomZAt(rover, player->mo->x, player->mo->y);
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 <= (unsigned)r_splitscreen; i++)
{
if (player != &players[displayplayers[i]])
continue;
players[displayplayers[i]].postimgflags = typeflag;
break;
}
thiscam->postimgflags = postimgtype;
}
void P_DoTimeOver(player_t *player)
@ -4262,7 +4268,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
{

View file

@ -2840,7 +2840,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
@ -2859,6 +2859,11 @@ void V_DoPostProcessor(INT32 view, player_t *player, INT32 param)
if (view < 0 || view > 3 || view > r_splitscreen)
return;
camera_t *thiscam = &camera[view];
if (!thiscam->postimgflags)
return;
if ((view == 1 && r_splitscreen == 1) || view >= 2)
yoffset = viewheight;
else
@ -2872,10 +2877,7 @@ void V_DoPostProcessor(INT32 view, player_t *player, INT32 param)
UINT8 *tmpscr = screens[4];
UINT8 *srcscr = screens[0];
if (!player->postimgflags)
return;
if (player->postimgflags & POSTIMG_WATER)
if (thiscam->postimgflags & POSTIMG_WATER)
{
INT32 y;
// Set disStart to a range from 0 to FINEANGLE, incrementing by 128 per tic
@ -2933,25 +2935,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->postimgflags & POSTIMG_HEAT) // Heat wave
{
INT32 y;
@ -2998,7 +2982,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->postimgflags & POSTIMG_FLIP) && !(thiscam->postimgflags & POSTIMG_MIRROR)) // Flip the screen upside-down
{
INT32 y, y2;
@ -3009,7 +3007,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->postimgflags & POSTIMG_MIRROR) && !(thiscam->postimgflags & POSTIMG_FLIP)) // Flip the screen on the x axis
{
INT32 y, x, x2;
@ -3021,7 +3019,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->postimgflags & POSTIMG_MIRROR) && (thiscam->postimgflags & POSTIMG_FLIP)) // Flip the screen upside-down and on the x axis
{
INT32 y, x;

View file

@ -337,7 +337,7 @@ INT32 V_ThinStringWidth(const char *string, INT32 option);
// Find string width from tny_font chars, 0.5x scale
INT32 V_SmallThinStringWidth(const char *string, INT32 option);
void V_DoPostProcessor(INT32 view, player_t *player, INT32 param);
void V_DoPostProcessor(INT32 view, INT32 param);
void V_DrawPatchFill(patch_t *pat);