From a50af06efc1ef71acc5d6fc11e98470e3a600190 Mon Sep 17 00:00:00 2001 From: Spoike Date: Thu, 13 Feb 2014 23:37:33 +0000 Subject: [PATCH] fix some warnings. properly fix v1 holes. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4607 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/gl/gl_heightmap.c | 52 +++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/engine/gl/gl_heightmap.c b/engine/gl/gl_heightmap.c index a54a949e6..c18556327 100644 --- a/engine/gl/gl_heightmap.c +++ b/engine/gl/gl_heightmap.c @@ -588,7 +588,8 @@ static void *Terr_ReadV1(heightmap_t *hm, hmsection_t *s, void *ptr, int len) { int x = (i & 7); int y = (i>>3); - if (ds->holes & ((x>>1)|((y>>1)<<3))) + int b = (1u<<(x>>1)) << ((y>>1)<<2); + if (ds->holes & b) s->holes[y] |= 1u<minh; struct hmwater_s *w = s->water; memset(&ds, 0, sizeof(ds)); @@ -1491,10 +1490,23 @@ static void Terr_SaveV1(heightmap_t *hm, hmsection_t *s, vfsfile_t *f, int sx, i { int x = (i & 7); int y = (i>>3); + int b = (1u<<(x>>1)) << ((y>>1)<<2); if (s->holes[y] & (1u<>1)|((y>>1)<<3)); + ds.holes |= b; } + //make sure the user can see the holes they just saved. + memset(s->holes, 0, sizeof(s->holes)); + for (i = 0; i < 8*8; i++) + { + int x = (i & 7); + int y = (i>>3); + int b = (1u<<(x>>1)) << ((y>>1)<<2); + if (ds.holes & b) + s->holes[y] |= 1u<flags |= TSF_DIRTY; + lm = lightmap[s->lightmap]->lightmaps; lm += (s->lmy * HMLMSTRIDE + s->lmx) * lightmap_bytes; for (i = 0; i < SECTTEXSIZE; i++) @@ -1521,7 +1533,6 @@ static void Terr_SaveV1(heightmap_t *hm, hmsection_t *s, vfsfile_t *f, int sx, i } } ds.waterheight = w?w->heights[4*8+4]:s->minh; - ds.holes = 0;//s->holes; ds.minh = s->minh; ds.maxh = s->maxh; ds.ents_num = s->numents; @@ -2165,8 +2176,8 @@ static void Terr_RebuildMesh(model_t *model, hmsection_t *s, int x, int y) int holerow; //skip generation of the mesh above holes - holerow = vy/(SECTHEIGHTSIZE>>1); - holebit = 1u<<(vx/(SECTHEIGHTSIZE>>1)); + holerow = ((vy<<3)/(SECTHEIGHTSIZE-1)); + holebit = 1u<<((vx<<3)/(SECTHEIGHTSIZE-1)); if (s->holes[holerow] & holebit) continue; #endif @@ -2394,8 +2405,8 @@ static void Terr_RebuildMesh(model_t *model, hmsection_t *s, int x, int y) int holebit; //skip generation of the mesh above holes - holerow = vy/(SECTHEIGHTSIZE>>1); - holebit = 1u<<(vx/(SECTHEIGHTSIZE>>1)); + holerow = ((vy<<3)/(SECTHEIGHTSIZE-1)); + holebit = 1u<<((vx<<3)/(SECTHEIGHTSIZE-1)); if (s->holes[holerow] & holebit) continue; #endif @@ -2612,6 +2623,8 @@ void Terr_DrawInBounds(struct tdibctx *ctx, int x, int y, int w, int h) case mod_brush: Surf_GenBrushBatches(ctx->batches, &s->ents[i]); break; + default: //FIXME: no sprites! oh noes! + break; } } @@ -2911,8 +2924,8 @@ unsigned int Heightmap_PointContentsHM(heightmap_t *hm, float clipmipsz, vec3_t sx = x; x-=sx; sy = y; y-=sy; - holerow = sy/(SECTHEIGHTSIZE>>1); - holebit = 1u<<(sx/(SECTHEIGHTSIZE>>1)); + holerow = ((sy<<3)/(SECTHEIGHTSIZE-1)); + holebit = 1u<<((sx<<3)/(SECTHEIGHTSIZE-1)); if (s->holes[holerow] & (1u<>1); - holebit = 1u<<(tx/(SECTHEIGHTSIZE>>1)); + holerow = ((ty<<3)/(SECTHEIGHTSIZE-1)); + holebit = 1u<<((tx<<3)/(SECTHEIGHTSIZE-1)); if (s->holes[holerow] & holebit) return; //no collision with holes @@ -3624,11 +3637,16 @@ static void ted_dorelight(heightmap_t *hm) } static void ted_sethole(void *ctx, hmsection_t *s, int idx, float wx, float wy, float w) { - unsigned int row = idx>>4; + unsigned int row = idx/9; + unsigned int col = idx%9; unsigned int bit; unsigned int mask; - mask = 1u<<(idx&7); - if (*(float*)ctx >= 1) + if (row == 8 || col == 8) + return; //meh, our painting function is written with an overlap of 1 + if (w <= 0) + return; + mask = 1u<<(col); + if (*(float*)ctx > 0) bit = mask; else bit = 0; @@ -4043,7 +4061,7 @@ void QCBUILTIN PF_terrain_edit(pubprogfuncs_t *prinst, struct globalvars_s *pr_g */ pos[0] -= 0.5 * hm->sectionsize / 8; pos[1] -= 0.5 * hm->sectionsize / 8; - ted_itterate(hm, tid_linear, pos, radius, 1, 8, ted_sethole, &quant); + ted_itterate(hm, tid_linear, pos, radius, 1, 9, ted_sethole, &quant); break; case ter_height_set: ted_itterate(hm, tid_linear, pos, radius, 1, SECTHEIGHTSIZE, ted_heightset, &quant);