bring in many of LordHavoc's changes to qbsp: HalfLife WorldCraft texture

alighnment, partial "point of plane" autocorrection (currently disabled: I
want to make it optional), large map support (not sure where that's
hiding), hipnotic entity rotation
This commit is contained in:
Bill Currie 2003-09-03 22:00:08 +00:00
parent 996de18cc6
commit 231a1bfb56
14 changed files with 255 additions and 218 deletions

View file

@ -46,6 +46,7 @@ extern const vec3_t vec3_origin;
#define DotProduct(a,b) ((a)[0]*(b)[0]+(a)[1]*(b)[1]+(a)[2]*(b)[2])
#define VectorSubtract(a,b,c) {(c)[0]=(a)[0]-(b)[0];(c)[1]=(a)[1]-(b)[1];(c)[2]=(a)[2]-(b)[2];}
#define VectorNegate(a,b) {(b)[0]=-(a)[0];(b)[1]=-(a)[1];(b)[2]=-(a)[2];}
#define VectorAdd(a,b,c) {(c)[0]=(a)[0]+(b)[0];(c)[1]=(a)[1]+(b)[1];(c)[2]=(a)[2]+(b)[2];}
#define VectorCopy(a,b) {(b)[0]=(a)[0];(b)[1]=(a)[1];(b)[2]=(a)[2];}
#define VectorMultAdd(a,s,b,c) {(c)[0]=(a)[0]+(s)*(b)[0];(c)[1]=(a)[1]+(s)*(b)[1];(c)[2]=(a)[2]+(s)*(b)[2];}

View file

