diff --git a/Makefile b/Makefile index c481feef..98e30de1 100644 --- a/Makefile +++ b/Makefile @@ -141,5 +141,7 @@ QBSP_OBJECTS = \ mathlib.o merge.o outside.o parser.o portals.o qbsp.o solidbsp.o \ surfaces.o tjunc.o util.o wad.o winding.o writebsp.o +qbsp/%.o: CPPFLAGS += -DDOUBLEVEC_T + qbsp/$(BIN_PFX)qbsp$(EXT): $(patsubst %,qbsp/%,$(QBSP_OBJECTS)) $(CC) -o $@ $^ $(LCURSES) diff --git a/qbsp/brush.c b/qbsp/brush.c index 755e5a3f..2c71ae5d 100644 --- a/qbsp/brush.c +++ b/qbsp/brush.c @@ -443,7 +443,7 @@ AddBrushPlane(plane_t *plane) { int i; plane_t *pl; - float l; + vec_t l; l = VectorLength(plane->normal); if (l < 0.999 || l > 1.001) @@ -664,7 +664,7 @@ ExpandBrush(vec3_t hull_size[2], face_t *pFaceList) for (s = -1; s <= 1; s += 2) { // add the plane VectorCopy(vec3_origin, plane.normal); - plane.normal[x] = (float)s; + plane.normal[x] = (vec_t)s; if (s == -1) plane.dist = -brush_mins[x] + -hull_size[0][x]; else diff --git a/qbsp/map.c b/qbsp/map.c index 134ed0b6..4f872b7c 100644 --- a/qbsp/map.c +++ b/qbsp/map.c @@ -113,10 +113,8 @@ ParseEpair(void) e->value = copystring(token); if (!strcasecmp(e->key, "origin")) - sscanf(e->value, "%f %f %f", - &(map.rgEntities[map.iEntities].origin[0]), - &(map.rgEntities[map.iEntities].origin[1]), - &(map.rgEntities[map.iEntities].origin[2])); + GetVectorForKey(map.iEntities, e->key, + map.rgEntities[map.iEntities].origin); else if (!strcasecmp(e->key, "classname")) { if (!strcasecmp(e->value, "info_player_start")) { if (rgfStartSpots & info_player_start) @@ -143,7 +141,7 @@ TextureAxisFromPlane(plane_t *pln, vec3_t xv, vec3_t yv) }; int bestaxis; - float dot, best; + vec_t dot, best; int i; best = 0; @@ -171,7 +169,7 @@ ParseBrush(void) texinfo_t tx; vec_t d; int shift[2], rotate; - float scale[2]; + vec_t scale[2]; int iFace; map.rgBrushes[map.iBrushes].iFaceEnd = map.iFaces + 1; @@ -189,7 +187,7 @@ ParseBrush(void) for (j = 0; j < 3; j++) { ParseToken(false); - planepts[i][j] = (float)atoi(token); + planepts[i][j] = (vec_t)atoi(token); } ParseToken(false); @@ -253,8 +251,8 @@ ParseBrush(void) { vec3_t vecs[2]; int sv, tv; - float ang, sinv, cosv; - float ns, nt; + vec_t ang, sinv, cosv; + vec_t ns, nt; TextureAxisFromPlane(&(map.rgFaces[map.iFaces].plane), vecs[0], vecs[1]); @@ -279,7 +277,7 @@ ParseBrush(void) sinv = -1; cosv = 0; } else { - ang = (float)rotate / 180 * Q_PI; + ang = (vec_t)rotate / 180 * Q_PI; sinv = sin(ang); cosv = cos(ang); } diff --git a/qbsp/outside.c b/qbsp/outside.c index cd3567c3..bde545da 100644 --- a/qbsp/outside.c +++ b/qbsp/outside.c @@ -126,9 +126,9 @@ MarkLeakTrail(portal_t *n2) { int i, j; vec3_t p1, p2, dir; - float len; + vec_t len; portal_t *n1; - float *v; + vec_t *v; if (hullnum != 2) return; @@ -268,7 +268,7 @@ SimplifyLeakline(node_t *headnode) int i, j, k; portal_t *p1, *p2; vec3_t dir; - float len; + vec_t len; if (numleaks < 2) return; diff --git a/qbsp/portals.c b/qbsp/portals.c index b5a44603..40cd1c06 100644 --- a/qbsp/portals.c +++ b/qbsp/portals.c @@ -357,7 +357,7 @@ static void CheckWindingArea(winding_t *w) { int i; - float total, add; + vec_t total, add; vec3_t v1, v2, cross; total = 0; @@ -381,7 +381,7 @@ CheckLeafPortalConsistancy(node_t *node) plane_t plane, plane2; int i; winding_t *w; - float dist; + vec_t dist; side = side2 = 0; // quiet compiler warning diff --git a/qbsp/surfaces.c b/qbsp/surfaces.c index 8f20ff3b..575e9065 100644 --- a/qbsp/surfaces.c +++ b/qbsp/surfaces.c @@ -41,12 +41,13 @@ piece off and insert the remainder in the next link void SubdivideFace(face_t *f, face_t **prevptr) { - float mins, maxs; + vec_t mins, maxs; vec_t v; int axis, i; plane_t plane; face_t *front, *back, *next; texinfo_t *tex; + vec3_t tmp; // special (non-surface cached) faces don't need subdivision tex = &pWorldEnt->pTexinfo[f->texturenum]; @@ -59,8 +60,12 @@ SubdivideFace(face_t *f, face_t **prevptr) mins = 9999; maxs = -9999; + tmp[0] = tex->vecs[axis][0]; + tmp[1] = tex->vecs[axis][1]; + tmp[2] = tex->vecs[axis][2]; + for (i = 0; i < f->numpoints; i++) { - v = DotProduct(f->pts[i], tex->vecs[axis]); + v = DotProduct(f->pts[i], tmp); if (v < mins) mins = v; if (v > maxs) @@ -71,7 +76,7 @@ SubdivideFace(face_t *f, face_t **prevptr) break; // split it - VectorCopy(tex->vecs[axis], plane.normal); + VectorCopy(tmp, plane.normal); v = VectorLength(plane.normal); VectorNormalize(plane.normal); plane.dist = (mins + options.dxSubdivide - 16) / v; @@ -180,7 +185,7 @@ InitHash(void) hash_scale[0] = newsize[0] / size[0]; hash_scale[1] = newsize[1] / size[1]; - hash_scale[2] = (float)newsize[1]; + hash_scale[2] = (vec_t)newsize[1]; hvert_p = pHashverts; } diff --git a/qbsp/tjunc.c b/qbsp/tjunc.c index 3d8391f1..92fd0c84 100644 --- a/qbsp/tjunc.c +++ b/qbsp/tjunc.c @@ -61,7 +61,7 @@ InitHash(vec3_t mins, vec3_t maxs) hash_scale[0] = newsize[0] / size[0]; hash_scale[1] = newsize[1] / size[1]; - hash_scale[2] = (float)newsize[1]; + hash_scale[2] = (vec_t)newsize[1]; } static unsigned diff --git a/qbsp/writebsp.c b/qbsp/writebsp.c index 86f8aeab..bb0bc5f4 100644 --- a/qbsp/writebsp.c +++ b/qbsp/writebsp.c @@ -32,6 +32,7 @@ ExportNodePlanes_r(node_t *node) plane_t *plane; dplane_t *dplane; int i; + vec3_t tmp; if (node->planenum == -1) return; @@ -40,11 +41,15 @@ ExportNodePlanes_r(node_t *node) dplane = pWorldEnt->pPlanes; // search for an equivalent plane - for (i = 0; i < pWorldEnt->iPlanes; i++, dplane++) - if (DotProduct(dplane->normal, plane->normal) > 1 - 0.00001 && + for (i = 0; i < pWorldEnt->iPlanes; i++, dplane++) { + tmp[0] = dplane->normal[0]; + tmp[1] = dplane->normal[1]; + tmp[2] = dplane->normal[2]; + if (DotProduct(tmp, plane->normal) > 1 - 0.00001 && fabs(dplane->dist - plane->dist) < 0.01 && dplane->type == plane->type) break; + } // a new plane planemapping[node->planenum] = i;