From f30d472ad2e9b5ec1a0b24a0cafb39481e494ae3 Mon Sep 17 00:00:00 2001 From: Alug Date: Fri, 27 Jun 2025 12:29:56 +0200 Subject: [PATCH] dont render precip in skyboxes! is really ugly and was never intended, and half the time this would make splashes appear through walls and crap lol --- src/r_main.cpp | 15 ++++++++------- src/r_portal.c | 23 +++++++++++++---------- src/r_portal.h | 29 +++++++++++++++-------------- 3 files changed, 36 insertions(+), 31 deletions(-) diff --git a/src/r_main.cpp b/src/r_main.cpp index b8365cf24..5a4a54e72 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -1502,14 +1502,17 @@ static void Mask_Post (maskcount_t* m) // ================ // viewx, viewy, viewangle, all that good stuff must be set -static void R_RenderViewpoint(maskcount_t* mask, INT32 cachenum) +static void R_RenderViewpoint(maskcount_t* mask, INT32 cachenum, boolean drawprecip) { Mask_Pre(mask); curdrawsegs = ds_p; R_RenderFirstBSPNode(cachenum); - R_AddPrecipitationSprites(); + + // dont draw precip in skyboxes! + if (drawprecip) + R_AddPrecipitationSprites(); Mask_Post(mask); } @@ -1539,7 +1542,7 @@ void R_RenderPlayerView(void) R_ClearSegTables(); R_ClearPlanes(); R_ClearSprites(); - R_RenderViewpoint(&masks[nummasks - 1], nummasks - 1); + R_RenderViewpoint(&masks[nummasks - 1], nummasks - 1, false); R_ClipSprites(drawsegs, NULL); R_DrawSkyPlanes(); R_DrawPlanes(); @@ -1577,7 +1580,7 @@ void R_RenderPlayerView(void) // The head node is the last node output. ps_numbspcalls = ps_numpolyobjects = ps_numdrawnodes = 0; ps_bsptime = I_GetPreciseTime(); - R_RenderViewpoint(&masks[nummasks - 1], nummasks - 1); + R_RenderViewpoint(&masks[nummasks - 1], nummasks - 1, true); ps_bsptime = I_GetPreciseTime() - ps_bsptime; ps_sw_spritecliptime = I_GetPreciseTime(); @@ -1623,9 +1626,7 @@ void R_RenderPlayerView(void) // Render the BSP from the new viewpoint, and clip // any sprites with the new clipsegs and window. - R_RenderViewpoint(&masks[nummasks - 1], nummasks - 1); - - //portalskipprecipmobjs = false; + R_RenderViewpoint(&masks[nummasks - 1], nummasks - 1, !portal->isskybox); R_ClipSprites(ds_p - (masks[nummasks - 1].drawsegs[1] - masks[nummasks - 1].drawsegs[0]), portal); diff --git a/src/r_portal.c b/src/r_portal.c index edab00a32..35cdea232 100644 --- a/src/r_portal.c +++ b/src/r_portal.c @@ -31,7 +31,7 @@ INT32 portalclipstart, portalclipend; portal_t *g_portal; // is curline a portal seg? -void Portal_InitList (void) +void Portal_InitList(void) { portalrender = 0; portal_base = portal_cap = NULL; @@ -43,7 +43,7 @@ void Portal_InitList (void) * the function is called, so it is useful for converting one-sided * lines into portals. */ -void Portal_ClipRange (portal_t* portal) +void Portal_ClipRange(portal_t* portal) { INT32 i; INT32 start = portal->start; @@ -65,7 +65,7 @@ void Portal_ClipRange (portal_t* portal) /** Apply the clipping window from a portal. */ -void Portal_ClipApply (const portal_t* portal) +void Portal_ClipApply(const portal_t* portal) { INT32 i; INT32 start = portal->start; @@ -97,7 +97,7 @@ void Portal_ClipApply (const portal_t* portal) } } -static portal_t* Portal_Add (const INT16 x1, const INT16 x2) +static portal_t* Portal_Add(const INT16 x1, const INT16 x2) { portal_t *portal = Z_Malloc(sizeof(portal_t), PU_LEVEL, NULL); INT16 *ceilingclipsave = Z_Malloc(sizeof(INT16)*(x2-x1 + 1), PU_LEVEL, NULL); @@ -127,10 +127,12 @@ static portal_t* Portal_Add (const INT16 x1, const INT16 x2) // Increase recursion level. portal->pass = portalrender+1; + portal->isskybox = false; + return portal; } -void Portal_Remove (portal_t* portal) +void Portal_Remove(portal_t* portal) { portalcullsector = NULL; portal_base = portal->next; @@ -150,7 +152,7 @@ void Portal_Remove (portal_t* portal) * When the portal renders, it will create the illusion of * the two lines being seamed together. */ -void Portal_Add2Lines (const INT32 line1, const INT32 line2, const INT32 x1, const INT32 x2) +void Portal_Add2Lines(const INT32 line1, const INT32 line2, const INT32 x1, const INT32 x2) { portal_t* portal = Portal_Add(x1, x2); @@ -206,7 +208,7 @@ void Portal_Add2Lines (const INT32 line1, const INT32 line2, const INT32 x1, con * Since visplanes top/bottom windows work in an identical way, * it can just be copied almost directly. */ -static void Portal_ClipVisplane (const visplane_t* plane, portal_t* portal) +static void Portal_ClipVisplane(const visplane_t* plane, portal_t* portal) { INT32 i; INT16 start = portal->start; @@ -230,7 +232,7 @@ static void Portal_ClipVisplane (const visplane_t* plane, portal_t* portal) extern INT32 viewwidth; -static boolean TrimVisplaneBounds (const visplane_t* plane, INT16* start, INT16* end) +static boolean TrimVisplaneBounds(const visplane_t* plane, INT16* start, INT16* end) { *start = plane->minx; *end = plane->maxx + 1; @@ -268,7 +270,7 @@ static boolean TrimVisplaneBounds (const visplane_t* plane, INT16* start, INT16* * Applies the necessary offsets and rotation to give * a depth illusion to the skybox. */ -void Portal_AddSkybox (const visplane_t* plane) +void Portal_AddSkybox(const visplane_t* plane) { INT16 start, end; mapheader_t *mh; @@ -315,12 +317,13 @@ void Portal_AddSkybox (const visplane_t* plane) portal->viewz += viewz * -mh->skybox_scalez; portal->clipline = -1; + portal->isskybox = true; } /** Creates portals for the currently existing sky visplanes. * The visplanes are also removed and cleared from the list. */ -void Portal_AddSkyboxPortals (void) +void Portal_AddSkyboxPortals(void) { visplane_t *pl; INT32 i; diff --git a/src/r_portal.h b/src/r_portal.h index 05fe3d977..cca02e034 100644 --- a/src/r_portal.h +++ b/src/r_portal.h @@ -34,15 +34,16 @@ struct portal_t fixed_t viewz; angle_t viewangle; - UINT8 pass; /**< Keeps track of the portal's recursion depth. */ - INT32 clipline; /**< Optional clipline for line-based portals. */ + UINT8 pass; /**< Keeps track of the portal's recursion depth. */ + INT32 clipline; /**< Optional clipline for line-based portals. */ + boolean isskybox; // Clipping information. - INT32 start; /**< First horizontal pixel coordinate to draw at. */ - INT32 end; /**< Last horizontal pixel coordinate to draw at. */ - INT16 *ceilingclip; /**< Temporary screen top clipping array. */ - INT16 *floorclip; /**< Temporary screen bottom clipping array. */ - fixed_t *frontscale;/**< Temporary screen bottom clipping array. */ + INT32 start; /**< First horizontal pixel coordinate to draw at. */ + INT32 end; /**< Last horizontal pixel coordinate to draw at. */ + INT16 *ceilingclip; /**< Temporary screen top clipping array. */ + INT16 *floorclip; /**< Temporary screen bottom clipping array. */ + fixed_t *frontscale; /**< Temporary screen bottom clipping array. */ }; extern portal_t* portal_base; @@ -53,15 +54,15 @@ extern line_t *portalclipline; extern sector_t *portalcullsector; extern INT32 portalclipstart, portalclipend; -void Portal_InitList (void); -void Portal_Remove (portal_t* portal); -void Portal_Add2Lines (const INT32 line1, const INT32 line2, const INT32 x1, const INT32 x2); -void Portal_AddSkybox (const visplane_t* plane); +void Portal_InitList(void); +void Portal_Remove(portal_t* portal); +void Portal_Add2Lines(const INT32 line1, const INT32 line2, const INT32 x1, const INT32 x2); +void Portal_AddSkybox(const visplane_t* plane); -void Portal_ClipRange (portal_t* portal); -void Portal_ClipApply (const portal_t* portal); +void Portal_ClipRange(portal_t* portal); +void Portal_ClipApply(const portal_t* portal); -void Portal_AddSkyboxPortals (void); +void Portal_AddSkyboxPortals(void); #ifdef __cplusplus } // extern "C"