--- deliantra/Deliantra-Client/Client.xs 2007/04/20 17:25:41 1.184 +++ deliantra/Deliantra-Client/Client.xs 2007/04/21 09:21:03 1.185 @@ -1602,6 +1602,7 @@ // rather ugly, if you ask me // could also be stored inside mapcell and updated on change memset (smooth_max, 0, sizeof (smooth_max)); + memset (smooth_level, 0, sizeof (smooth_level)); for (y = 0; y < sh; y++) if (0 <= y + my && y + my < self->rows) @@ -1622,8 +1623,6 @@ for (z = 0; z <= 2; z++) { - memset (smooth_level, 0, sizeof (smooth_level)); - for (y = 0; y < sh; y++) if (0 <= y + my && y + my < self->rows) { @@ -1718,79 +1717,79 @@ } } } + } - // go through all smoothlevels, lowest to highest, then draw. - // this is basically counting sort + // go through all smoothlevels, lowest to highest, then draw. + // this is basically counting sort + { + int w, b; + + for (w = 0; w < 256 / 32; ++w) { - int w, b; + uint32_t smask = smooth_level [w]; + if (smask) + for (b = 0; b < 32; ++b) + if (smask & (((uint32_t)1) << b)) + { + int level = (w << 5) | b; + HE *he; - for (w = 0; w < 256 / 32; ++w) - { - uint32_t smask = smooth_level [w]; - if (smask) - for (b = 0; b < 32; ++b) - if (smask & (((uint32_t)1) << b)) + hv_iterinit (smooth); + while ((he = hv_iternext (smooth))) { - int level = (w << 5) | b; - HE *he; + smooth_key *skey = (smooth_key *)HeKEY (he); + IV bits = SvIVX (HeVAL (he)); - hv_iterinit (smooth); - while ((he = hv_iternext (smooth))) + if (!(bits & 0x1000) + && skey->level == level + && level >= smooth_max [skey->x][skey->y]) { - smooth_key *skey = (smooth_key *)HeKEY (he); - IV bits = SvIVX (HeVAL (he)); + maptex tex = self->tex [skey->tile]; + int px = (((int)skey->x) - 1) * T; + int py = (((int)skey->y) - 1) * T; + int border = bits & 15; + int corner = (bits >> 8) & ~(bits >> 4) & 15; + float dx = tex.s * .0625f; // 16 images/row + float dy = tex.t * .5f ; // 2 images/column + + // this time naively avoiding texture state changes + // save gobs of state changes. + if (last_name != tex.name) + { + if (!tex.name) + continue; // smoothing not yet available + + glEnd (); + glBindTexture (GL_TEXTURE_2D, last_name = tex.name); + glBegin (GL_QUADS); + } - if (!(bits & 0x1000) - && skey->level == level - && level >= smooth_max [skey->x][skey->y]) + if (border) { - maptex tex = self->tex [skey->tile]; - int px = (((int)skey->x) - 1) * T; - int py = (((int)skey->y) - 1) * T; - int border = bits & 15; - int corner = (bits >> 8) & ~(bits >> 4) & 15; - float dx = tex.s * .0625f; // 16 images/row - float dy = tex.t * .5f ; // 2 images/column - - // this time naively avoiding texture state changes - // save gobs of state changes. - if (last_name != tex.name) - { - if (!tex.name) - continue; // smoothing not yet available - - glEnd (); - glBindTexture (GL_TEXTURE_2D, last_name = tex.name); - glBegin (GL_QUADS); - } - - if (border) - { - float ox = border * dx; - - glTexCoord2f (ox , 0.f ); glVertex2f (px , py ); - glTexCoord2f (ox , dy ); glVertex2f (px , py + T); - glTexCoord2f (ox + dx, dy ); glVertex2f (px + T, py + T); - glTexCoord2f (ox + dx, 0.f ); glVertex2f (px + T, py ); - } - - if (corner) - { - float ox = corner * dx; - - glTexCoord2f (ox , dy ); glVertex2f (px , py ); - glTexCoord2f (ox , dy * 2.f); glVertex2f (px , py + T); - glTexCoord2f (ox + dx, dy * 2.f); glVertex2f (px + T, py + T); - glTexCoord2f (ox + dx, dy ); glVertex2f (px + T, py ); - } + float ox = border * dx; + + glTexCoord2f (ox , 0.f ); glVertex2f (px , py ); + glTexCoord2f (ox , dy ); glVertex2f (px , py + T); + glTexCoord2f (ox + dx, dy ); glVertex2f (px + T, py + T); + glTexCoord2f (ox + dx, 0.f ); glVertex2f (px + T, py ); + } + + if (corner) + { + float ox = corner * dx; + + glTexCoord2f (ox , dy ); glVertex2f (px , py ); + glTexCoord2f (ox , dy * 2.f); glVertex2f (px , py + T); + glTexCoord2f (ox + dx, dy * 2.f); glVertex2f (px + T, py + T); + glTexCoord2f (ox + dx, dy ); glVertex2f (px + T, py ); } } } - } + } } + } - hv_clear (smooth); - } + //hv_clear (smooth); glEnd ();