diff --git a/src/d_main.c b/src/d_main.c index c10912451..fc3df6dd4 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -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]); } } diff --git a/src/d_player.h b/src/d_player.h index 140a4a748..6ddca1622 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -412,8 +412,6 @@ typedef struct player_s // See pflags_t, above. pflags_t pflags; - UINT16 postimgflags; - // playing animation. panim_t panim; diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index f3778718a..d401f8b67 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -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; diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 5b02b85f3..cb5b0609f 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -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); diff --git a/src/hardware/hw_portal.c b/src/hardware/hw_portal.c index 27d77af2e..9bb5af40f 100644 --- a/src/hardware/hw_portal.c +++ b/src/hardware/hw_portal.c @@ -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); diff --git a/src/p_local.h b/src/p_local.h index 44bdb873a..efb8299c5 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -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]; diff --git a/src/p_mobj.c b/src/p_mobj.c index e1e25a3aa..53391416c 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -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 diff --git a/src/p_user.c b/src/p_user.c index 5e4bde97c..c050b8e82 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -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<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 { diff --git a/src/v_video.c b/src/v_video.c index 5e8bf9f9f..89e2b5241 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -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)<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)<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; diff --git a/src/v_video.h b/src/v_video.h index 1898f438b..36aa9f908 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -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);