[PATCH] qbsp: Use double-precision floating point

Set the vec_t type to "double" using the DOUBLEVEC_T preproccessor define. Fix
up hard-coded usages of float in various places throughout the code. Note that
texinfo_t is an on-disk structure, so that needs to stay as float and we work
around incompatibilities with the vector functions using a temporary vec3_t.

Signed-off-by: Tyrann <tyrann@disenchant.net>
This commit is contained in:
Tyrann 2006-09-16 16:36:16 +09:30
parent b550faf877
commit 4464491807
8 changed files with 34 additions and 24 deletions

View File

@ -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)

View File

@ -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

View File

@ -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);
}

View File

@ -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;

View File

@ -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

View File

@ -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;
}

View File

@ -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

View File

@ -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;