diff --git a/source/src/protos.h b/source/src/protos.h index 74fc58ca..fe957777 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -271,10 +271,7 @@ extern void resetcubes(); extern void setupstrips(); extern void renderstripssky(); extern void renderstrips(); - -extern vec shadowtexgenS, shadowtexgenT; - -extern void rendershadow(int x, int y, int xs, int ys); +extern void rendershadow(int x, int y, int xs, int ys, const vec &texgenS, const vec &texgenT); // water extern void setwatercolor(const char *r = "", const char *g = "", const char *b = "", const char *a = ""); diff --git a/source/src/rendercubes.cpp b/source/src/rendercubes.cpp index e632597d..4a0a916e 100644 --- a/source/src/rendercubes.cpp +++ b/source/src/rendercubes.cpp @@ -369,8 +369,6 @@ static void resetshadowverts() static void rendershadowstrips() { - stripend(shadowverts); - glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); @@ -396,12 +394,8 @@ static void rendershadowstrips() #define shadowvert(v1, v2, v3) { \ shadowvertex &v = shadowverts.add(); \ v.x = (float)(v1); v.y = (float)(v2); v.z = (float)(v3); \ - v.u = v.x*shadowtexgenS.x + v.y*shadowtexgenS.y + shadowtexgenS.z; \ - v.v = v.x*shadowtexgenT.x + v.y*shadowtexgenT.y + shadowtexgenT.z; \ } -vec shadowtexgenS, shadowtexgenT; - void rendershadow_tri(sqr *h, int x1, int y1, int x2, int y2, int x3, int y3) // floor tris on a corner cube { stripend(shadowverts); @@ -473,7 +467,7 @@ static void rendershadow_flatdelta(int x, int y, float h1, float h2, float h3, f oy = y; } -void rendershadow(int x, int y, int xs, int ys) +void rendershadow(int x, int y, int xs, int ys, const vec &texgenS, const vec &texgenT) { x = max(x, 1); y = max(y, 1); @@ -530,6 +524,15 @@ void rendershadow(int x, int y, int xs, int ys) } } + stripend(shadowverts); + + for(shadowvertex *v = shadowverts.getbuf(), *end = &v[shadowverts.length()]; v < end; v++) + { + float vx = v->x, vy = v->y; + v->u = vx*texgenS.x + vy*texgenS.y + texgenS.z; + v->v = vx*texgenT.x + vy*texgenT.y + texgenT.z; + } + rendershadowstrips(); } diff --git a/source/src/vertmodel.h b/source/src/vertmodel.h index 4e7f0793..4502d5c0 100644 --- a/source/src/vertmodel.h +++ b/source/src/vertmodel.h @@ -1159,15 +1159,16 @@ struct vertmodel : model lasttexcoordarray = NULL; } - shadowtexgenS.x = c / (2*shadowrad); - shadowtexgenS.y = s / (2*shadowrad); - shadowtexgenS.z = -(x1*c - y2*s + o.x)*shadowtexgenS.x - (y2*c + x1*s + o.y)*shadowtexgenS.y; + vec texgenS, texgenT; + texgenS.x = c / (2*shadowrad); + texgenS.y = s / (2*shadowrad); + texgenS.z = -(x1*c - y2*s + o.x)*texgenS.x - (y2*c + x1*s + o.y)*texgenS.y; - shadowtexgenT.x = s / (2*shadowrad); - shadowtexgenT.y = -c / (2*shadowrad); - shadowtexgenT.z = -(x1*c - y2*s + o.x)*shadowtexgenT.x - (y2*c + x1*s + o.y)*shadowtexgenT.y; + texgenT.x = s / (2*shadowrad); + texgenT.y = -c / (2*shadowrad); + texgenT.z = -(x1*c - y2*s + o.x)*texgenT.x - (y2*c + x1*s + o.y)*texgenT.y; - ::rendershadow(int(floor(o.x-shadowrad)), int(floor(o.y-shadowrad)), int(ceil(o.x+shadowrad)), int(ceil(o.y+shadowrad))); + ::rendershadow(int(floor(o.x-shadowrad)), int(floor(o.y-shadowrad)), int(ceil(o.x+shadowrad)), int(ceil(o.y+shadowrad)), texgenS, texgenT); } char *shadowfile()