@ -20,7 +20,7 @@
$Id$
*/
#define MAX_FACES 128
#define MAX_FACES 256
typedef struct mface_s
{
struct mface_s *next;

View file

@ -36,8 +36,9 @@ int numbrushplanes;
plane_t planes[MAX_MAP_PLANES];
int numbrushfaces;
mface_t faces[128]; // beveled clipping hull can generate many extra
mface_t faces[MAX_FACES]; // beveled clipping hull can generate many extra
static entity_t *CurrentEntity;
/*
CheckFace
@ -57,7 +58,7 @@ CheckFace (face_t *f)
VectorCopy (planes[f->planenum].normal, facenormal);
if (f->planeside)
VectorSubtract (vec3_origin, facenormal, facenormal);
VectorNegate (facenormal, facenormal);
for (i = 0; i < f->numpoints; i++) {
p1 = f->pts[i];
@ -74,6 +75,9 @@ CheckFace (face_t *f)
if (d < -ON_EPSILON || d > ON_EPSILON)
Sys_Error ("CheckFace: point off plane");
#if 0 //XXX point off plane autofix
VectorMultSub (p1, d, planes[f->planenum].normal, p1);
#endif
// check the edge isn't degenerate
p2 = f->pts[j];
@ -105,8 +109,8 @@ ClearBounds (brushset_t *bs)
for (j = 0; j < NUM_HULLS; j++)
for (i = 0; i < 3; i++) {
bs->mins[i] = 99999;
bs->maxs[i] = -99999;
bs->mins[i] = BOGUS_RANGE;
bs->maxs[i] = -BOGUS_RANGE;
}
}
@ -160,12 +164,10 @@ NormalizePlane (plane_t *dp)
if (dp->normal[0] == -1.0) {
dp->normal[0] = 1.0;
dp->dist = -dp->dist;
}
if (dp->normal[1] == -1.0) {
} else if (dp->normal[1] == -1.0) {
dp->normal[1] = 1.0;
dp->dist = -dp->dist;
}
if (dp->normal[2] == -1.0) {
} else if (dp->normal[2] == -1.0) {
dp->normal[2] = 1.0;
dp->dist = -dp->dist;
}
@ -194,7 +196,7 @@ NormalizePlane (plane_t *dp)
else
dp->type = PLANE_ANYZ;
if (dp->normal[dp->type - PLANE_ANYX] < 0) {
VectorSubtract (vec3_origin, dp->normal, dp->normal);
VectorNegate (dp->normal, dp->normal);
dp->dist = -dp->dist;
}
}
@ -253,22 +255,52 @@ FindPlane (plane_t *dplane, int *side)
vec3_t brush_mins, brush_maxs;
face_t *brush_faces;
static entity_t *
FindTargetEntity (const char *targetname)
{
int entnum;
for (entnum = 0; entnum < num_entities; entnum++)
if (!strcmp (targetname,
ValueForKey (&entities[entnum], "targetname")))
return &entities[entnum];
return 0;
}
#define ZERO_EPSILON 0.001
static void
CreateBrushFaces (void)
{
face_t *f;
int i, j, k;
int i, j, k, rotate;
mface_t *mf;
plane_t plane;
vec_t r;
winding_t *w;
vec3_t offset, point;
brush_mins[0] = brush_mins[1] = brush_mins[2] = 99999;
brush_maxs[0] = brush_maxs[1] = brush_maxs[2] = -99999;
offset[0] = offset[1] = offset[2] = 0;
brush_mins[0] = brush_mins[1] = brush_mins[2] = BOGUS_RANGE;
brush_maxs[0] = brush_maxs[1] = brush_maxs[2] = -BOGUS_RANGE;
brush_faces = NULL;
rotate = !strncmp (ValueForKey (CurrentEntity, "classname"), "rotate_", 7);
if (rotate) {
entity_t *FoundEntity;
const char *searchstring;
char text[20];
searchstring = ValueForKey (CurrentEntity, "target");
FoundEntity = FindTargetEntity (searchstring);
if (FoundEntity)
GetVectorForKey (FoundEntity, "origin", offset);
snprintf (text, sizeof (text), "%g %g %g",
offset[0], offset[1], offset[2]);
SetKeyValue (CurrentEntity, "origin", text);
}
for (i = 0; i < numbrushfaces; i++) {
mf = &faces[i];
@ -278,10 +310,11 @@ CreateBrushFaces (void)
if (j == i)
continue;
// flip the plane, because we want to keep the back side
VectorSubtract (vec3_origin, faces[j].plane.normal, plane.normal);
VectorNegate (faces[j].plane.normal, plane.normal);
plane.dist = -faces[j].plane.dist;
w = ClipWinding (w, &plane, false);
// keepon was false. avoid clipping away windings on plane?
w = ClipWinding (w, &plane, true);
}
if (!w)
@ -295,11 +328,12 @@ CreateBrushFaces (void)
for (j = 0; j < w->numpoints; j++) {
for (k = 0; k < 3; k++) {
r = RINT (w->points[j][k]);
if (fabs (w->points[j][k] - r) < ZERO_EPSILON)
point[k] = w->points[j][k] - offset[k];
r = RINT (point[k]);
if (fabs (point[k] - r) < ZERO_EPSILON)
f->pts[j][k] = r;
else
f->pts[j][k] = w->points[j][k];
f->pts[j][k] = point[k];
if (f->pts[j][k] < brush_mins[k])
brush_mins[k] = f->pts[j][k];
@ -308,13 +342,45 @@ CreateBrushFaces (void)
}
}
VectorCopy (mf->plane.normal, plane.normal);
VectorScale (mf->plane.normal, mf->plane.dist, point);
VectorSubtract (point, offset, point);
plane.dist = DotProduct (plane.normal, point);
FreeWinding (w);
f->texturenum = mf->texinfo;
f->planenum = FindPlane (&mf->plane, &f->planeside);
f->planenum = FindPlane (&plane, &f->planeside);
f->next = brush_faces;
brush_faces = f;
CheckFace (f);
}
// Rotatable objects have to have a bounding box big enough
// to account for all its rotations.
if (rotate) {
vec_t delta, min, max;
min = brush_mins[0];
if (min > brush_mins[1])
min = brush_mins[1];
if (min > brush_mins[2])
min = brush_mins[2];
max = brush_maxs[0];
if (max > brush_maxs[1])
max = brush_maxs[1];
if (max > brush_maxs[2])
max = brush_maxs[2];
delta = fabs(max);
if (fabs(min) > delta)
delta = fabs(min);
for (k = 0; k < 3; k++) {
brush_mins[k] = -delta;
brush_maxs[k] = delta;
}
}
}
/*
@ -328,7 +394,6 @@ vec3_t hull_size[3][2] = {
{{0, 0, 0}, {0, 0, 0}},
{{-16, -16, -32}, {16, 16, 24}},
{{-32, -32, -64}, {32, 32, 24}}
};
#define MAX_HULL_POINTS 64
@ -387,7 +452,7 @@ TestAddPlane (plane_t *plane)
if (_VectorCompare (plane->normal, pl->normal)
&& fabs (plane->dist - pl->dist) < ON_EPSILON)
return;
VectorSubtract (vec3_origin, plane->normal, inv);
VectorNegate (plane->normal, inv);
if (_VectorCompare (inv, pl->normal)
&& fabs (plane->dist + pl->dist) < ON_EPSILON) return;
}
@ -413,7 +478,7 @@ TestAddPlane (plane_t *plane)
// the plane is a seperator
if (counts[0]) {
VectorSubtract (vec3_origin, plane->normal, flip.normal);
VectorNegate (plane->normal, flip.normal);
flip.dist = -plane->dist;
plane = &flip;
}
@ -497,7 +562,7 @@ AddHullEdge (vec3_t p1, vec3_t p2, int hullnum)
planeorg[b] += hull_size[hullnum][d][b];
planeorg[c] += hull_size[hullnum][e][c];
VectorCopy (vec3_origin, planevec);
VectorZero (planevec);
planevec[a] = 1;
CrossProduct (planevec, edgevec, plane.normal);
@ -529,7 +594,7 @@ ExpandBrush (int hullnum)
// expand all of the planes
for (i = 0; i < numbrushfaces; i++) {
p = &faces[i].plane;
VectorCopy (vec3_origin, corner);
VectorZero (corner);
for (x = 0; x < 3; x++) {
if (p->normal[x] > 0)
corner[x] = hull_size[hullnum][1][x];
@ -543,7 +608,7 @@ ExpandBrush (int hullnum)
for (x = 0; x < 3; x++)
for (s = -1; s <= 1; s += 2) {
// add the plane
VectorCopy (vec3_origin, plane.normal);
VectorZero (plane.normal);
plane.normal[x] = s;
if (s == -1)
plane.dist = -brush_mins[x] + -hull_size[hullnum][0][x];
@ -667,6 +732,8 @@ Brush_LoadEntity (entity_t *ent, int hullnum)
qprintf ("--- Brush_LoadEntity ---\n");
CurrentEntity = ent;
for (mbr = ent->brushes; mbr; mbr = mbr->next) {
b = LoadBrush (mbr, hullnum);
if (!b)

View file

@ -246,14 +246,11 @@ SaveOutside (qboolean mirror)
{
VectorCopy (f->pts[f->numpoints - 1 - i], newf->pts[i]);
}
} else
newf = NULL;
validfaces[planenum] = MergeFaceToList (f, validfaces[planenum]);
if (newf)
validfaces[planenum] = MergeFaceToList (newf,
validfaces[planenum]);
}
validfaces[planenum] = MergeFaceToList (f, validfaces[planenum]);
validfaces[planenum] = FreeMergeListScraps (validfaces[planenum]);
}
}

View file

@ -41,6 +41,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "bsp5.h"
int nummapbrushfaces;
int nummapbrushes;
mbrush_t mapbrushes[MAX_MAP_BRUSHES];
@ -302,14 +303,17 @@ ParseVerts (int *n_verts)
static void
ParseBrush (void)
{
float shift[2], rotate, scale[2];
int i, j, n_verts = 0;
float rotate, scale[2];
float ang, sinv, cosv, ns, nt;
int sv, tv;
int i, j, n_verts = 0, hltexdef;
mbrush_t *b;
mface_t *f, *f2;
plane_t plane;
texinfo_t tx;
vec3_t planepts[3];
vec3_t t1, t2, t3, *verts = 0;
vec_t d;
vec3_t t1, t2, *verts = 0;
vec_t d, vecs[2][4];
b = &mapbrushes[nummapbrushes];
nummapbrushes++;
@ -335,7 +339,7 @@ ParseBrush (void)
GetToken (false);
for (i = 0; i < n_v; i++) {
GetToken (false);
v = atoi (token);
v = atof (token);
if (i < 3)
VectorCopy (verts[v], planepts[i]);
}
@ -350,7 +354,7 @@ ParseBrush (void)
for (j = 0; j < 3; j++) {
GetToken (false);
planepts[i][j] = atoi (token);
planepts[i][j] = atof (token);
}
GetToken (false);
@ -359,16 +363,51 @@ ParseBrush (void)
}
}
// convert points to a plane
VectorSubtract (planepts[0], planepts[1], t1);
VectorSubtract (planepts[2], planepts[1], t2);
CrossProduct(t1, t2, plane.normal);
VectorNormalize (plane.normal);
plane.dist = DotProduct(planepts[1], plane.normal);
// read the texturedef
memset (&tx, 0, sizeof (tx));
GetToken (false);
tx.miptex = FindMiptex (token);
GetToken (false);
shift[0] = atoi (token);
if ((hltexdef = !strcmp (token, "["))) {
// S vector
GetToken (false);
vecs[0][0] = atof (token);
GetToken (false);
vecs[0][1] = atof (token);
GetToken (false);
vecs[0][2] = atof (token);
GetToken (false);
vecs[0][3] = atof (token);
// ]
GetToken (false);
// [
GetToken (false);
// T vector
GetToken (false);
vecs[1][0] = atof (token);
GetToken (false);
vecs[1][1] = atof (token);
GetToken (false);
vecs[1][2] = atof (token);
GetToken (false);
vecs[1][3] = atof (token);
// ]
GetToken (false);
} else {
vecs[0][3] = atof (token);
GetToken (false);
vecs[1][3] = atof (token);
}
GetToken (false);
shift[1] = atoi (token);
GetToken (false);
rotate = atoi (token);
rotate = atof (token);
GetToken (false);
scale[0] = atof (token);
GetToken (false);
@ -399,90 +438,74 @@ ParseBrush (void)
continue;
}
if (DotProduct (plane.normal, plane.normal) < 0.1) {
printf ("WARNING: brush plane with no normal on line %d\n",
script_line);
continue;
}
if (!hltexdef) {
// fake proper texture vectors from QuakeEd style
TextureAxisFromPlane (&f->plane, vecs[0], vecs[1]);
}
if (!scale[0])
scale[0] = 1;
if (!scale[1])
scale[1] = 1;
// rotate axis
if (rotate == 0) {
sinv = 0;
cosv = 1;
} else if (rotate == 90) {
sinv = 1;
cosv = 0;
} else if (rotate == 180) {
sinv = 0;
cosv = -1;
} else if (rotate == 270) {
sinv = -1;
cosv = 0;
} else {
ang = rotate / 180 * M_PI;
sinv = sin (ang);
cosv = cos (ang);
}
if (vecs[0][0])
sv = 0;
else if (vecs[0][1])
sv = 1;
else
sv = 2;
if (vecs[1][0])
tv = 0;
else if (vecs[1][1])
tv = 1;
else
tv = 2;
for (i = 0; i < 2; i++) {
// rotate
ns = cosv * vecs[i][sv] - sinv * vecs[i][tv];
nt = sinv * vecs[i][sv] + cosv * vecs[i][tv];
vecs[i][sv] = ns;
vecs[i][tv] = nt;
// cale and store into texinfo
for (j = 0; j < 3; j++)
tx.vecs[i][j] = vecs[i][j] / scale[i];
tx.vecs[i][3] = vecs[i][3];
}
f = malloc (sizeof (mface_t));
f->next = b->faces;
b->faces = f;
// convert to a vector / dist plane
for (j = 0; j < 3; j++) {
t1[j] = planepts[0][j] - planepts[1][j];
t2[j] = planepts[2][j] - planepts[1][j];
t3[j] = planepts[1][j];
}
CrossProduct (t1, t2, f->plane.normal);
if (_VectorCompare (f->plane.normal, vec3_origin)) {
printf ("WARNING: brush plane with no normal\n");
b->faces = f->next;
free (f);
break;
}
_VectorNormalize (f->plane.normal);
f->plane.dist = DotProduct (t3, f->plane.normal);
// fake proper texture vectors from QuakeEd style
{
float ang, sinv, cosv, ns, nt;
int sv, tv;
vec3_t vecs[2];
TextureAxisFromPlane (&f->plane, vecs[0], vecs[1]);
if (!scale[0])
scale[0] = 1;
if (!scale[1])
scale[1] = 1;
// rotate axis
if (rotate == 0) {
sinv = 0;
cosv = 1;
} else if (rotate == 90) {
sinv = 1;
cosv = 0;
} else if (rotate == 180) {
sinv = 0;
cosv = -1;
} else if (rotate == 270) {
sinv = -1;
cosv = 0;
} else {
ang = rotate / 180 * M_PI;
sinv = sin (ang);
cosv = cos (ang);
}
if (vecs[0][0])
sv = 0;
else if (vecs[0][1])
sv = 1;
else
sv = 2;
if (vecs[1][0])
tv = 0;
else if (vecs[1][1])
tv = 1;
else
tv = 2;
for (i = 0; i < 2; i++) {
ns = cosv * vecs[i][sv] - sinv * vecs[i][tv];
nt = sinv * vecs[i][sv] + cosv * vecs[i][tv];
vecs[i][sv] = ns;
vecs[i][tv] = nt;
}
for (i = 0; i < 2; i++)
for (j = 0; j < 3; j++)
tx.vecs[i][j] = vecs[i][j] / scale[i];
tx.vecs[0][3] = shift[0];
tx.vecs[1][3] = shift[1];
}
f->plane = plane;
// unique the texinfo
f->texinfo = FindTexinfo (&tx);
nummapbrushfaces++;
} while (1);
if (verts)
free (verts);
@ -565,9 +588,10 @@ LoadMapFile (const char *filename)
qprintf ("--- LoadMapFile ---\n");
qprintf ("%s\n", filename);
qprintf ("%5i faces\n", nummapbrushfaces);
qprintf ("%5i brushes (%i detail)\n", nummapbrushes, numdetailbrushes);
qprintf ("%5i entities\n", num_entities);
qprintf ("%5i miptex\n", nummiptex);
qprintf ("%5i textures\n", nummiptex);
qprintf ("%5i texinfo\n", bsp->numtexinfo);
}

View file

@ -93,7 +93,7 @@ TryMerge (face_t *f1, face_t *f2)
plane = &planes[f1->planenum];
VectorCopy (plane->normal, planenormal);
if (f1->planeside)
VectorSubtract (vec3_origin, planenormal, planenormal);
VectorNegate (planenormal, planenormal);
back = f1->pts[(i + f1->numpoints - 1) % f1->numpoints];
VectorSubtract (p1, back, delta);

View file

@ -99,9 +99,6 @@ MarkLeakTrail (portal_t *n2)
portal_t *n1;
vec3_t p1, p2, dir;
if (options.hullnum)
return;
n1 = prevleaknode;
prevleaknode = n2;
@ -124,6 +121,11 @@ MarkLeakTrail (portal_t *n2)
len = VectorLength (dir);
_VectorNormalize (dir);
if (!leakfile)
leakfile = fopen (options.pointfile, "w");
if (!leakfile)
Sys_Error ("Couldn't open %s\n", options.pointfile);
while (len > 2) {
fprintf (leakfile, "%f %f %f\n", p1[0], p1[1], p1[2]);
for (i = 0; i < 3; i++)
@ -133,7 +135,6 @@ MarkLeakTrail (portal_t *n2)
}
int hit_occupied;
int backdraw;
/*
RecursiveFillOutside
@ -175,7 +176,7 @@ RecursiveFillOutside (node_t *l, qboolean fill)
if (RecursiveFillOutside (p->nodes[s], fill)) {
// leaked, so stop filling
if (backdraw-- > 0) {
if (!options.hullnum) {
MarkLeakTrail (p);
DrawLeaf (l, 2);
}
@ -243,67 +244,23 @@ FillOutside (node_t *node)
prevleaknode = NULL;
if (!options.hullnum) {
leakfile = fopen (options.pointfile, "w");
if (!leakfile)
Sys_Error ("Couldn't open %s\n", options.pointfile);
}
if (RecursiveFillOutside (outside_node.portals->nodes[s], false)) {
v = entities[hit_occupied].origin;
qprintf ("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
qprintf ("reached occupant at: (%4.0f,%4.0f,%4.0f)\n", v[0], v[1],
v[2]);
qprintf ("no filling performed\n");
qprintf ("leak file written to %s\n", options.pointfile);
qprintf ("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
if (!options.hullnum) {
node_t *n, *nextnode;
portal_t *p, *p2;
int i, j, next, side;
vec3_t wc;
n = &outside_node;
next = -1;
while ((n->o_dist > 1) || (next == -1)) {
nextnode = NULL;
p2 = NULL;
for (p = n->portals; p; p = p->next[side]) {
side = (p->nodes[1] == n);
if ((next == -1)
|| ((p->nodes[!side]->o_dist < next)
&& (p->nodes[!side]->o_dist))
)
{
next = p->nodes[!side]->o_dist;
nextnode = p->nodes[!side];
p2 = p;
}
}
if (nextnode) {
n = nextnode;
wc[0] = wc[1] = wc[2] = 0;
for (i = 0; i < p2->winding->numpoints; i++) {
for (j = 0; j < 3; j++)
wc[j] += p2->winding->points[i][j];
}
for (j = 0; j < 3; j++)
wc[j] /= p2->winding->numpoints;
fprintf (leakfile, "%g %g %g\n", wc[0], wc[1], wc[2]);
} else
break;
}
v = entities[n->occupied].origin;
fprintf (leakfile, "%g %g %g\n", v[0], v[1], v[2]);
if (leakfile)
fclose (leakfile);
leakfile = 0;
if (!options.hullnum) {
v = entities[hit_occupied].origin;
qprintf ("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
qprintf ("reached occupant at: (%4.0f,%4.0f,%4.0f)\n", v[0], v[1],
v[2]);
qprintf ("no filling performed\n");
qprintf ("leak file written to %s\n", options.pointfile);
qprintf ("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
}
// remove faces from filled in leafs
ClearOutFaces (node);
return false;
}
if (!options.hullnum)
fclose (leakfile);
// now go back and fill things in
valid++;

View file

@ -197,7 +197,7 @@ CutNodePortals_r (node_t *node)
side = 0;
else if (p->nodes[1] == node) {
clipplane.dist = -clipplane.dist;
VectorSubtract (vec3_origin, clipplane.normal, clipplane.normal);
VectorNegate (clipplane.normal, clipplane.normal);
side = 1;
} else
Sys_Error ("CutNodePortals_r: mislinked portal");
@ -330,15 +330,7 @@ int num_visleafs; // leafs the player can be in
int num_visportals;
int num_realleafs;
static void
WriteFloat (FILE *f, vec_t v)
{
if (fabs (v - RINT (v)) < 0.001)
fprintf (f, "%i ", (int) RINT (v));
else
fprintf (f, "%f ", v);
}
//FIXME make work with transparent water
static int
HasContents (node_t *n, int cont)
{
@ -414,14 +406,12 @@ WritePortalFile_r (node_t *node)
} else
fprintf (pf, "%i %i %i ", w->numpoints,
p->nodes[0]->visleafnum, p->nodes[1]->visleafnum);
for (i = 0; i < w->numpoints; i++) {
fprintf (pf, "(");
WriteFloat (pf, w->points[i][0]);
WriteFloat (pf, w->points[i][1]);
WriteFloat (pf, w->points[i][2]);
fprintf (pf, ") ");
for (i = 0; i < w->numpoints - 1; i++) {
fprintf (pf, "(%g %g %g) ",
w->points[i][0], w->points[i][0], w->points[i][0]);
}
fprintf (pf, "\n");
fprintf (pf, "(%g %g %g)\n",
w->points[i][0], w->points[i][0], w->points[i][0]);
}
if (p->nodes[0] == node)

View file

@ -87,7 +87,7 @@ BaseWindingForPlane (plane_t *p)
if (x == -1)
Sys_Error ("BaseWindingForPlane: no axis found");
VectorCopy (vec3_origin, vup);
VectorZero (vup);
switch (x) {
case 0:
case 1:
@ -106,8 +106,8 @@ BaseWindingForPlane (plane_t *p)
CrossProduct (vup, p->normal, vright);
VectorScale (vup, 8192, vup);
VectorScale (vright, 8192, vright);
VectorScale (vup, BOGUS_RANGE, vup);
VectorScale (vright, BOGUS_RANGE, vright);
// project a really big axis aligned box onto the plane
w = NewWinding (4);
@ -161,10 +161,10 @@ winding_t *
ClipWinding (winding_t *in, plane_t *split, qboolean keepon)
{
int maxpts, i, j;
int sides[MAX_POINTS_ON_WINDING];
int sides[MAX_POINTS_ON_WINDING + 1];
int counts[3];
vec_t dot;
vec_t dists[MAX_POINTS_ON_WINDING];
vec_t dists[MAX_POINTS_ON_WINDING + 1];
vec_t *p1, *p2;
vec3_t mid;
winding_t *neww;
@ -258,10 +258,10 @@ DivideWinding (winding_t *in, plane_t *split, winding_t **front,
winding_t **back)
{
int maxpts, i, j;
int sides[MAX_POINTS_ON_WINDING];
int sides[MAX_POINTS_ON_WINDING + 1];
int counts[3];
vec_t dot;
vec_t dists[MAX_POINTS_ON_WINDING];
vec_t dists[MAX_POINTS_ON_WINDING + 1];
vec_t *p1, *p2;
vec3_t mid;
winding_t *f, *b;

View file

@ -32,6 +32,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "compat.h"
#include "bsp5.h"
#include "options.h"
/*
input
@ -99,7 +100,7 @@ CanJoinFaces (face_t *f, face_t *f2)
VectorCopy (region_maxs, oldmaxs);
AddFaceToRegionSize (f2);
for (i = 0; i < 3; i++) {
if (region_maxs[i] - region_mins[i] > 240) {
if (region_maxs[i] - region_mins[i] > options.subdivide_size) {
VectorCopy (oldmins, region_mins);
VectorCopy (oldmaxs, region_maxs);
return false;

View file

@ -283,8 +283,8 @@ SelectPartition (surface_t *surfaces, int *detail)
// calculate a bounding box of the entire surfaceset
for (i = 0; i < 3; i++) {
mins[i] = 99999;
maxs[i] = -99999;
mins[i] = BOGUS_RANGE;
maxs[i] = -BOGUS_RANGE;
}
for (p = surfaces; p; p = p->next)
@ -329,8 +329,8 @@ CalcSurfaceInfo (surface_t * surf)
// calculate a bounding box
for (i = 0; i < 3; i++) {
surf->mins[i] = 99999;
surf->maxs[i] = -99999;
surf->mins[i] = BOGUS_RANGE;
surf->maxs[i] = -BOGUS_RANGE;
}
for (f = surf->faces; f; f = f->next) {

View file

@ -72,8 +72,8 @@ SubdivideFace (face_t *f, face_t **prevptr)
for (axis = 0; axis < 2; axis++) {
while (1) {
mins = 9999;
maxs = -9999;
mins = BOGUS_RANGE;
maxs = -BOGUS_RANGE;
for (i = 0; i < f->numpoints; i++) {
v = DotProduct (f->pts[i], tex->vecs[axis]);

View file

@ -104,7 +104,7 @@ CanonicalVector (vec3_t vec)
if (vec[0] > EQUAL_EPSILON)
return;
else if (vec[0] < -EQUAL_EPSILON) {
VectorSubtract (vec3_origin, vec, vec);
VectorNegate (vec, vec);
return;
} else
vec[0] = 0;
@ -112,7 +112,7 @@ CanonicalVector (vec3_t vec)
if (vec[1] > EQUAL_EPSILON)
return;
else if (vec[1] < -EQUAL_EPSILON) {
VectorSubtract (vec3_origin, vec, vec);
VectorNegate (vec, vec);
return;
} else
vec[1] = 0;
@ -120,7 +120,7 @@ CanonicalVector (vec3_t vec)
if (vec[2] > EQUAL_EPSILON)
return;
else if (vec[2] < -EQUAL_EPSILON) {
VectorSubtract (vec3_origin, vec, vec);
VectorNegate (vec, vec);
return;
} else
vec[2] = 0;
@ -437,7 +437,7 @@ tjunc (node_t *headnode)
else
maxs[i] = fabs (brushset->mins[i]);
}
VectorSubtract (vec3_origin, maxs, mins);
VectorNegate (maxs, mins);
InitHash (mins, maxs);

View file

@ -512,11 +512,11 @@ FinishBSPFile (void)
QFile *f;
printf ("--- FinishBSPFile ---\n");
printf ("WriteBSPFile: %s\n", options.bspfile);
WriteMiptex ();
// XXX PrintBSPFileSizes ();
printf ("WriteBSPFile: %s\n", options.bspfile);
f = Qopen (options.bspfile, "wb");
if (!f)
Sys_Error ("couldn't open %s. %s", options.bspfile, strerror(errno));