make _VectorCompare use EQUAL_EPSILON (VectorCompare is still the fast

macro) and use it instead of VectorCompare in the map tools. This (and, it
seems, RINT) fixes qfbsp on spc. Also, jump /all/ entities that get hit
by the filler in qfbsp
This commit is contained in:
Bill Currie 2002-09-20 17:02:53 +00:00
parent fa63d28acf
commit 56843557f6
13 changed files with 32 additions and 26 deletions

View File

@ -39,6 +39,9 @@
extern int nanmask;
extern const vec3_t vec3_origin;
#define EQUAL_EPSILON 0.001
#define RINT(x) (floor ((x) + 0.5))
#define IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask)
#define DotProduct(a,b) ((a)[0]*(b)[0]+(a)[1]*(b)[1]+(a)[2]*(b)[2])
@ -84,7 +87,7 @@ extern const vec3_t vec3_origin;
vec_t _DotProduct (const vec3_t v1, const vec3_t v2);
void _VectorAdd (const vec3_t veca, const vec3_t vecb, vec3_t out);
void _VectorCopy (const vec3_t in, vec3_t out);
int _VectorCompare (const vec3_t v1, const vec3_t v2);
int _VectorCompare (const vec3_t v1, const vec3_t v2); // uses EQUAL_EPSILON
//vec_t _VectorLength (vec3_t v);
void _VectorMA (const vec3_t veca, float scale, const vec3_t vecb,
vec3_t vecc);

View File

@ -337,7 +337,7 @@ _VectorCompare (const vec3_t v1, const vec3_t v2)
int i;
for (i = 0; i < 3; i++)
if (v1[i] != v2[i])
if (fabs (v1[i] - v2[i]) > EQUAL_EPSILON)
return 0;
return 1;

View File

@ -285,5 +285,3 @@ struct brush_s *AllocBrush (void);
//=============================================================================
extern bsp_t *bsp;
#define EQUAL_EPSILON 0.001

View File

