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