From 3a125dbbd585587330f52a5dc74b317d40defa50 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 14 Dec 2018 17:14:03 +0000 Subject: [PATCH 01/11] compare with actual doubles, not ints --- src/hardware/hw_bsp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index a180697d..f9f310a6 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -193,14 +193,14 @@ static polyvertex_t *fracdivline(fdivline_t *bsp, polyvertex_t *v1, v2dy = bsp->dy; den = v2dy*v1dx - v2dx*v1dy; - if (den == 0) + if (den == 0.0) return NULL; // parallel // first check the frac along the polygon segment, // (do not accept hit with the extensions) num = (v2x - v1x)*v2dy + (v1y - v2y)*v2dx; frac = num / den; - if (frac < 0 || frac > 1) + if (frac < 0.0 || frac > 1.0) return NULL; // now get the frac along the BSP line From 4089b6b8e9da1075c8e3c463ec7f268b384bda58 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 14 Dec 2018 18:00:08 +0000 Subject: [PATCH 02/11] use continue if NULL instead of a big if block if ...not NULL also, SplitPoly returns if ps < 0, so there's no need to check for ps >= 0 afterwards --- src/hardware/hw_bsp.c | 144 +++++++++++++++++++++--------------------- 1 file changed, 72 insertions(+), 72 deletions(-) diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index f9f310a6..271d832a 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -294,57 +294,57 @@ static void SplitPoly (fdivline_t *bsp, //splitting parametric line // start & end points pv = fracdivline(bsp, &poly->pts[i], &poly->pts[j]); - if (pv) + if (pv == NULL) + continue; + + if (ps < 0) { - if (ps < 0) + // first point + ps = i; + vs = *pv; + fracs = bspfrac; + } + else + { + //the partition line traverse a junction between two segments + // or the two points are so close, they can be considered as one + // thus, don't accept, since split 2 must be another vertex + if (SameVertice(pv, &lastpv)) { - // first point - ps = i; - vs = *pv; - fracs = bspfrac; - } - else - { - //the partition line traverse a junction between two segments - // or the two points are so close, they can be considered as one - // thus, don't accept, since split 2 must be another vertex - if (SameVertice(pv, &lastpv)) + if (pe < 0) { - if (pe < 0) - { - ps = i; - psonline = 1; - } - else - { - pe = i; - peonline = 1; - } + ps = i; + psonline = 1; } else { - if (pe < 0) - { - pe = i; - ve = *pv; - frace = bspfrac; - } - else - { - // a frac, not same vertice as last one - // we already got pt2 so pt 2 is not on the line, - // so we probably got back to the start point - // which is on the line - if (SameVertice(pv, &vs)) - psonline = 1; - break; - } + pe = i; + peonline = 1; + } + } + else + { + if (pe < 0) + { + pe = i; + ve = *pv; + frace = bspfrac; + } + else + { + // a frac, not same vertice as last one + // we already got pt2 so pt 2 is not on the line, + // so we probably got back to the start point + // which is on the line + if (SameVertice(pv, &vs)) + psonline = 1; + break; } } - - // remember last point intercept to detect identical points - lastpv = *pv; } + + // remember last point intercept to detect identical points + lastpv = *pv; } // no split: the partition line is either parallel and @@ -368,7 +368,7 @@ static void SplitPoly (fdivline_t *bsp, //splitting parametric line return; } - if (ps >= 0 && pe < 0) + if (pe < 0) { //I_Error("SplitPoly: only one point for split line (%d %d)", ps, pe); *frontpoly = poly; @@ -482,42 +482,42 @@ static poly_t *CutOutSubsecPoly(seg_t *lseg, INT32 count, poly_t *poly) pv = fracdivline(&cutseg, &poly->pts[i], &poly->pts[j]); - if (pv) + if (pv == NULL) + continue; + + if (ps < 0) { - if (ps < 0) + ps = i; + vs = *pv; + fracs = bspfrac; + } + else + { + //frac 1 on previous segment, + // 0 on the next, + //the split line goes through one of the convex poly + // vertices, happens quite often since the convex + // poly is already adjacent to the subsector segs + // on most borders + if (SameVertice(pv, &vs)) + continue; + + if (fracs <= bspfrac) { + nump = 2 + poly->numpts - (i-ps); + pe = ps; ps = i; - vs = *pv; - fracs = bspfrac; + ve = *pv; } else { - //frac 1 on previous segment, - // 0 on the next, - //the split line goes through one of the convex poly - // vertices, happens quite often since the convex - // poly is already adjacent to the subsector segs - // on most borders - if (SameVertice(pv, &vs)) - continue; - - if (fracs <= bspfrac) - { - nump = 2 + poly->numpts - (i-ps); - pe = ps; - ps = i; - ve = *pv; - } - else - { - nump = 2 + (i-ps); - pe = i; - ve = vs; - vs = *pv; - } - //found 2nd point - break; + nump = 2 + (i-ps); + pe = i; + ve = vs; + vs = *pv; } + //found 2nd point + break; } } From 02fc845a723effa6a40797cd5c6bbead9b0bae3a Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 14 Dec 2018 18:01:18 +0000 Subject: [PATCH 03/11] Make sure nptfront is explicitly > 0, so we don't alloc a poly for negative number points at all --- src/hardware/hw_bsp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index 271d832a..c75d0b48 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -387,7 +387,7 @@ static void SplitPoly (fdivline_t *bsp, //splitting parametric line *backpoly = HWR_AllocPoly(2 + nptback); else *backpoly = NULL; - if (nptfront) + if (nptfront > 0) *frontpoly = HWR_AllocPoly(2 + nptfront); else *frontpoly = NULL; From 52fd3dcbed185f78e367cc5d2183d4a39ddfc092 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 14 Dec 2018 18:11:30 +0000 Subject: [PATCH 04/11] split loading status code into a separate function --- src/hardware/hw_bsp.c | 51 +++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index c75d0b48..09620263 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -589,10 +589,36 @@ static inline void SearchDivline(node_t *bsp, fdivline_t *divline) divline->dy = FIXED_TO_FLOAT(bsp->dy); } +#ifdef HWR_LOADING_SCREEN //Hurdler: implement a loading status static size_t ls_count = 0; static UINT8 ls_percent = 0; +static void loading_status(void) +{ + char s[16]; + int x, y; + + I_OsPolling(); + CON_Drawer(); + sprintf(s, "%d%%", (++ls_percent)<<1); + x = BASEVIDWIDTH/2; + y = BASEVIDHEIGHT/2; + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); // Black background to match fade in effect + //V_DrawPatchFill(W_CachePatchName("SRB2BACK",PU_CACHE)); // SRB2 background, ehhh too bright. + M_DrawTextBox(x-58, y-8, 13, 1); + V_DrawString(x-50, y, V_YELLOWMAP, "Loading..."); + V_DrawRightAlignedString(x+50, y, V_YELLOWMAP, s); + + // Is this really necessary at this point..? + V_DrawCenteredString(BASEVIDWIDTH/2, 40, V_YELLOWMAP, "OPENGL MODE IS INCOMPLETE AND MAY"); + V_DrawCenteredString(BASEVIDWIDTH/2, 50, V_YELLOWMAP, "NOT DISPLAY SOME SURFACES."); + V_DrawCenteredString(BASEVIDWIDTH/2, 70, V_YELLOWMAP, "USE AT SONIC'S RISK."); + + I_UpdateNoVsync(); +} +#endif + // poly : the convex polygon that encloses all child subsectors static void WalkBSPNode(INT32 bspnum, poly_t *poly, UINT16 *leafnode, fixed_t *bbox) { @@ -631,32 +657,13 @@ static void WalkBSPNode(INT32 bspnum, poly_t *poly, UINT16 *leafnode, fixed_t *b else { HWR_SubsecPoly(bspnum&(~NF_SUBSECTOR), poly); - //Hurdler: implement a loading status + //Hurdler: implement a loading status #ifdef HWR_LOADING_SCREEN if (ls_count-- <= 0) { - char s[16]; - int x, y; - - I_OsPolling(); ls_count = numsubsectors/50; - CON_Drawer(); - sprintf(s, "%d%%", (++ls_percent)<<1); - x = BASEVIDWIDTH/2; - y = BASEVIDHEIGHT/2; - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); // Black background to match fade in effect - //V_DrawPatchFill(W_CachePatchName("SRB2BACK",PU_CACHE)); // SRB2 background, ehhh too bright. - M_DrawTextBox(x-58, y-8, 13, 1); - V_DrawString(x-50, y, V_YELLOWMAP, "Loading..."); - V_DrawRightAlignedString(x+50, y, V_YELLOWMAP, s); - - // Is this really necessary at this point..? - V_DrawCenteredString(BASEVIDWIDTH/2, 40, V_YELLOWMAP, "OPENGL MODE IS INCOMPLETE AND MAY"); - V_DrawCenteredString(BASEVIDWIDTH/2, 50, V_YELLOWMAP, "NOT DISPLAY SOME SURFACES."); - V_DrawCenteredString(BASEVIDWIDTH/2, 70, V_YELLOWMAP, "USE AT SONIC'S RISK."); - - I_UpdateNoVsync(); + loading_status(); } #endif } @@ -968,7 +975,9 @@ void HWR_CreatePlanePolygons(INT32 bspnum) fixed_t rootbbox[4]; CONS_Debug(DBG_RENDER, "Creating polygons, please wait...\n"); +#ifdef HWR_LOADING_SCREEN ls_count = ls_percent = 0; // reset the loading status +#endif CON_Drawer(); //let the user know what we are doing I_FinishUpdate(); // page flip or blit buffer From b42c306ef36213496910f20ebbd5d593deb59b2b Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 14 Dec 2018 18:14:08 +0000 Subject: [PATCH 05/11] remove code from SearchDivline that was disabled ...and doesn't seem to exist anymore anyway --- src/hardware/hw_bsp.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index 09620263..95978c48 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -581,8 +581,6 @@ static inline void HWR_SubsecPoly(INT32 num, poly_t *poly) // search for the segs source of this divline static inline void SearchDivline(node_t *bsp, fdivline_t *divline) { -#if 0 // MAR - If you don't use the same partition line that the BSP uses, the front/back polys won't match the subsectors in the BSP! -#endif divline->x = FIXED_TO_FLOAT(bsp->x); divline->y = FIXED_TO_FLOAT(bsp->y); divline->dx = FIXED_TO_FLOAT(bsp->dx); From 623d1574cec726852364ad242bdababaf4e291da Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 14 Dec 2018 21:00:53 +0000 Subject: [PATCH 06/11] minor cleanup --- src/hardware/hw_bsp.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index 95978c48..8fec4f96 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -654,7 +654,7 @@ static void WalkBSPNode(INT32 bspnum, poly_t *poly, UINT16 *leafnode, fixed_t *b } else { - HWR_SubsecPoly(bspnum&(~NF_SUBSECTOR), poly); + HWR_SubsecPoly(bspnum & ~NF_SUBSECTOR, poly); //Hurdler: implement a loading status #ifdef HWR_LOADING_SCREEN @@ -666,7 +666,7 @@ static void WalkBSPNode(INT32 bspnum, poly_t *poly, UINT16 *leafnode, fixed_t *b #endif } M_ClearBox(bbox); - poly = extrasubsectors[bspnum&~NF_SUBSECTOR].planepoly; + poly = extrasubsectors[bspnum & ~NF_SUBSECTOR].planepoly; for (i = 0, pt = poly->pts; i < poly->numpts; i++,pt++) M_AddToBox(bbox, FLOAT_TO_FIXED(pt->x), FLOAT_TO_FIXED(pt->y)); @@ -698,14 +698,13 @@ static void WalkBSPNode(INT32 bspnum, poly_t *poly, UINT16 *leafnode, fixed_t *b if (backpoly) { // Correct back bbox to include floor/ceiling convex polygon - WalkBSPNode(bsp->children[1], backpoly, &bsp->children[1], - bsp->bbox[1]); + WalkBSPNode(bsp->children[1], backpoly, &bsp->children[1], bsp->bbox[1]); - // enlarge bbox with seconde child + // enlarge bbox with second child M_AddToBox(bbox, bsp->bbox[1][BOXLEFT ], - bsp->bbox[1][BOXTOP ]); + bsp->bbox[1][BOXTOP ]); M_AddToBox(bbox, bsp->bbox[1][BOXRIGHT ], - bsp->bbox[1][BOXBOTTOM]); + bsp->bbox[1][BOXBOTTOM]); } } @@ -785,9 +784,9 @@ static void SearchSegInBSP(INT32 bspnum,polyvertex_t *p,poly_t *poly) if (bspnum & NF_SUBSECTOR) { - if (bspnum!=-1) + if (bspnum != -1) { - bspnum&=~NF_SUBSECTOR; + bspnum &= ~NF_SUBSECTOR; q = extrasubsectors[bspnum].planepoly; if (poly == q || !q) return; From 09d9a555c65e0fed2329bc79860bb572e2969a22 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 14 Dec 2018 16:21:07 -0500 Subject: [PATCH 07/11] compiler SSE tweak for 32-bit --- src/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index fbf75f26..36cd1608 100644 --- a/src/Makefile +++ b/src/Makefile @@ -288,7 +288,8 @@ OPTS += -DCOMPVERSION ifndef NONX86 ifndef GCC29 - M5=-march=pentium + #M5=-march=pentium + M5=-march=nocona -msse -mfpmath=sse M4=-march=i486 else M5=-mpentium From c1e0041a0bf1becf6902a8290d08c7fe18a36cf8 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 14 Dec 2018 21:22:13 +0000 Subject: [PATCH 08/11] copy doom legacy's replacement for the den == 0.0 calc in fracdivline --- src/hardware/hw_bsp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index 8fec4f96..e0ab5b0d 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -193,7 +193,7 @@ static polyvertex_t *fracdivline(fdivline_t *bsp, polyvertex_t *v1, v2dy = bsp->dy; den = v2dy*v1dx - v2dx*v1dy; - if (den == 0.0) + if (fabs(den) < 1.0E-36f) // avoid checking exactly for 0.0 return NULL; // parallel // first check the frac along the polygon segment, From abae63a64bb99ded02e91d1edf29f33fff5aeb1a Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 14 Dec 2018 16:47:24 -0500 Subject: [PATCH 09/11] SameVertice floating point match; fixes 64-bit OGL holes --- src/hardware/hw_bsp.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index e0ab5b0d..dc49908b 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -254,10 +254,21 @@ static boolean SameVertice (polyvertex_t *p1, polyvertex_t *p2) if (diff < -1.5f || diff > 1.5f) return false; #else +#if 0 if (p1->x != p2->x) return false; if (p1->y != p2->y) return false; +#else +#define DIVLINE_VERTEX_DIFF 0.45f + float ep = DIVLINE_VERTEX_DIFF; + if (fabsf( p2->x - p1->x ) > ep ) + return false; + if (fabsf( p2->y - p1->y ) > ep ) + return false; + // p1 and p2 are considered the same vertex + return true; +#endif #endif // p1 and p2 are considered the same vertex return true; From de96fe8e7b9c00eab7eeef2c8a907a85b19ac5cc Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 14 Dec 2018 16:47:38 -0500 Subject: [PATCH 10/11] Revert "compiler SSE tweak for 32-bit" This reverts commit 09d9a555c65e0fed2329bc79860bb572e2969a22. --- src/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Makefile b/src/Makefile index 36cd1608..fbf75f26 100644 --- a/src/Makefile +++ b/src/Makefile @@ -288,8 +288,7 @@ OPTS += -DCOMPVERSION ifndef NONX86 ifndef GCC29 - #M5=-march=pentium - M5=-march=nocona -msse -mfpmath=sse + M5=-march=pentium M4=-march=i486 else M5=-mpentium From e0079ea1a29c918b8493183f3aeb1622684b7714 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Fri, 14 Dec 2018 23:28:07 +0000 Subject: [PATCH 11/11] remove NearVertice (which was unused anyway), clean up maz's changes --- src/hardware/hw_bsp.c | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/src/hardware/hw_bsp.c b/src/hardware/hw_bsp.c index dc49908b..53602cc7 100644 --- a/src/hardware/hw_bsp.c +++ b/src/hardware/hw_bsp.c @@ -217,29 +217,6 @@ static polyvertex_t *fracdivline(fdivline_t *bsp, polyvertex_t *v1, return &pt; } -#if 0 -//Hurdler: it's not used anymore -static boolean NearVertice (polyvertex_t *p1, polyvertex_t *p2) -{ -#if 1 - float diff; - diff = p2->x - p1->x; - if (diff < -1.5f || diff > 1.5f) - return false; - diff = p2->y - p1->y; - if (diff < -1.5f || diff > 1.5f) - return false; -#else - if (p1->x != p2->x) - return false; - if (p1->y != p2->y) - return false; -#endif - // p1 and p2 are considered the same vertex - return true; -} -#endif - // if two vertice coords have a x and/or y difference // of less or equal than 1 FRACUNIT, they are considered the same // point. Note: hardcoded value, 1.0f could be anything else. @@ -253,8 +230,7 @@ static boolean SameVertice (polyvertex_t *p1, polyvertex_t *p2) diff = p2->y - p1->y; if (diff < -1.5f || diff > 1.5f) return false; -#else -#if 0 +#elif 0 if (p1->x != p2->x) return false; if (p1->y != p2->y) @@ -263,12 +239,9 @@ static boolean SameVertice (polyvertex_t *p1, polyvertex_t *p2) #define DIVLINE_VERTEX_DIFF 0.45f float ep = DIVLINE_VERTEX_DIFF; if (fabsf( p2->x - p1->x ) > ep ) - return false; - if (fabsf( p2->y - p1->y ) > ep ) - return false; - // p1 and p2 are considered the same vertex - return true; -#endif + return false; + if (fabsf( p2->y - p1->y ) > ep ) + return false; #endif // p1 and p2 are considered the same vertex return true;