From 8ad191b080230d93c2321e25bf3b6c28e067cf1c Mon Sep 17 00:00:00 2001 From: Lactozilla Date: Mon, 26 Jun 2023 17:36:00 -0300 Subject: [PATCH] Fix crashes and issues in OpenGL, remove old code --- src/doomdef.h | 7 - src/hardware/hw_main.c | 947 +++++------------------------------------ src/hardware/hw_main.h | 4 +- src/p_world.c | 3 + src/p_world.h | 2 + src/r_bsp.c | 2 +- 6 files changed, 103 insertions(+), 862 deletions(-) diff --git a/src/doomdef.h b/src/doomdef.h index ba1be05dd..608300242 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -636,13 +636,6 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; /// Experimental attempts at preventing MF_PAPERCOLLISION objects from getting stuck in walls. //#define PAPER_COLLISIONCORRECTION -/// FINALLY some real clipping that doesn't make walls dissappear AND speeds the game up -/// (that was the original comment from SRB2CB, sadly it is a lie and actually slows game down) -/// on the bright side it fixes some weird issues with translucent walls -/// \note SRB2CB port. -/// SRB2CB itself ported this from PrBoom+ -#define NEWCLIP - /// OpenGL shaders #define GL_SHADERS diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index d304b6416..1aa9486f4 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -43,12 +43,8 @@ #include "../d_main.h" #include "../p_slopes.h" #include "hw_md2.h" - -#ifdef NEWCLIP #include "hw_clip.h" -#endif -#define R_FAKEFLOORS #define HWPRECIP // ========================================================================== @@ -73,37 +69,10 @@ void HWR_AddTransparentPolyobjectFloor(levelflat_t *levelflat, polyobj_t *polyse boolean drawsky = true; -// ========================================================================== -// VIEW GLOBALS -// ========================================================================== -// Fineangles in the SCREENWIDTH wide window. -#define FIELDOFVIEW ANGLE_90 -#define ABS(x) ((x) < 0 ? -(x) : (x)) - -static angle_t gl_clipangle; - -// The viewangletox[viewangle + FINEANGLES/4] lookup -// maps the visible view angles to screen X coordinates, -// flattening the arc to a flat projection plane. -// There will be many angles mapped to the same X. -static INT32 gl_viewangletox[FINEANGLES/2]; - -// The xtoviewangleangle[] table maps a screen pixel -// to the lowest viewangle that maps back to x ranges -// from clipangle to -clipangle. -static angle_t gl_xtoviewangle[MAXVIDWIDTH+1]; - // ========================================================================== // GLOBALS // ========================================================================== -// uncomment to remove the plane rendering -#define DOPLANES -//#define DOWALLS - -// test change fov when looking up/down but bsp projection messup :( -//#define NOCRAPPYMLOOK - // base values set at SetViewSize static float gl_basecentery; @@ -349,8 +318,6 @@ static FUINT HWR_CalcSlopeLight(FUINT lightnum, angle_t dir, fixed_t delta) // FLOOR/CEILING GENERATION FROM SUBSECTORS // ========================================================================== -#ifdef DOPLANES - // -----------------+ // HWR_RenderPlane : Render a floor or ceiling convex polygon // -----------------+ @@ -568,7 +535,7 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool const float renderdist = 27000.0f; // How far out to properly render the plane const float farrenderdist = 32768.0f; // From here, raise plane to horizon level to fill in the line with some texture distortion - seg_t *line = &segs[subsector->firstline]; + seg_t *line = &viewworld->segs[subsector->firstline]; for (i = 0; i < subsector->numlines; i++, line++) { @@ -634,7 +601,6 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool HWR_PlaneLighting(planeVerts, nrPlaneVerts); #endif } -#endif //doplanes FBITFIELD HWR_GetBlendModeFlag(INT32 style) { @@ -732,45 +698,6 @@ static void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIEL HWR_ProcessPolygon(pSurf, wallVerts, 4, blendmode|PF_Modulated|PF_Occlude, shader, false); } -// ========================================================================== -// BSP, CULL, ETC.. -// ========================================================================== - -// return the frac from the interception of the clipping line -// (in fact a clipping plane that has a constant, so can clip with simple 2d) -// with the wall segment -// -#ifndef NEWCLIP -static float HWR_ClipViewSegment(INT32 x, polyvertex_t *v1, polyvertex_t *v2) -{ - float num, den; - float v1x, v1y, v1dx, v1dy, v2dx, v2dy; - angle_t pclipangle = gl_xtoviewangle[x]; - - // a segment of a polygon - v1x = v1->x; - v1y = v1->y; - v1dx = (v2->x - v1->x); - v1dy = (v2->y - v1->y); - - // the clipping line - pclipangle = pclipangle + dup_viewangle; //back to normal angle (non-relative) - v2dx = FIXED_TO_FLOAT(FINECOSINE(pclipangle>>ANGLETOFINESHIFT)); - v2dy = FIXED_TO_FLOAT(FINESINE(pclipangle>>ANGLETOFINESHIFT)); - - den = v2dy*v1dx - v2dx*v1dy; - if (den == 0) - return -1; // parallel - - // calc the frac along the polygon segment, - //num = (v2x - v1x)*v2dy + (v1y - v2y)*v2dx; - //num = -v1x * v2dy + v1y * v2dx; - num = (gl_viewx - v1x)*v2dy + (v1y - gl_viewy)*v2dx; - - return num / den; -} -#endif - // SoM: split up and light walls according to the lightlist. // This may also include leaving out parts of the wall that can't be seen static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, FSurfaceInfo* Surf, INT32 cutflag, ffloor_t *pfloor, FBITFIELD polyflags) @@ -1219,12 +1146,12 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom INT32 repeats; if (gl_linedef->frontsector->heightsec != -1) - front = §ors[gl_linedef->frontsector->heightsec]; + front = &viewworld->sectors[gl_linedef->frontsector->heightsec]; else front = gl_linedef->frontsector; if (gl_linedef->backsector->heightsec != -1) - back = §ors[gl_linedef->backsector->heightsec]; + back = &viewworld->sectors[gl_linedef->backsector->heightsec]; else back = gl_linedef->backsector; @@ -1535,13 +1462,13 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope)) continue; - texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture); + texnum = R_GetTextureNum(viewworld->sides[rover->master->sidenum[0]].midtexture); if (rover->master->flags & ML_TFERLINE) { size_t linenum = gl_curline->linedef-gl_backsector->lines[0]; newline = rover->master->frontsector->lines[0] + linenum; - texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture); + texnum = R_GetTextureNum(viewworld->sides[newline->sidenum[0]].midtexture); } h = P_GetFFloorTopZAt (rover, v1x, v1y); @@ -1585,13 +1512,13 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // -- Monster Iestyn 26/06/18 if (newline) { - texturevpeg = sides[newline->sidenum[0]].rowoffset; + texturevpeg = viewworld->sides[newline->sidenum[0]].rowoffset; attachtobottom = !!(newline->flags & ML_DONTPEGBOTTOM); slopeskew = !!(newline->flags & ML_SKEWTD); } else { - texturevpeg = sides[rover->master->sidenum[0]].rowoffset; + texturevpeg = viewworld->sides[rover->master->sidenum[0]].rowoffset; attachtobottom = !!(gl_linedef->flags & ML_DONTPEGBOTTOM); slopeskew = !!(rover->master->flags & ML_SKEWTD); } @@ -1692,13 +1619,13 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope)) continue; - texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture); + texnum = R_GetTextureNum(viewworld->sides[rover->master->sidenum[0]].midtexture); if (rover->master->flags & ML_TFERLINE) { size_t linenum = gl_curline->linedef-gl_backsector->lines[0]; newline = rover->master->frontsector->lines[0] + linenum; - texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture); + texnum = R_GetTextureNum(viewworld->sides[newline->sidenum[0]].midtexture); } h = P_GetFFloorTopZAt (rover, v1x, v1y); hS = P_GetFFloorTopZAt (rover, v2x, v2y); @@ -1736,13 +1663,13 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (newline) { - wallVerts[3].t = wallVerts[2].t = (*rover->topheight - h + sides[newline->sidenum[0]].rowoffset) * grTex->scaleY; - wallVerts[0].t = wallVerts[1].t = (h - l + (*rover->topheight - h + sides[newline->sidenum[0]].rowoffset)) * grTex->scaleY; + wallVerts[3].t = wallVerts[2].t = (*rover->topheight - h + viewworld->sides[newline->sidenum[0]].rowoffset) * grTex->scaleY; + wallVerts[0].t = wallVerts[1].t = (h - l + (*rover->topheight - h + viewworld->sides[newline->sidenum[0]].rowoffset)) * grTex->scaleY; } else { - wallVerts[3].t = wallVerts[2].t = (*rover->topheight - h + sides[rover->master->sidenum[0]].rowoffset) * grTex->scaleY; - wallVerts[0].t = wallVerts[1].t = (h - l + (*rover->topheight - h + sides[rover->master->sidenum[0]].rowoffset)) * grTex->scaleY; + wallVerts[3].t = wallVerts[2].t = (*rover->topheight - h + viewworld->sides[rover->master->sidenum[0]].rowoffset) * grTex->scaleY; + wallVerts[0].t = wallVerts[1].t = (h - l + (*rover->topheight - h + viewworld->sides[rover->master->sidenum[0]].rowoffset)) * grTex->scaleY; } wallVerts[0].s = wallVerts[3].s = cliplow * grTex->scaleX; @@ -1796,7 +1723,6 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // // e6y: Check whether the player can look beyond this line // -#ifdef NEWCLIP boolean checkforemptylines = true; // Don't modify anything here, just check // Kalaron: Modified for sloped linedefs @@ -1879,295 +1805,6 @@ static boolean CheckClip(seg_t * seg, sector_t * afrontsector, sector_t * abacks return false; } -#else -//Hurdler: just like in r_bsp.c -#if 1 -#define MAXSEGS MAXVIDWIDTH/2+1 -#else -//Alam_GBC: Or not (may cause overflow) -#define MAXSEGS 128 -#endif - -// hw_newend is one past the last valid seg -static cliprange_t * hw_newend; -static cliprange_t gl_solidsegs[MAXSEGS]; - -// needs fix: walls are incorrectly clipped one column less -static consvar_t cv_glclipwalls = CVAR_INIT ("gr_clipwalls", "Off", 0, CV_OnOff, NULL); - -static void printsolidsegs(void) -{ - cliprange_t * start; - if (!hw_newend) - return; - for (start = gl_solidsegs;start != hw_newend;start++) - { - CONS_Debug(DBG_RENDER, "%d-%d|",start->first,start->last); - } - CONS_Debug(DBG_RENDER, "\n\n"); -} - -// -// -// -static void HWR_ClipSolidWallSegment(INT32 first, INT32 last) -{ - cliprange_t *next, *start; - float lowfrac, highfrac; - boolean poorhack = false; - - // Find the first range that touches the range - // (adjacent pixels are touching). - start = gl_solidsegs; - while (start->last < first-1) - start++; - - if (first < start->first) - { - if (last < start->first-1) - { - // Post is entirely visible (above start), - // so insert a new clippost. - HWR_StoreWallRange(first, last); - - next = hw_newend; - hw_newend++; - - while (next != start) - { - *next = *(next-1); - next--; - } - - next->first = first; - next->last = last; - printsolidsegs(); - return; - } - - // There is a fragment above *start. - if (!cv_glclipwalls.value) - { - if (!poorhack) HWR_StoreWallRange(first, last); - poorhack = true; - } - else - { - highfrac = HWR_ClipViewSegment(start->first+1, (polyvertex_t *)gl_curline->pv1, (polyvertex_t *)gl_curline->pv2); - HWR_StoreWallRange(0, highfrac); - } - // Now adjust the clip size. - start->first = first; - } - - // Bottom contained in start? - if (last <= start->last) - { - printsolidsegs(); - return; - } - next = start; - while (last >= (next+1)->first-1) - { - // There is a fragment between two posts. - if (!cv_glclipwalls.value) - { - if (!poorhack) HWR_StoreWallRange(first,last); - poorhack = true; - } - else - { - lowfrac = HWR_ClipViewSegment(next->last-1, (polyvertex_t *)gl_curline->pv1, (polyvertex_t *)gl_curline->pv2); - highfrac = HWR_ClipViewSegment((next+1)->first+1, (polyvertex_t *)gl_curline->pv1, (polyvertex_t *)gl_curline->pv2); - HWR_StoreWallRange(lowfrac, highfrac); - } - next++; - - if (last <= next->last) - { - // Bottom is contained in next. - // Adjust the clip size. - start->last = next->last; - goto crunch; - } - } - - if (first == next->first+1) // 1 line texture - { - if (!cv_glclipwalls.value) - { - if (!poorhack) HWR_StoreWallRange(first,last); - poorhack = true; - } - else - HWR_StoreWallRange(0, 1); - } - else - { - // There is a fragment after *next. - if (!cv_glclipwalls.value) - { - if (!poorhack) HWR_StoreWallRange(first,last); - poorhack = true; - } - else - { - lowfrac = HWR_ClipViewSegment(next->last-1, (polyvertex_t *)gl_curline->pv1, (polyvertex_t *)gl_curline->pv2); - HWR_StoreWallRange(lowfrac, 1); - } - } - - // Adjust the clip size. - start->last = last; - - // Remove start+1 to next from the clip list, - // because start now covers their area. -crunch: - if (next == start) - { - printsolidsegs(); - // Post just extended past the bottom of one post. - return; - } - - - while (next++ != hw_newend) - { - // Remove a post. - *++start = *next; - } - - hw_newend = start; - printsolidsegs(); -} - -// -// handle LineDefs with upper and lower texture (windows) -// -static void HWR_ClipPassWallSegment(INT32 first, INT32 last) -{ - cliprange_t *start; - float lowfrac, highfrac; - //to allow noclipwalls but still solidseg reject of non-visible walls - boolean poorhack = false; - - // Find the first range that touches the range - // (adjacent pixels are touching). - start = gl_solidsegs; - while (start->last < first - 1) - start++; - - if (first < start->first) - { - if (last < start->first-1) - { - // Post is entirely visible (above start). - HWR_StoreWallRange(0, 1); - return; - } - - // There is a fragment above *start. - if (!cv_glclipwalls.value) - { //20/08/99: Changed by Hurdler (taken from faB's code) - if (!poorhack) HWR_StoreWallRange(0, 1); - poorhack = true; - } - else - { - highfrac = HWR_ClipViewSegment(min(start->first + 1, - start->last), (polyvertex_t *)gl_curline->pv1, - (polyvertex_t *)gl_curline->pv2); - HWR_StoreWallRange(0, highfrac); - } - } - - // Bottom contained in start? - if (last <= start->last) - return; - - while (last >= (start+1)->first-1) - { - // There is a fragment between two posts. - if (!cv_glclipwalls.value) - { - if (!poorhack) HWR_StoreWallRange(0, 1); - poorhack = true; - } - else - { - lowfrac = HWR_ClipViewSegment(max(start->last-1,start->first), (polyvertex_t *)gl_curline->pv1, (polyvertex_t *)gl_curline->pv2); - highfrac = HWR_ClipViewSegment(min((start+1)->first+1,(start+1)->last), (polyvertex_t *)gl_curline->pv1, (polyvertex_t *)gl_curline->pv2); - HWR_StoreWallRange(lowfrac, highfrac); - } - start++; - - if (last <= start->last) - return; - } - - if (first == start->first+1) // 1 line texture - { - if (!cv_glclipwalls.value) - { - if (!poorhack) HWR_StoreWallRange(0, 1); - poorhack = true; - } - else - HWR_StoreWallRange(0, 1); - } - else - { - // There is a fragment after *next. - if (!cv_glclipwalls.value) - { - if (!poorhack) HWR_StoreWallRange(0,1); - poorhack = true; - } - else - { - lowfrac = HWR_ClipViewSegment(max(start->last - 1, - start->first), (polyvertex_t *)gl_curline->pv1, - (polyvertex_t *)gl_curline->pv2); - HWR_StoreWallRange(lowfrac, 1); - } - } -} - -// -------------------------------------------------------------------------- -// HWR_ClipToSolidSegs check if it is hide by wall (solidsegs) -// -------------------------------------------------------------------------- -static boolean HWR_ClipToSolidSegs(INT32 first, INT32 last) -{ - cliprange_t * start; - - // Find the first range that touches the range - // (adjacent pixels are touching). - start = gl_solidsegs; - while (start->last < first-1) - start++; - - if (first < start->first) - return true; - - // Bottom contained in start? - if (last <= start->last) - return false; - - return true; -} - -// -// HWR_ClearClipSegs -// -static void HWR_ClearClipSegs(void) -{ - gl_solidsegs[0].first = -0x7fffffff; - gl_solidsegs[0].last = -1; - gl_solidsegs[1].first = vid.width; //viewwidth; - gl_solidsegs[1].last = 0x7fffffff; - hw_newend = gl_solidsegs+2; -} -#endif // NEWCLIP // -----------------+ // HWR_AddLine : Clips the given segment and adds any visible pieces to the line list. @@ -2177,11 +1814,6 @@ static void HWR_ClearClipSegs(void) static void HWR_AddLine(seg_t * line) { angle_t angle1, angle2; -#ifndef NEWCLIP - INT32 x1, x2; - angle_t span, tspan; - boolean bothceilingssky = false, bothfloorssky = false; -#endif // SoM: Backsector needs to be run through R_FakeFlat static sector_t tempsec; @@ -2201,8 +1833,7 @@ static void HWR_AddLine(seg_t * line) angle1 = R_PointToAngle64(v1x, v1y); angle2 = R_PointToAngle64(v2x, v2y); -#ifdef NEWCLIP - // PrBoom: Back side, i.e. backface culling - read: endAngle >= startAngle! + // PrBoom: Back side, i.e. backface culling - read: endAngle >= startAngle! if (angle2 - angle1 < ANGLE_180) return; @@ -2214,90 +1845,9 @@ static void HWR_AddLine(seg_t * line) } checkforemptylines = true; -#else - // Clip to view edges. - span = angle1 - angle2; - - // backface culling : span is < ANGLE_180 if ang1 > ang2 : the seg is facing - if (span >= ANGLE_180) - return; - - // Global angle needed by segcalc. - //rw_angle1 = angle1; - angle1 -= dup_viewangle; - angle2 -= dup_viewangle; - - tspan = angle1 + gl_clipangle; - if (tspan > 2*gl_clipangle) - { - tspan -= 2*gl_clipangle; - - // Totally off the left edge? - if (tspan >= span) - return; - - angle1 = gl_clipangle; - } - tspan = gl_clipangle - angle2; - if (tspan > 2*gl_clipangle) - { - tspan -= 2*gl_clipangle; - - // Totally off the left edge? - if (tspan >= span) - return; - - angle2 = (angle_t)-(signed)gl_clipangle; - } - -#if 0 - { - float fx1,fx2,fy1,fy2; - //BP: test with a better projection than viewangletox[R_PointToAngle(angle)] - // do not enable this at release 4 mul and 2 div - fx1 = ((polyvertex_t *)(line->pv1))->x-gl_viewx; - fy1 = ((polyvertex_t *)(line->pv1))->y-gl_viewy; - fy2 = (fx1 * gl_viewcos + fy1 * gl_viewsin); - if (fy2 < 0) - // the point is back - fx1 = 0; - else - fx1 = gl_windowcenterx + (fx1 * gl_viewsin - fy1 * gl_viewcos) * gl_centerx / fy2; - - fx2 = ((polyvertex_t *)(line->pv2))->x-gl_viewx; - fy2 = ((polyvertex_t *)(line->pv2))->y-gl_viewy; - fy1 = (fx2 * gl_viewcos + fy2 * gl_viewsin); - if (fy1 < 0) - // the point is back - fx2 = vid.width; - else - fx2 = gl_windowcenterx + (fx2 * gl_viewsin - fy2 * gl_viewcos) * gl_centerx / fy1; - - x1 = fx1+0.5f; - x2 = fx2+0.5f; - } -#else - // The seg is in the view range, - // but not necessarily visible. - angle1 = (angle1+ANGLE_90)>>ANGLETOFINESHIFT; - angle2 = (angle2+ANGLE_90)>>ANGLETOFINESHIFT; - - x1 = gl_viewangletox[angle1]; - x2 = gl_viewangletox[angle2]; -#endif - // Does not cross a pixel? -// if (x1 == x2) -/* { - // BP: HERE IS THE MAIN PROBLEM ! - //CONS_Debug(DBG_RENDER, "tineline\n"); - return; - } -*/ -#endif gl_backsector = line->backsector; -#ifdef NEWCLIP if (!line->backsector) { gld_clipper_SafeAddClipRange(angle2, angle1); @@ -2339,115 +1889,6 @@ static void HWR_AddLine(seg_t * line) } HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D - return; -#else - // Single sided line? - if (!gl_backsector) - goto clipsolid; - - gl_backsector = R_FakeFlat(gl_backsector, &tempsec, NULL, NULL, true); - - if (gl_backsector->ceilingpic == viewworld->skyflatnum && gl_frontsector->ceilingpic == viewworld->skyflatnum) - bothceilingssky = true; - if (gl_backsector->floorpic == viewworld->skyflatnum && gl_frontsector->floorpic == viewworld->skyflatnum) - bothfloorssky = true; - - if (bothceilingssky && bothfloorssky) // everything's sky? let's save us a bit of time then - { - if (!line->polyseg && - !line->sidedef->midtexture - && ((!gl_frontsector->ffloors && !gl_backsector->ffloors) - || Tag_Compare(&gl_frontsector->tags, &gl_backsector->tags))) - return; // line is empty, don't even bother - - goto clippass; // treat like wide open window instead - } - - if (gl_frontsector->f_slope || gl_frontsector->c_slope || gl_backsector->f_slope || gl_backsector->c_slope) - { - fixed_t frontf1,frontf2, frontc1, frontc2; // front floor/ceiling ends - fixed_t backf1, backf2, backc1, backc2; // back floor ceiling ends - -#define SLOPEPARAMS(slope, end1, end2, normalheight) \ - end1 = P_GetZAt(slope, v1x, v1y, normalheight); \ - end2 = P_GetZAt(slope, v2x, v2y, normalheight); - - SLOPEPARAMS(gl_frontsector->f_slope, frontf1, frontf2, gl_frontsector-> floorheight) - SLOPEPARAMS(gl_frontsector->c_slope, frontc1, frontc2, gl_frontsector->ceilingheight) - SLOPEPARAMS( gl_backsector->f_slope, backf1, backf2, gl_backsector-> floorheight) - SLOPEPARAMS( gl_backsector->c_slope, backc1, backc2, gl_backsector->ceilingheight) -#undef SLOPEPARAMS - // if both ceilings are skies, consider it always "open" - // same for floors - if (!bothceilingssky && !bothfloorssky) - { - // Closed door. - if ((backc1 <= frontf1 && backc2 <= frontf2) - || (backf1 >= frontc1 && backf2 >= frontc2)) - { - goto clipsolid; - } - - // Check for automap fix. - if (backc1 <= backf1 && backc2 <= backf2 - && ((backc1 >= frontc1 && backc2 >= frontc2) || gl_curline->sidedef->toptexture) - && ((backf1 <= frontf1 && backf2 >= frontf2) || gl_curline->sidedef->bottomtexture)) - goto clipsolid; - } - - // Window. - if (!bothceilingssky) // ceilings are always the "same" when sky - if (backc1 != frontc1 || backc2 != frontc2) - goto clippass; - if (!bothfloorssky) // floors are always the "same" when sky - if (backf1 != frontf1 || backf2 != frontf2) - goto clippass; - } - else - { - // if both ceilings are skies, consider it always "open" - // same for floors - if (!bothceilingssky && !bothfloorssky) - { - // Closed door. - if (gl_backsector->ceilingheight <= gl_frontsector->floorheight || - gl_backsector->floorheight >= gl_frontsector->ceilingheight) - goto clipsolid; - - // Check for automap fix. - if (gl_backsector->ceilingheight <= gl_backsector->floorheight - && ((gl_backsector->ceilingheight >= gl_frontsector->ceilingheight) || gl_curline->sidedef->toptexture) - && ((gl_backsector->floorheight <= gl_backsector->floorheight) || gl_curline->sidedef->bottomtexture)) - goto clipsolid; - } - - // Window. - if (!bothceilingssky) // ceilings are always the "same" when sky - if (gl_backsector->ceilingheight != gl_frontsector->ceilingheight) - goto clippass; - if (!bothfloorssky) // floors are always the "same" when sky - if (gl_backsector->floorheight != gl_frontsector->floorheight) - goto clippass; - } - - // Reject empty lines used for triggers and special events. - // Identical floor and ceiling on both sides, - // identical light levels on both sides, - // and no middle texture. - if (R_IsEmptyLine(gl_curline, gl_frontsector, gl_backsector)) - return; - -clippass: - if (x1 == x2) - { x2++;x1 -= 2; } - HWR_ClipPassWallSegment(x1, x2-1); - return; - -clipsolid: - if (x1 == x2) - goto clippass; - HWR_ClipSolidWallSegment(x1, x2-1); -#endif } // HWR_CheckBBox @@ -2462,10 +1903,6 @@ static boolean HWR_CheckBBox(fixed_t *bspcoord) INT32 boxpos; fixed_t px1, py1, px2, py2; angle_t angle1, angle2; -#ifndef NEWCLIP - INT32 sx1, sx2; - angle_t span, tspan; -#endif // Find the corners of the box // that define the edges from current viewpoint. @@ -2491,59 +1928,9 @@ static boolean HWR_CheckBBox(fixed_t *bspcoord) px2 = bspcoord[checkcoord[boxpos][2]]; py2 = bspcoord[checkcoord[boxpos][3]]; -#ifdef NEWCLIP angle1 = R_PointToAngle64(px1, py1); angle2 = R_PointToAngle64(px2, py2); return gld_clipper_SafeCheckRange(angle2, angle1); -#else - // check clip list for an open space - angle1 = R_PointToAngle2(dup_viewx>>1, dup_viewy>>1, px1>>1, py1>>1) - dup_viewangle; - angle2 = R_PointToAngle2(dup_viewx>>1, dup_viewy>>1, px2>>1, py2>>1) - dup_viewangle; - - span = angle1 - angle2; - - // Sitting on a line? - if (span >= ANGLE_180) - return true; - - tspan = angle1 + gl_clipangle; - - if (tspan > 2*gl_clipangle) - { - tspan -= 2*gl_clipangle; - - // Totally off the left edge? - if (tspan >= span) - return false; - - angle1 = gl_clipangle; - } - tspan = gl_clipangle - angle2; - if (tspan > 2*gl_clipangle) - { - tspan -= 2*gl_clipangle; - - // Totally off the left edge? - if (tspan >= span) - return false; - - angle2 = (angle_t)-(signed)gl_clipangle; - } - - // Find the first clippost - // that touches the source post - // (adjacent pixels are touching). - angle1 = (angle1+ANGLE_90)>>ANGLETOFINESHIFT; - angle2 = (angle2+ANGLE_90)>>ANGLETOFINESHIFT; - sx1 = gl_viewangletox[angle1]; - sx2 = gl_viewangletox[angle2]; - - // Does not cross a pixel. - if (sx1 == sx2) - return false; - - return HWR_ClipToSolidSegs(sx1, sx2 - 1); -#endif } // @@ -2853,48 +2240,36 @@ static void HWR_Subsector(size_t num) ffloor_t *rover; #ifdef PARANOIA //no risk while developing, enough debugging nights! - if (num >= world->numextrasubsectors) + if (num >= viewworld->numextrasubsectors) I_Error("HWR_Subsector: ss %s with numss = %s, addss = %s\n", - sizeu1(num), sizeu2(numsubsectors), sizeu3(world->numextrasubsectors)); + sizeu1(num), sizeu2(numsubsectors), sizeu3(viewworld->numextrasubsectors)); #endif - if (num < numsubsectors) + if (num < viewworld->numsubsectors) { // subsector - sub = &subsectors[num]; + sub = &viewworld->subsectors[num]; // sector gl_frontsector = sub->sector; // how many linedefs count = sub->numlines; // first line seg - line = &segs[sub->firstline]; + line = &viewworld->segs[sub->firstline]; } else { // there are no segs but only planes - sub = &subsectors[0]; + sub = &viewworld->subsectors[0]; gl_frontsector = sub->sector; count = 0; line = NULL; } //SoM: 4/7/2000: Test to make Boom water work in Hardware mode. - gl_frontsector = R_FakeFlat(gl_frontsector, &tempsec, &floorlightlevel, - &ceilinglightlevel, false); - //FIXME: Use floorlightlevel and ceilinglightlevel insted of lightlevel. + gl_frontsector = R_FakeFlat(gl_frontsector, &tempsec, &floorlightlevel, &ceilinglightlevel, false); floorcolormap = ceilingcolormap = gl_frontsector->extra_colormap; - // ------------------------------------------------------------------------ - // sector lighting, DISABLED because it's done in HWR_StoreWallRange - // ------------------------------------------------------------------------ - /// \todo store a RGBA instead of just intensity, allow coloured sector lighting - //light = (FUBYTE)(sub->sector->lightlevel & 0xFF) / 255.0f; - //gl_cursectorlight.red = light; - //gl_cursectorlight.green = light; - //gl_cursectorlight.blue = light; - //gl_cursectorlight.alpha = light; - // ----- end special tricks ----- cullFloorHeight = P_GetSectorFloorZAt (gl_frontsector, viewx, viewy); cullCeilingHeight = P_GetSectorCeilingZAt(gl_frontsector, viewx, viewy); @@ -2909,7 +2284,8 @@ static void HWR_Subsector(size_t num) { for (rover = gl_frontsector->ffloors; rover; rover = rover->next) { - sector_t *controlSec = §ors[rover->secnum]; + sector_t *controlSec = &viewworld->sectors[rover->secnum]; + if (controlSec->moved == true) { anyMoved = true; @@ -2941,37 +2317,27 @@ static void HWR_Subsector(size_t num) sub->sector->extra_colormap = gl_frontsector->extra_colormap; // render floor ? -#ifdef DOPLANES - // yeah, easy backface cull! :) - if (cullFloorHeight < dup_viewz) + if (sub->validcount != validcount) { - if (gl_frontsector->floorpic != viewworld->skyflatnum) + // yeah, easy backface cull! :) + if (cullFloorHeight < dup_viewz && gl_frontsector->floorpic != viewworld->skyflatnum) { - if (sub->validcount != validcount) - { - HWR_GetLevelFlat(&viewworld->flats[gl_frontsector->floorpic]); - HWR_RenderPlane(sub, &world->extrasubsectors[num], false, - // Hack to make things continue to work around slopes. - locFloorHeight == cullFloorHeight ? locFloorHeight : gl_frontsector->floorheight, - // We now return you to your regularly scheduled rendering. - PF_Occlude, floorlightlevel, &viewworld->flats[gl_frontsector->floorpic], NULL, 255, floorcolormap); - } + HWR_GetLevelFlat(&viewworld->flats[gl_frontsector->floorpic]); + HWR_RenderPlane(sub, &viewworld->extrasubsectors[num], false, + // Hack to make things continue to work around slopes. + locFloorHeight == cullFloorHeight ? locFloorHeight : gl_frontsector->floorheight, + // We now return you to your regularly scheduled rendering. + PF_Occlude, floorlightlevel, &viewworld->flats[gl_frontsector->floorpic], NULL, 255, floorcolormap); } - } - if (cullCeilingHeight > dup_viewz) - { - if (gl_frontsector->ceilingpic != viewworld->skyflatnum) + if (cullCeilingHeight > dup_viewz && gl_frontsector->ceilingpic != viewworld->skyflatnum) { - if (sub->validcount != validcount) - { - HWR_GetLevelFlat(&viewworld->flats[gl_frontsector->ceilingpic]); - HWR_RenderPlane(sub, &world->extrasubsectors[num], true, - // Hack to make things continue to work around slopes. - locCeilingHeight == cullCeilingHeight ? locCeilingHeight : gl_frontsector->ceilingheight, - // We now return you to your regularly scheduled rendering. - PF_Occlude, ceilinglightlevel, &viewworld->flats[gl_frontsector->ceilingpic], NULL, 255, ceilingcolormap); - } + HWR_GetLevelFlat(&viewworld->flats[gl_frontsector->ceilingpic]); + HWR_RenderPlane(sub, &viewworld->extrasubsectors[num], true, + // Hack to make things continue to work around slopes. + locCeilingHeight == cullCeilingHeight ? locCeilingHeight : gl_frontsector->ceilingheight, + // We now return you to your regularly scheduled rendering. + PF_Occlude, ceilinglightlevel, &viewworld->flats[gl_frontsector->ceilingpic], NULL, 255, ceilingcolormap); } } @@ -2979,7 +2345,6 @@ static void HWR_Subsector(size_t num) if (gl_frontsector->ceilingpic == viewworld->skyflatnum || gl_frontsector->floorpic == viewworld->skyflatnum) drawsky = true; -#ifdef R_FAKEFLOORS if (gl_frontsector->ffloors) { /// \todo fix light, xoffs, yoffs, extracolormap ? @@ -3010,7 +2375,7 @@ static void HWR_Subsector(size_t num) alpha = HWR_FogBlockAlpha(*gl_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap); HWR_AddTransparentFloor(NULL, - &world->extrasubsectors[num], + &viewworld->extrasubsectors[num], false, *rover->bottomheight, *gl_frontsector->lightlist[light].lightlevel, @@ -3022,7 +2387,7 @@ static void HWR_Subsector(size_t num) light = R_GetPlaneLight(gl_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); HWR_AddTransparentFloor(&viewworld->flats[*rover->bottompic], - &world->extrasubsectors[num], + &viewworld->extrasubsectors[num], false, *rover->bottomheight, *gl_frontsector->lightlist[light].lightlevel, @@ -3034,7 +2399,7 @@ static void HWR_Subsector(size_t num) { HWR_GetLevelFlat(&viewworld->flats[*rover->bottompic]); light = R_GetPlaneLight(gl_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); - HWR_RenderPlane(sub, &world->extrasubsectors[num], false, *rover->bottomheight, HWR_RippleBlend(gl_frontsector, rover, false)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, &viewworld->flats[*rover->bottompic], + HWR_RenderPlane(sub, &viewworld->extrasubsectors[num], false, *rover->bottomheight, HWR_RippleBlend(gl_frontsector, rover, false)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, &viewworld->flats[*rover->bottompic], rover->master->frontsector, 255, *gl_frontsector->lightlist[light].extra_colormap); } } @@ -3056,7 +2421,7 @@ static void HWR_Subsector(size_t num) alpha = HWR_FogBlockAlpha(*gl_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap); HWR_AddTransparentFloor(NULL, - &world->extrasubsectors[num], + &viewworld->extrasubsectors[num], true, *rover->topheight, *gl_frontsector->lightlist[light].lightlevel, @@ -3068,7 +2433,7 @@ static void HWR_Subsector(size_t num) light = R_GetPlaneLight(gl_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); HWR_AddTransparentFloor(&viewworld->flats[*rover->toppic], - &world->extrasubsectors[num], + &viewworld->extrasubsectors[num], true, *rover->topheight, *gl_frontsector->lightlist[light].lightlevel, @@ -3080,14 +2445,12 @@ static void HWR_Subsector(size_t num) { HWR_GetLevelFlat(&viewworld->flats[*rover->toppic]); light = R_GetPlaneLight(gl_frontsector, centerHeight, dup_viewz < cullHeight ? true : false); - HWR_RenderPlane(sub, &world->extrasubsectors[num], true, *rover->topheight, HWR_RippleBlend(gl_frontsector, rover, false)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, &viewworld->flats[*rover->toppic], + HWR_RenderPlane(sub, &viewworld->extrasubsectors[num], true, *rover->topheight, HWR_RippleBlend(gl_frontsector, rover, false)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, &viewworld->flats[*rover->toppic], rover->master->frontsector, 255, *gl_frontsector->lightlist[light].extra_colormap); } } } } -#endif -#endif //doplanes // Draw all the polyobjects in this subsector if (sub->polyList) @@ -3119,10 +2482,10 @@ static void HWR_Subsector(size_t num) } } -// Hurder ici se passe les choses INT32�essantes! -// on vient de tracer le sol et le plafond -// on trace �pr�ent d'abord les sprites et ensuite les murs -// hurdler: faux: on ajoute seulement les sprites, le murs sont trac� d'abord + // Hurder interesting things are happening here! + // we have just drawn the floor and the ceiling + // we now draw the sprites first and then the walls + // hurdler: false: we only add the sprites, the walls are drawn first if (line) { // draw sprites first, coz they are clipped to the solidsegs of @@ -3139,7 +2502,6 @@ static void HWR_Subsector(size_t num) while (count--) { - if (!line->glseg && !line->polyseg) // ignore segs that belong to polyobjects HWR_AddLine(line); line++; @@ -3180,7 +2542,7 @@ fixed_t *hwbbox; static void HWR_RenderBSPNode(INT32 bspnum) { - node_t *bsp = &nodes[bspnum]; + node_t *bsp = &viewworld->nodes[bspnum]; // Decide which side the view point is on INT32 side; @@ -3219,78 +2581,6 @@ static void HWR_RenderBSPNode(INT32 bspnum) } } -// ========================================================================== -// FROM R_MAIN.C -// ========================================================================== - -//BP : exactely the same as R_InitTextureMapping -void HWR_InitTextureMapping(void) -{ - angle_t i; - INT32 x; - INT32 t; - fixed_t focallength; - fixed_t grcenterx; - fixed_t grcenterxfrac; - INT32 grviewwidth; - -#define clipanglefov (FIELDOFVIEW>>ANGLETOFINESHIFT) - - grviewwidth = vid.width; - grcenterx = grviewwidth/2; - grcenterxfrac = grcenterx< FRACUNIT*2) - t = -1; - else if (FINETANGENT(i) < -FRACUNIT*2) - t = grviewwidth+1; - else - { - t = FixedMul(FINETANGENT(i), focallength); - t = (grcenterxfrac - t+FRACUNIT-1)>>FRACBITS; - - if (t < -1) - t = -1; - else if (t > grviewwidth+1) - t = grviewwidth+1; - } - gl_viewangletox[i] = t; - } - - // Scan viewangletox[] to generate xtoviewangle[]: - // xtoviewangle will give the smallest view angle - // that maps to x. - for (x = 0; x <= grviewwidth; x++) - { - i = 0; - while (gl_viewangletox[i]>x) - i++; - gl_xtoviewangle[x] = (i<fixedheight - viewz) - ABS(sortnode[n1].plane->fixedheight - viewz); + return abs(sortnode[n2].plane->fixedheight - viewz) - abs(sortnode[n1].plane->fixedheight - viewz); } // @@ -5491,9 +4781,6 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) // ========================================================================== // Sky dome rendering, ported from PrBoom+ // ========================================================================== - -static gl_sky_t gl_sky; - static void HWR_SkyDomeVertex(gl_sky_t *sky, gl_skyvertex_t *vbo, int r, int c, signed char yflip, float delta, boolean foglayer) { const float radians = (float)(M_PIl / 180.0f); @@ -5535,10 +4822,25 @@ static void HWR_SkyDomeVertex(gl_sky_t *sky, gl_skyvertex_t *vbo, int r, int c, vbo->z = z; } -// Clears the sky dome. -void HWR_ClearSkyDome(void) +void HWR_FreeSkyDome(void *skydome) { - gl_sky_t *sky = &gl_sky; + gl_sky_t *sky = (gl_sky_t *)skydome; + if (sky == NULL) + return; + + if (sky->loops) + free(sky->loops); + if (sky->data) + free(sky->data); + + Z_Free(sky); +} + +static void HWR_ClearSkyDome(world_t *w) +{ + gl_sky_t *sky = (gl_sky_t *)w->sky_dome; + if (sky == NULL) + return; if (sky->loops) free(sky->loops); @@ -5559,7 +4861,7 @@ void HWR_ClearSkyDome(void) sky->rebuild = true; } -void HWR_BuildSkyDome(void) +static void HWR_BuildSkyDome(world_t *w) { int c, r; signed char yflip; @@ -5567,15 +4869,22 @@ void HWR_BuildSkyDome(void) int col_count = 4; float delta; - gl_sky_t *sky = &gl_sky; + gl_sky_t *sky = (gl_sky_t *)w->sky_dome; gl_skyvertex_t *vertex_p; - texture_t *texture = textures[texturetranslation[viewworld->skytexture]]; + INT32 skytexture = texturetranslation[w->skytexture]; + texture_t *texture = textures[skytexture]; + + if (sky == NULL) + { + sky = Z_Calloc(sizeof(gl_sky_t), PU_STATIC, NULL); + w->sky_dome = sky; + } sky->detail = 16; col_count *= sky->detail; if ((sky->columns != col_count) || (sky->rows != row_count)) - HWR_ClearSkyDome(); + HWR_ClearSkyDome(w); sky->columns = col_count; sky->rows = row_count; @@ -5588,7 +4897,7 @@ void HWR_BuildSkyDome(void) if (!sky->data) sky->data = malloc(sky->vertex_count * sizeof(sky->data[0])); - sky->texture = texturetranslation[viewworld->skytexture]; + sky->texture = skytexture; sky->width = texture->width; sky->height = texture->height; @@ -5676,15 +4985,21 @@ static void HWR_DrawSkyBackground(player_t *player) HWR_GetTexture(texturetranslation[viewworld->skytexture]); - if (gl_sky.texture != texturetranslation[viewworld->skytexture]) + gl_sky_t *gl_sky = (gl_sky_t *)viewworld->sky_dome; + if (gl_sky == NULL) { - HWR_ClearSkyDome(); - HWR_BuildSkyDome(); + HWR_BuildSkyDome(viewworld); + gl_sky = (gl_sky_t *)viewworld->sky_dome; + } + else if (gl_sky->texture != texturetranslation[viewworld->skytexture]) + { + HWR_ClearSkyDome(viewworld); + HWR_BuildSkyDome(viewworld); } HWD.pfnSetShader(SHADER_SKY); // sky shader HWD.pfnSetTransform(&dometransform); - HWD.pfnRenderSkyDome(&gl_sky); + HWD.pfnRenderSkyDome(gl_sky); } else { @@ -5719,7 +5034,7 @@ static void HWR_DrawSkyBackground(player_t *player) // software doesn't draw any further than 1024 for skies anyway, but this doesn't overlap properly // The only time this will probably be an issue is when a sky wider than 1024 is used as a sky AND a regular wall texture - angle = (dup_viewangle + gl_xtoviewangle[0]); + angle = (dup_viewangle + xtoviewangle[0]); dimensionmultiply = ((float)textures[texturetranslation[viewworld->skytexture]]->width/256.0f); @@ -5967,7 +5282,6 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player) drawcount = 0; -#ifdef NEWCLIP if (rendermode == render_opengl) { angle_t a1 = gld_FrustumAngle(gl_aimingangle); @@ -5977,9 +5291,6 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player) gld_FrustrumSetup(); #endif } -#else - HWR_ClearClipSegs(); -#endif //04/01/2000: Hurdler: added for T&L // Actually it only works on Walls and Planes @@ -5993,36 +5304,7 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player) if (cv_glbatching.value) HWR_StartBatching(); - HWR_RenderBSPNode((INT32)numnodes-1); - -#ifndef NEWCLIP - // Make a viewangle int so we can render things based on mouselook - if (player == &players[consoleplayer]) - viewangle = localaiming; - else if (splitscreen && player == &players[secondarydisplayplayer]) - viewangle = localaiming2; - - // Handle stuff when you are looking farther up or down. - if ((gl_aimingangle || cv_fov.value+player->fovadd > 90*FRACUNIT)) - { - dup_viewangle += ANGLE_90; - HWR_ClearClipSegs(); - HWR_RenderBSPNode((INT32)numnodes-1); //left - - dup_viewangle += ANGLE_90; - if (((INT32)gl_aimingangle > ANGLE_45 || (INT32)gl_aimingangle<-ANGLE_45)) - { - HWR_ClearClipSegs(); - HWR_RenderBSPNode((INT32)numnodes-1); //back - } - - dup_viewangle += ANGLE_90; - HWR_ClearClipSegs(); - HWR_RenderBSPNode((INT32)numnodes-1); //right - - dup_viewangle += ANGLE_90; - } -#endif + HWR_RenderBSPNode((INT32)viewworld->numnodes-1); if (cv_glbatching.value) HWR_RenderBatches(); @@ -6181,7 +5463,6 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) drawcount = 0; -#ifdef NEWCLIP if (rendermode == render_opengl) { angle_t a1 = gld_FrustumAngle(gl_aimingangle); @@ -6191,9 +5472,6 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) gld_FrustrumSetup(); #endif } -#else - HWR_ClearClipSegs(); -#endif //04/01/2000: Hurdler: added for T&L // Actually it only works on Walls and Planes @@ -6211,36 +5489,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) if (cv_glbatching.value) HWR_StartBatching(); - HWR_RenderBSPNode((INT32)numnodes-1); - -#ifndef NEWCLIP - // Make a viewangle int so we can render things based on mouselook - if (player == &players[consoleplayer]) - viewangle = localaiming; - else if (splitscreen && player == &players[secondarydisplayplayer]) - viewangle = localaiming2; - - // Handle stuff when you are looking farther up or down. - if ((gl_aimingangle || cv_fov.value+player->fovadd > 90*FRACUNIT)) - { - dup_viewangle += ANGLE_90; - HWR_ClearClipSegs(); - HWR_RenderBSPNode((INT32)numnodes-1); //left - - dup_viewangle += ANGLE_90; - if (((INT32)gl_aimingangle > ANGLE_45 || (INT32)gl_aimingangle<-ANGLE_45)) - { - HWR_ClearClipSegs(); - HWR_RenderBSPNode((INT32)numnodes-1); //back - } - - dup_viewangle += ANGLE_90; - HWR_ClearClipSegs(); - HWR_RenderBSPNode((INT32)numnodes-1); //right - - dup_viewangle += ANGLE_90; - } -#endif + HWR_RenderBSPNode((INT32)viewworld->numnodes-1); PS_STOP_TIMING(ps_bsptime); @@ -6302,8 +5551,8 @@ void HWR_LoadLevel(void) HWR_CreatePlanePolygons((INT32)world->numnodes - 1); // Build the sky dome - HWR_ClearSkyDome(); - HWR_BuildSkyDome(); + HWR_ClearSkyDome(world); + HWR_BuildSkyDome(world); gl_maploaded = true; } @@ -6395,10 +5644,6 @@ void HWR_AddCommands(void) CV_RegisterVar(&cv_glsolvetjoin); CV_RegisterVar(&cv_glbatching); - -#ifndef NEWCLIP - CV_RegisterVar(&cv_glclipwalls); -#endif } void HWR_AddSessionCommands(void) diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 4a1b412fc..47cd16345 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -33,11 +33,9 @@ void HWR_DrawConsoleBack(UINT32 color, INT32 height); void HWR_DrawTutorialBack(UINT32 color, INT32 boxheight); void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player); void HWR_RenderPlayerView(INT32 viewnumber, player_t *player); -void HWR_ClearSkyDome(void); -void HWR_BuildSkyDome(void); +void HWR_FreeSkyDome(void *skydome); void HWR_DrawViewBorder(INT32 clearlines); void HWR_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum); -void HWR_InitTextureMapping(void); void HWR_SetViewSize(void); void HWR_DrawPatch(patch_t *gpatch, INT32 x, INT32 y, INT32 option); void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap); diff --git a/src/p_world.c b/src/p_world.c index 8fd02abc3..07226fd0a 100644 --- a/src/p_world.c +++ b/src/p_world.c @@ -373,6 +373,9 @@ void P_UnloadWorld(world_t *w) HWR_FreeExtraSubsectors(world->extrasubsectors); world->extrasubsectors = NULL; } + + if (world->sky_dome) + HWR_FreeSkyDome(world->sky_dome); } // diff --git a/src/p_world.h b/src/p_world.h index 0a1c59039..275e3a6fc 100644 --- a/src/p_world.h +++ b/src/p_world.h @@ -133,6 +133,8 @@ typedef struct size_t interpolated_mobjs_capacity; boolean interpolated_level_this_frame; + + void *sky_dome; } world_t; extern world_t *world; diff --git a/src/r_bsp.c b/src/r_bsp.c index 5d01bb45a..0369cf60a 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -873,7 +873,7 @@ static void R_Subsector(size_t num) { for (rover = frontsector->ffloors; rover; rover = rover->next) { - sector_t *controlSec = §ors[rover->secnum]; + sector_t *controlSec = &viewworld->sectors[rover->secnum]; if (controlSec->moved == true) {