diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 8158c28b8..1485f4d91 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -258,7 +258,7 @@ void yax_updategrays(int32_t posze) // all references to floor/ceiling bunchnums should be through the // get/set functions! -static int32_t g_nodraw = 0; +int32_t g_nodraw = 0; int32_t scansector_retfast = 0; static int32_t scansector_collectsprites = 1; static int32_t yax_globalcf = -1; @@ -526,7 +526,7 @@ static int16_t bunchsec[YAX_MAXBUNCHES], bunchdist[YAX_MAXBUNCHES]; static int32_t ymostallocsize = 0; // numyaxbunches*xdimen (no sizeof(int16_t) here!) static int16_t *yumost=NULL, *ydmost=NULL; // used as if [numyaxbunches][xdimen] -static uint8_t haveymost[YAX_MAXBUNCHES>>3]; +uint8_t haveymost[YAX_MAXBUNCHES>>3]; // adapted from build.c static void yax_getclosestpointonwall(int32_t dawall, int32_t *closestx, int32_t *closesty) @@ -722,7 +722,7 @@ void yax_preparedrawrooms(void) Bmemset(yax_spritesortcnt, 0, sizeof(yax_spritesortcnt)); Bmemset(haveymost, 0, (numyaxbunches+7)>>3); - if (ymostallocsize < xdimen*numyaxbunches) + if (getrendermode()==0 && ymostallocsize < xdimen*numyaxbunches) { ymostallocsize = xdimen*numyaxbunches; yumost = Brealloc(yumost, ymostallocsize*sizeof(int16_t)); diff --git a/polymer/eduke32/build/src/engine_priv.h b/polymer/eduke32/build/src/engine_priv.h index e8750386a..e725d54e4 100644 --- a/polymer/eduke32/build/src/engine_priv.h +++ b/polymer/eduke32/build/src/engine_priv.h @@ -76,7 +76,10 @@ int32_t animateoffs(int16_t tilenum, int16_t fakevar); extern void polymost_scansector(int32_t sectnum); #endif int32_t engine_addtsprite(int16_t z, int16_t sectnum); -int32_t scansector_retfast; +extern int32_t g_nodraw, scansector_retfast; +#ifdef YAX_ENABLE +extern uint8_t haveymost[YAX_MAXBUNCHES>>3]; +#endif #ifdef YAX_DEBUG extern char m32_debugstr[64][128]; diff --git a/polymer/eduke32/build/src/polymost.c b/polymer/eduke32/build/src/polymost.c index 7fc38dddc..449b3eb35 100644 --- a/polymer/eduke32/build/src/polymost.c +++ b/polymer/eduke32/build/src/polymost.c @@ -99,10 +99,10 @@ int32_t rendmode=0; int32_t usemodels=1, usehightile=1; #include //<-important! -typedef struct { float x, cy[2], fy[2]; int32_t n, p, tag, ctag, ftag; } vsptyp; +typedef struct { float x, cy[2], fy[2]; int32_t tag; int16_t n, p, ctag, ftag; } vsptyp; #define VSPMAX 4096 //<- careful! static vsptyp vsp[VSPMAX]; -static int32_t vcnt, gtag; +static int32_t gtag; static double dxb1[MAXWALLSB], dxb2[MAXWALLSB]; @@ -1993,7 +1993,7 @@ void drawpoly(double *dpx, double *dpy, int32_t n, int32_t method) // backup of the n for possible redrawing of fullbright int32_t n_ = n, method_ = method; - if (method == -1) return; + if (method == -1 || g_nodraw) return; if (n == 3) { @@ -2788,15 +2788,36 @@ void drawpoly(double *dpx, double *dpy, int32_t n, int32_t method) #endif } + +static void vsp_finalize_init(vsptyp *vsp, int32_t vcnt) +{ + int32_t i; + + for (i=0; i 0))) - { spx[scnt] = x0; spy[scnt] = y0; spt[scnt] = -1; scnt++; } + { spx[scnt] = x0; /*spy[scnt] = y0;*/ spt[scnt] = -1; scnt++; } } //Test for intersection on umost (j == 0) and dmost (j == 1) @@ -2969,7 +2979,7 @@ void domost(float x0, float y0, float x1, float y1) t = n/d; nx = (x1-x0)*t + x0; if ((nx > nx0) && (nx < nx1)) { - spx[scnt] = nx; spy[scnt] = (y1-y0)*t + y0; + spx[scnt] = nx; /* spy[scnt] = (y1-y0)*t + y0; */ spt[scnt] = j; scnt++; } } @@ -2979,7 +2989,7 @@ void domost(float x0, float y0, float x1, float y1) if ((scnt >= 2) && (spx[scnt-1] < spx[scnt-2])) { f = spx[scnt-1]; spx[scnt-1] = spx[scnt-2]; spx[scnt-2] = f; - f = spy[scnt-1]; spy[scnt-1] = spy[scnt-2]; spy[scnt-2] = f; + /* f = spy[scnt-1]; spy[scnt-1] = spy[scnt-2]; spy[scnt-2] = f; */ j = spt[scnt-1]; spt[scnt-1] = spt[scnt-2]; spt[scnt-2] = j; } @@ -2988,7 +2998,7 @@ void domost(float x0, float y0, float x1, float y1) { t = (x1-nx0)*cv[dir] - (y1-cy[dir])*dx; if (((!dir) && (t < 0)) || ((dir) && (t > 0))) - { spx[scnt] = x1; spy[scnt] = y1; spt[scnt] = -1; scnt++; } + { spx[scnt] = x1; /* spy[scnt] = y1; */ spt[scnt] = -1; scnt++; } } vsp[i].tag = vsp[newi].tag = -1; @@ -2996,7 +3006,7 @@ void domost(float x0, float y0, float x1, float y1) { if (z < scnt) { - vcnt = vsinsaft(i); + vcnt = vsinsaft(vsp, i); t = (spx[z]-nx0)/dx; vsp[i].cy[1] = t*cv[0] + cy[0]; vsp[i].fy[1] = t*cv[1] + cy[1]; @@ -3033,31 +3043,26 @@ void domost(float x0, float y0, float x1, float y1) if (!dir) { + dpx[0] = dx0; dpy[0] = vsp[i].cy[0]; + dpx[1] = dx1; dpy[1] = vsp[i].cy[1]; + switch (k) { case 1: case 2: - dpx[0] = dx0; dpy[0] = vsp[i].cy[0]; - dpx[1] = dx1; dpy[1] = vsp[i].cy[1]; dpx[2] = dx0; dpy[2] = ny0; drawpoly(dpx,dpy,3,domostpolymethod); vsp[i].cy[0] = ny0; vsp[i].ctag = gtag; break; case 3: case 6: - dpx[0] = dx0; dpy[0] = vsp[i].cy[0]; - dpx[1] = dx1; dpy[1] = vsp[i].cy[1]; dpx[2] = dx1; dpy[2] = ny1; drawpoly(dpx,dpy,3,domostpolymethod); vsp[i].cy[1] = ny1; vsp[i].ctag = gtag; break; case 4: case 5: case 7: - dpx[0] = dx0; dpy[0] = vsp[i].cy[0]; - dpx[1] = dx1; dpy[1] = vsp[i].cy[1]; dpx[2] = dx1; dpy[2] = ny1; dpx[3] = dx0; dpy[3] = ny0; drawpoly(dpx,dpy,4,domostpolymethod); vsp[i].cy[0] = ny0; vsp[i].cy[1] = ny1; vsp[i].ctag = gtag; break; case 8: - dpx[0] = dx0; dpy[0] = vsp[i].cy[0]; - dpx[1] = dx1; dpy[1] = vsp[i].cy[1]; dpx[2] = dx1; dpy[2] = vsp[i].fy[1]; dpx[3] = dx0; dpy[3] = vsp[i].fy[0]; drawpoly(dpx,dpy,4,domostpolymethod); vsp[i].ctag = vsp[i].ftag = -1; break; @@ -3110,9 +3115,16 @@ void domost(float x0, float y0, float x1, float y1) while (i) { ni = vsp[i].n; - if ((vsp[i].cy[0] >= vsp[i].fy[0]) && (vsp[i].cy[1] >= vsp[i].fy[1])) { vsp[i].ctag = vsp[i].ftag = -1; } + + if ((vsp[i].cy[0] >= vsp[i].fy[0]) && (vsp[i].cy[1] >= vsp[i].fy[1])) + vsp[i].ctag = vsp[i].ftag = -1; + if ((vsp[i].ctag == vsp[ni].ctag) && (vsp[i].ftag == vsp[ni].ftag)) - { vsp[i].cy[1] = vsp[ni].cy[1]; vsp[i].fy[1] = vsp[ni].fy[1]; vsdel(ni); } + { + vsp[i].cy[1] = vsp[ni].cy[1]; + vsp[i].fy[1] = vsp[ni].fy[1]; + vsdel(vsp, ni); + } else i = ni; } }