From 5a6a9c30d1aef72b39ab8b6866eb4a237b187314 Mon Sep 17 00:00:00 2001 From: stevenaaus Date: Wed, 24 Aug 2011 07:47:29 +0000 Subject: [PATCH] z-fighting (flickering gl texture clash most notable in e1m1) bug fix, from Sander. git-svn-id: http://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@480 af15c1b1-3010-417e-b628-4374ebc0bcbd --- Quake/gl_rmain.c | 2 ++ Quake/gl_rmisc.c | 4 ++++ Quake/quakedef.h | 2 ++ Quake/r_brush.c | 14 ++++++++++++++ Quake/world.c | 3 --- 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Quake/gl_rmain.c b/Quake/gl_rmain.c index 1cc642a2..bb4baf98 100644 --- a/Quake/gl_rmain.c +++ b/Quake/gl_rmain.c @@ -103,6 +103,8 @@ cvar_t r_nolerp_list = {"r_nolerp_list", "progs/flame.mdl,progs/flame2.mdl,progs extern cvar_t r_vfog; //johnfitz +cvar_t gl_zfix = {"gl_zfix", "1", true}; // QuakeSpasm z-fighting fix + qboolean r_drawflat_cheatsafe, r_fullbright_cheatsafe, r_lightmap_cheatsafe, r_drawworld_cheatsafe; //johnfitz /* diff --git a/Quake/gl_rmisc.c b/Quake/gl_rmisc.c index 718aa97c..521656fe 100644 --- a/Quake/gl_rmisc.c +++ b/Quake/gl_rmisc.c @@ -45,6 +45,8 @@ extern cvar_t r_lerpmove; extern cvar_t r_nolerp_list; //johnfitz +extern cvar_t gl_zfix; // QuakeSpasm z-fighting fix + extern float load_subdivide_size; //johnfitz -- remember what subdivide_size value was when this map was loaded extern cvar_t gl_subdivide_size; //johnfitz -- moved here from gl_model.c @@ -240,6 +242,8 @@ void R_Init (void) Cvar_RegisterVariable (&r_nolerp_list, R_NoLerpList_f); //johnfitz + Cvar_RegisterVariable (&gl_zfix, NULL); // QuakeSpasm z-fighting fix + Cvar_RegisterVariable (&gl_subdivide_size, NULL); //johnfitz -- moved here from gl_model.c R_InitParticles (); diff --git a/Quake/quakedef.h b/Quake/quakedef.h index 9659eaae..c121ae75 100644 --- a/Quake/quakedef.h +++ b/Quake/quakedef.h @@ -73,6 +73,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define ON_EPSILON 0.1 // point on plane side epsilon +#define DIST_EPSILON (0.03125) // 1/32 epsilon to keep floating point happy (moved from world.c) + #define MAX_MSGLEN 32000 // max length of a reliable message //johnfitz -- was 8000 #define MAX_DATAGRAM 32000 // max length of unreliable message //johnfitz -- was 1024 diff --git a/Quake/r_brush.c b/Quake/r_brush.c index 8c2e135a..f9ee5c1e 100644 --- a/Quake/r_brush.c +++ b/Quake/r_brush.c @@ -25,6 +25,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern cvar_t gl_fullbrights, r_drawflat, gl_overbright, r_oldwater; //johnfitz +extern cvar_t gl_zfix; // QuakeSpasm z-fighting fix + int gl_lightmap_format; int lightmap_bytes; @@ -543,7 +545,19 @@ void R_DrawBrushModel (entity_t *e) glPushMatrix (); e->angles[0] = -e->angles[0]; // stupid quake bug + if (gl_zfix.value) + { + e->origin[0] -= DIST_EPSILON; + e->origin[1] -= DIST_EPSILON; + e->origin[2] -= DIST_EPSILON; + } R_RotateForEntity (e->origin, e->angles); + if (gl_zfix.value) + { + e->origin[0] += DIST_EPSILON; + e->origin[1] += DIST_EPSILON; + e->origin[2] += DIST_EPSILON; + } e->angles[0] = -e->angles[0]; // stupid quake bug // diff --git a/Quake/world.c b/Quake/world.c index c6db6b5a..64cfa8f8 100644 --- a/Quake/world.c +++ b/Quake/world.c @@ -556,9 +556,6 @@ LINE TESTING IN HULLS =============================================================================== */ -// 1/32 epsilon to keep floating point happy -#define DIST_EPSILON (0.03125) - /* ================== SV_RecursiveHullCheck