@ -391,7 +391,7 @@ CreateBrushFaces (void)
for (j = 0; j < w->numpoints; j++) {
for (k = 0; k < 3; k++) {
r = (int) (w->points[j][k] + 0.5);
r = RINT (w->points[j][k]);
if (fabs (w->points[j][k] - r) < ZERO_EPSILON)
f->pts[j][k] = r;
else
@ -453,7 +453,7 @@ AddBrushPlane (plane_t *plane)
for (i = 0; i < numbrushfaces; i++) {
pl = &faces[i].plane;
if (VectorCompare (pl->normal, plane->normal)
if (_VectorCompare (pl->normal, plane->normal)
&& fabs (pl->dist - plane->dist) < ON_EPSILON)
return;
}
@ -484,11 +484,11 @@ TestAddPlane (plane_t *plane)
// see if the plane has allready been added
for (i = 0; i < numbrushfaces; i++) {
pl = &faces[i].plane;
if (VectorCompare (plane->normal, pl->normal)
if (_VectorCompare (plane->normal, pl->normal)
&& fabs (plane->dist - pl->dist) < ON_EPSILON)
return;
VectorSubtract (vec3_origin, plane->normal, inv);
if (VectorCompare (inv, pl->normal)
if (_VectorCompare (inv, pl->normal)
&& fabs (plane->dist + pl->dist) < ON_EPSILON) return;
}
@ -536,7 +536,7 @@ AddHullPoint (vec3_t p, int hullnum)
vec_t *c;
for (i = 0; i < num_hull_points; i++)
if (VectorCompare (p, hull_points[i]))
if (_VectorCompare (p, hull_points[i]))
return i;
VectorCopy (p, hull_points[num_hull_points]);

View File

@ -327,7 +327,7 @@ ParseBrush (void)
}
CrossProduct (t1, t2, f->plane.normal);
if (VectorCompare (f->plane.normal, vec3_origin)) {
if (_VectorCompare (f->plane.normal, vec3_origin)) {
printf ("WARNING: brush plane with no normal\n");
b->faces = f->next;
free (f);

View File

@ -48,7 +48,7 @@ CheckColinear (face_t *f)
VectorSubtract (f->pts[j], f->pts[i], v2);
VectorNormalize (v2);
if (VectorCompare (v1, v2))
if (_VectorCompare (v1, v2))
Sys_Error ("Colinear edge");
}

View File

@ -116,6 +116,7 @@ RecursiveFillOutside (node_t *l, qboolean fill)
{
portal_t *p;
int s;
qboolean res = false;
if (l->contents == CONTENTS_SOLID || l->contents == CONTENTS_SKY)
return false;
@ -124,8 +125,12 @@ RecursiveFillOutside (node_t *l, qboolean fill)
return false;
if (l->occupied) {
vec_t *v;
hit_occupied = l->occupied;
return true;
v = entities[hit_occupied].origin;
qprintf ("reached occupant at: (%4.0f,%4.0f,%4.0f) %s\n", v[0], v[1],
v[2], ValueForKey (&entities[hit_occupied], "classname"));
res = true;
}
l->valid = valid;
@ -144,12 +149,12 @@ RecursiveFillOutside (node_t *l, qboolean fill)
MarkLeakTrail (p);
DrawLeaf (l, 2);
}
return true;
res = true;
}
p = p->next[!s];
}
return false;
return res;
}
void
@ -190,7 +195,7 @@ FillOutside (node_t *node)
inside = false;
for (i = 1; i < num_entities; i++) {
if (!VectorCompare (entities[i].origin, vec3_origin)) {
if (!_VectorCompare (entities[i].origin, vec3_origin)) {
if (PlaceOccupant (i, entities[i].origin, node))
inside = true;
}

View File

@ -403,8 +403,8 @@ int num_visportals;
void
WriteFloat (FILE *f, vec_t v)
{
if (fabs (v - (int) (v + 0.5)) < 0.001)
fprintf (f, "%i ", (int) (v + 0.5));
if (fabs (v - RINT (v)) < 0.001)
fprintf (f, "%i ", (int) RINT (v));
else
fprintf (f, "%f ", v);
}

View File

@ -265,7 +265,7 @@ HealEdges (int e1, int e2)
bsp->vertexes[ed->v[0]].point, v2);
VectorNormalize (v2);
if (!VectorCompare (v1, v2))
if (!_VectorCompare (v1, v2))
Sys_Error ("HealEdges: edges not colinear");
edgemapping[e2] = e1;

View File

@ -343,7 +343,7 @@ DividePlane (surface_t *in, plane_t *split, surface_t **front,
inplane = &planes[in->planenum];
// parallel case is easy
if (VectorCompare (inplane->normal, split->normal)) {
if (_VectorCompare (inplane->normal, split->normal)) {
// check for exactly on node
if (inplane->dist == split->dist) { // divide the facets to the front
// and back sides

View File

@ -251,8 +251,8 @@ GetVertex (vec3_t in, int planenum)
dvertex_t v;
for (i = 0; i < 3; i++) {
if (fabs (in[i] - (int) (in[i] + 0.5)) < 0.001)
vert[i] = (int) (in[i] + 0.5);
if (fabs (in[i] - RINT (in[i])) < 0.001)
vert[i] = RINT (in[i]);
else
vert[i] = in[i];
}

View File

@ -515,9 +515,9 @@ Cmd_Base (void)
// run through all the base triangles, storing each unique vertex in the base
// vertex list and setting the indirect triangles to point to the base vertices
for (i = 0; i < model.numtris; i++) {
if (VectorCompare (ptri[i].verts[0], ptri[i].verts[1])
|| VectorCompare (ptri[i].verts[1], ptri[i].verts[2])
|| VectorCompare (ptri[i].verts[2], ptri[i].verts[0])) {
if (_VectorCompare (ptri[i].verts[0], ptri[i].verts[1])
|| _VectorCompare (ptri[i].verts[1], ptri[i].verts[2])
|| _VectorCompare (ptri[i].verts[2], ptri[i].verts[0])) {
degeneratetris++;
degenerate[i] = 1;
} else {
@ -526,7 +526,7 @@ Cmd_Base (void)
for (j = 0; j < 3; j++) {
for (k=0 ; k<model.numverts ; k++)
if (VectorCompare (ptri[i].verts[j], baseverts[k]))
if (_VectorCompare (ptri[i].verts[j], baseverts[k]))
break; // this vertex is already in the base vertex list
if (k == model.numverts) {

View File

@ -269,7 +269,7 @@ RecursiveLeafFlow (int leafnum, threaddata_t *thread, pstack_t *prevstack)
VectorSubtract (vec3_origin, p->plane.normal, backplane.normal);
backplane.dist = -p->plane.dist;
if (VectorCompare (prevstack->portalplane.normal, backplane.normal))
if (_VectorCompare (prevstack->portalplane.normal, backplane.normal))
continue; // can't go out a coplanar face
c_portalcheck++;