diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 290273a24..8f1fde3d8 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -48,6 +48,7 @@ #include "../m_cheat.h" #include "../m_argv.h" // parm functions for msaa #include "../p_slopes.h" +#include "../r_portal.h" #define ABS(x) ((x) < 0 ? -(x) : (x)) diff --git a/src/r_bsp.h b/src/r_bsp.h index 97d48bdfd..f93541d7b 100644 --- a/src/r_bsp.h +++ b/src/r_bsp.h @@ -25,7 +25,8 @@ extern side_t *sidedef; extern line_t *linedef; extern sector_t *frontsector; extern sector_t *backsector; -extern portal_pair *g_portal; // is curline a portal seg? +typedef struct portal_s portal_t; +extern portal_t *g_portal; // is curline a portal seg? // drawsegs are allocated on the fly... see r_segs.c diff --git a/src/r_main.c b/src/r_main.c index 7da1ab33f..1cef37b08 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1481,8 +1481,8 @@ static void R_PortalFrame(portal_t *portal) viewz = portal->viewz; viewangle = portal->viewangle; - // newview->sin = FINESINE(newview->angle>>ANGLETOFINESHIFT); - // newview->cos = FINECOSINE(newview->angle>>ANGLETOFINESHIFT); + // viewsin = FINESINE(viewangle>>ANGLETOFINESHIFT); + // viewcos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); portalclipstart = portal->start; portalclipend = portal->end; @@ -1490,12 +1490,14 @@ static void R_PortalFrame(portal_t *portal) if (portal->clipline != -1) { portalclipline = &lines[portal->clipline]; - viewsector = portalcullsector = portalclipline->frontsector; + portalcullsector = portalclipline->frontsector; + viewsector = portalclipline->frontsector; } else { portalclipline = NULL; - viewsector = portalcullsector = R_PointInSubsector(viewx, viewy)->sector; + portalcullsector = NULL; + viewsector = R_PointInSubsector(viewx, viewy)->sector; } } @@ -1511,7 +1513,6 @@ static void R_PortalFrame(portal_t *portal) void R_RenderPlayerView(player_t *player) { - portal_t *portal; const boolean skybox = (skyboxmo[0] && cv_skybox.value); UINT8 i; @@ -1617,10 +1618,14 @@ void R_RenderPlayerView(player_t *player) // Portal rendering. Hijacks the BSP traversal. if (portal_base) { - for(portal = portal_base; portal; portal = portal_base) + portal_t *portal; + + for (portal = portal_base; portal; portal = portal_base) { portalrender = portal->pass; // Recursiveness depth. + R_ClearFFloorClips(); + // Apply the viewpoint stored for the portal. R_PortalFrame(portal); @@ -1642,8 +1647,6 @@ void R_RenderPlayerView(player_t *player) validcount++; } - - portalcullsector = NULL; // Just in case... } PS_STOP_TIMING(ps_sw_portaltime); diff --git a/src/r_plane.c b/src/r_plane.c index 275fd5fd9..d8d77457f 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -28,6 +28,7 @@ #include "z_zone.h" #include "p_tick.h" #include "r_fps.h" +#include "r_portal.h" // // opening @@ -39,12 +40,6 @@ // good night sweet prince //#define SHITPLANESPARENCY -//SoM: 3/23/2000: Use Boom visplane hashing. -#define VISPLANEHASHBITS 9 -#define VISPLANEHASHMASK ((1<start; INT32 end = portal->end; @@ -59,6 +63,7 @@ void Portal_ClipStoreFromRange (portal_t* portal) } } + /** Apply the clipping window from a portal. */ void Portal_ClipApply (const portal_t* portal) @@ -93,12 +98,12 @@ void Portal_ClipApply (const portal_t* portal) } } -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), PU_LEVEL, NULL); - INT16 *floorclipsave = Z_Malloc(sizeof(INT16)*(x2-x1), PU_LEVEL, NULL); - fixed_t *frontscalesave = Z_Malloc(sizeof(fixed_t)*(x2-x1), PU_LEVEL, NULL); + INT16 *ceilingclipsave = Z_Malloc(sizeof(INT16)*(x2-x1 + 1), PU_LEVEL, NULL); + INT16 *floorclipsave = Z_Malloc(sizeof(INT16)*(x2-x1 + 1), PU_LEVEL, NULL); + fixed_t *frontscalesave = Z_Malloc(sizeof(fixed_t)*(x2-x1 + 1), PU_LEVEL, NULL); // Linked list. if (!portal_base) @@ -128,6 +133,7 @@ portal_t* Portal_Add (const INT16 x1, const INT16 x2) void Portal_Remove (portal_t* portal) { + portalcullsector = NULL; portal_base = portal->next; Z_Free(portal->ceilingclip); Z_Free(portal->floorclip); @@ -179,9 +185,9 @@ void Portal_Add2Lines (const INT32 line1, const INT32 line2, const INT32 x1, con portal->clipline = line2; - Portal_ClipStoreFromRange(portal); + Portal_ClipRange(portal); - portalline = true; // this tells R_StoreWallRange that curline is a portal seg + g_portal = portal; // this tells R_StoreWallRange that curline is a portal seg } diff --git a/src/r_portal.h b/src/r_portal.h index 8df3db415..c944f46d0 100644 --- a/src/r_portal.h +++ b/src/r_portal.h @@ -11,6 +11,9 @@ /// \file r_portal.h /// \brief Software renderer portal struct, functions, linked list extern. +#ifndef __R_PORTAL__ +#define __R_PORTAL__ + #include "r_data.h" @@ -41,9 +44,14 @@ extern portal_t* portal_base; extern portal_t* portal_cap; extern UINT8 portalrender; +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_ClipStoreFromRange (portal_t* portal); void Portal_ClipApply (const portal_t* portal); + +#endif diff --git a/src/r_segs.c b/src/r_segs.c index 452351aa3..3b2c7d512 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -15,6 +15,7 @@ #include "r_local.h" #include "r_sky.h" +#include "r_portal.h" #include "r_splats.h" #include "w_wad.h" diff --git a/src/r_state.h b/src/r_state.h index 5234d1d62..b48f0268d 100644 --- a/src/r_state.h +++ b/src/r_state.h @@ -94,10 +94,6 @@ extern boolean viewsky, skyVisible; extern boolean skyVisiblePerPlayer[MAXSPLITSCREENPLAYERS]; // saved values of skyVisible of each splitscreen player extern sector_t *viewsector; extern player_t *viewplayer; -extern UINT8 portalrender; -extern sector_t *portalcullsector; -extern line_t *portalclipline; -extern INT32 portalclipstart, portalclipend; extern consvar_t cv_allowmlook; extern consvar_t cv_maxportals; diff --git a/src/r_things.c b/src/r_things.c index 17d198801..309e27c42 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -31,6 +31,7 @@ #include "dehacked.h" // get_number (for thok) #include "d_netfil.h" // blargh. for nameonly(). #include "m_cheat.h" // objectplace +#include "r_portal.h" #include "k_kart.h" // SRB2kart #include "p_local.h" // stplyr #ifdef HWRENDER