From ba376dbbfe114aa6ffd4217981252e42852f56e4 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 10 Mar 2024 18:53:18 +0100 Subject: [PATCH 01/25] Port R_PointToPseudoAngle from dsda-doom --- src/m_fixed.h | 35 +++++++++++++++++++++++++++++++++++ src/r_main.c | 34 ++++++++++++++++++++++++++++++++++ src/r_main.h | 1 + 3 files changed, 70 insertions(+) diff --git a/src/m_fixed.h b/src/m_fixed.h index 4e4c79c65..9fe35c91d 100644 --- a/src/m_fixed.h +++ b/src/m_fixed.h @@ -260,6 +260,41 @@ typedef struct fixed_t y; } vector2_t; +// Source: "Know Your FPU: Fixing Floating Fast" +// http://www.stereopsis.com/sree/fpu2006.html +// +// xs_CRoundToInt: Round toward nearest, but ties round toward even (just like FISTP) +// taken from prboom+ for OpenGL big room fix +#ifndef _xs_DEFAULT_CONVERSION +#define _xs_DEFAULT_CONVERSION 0 +#endif //_xs_DEFAULT_CONVERSION + +#ifdef WORDS_BIGENDIAN + #define _xs_iexp_ 0 + #define _xs_iman_ 1 +#else + #define _xs_iexp_ 1 //intel is little endian + #define _xs_iman_ 0 +#endif //BigEndian_ + +typedef double real64; +typedef union _xs_doubleints +{ + real64 val; + unsigned ival[2]; +} _xs_doubleints; + +FUNCMATH FUNCINLINE ATTRINLINE int xs_CRoundToInt(real64 val) +{ +#if _xs_DEFAULT_CONVERSION==0 + _xs_doubleints uval; + uval.val = val + 6755399441055744.0; + return uval.ival[_xs_iman_]; +#else + return int(floor(val+.5)); +#endif +} + vector2_t *FV2_Load(vector2_t *vec, fixed_t x, fixed_t y); vector2_t *FV2_UnLoad(vector2_t *vec, fixed_t *x, fixed_t *y); vector2_t *FV2_Copy(vector2_t *a_o, const vector2_t *a_i); diff --git a/src/r_main.c b/src/r_main.c index 8a975498d..f2609fb5c 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -457,6 +457,40 @@ angle_t R_PointToAngle2(fixed_t pviewx, fixed_t pviewy, fixed_t x, fixed_t y) 0; } +// +// R_PointToPseudoAngle +// ! Returns the pseudoangle between the line p1 to (infinity, p1.y) and the +// line from p1 to p2. The pseudoangle has the property that the ordering of +// points by true angle anround p1 and ordering of points by pseudoangle are the +// same. +// +// For clipping exact angles are not needed. Only the ordering matters. +// This is about as fast as the fixed point R_PointToAngle2 but without +// the precision issues associated with that function. +// + +angle_t R_PointToPseudoAngle (fixed_t x, fixed_t y) +{ + // Note: float won't work here as it's less precise than the BAM values being passed as parameters + double vecx = (double)x - viewx; + double vecy = (double)y - viewy; + double epsilon = 1e-9; + + if (fabs(vecx) < epsilon && fabs(vecy) < epsilon) + { + return 0; + } + else + { + double result = vecy / (fabs(vecx) + fabs(vecy)); + if (vecx < 0) + { + result = 2.0 - result; + } + return (angle_t)xs_CRoundToInt(result * (1 << 30)); + } +} + fixed_t R_PointToDist2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1) { return FixedHypot(px1 - px2, py1 - py2); diff --git a/src/r_main.h b/src/r_main.h index 63c7c3ab5..85bb9e827 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -71,6 +71,7 @@ angle_t R_PointToAngle(fixed_t x, fixed_t y); angle_t R_PointToAngle64(INT64 x, INT64 y); angle_t R_PointToAngleEx(INT32 x2, INT32 y2, INT32 x1, INT32 y1); angle_t R_PointToAngle2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1); +angle_t R_PointToPseudoAngle (fixed_t x, fixed_t y); fixed_t R_PointToDist(fixed_t x, fixed_t y); fixed_t R_PointToDist2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1); angle_t R_PlayerSliptideAngle(player_t *player); -- 2.54.0 From 50ba93541dfbbef9bb5d676ed2ab75cde7a94488 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 10 Mar 2024 17:59:24 +0100 Subject: [PATCH 02/25] i am in pain --- src/hardware/hw_clip.c | 264 ------------------------------ src/hardware/hw_main.c | 3 + src/hardware/r_opengl/r_opengl.c | 272 ++++++++++++++++++++++++++++++- 3 files changed, 274 insertions(+), 265 deletions(-) diff --git a/src/hardware/hw_clip.c b/src/hardware/hw_clip.c index 8ef5636aa..9e161b2ea 100644 --- a/src/hardware/hw_clip.c +++ b/src/hardware/hw_clip.c @@ -84,271 +84,7 @@ static GLdouble projMatrix[16]; float frustum[6][4]; #endif -typedef struct clipnode_s - { - struct clipnode_s *prev, *next; - angle_t start, end; - } clipnode_t; -clipnode_t *freelist; -clipnode_t *clipnodes; -clipnode_t *cliphead; - -static clipnode_t * gld_clipnode_GetNew(void); -static clipnode_t * gld_clipnode_NewRange(angle_t start, angle_t end); -static boolean gld_clipper_IsRangeVisible(angle_t startAngle, angle_t endAngle); -static void gld_clipper_AddClipRange(angle_t start, angle_t end); -static void gld_clipper_RemoveRange(clipnode_t * range); -static void gld_clipnode_Free(clipnode_t *node); - -static clipnode_t * gld_clipnode_GetNew(void) -{ - if (freelist) - { - clipnode_t * p = freelist; - freelist = p->next; - return p; - } - else - { - return (clipnode_t*)malloc(sizeof(clipnode_t)); - } -} - -static clipnode_t * gld_clipnode_NewRange(angle_t start, angle_t end) -{ - clipnode_t * c = gld_clipnode_GetNew(); - c->start = start; - c->end = end; - c->next = c->prev=NULL; - return c; -} - -boolean gld_clipper_SafeCheckRange(angle_t startAngle, angle_t endAngle) -{ - if(startAngle > endAngle) - { - return (gld_clipper_IsRangeVisible(startAngle, ANGLE_MAX) || gld_clipper_IsRangeVisible(0, endAngle)); - } - - return gld_clipper_IsRangeVisible(startAngle, endAngle); -} - -static boolean gld_clipper_IsRangeVisible(angle_t startAngle, angle_t endAngle) -{ - clipnode_t *ci; - ci = cliphead; - - if (endAngle == 0 && ci && ci->start == 0) - return false; - - while (ci != NULL && ci->start < endAngle) - { - if (startAngle >= ci->start && endAngle <= ci->end) - { - return false; - } - ci = ci->next; - } - - return true; -} - -static void gld_clipnode_Free(clipnode_t *node) -{ - node->next = freelist; - freelist = node; -} - -static void gld_clipper_RemoveRange(clipnode_t *range) -{ - if (range == cliphead) - { - cliphead = cliphead->next; - } - else - { - if (range->prev) - { - range->prev->next = range->next; - } - if (range->next) - { - range->next->prev = range->prev; - } - } - - gld_clipnode_Free(range); -} - -void gld_clipper_SafeAddClipRange(angle_t startangle, angle_t endangle) -{ - if(startangle > endangle) - { - // The range has to added in two parts. - gld_clipper_AddClipRange(startangle, ANGLE_MAX); - gld_clipper_AddClipRange(0, endangle); - } - else - { - // Add the range as usual. - gld_clipper_AddClipRange(startangle, endangle); - } -} - -static void gld_clipper_AddClipRange(angle_t start, angle_t end) -{ - clipnode_t *node, *temp, *prevNode, *node2, *delnode; - - if (cliphead) - { - //check to see if range contains any old ranges - node = cliphead; - while (node != NULL && node->start < end) - { - if (node->start >= start && node->end <= end) - { - temp = node; - node = node->next; - gld_clipper_RemoveRange(temp); - } - else - { - if (node->start <= start && node->end >= end) - { - return; - } - else - { - node = node->next; - } - } - } - - //check to see if range overlaps a range (or possibly 2) - node = cliphead; - while (node != NULL && node->start <= end) - { - if (node->end >= start) - { - // we found the first overlapping node - if (node->start > start) - { - // the new range overlaps with this node's start point - node->start = start; - } - if (node->end < end) - { - node->end = end; - } - - node2 = node->next; - while (node2 && node2->start <= node->end) - { - if (node2->end > node->end) - { - node->end = node2->end; - } - - delnode = node2; - node2 = node2->next; - gld_clipper_RemoveRange(delnode); - } - return; - } - node = node->next; - } - - //just add range - node = cliphead; - prevNode = NULL; - temp = gld_clipnode_NewRange(start, end); - while (node != NULL && node->start < end) - { - prevNode = node; - node = node->next; - } - temp->next = node; - if (node == NULL) - { - temp->prev = prevNode; - if (prevNode) - { - prevNode->next = temp; - } - if (!cliphead) - { - cliphead = temp; - } - } - else - { - if (node == cliphead) - { - cliphead->prev = temp; - cliphead = temp; - } - else - { - temp->prev = prevNode; - prevNode->next = temp; - node->prev = temp; - } - } - } - else - { - temp = gld_clipnode_NewRange(start, end); - cliphead = temp; - return; - } -} - -void gld_clipper_Clear(void) -{ - clipnode_t *node = cliphead; - clipnode_t *temp; - - while (node != NULL) - { - temp = node; - node = node->next; - gld_clipnode_Free(temp); - } - - cliphead = NULL; -} - -#define RMUL (1.6f/1.333333f) - -angle_t gld_FrustumAngle(angle_t tiltangle) -{ - double floatangle; - angle_t a1; - - float tilt = (float)fabs(((double)(int)tiltangle) / ANG1); - - // NEWCLIP TODO: SRB2CBTODO: make a global render_fov for this function - - float render_fov = FIXED_TO_FLOAT(cv_fov.value); - float render_fovratio = (float)BASEVIDWIDTH / (float)BASEVIDHEIGHT; // SRB2CBTODO: NEWCLIPTODO: Is this right? - float render_multiplier = 64.0f / render_fovratio / RMUL; - - if (tilt > 90.0f) - tilt = 90.0f; - - // If the pitch is larger than this you can look all around at a FOV of 90 - if (abs((signed)tiltangle) > 46 * ANG1) - return 0xffffffff; - - // ok, this is a gross hack that barely works... - // but at least it doesn't overestimate too much... - floatangle = 2.0f + (45.0f + (tilt / 1.9f)) * (float)render_fov * 48.0f / render_multiplier / 90.0f; - a1 = ANG1 * (int)floatangle; - if (a1 >= ANGLE_180) - return 0xffffffff; - return a1; -} // SRB2CB I don't think used any of this stuff, let's disable for now since SRB2 probably doesn't want it either // compiler complains about (p)glGetFloatv anyway, in case anyone wants this diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 66e520726..e5b775d3f 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5891,6 +5891,9 @@ void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox) } HWR_ClearClipper(); + + // Set transform. + HWD.pfnSetTransform(&atransform); // Reset the shader state. //HWR_SetShaderState(); diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index bb5c1fe3d..33a431015 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -28,6 +28,7 @@ #include "r_vbo.h" #include "../hw_shaders.h" #include "../hw_main.h" +#include "../hw_clip.h" // Eeeeh not sure is this right way, but it works < sry :c < sry again it had to go :c @@ -884,9 +885,11 @@ static void GLPerspective(GLfloat fovy, GLfloat aspect) m[1][1] = cotangent; m[2][2] = -(zFar + zNear) / deltaZ; m[3][2] = -2.0f * zNear * zFar / deltaZ; + pglMultMatrixf(&m[0][0]); } + // -----------------+ // SetModelView : // -----------------+ @@ -2725,7 +2728,9 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform) static boolean special_splitscreen; GLdouble used_fov; boolean shearing = false; + pglLoadIdentity(); + if (stransform) { used_fov = stransform->fovxangle; @@ -2746,7 +2751,7 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform) if (stransform->roll) pglRotatef(stransform->rollangle, 0.0f, 0.0f, 1.0f); - pglRotatef(stransform->anglex, 1.0f, 0.0f, 0.0f); + pglRotatef(stransform->anglex , 1.0f, 0.0f, 0.0f); pglRotatef(stransform->angley+270.0f, 0.0f, 1.0f, 0.0f); pglTranslatef(-stransform->x, -stransform->z, -stransform->y); @@ -2780,6 +2785,7 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform) } else GLPerspective((GLfloat)used_fov, ASPECT_RATIO); + pglGetFloatv(GL_PROJECTION_MATRIX, projMatrix); // added for new coronas' code (without depth buffer) pglMatrixMode(GL_MODELVIEW); @@ -3347,4 +3353,268 @@ EXPORT void HWRAPI(SetScreenPalette)(RGBA_t *palette) } } +typedef struct clipnode_s + { + struct clipnode_s *prev, *next; + angle_t start, end; + } clipnode_t; + +clipnode_t *freelist; +clipnode_t *clipnodes; +clipnode_t *cliphead; + +static clipnode_t * gld_clipnode_GetNew(void); +static clipnode_t * gld_clipnode_NewRange(angle_t start, angle_t end); +static boolean gld_clipper_IsRangeVisible(angle_t startAngle, angle_t endAngle); +static void gld_clipper_AddClipRange(angle_t start, angle_t end); +static void gld_clipper_RemoveRange(clipnode_t * range); +static void gld_clipnode_Free(clipnode_t *node); + +static clipnode_t * gld_clipnode_GetNew(void) +{ + if (freelist) + { + clipnode_t * p = freelist; + freelist = p->next; + return p; + } + else + { + return (clipnode_t*)malloc(sizeof(clipnode_t)); + } +} + +static clipnode_t * gld_clipnode_NewRange(angle_t start, angle_t end) +{ + clipnode_t * c = gld_clipnode_GetNew(); + c->start = start; + c->end = end; + c->next = c->prev=NULL; + return c; +} + +boolean gld_clipper_SafeCheckRange(angle_t startAngle, angle_t endAngle) +{ + if(startAngle > endAngle) + { + return (gld_clipper_IsRangeVisible(startAngle, ANGLE_MAX) || gld_clipper_IsRangeVisible(0, endAngle)); + } + + return gld_clipper_IsRangeVisible(startAngle, endAngle); +} + +static boolean gld_clipper_IsRangeVisible(angle_t startAngle, angle_t endAngle) +{ + clipnode_t *ci; + ci = cliphead; + + if (endAngle == 0 && ci && ci->start == 0) + return false; + + while (ci != NULL && ci->start < endAngle) + { + if (startAngle >= ci->start && endAngle <= ci->end) + { + return false; + } + ci = ci->next; + } + + return true; +} + +static void gld_clipnode_Free(clipnode_t *node) +{ + node->next = freelist; + freelist = node; +} + +static void gld_clipper_RemoveRange(clipnode_t *range) +{ + if (range == cliphead) + { + cliphead = cliphead->next; + } + else + { + if (range->prev) + { + range->prev->next = range->next; + } + if (range->next) + { + range->next->prev = range->prev; + } + } + + gld_clipnode_Free(range); +} + +void gld_clipper_SafeAddClipRange(angle_t startangle, angle_t endangle) +{ + if(startangle > endangle) + { + // The range has to added in two parts. + gld_clipper_AddClipRange(startangle, ANGLE_MAX); + gld_clipper_AddClipRange(0, endangle); + } + else + { + // Add the range as usual. + gld_clipper_AddClipRange(startangle, endangle); + } +} + +static void gld_clipper_AddClipRange(angle_t start, angle_t end) +{ + clipnode_t *node, *temp, *prevNode, *node2, *delnode; + + if (cliphead) + { + //check to see if range contains any old ranges + node = cliphead; + while (node != NULL && node->start < end) + { + if (node->start >= start && node->end <= end) + { + temp = node; + node = node->next; + gld_clipper_RemoveRange(temp); + } + else + { + if (node->start <= start && node->end >= end) + { + return; + } + else + { + node = node->next; + } + } + } + + //check to see if range overlaps a range (or possibly 2) + node = cliphead; + while (node != NULL && node->start <= end) + { + if (node->end >= start) + { + // we found the first overlapping node + if (node->start > start) + { + // the new range overlaps with this node's start point + node->start = start; + } + if (node->end < end) + { + node->end = end; + } + + node2 = node->next; + while (node2 && node2->start <= node->end) + { + if (node2->end > node->end) + { + node->end = node2->end; + } + + delnode = node2; + node2 = node2->next; + gld_clipper_RemoveRange(delnode); + } + return; + } + node = node->next; + } + + //just add range + node = cliphead; + prevNode = NULL; + temp = gld_clipnode_NewRange(start, end); + while (node != NULL && node->start < end) + { + prevNode = node; + node = node->next; + } + temp->next = node; + if (node == NULL) + { + temp->prev = prevNode; + if (prevNode) + { + prevNode->next = temp; + } + if (!cliphead) + { + cliphead = temp; + } + } + else + { + if (node == cliphead) + { + cliphead->prev = temp; + cliphead = temp; + } + else + { + temp->prev = prevNode; + prevNode->next = temp; + node->prev = temp; + } + } + } + else + { + temp = gld_clipnode_NewRange(start, end); + cliphead = temp; + return; + } +} + +void gld_clipper_Clear(void) +{ + clipnode_t *node = cliphead; + clipnode_t *temp; + + while (node != NULL) + { + temp = node; + node = node->next; + gld_clipnode_Free(temp); + } + + cliphead = NULL; +} + +#define RMUL (1.6f/1.333333f) + +angle_t gld_FrustumAngle(angle_t tiltangle) +{ + double fov2; + double floatangle; + angle_t a1; + + float tilt = (float)fabs(((double)(int)tiltangle) / ANG1); + + // NEWCLIP TODO: SRB2CBTODO: make a global render_fov for this function + + if (tilt > 90.0f) + tilt = 90.0f; + + // If the pitch is larger than this you can look all around at a FOV of 90 + if (abs((signed)tiltangle) > 46 * ANG1) + return 0xffffffff; + + // ok, this is a gross hack that barely works... + // but at least it doesn't overestimate too much... + fov2 = atan(1 / projMatrix[0]) * 360 / M_PIl; + floatangle = 2.0f + (45.0f + (tilt / 1.9f)) * fov2 / 90.0f; + if (floatangle >= 180.0) + return 0xffffffff; + a1 = (angle_t)xs_CRoundToInt(ANG1 * floatangle); + return a1; +} + #endif //HWRENDER -- 2.54.0 From 8ec7e2321756aed53fc625e3f7246d38d49f54b5 Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 10 Mar 2024 18:50:38 +0100 Subject: [PATCH 03/25] clean up stuff a little --- src/hardware/hw_clip.c | 17 +++++------------ src/hardware/hw_clip.h | 2 +- src/hardware/hw_main.c | 2 +- src/hardware/r_opengl/r_opengl.c | 10 ++++++++++ src/m_menu.c | 4 +++- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/hardware/hw_clip.c b/src/hardware/hw_clip.c index 9e161b2ea..d8f42e624 100644 --- a/src/hardware/hw_clip.c +++ b/src/hardware/hw_clip.c @@ -68,15 +68,10 @@ ** */ -#include -#include "../v_video.h" -#include "hw_main.h" #include "hw_clip.h" -#include "hw_glob.h" -#include "../r_state.h" -#include "../tables.h" -#include "r_opengl/r_opengl.h" -#include "../r_main.h" // for cv_fov + +// clipping code moved to r_opengl.c, let me qoute the below comment "only r_opengl.c can use the base gl funcs as it turns out.." + #ifdef HAVE_SPHEREFRUSTRUM static GLdouble viewMatrix[16]; @@ -84,15 +79,13 @@ static GLdouble projMatrix[16]; float frustum[6][4]; #endif - - // SRB2CB I don't think used any of this stuff, let's disable for now since SRB2 probably doesn't want it either // compiler complains about (p)glGetFloatv anyway, in case anyone wants this // only r_opengl.c can use the base gl funcs as it turns out, that's a problem for whoever wants sphere frustum checks // btw to renable define HAVE_SPHEREFRUSTRUM in hw_clip.h #ifdef HAVE_SPHEREFRUSTRUM // -// gld_FrustrumSetup +// gld_FrustumSetup // #define CALCMATRIX(a, b, c, d, e, f, g, h)\ @@ -111,7 +104,7 @@ frustum[i][1] /= t; \ frustum[i][2] /= t; \ frustum[i][3] /= t -void gld_FrustrumSetup(void) +void gld_FrustumSetup(void) { float t; float clip[16]; diff --git a/src/hardware/hw_clip.h b/src/hardware/hw_clip.h index 27a2ed1ef..dfaa87f81 100644 --- a/src/hardware/hw_clip.h +++ b/src/hardware/hw_clip.h @@ -19,6 +19,6 @@ void gld_clipper_SafeAddClipRange(angle_t startangle, angle_t endangle); void gld_clipper_Clear(void); angle_t gld_FrustumAngle(angle_t tiltangle); #ifdef HAVE_SPHEREFRUSTRUM -void gld_FrustrumSetup(void); +void gld_FrustumSetup(void); boolean gld_SphereInFrustum(float x, float y, float z, float radius); #endif diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index e5b775d3f..e946fc1d6 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5545,7 +5545,7 @@ void HWR_ClearClipper(void) gld_clipper_Clear(); gld_clipper_SafeAddClipRange(viewangle + a1, viewangle - a1); #ifdef HAVE_SPHEREFRUSTRUM - gld_FrustrumSetup(); + gld_FrustumSetup(); #endif } diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 33a431015..174813eeb 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -3353,6 +3353,16 @@ EXPORT void HWRAPI(SetScreenPalette)(RGBA_t *palette) } } + +/* + * hw_clip + * SRB2CB + * + * PrBoom's OpenGL clipping + * + * + */ + typedef struct clipnode_s { struct clipnode_s *prev, *next; diff --git a/src/m_menu.c b/src/m_menu.c index 5cf720be7..a9cac9ecd 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4338,7 +4338,9 @@ void M_Init(void) OP_ExpOptionsMenu[op_exp_fofcut].status = IT_DISABLED; } - if (rendermode == render_opengl){ + if (rendermode == render_opengl) + { + OP_ExpOptionsMenu[op_exp_angleshit].status = IT_DISABLED; OP_ExpOptionsMenu[op_exp_ffclip].status = IT_DISABLED; OP_ExpOptionsMenu[op_exp_sprclip].status = IT_DISABLED; } -- 2.54.0 From d802970bc4d34cb97935dc477f2bb47038eaab9e Mon Sep 17 00:00:00 2001 From: Indev Date: Sun, 10 Mar 2024 21:41:49 +0300 Subject: [PATCH 04/25] Snap viewpoint text to bottom --- src/st_stuff.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index 1c31f1f1e..881ab5fcc 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -799,16 +799,16 @@ static void ST_overlayDrawer(void) strlcpy(name, player_names[stplyr-players], 13);*/ // Show name of player being displayed - V_DrawCenteredString((BASEVIDWIDTH/2), BASEVIDHEIGHT-40, V_HUDTRANS, M_GetText("VIEWPOINT:")); - V_DrawCenteredString((BASEVIDWIDTH/2), BASEVIDHEIGHT-32, V_HUDTRANS|V_ALLOWLOWERCASE, player_names[stplyr-players]); + V_DrawCenteredString((BASEVIDWIDTH/2), BASEVIDHEIGHT-40, V_SNAPTOBOTTOM|V_HUDTRANS, M_GetText("VIEWPOINT:")); + V_DrawCenteredString((BASEVIDWIDTH/2), BASEVIDHEIGHT-32, V_SNAPTOBOTTOM|V_HUDTRANS|V_ALLOWLOWERCASE, player_names[stplyr-players]); } } else if (!demo.title) { if (!splitscreen) { - V_DrawCenteredString((BASEVIDWIDTH/2), BASEVIDHEIGHT-40, V_HUDTRANSHALF, M_GetText("VIEWPOINT:")); - V_DrawCenteredString((BASEVIDWIDTH/2), BASEVIDHEIGHT-32, V_HUDTRANSHALF|V_ALLOWLOWERCASE, player_names[stplyr-players]); + V_DrawCenteredString((BASEVIDWIDTH/2), BASEVIDHEIGHT-40, V_SNAPTOBOTTOM|V_HUDTRANSHALF, M_GetText("VIEWPOINT:")); + V_DrawCenteredString((BASEVIDWIDTH/2), BASEVIDHEIGHT-32, V_SNAPTOBOTTOM|V_HUDTRANSHALF|V_ALLOWLOWERCASE, player_names[stplyr-players]); } else if (splitscreen == 1) { -- 2.54.0 From e77453e43a129b2d87c2c5b63270b97200567d5b Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 11 Mar 2024 02:15:34 +0100 Subject: [PATCH 05/25] actually move stuff back to hw_clip lmao --- src/hardware/hw_clip.c | 282 ++++++++++++++++++++++++++++++- src/hardware/r_opengl/r_opengl.c | 276 +----------------------------- src/hardware/r_opengl/r_opengl.h | 2 + 3 files changed, 279 insertions(+), 281 deletions(-) diff --git a/src/hardware/hw_clip.c b/src/hardware/hw_clip.c index d8f42e624..594a0aa87 100644 --- a/src/hardware/hw_clip.c +++ b/src/hardware/hw_clip.c @@ -68,16 +68,282 @@ ** */ + +#include +#include "../v_video.h" +#include "hw_main.h" #include "hw_clip.h" +#include "hw_glob.h" +#include "../r_state.h" +#include "../tables.h" +#include "r_opengl/r_opengl.h" -// clipping code moved to r_opengl.c, let me qoute the below comment "only r_opengl.c can use the base gl funcs as it turns out.." + +typedef struct clipnode_s + { + struct clipnode_s *prev, *next; + angle_t start, end; + } clipnode_t; + +clipnode_t *freelist; +clipnode_t *clipnodes; +clipnode_t *cliphead; + +static clipnode_t * gld_clipnode_GetNew(void); +static clipnode_t * gld_clipnode_NewRange(angle_t start, angle_t end); +static boolean gld_clipper_IsRangeVisible(angle_t startAngle, angle_t endAngle); +static void gld_clipper_AddClipRange(angle_t start, angle_t end); +static void gld_clipper_RemoveRange(clipnode_t * range); +static void gld_clipnode_Free(clipnode_t *node); + +static clipnode_t * gld_clipnode_GetNew(void) +{ + if (freelist) + { + clipnode_t * p = freelist; + freelist = p->next; + return p; + } + else + { + return (clipnode_t*)malloc(sizeof(clipnode_t)); + } +} + +static clipnode_t * gld_clipnode_NewRange(angle_t start, angle_t end) +{ + clipnode_t * c = gld_clipnode_GetNew(); + c->start = start; + c->end = end; + c->next = c->prev=NULL; + return c; +} + +boolean gld_clipper_SafeCheckRange(angle_t startAngle, angle_t endAngle) +{ + if(startAngle > endAngle) + { + return (gld_clipper_IsRangeVisible(startAngle, ANGLE_MAX) || gld_clipper_IsRangeVisible(0, endAngle)); + } + + return gld_clipper_IsRangeVisible(startAngle, endAngle); +} + +static boolean gld_clipper_IsRangeVisible(angle_t startAngle, angle_t endAngle) +{ + clipnode_t *ci; + ci = cliphead; + + if (endAngle == 0 && ci && ci->start == 0) + return false; + + while (ci != NULL && ci->start < endAngle) + { + if (startAngle >= ci->start && endAngle <= ci->end) + { + return false; + } + ci = ci->next; + } + + return true; +} + +static void gld_clipnode_Free(clipnode_t *node) +{ + node->next = freelist; + freelist = node; +} + +static void gld_clipper_RemoveRange(clipnode_t *range) +{ + if (range == cliphead) + { + cliphead = cliphead->next; + } + else + { + if (range->prev) + { + range->prev->next = range->next; + } + if (range->next) + { + range->next->prev = range->prev; + } + } + + gld_clipnode_Free(range); +} + +void gld_clipper_SafeAddClipRange(angle_t startangle, angle_t endangle) +{ + if(startangle > endangle) + { + // The range has to added in two parts. + gld_clipper_AddClipRange(startangle, ANGLE_MAX); + gld_clipper_AddClipRange(0, endangle); + } + else + { + // Add the range as usual. + gld_clipper_AddClipRange(startangle, endangle); + } +} + +static void gld_clipper_AddClipRange(angle_t start, angle_t end) +{ + clipnode_t *node, *temp, *prevNode, *node2, *delnode; + + if (cliphead) + { + //check to see if range contains any old ranges + node = cliphead; + while (node != NULL && node->start < end) + { + if (node->start >= start && node->end <= end) + { + temp = node; + node = node->next; + gld_clipper_RemoveRange(temp); + } + else + { + if (node->start <= start && node->end >= end) + { + return; + } + else + { + node = node->next; + } + } + } + + //check to see if range overlaps a range (or possibly 2) + node = cliphead; + while (node != NULL && node->start <= end) + { + if (node->end >= start) + { + // we found the first overlapping node + if (node->start > start) + { + // the new range overlaps with this node's start point + node->start = start; + } + if (node->end < end) + { + node->end = end; + } + + node2 = node->next; + while (node2 && node2->start <= node->end) + { + if (node2->end > node->end) + { + node->end = node2->end; + } + + delnode = node2; + node2 = node2->next; + gld_clipper_RemoveRange(delnode); + } + return; + } + node = node->next; + } + + //just add range + node = cliphead; + prevNode = NULL; + temp = gld_clipnode_NewRange(start, end); + while (node != NULL && node->start < end) + { + prevNode = node; + node = node->next; + } + temp->next = node; + if (node == NULL) + { + temp->prev = prevNode; + if (prevNode) + { + prevNode->next = temp; + } + if (!cliphead) + { + cliphead = temp; + } + } + else + { + if (node == cliphead) + { + cliphead->prev = temp; + cliphead = temp; + } + else + { + temp->prev = prevNode; + prevNode->next = temp; + node->prev = temp; + } + } + } + else + { + temp = gld_clipnode_NewRange(start, end); + cliphead = temp; + return; + } +} + +void gld_clipper_Clear(void) +{ + clipnode_t *node = cliphead; + clipnode_t *temp; + + while (node != NULL) + { + temp = node; + node = node->next; + gld_clipnode_Free(temp); + } + + cliphead = NULL; +} + +#define RMUL (1.6f/1.333333f) + +angle_t gld_FrustumAngle(angle_t tiltangle) +{ + double fov2; + double floatangle; + angle_t a1; + + float tilt = (float)fabs(((double)(int)tiltangle) / ANG1); + + // NEWCLIP TODO: SRB2CBTODO: make a global render_fov for this function + + if (tilt > 90.0f) + tilt = 90.0f; + + // If the pitch is larger than this you can look all around at a FOV of 90 + if (abs((signed)tiltangle) > 46 * ANG1) + return 0xffffffff; + + // ok, this is a gross hack that barely works... + // but at least it doesn't overestimate too much... + fov2 = atan(1 / projMatrix[0]) * 360 / M_PIl; + floatangle = 2.0f + (45.0f + (tilt / 1.9f)) * fov2 / 90.0f; + if (floatangle >= 180.0) + return 0xffffffff; + a1 = (angle_t)xs_CRoundToInt(ANG1 * floatangle); + return a1; +} -#ifdef HAVE_SPHEREFRUSTRUM -static GLdouble viewMatrix[16]; -static GLdouble projMatrix[16]; -float frustum[6][4]; -#endif // SRB2CB I don't think used any of this stuff, let's disable for now since SRB2 probably doesn't want it either // compiler complains about (p)glGetFloatv anyway, in case anyone wants this @@ -88,6 +354,10 @@ float frustum[6][4]; // gld_FrustumSetup // +static GLdouble viewMatrix[16]; +static GLdouble projMatrix[16]; +float frustum[6][4]; + #define CALCMATRIX(a, b, c, d, e, f, g, h)\ (float)(viewMatrix[a] * projMatrix[b] + \ viewMatrix[c] * projMatrix[d] + \ diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 174813eeb..e287d681d 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -111,7 +111,7 @@ const GLubyte *gl_extensions = NULL; //Hurdler: 04/10/2000: added for the kick ass coronas as Boris wanted;-) static GLfloat modelMatrix[16]; -static GLfloat projMatrix[16]; +GLfloat projMatrix[16]; static GLint viewport[4]; @@ -3353,278 +3353,4 @@ EXPORT void HWRAPI(SetScreenPalette)(RGBA_t *palette) } } - -/* - * hw_clip - * SRB2CB - * - * PrBoom's OpenGL clipping - * - * - */ - -typedef struct clipnode_s - { - struct clipnode_s *prev, *next; - angle_t start, end; - } clipnode_t; - -clipnode_t *freelist; -clipnode_t *clipnodes; -clipnode_t *cliphead; - -static clipnode_t * gld_clipnode_GetNew(void); -static clipnode_t * gld_clipnode_NewRange(angle_t start, angle_t end); -static boolean gld_clipper_IsRangeVisible(angle_t startAngle, angle_t endAngle); -static void gld_clipper_AddClipRange(angle_t start, angle_t end); -static void gld_clipper_RemoveRange(clipnode_t * range); -static void gld_clipnode_Free(clipnode_t *node); - -static clipnode_t * gld_clipnode_GetNew(void) -{ - if (freelist) - { - clipnode_t * p = freelist; - freelist = p->next; - return p; - } - else - { - return (clipnode_t*)malloc(sizeof(clipnode_t)); - } -} - -static clipnode_t * gld_clipnode_NewRange(angle_t start, angle_t end) -{ - clipnode_t * c = gld_clipnode_GetNew(); - c->start = start; - c->end = end; - c->next = c->prev=NULL; - return c; -} - -boolean gld_clipper_SafeCheckRange(angle_t startAngle, angle_t endAngle) -{ - if(startAngle > endAngle) - { - return (gld_clipper_IsRangeVisible(startAngle, ANGLE_MAX) || gld_clipper_IsRangeVisible(0, endAngle)); - } - - return gld_clipper_IsRangeVisible(startAngle, endAngle); -} - -static boolean gld_clipper_IsRangeVisible(angle_t startAngle, angle_t endAngle) -{ - clipnode_t *ci; - ci = cliphead; - - if (endAngle == 0 && ci && ci->start == 0) - return false; - - while (ci != NULL && ci->start < endAngle) - { - if (startAngle >= ci->start && endAngle <= ci->end) - { - return false; - } - ci = ci->next; - } - - return true; -} - -static void gld_clipnode_Free(clipnode_t *node) -{ - node->next = freelist; - freelist = node; -} - -static void gld_clipper_RemoveRange(clipnode_t *range) -{ - if (range == cliphead) - { - cliphead = cliphead->next; - } - else - { - if (range->prev) - { - range->prev->next = range->next; - } - if (range->next) - { - range->next->prev = range->prev; - } - } - - gld_clipnode_Free(range); -} - -void gld_clipper_SafeAddClipRange(angle_t startangle, angle_t endangle) -{ - if(startangle > endangle) - { - // The range has to added in two parts. - gld_clipper_AddClipRange(startangle, ANGLE_MAX); - gld_clipper_AddClipRange(0, endangle); - } - else - { - // Add the range as usual. - gld_clipper_AddClipRange(startangle, endangle); - } -} - -static void gld_clipper_AddClipRange(angle_t start, angle_t end) -{ - clipnode_t *node, *temp, *prevNode, *node2, *delnode; - - if (cliphead) - { - //check to see if range contains any old ranges - node = cliphead; - while (node != NULL && node->start < end) - { - if (node->start >= start && node->end <= end) - { - temp = node; - node = node->next; - gld_clipper_RemoveRange(temp); - } - else - { - if (node->start <= start && node->end >= end) - { - return; - } - else - { - node = node->next; - } - } - } - - //check to see if range overlaps a range (or possibly 2) - node = cliphead; - while (node != NULL && node->start <= end) - { - if (node->end >= start) - { - // we found the first overlapping node - if (node->start > start) - { - // the new range overlaps with this node's start point - node->start = start; - } - if (node->end < end) - { - node->end = end; - } - - node2 = node->next; - while (node2 && node2->start <= node->end) - { - if (node2->end > node->end) - { - node->end = node2->end; - } - - delnode = node2; - node2 = node2->next; - gld_clipper_RemoveRange(delnode); - } - return; - } - node = node->next; - } - - //just add range - node = cliphead; - prevNode = NULL; - temp = gld_clipnode_NewRange(start, end); - while (node != NULL && node->start < end) - { - prevNode = node; - node = node->next; - } - temp->next = node; - if (node == NULL) - { - temp->prev = prevNode; - if (prevNode) - { - prevNode->next = temp; - } - if (!cliphead) - { - cliphead = temp; - } - } - else - { - if (node == cliphead) - { - cliphead->prev = temp; - cliphead = temp; - } - else - { - temp->prev = prevNode; - prevNode->next = temp; - node->prev = temp; - } - } - } - else - { - temp = gld_clipnode_NewRange(start, end); - cliphead = temp; - return; - } -} - -void gld_clipper_Clear(void) -{ - clipnode_t *node = cliphead; - clipnode_t *temp; - - while (node != NULL) - { - temp = node; - node = node->next; - gld_clipnode_Free(temp); - } - - cliphead = NULL; -} - -#define RMUL (1.6f/1.333333f) - -angle_t gld_FrustumAngle(angle_t tiltangle) -{ - double fov2; - double floatangle; - angle_t a1; - - float tilt = (float)fabs(((double)(int)tiltangle) / ANG1); - - // NEWCLIP TODO: SRB2CBTODO: make a global render_fov for this function - - if (tilt > 90.0f) - tilt = 90.0f; - - // If the pitch is larger than this you can look all around at a FOV of 90 - if (abs((signed)tiltangle) > 46 * ANG1) - return 0xffffffff; - - // ok, this is a gross hack that barely works... - // but at least it doesn't overestimate too much... - fov2 = atan(1 / projMatrix[0]) * 360 / M_PIl; - floatangle = 2.0f + (45.0f + (tilt / 1.9f)) * fov2 / 90.0f; - if (floatangle >= 180.0) - return 0xffffffff; - a1 = (angle_t)xs_CRoundToInt(ANG1 * floatangle); - return a1; -} - #endif //HWRENDER diff --git a/src/hardware/r_opengl/r_opengl.h b/src/hardware/r_opengl/r_opengl.h index ba3cccbce..34b2d3cf7 100644 --- a/src/hardware/r_opengl/r_opengl.h +++ b/src/hardware/r_opengl/r_opengl.h @@ -123,6 +123,8 @@ extern GLint maximumAnisotropy; extern INT32 oglflags; extern GLint textureformatGL; +extern GLfloat projMatrix[16]; + typedef enum { GLF_NOZBUFREAD = 0x01, -- 2.54.0 From 5ade9699c1e77199e080d943f187862d2b969b1d Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 11 Mar 2024 02:22:40 +0100 Subject: [PATCH 06/25] give this a better name lol --- src/hardware/hw_clip.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_clip.c b/src/hardware/hw_clip.c index 594a0aa87..be8b21dcd 100644 --- a/src/hardware/hw_clip.c +++ b/src/hardware/hw_clip.c @@ -318,7 +318,7 @@ void gld_clipper_Clear(void) angle_t gld_FrustumAngle(angle_t tiltangle) { - double fov2; + double clipfov; double floatangle; angle_t a1; @@ -335,8 +335,8 @@ angle_t gld_FrustumAngle(angle_t tiltangle) // ok, this is a gross hack that barely works... // but at least it doesn't overestimate too much... - fov2 = atan(1 / projMatrix[0]) * 360 / M_PIl; - floatangle = 2.0f + (45.0f + (tilt / 1.9f)) * fov2 / 90.0f; + clipfov = atan(1 / projMatrix[0]) * 360 / M_PIl; + floatangle = 2.0f + (45.0f + (tilt / 1.9f)) * clipfov / 90.0f; if (floatangle >= 180.0) return 0xffffffff; a1 = (angle_t)xs_CRoundToInt(ANG1 * floatangle); -- 2.54.0 From 95f51a26c1a28e50b4e05d4ef9aead7051dc19ca Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 11 Mar 2024 03:40:13 +0100 Subject: [PATCH 07/25] attempt at unfucking renderview --- src/hardware/hw_main.c | 95 +++++------------------------------------- 1 file changed, 11 insertions(+), 84 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index e946fc1d6..6b7d4f8c7 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -271,8 +271,6 @@ FTransform atransform; static float gr_viewx, gr_viewy, gr_viewz; float gr_viewsin, gr_viewcos; -static fixed_t dup_viewx, dup_viewy, dup_viewz; - static angle_t gr_aimingangle; static float gr_viewludsin, gr_viewludcos; @@ -854,7 +852,7 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc for (i = 0; i < subsector->numlines; i++, line++) { - if (line->linedef->special == HORIZONSPECIAL && R_PointOnSegSide(dup_viewx, dup_viewy, line) == 0) + if (line->linedef->special == HORIZONSPECIAL && R_PointOnSegSide(viewx, viewy, line) == 0) { P_ClosestPointOnLine(viewx, viewy, line->linedef, &v); dist = FIXED_TO_FLOAT(R_PointToDist(v.x, v.y)); @@ -5472,11 +5470,6 @@ void HWR_SetTransform(float fpov, player_t *player) postimg_t *postprocessor = &postimgtype[0]; INT32 i; - // copy view cam position for local use - dup_viewx = viewx; - dup_viewy = viewy; - dup_viewz = viewz; - gr_viewx = FIXED_TO_FLOAT(viewx); gr_viewy = FIXED_TO_FLOAT(viewy); gr_viewz = FIXED_TO_FLOAT(viewz); @@ -5663,7 +5656,9 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe portalclipline = NULL; else HWR_PortalClipping(rootportal); + validcount++; + HWR_RenderBSPNode((INT32)numnodes-1);// no actual rendering happens // for each found portal: @@ -5681,11 +5676,12 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe // draw normal things in current frame in current incremented stencil buffer area HWR_SetStencilState(HWR_STENCIL_NORMAL, stencil_level); if (!cv_portalonly.value || rootportal) - { + { + HWR_SetTransform(fpov, player); + HWR_ClearClipper(); HWR_ClearSprites(); - // the frame should be correct, set by either the for loop or the above layer in recursion - HWR_SetTransform(fpov, player); + if (!rootportal) portalclipline = NULL; else @@ -5693,7 +5689,10 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe HWR_PortalFrame(rootportal);// for portalclipsector, it could have gone null from search HWR_PortalClipping(rootportal); } - //drawcount = 0; + + // Set transform. + HWD.pfnSetTransform(&atransform); + validcount++; if (cv_grbatching.value) @@ -5769,8 +5768,6 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox) { const float fpov = FIXED_TO_FLOAT(cv_fov.value+player->fovadd); - postimg_t *postprocessor = &postimgtype[0]; - INT32 i; // set window position gr_centerx = gr_basecenterx; @@ -5809,67 +5806,8 @@ void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox) // check for new console commands. NetUpdate(); - gr_viewx = FIXED_TO_FLOAT(viewx); - gr_viewy = FIXED_TO_FLOAT(viewy); - gr_viewz = FIXED_TO_FLOAT(viewz); - gr_viewsin = FIXED_TO_FLOAT(viewsin); - gr_viewcos = FIXED_TO_FLOAT(viewcos); - - memset(&atransform, 0x00, sizeof(FTransform)); - - // Set T&L transform - atransform.x = gr_viewx; - atransform.y = gr_viewy; - atransform.z = gr_viewz; - - atransform.scalex = 1; - atransform.scaley = (float)vid.width/vid.height; - atransform.scalez = 1; - - // 14042019 - gr_aimingangle = aimingangle; - atransform.shearing = false; - atransform.viewaiming = aimingangle; - - if (cv_grshearing.value) - { - gr_aimingangle = 0; - atransform.shearing = true; - } - - gr_viewludsin = FIXED_TO_FLOAT(FINECOSINE(gr_aimingangle>>ANGLETOFINESHIFT)); - gr_viewludcos = FIXED_TO_FLOAT(-FINESINE(gr_aimingangle>>ANGLETOFINESHIFT)); - - atransform.anglex = (float)(gr_aimingangle>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES); - atransform.angley = (float)(viewangle>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES); - - atransform.fovxangle = fpov; // Tails - atransform.fovyangle = fpov; // Tails - if (player->viewrollangle != 0) - { - fixed_t rol = AngleFixed(player->viewrollangle); - atransform.rollangle = FIXED_TO_FLOAT(rol); - atransform.roll = true; - } - atransform.splitscreen = splitscreen; - - for (i = 0; i <= splitscreen; i++) - { - if (player == &players[displayplayers[i]]) - postprocessor = &postimgtype[i]; - } - - atransform.flip = false; - if (*postprocessor == postimg_flip) - atransform.flip = true; - - atransform.mirror = false; - if (*postprocessor == postimg_mirror) - atransform.mirror = true; - // Clear view, set viewport (glViewport), set perspective... HWR_ClearView(); - HWR_ClearSprites(); ST_doPaletteStuff(); @@ -5890,19 +5828,8 @@ void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox) current_bsp_culling_distance = bsp_culling_distances[cv_grrenderdistance.value - 1]; } - HWR_ClearClipper(); - - // Set transform. - HWD.pfnSetTransform(&atransform); - - // Reset the shader state. - //HWR_SetShaderState(); - - validcount++; - portalclipline = NULL; HWR_RenderViewpoint(NULL, fpov, player, 0, !skybox); - HWR_SetTransform(fpov, player);// not sure if needed // Unset transform and shader HWD.pfnSetTransform(NULL); -- 2.54.0 From 01cce7c9c6fd4652932ba8c870b0bc6074aca464 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 11 Mar 2024 04:25:41 +0100 Subject: [PATCH 08/25] remove pseudoangle as its slower --- src/r_main.c | 34 ---------------------------------- src/r_main.h | 1 - 2 files changed, 35 deletions(-) diff --git a/src/r_main.c b/src/r_main.c index f2609fb5c..8a975498d 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -457,40 +457,6 @@ angle_t R_PointToAngle2(fixed_t pviewx, fixed_t pviewy, fixed_t x, fixed_t y) 0; } -// -// R_PointToPseudoAngle -// ! Returns the pseudoangle between the line p1 to (infinity, p1.y) and the -// line from p1 to p2. The pseudoangle has the property that the ordering of -// points by true angle anround p1 and ordering of points by pseudoangle are the -// same. -// -// For clipping exact angles are not needed. Only the ordering matters. -// This is about as fast as the fixed point R_PointToAngle2 but without -// the precision issues associated with that function. -// - -angle_t R_PointToPseudoAngle (fixed_t x, fixed_t y) -{ - // Note: float won't work here as it's less precise than the BAM values being passed as parameters - double vecx = (double)x - viewx; - double vecy = (double)y - viewy; - double epsilon = 1e-9; - - if (fabs(vecx) < epsilon && fabs(vecy) < epsilon) - { - return 0; - } - else - { - double result = vecy / (fabs(vecx) + fabs(vecy)); - if (vecx < 0) - { - result = 2.0 - result; - } - return (angle_t)xs_CRoundToInt(result * (1 << 30)); - } -} - fixed_t R_PointToDist2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1) { return FixedHypot(px1 - px2, py1 - py2); diff --git a/src/r_main.h b/src/r_main.h index 85bb9e827..63c7c3ab5 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -71,7 +71,6 @@ angle_t R_PointToAngle(fixed_t x, fixed_t y); angle_t R_PointToAngle64(INT64 x, INT64 y); angle_t R_PointToAngleEx(INT32 x2, INT32 y2, INT32 x1, INT32 y1); angle_t R_PointToAngle2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1); -angle_t R_PointToPseudoAngle (fixed_t x, fixed_t y); fixed_t R_PointToDist(fixed_t x, fixed_t y); fixed_t R_PointToDist2(fixed_t px2, fixed_t py2, fixed_t px1, fixed_t py1); angle_t R_PlayerSliptideAngle(player_t *player); -- 2.54.0 From 2fd0d980e39ad3d89465559ae9b3cb66c0adb642 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 11 Mar 2024 04:27:52 +0100 Subject: [PATCH 09/25] make 64 default again --- src/r_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_main.c b/src/r_main.c index 8a975498d..a74be33d8 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -213,7 +213,7 @@ consvar_t cv_homremoval = {"homremoval", "Yes", CV_SAVE, homremoval_cons_t, NULL consvar_t cv_maxportals = {"maxportals", "2", CV_SAVE, maxportals_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t pointoangle_cons_t[] = {{0, "Ex"}, {1, "64"}, {0, NULL}}; -consvar_t cv_pointoangleexor64 = {"r_pointtoangle", "Ex", CV_SAVE, pointoangle_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_pointoangleexor64 = {"r_pointtoangle", "64", CV_SAVE, pointoangle_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; void SplitScreen_OnChange(void) { -- 2.54.0 From dc465c35815ecbdd229f398bc1849fea59c7f1c8 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 11 Mar 2024 11:00:14 +0100 Subject: [PATCH 10/25] optimize hwr_renderbpsnode actually just make it behave like the software version lol --- src/hardware/hw_main.c | 56 +++++++++++++++++++----------------------- src/r_bsp.c | 8 +++--- 2 files changed, 29 insertions(+), 35 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 66e520726..bc225b6c9 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3490,42 +3490,36 @@ static boolean HWR_PortalCheckBBox(fixed_t *bspcoord) void HWR_RenderBSPNode(INT32 bspnum) { - node_t *bsp = &nodes[bspnum]; - - // Decide which side the view point is on - INT32 side; - ps_numbspcalls.value.i++; - // Found a subsector? - if (bspnum & NF_SUBSECTOR) + while (!(bspnum & NF_SUBSECTOR)) // Found a subsector? { - // PORTAL CULLING - if (portalclipline) - { - sector_t *sect = subsectors[bspnum & ~NF_SUBSECTOR].sector; - if (portalcullsector) - { - if (sect != portalcullsector) - return; - portalcullsector = NULL; - } - } - if (bspnum != -1) - HWR_Subsector(bspnum&(~NF_SUBSECTOR)); - return; + node_t *bsp = &nodes[bspnum]; + + // Decide which side the view point is on. + INT32 side = R_PointOnSide(viewx, viewy, bsp); + + // Recursively divide front space. + if (HWR_PortalCheckBBox(bsp->bbox[side])) + HWR_RenderBSPNode(bsp->children[side]); + + // Possibly divide back space + if (!(HWR_CheckBBox(bsp->bbox[side^1]) && HWR_PortalCheckBBox(bsp->bbox[side^1]))) + return; + + bspnum = bsp->children[side^1]; } - // Decide which side the view point is on. - side = R_PointOnSide(viewx, viewy, bsp); - - // Recursively divide front space. - if (HWR_PortalCheckBBox(bsp->bbox[side])) - HWR_RenderBSPNode(bsp->children[side]); - - // Possibly divide back space. - if (HWR_CheckBBox(bsp->bbox[side^1]) && HWR_PortalCheckBBox(bsp->bbox[side^1])) - HWR_RenderBSPNode(bsp->children[side^1]); + // PORTAL CULLING + if (portalclipline && portalcullsector) + { + const sector_t *sect = subsectors[bspnum & ~NF_SUBSECTOR].sector; + if (sect != portalcullsector) + return; + portalcullsector = NULL; + } + // e6y: support for extended nodes + HWR_Subsector(bspnum == -1 ? 0 : bspnum & ~NF_SUBSECTOR); } // ========================================================================== diff --git a/src/r_bsp.c b/src/r_bsp.c index e0b8039af..3ec67d70d 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -1311,9 +1311,9 @@ void R_RenderBSPNode(INT32 bspnum) { node_t *bsp; INT32 side; - + ps_numbspcalls.value.i++; - + while (!(bspnum & NF_SUBSECTOR)) // Found a subsector? { bsp = &nodes[bspnum]; @@ -1324,7 +1324,6 @@ void R_RenderBSPNode(INT32 bspnum) R_RenderBSPNode(bsp->children[side]); // Possibly divide back space. - if (!R_CheckBBox(bsp->bbox[side^1])) return; @@ -1332,7 +1331,8 @@ void R_RenderBSPNode(INT32 bspnum) } // PORTAL CULLING - if (portalcullsector) { + if (portalcullsector) + { sector_t *sect = subsectors[bspnum & ~NF_SUBSECTOR].sector; if (sect != portalcullsector) return; -- 2.54.0 From cbe78cc50ff5184664e96e761c04d1fbabad55e2 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 11 Mar 2024 11:22:08 +0100 Subject: [PATCH 11/25] can do that directly --- src/hardware/hw_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index bc225b6c9..b151e5696 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3513,8 +3513,7 @@ void HWR_RenderBSPNode(INT32 bspnum) // PORTAL CULLING if (portalclipline && portalcullsector) { - const sector_t *sect = subsectors[bspnum & ~NF_SUBSECTOR].sector; - if (sect != portalcullsector) + if (portalcullsector != subsectors[bspnum & ~NF_SUBSECTOR].sector) return; portalcullsector = NULL; } -- 2.54.0 From 8461449f2f73e86d38dcb1cc910873da2c3e7443 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 11 Mar 2024 11:47:05 +0100 Subject: [PATCH 12/25] more opitmizations stuff --- src/doomtype.h | 4 ++++ src/hardware/hw_main.c | 6 +++--- src/hardware/hw_main.h | 2 +- src/r_main.c | 4 ++-- src/r_main.h | 4 ++-- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/doomtype.h b/src/doomtype.h index dd7c26b5d..5a04f77ba 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -249,6 +249,7 @@ size_t strlcpy(char *dst, const char *src, size_t siz); #if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) // >= GCC 3.1 #define FUNCDEAD __attribute__ ((deprecated)) #define FUNCINLINE __attribute__((always_inline)) + #define PUREFUNC __attribute__((pure)) #define FUNCNONNULL __attribute__((nonnull)) #endif @@ -321,6 +322,9 @@ size_t strlcpy(char *dst, const char *src, size_t siz); #ifndef ATTRNOINLINE #define ATTRNOINLINE #endif +#ifndef PUREFUNC +#define PUREFUNC +#endif /* Miscellaneous types that don't fit anywhere else (Can this be changed?) */ diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index b151e5696..46c3c4267 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2690,7 +2690,7 @@ doaddline: // // modified to use local variables -boolean HWR_CheckBBox(fixed_t *bspcoord) +boolean HWR_CheckBBox(const fixed_t *bspcoord) { INT32 boxpos; fixed_t px1, py1, px2, py2; @@ -3443,7 +3443,7 @@ skip_stuff_for_portals: // use returned value as multiplier for the added values from p_thrust thing // P_InterceptVector needs divlines which need dx and dy, dx=x2-x1 dy=y2-y1 -static boolean HWR_PortalCheckBBox(fixed_t *bspcoord) +static boolean HWR_PortalCheckBBox(const fixed_t *bspcoord) { vertex_t closest_point; if (!portalclipline) @@ -3494,7 +3494,7 @@ void HWR_RenderBSPNode(INT32 bspnum) while (!(bspnum & NF_SUBSECTOR)) // Found a subsector? { - node_t *bsp = &nodes[bspnum]; + const node_t *bsp = &nodes[bspnum]; // Decide which side the view point is on. INT32 side = R_PointOnSide(viewx, viewy, bsp); diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index ab5d57159..16b09be8d 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -140,7 +140,7 @@ void HWR_AddPolyObjectSegs(void); void HWR_RenderBSPNode(INT32 bspnum); void HWR_Subsector(size_t num); void HWR_AddLine(seg_t *line); -boolean HWR_CheckBBox(fixed_t *bspcoord); +boolean HWR_CheckBBox(const fixed_t *bspcoord); void HWR_RenderDrawNodes(void); // hw_main.c: Sprites diff --git a/src/r_main.c b/src/r_main.c index 8a975498d..fce4fd92e 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -331,7 +331,7 @@ static void FlipCam4_OnChange(void) // // killough 5/2/98: reformatted // -INT32 R_PointOnSide(fixed_t x, fixed_t y, node_t *restrict node) +PUREFUNC INT32 R_PointOnSide(fixed_t x, fixed_t y, const node_t *restrict node) { if (!node->dx) return x <= node->x ? node->dy > 0 : node->dy < 0; @@ -350,7 +350,7 @@ INT32 R_PointOnSide(fixed_t x, fixed_t y, node_t *restrict node) } // killough 5/2/98: reformatted -INT32 R_PointOnSegSide(fixed_t x, fixed_t y, seg_t *line) +PUREFUNC INT32 R_PointOnSegSide(fixed_t x, fixed_t y, const seg_t *line) { fixed_t lx = line->v1->x; fixed_t ly = line->v1->y; diff --git a/src/r_main.h b/src/r_main.h index 63c7c3ab5..c8c3f4e8c 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -65,8 +65,8 @@ extern lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ]; #define NUMCOLORMAPS 32 // Utility functions. -INT32 R_PointOnSide(fixed_t x, fixed_t y, node_t *node); -INT32 R_PointOnSegSide(fixed_t x, fixed_t y, seg_t *line); +INT32 R_PointOnSide(fixed_t x, fixed_t y, const node_t *node); +INT32 R_PointOnSegSide(fixed_t x, fixed_t y, const seg_t *line); angle_t R_PointToAngle(fixed_t x, fixed_t y); angle_t R_PointToAngle64(INT64 x, INT64 y); angle_t R_PointToAngleEx(INT32 x2, INT32 y2, INT32 x1, INT32 y1); -- 2.54.0 From d2c157262a1e7454c651265979bcfb4c36e7d7c5 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 11 Mar 2024 12:40:18 +0100 Subject: [PATCH 13/25] those can all be static --- src/hardware/hw_glob.h | 2 -- src/hardware/hw_main.c | 10 +++++----- src/hardware/hw_main.h | 7 ------- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index 742fd82ae..a5b66a429 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -92,8 +92,6 @@ void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, extracolormap_t *planecolormap); -void HWR_RenderDrawNodes(void); - // -------- // hw_shaders.c // -------- diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 46c3c4267..91f322b27 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2542,7 +2542,7 @@ static boolean CheckClip(sector_t * afrontsector, sector_t * abacksector) // HWR_AddLine // Clips the given segment and adds any visible pieces to the line list. -void HWR_AddLine(seg_t *line) +static void HWR_AddLine(seg_t *line) { angle_t angle1, angle2; @@ -2690,7 +2690,7 @@ doaddline: // // modified to use local variables -boolean HWR_CheckBBox(const fixed_t *bspcoord) +static boolean HWR_CheckBBox(const fixed_t *bspcoord) { INT32 boxpos; fixed_t px1, py1, px2, py2; @@ -3115,7 +3115,7 @@ static boolean HWR_DoCulling(line_t *cullheight, line_t *viewcullheight, float v // : Add sprites of things in sector. // : Draw one or more line segments. // -----------------+ -void HWR_Subsector(size_t num) +static void HWR_Subsector(size_t num) { INT16 count; seg_t *line; @@ -3488,7 +3488,7 @@ static boolean HWR_PortalCheckBBox(const fixed_t *bspcoord) // traversing subtree recursively. // Just call with BSP root. -void HWR_RenderBSPNode(INT32 bspnum) +static void HWR_RenderBSPNode(INT32 bspnum) { ps_numbspcalls.value.i++; @@ -4583,7 +4583,7 @@ static int CompareDrawNodePlanes(const void *p1, const void *p2) // // HWR_RenderDrawNodes // Sorts and renders the list of drawnodes for the scene being rendered. -void HWR_RenderDrawNodes(void) +static void HWR_RenderDrawNodes(void) { INT32 i = 0, run_start = 0; diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 16b09be8d..3530c2915 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -136,13 +136,6 @@ void HWR_DrawSkyBackground(float fpov); void HWR_AddPolyObjectSegs(void); -// hw_main.c: BSP -void HWR_RenderBSPNode(INT32 bspnum); -void HWR_Subsector(size_t num); -void HWR_AddLine(seg_t *line); -boolean HWR_CheckBBox(const fixed_t *bspcoord); -void HWR_RenderDrawNodes(void); - // hw_main.c: Sprites void HWR_AddSprites(sector_t *sec); void HWR_ProjectSprite(mobj_t *thing); -- 2.54.0 From a527831aa941fff30123096460c239d799df2c34 Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 11 Mar 2024 21:21:07 +0100 Subject: [PATCH 14/25] sort grid when opening skin menu instead of everytime a skin is added --- src/m_menu.c | 9 +++ src/r_things.c | 155 ++++++++++++++++++++++++------------------------- 2 files changed, 86 insertions(+), 78 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 5cf720be7..7382a3aad 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -11621,6 +11621,8 @@ static void M_SetupMultiPlayer(INT32 choice) //change the y offsets of the menu depending on cvar settings SKINSELECTMENUEDIT + sortSkinGrid(); + MP_PlayerSetupDef.prevMenu = currentMenu; M_SetupNextMenu(&MP_PlayerSetupDef); } @@ -11658,6 +11660,8 @@ static void M_SetupMultiPlayer2(INT32 choice) //change the y offsets of the menu depending on cvar settings SKINSELECTMENUEDIT + sortSkinGrid(); + MP_PlayerSetupDef.prevMenu = currentMenu; M_SetupNextMenu(&MP_PlayerSetupDef); } @@ -11695,6 +11699,8 @@ static void M_SetupMultiPlayer3(INT32 choice) //change the y offsets of the menu depending on cvar settings SKINSELECTMENUEDIT + sortSkinGrid(); + MP_PlayerSetupDef.prevMenu = currentMenu; M_SetupNextMenu(&MP_PlayerSetupDef); } @@ -11731,6 +11737,8 @@ static void M_SetupMultiPlayer4(INT32 choice) //change the y offsets of the menu depending on cvar settings SKINSELECTMENUEDIT + + sortSkinGrid(); MP_PlayerSetupDef.prevMenu = currentMenu; M_SetupNextMenu(&MP_PlayerSetupDef); @@ -11756,6 +11764,7 @@ static boolean M_QuitMultiPlayerMenu(void) return true; } + // ================= // DATA OPTIONS MENU // ================= diff --git a/src/r_things.c b/src/r_things.c index 98d2dc53a..48101fb48 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -3189,93 +3189,92 @@ static int skinSortFunc(const void *a, const void *b) //tbh i have no clue what const UINT8 val_a = *((const UINT8 *)a); const UINT8 val_b = *((const UINT8 *)b); - //return (strcmp(in1->realname, in2->realname) < 0) || (strcmp(in1->realname, in2->realname) ==); switch (cv_skinselectgridsort.value) { - case SKINMENUSORT_REALNAME: - //CONS_Printf("Sorting by realname\n"); - // check name - if ((temp = strcmp(in1->realname, in2->realname))) - return temp; - // sort by internal name - return strcmp(in1->name, in2->name); - break; + case SKINMENUSORT_REALNAME: + //CONS_Printf("Sorting by realname\n"); + // check name + if ((temp = strcmp(in1->realname, in2->realname))) + return temp; + // sort by internal name + return strcmp(in1->name, in2->name); + break; - case SKINMENUSORT_NAME: - //CONS_Printf("Sorting by name\n"); - return strcmp(in1->name, in2->name); - break; + case SKINMENUSORT_NAME: + //CONS_Printf("Sorting by name\n"); + return strcmp(in1->name, in2->name); + break; - case SKINMENUSORT_SPEED: - //CONS_Printf("Sorting by speed\n"); - // check speed - if (in1->kartspeed < in2->kartspeed) - return -1; - else if (in2->kartspeed < in1->kartspeed) - return 1; - // then check weight - if (in1->kartweight < in2->kartweight) - return -1; - else if (in2->kartweight < in1->kartweight) - return 1; - // then check name - if ((temp = strcmp(in1->realname, in2->realname))) - return temp; - // sort by internal name - return strcmp(in1->name, in2->name); - break; + case SKINMENUSORT_SPEED: + //CONS_Printf("Sorting by speed\n"); + // check speed + if (in1->kartspeed < in2->kartspeed) + return -1; + else if (in2->kartspeed < in1->kartspeed) + return 1; + // then check weight + if (in1->kartweight < in2->kartweight) + return -1; + else if (in2->kartweight < in1->kartweight) + return 1; + // then check name + if ((temp = strcmp(in1->realname, in2->realname))) + return temp; + // sort by internal name + return strcmp(in1->name, in2->name); + break; - case SKINMENUSORT_WEIGHT: - //CONS_Printf("Sorting by weight\n"); - // check weight - if (in1->kartweight < in2->kartweight) - return -1; - else if (in2->kartweight < in1->kartweight) - return 1; - // then check speed - if (in1->kartspeed < in2->kartspeed) - return -1; - else if (in2->kartspeed < in1->kartspeed) - return 1; - // then check name - if ((temp = strcmp(in1->realname, in2->realname))) - return temp; - // sort by internal name - return strcmp(in1->name, in2->name); - break; + case SKINMENUSORT_WEIGHT: + //CONS_Printf("Sorting by weight\n"); + // check weight + if (in1->kartweight < in2->kartweight) + return -1; + else if (in2->kartweight < in1->kartweight) + return 1; + // then check speed + if (in1->kartspeed < in2->kartspeed) + return -1; + else if (in2->kartspeed < in1->kartspeed) + return 1; + // then check name + if ((temp = strcmp(in1->realname, in2->realname))) + return temp; + // sort by internal name + return strcmp(in1->name, in2->name); + break; - case SKINMENUSORT_PREFCOLOR: - //CONS_Printf("Sorting by prefcolor\n"); - // check prefcolor - if (in1->prefcolor < in2->prefcolor) - return -1; - else if (in2->prefcolor < in1->prefcolor) - return 1; - // then check name - if ((temp = strcmp(in1->realname, in2->realname))) - return temp; - // sort by internal name - return strcmp(in1->name, in2->name); - break; + case SKINMENUSORT_PREFCOLOR: + //CONS_Printf("Sorting by prefcolor\n"); + // check prefcolor + if (in1->prefcolor < in2->prefcolor) + return -1; + else if (in2->prefcolor < in1->prefcolor) + return 1; + // then check name + if ((temp = strcmp(in1->realname, in2->realname))) + return temp; + // sort by internal name + return strcmp(in1->name, in2->name); + break; - case SKINMENUSORT_ID: - //CONS_Printf("Sorting by id\n"); - //how do i do by ID????? - //wait why dont i just convert the inputs to UINT32s - //please tell me im allowed to define variables in here since its a block + case SKINMENUSORT_ID: + //CONS_Printf("Sorting by id\n"); + //how do i do by ID????? + //wait why dont i just convert the inputs to UINT32s + //please tell me im allowed to define variables in here since its a block - if (val_a == val_b) - return 0; - else if (val_a < val_b) - return -1; - else - return 1; + if (val_a == val_b) + return 0; + else if (val_a < val_b) + return -1; + else + return 1; - default: - return strcmp(in1->name, in2->name); - break; + default: + return strcmp(in1->name, in2->name); + break; } //im scared this somehow will sometimes end up here so im gonna add this here just to be safe return strcmp(in1->name, in2->name); @@ -3283,7 +3282,7 @@ static int skinSortFunc(const void *a, const void *b) //tbh i have no clue what void sortSkinGrid(void) { - CONS_Printf("Sorting skin list (%d)...\n", cv_skinselectgridsort.value); + //CONS_Printf("Sorting skin list (%d)...\n", cv_skinselectgridsort.value); qsort(skinsorted, numskins, sizeof(UINT8), skinSortFunc); } @@ -3599,7 +3598,7 @@ next_token: numallskins++; } - sortSkinGrid(); + //sortSkinGrid(); return; } -- 2.54.0 From ad252fdbf2a83e8149df6d761b768b81633042c0 Mon Sep 17 00:00:00 2001 From: Indev Date: Tue, 12 Mar 2024 00:24:32 +0300 Subject: [PATCH 15/25] Add snap to bottom flags for race countdown and level title too --- src/k_kart.c | 4 ++-- src/st_stuff.c | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index aa720bd88..40486cfd5 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -10037,11 +10037,11 @@ void K_drawKartHUD(void) int xoff = cv_dnft_xoffset.value; if (splitscreen > 1) - V_DrawCenteredString(BASEVIDWIDTH/4+xoff, LAPS_Y+1+yoff, K_calcSplitFlags(0), countstr); + V_DrawCenteredString(BASEVIDWIDTH/4+xoff, LAPS_Y+1+yoff, K_calcSplitFlags(V_SNAPTOBOTTOM), countstr); else { INT32 karlen = strlen(countstr)*6; // half of 12 - V_DrawKartString((BASEVIDWIDTH/2)-karlen+xoff, LAPS_Y+3+yoff, K_calcSplitFlags(0), countstr); + V_DrawKartString((BASEVIDWIDTH/2)-karlen+xoff, LAPS_Y+3+yoff, K_calcSplitFlags(V_SNAPTOBOTTOM), countstr); } } diff --git a/src/st_stuff.c b/src/st_stuff.c index 881ab5fcc..06ce08c5e 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -746,13 +746,13 @@ static void ST_drawLevelTitle(void) { dupcalc = (dupcalc - BASEVIDWIDTH)>>1; - V_DrawFill(sub - dupcalc, bary+9, ttlnumxpos+dupcalc + 1, 2, 31); - V_DrawDiag(sub + ttlnumxpos + 1, bary, 11, 31); - V_DrawFill(sub - dupcalc, bary, ttlnumxpos+dupcalc, 10, gtc); - V_DrawDiag(sub + ttlnumxpos, bary, 10, gtc); + V_DrawFill(sub - dupcalc, bary+9, ttlnumxpos+dupcalc + 1, 2, 31|V_SNAPTOBOTTOM); + V_DrawDiag(sub + ttlnumxpos + 1, bary, 11, 31|V_SNAPTOBOTTOM); + V_DrawFill(sub - dupcalc, bary, ttlnumxpos+dupcalc, 10, gtc|V_SNAPTOBOTTOM); + V_DrawDiag(sub + ttlnumxpos, bary, 10, gtc|V_SNAPTOBOTTOM); if (subttl[0]) - V_DrawRightAlignedString(sub + zonexpos - 8, bary+1, V_ALLOWLOWERCASE, subttl); + V_DrawRightAlignedString(sub + zonexpos - 8, bary+1, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, subttl); //else //V_DrawRightAlignedString(sub + zonexpos - 8, bary+1, V_ALLOWLOWERCASE, va("%s Mode", gametype_cons_t[gametype].strvalue)); } @@ -761,15 +761,15 @@ static void ST_drawLevelTitle(void) lvlttlxpos += sub; zonexpos += sub; - V_DrawLevelTitle(lvlttlxpos, bary-18, 0, lvlttl); + V_DrawLevelTitle(lvlttlxpos, bary-18, V_SNAPTOBOTTOM, lvlttl); if (strlen(zonttl) > 0) - V_DrawLevelTitle(zonexpos, bary+6, 0, zonttl); + V_DrawLevelTitle(zonexpos, bary+6, V_SNAPTOBOTTOM, zonttl); else if (!(mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE)) - V_DrawLevelTitle(zonexpos, bary+6, 0, M_GetText("Zone")); + V_DrawLevelTitle(zonexpos, bary+6, V_SNAPTOBOTTOM, M_GetText("Zone")); if (actnum[0]) - V_DrawLevelTitle(ttlnumxpos+12, bary+6, 0, actnum); + V_DrawLevelTitle(ttlnumxpos+12, bary+6, V_SNAPTOBOTTOM, actnum); } // Draw the status bar overlay, customisable: the user chooses which -- 2.54.0 From ad8cdc676ceb41687bb875339e6708edcf0f384d Mon Sep 17 00:00:00 2001 From: Alug Date: Mon, 11 Mar 2024 23:53:45 +0100 Subject: [PATCH 16/25] midi music bros --- src/d_clisrv.c | 1 - src/m_menu.c | 80 +++++++++++++++++++++++++++++++------------------- 2 files changed, 50 insertions(+), 31 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index f31d4d8d6..c187c7d4e 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -208,7 +208,6 @@ static inline void *G_ScpyTiccmd(ticcmd_t* dest, void* src, const size_t n) } - // Some software don't support largest packet // (original sersetup, not exactely, but the probability of sending a packet // of 512 bytes is like 0.1) diff --git a/src/m_menu.c b/src/m_menu.c index 7382a3aad..bde1e3d34 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1524,14 +1524,14 @@ static menuitem_t OP_SoundOptionsMenu[] = {IT_STRING|IT_CVAR|IT_CV_SLIDER, NULL, "Music Volume", &cv_digmusicvolume, 38}, -/* -- :nonnathisshit: +#ifndef NO_MIDI {IT_STRING|IT_CVAR, NULL, "MIDI", &cv_gamemidimusic, 50}, {IT_STRING|IT_CVAR|IT_CV_SLIDER, NULL, "MIDI Volume", &cv_midimusicvolume, 58}, -*/ +#endif //{IT_STRING|IT_CALL, NULL, "Restart Audio System", M_RestartAudio, 50}, - +#ifdef NO_MIDI {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 50}, {IT_STRING|IT_CVAR, NULL, "Surround Sound", &surround, 60}, @@ -1545,14 +1545,33 @@ static menuitem_t OP_SoundOptionsMenu[] = {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 125}, {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 135}, {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 155} +#else + {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 60}, + {IT_STRING|IT_CVAR, NULL, "Surround Sound", &surround, 70}, + + {IT_STRING|IT_CVAR, NULL, "Chat Notifications", &cv_chatnotifications, 85}, + {IT_STRING|IT_CVAR, NULL, "Character voices", &cv_kartvoices, 95}, + {IT_STRING|IT_CVAR, NULL, "Powerup Warning", &cv_kartinvinsfx, 105}, + + {IT_KEYHANDLER|IT_STRING, NULL, "Sound Test", M_HandleSoundTest, 115}, + {IT_STRING|IT_CALL, NULL, "Music Test", M_MusicTest, 125}, + + {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 135}, + {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 145}, + {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 165} +#endif }; static const char* OP_SoundTooltips[] = { "Turn Sound effects on or off.", - "Volume of sound effects.", - "Turn Sound effects on or off.", - "Volume of music.", + "Volume of Sound effects.", + "Turn Music on or off.", + "Volume of Music.", +#ifndef NO_MIDI + "Turn Midi Music on or off.", + "Volume of Midi Music.", +#endif "Reverse left and right channels of audio.", "Surround Sound.", "Chat notification sound.", @@ -1869,8 +1888,7 @@ static menuitem_t OP_AdvServerOptionsMenu[] = #ifndef NONET static const char* OP_AdvServerOptionsTooltips[] = -{ - +{ "Server used for master server.", "Attempts to resynchronise player to server.", "Maximum allowed delay.", @@ -4052,7 +4070,7 @@ void M_StartControlPanel(void) Dummymenuplayer_OnChange(); - if ((server || IsPlayerAdmin(consoleplayer))) + if (server || IsPlayerAdmin(consoleplayer)) { MPauseMenu[mpause_switchmap].status = IT_STRING | IT_CALL; MPauseMenu[mpause_addons].status = IT_STRING | IT_CALL; @@ -4818,7 +4836,7 @@ static void M_DrawGenericMenu(void) if (currentMenu == &OP_ControlsDef) { - if (!(OP_ControlsTooltips[itemOn] == NULL)) + if (!(OP_ControlsTooltips[itemOn] == NULL)) { M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_ControlsTooltips[itemOn], 30, coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) @@ -4828,7 +4846,7 @@ static void M_DrawGenericMenu(void) if (currentMenu == &OP_MouseOptionsDef) { - if (!(OP_MouseTooltips[itemOn] == NULL)) + if (!(OP_MouseTooltips[itemOn] == NULL)) { M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_MouseTooltips[itemOn], 30, coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) @@ -4838,7 +4856,7 @@ static void M_DrawGenericMenu(void) if (currentMenu == &OP_VideoOptionsDef) { - if (!(OP_VideoTooltips[itemOn] == NULL)) + if (!(OP_VideoTooltips[itemOn] == NULL)) { M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_VideoTooltips[itemOn], 30, coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) @@ -4848,7 +4866,7 @@ static void M_DrawGenericMenu(void) if (currentMenu == &OP_SoundOptionsDef) { - if (!(OP_SoundTooltips[itemOn] == NULL)) + if (!(OP_SoundTooltips[itemOn] == NULL)) { M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_SoundTooltips[itemOn], 30, coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) @@ -4858,7 +4876,7 @@ static void M_DrawGenericMenu(void) if (currentMenu == &OP_SoundAdvancedDef) { - if (!(OP_SoundAdvancedTooltips[itemOn] == NULL)) + if (!(OP_SoundAdvancedTooltips[itemOn] == NULL)) { M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_SoundAdvancedTooltips[itemOn], 30, coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) @@ -4868,7 +4886,7 @@ static void M_DrawGenericMenu(void) if (currentMenu == &OP_ExpOptionsDef) { - if (!(OP_ExpTooltips[itemOn] == NULL)) + if (!(OP_ExpTooltips[itemOn] == NULL)) { M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_ExpTooltips[itemOn], 30, coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) @@ -4878,7 +4896,7 @@ static void M_DrawGenericMenu(void) if (currentMenu == &OP_ChatOptionsDef) { - if (!(OP_ChatOptionsTooltips[itemOn] == NULL)) + if (!(OP_ChatOptionsTooltips[itemOn] == NULL)) { M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_ChatOptionsTooltips[itemOn], 30, coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) @@ -4890,7 +4908,7 @@ static void M_DrawGenericMenu(void) if (currentMenu == &OP_GameOptionsDef) { - if (!(OP_GameTooltips[itemOn] == NULL)) + if (!(OP_GameTooltips[itemOn] == NULL)) { M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_GameTooltips[itemOn], 30, coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) @@ -4901,7 +4919,7 @@ static void M_DrawGenericMenu(void) if (currentMenu == &OP_ServerOptionsDef) { - if (!(OP_ServerOptionsTooltips[itemOn] == NULL)) + if (!(OP_ServerOptionsTooltips[itemOn] == NULL)) { M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_ServerOptionsTooltips[itemOn], 30, coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) @@ -4912,7 +4930,7 @@ static void M_DrawGenericMenu(void) if (currentMenu == &OP_AdvServerOptionsDef) { - if (!(OP_AdvServerOptionsTooltips[itemOn] == NULL)) + if (!(OP_AdvServerOptionsTooltips[itemOn] == NULL)) { M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_AdvServerOptionsTooltips[itemOn], 30, coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) @@ -4925,7 +4943,7 @@ static void M_DrawGenericMenu(void) if (currentMenu == &OP_PlayerDistortDef) { - if (!(OP_PlayerDistortTooltips[itemOn] == NULL)) + if (!(OP_PlayerDistortTooltips[itemOn] == NULL)) { M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_PlayerDistortTooltips[itemOn], 30, coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) @@ -4938,7 +4956,7 @@ static void M_DrawGenericMenu(void) if (currentMenu == &OP_SaturnCreditsDef) // C: { - if (!(OP_CreditTooltips[itemOn] == NULL)) + if (!(OP_CreditTooltips[itemOn] == NULL)) { M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_CreditTooltips[itemOn], 30, coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) @@ -4948,7 +4966,7 @@ static void M_DrawGenericMenu(void) if (currentMenu == &OP_BirdDef) { - if (!(OP_BirdTooltips[itemOn] == NULL)) + if (!(OP_BirdTooltips[itemOn] == NULL)) { M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_BirdTooltips[itemOn], 30, coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) @@ -4958,7 +4976,7 @@ static void M_DrawGenericMenu(void) if (currentMenu == &OP_TiltDef) { - if (!(OP_TiltTooltips[itemOn] == NULL)) + if (!(OP_TiltTooltips[itemOn] == NULL)) { M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_TiltTooltips[itemOn], 30, coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) @@ -4968,7 +4986,7 @@ static void M_DrawGenericMenu(void) if (currentMenu == &OP_AdvancedBirdDef) { - if (!(OP_AdvancedBirdTooltips[itemOn] == NULL)) + if (!(OP_AdvancedBirdTooltips[itemOn] == NULL)) { M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, OP_AdvancedBirdTooltips[itemOn], 30, coolalphatimer); if (coolalphatimer > 0 && interpTimerHackAllow) @@ -7915,17 +7933,21 @@ static void M_DrawSkyRoom(void) (digital_disabled ? warningflags : highlightflags), (digital_disabled ? "OFF" : "ON")); - /*V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x, +#ifndef NO_MIDI + V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x, currentMenu->y+currentMenu->menuitems[5].alphaKey, (midi_disabled ? warningflags : highlightflags), - (midi_disabled ? "OFF" : "ON"));*/ + (midi_disabled ? "OFF" : "ON")); +#endif if (itemOn == 0) lengthstring = 8*(sound_disabled ? 3 : 2); else if (itemOn == 2) lengthstring = 8*(digital_disabled ? 3 : 2); - /*else if (itemOn == 5) - lengthstring = 8*(midi_disabled ? 3 : 2);*/ +#ifndef NO_MIDI + else if (itemOn == 5) + lengthstring = 8*(midi_disabled ? 3 : 2); +#endif } for (i = 0; i < currentMenu->numitems; ++i) @@ -9259,8 +9281,6 @@ void M_ModeAttackRetry(INT32 choice) G_CheckDemoStatus(); // Cancel recording if (modeattacking == ATTACKING_RECORD) M_ChooseTimeAttack(0); - /*else if (modeattacking == ATTACKING_NIGHTS) - M_ChooseNightsAttack(0);*/ } static void M_ModeAttackEndGame(INT32 choice) -- 2.54.0 From e0b98707cfa3b31cb40c1b003fcd8e03b341e651 Mon Sep 17 00:00:00 2001 From: Indev Date: Tue, 12 Mar 2024 20:38:57 +0300 Subject: [PATCH 17/25] If game crashes in level, add it to crash report --- src/sdl/i_system.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 2f8e84767..8090a36ea 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -343,6 +343,9 @@ static void write_backtrace(bt_crash_reason_t reason) if (compdate && comptime && comprevision && compbranch) fprintf(out, "Compiled: %s %s, commit %s, branch %s\n", compdate, comptime, comprevision, compbranch); + if (gamestate == GS_LEVEL) + fprintf(out, "Game map: %s\n", G_BuildMapName(gamemap)); + fprintf(out, "Time of crash: %s\n", asctime(timeinfo)); fprintf(out, "Caused by: "); -- 2.54.0 From 06acf6554de6df2e5e74b93e1ea146f129a0c0e9 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 12 Mar 2024 18:50:55 +0100 Subject: [PATCH 18/25] Fix buffer overrun in I_ClipboardPaste https://git.do.srb2.org/STJr/SRB2/-/commit/9772bbeda172bc60482f137fc465e12070c76f22 --- src/sdl/i_system.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 8090a36ea..643957c5c 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -3794,10 +3794,10 @@ const char *I_ClipboardPaste(void) if (!SDL_HasClipboardText()) return NULL; + clipboard_contents = SDL_GetClipboardText(); - memcpy(clipboard_modified, clipboard_contents, 255); + strlcpy(clipboard_modified, clipboard_contents, 256); SDL_free(clipboard_contents); - clipboard_modified[255] = 0; while (*i) { -- 2.54.0 From 22f16c1d2776a28f8f68ff3afaf2c9e440b3b805 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 13 Mar 2024 07:28:16 +0100 Subject: [PATCH 19/25] optimize HWR_AddLine and HWR_ProcessSeg --- src/hardware/hw_main.c | 189 ++++++++++++++++++++++++----------------- 1 file changed, 109 insertions(+), 80 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 91f322b27..f8e4a1a2b 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1328,6 +1328,88 @@ void HWR_DrawSkyWall(FOutVector *wallVerts, FSurfaceInfo *Surf) // PF_Occlude is set in HWR_ProjectWall to draw into the depth buffer } +// Returns true if the midtexture is visible, and false if... it isn't... +static boolean HWR_BlendMidtextureSurface(FSurfaceInfo *pSurf) +{ + FUINT blendmode = 0; + + pSurf->PolyColor.s.alpha = 0xFF; + + if (!gr_curline->polyseg) + { + // set alpha for transparent walls + switch (gr_linedef->special) + { + case 900: + blendmode = HWR_TranstableToAlpha(tr_trans10, pSurf); + break; + case 901: + blendmode = HWR_TranstableToAlpha(tr_trans20, pSurf); + break; + case 902: + blendmode = HWR_TranstableToAlpha(tr_trans30, pSurf); + break; + case 903: + blendmode = HWR_TranstableToAlpha(tr_trans40, pSurf); + break; + case 904: + blendmode = HWR_TranstableToAlpha(tr_trans50, pSurf); + break; + case 905: + blendmode = HWR_TranstableToAlpha(tr_trans60, pSurf); + break; + case 906: + blendmode = HWR_TranstableToAlpha(tr_trans70, pSurf); + break; + case 907: + blendmode = HWR_TranstableToAlpha(tr_trans80, pSurf); + break; + case 908: + blendmode = HWR_TranstableToAlpha(tr_trans90, pSurf); + break; + // Translucent + case 102: + case 121: + case 123: + case 124: + case 125: + case 141: + case 142: + case 144: + case 145: + case 174: + case 175: + case 192: + case 195: + case 221: + case 253: + case 256: + blendmode = PF_Translucent; + break; + default: + blendmode = PF_Masked; + break; + } + } + else if (gr_curline->polyseg->translucency > 0) + { + // Polyobject translucency is shared between all of its lines + if (gr_curline->polyseg->translucency >= NUMTRANSMAPS) // wall not drawn + return false; + //Surf.PolyColor.s.alpha = 0x00; // This shouldn't draw anything regardless of blendmode + //blendmode = PF_Masked; + else + blendmode = HWR_TranstableToAlpha(gr_curline->polyseg->translucency, pSurf); + } + + if (blendmode != PF_Masked && pSurf->PolyColor.s.alpha == 0x00) + return false; + + pSurf->PolyFlags = blendmode; + + return true; +} + // // HWR_ProcessSeg // A portion or all of a wall segment will be drawn, from startfrac to endfrac, @@ -1346,9 +1428,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom fixed_t worldhighslope = 0, worldlowslope = 0; fixed_t v1x, v1y, v2x, v2y; - GLMapTexture_t *grTex = NULL; float cliplow = 0.0f, cliphigh = 0.0f; - INT32 gr_midtexture; fixed_t h, l; // 3D sides and 2s middle textures fixed_t hS, lS; @@ -1410,11 +1490,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[2].z = wallVerts[1].z = ve.y; // x offset the texture - { - fixed_t texturehpeg = gr_sidedef->textureoffset + gr_curline->offset; - cliplow = (float)texturehpeg; - cliphigh = (float)(texturehpeg + (gr_curline->flength*FRACUNIT)); - } + fixed_t texturehpeg = gr_sidedef->textureoffset + gr_curline->offset; + cliplow = (float)texturehpeg; + cliphigh = (float)(texturehpeg + (gr_curline->flength*FRACUNIT)); if (HWR_ShouldUsePaletteRendering()) { @@ -1431,13 +1509,15 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (gr_linedef->flags & ML_TFERLINE) noencore = true; - if (gr_frontsector) - Surf.PolyColor.s.alpha = 255; + Surf.PolyColor.s.alpha = 255; + + INT32 gr_midtexture = R_GetTextureNum(gr_sidedef->midtexture); + GLMapTexture_t *grTex = NULL; + // two sided line if (gr_backsector) { INT32 gr_toptexture, gr_bottomtexture; - // two sided line SLOPEPARAMS(gr_backsector->c_slope, worldhigh, worldhighslope, gr_backsector->ceilingheight) SLOPEPARAMS(gr_backsector->f_slope, worldlow, worldlowslope, gr_backsector->floorheight) @@ -1656,8 +1736,8 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom else HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); } - gr_midtexture = R_GetTextureNum(gr_sidedef->midtexture); - if (gr_midtexture || gr_portal == GRPORTAL_STENCIL || gr_portal == GRPORTAL_DEPTH || gl_drawing_stencil) + + if ((gr_midtexture && HWR_BlendMidtextureSurface(&Surf)) || gr_portal == GRPORTAL_STENCIL || gr_portal == GRPORTAL_DEPTH || gl_drawing_stencil) { sector_t *front, *back; INT32 repeats; @@ -1876,72 +1956,8 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } } - // set alpha for transparent walls (new boom and legacy linedef types) - FBITFIELD blendmode; - - switch (gr_linedef->special) - { - case 900: - blendmode = HWR_TranstableToAlpha(tr_trans10, &Surf); - break; - case 901: - blendmode = HWR_TranstableToAlpha(tr_trans20, &Surf); - break; - case 902: - blendmode = HWR_TranstableToAlpha(tr_trans30, &Surf); - break; - case 903: - blendmode = HWR_TranstableToAlpha(tr_trans40, &Surf); - break; - case 904: - blendmode = HWR_TranstableToAlpha(tr_trans50, &Surf); - break; - case 905: - blendmode = HWR_TranstableToAlpha(tr_trans60, &Surf); - break; - case 906: - blendmode = HWR_TranstableToAlpha(tr_trans70, &Surf); - break; - case 907: - blendmode = HWR_TranstableToAlpha(tr_trans80, &Surf); - break; - case 908: - blendmode = HWR_TranstableToAlpha(tr_trans90, &Surf); - break; - // Translucent - case 102: - case 121: - case 123: - case 124: - case 125: - case 141: - case 142: - case 144: - case 145: - case 174: - case 175: - case 192: - case 195: - case 221: - case 253: - case 256: - blendmode = PF_Translucent; - break; - default: - blendmode = PF_Masked; - break; - } - - if (gr_curline->polyseg && gr_curline->polyseg->translucency > 0) - { - if (gr_curline->polyseg->translucency >= NUMTRANSMAPS) // wall not drawn - { - Surf.PolyColor.s.alpha = 0x00; // This shouldn't draw anything regardless of blendmode - blendmode = PF_Masked; - } - else - blendmode = HWR_TranstableToAlpha(gr_curline->polyseg->translucency, &Surf); - } + // TODO: Actually use the surface's flags so that I don't have to do this + FUINT blendmode = Surf.PolyFlags; // Render midtextures on two-sided lines with a z-buffer offset. // This will cause the midtexture appear on top, if a FOF overlaps with it. @@ -1964,7 +1980,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom else { // Single sided line... Deal only with the middletexture (if one exists) - gr_midtexture = R_GetTextureNum(gr_sidedef->midtexture); + if (gr_midtexture && gr_linedef->special != HORIZONSPECIAL) // Ignore horizon line for OGL { { @@ -2602,7 +2618,7 @@ static void HWR_AddLine(seg_t *line) checkforemptylines = true; gr_backsector = line->backsector; - + // do an extra culling check when rendering portals // check if any line vertex is on the viewable side of the portal target line // if not, the line can be culled. @@ -2664,6 +2680,19 @@ doaddline: else { gr_backsector = R_FakeFlat(gr_backsector, &tempsec, NULL, NULL, true); + + if ((gr_backsector->ceilingpic == skyflatnum && gr_frontsector->ceilingpic == skyflatnum) && (gr_backsector->floorpic == skyflatnum && gr_frontsector->floorpic == skyflatnum)) // everything's sky? let's save us a bit of time then + { + if (!line->polyseg && + !line->sidedef->midtexture + && ((!gr_frontsector->ffloors && !gr_backsector->ffloors) + || gr_frontsector->tag == gr_backsector->tag)) + return; // line is empty, don't even bother + // treat like wide open window instead + HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D + return; + } + if (CheckClip(gr_frontsector, gr_backsector)) { gld_clipper_SafeAddClipRange(angle2, angle1); -- 2.54.0 From 7bfbb9d42c42f4d8adebc18cf7da85234c40cbe3 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 13 Mar 2024 07:34:12 +0100 Subject: [PATCH 20/25] revert that part --- src/hardware/hw_main.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index f8e4a1a2b..83b3910cd 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2681,18 +2681,6 @@ doaddline: { gr_backsector = R_FakeFlat(gr_backsector, &tempsec, NULL, NULL, true); - if ((gr_backsector->ceilingpic == skyflatnum && gr_frontsector->ceilingpic == skyflatnum) && (gr_backsector->floorpic == skyflatnum && gr_frontsector->floorpic == skyflatnum)) // everything's sky? let's save us a bit of time then - { - if (!line->polyseg && - !line->sidedef->midtexture - && ((!gr_frontsector->ffloors && !gr_backsector->ffloors) - || gr_frontsector->tag == gr_backsector->tag)) - return; // line is empty, don't even bother - // treat like wide open window instead - HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D - return; - } - if (CheckClip(gr_frontsector, gr_backsector)) { gld_clipper_SafeAddClipRange(angle2, angle1); -- 2.54.0 From f4ac17408e28ee991cd91e23525a0bd3456293a3 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 12 Mar 2024 14:02:46 +0100 Subject: [PATCH 21/25] remove some suff --- src/p_map.c | 249 +--------------------------------------------------- 1 file changed, 2 insertions(+), 247 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 3372fe088..6051d5d1c 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -248,26 +248,6 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) //pflags = object->player->pflags & (PF_JUMPED|PF_SPINNING|PF_THOKKED); // I still need these. P_ResetPlayer(object->player); - - /* // SRB2kart - Springs don't need to change player state in kart. - if (P_MobjFlip(object)*vertispeed > 0) - P_SetPlayerMobjState(object, S_PLAY_SPRING); - else if (P_MobjFlip(object)*vertispeed < 0) - P_SetPlayerMobjState(object, S_PLAY_FALL1); - else // horizontal spring - { - if (pflags & (PF_JUMPED|PF_SPINNING) && object->player->panim == PA_ROLL) - object->player->pflags = pflags; - else - P_SetPlayerMobjState(object, S_PLAY_RUN1); - } - - if (spring->info->painchance) - { - object->player->pflags |= PF_JUMPED; - P_SetPlayerMobjState(object, S_PLAY_ATK1); - } - */ } return true; } @@ -314,14 +294,6 @@ static void P_DoFanAndGasJet(mobj_t *spring, mobj_t *object) if (flipval*object->momz > FixedMul(speed, spring->scale)) object->momz = flipval*FixedMul(speed, spring->scale); - /* // SRB2kart - don't need state change - if (p && !p->powers[pw_tailsfly]) // doesn't reset anim for Tails' flight - { - P_ResetPlayer(p); - if (p->panim != PA_FALL) - P_SetPlayerMobjState(object, S_PLAY_FALL1); - } - */ break; case MT_STEAM: // Steam if (zdist > FixedMul(16*FRACUNIT, spring->scale)) @@ -341,14 +313,6 @@ static void P_DoFanAndGasJet(mobj_t *spring, mobj_t *object) else object->momz = flipval*FixedMul(speed, FixedSqrt(FixedMul(spring->scale, object->scale))); // scale the speed with both objects' scales, just like with springs! - /* // SRB2kart - don't need state change - if (p) - { - P_ResetPlayer(p); - if (p->panim != PA_FALL) - P_SetPlayerMobjState(object, S_PLAY_FALL1); - } - */ break; default: break; @@ -365,10 +329,6 @@ static void P_DoTailsCarry(player_t *sonic, player_t *tails) return; if ((sonic->pflags & PF_CARRIED) && sonic->mo->tracer == tails->mo) return; - - //if (!tails->powers[pw_tailsfly] && !(tails->charability == CA_FLY && (tails->mo->state >= &states[S_PLAY_SPC1] && tails->mo->state <= &states[S_PLAY_SPC4]))) - // return; // SRB2kart - no changey statey - if (tails->bot == 1) return; @@ -407,13 +367,6 @@ static void P_DoTailsCarry(player_t *sonic, player_t *tails) { // Why block opposing teams from tailsflying each other? // Sneaking into the hands of a flying tails player in Race might be a viable strategy, who knows. - /* - if (gametype == GT_RACE || gametype == GT_COMPETITION - || (netgame && (tails->spectator || sonic->spectator)) - || (G_TagGametype() && (!(tails->pflags & PF_TAGIT) != !(sonic->pflags & PF_TAGIT))) - || (gametype == GT_MATCH) - || (G_GametypeHasTeams() && tails->ctfteam != sonic->ctfteam)) - sonic->pflags &= ~PF_CARRIED; */ if (tails->spectator || sonic->spectator || G_RaceGametype()) // SRB2kart sonic->pflags &= ~PF_CARRIED; else @@ -487,35 +440,6 @@ static boolean PIT_CheckThing(mobj_t *thing) } #endif - // Metal Sonic destroys tiny baby objects. - /*if (tmthing->type == MT_METALSONIC_RACE - && (thing->flags & (MF_MISSILE|MF_ENEMY|MF_BOSS) || thing->type == MT_SPIKE)) - { - if ((thing->flags & (MF_ENEMY|MF_BOSS)) && (thing->health <= 0 || !(thing->flags & MF_SHOOTABLE))) - return true; - blockdist = thing->radius + tmthing->radius; - if (abs(thing->x - tmx) >= blockdist || abs(thing->y - tmy) >= blockdist) - return true; // didn't hit it - // see if it went over / under - if (tmthing->z > thing->z + thing->height) - return true; // overhead - if (tmthing->z + tmthing->height < thing->z) - return true; // underneath - if (thing->type == MT_SPIKE) - { - S_StartSound(tmthing, thing->info->deathsound); - for (thing = thing->subsector->sector->thinglist; thing; thing = thing->snext) - if (thing->type == MT_SPIKE && thing->health > 0 && thing->flags & MF_SOLID && P_AproxDistance(thing->x - tmthing->x, thing->y - tmthing->y) < FixedMul(56*FRACUNIT, thing->scale)) - P_KillMobj(thing, tmthing, tmthing); - } - else - { - thing->health = 0; - P_KillMobj(thing, tmthing, tmthing); - } - return true; - }*/ - if (!(thing->flags & (MF_SOLID|MF_SPECIAL|MF_PAIN|MF_SHOOTABLE)) || (thing->flags & MF_NOCLIPTHING)) return true; @@ -1207,21 +1131,7 @@ static boolean PIT_CheckThing(mobj_t *thing) if ((tmthing->type == MT_THROWNBOUNCE && tmthing->fuse > 8*TICRATE) && thing->flags & MF_SOLID) return true; - // Missiles ignore Brak's helper. - /*if (thing->type == MT_BLACKEGGMAN_HELPER) - return true; - - // Hurting Brak - if (tmthing->type == MT_BLACKEGGMAN_MISSILE - && thing->type == MT_BLACKEGGMAN && tmthing->target != thing) - { - // Not if Brak's already in pain - if (!(thing->state >= &states[S_BLACKEGG_PAIN1] && thing->state <= &states[S_BLACKEGG_PAIN35])) - P_SetMobjState(thing, thing->info->painstate); - return false; - }*/ - - if (!(thing->flags & MF_SHOOTABLE)/* && !(thing->type == MT_EGGSHIELD)*/) + if (!(thing->flags & MF_SHOOTABLE)) { // didn't do any damage return !(thing->flags & MF_SOLID); @@ -1232,80 +1142,11 @@ static boolean PIT_CheckThing(mobj_t *thing) && thing->player->pflags & PF_CARRIED && thing->tracer == tmthing->target) return true; // Don't give rings to your carry player by accident. - /*if (thing->type == MT_EGGSHIELD) - { - fixed_t touchx, touchy; - angle_t angle; - - if (P_AproxDistance(tmthing->x-thing->x, tmthing->y-thing->y) > - P_AproxDistance((tmthing->x-tmthing->momx)-thing->x, (tmthing->y-tmthing->momy)-thing->y)) - { - touchx = tmthing->x + tmthing->momx; - touchy = tmthing->y + tmthing->momy; - } - else - { - touchx = tmthing->x; - touchy = tmthing->y; - } - - angle = R_PointToAngle2(thing->x, thing->y, touchx, touchy) - thing->angle; - - if (!(angle > ANGLE_90 && angle < ANGLE_270)) // hit front of shield, didn't destroy it - return false; - else // hit shield from behind, shield is destroyed! - { - P_KillMobj(thing, tmthing, tmthing); - return false; - } - }*/ - if (tmthing->type == MT_SHELL && tmthing->threshold > TICRATE) return true; // damage / explode if (tmthing->flags & MF_ENEMY) // An actual ENEMY! (Like the deton, for example) P_DamageMobj(thing, tmthing, tmthing, 1); - /*else if (tmthing->type == MT_BLACKEGGMAN_MISSILE && thing->player - && (thing->player->pflags & PF_JUMPED) - && !thing->player->powers[pw_flashing] - && thing->tracer != tmthing - && tmthing->target != thing) - { - // Hop on the missile for a ride! - thing->player->pflags |= PF_ITEMHANG; - thing->player->pflags &= ~PF_JUMPED; - P_SetTarget(&thing->tracer, tmthing); - P_SetTarget(&tmthing->target, thing); // Set owner to the player - P_SetTarget(&tmthing->tracer, NULL); // Disable homing-ness - tmthing->momz = 0; - - thing->angle = tmthing->angle; - - if (!demo.playback || P_AnalogMove(thing->player)) - { - if (thing->player == &players[consoleplayer]) - localangle[0] = thing->angle; - else if (thing->player == &players[displayplayers[1]]) - localangle[1] = thing->angle; - else if (thing->player == &players[displayplayers[2]]) - localangle[2] = thing->angle; - else if (thing->player == &players[displayplayers[3]]) - localangle[3] = thing->angle; - } - - return true; - } - else if (tmthing->type == MT_BLACKEGGMAN_MISSILE && thing->player && ((thing->player->pflags & PF_ITEMHANG) || (thing->player->pflags & PF_JUMPED))) - { - // Ignore - } - else if (tmthing->type == MT_BLACKEGGMAN_GOOPFIRE) - { - P_UnsetThingPosition(tmthing); - tmthing->x = thing->x; - tmthing->y = thing->y; - P_SetThingPosition(tmthing); - }*/ else P_DamageMobj(thing, tmthing, tmthing->target, 1); @@ -1374,29 +1215,6 @@ static boolean PIT_CheckThing(mobj_t *thing) P_SetTarget(&thing->target, tmthing); } - // Respawn rings and items - /*if ((tmthing->type == MT_NIGHTSDRONE || thing->type == MT_NIGHTSDRONE) - && (tmthing->player || thing->player)) - { - mobj_t *droneobj = (tmthing->type == MT_NIGHTSDRONE) ? tmthing : thing; - player_t *pl = (droneobj == thing) ? tmthing->player : thing->player; - - // Must be in bonus time, and must be NiGHTS, must wait about a second - // must be flying in the SAME DIRECTION as the last time you came through. - // not (your direction) xor (stored direction) - // In other words, you can't u-turn and respawn rings near the drone. - if (pl->bonustime && (pl->pflags & PF_NIGHTSMODE) && (INT32)leveltime > droneobj->extravalue2 && ( - !(pl->flyangle > 90 && pl->flyangle < 270) - ^ (droneobj->extravalue1 > 90 && droneobj->extravalue1 < 270) - )) - { - // Reload all the fancy ring stuff! - P_ReloadRings(); - } - droneobj->extravalue1 = pl->flyangle; - droneobj->extravalue2 = (INT32)leveltime + TICRATE; - }*/ - // check for special pickup if (thing->flags & MF_SPECIAL && tmthing->player) { @@ -1469,71 +1287,10 @@ static boolean PIT_CheckThing(mobj_t *thing) P_DamageMobj(thing, tmthing, tmthing, 1); else if (thing->player->kartstuff[k_invincibilitytimer] && !tmthing->player->kartstuff[k_invincibilitytimer]) P_DamageMobj(tmthing, thing, thing, 1); - - /*if (G_BattleGametype() && (!G_GametypeHasTeams() || tmthing->player->ctfteam != thing->player->ctfteam)) - { - if ((tmthing->player->powers[pw_invulnerability] || tmthing->player->powers[pw_super]) - && !thing->player->powers[pw_super]) - P_DamageMobj(thing, tmthing, tmthing, 1); - else if ((thing->player->powers[pw_invulnerability] || thing->player->powers[pw_super]) - && !tmthing->player->powers[pw_super]) - P_DamageMobj(tmthing, thing, thing, 1); - } - - // If players are using touch tag, seekers damage hiders. - if (G_TagGametype() && cv_touchtag.value && - ((thing->player->pflags & PF_TAGIT) != (tmthing->player->pflags & PF_TAGIT))) - { - if ((tmthing->player->pflags & PF_TAGIT) && !(thing->player->pflags & PF_TAGIT)) - P_DamageMobj(thing, tmthing, tmthing, 1); - else if ((thing->player->pflags & PF_TAGIT) && !(tmthing->player->pflags & PF_TAGIT)) - P_DamageMobj(tmthing, thing, tmthing, 1); - }*/ } - // Force solid players in hide and seek to avoid corner stacking. - // Kart: No Tailspickup ever, players are always solid - /*if (cv_tailspickup.value && gametype != GT_HIDEANDSEEK) - { - if (tmthing->player && thing->player) - { - P_DoTailsCarry(thing->player, tmthing->player); - return true; - } - } - else if (thing->player) { - if (thing->player-players == consoleplayer && botingame) - //CV_SetValue(&cv_analog2, true); - thing->player->pflags &= ~PF_CARRIED; - }*/ - if (thing->player) { - // Doesn't matter what gravity player's following! Just do your stuff in YOUR direction only - /*if (tmthing->eflags & MFE_VERTICALFLIP - && (tmthing->z + tmthing->height + tmthing->momz < thing->z - || tmthing->z + tmthing->height + tmthing->momz >= thing->z + thing->height)) - ; - else if (!(tmthing->eflags & MFE_VERTICALFLIP) - && (tmthing->z + tmthing->momz > thing->z + thing->height - || tmthing->z + tmthing->momz <= thing->z)) - ; - else if (P_IsObjectOnGround(thing) - && !P_IsObjectOnGround(tmthing) // Don't crush if the monitor is on the ground... - && (tmthing->flags & MF_SOLID)) - { - if (tmthing->flags & (MF_MONITOR|MF_PUSHABLE)) - { - // Objects kill you if it falls from above. - if (thing != tmthing->target) - P_DamageMobj(thing, tmthing, tmthing->target, 10000); - - tmthing->momz = -tmthing->momz/2; // Bounce, just for fun! - // The tmthing->target allows the pusher of the object - // to get the point if he topples it on an opponent. - } - }*/ - if (tmthing->type == MT_FAN || tmthing->type == MT_STEAM) P_DoFanAndGasJet(tmthing, thing); } @@ -1755,9 +1512,7 @@ static boolean PIT_CheckThing(mobj_t *thing) ; // Fix a few nasty spring-jumping bugs that happen sometimes. // Monitors are not treated as solid to players who are jumping, spinning or gliding, // unless it's a CTF team monitor and you're on the wrong team - /*else if (thing->flags & MF_MONITOR && tmthing->player && tmthing->player->pflags & (PF_JUMPED|PF_SPINNING|PF_GLIDING) - && !((thing->type == MT_REDRINGBOX && tmthing->player->ctfteam != 1) || (thing->type == MT_BLUERINGBOX && tmthing->player->ctfteam != 2))) - ;*/ + // z checking at last // Treat noclip things as non-solid! else if ((thing->flags & (MF_SOLID|MF_NOCLIP)) == MF_SOLID -- 2.54.0 From 98d03edf23eedf53702845f44239c6a106c6c6b1 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 13 Mar 2024 08:48:04 +0100 Subject: [PATCH 22/25] Ensure opaque midtextures always use PF_Masked --- src/hardware/hw_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 83b3910cd..1c18a5325 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1331,7 +1331,7 @@ void HWR_DrawSkyWall(FOutVector *wallVerts, FSurfaceInfo *Surf) // Returns true if the midtexture is visible, and false if... it isn't... static boolean HWR_BlendMidtextureSurface(FSurfaceInfo *pSurf) { - FUINT blendmode = 0; + FUINT blendmode = PF_Masked; pSurf->PolyColor.s.alpha = 0xFF; -- 2.54.0 From 1457000f81d02c527562c3e8af28c34544a292b0 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 13 Mar 2024 09:57:05 +0100 Subject: [PATCH 23/25] remove xs_CRoundToInt while ye, less exact stuff doesent matter too much in the context of doom, it matters more in kart, due to polygon rendering and seg processing being extremely heavy and also generally more complex maps --- src/hardware/hw_clip.c | 2 +- src/m_fixed.h | 35 ----------------------------------- 2 files changed, 1 insertion(+), 36 deletions(-) diff --git a/src/hardware/hw_clip.c b/src/hardware/hw_clip.c index be8b21dcd..de27433c4 100644 --- a/src/hardware/hw_clip.c +++ b/src/hardware/hw_clip.c @@ -339,7 +339,7 @@ angle_t gld_FrustumAngle(angle_t tiltangle) floatangle = 2.0f + (45.0f + (tilt / 1.9f)) * clipfov / 90.0f; if (floatangle >= 180.0) return 0xffffffff; - a1 = (angle_t)xs_CRoundToInt(ANG1 * floatangle); + a1 = ANG1 * (int)floatangle; return a1; } diff --git a/src/m_fixed.h b/src/m_fixed.h index 9fe35c91d..4e4c79c65 100644 --- a/src/m_fixed.h +++ b/src/m_fixed.h @@ -260,41 +260,6 @@ typedef struct fixed_t y; } vector2_t; -// Source: "Know Your FPU: Fixing Floating Fast" -// http://www.stereopsis.com/sree/fpu2006.html -// -// xs_CRoundToInt: Round toward nearest, but ties round toward even (just like FISTP) -// taken from prboom+ for OpenGL big room fix -#ifndef _xs_DEFAULT_CONVERSION -#define _xs_DEFAULT_CONVERSION 0 -#endif //_xs_DEFAULT_CONVERSION - -#ifdef WORDS_BIGENDIAN - #define _xs_iexp_ 0 - #define _xs_iman_ 1 -#else - #define _xs_iexp_ 1 //intel is little endian - #define _xs_iman_ 0 -#endif //BigEndian_ - -typedef double real64; -typedef union _xs_doubleints -{ - real64 val; - unsigned ival[2]; -} _xs_doubleints; - -FUNCMATH FUNCINLINE ATTRINLINE int xs_CRoundToInt(real64 val) -{ -#if _xs_DEFAULT_CONVERSION==0 - _xs_doubleints uval; - uval.val = val + 6755399441055744.0; - return uval.ival[_xs_iman_]; -#else - return int(floor(val+.5)); -#endif -} - vector2_t *FV2_Load(vector2_t *vec, fixed_t x, fixed_t y); vector2_t *FV2_UnLoad(vector2_t *vec, fixed_t *x, fixed_t *y); vector2_t *FV2_Copy(vector2_t *a_o, const vector2_t *a_i); -- 2.54.0 From c96b51d3190b38a1e74d6a4bfd5fcec12ef07308 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 13 Mar 2024 10:07:51 +0100 Subject: [PATCH 24/25] forgor menu stuff --- src/m_menu.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index a9cac9ecd..7fc8c98bf 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4340,7 +4340,6 @@ void M_Init(void) if (rendermode == render_opengl) { - OP_ExpOptionsMenu[op_exp_angleshit].status = IT_DISABLED; OP_ExpOptionsMenu[op_exp_ffclip].status = IT_DISABLED; OP_ExpOptionsMenu[op_exp_sprclip].status = IT_DISABLED; } -- 2.54.0 From 3b5f9dd55af965eafd522125a7e0b8093fbaca7d Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 13 Mar 2024 10:16:07 +0100 Subject: [PATCH 25/25] clean up --- src/hardware/hw_clip.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/hardware/hw_clip.c b/src/hardware/hw_clip.c index de27433c4..926f68fc6 100644 --- a/src/hardware/hw_clip.c +++ b/src/hardware/hw_clip.c @@ -324,8 +324,6 @@ angle_t gld_FrustumAngle(angle_t tiltangle) float tilt = (float)fabs(((double)(int)tiltangle) / ANG1); - // NEWCLIP TODO: SRB2CBTODO: make a global render_fov for this function - if (tilt > 90.0f) tilt = 90.0f; @@ -344,7 +342,6 @@ angle_t gld_FrustumAngle(angle_t tiltangle) } - // SRB2CB I don't think used any of this stuff, let's disable for now since SRB2 probably doesn't want it either // compiler complains about (p)glGetFloatv anyway, in case anyone wants this // only r_opengl.c can use the base gl funcs as it turns out, that's a problem for whoever wants sphere frustum checks -- 2.54.0