2010-09-09 11:46:38 +00:00
|
|
|
#include "QF/script.h"
|
|
|
|
#include "QF/sys.h"
|
|
|
|
|
|
|
|
#include "SetBrush.h"
|
|
|
|
#include "Entity.h"
|
|
|
|
#include "EntityClass.h"
|
|
|
|
#include "Map.h"
|
|
|
|
#include "Preferences.h"
|
2010-09-11 08:35:25 +00:00
|
|
|
#include "XYView.h"
|
|
|
|
#include "ZView.h"
|
|
|
|
#include "CameraView.h"
|
|
|
|
#include "Clipper.h"
|
|
|
|
#include "QuakeEd.h"
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
@implementation SetBrush
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
textureAxisFromPlane
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
#if 1
|
2010-09-29 20:09:11 +00:00
|
|
|
vec3_t baseaxis[18] = {
|
|
|
|
{ 0, 0, 1}, {1, 0, 0}, {0, -1, 0}, // floor
|
|
|
|
{ 0, 0, -1}, {1, 0, 0}, {0, -1, 0}, // ceiling
|
|
|
|
{ 1, 0, 0}, {0, 1, 0}, {0, 0, -1}, // west wall
|
|
|
|
{-1, 0, 0}, {0, 1, 0}, {0, 0, -1}, // east wall
|
|
|
|
{ 0, 1, 0}, {1, 0, 0}, {0, 0, -1}, // south wall
|
|
|
|
{ 0, -1, 0}, {1, 0, 0}, {0, 0, -1} // north wall
|
2003-03-18 19:48:24 +00:00
|
|
|
};
|
|
|
|
#else
|
2010-09-29 20:09:11 +00:00
|
|
|
vec3_t baseaxis[18] = {
|
|
|
|
{ 0, 0, 1}, { 1, 0, 0}, {0, -1, 0}, // floor
|
|
|
|
{ 0, 0, -1}, { 1, 0, 0}, {0, 1, 0}, // ceiling
|
|
|
|
{ 1, 0, 0}, { 0, 1, 0}, {0, 0, -1}, // west wall
|
|
|
|
{-1, 0, 0}, { 0, -1, 0}, {0, 0, -1}, // east wall
|
|
|
|
{ 0, 1, 0}, {-1, 0, 0}, {0, 0, -1}, // south wall
|
|
|
|
{ 0, -1, 0}, { 1, 0, 0}, {0, 0, -1} // north wall
|
2003-03-18 19:48:24 +00:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
float
|
|
|
|
TextureAxisFromPlane (plane_t *pln, float *xv, float *yv)
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
int bestaxis;
|
|
|
|
float dot, best;
|
|
|
|
int i;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
best = 0;
|
|
|
|
bestaxis = 0;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
for (i = 0; i < 6; i++) {
|
|
|
|
dot = DotProduct (pln->normal, baseaxis[i * 3]);
|
|
|
|
if (dot > best) {
|
2003-03-18 19:48:24 +00:00
|
|
|
best = dot;
|
|
|
|
bestaxis = i;
|
|
|
|
}
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
VectorCopy (baseaxis[bestaxis * 3 + 1], xv);
|
|
|
|
VectorCopy (baseaxis[bestaxis * 3 + 2], yv);
|
|
|
|
|
|
|
|
return lightaxis[bestaxis >> 1];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
#define BOGUS_RANGE 18000
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
CheckFace
|
|
|
|
|
|
|
|
Note: this will not catch 0 area polygons
|
|
|
|
=================
|
|
|
|
*/
|
2010-09-11 10:03:41 +00:00
|
|
|
void
|
|
|
|
CheckFace (face_t * f)
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
int i, j;
|
2010-09-29 20:09:11 +00:00
|
|
|
float *p1, *p2;
|
2010-09-11 10:03:41 +00:00
|
|
|
float d, edgedist;
|
|
|
|
vec3_t dir, edgenormal;
|
2010-09-29 20:09:11 +00:00
|
|
|
winding_t *w;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
w = f->w;
|
|
|
|
if (!w)
|
2010-09-09 11:46:38 +00:00
|
|
|
Sys_Error ("CheckFace: no winding");
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
if (w->numpoints < 3)
|
2010-09-11 10:03:41 +00:00
|
|
|
Sys_Error ("CheckFace: %i points", w->numpoints);
|
|
|
|
|
|
|
|
for (i = 0; i < w->numpoints; i++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
p1 = w->points[i];
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
for (j = 0; j < 3; j++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
if (p1[j] > BOGUS_RANGE || p1[j] < -BOGUS_RANGE)
|
2010-09-11 10:03:41 +00:00
|
|
|
Sys_Error ("CheckFace: BUGUS_RANGE: %f", p1[j]);
|
2010-09-29 20:09:11 +00:00
|
|
|
}
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
j = i + 1 == w->numpoints ? 0 : i + 1;
|
|
|
|
|
|
|
|
// check the point is on the face plane
|
2003-03-18 19:48:24 +00:00
|
|
|
d = DotProduct (p1, f->plane.normal) - f->plane.dist;
|
|
|
|
if (d < -ON_EPSILON || d > ON_EPSILON)
|
2010-09-09 11:46:38 +00:00
|
|
|
Sys_Error ("CheckFace: point off plane");
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
// check the edge isn't degenerate
|
2003-03-18 19:48:24 +00:00
|
|
|
p2 = w->points[j];
|
|
|
|
VectorSubtract (p2, p1, dir);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
if (VectorLength (dir) < ON_EPSILON)
|
2010-09-09 11:46:38 +00:00
|
|
|
Sys_Error ("CheckFace: degenerate edge");
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
CrossProduct (f->plane.normal, dir, edgenormal);
|
|
|
|
VectorNormalize (edgenormal);
|
|
|
|
edgedist = DotProduct (p1, edgenormal);
|
|
|
|
edgedist += ON_EPSILON;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
// all other points must be on front side
|
|
|
|
for (j = 0; j < w->numpoints; j++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
if (j == i)
|
|
|
|
continue;
|
|
|
|
d = DotProduct (w->points[j], edgenormal);
|
|
|
|
if (d > edgedist)
|
2010-09-09 11:46:38 +00:00
|
|
|
Sys_Error ("CheckFace: non-convex");
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=============================================================================
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
TURN PLANES INTO GROUPS OF FACES
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
=============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
NewWinding
|
|
|
|
==================
|
|
|
|
*/
|
2010-09-29 20:09:11 +00:00
|
|
|
winding_t *
|
2010-09-11 10:03:41 +00:00
|
|
|
NewWinding (int points)
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
winding_t *w;
|
2010-09-11 10:03:41 +00:00
|
|
|
size_t size;
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
if (points > MAX_POINTS_ON_WINDING)
|
2010-09-09 11:46:38 +00:00
|
|
|
Sys_Error ("NewWinding: %i points", points);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
size = (size_t) ((winding_t *) 0)->points[points];
|
2003-03-18 19:48:24 +00:00
|
|
|
w = malloc (size);
|
|
|
|
memset (w, 0, size);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return w;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
CopyWinding
|
|
|
|
==================
|
|
|
|
*/
|
2010-09-29 20:09:11 +00:00
|
|
|
winding_t *
|
2010-09-11 10:03:41 +00:00
|
|
|
CopyWinding (winding_t * w)
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
size_t size;
|
2010-09-29 20:09:11 +00:00
|
|
|
winding_t *c;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
size = (size_t) ((winding_t *) 0)->points[w->numpoints];
|
2003-03-18 19:48:24 +00:00
|
|
|
c = malloc (size);
|
|
|
|
memcpy (c, w, size);
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
ClipWinding
|
|
|
|
|
|
|
|
Clips the winding to the plane, returning the new winding on the positive side
|
|
|
|
Frees the input winding.
|
|
|
|
==================
|
|
|
|
*/
|
2010-09-29 20:09:11 +00:00
|
|
|
winding_t *
|
2010-09-11 10:03:41 +00:00
|
|
|
ClipWinding (winding_t * in, plane_t *split)
|
|
|
|
{
|
|
|
|
float dists[MAX_POINTS_ON_WINDING];
|
|
|
|
int sides[MAX_POINTS_ON_WINDING];
|
|
|
|
int counts[3];
|
|
|
|
float dot;
|
|
|
|
int i, j;
|
2010-09-29 20:09:11 +00:00
|
|
|
float *p1, *p2, *mid;
|
|
|
|
winding_t *neww;
|
2010-09-11 10:03:41 +00:00
|
|
|
int maxpts;
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
counts[0] = counts[1] = counts[2] = 0;
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
// determine sides for each point
|
2010-09-11 10:03:41 +00:00
|
|
|
for (i = 0; i < in->numpoints; i++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
dot = DotProduct (in->points[i], split->normal);
|
|
|
|
dot -= split->dist;
|
|
|
|
dists[i] = dot;
|
|
|
|
if (dot > ON_EPSILON)
|
|
|
|
sides[i] = SIDE_FRONT;
|
|
|
|
else if (dot < -ON_EPSILON)
|
|
|
|
sides[i] = SIDE_BACK;
|
2010-09-29 20:09:11 +00:00
|
|
|
else
|
2003-03-18 19:48:24 +00:00
|
|
|
sides[i] = SIDE_ON;
|
|
|
|
counts[sides[i]]++;
|
|
|
|
}
|
|
|
|
sides[i] = sides[0];
|
|
|
|
dists[i] = dists[0];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
if (!counts[0] && !counts[1])
|
|
|
|
return in;
|
2010-09-11 10:03:41 +00:00
|
|
|
if (!counts[0]) {
|
2003-03-18 19:48:24 +00:00
|
|
|
free (in);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (!counts[1])
|
|
|
|
return in;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
// can't use counts[0]+2 because of fp grouping errors
|
|
|
|
maxpts = in->numpoints + 4;
|
2003-03-18 19:48:24 +00:00
|
|
|
neww = NewWinding (maxpts);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
for (i = 0; i < in->numpoints; i++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
p1 = in->points[i];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
mid = neww->points[neww->numpoints];
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
if (sides[i] == SIDE_FRONT || sides[i] == SIDE_ON) {
|
2003-03-18 19:48:24 +00:00
|
|
|
VectorCopy (p1, mid);
|
|
|
|
mid[3] = p1[3];
|
|
|
|
mid[4] = p1[4];
|
|
|
|
neww->numpoints++;
|
|
|
|
if (sides[i] == SIDE_ON)
|
|
|
|
continue;
|
|
|
|
mid = neww->points[neww->numpoints];
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
if (sides[i + 1] == SIDE_ON || sides[i + 1] == sides[i])
|
2003-03-18 19:48:24 +00:00
|
|
|
continue;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
// generate a split point
|
2003-03-18 19:48:24 +00:00
|
|
|
if (i == in->numpoints - 1)
|
|
|
|
p2 = in->points[0];
|
|
|
|
else
|
|
|
|
p2 = p1 + 5;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
neww->numpoints++;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
dot = dists[i] / (dists[i] - dists[i + 1]);
|
2010-09-29 20:09:11 +00:00
|
|
|
for (j = 0; j < 3; j++) { // avoid round off error when possible
|
2003-03-18 19:48:24 +00:00
|
|
|
if (split->normal[j] == 1)
|
|
|
|
mid[j] = split->dist;
|
|
|
|
else if (split->normal[j] == -1)
|
|
|
|
mid[j] = -split->dist;
|
2010-09-11 10:03:41 +00:00
|
|
|
mid[j] = p1[j] + dot * (p2[j] - p1[j]);
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
mid[3] = p1[3] + dot * (p2[3] - p1[3]);
|
|
|
|
mid[4] = p1[4] + dot * (p2[4] - p1[4]);
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (neww->numpoints > maxpts)
|
2010-09-09 11:46:38 +00:00
|
|
|
Sys_Error ("ClipWinding: points exceeded estimate");
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
// free the original winding
|
2003-03-18 19:48:24 +00:00
|
|
|
free (in);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return neww;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
BasePolyForPlane
|
|
|
|
|
|
|
|
There has GOT to be a better way of doing this...
|
|
|
|
=================
|
|
|
|
*/
|
2010-09-29 20:09:11 +00:00
|
|
|
winding_t *
|
2010-09-11 10:03:41 +00:00
|
|
|
BasePolyForPlane (face_t * f)
|
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
int i, x;
|
|
|
|
float max, v;
|
|
|
|
vec3_t org, vright, vup;
|
|
|
|
vec3_t xaxis, yaxis;
|
|
|
|
winding_t *w;
|
|
|
|
texturedef_t *td;
|
|
|
|
plane_t *p;
|
|
|
|
float ang, sinv, cosv;
|
|
|
|
float s, t, ns, nt;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
p = &f->plane;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
// find the major axis
|
2003-03-18 19:48:24 +00:00
|
|
|
max = -BOGUS_RANGE;
|
|
|
|
x = -1;
|
2010-09-11 10:03:41 +00:00
|
|
|
for (i = 0; i < 3; i++) {
|
|
|
|
v = fabs (p->normal[i]);
|
|
|
|
if (v > max) {
|
2003-03-18 19:48:24 +00:00
|
|
|
x = i;
|
|
|
|
max = v;
|
|
|
|
}
|
|
|
|
}
|
2010-09-29 20:09:11 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
if (x == -1)
|
2010-09-09 11:46:38 +00:00
|
|
|
Sys_Error ("BasePolyForPlane: no axis found");
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
VectorCopy (vec3_origin, vup);
|
|
|
|
switch (x) {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
vup[2] = 1;
|
|
|
|
break;
|
2010-09-29 20:09:11 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
case 2:
|
|
|
|
vup[0] = 1;
|
|
|
|
break;
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
v = DotProduct (vup, p->normal);
|
2010-09-09 11:46:38 +00:00
|
|
|
VectorMultAdd (vup, -v, p->normal, vup);
|
2003-03-18 19:48:24 +00:00
|
|
|
VectorNormalize (vup);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
VectorScale (p->normal, p->dist, org);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
CrossProduct (vup, p->normal, vright);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
VectorScale (vup, 8192, vup);
|
|
|
|
VectorScale (vright, 8192, vright);
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
// project a really big axis-aligned box onto the plane
|
2003-03-18 19:48:24 +00:00
|
|
|
w = NewWinding (4);
|
|
|
|
w->numpoints = 4;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
VectorSubtract (org, vright, w->points[0]);
|
|
|
|
VectorAdd (w->points[0], vup, w->points[0]);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
VectorAdd (org, vright, w->points[1]);
|
|
|
|
VectorAdd (w->points[1], vup, w->points[1]);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
VectorAdd (org, vright, w->points[2]);
|
|
|
|
VectorSubtract (w->points[2], vup, w->points[2]);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
VectorSubtract (org, vright, w->points[3]);
|
|
|
|
VectorSubtract (w->points[3], vup, w->points[3]);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
// set texture values
|
2010-09-11 10:03:41 +00:00
|
|
|
f->light = TextureAxisFromPlane (&f->plane, xaxis, yaxis);
|
2003-03-18 19:48:24 +00:00
|
|
|
td = &f->texture;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
// rotate axis
|
2003-03-18 19:48:24 +00:00
|
|
|
ang = td->rotate / 180 * M_PI;
|
2010-09-11 10:03:41 +00:00
|
|
|
sinv = sin (ang);
|
|
|
|
cosv = cos (ang);
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
if (!(td->scale[0]))
|
2003-03-18 19:48:24 +00:00
|
|
|
td->scale[0] = 1;
|
2010-09-29 20:09:11 +00:00
|
|
|
|
|
|
|
if (!(td->scale[1]))
|
2003-03-18 19:48:24 +00:00
|
|
|
td->scale[1] = 1;
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
for (i = 0; i < 4; i++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
s = DotProduct (w->points[i], xaxis);
|
|
|
|
t = DotProduct (w->points[i], yaxis);
|
|
|
|
|
|
|
|
ns = cosv * s - sinv * t;
|
2010-09-11 10:03:41 +00:00
|
|
|
nt = sinv * s + cosv * t;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
w->points[i][3] = ns / td->scale[0] + td->shift[0];
|
|
|
|
w->points[i][4] = nt / td->scale[1] + td->shift[1];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
return w;
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===========
|
|
|
|
calcWindings
|
|
|
|
|
|
|
|
recalc the faces and mins / maxs from the planes
|
|
|
|
If a face has a NULL winding, it is an overconstraining plane and
|
|
|
|
can be removed.
|
|
|
|
===========
|
|
|
|
*/
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) calcWindings
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
int i, j, k;
|
|
|
|
float v;
|
2010-09-29 20:09:11 +00:00
|
|
|
face_t *f;
|
|
|
|
winding_t *w;
|
2010-09-11 10:03:41 +00:00
|
|
|
plane_t plane;
|
|
|
|
vec3_t t1, t2, t3;
|
|
|
|
BOOL useplane[MAX_FACES];
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
bmins[0] = bmins[1] = bmins[2] = 99999;
|
|
|
|
bmaxs[0] = bmaxs[1] = bmaxs[2] = -99999;
|
|
|
|
invalid = NO;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
[self freeWindings];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
for (i = 0; i < MAX_FACES; i++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
f = &faces[i];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
// calc a plane from the points
|
|
|
|
for (j = 0; j < 3; j++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
t1[j] = f->planepts[0][j] - f->planepts[1][j];
|
|
|
|
t2[j] = f->planepts[2][j] - f->planepts[1][j];
|
|
|
|
t3[j] = f->planepts[1][j];
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
CrossProduct (t1, t2, f->plane.normal);
|
|
|
|
if (VectorCompare (f->plane.normal, vec3_origin)) {
|
2003-03-18 19:48:24 +00:00
|
|
|
useplane[i] = NO;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
VectorNormalize (f->plane.normal);
|
|
|
|
f->plane.dist = DotProduct (t3, f->plane.normal);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
// if the plane duplicates another plane, ignore it
|
|
|
|
// (assume it is a brush being edited that will be fixed)
|
2003-03-18 19:48:24 +00:00
|
|
|
useplane[i] = YES;
|
2010-09-11 10:03:41 +00:00
|
|
|
for (j = 0; j < i; j++) {
|
|
|
|
if (f->plane.normal[0] == faces[j].plane.normal[0]
|
2010-09-29 20:09:11 +00:00
|
|
|
&& f->plane.normal[1] == faces[j].plane.normal[1]
|
|
|
|
&& f->plane.normal[2] == faces[j].plane.normal[2]
|
|
|
|
&& f->plane.dist == faces[j].plane.dist) {
|
2003-03-18 19:48:24 +00:00
|
|
|
useplane[i] = NO;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
for (i = 0; i < numfaces; i++) {
|
2010-09-29 20:09:11 +00:00
|
|
|
if (!useplane[i]) // duplicate plane
|
|
|
|
continue;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
f = &faces[i];
|
|
|
|
|
|
|
|
w = BasePolyForPlane (f);
|
2010-09-11 10:03:41 +00:00
|
|
|
for (j = 0; j < numfaces && w; j++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
if (j == i)
|
|
|
|
continue;
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
// flip the plane, because we want to keep the back side
|
2003-03-18 19:48:24 +00:00
|
|
|
VectorSubtract (vec3_origin, faces[j].plane.normal, plane.normal);
|
|
|
|
plane.dist = -faces[j].plane.dist;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
w = ClipWinding (w, &plane);
|
|
|
|
}
|
|
|
|
f->w = w;
|
2010-09-11 10:03:41 +00:00
|
|
|
if (w) {
|
2003-03-18 19:48:24 +00:00
|
|
|
CheckFace (f);
|
2010-09-11 10:03:41 +00:00
|
|
|
for (j = 0; j < w->numpoints; j++) {
|
|
|
|
for (k = 0; k < 3; k++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
v = w->points[j][k];
|
2010-09-11 10:03:41 +00:00
|
|
|
if (fabs (v - rint (v)) < FP_EPSILON)
|
|
|
|
v = w->points[j][k] = rint (v);
|
2003-03-18 19:48:24 +00:00
|
|
|
if (v < bmins[k])
|
|
|
|
bmins[k] = v;
|
|
|
|
if (v > bmaxs[k])
|
|
|
|
bmaxs[k] = v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
}
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
if (bmins[0] == 99999) {
|
2003-03-18 19:48:24 +00:00
|
|
|
invalid = YES;
|
|
|
|
VectorCopy (vec3_origin, bmins);
|
|
|
|
VectorCopy (vec3_origin, bmaxs);
|
|
|
|
return nil;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
// ============================================================================
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
===========
|
|
|
|
initOwner:::
|
|
|
|
===========
|
|
|
|
*/
|
2010-09-29 20:09:11 +00:00
|
|
|
- (SetBrush *) initOwner: own
|
|
|
|
mins: (float *)mins
|
|
|
|
maxs: (float *)maxs
|
|
|
|
texture: (texturedef_t *)tex
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
[super init];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
parent = own;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
[self setTexturedef: tex];
|
|
|
|
[self setMins: mins maxs: maxs];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) setMins: (float *)
|
|
|
|
mins maxs: (float *)maxs
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
int i, j;
|
|
|
|
vec3_t pts[4][2];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
for (i = 0; i < 3; i++) {
|
|
|
|
if (maxs[i] - mins[i] <= 0) {
|
2003-03-18 19:48:24 +00:00
|
|
|
VectorCopy (mins, bmins);
|
|
|
|
VectorCopy (maxs, bmaxs);
|
|
|
|
invalid = YES;
|
|
|
|
numfaces = 0;
|
|
|
|
return self;
|
2010-09-11 10:03:41 +00:00
|
|
|
}
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
pts[0][0][0] = mins[0];
|
|
|
|
pts[0][0][1] = mins[1];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
pts[1][0][0] = mins[0];
|
|
|
|
pts[1][0][1] = maxs[1];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
pts[2][0][0] = maxs[0];
|
|
|
|
pts[2][0][1] = maxs[1];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
pts[3][0][0] = maxs[0];
|
|
|
|
pts[3][0][1] = mins[1];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
for (i = 0; i < 4; i++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
pts[i][0][2] = mins[2];
|
|
|
|
pts[i][1][0] = pts[i][0][0];
|
|
|
|
pts[i][1][1] = pts[i][0][1];
|
|
|
|
pts[i][1][2] = maxs[2];
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
numfaces = 6;
|
2010-09-11 10:03:41 +00:00
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
j = (i + 1) % 4;
|
2003-03-18 19:48:24 +00:00
|
|
|
faces[i].planepts[0][0] = pts[j][1][0];
|
|
|
|
faces[i].planepts[0][1] = pts[j][1][1];
|
|
|
|
faces[i].planepts[0][2] = pts[j][1][2];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
faces[i].planepts[1][0] = pts[i][1][0];
|
|
|
|
faces[i].planepts[1][1] = pts[i][1][1];
|
|
|
|
faces[i].planepts[1][2] = pts[i][1][2];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
faces[i].planepts[2][0] = pts[i][0][0];
|
|
|
|
faces[i].planepts[2][1] = pts[i][0][1];
|
|
|
|
faces[i].planepts[2][2] = pts[i][0][2];
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
faces[4].planepts[0][0] = pts[0][1][0];
|
|
|
|
faces[4].planepts[0][1] = pts[0][1][1];
|
|
|
|
faces[4].planepts[0][2] = pts[0][1][2];
|
|
|
|
|
|
|
|
faces[4].planepts[1][0] = pts[1][1][0];
|
|
|
|
faces[4].planepts[1][1] = pts[1][1][1];
|
|
|
|
faces[4].planepts[1][2] = pts[1][1][2];
|
|
|
|
|
|
|
|
faces[4].planepts[2][0] = pts[2][1][0];
|
|
|
|
faces[4].planepts[2][1] = pts[2][1][1];
|
|
|
|
faces[4].planepts[2][2] = pts[2][1][2];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
faces[5].planepts[0][0] = pts[2][0][0];
|
|
|
|
faces[5].planepts[0][1] = pts[2][0][1];
|
|
|
|
faces[5].planepts[0][2] = pts[2][0][2];
|
|
|
|
|
|
|
|
faces[5].planepts[1][0] = pts[1][0][0];
|
|
|
|
faces[5].planepts[1][1] = pts[1][0][1];
|
|
|
|
faces[5].planepts[1][2] = pts[1][0][2];
|
|
|
|
|
|
|
|
faces[5].planepts[2][0] = pts[0][0][0];
|
|
|
|
faces[5].planepts[2][1] = pts[0][0][1];
|
|
|
|
faces[5].planepts[2][2] = pts[0][0][2];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
[self calcWindings];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) parent
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) setParent: (id)p
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
parent = p;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) setEntityColor: (vec3_t)color
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
VectorCopy (color, entitycolor);
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (void) freeWindings
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
int i;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
for (i = 0; i < MAX_FACES; i++) {
|
2010-09-11 10:03:41 +00:00
|
|
|
if (faces[i].w) {
|
2003-03-18 19:48:24 +00:00
|
|
|
free (faces[i].w);
|
|
|
|
faces[i].w = NULL;
|
|
|
|
}
|
2010-09-29 20:09:11 +00:00
|
|
|
}
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-10-11 00:19:09 +00:00
|
|
|
- (id) copyWithZone: (NSZone *) zone
|
|
|
|
{
|
|
|
|
SetBrush *new;
|
|
|
|
|
|
|
|
[self freeWindings];
|
|
|
|
|
|
|
|
new = [[SetBrush allocWithZone: zone] init];
|
|
|
|
new->regioned = regioned;
|
|
|
|
new->selected = selected;
|
|
|
|
new->invalid = invalid;
|
|
|
|
new->parent = parent;
|
|
|
|
VectorCopy (bmins, new->bmins);
|
|
|
|
VectorCopy (bmaxs, new->bmaxs);
|
|
|
|
VectorCopy (entitycolor, new->entitycolor);
|
|
|
|
new->numfaces = numfaces;
|
|
|
|
memcpy (new->faces, faces, sizeof (new->faces));
|
|
|
|
|
|
|
|
[self calcWindings];
|
|
|
|
[new calcWindings];
|
|
|
|
return new;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (void) dealloc
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
[self freeWindings];
|
2010-09-29 20:09:11 +00:00
|
|
|
return [super dealloc];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===========
|
|
|
|
initOwner: fromTokens
|
|
|
|
===========
|
|
|
|
*/
|
2010-09-29 20:09:11 +00:00
|
|
|
int numsb;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-10-09 06:34:03 +00:00
|
|
|
static vec3_t *
|
|
|
|
ParseVerts (script_t *script, int *n_verts)
|
|
|
|
{
|
|
|
|
vec3_t *verts;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (strcmp (Script_Token (script), ":"))
|
|
|
|
Sys_Error ("parsing map file");
|
|
|
|
Script_GetToken (script, false);
|
|
|
|
*n_verts = atoi (Script_Token (script));
|
|
|
|
verts = malloc (sizeof (vec3_t) * *n_verts);
|
|
|
|
|
|
|
|
for (i = 0; i < *n_verts; i++) {
|
|
|
|
Script_GetToken (script, true);
|
|
|
|
verts[i][0] = atof (Script_Token (script));
|
|
|
|
Script_GetToken (script, true);
|
|
|
|
verts[i][1] = atof (Script_Token (script));
|
|
|
|
Script_GetToken (script, true);
|
|
|
|
verts[i][2] = atof (Script_Token (script));
|
|
|
|
}
|
|
|
|
return verts;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) initFromScript: (script_t *)script owner: own
|
2010-09-12 09:12:02 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
face_t *f;
|
2010-10-09 06:34:03 +00:00
|
|
|
vec3_t *verts = 0;
|
|
|
|
int n_verts = 0;
|
2010-09-29 20:09:11 +00:00
|
|
|
int i, j;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
[self init];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-12 09:12:02 +00:00
|
|
|
parent = own;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-12 09:12:02 +00:00
|
|
|
f = faces;
|
|
|
|
numfaces = 0;
|
2010-10-09 06:34:03 +00:00
|
|
|
|
|
|
|
if (!Script_GetToken (script, true))
|
|
|
|
return self;
|
|
|
|
|
|
|
|
if (strcmp (Script_Token (script), "(")) {
|
|
|
|
verts = ParseVerts (script, &n_verts);
|
|
|
|
} else {
|
|
|
|
Script_UngetToken (script);
|
|
|
|
}
|
|
|
|
|
2010-09-12 09:12:02 +00:00
|
|
|
do {
|
2011-03-29 03:46:49 +00:00
|
|
|
if (f - faces >= MAX_FACES) {
|
|
|
|
printf ("%s:%d: too many faces\n", script->file, script->line);
|
|
|
|
abort ();
|
|
|
|
}
|
2010-09-12 09:12:02 +00:00
|
|
|
if (!Script_GetToken (script, true))
|
|
|
|
break;
|
|
|
|
if (!strcmp (Script_Token (script), "}"))
|
|
|
|
break;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-10-09 06:34:03 +00:00
|
|
|
if (verts) {
|
|
|
|
int n_v, v;
|
|
|
|
n_v = atoi (Script_Token (script));
|
|
|
|
Script_GetToken (script, false);
|
|
|
|
for (i = 0; i < n_v; i++) {
|
2010-09-12 09:12:02 +00:00
|
|
|
Script_GetToken (script, false);
|
2010-10-09 06:34:03 +00:00
|
|
|
v = atoi (Script_Token (script));
|
|
|
|
if (i < 3)
|
|
|
|
VectorCopy (verts[v], f->planepts[i]);
|
2010-09-29 20:09:11 +00:00
|
|
|
}
|
2010-10-09 06:34:03 +00:00
|
|
|
printf ("\n");
|
2010-09-29 20:09:11 +00:00
|
|
|
Script_GetToken (script, false);
|
2010-10-09 06:34:03 +00:00
|
|
|
} else {
|
|
|
|
for (i = 0; i < 3; i++) {
|
|
|
|
if (i != 0)
|
|
|
|
Script_GetToken (script, true);
|
|
|
|
if (strcmp (Script_Token (script), "("))
|
|
|
|
Sys_Error ("parsing map file");
|
|
|
|
|
|
|
|
for (j = 0; j < 3; j++) {
|
|
|
|
Script_GetToken (script, false);
|
|
|
|
f->planepts[i][j] = atoi (Script_Token (script));
|
|
|
|
}
|
|
|
|
Script_GetToken (script, false);
|
2010-09-12 09:12:02 +00:00
|
|
|
|
2010-10-09 06:34:03 +00:00
|
|
|
if (strcmp (Script_Token (script), ")"))
|
|
|
|
Sys_Error ("parsing map file");
|
|
|
|
}
|
2010-09-12 09:12:02 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-12 09:12:02 +00:00
|
|
|
Script_GetToken (script, false);
|
|
|
|
strcpy (f->texture.texture, Script_Token (script));
|
|
|
|
Script_GetToken (script, false);
|
|
|
|
f->texture.shift[0] = atof (Script_Token (script));
|
|
|
|
Script_GetToken (script, false);
|
|
|
|
f->texture.shift[1] = atof (Script_Token (script));
|
|
|
|
Script_GetToken (script, false);
|
|
|
|
f->texture.rotate = atof (Script_Token (script));
|
|
|
|
Script_GetToken (script, false);
|
|
|
|
f->texture.scale[0] = atof (Script_Token (script));
|
|
|
|
Script_GetToken (script, false);
|
|
|
|
f->texture.scale[1] = atof (Script_Token (script));
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-10-09 06:34:03 +00:00
|
|
|
while (Script_TokenAvailable (script, false)) {
|
|
|
|
Script_GetToken (script, false);
|
|
|
|
if (!strcmp (Script_Token (script), "detail"))
|
|
|
|
; // XXX implement
|
|
|
|
else
|
|
|
|
Sys_Error ("parsing map file");
|
|
|
|
}
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
#if 0
|
2010-09-12 09:12:02 +00:00
|
|
|
flags = atoi (Script_Token (script));
|
|
|
|
|
|
|
|
flags &= 7;
|
|
|
|
|
|
|
|
f->texture.rotate = 0;
|
|
|
|
f->texture.scale[0] = 1;
|
|
|
|
f->texture.scale[1] = 1;
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
# define TEX_FLIPAXIS 1
|
|
|
|
# define TEX_FLIPS 2
|
|
|
|
# define TEX_FLIPT 4
|
2010-09-12 09:12:02 +00:00
|
|
|
|
|
|
|
if (flags & TEX_FLIPAXIS) {
|
|
|
|
f->texture.rotate = 90;
|
|
|
|
if (!(flags & TEX_FLIPT))
|
|
|
|
f->texture.scale[0] = -1;
|
|
|
|
if (flags & TEX_FLIPS)
|
|
|
|
f->texture.scale[1] = -1;
|
|
|
|
} else {
|
|
|
|
if (flags & TEX_FLIPS)
|
|
|
|
f->texture.scale[0] = -1;
|
|
|
|
if (flags & TEX_FLIPT)
|
|
|
|
f->texture.scale[1] = -1;
|
|
|
|
}
|
2010-09-29 20:09:11 +00:00
|
|
|
#endif /* if 0 */
|
2010-09-12 09:12:02 +00:00
|
|
|
f++;
|
|
|
|
numfaces++;
|
2003-03-18 19:48:24 +00:00
|
|
|
} while (1);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
numsb++;
|
|
|
|
|
|
|
|
[self calcWindings];
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-12-27 03:11:07 +00:00
|
|
|
- (void) writeToFile: (QFile *)file
|
2010-09-29 20:09:11 +00:00
|
|
|
region: (BOOL)reg
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
int i, j;
|
|
|
|
face_t *fa;
|
|
|
|
texturedef_t *td;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
if (reg && regioned)
|
2010-09-28 19:43:35 +00:00
|
|
|
return;
|
2010-12-27 03:11:07 +00:00
|
|
|
Qprintf (file, "{\n");
|
2010-09-11 10:03:41 +00:00
|
|
|
for (i = 0; i < numfaces; i++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
fa = &faces[i];
|
2010-09-29 20:09:11 +00:00
|
|
|
for (j = 0; j < 3; j++) {
|
2010-12-27 03:11:07 +00:00
|
|
|
Qprintf (file, "( %d %d %d ) ", (int) fa->planepts[j][0],
|
2010-09-29 20:09:11 +00:00
|
|
|
(int) fa->planepts[j][1], (int) fa->planepts[j][2]);
|
|
|
|
}
|
2003-03-18 19:48:24 +00:00
|
|
|
td = &fa->texture;
|
2010-12-27 03:11:07 +00:00
|
|
|
Qprintf (file, "%s %d %d %d %f %f\n", td->texture, (int) td->shift[0],
|
2010-09-29 20:09:11 +00:00
|
|
|
(int) td->shift[1], (int) td->rotate, td->scale[0],
|
|
|
|
td->scale[1]);
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-12-27 03:11:07 +00:00
|
|
|
Qprintf (file, "}\n");
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-28 19:43:35 +00:00
|
|
|
return;
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
INTERACTION
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
*/
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (void) getMins: (vec3_t)mins
|
|
|
|
maxs: (vec3_t)maxs
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
VectorCopy (bmins, mins);
|
|
|
|
VectorCopy (bmaxs, maxs);
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (BOOL) selected
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
return selected;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (void) setSelected: (BOOL)s
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
selected = s;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (BOOL) regioned
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
return regioned;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (void) setRegioned: (BOOL)s
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
regioned = s;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===========
|
|
|
|
setTexturedef
|
|
|
|
===========
|
|
|
|
*/
|
2010-09-28 19:43:35 +00:00
|
|
|
- (void) setTexturedef: (texturedef_t *)tex
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
int i;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
for (i = 0; i < MAX_FACES; i++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
faces[i].texture = *tex;
|
2010-09-29 20:09:11 +00:00
|
|
|
faces[i].qtexture = NULL; // recache next render
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
[self calcWindings]; // in case texture coords changed
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (void) setTexturedef: (texturedef_t *)tex
|
|
|
|
forFace: (int)f
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-27 18:09:02 +00:00
|
|
|
if (f > numfaces)
|
2010-09-11 10:03:41 +00:00
|
|
|
Sys_Error ("setTexturedef:forFace: bad face number %i", f);
|
2003-03-18 19:48:24 +00:00
|
|
|
faces[f].texture = *tex;
|
2010-09-29 20:09:11 +00:00
|
|
|
faces[f].qtexture = NULL; // recache next render
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
[self calcWindings]; // in case texture coords changed
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===========
|
|
|
|
texturedef
|
|
|
|
===========
|
|
|
|
*/
|
2010-09-29 20:09:11 +00:00
|
|
|
- (texturedef_t *) texturedef
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
return &faces[0].texture;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (texturedef_t *) texturedefForFace: (int)f
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
return &faces[f].texture;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===========
|
|
|
|
removeIfInvalid
|
|
|
|
|
|
|
|
So created veneers don't stay around
|
|
|
|
===========
|
|
|
|
*/
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) removeIfInvalid
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
int i, j;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
for (i = 0; i < numfaces; i++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
if (faces[i].w)
|
|
|
|
continue;
|
2010-09-11 10:03:41 +00:00
|
|
|
for (j = i + 1; j < numfaces; j++)
|
|
|
|
faces[j - 1] = faces[j];
|
2010-09-29 20:09:11 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
i--;
|
|
|
|
numfaces--;
|
|
|
|
}
|
2010-09-29 20:09:11 +00:00
|
|
|
for ( ; i < MAX_FACES; i++)
|
2003-03-18 19:48:24 +00:00
|
|
|
faces[i].w = NULL;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
if (numfaces < 4) {
|
2003-03-18 19:48:24 +00:00
|
|
|
invalid = YES;
|
|
|
|
[self remove];
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===========
|
|
|
|
containsPoint
|
|
|
|
|
|
|
|
===========
|
|
|
|
*/
|
2010-09-29 20:09:11 +00:00
|
|
|
- (BOOL) containsPoint: (vec3_t)pt
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
int i;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
for (i = 0; i < numfaces; i++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
if (DotProduct (faces[i].plane.normal, pt) >= faces[i].plane.dist)
|
|
|
|
return NO;
|
2010-09-29 20:09:11 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
return YES;
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===========
|
2010-09-29 20:09:11 +00:00
|
|
|
clipRay::::::
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
===========
|
|
|
|
*/
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) clipRay: (vec3_t)p1
|
|
|
|
: (vec3_t)p2
|
|
|
|
: (vec3_t)frontpoint
|
|
|
|
: (int *)f_face
|
|
|
|
: (vec3_t)backpoint
|
|
|
|
: (int *)b_face
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
int frontface, backface;
|
|
|
|
int i, j;
|
|
|
|
face_t *f;
|
|
|
|
float d1, d2, m;
|
|
|
|
float *start;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
start = p1;
|
|
|
|
|
|
|
|
frontface = -2;
|
|
|
|
backface = -2;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
f = faces;
|
2010-09-11 10:03:41 +00:00
|
|
|
for (i = 0; i < numfaces; i++, f++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
if (!f->w)
|
2010-09-29 20:09:11 +00:00
|
|
|
continue; // clipped off plane
|
2003-03-18 19:48:24 +00:00
|
|
|
d1 = DotProduct (p1, f->plane.normal) - f->plane.dist;
|
|
|
|
d2 = DotProduct (p2, f->plane.normal) - f->plane.dist;
|
2010-09-29 20:09:11 +00:00
|
|
|
if (d1 >= 0 && d2 >= 0) { // the whole ray is in front of the polytope
|
2003-03-18 19:48:24 +00:00
|
|
|
*f_face = -1;
|
|
|
|
*b_face = -1;
|
|
|
|
return self;
|
|
|
|
}
|
2010-09-29 20:09:11 +00:00
|
|
|
if (d1 > 0 && d2 < 0) { // new front plane
|
2003-03-18 19:48:24 +00:00
|
|
|
frontface = i;
|
2010-09-11 10:03:41 +00:00
|
|
|
m = d1 / (d1 - d2);
|
|
|
|
for (j = 0; j < 3; j++)
|
|
|
|
frontpoint[j] = p1[j] + m * (p2[j] - p1[j]);
|
2010-09-29 20:09:11 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
p1 = frontpoint;
|
|
|
|
}
|
2010-09-29 20:09:11 +00:00
|
|
|
if (d1 < 0 && d2 > 0) { // new back plane
|
2003-03-18 19:48:24 +00:00
|
|
|
backface = i;
|
2010-09-11 10:03:41 +00:00
|
|
|
m = d1 / (d1 - d2);
|
|
|
|
for (j = 0; j < 3; j++)
|
|
|
|
backpoint[j] = p1[j] + m * (p2[j] - p1[j]);
|
2010-09-29 20:09:11 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
p2 = backpoint;
|
|
|
|
}
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
*f_face = frontface;
|
|
|
|
*b_face = backface;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===========
|
2010-09-29 20:09:11 +00:00
|
|
|
hitByRay::::
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
===========
|
|
|
|
*/
|
2010-09-29 20:09:11 +00:00
|
|
|
- (void) hitByRay: (vec3_t)p1
|
|
|
|
: (vec3_t)p2
|
|
|
|
: (float *)time
|
|
|
|
: (int *)face
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
vec3_t frontpoint, backpoint, dir;
|
|
|
|
int frontface, backface;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
if (regioned) {
|
2003-03-18 19:48:24 +00:00
|
|
|
*time = -1;
|
|
|
|
*face = -1;
|
2010-10-10 04:07:28 +00:00
|
|
|
return;
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
[self clipRay: p1 : p2 : frontpoint : &frontface : backpoint : &backface];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
if (frontface == -2 && backface == -2) {
|
|
|
|
// entire ray is inside the brush, select first face
|
2003-03-18 19:48:24 +00:00
|
|
|
*time = 0;
|
|
|
|
*face = 0;
|
2010-10-10 04:07:28 +00:00
|
|
|
return;
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
if (frontface < 0) { // ray started inside the polytope, don't select it
|
2003-03-18 19:48:24 +00:00
|
|
|
*time = -1;
|
|
|
|
*face = -1;
|
2010-10-10 04:07:28 +00:00
|
|
|
return;
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
VectorSubtract (p2, p1, dir);
|
|
|
|
VectorNormalize (dir);
|
|
|
|
VectorSubtract (frontpoint, p1, frontpoint);
|
|
|
|
*time = DotProduct (frontpoint, dir);
|
|
|
|
|
|
|
|
if (*time < 0)
|
2010-09-09 11:46:38 +00:00
|
|
|
Sys_Error ("hitByRay: negative t");
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
*face = frontface;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
DRAWING ROUTINES
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
*/
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
BOOL fakebrush;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) drawConnections
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
id obj;
|
|
|
|
int c, i;
|
|
|
|
vec3_t dest, origin;
|
|
|
|
vec3_t mid;
|
|
|
|
vec3_t forward, right;
|
2010-09-29 20:09:11 +00:00
|
|
|
const char *targname;
|
2010-09-11 10:03:41 +00:00
|
|
|
vec3_t min, max, temp;
|
2010-09-29 20:09:11 +00:00
|
|
|
const char *targ;
|
2011-04-09 09:32:29 +00:00
|
|
|
NSArray *target_list;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
targ = [parent valueForQKey: "target"];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
if (!targ || !targ[0])
|
|
|
|
return self;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
origin[0] = (bmins[0] + bmaxs[0]) / 2;
|
|
|
|
origin[1] = (bmins[1] + bmaxs[1]) / 2;
|
|
|
|
|
2011-04-09 09:32:29 +00:00
|
|
|
target_list = [map_i targetsForTargetName: targ];
|
|
|
|
c = [target_list count];
|
2010-09-11 10:03:41 +00:00
|
|
|
for (i = 0; i < c; i++) {
|
2011-04-09 09:32:29 +00:00
|
|
|
obj = [target_list objectAtIndex: i];
|
2010-09-29 20:09:11 +00:00
|
|
|
targname = [obj valueForQKey: "targetname"];
|
2003-03-18 19:48:24 +00:00
|
|
|
if (strcmp (targ, targname))
|
|
|
|
continue;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
[[obj objectAtIndex: 0] getMins: min maxs: max];
|
2010-09-11 10:03:41 +00:00
|
|
|
dest[0] = (min[0] + max[0]) / 2;
|
|
|
|
dest[1] = (min[1] + max[1]) / 2;
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
XYmoveto (origin);
|
|
|
|
XYlineto (dest);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
forward[0] = dest[0] - origin[0];
|
|
|
|
forward[1] = dest[1] - origin[1];
|
|
|
|
forward[2] = 0;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
if (!forward[0] && !forward[1])
|
|
|
|
continue;
|
|
|
|
VectorNormalize (forward);
|
2010-09-11 10:03:41 +00:00
|
|
|
forward[0] = 8 * forward[0];
|
|
|
|
forward[1] = 8 * forward[1];
|
2003-03-18 19:48:24 +00:00
|
|
|
right[0] = forward[1];
|
|
|
|
right[1] = -forward[0];
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
mid[0] = (dest[0] + origin[0]) / 2;
|
|
|
|
mid[1] = (dest[1] + origin[1]) / 2;
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
temp[0] = mid[0] + right[0] - forward[0];
|
|
|
|
temp[1] = mid[1] + right[1] - forward[1];
|
|
|
|
XYmoveto (temp);
|
|
|
|
XYlineto (mid);
|
|
|
|
temp[0] = mid[0] - right[0] - forward[0];
|
|
|
|
temp[1] = mid[1] - right[1] - forward[1];
|
|
|
|
XYlineto (temp);
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (BOOL) fakeBrush: (SEL)call
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
id copy;
|
|
|
|
face_t face;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
if (!selected || fakebrush)
|
|
|
|
return NO;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
if (![clipper_i getFace: &face])
|
2003-03-18 19:48:24 +00:00
|
|
|
return NO;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
fakebrush = YES;
|
2010-09-29 20:09:11 +00:00
|
|
|
copy = [self copy];
|
|
|
|
copy = [copy addFace: &face];
|
2010-09-11 10:03:41 +00:00
|
|
|
if (copy) {
|
2010-09-29 20:09:11 +00:00
|
|
|
[copy performSelector: call];
|
2010-09-09 11:46:38 +00:00
|
|
|
[copy dealloc];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
fakebrush = NO;
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===========
|
|
|
|
XYDrawSelf
|
|
|
|
===========
|
|
|
|
*/
|
2010-09-28 19:43:35 +00:00
|
|
|
- (void) XYDrawSelf
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
int i, j;
|
2010-09-29 20:09:11 +00:00
|
|
|
winding_t *w;
|
2010-09-11 10:03:41 +00:00
|
|
|
vec3_t mid, end, s1, s2;
|
2010-09-29 20:09:11 +00:00
|
|
|
const char *val;
|
2010-09-11 10:03:41 +00:00
|
|
|
float ang;
|
|
|
|
id worldent, currentent;
|
|
|
|
BOOL keybrush;
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
if ([self fakeBrush: @selector (XYDrawSelf)])
|
2010-09-28 19:43:35 +00:00
|
|
|
return;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
[xyview_i addToScrollRange: bmins[0] : bmins[1]];
|
|
|
|
[xyview_i addToScrollRange: bmaxs[0] : bmaxs[1]];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
worldent = [map_i objectAtIndex: 0];
|
|
|
|
currentent = [map_i currentEntity];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
if (parent != worldent && self == [parent objectAtIndex: 0])
|
2003-03-18 19:48:24 +00:00
|
|
|
keybrush = YES;
|
|
|
|
else
|
|
|
|
keybrush = NO;
|
|
|
|
|
|
|
|
if (parent != worldent && worldent == currentent)
|
|
|
|
linecolor (entitycolor[0], entitycolor[1], entitycolor[2]);
|
2010-09-29 20:09:11 +00:00
|
|
|
else if (selected) // selected
|
|
|
|
linecolor (1, 0, 0);
|
|
|
|
else if (parent == currentent) // unselected, but in same entity
|
|
|
|
linecolor (0, 0, 0);
|
|
|
|
else // other entity green
|
|
|
|
linecolor (0, 0.5, 0);
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
if (keybrush)
|
2010-09-29 20:09:11 +00:00
|
|
|
[self drawConnections]; // target line
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
if (!selected &&
|
2010-09-29 20:09:11 +00:00
|
|
|
(bmaxs[0] < xy_draw_rect.origin.x
|
|
|
|
|| bmaxs[1] < xy_draw_rect.origin.y
|
|
|
|
|| bmins[0] > xy_draw_rect.origin.x + xy_draw_rect.size.width
|
|
|
|
|| bmins[1] > xy_draw_rect.origin.y + xy_draw_rect.size.height))
|
|
|
|
return; // off view, don't bother
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
for (i = 0; i < numfaces; i++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
w = faces[i].w;
|
|
|
|
if (!w)
|
|
|
|
continue;
|
2010-09-11 10:03:41 +00:00
|
|
|
if (DotProduct (faces[i].plane.normal, xy_viewnormal) > -VECTOR_EPSILON)
|
2003-03-18 19:48:24 +00:00
|
|
|
continue;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
XYmoveto (w->points[w->numpoints - 1]);
|
|
|
|
for (j = 0; j < w->numpoints; j++)
|
2003-03-18 19:48:24 +00:00
|
|
|
XYlineto (w->points[j]);
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
if (keybrush) {
|
2010-09-29 20:09:11 +00:00
|
|
|
val = [parent valueForQKey: "angle"]; // angle arrow
|
2010-09-11 10:03:41 +00:00
|
|
|
if (val && val[0]) {
|
|
|
|
ang = atof (val) * M_PI / 180;
|
2010-09-29 20:09:11 +00:00
|
|
|
if (ang > 0) { // negative values are up/down flags
|
2010-09-11 10:03:41 +00:00
|
|
|
mid[0] = (bmins[0] + bmaxs[0]) / 2;
|
|
|
|
mid[1] = (bmins[1] + bmaxs[1]) / 2;
|
|
|
|
|
|
|
|
end[0] = mid[0] + 16 * cos (ang);
|
|
|
|
end[1] = mid[1] + 16 * sin (ang);
|
|
|
|
|
|
|
|
s1[0] = mid[0] + 12 * cos (ang + 0.4);
|
|
|
|
s1[1] = mid[1] + 12 * sin (ang + 0.4);
|
|
|
|
|
|
|
|
s2[0] = mid[0] + 12 * cos (ang - 0.4);
|
|
|
|
s2[1] = mid[1] + 12 * sin (ang - 0.4);
|
|
|
|
|
|
|
|
XYmoveto (mid);
|
|
|
|
XYlineto (end);
|
|
|
|
XYmoveto (s1);
|
|
|
|
XYlineto (end);
|
|
|
|
XYlineto (s2);
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-28 19:43:35 +00:00
|
|
|
return;
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===========
|
|
|
|
ZDrawSelf
|
|
|
|
===========
|
|
|
|
*/
|
2010-09-28 19:43:35 +00:00
|
|
|
- (void) ZDrawSelf
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
int i;
|
2010-09-23 13:56:07 +00:00
|
|
|
NSPoint p;
|
2010-09-11 10:03:41 +00:00
|
|
|
vec3_t p1, p2;
|
|
|
|
vec3_t frontpoint, backpoint;
|
|
|
|
int frontface, backface;
|
2010-09-29 20:09:11 +00:00
|
|
|
qtexture_t *q;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
if ([self fakeBrush: @selector (ZDrawSelf)])
|
2010-09-28 19:43:35 +00:00
|
|
|
return;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
[zview_i addToHeightRange: bmins[2]];
|
|
|
|
[zview_i addToHeightRange: bmaxs[2]];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
if (selected) {
|
2010-09-23 13:56:07 +00:00
|
|
|
[[NSColor redColor] set];
|
2010-09-26 13:45:26 +00:00
|
|
|
NSFrameRect (NSMakeRect (1, bmins[2], 24, bmaxs[2] - bmins[2]));
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-09-23 13:56:07 +00:00
|
|
|
[zview_i getPoint: &p];
|
|
|
|
p1[0] = p.x;
|
|
|
|
p1[1] = p.y;
|
2010-09-29 20:09:11 +00:00
|
|
|
for (i = 0; i < 2; i++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
if (bmins[i] >= p1[i] || bmaxs[i] <= p1[i])
|
2010-09-28 19:43:35 +00:00
|
|
|
return;
|
2010-09-29 20:09:11 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
p1[2] = 4096;
|
|
|
|
p2[0] = p1[0];
|
|
|
|
p2[1] = p1[1];
|
|
|
|
p2[2] = -4096;
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
[self clipRay: p1 : p2 : frontpoint : &frontface : backpoint : &backface];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
if (frontface == -1 || backface == -1)
|
2010-09-28 19:43:35 +00:00
|
|
|
return;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
q = TEX_ForName (faces[frontface].texture.texture);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-23 13:56:07 +00:00
|
|
|
[[NSColor colorWithCalibratedRed: q->flatcolor.chan[0] / 255.0
|
2010-09-29 20:09:11 +00:00
|
|
|
green: q->flatcolor.chan[1] / 255.0
|
|
|
|
blue: q->flatcolor.chan[2] / 255.0
|
|
|
|
alpha: 1.0] set];
|
2010-09-23 13:56:07 +00:00
|
|
|
NSRectFill (NSMakeRect (-8, backpoint[2],
|
2010-09-29 20:09:11 +00:00
|
|
|
17, frontpoint[2] - backpoint[2] + 1));
|
2010-09-23 13:56:07 +00:00
|
|
|
[[NSColor blackColor] set];
|
|
|
|
NSFrameRect (NSMakeRect (-12, backpoint[2],
|
2010-09-29 20:09:11 +00:00
|
|
|
25, frontpoint[2] - backpoint[2] + 1));
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-28 19:43:35 +00:00
|
|
|
return;
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===========
|
|
|
|
CameraDrawSelf
|
|
|
|
===========
|
|
|
|
*/
|
2010-09-28 19:43:35 +00:00
|
|
|
- (void) CameraDrawSelf
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
int i, j;
|
2010-09-29 20:09:11 +00:00
|
|
|
winding_t *w;
|
2010-09-11 10:03:41 +00:00
|
|
|
id worldent, currentent;
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
if ([self fakeBrush: @selector (CameraDrawSelf)])
|
2010-09-28 19:43:35 +00:00
|
|
|
return;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
worldent = [map_i objectAtIndex: 0];
|
|
|
|
currentent = [map_i currentEntity];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
if (parent != worldent && worldent == currentent)
|
|
|
|
linecolor (entitycolor[0], entitycolor[1], entitycolor[2]);
|
|
|
|
else if (selected)
|
2010-09-11 10:03:41 +00:00
|
|
|
linecolor (1, 0, 0);
|
2010-09-29 20:09:11 +00:00
|
|
|
else if (parent == [map_i currentEntity])
|
2010-09-11 10:03:41 +00:00
|
|
|
linecolor (0, 0, 0);
|
2003-03-18 19:48:24 +00:00
|
|
|
else
|
2010-09-11 10:03:41 +00:00
|
|
|
linecolor (0, 0.5, 0);
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
for (i = 0; i < numfaces; i++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
w = faces[i].w;
|
|
|
|
if (!w)
|
|
|
|
continue;
|
2010-09-11 10:03:41 +00:00
|
|
|
CameraMoveto (w->points[w->numpoints - 1]);
|
|
|
|
for (j = 0; j < w->numpoints; j++)
|
2003-03-18 19:48:24 +00:00
|
|
|
CameraLineto (w->points[j]);
|
|
|
|
}
|
2010-09-28 19:43:35 +00:00
|
|
|
return;
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===========
|
|
|
|
XYRenderSelf
|
|
|
|
===========
|
|
|
|
*/
|
2010-09-28 19:43:35 +00:00
|
|
|
- (void) XYRenderSelf
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
int i;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
if ([self fakeBrush: @selector (XYRenderSelf)])
|
2010-09-28 19:43:35 +00:00
|
|
|
return;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
for (i = 0; i < numfaces; i++)
|
2003-03-18 19:48:24 +00:00
|
|
|
REN_DrawXYFace (&faces[i]);
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-28 19:43:35 +00:00
|
|
|
return;
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===========
|
|
|
|
CameraRenderSelf
|
|
|
|
===========
|
|
|
|
*/
|
2010-09-29 20:09:11 +00:00
|
|
|
- (void) CameraRenderSelf
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
int i;
|
|
|
|
BOOL olddraw;
|
|
|
|
extern qtexture_t badtex;
|
|
|
|
pixel32_t p;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
if ([self fakeBrush: @selector (CameraRenderSelf)])
|
2010-09-28 19:43:35 +00:00
|
|
|
return;
|
2010-09-29 20:09:11 +00:00
|
|
|
|
|
|
|
// hack to draw entity boxes as single flat color
|
2010-09-11 10:03:41 +00:00
|
|
|
if (![parent modifiable]) {
|
2003-03-18 19:48:24 +00:00
|
|
|
olddraw = r_drawflat;
|
|
|
|
r_drawflat = YES;
|
|
|
|
|
|
|
|
p = badtex.flatcolor;
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
badtex.flatcolor.chan[0] = entitycolor[0] * 255;
|
|
|
|
badtex.flatcolor.chan[1] = entitycolor[1] * 255;
|
|
|
|
badtex.flatcolor.chan[2] = entitycolor[2] * 255;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
for (i = 0; i < numfaces; i++)
|
2003-03-18 19:48:24 +00:00
|
|
|
REN_DrawCameraFace (&faces[i]);
|
|
|
|
|
|
|
|
badtex.flatcolor = p;
|
|
|
|
r_drawflat = olddraw;
|
2010-09-11 10:03:41 +00:00
|
|
|
} else {
|
|
|
|
for (i = 0; i < numfaces; i++)
|
2003-03-18 19:48:24 +00:00
|
|
|
REN_DrawCameraFace (&faces[i]);
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-28 19:43:35 +00:00
|
|
|
return;
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
SINGLE BRUSH ACTIONS
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
*/
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
face_t *dragface, *dragface2;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
int numcontrolpoints;
|
|
|
|
float *controlpoints[MAX_FACES * 3];
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (BOOL) checkModifiable
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
// int i;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
if ([parent modifiable])
|
2003-03-18 19:48:24 +00:00
|
|
|
return YES;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
// don't stretch spawned entities, move all points
|
2003-03-18 19:48:24 +00:00
|
|
|
#if 0
|
2010-09-11 10:03:41 +00:00
|
|
|
numcontrolpoints = numfaces * 3;
|
|
|
|
|
|
|
|
for (i = 0; i < numcontrolpoints; i++)
|
|
|
|
controlpoints[i] = faces[i / 3].planepts[i % 3];
|
|
|
|
#endif
|
2010-09-29 20:09:11 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (void) getZdragface: (vec3_t)dragpoint
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
int i, j;
|
|
|
|
float d;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
if (![self checkModifiable])
|
2010-09-28 19:43:35 +00:00
|
|
|
return;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
numcontrolpoints = 0;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
for (i = 0; i < numfaces; i++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
if (!faces[i].w)
|
|
|
|
continue;
|
2010-09-29 20:09:11 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
if (faces[i].plane.normal[2] == 1)
|
|
|
|
d = dragpoint[2] - faces[i].plane.dist;
|
|
|
|
else if (faces[i].plane.normal[2] == -1)
|
|
|
|
d = -faces[i].plane.dist - dragpoint[2];
|
|
|
|
else
|
|
|
|
continue;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
if (d <= 0)
|
|
|
|
continue;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
for (j = 0; j < 3; j++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
controlpoints[numcontrolpoints] = faces[i].planepts[j];
|
|
|
|
numcontrolpoints++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (void) getXYdragface: (vec3_t)dragpoint
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
int i, j;
|
|
|
|
float d;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
numcontrolpoints = 0;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
if (![self checkModifiable])
|
2010-09-28 19:43:35 +00:00
|
|
|
return;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
for (i = 0; i < numfaces; i++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
if (!faces[i].w)
|
|
|
|
continue;
|
2010-09-29 20:09:11 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
if (faces[i].plane.normal[2])
|
|
|
|
continue;
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
d = DotProduct (faces[i].plane.normal, dragpoint) - faces[i].plane.dist;
|
2003-03-18 19:48:24 +00:00
|
|
|
if (d <= 0)
|
|
|
|
continue;
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
for (j = 0; j < 3; j++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
controlpoints[numcontrolpoints] = faces[i].planepts[j];
|
|
|
|
numcontrolpoints++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (void) getXYShearPoints: (vec3_t)dragpoint
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
int i, j, k;
|
|
|
|
int facectl;
|
|
|
|
float d;
|
|
|
|
int numdragplanes;
|
|
|
|
BOOL dragplane[MAX_FACES];
|
2010-09-29 20:09:11 +00:00
|
|
|
winding_t *w;
|
|
|
|
face_t *f;
|
2010-09-11 10:03:41 +00:00
|
|
|
BOOL onplane[MAX_POINTS_ON_WINDING];
|
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
if (![self checkModifiable])
|
2010-09-28 19:43:35 +00:00
|
|
|
return;
|
2003-03-18 19:48:24 +00:00
|
|
|
numcontrolpoints = 0;
|
|
|
|
numdragplanes = 0;
|
2010-09-11 10:03:41 +00:00
|
|
|
for (i = 0; i < numfaces; i++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
dragplane[i] = NO;
|
|
|
|
if (!faces[i].w)
|
|
|
|
continue;
|
2010-09-29 20:09:11 +00:00
|
|
|
// if (faces[i].plane.normal[2])
|
|
|
|
// continue;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
d = DotProduct (faces[i].plane.normal, dragpoint) - faces[i].plane.dist;
|
2003-03-18 19:48:24 +00:00
|
|
|
if (d <= -ON_EPSILON)
|
|
|
|
continue;
|
|
|
|
dragplane[i] = YES;
|
|
|
|
numdragplanes++;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
// find faces that just share an edge with a drag plane
|
2010-09-11 10:03:41 +00:00
|
|
|
for (i = 0; i < numfaces; i++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
f = &faces[i];
|
|
|
|
w = f->w;
|
|
|
|
if (!w)
|
|
|
|
continue;
|
2010-09-29 20:09:11 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
if (dragplane[i] && numdragplanes == 1) {
|
|
|
|
for (j = 0; j < 3; j++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
controlpoints[numcontrolpoints] = faces[i].planepts[j];
|
|
|
|
numcontrolpoints++;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2010-09-29 20:09:11 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
if (!dragplane[i] && numdragplanes > 1)
|
|
|
|
continue;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
facectl = 0;
|
2010-09-11 10:03:41 +00:00
|
|
|
for (j = 0; j < w->numpoints; j++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
onplane[j] = NO;
|
2010-09-11 10:03:41 +00:00
|
|
|
for (k = 0; k < numfaces; k++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
if (!dragplane[k])
|
|
|
|
continue;
|
|
|
|
if (k == i)
|
|
|
|
continue;
|
|
|
|
d = DotProduct (w->points[j], faces[k].plane.normal)
|
2010-09-29 20:09:11 +00:00
|
|
|
- faces[k].plane.dist;
|
2010-09-11 10:03:41 +00:00
|
|
|
if (fabs (d) > ON_EPSILON)
|
2003-03-18 19:48:24 +00:00
|
|
|
continue;
|
|
|
|
onplane[j] = YES;
|
|
|
|
facectl++;
|
2010-09-11 10:03:41 +00:00
|
|
|
break;
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
}
|
2010-09-29 20:09:11 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
if (facectl == 0)
|
|
|
|
continue;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
// find one or two static points to go with the controlpoints
|
|
|
|
// and change the plane points
|
2003-03-18 19:48:24 +00:00
|
|
|
k = 0;
|
2010-09-11 10:03:41 +00:00
|
|
|
for (j = 0; j < w->numpoints; j++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
if (!onplane[j])
|
|
|
|
continue;
|
2010-09-11 10:03:41 +00:00
|
|
|
if (facectl >= 2 && !onplane[(j + 1) % w->numpoints])
|
2003-03-18 19:48:24 +00:00
|
|
|
continue;
|
2010-09-11 10:03:41 +00:00
|
|
|
if (facectl == 3 && !onplane[(j + 2) % w->numpoints])
|
2003-03-18 19:48:24 +00:00
|
|
|
continue;
|
|
|
|
VectorCopy (w->points[j], f->planepts[k]);
|
|
|
|
controlpoints[numcontrolpoints] = f->planepts[k];
|
|
|
|
numcontrolpoints++;
|
|
|
|
k++;
|
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
if (facectl >= 2) {
|
|
|
|
VectorCopy (w->points[(j + 1) % w->numpoints], f->planepts[k]);
|
2003-03-18 19:48:24 +00:00
|
|
|
controlpoints[numcontrolpoints] = f->planepts[k];
|
|
|
|
numcontrolpoints++;
|
|
|
|
k++;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
if (facectl == 3) {
|
|
|
|
VectorCopy (w->points[(j + 2) % w->numpoints], f->planepts[k]);
|
2003-03-18 19:48:24 +00:00
|
|
|
controlpoints[numcontrolpoints] = f->planepts[k];
|
|
|
|
numcontrolpoints++;
|
|
|
|
k++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
for ( ; j < w->numpoints && k != 3; j++) {
|
2010-09-11 10:03:41 +00:00
|
|
|
if (!onplane[j]) {
|
2003-03-18 19:48:24 +00:00
|
|
|
VectorCopy (w->points[j], f->planepts[k]);
|
|
|
|
k++;
|
|
|
|
}
|
2010-09-29 20:09:11 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
for (j = 0; j < w->numpoints && k != 3; j++) {
|
2010-09-11 10:03:41 +00:00
|
|
|
if (!onplane[j]) {
|
2003-03-18 19:48:24 +00:00
|
|
|
VectorCopy (w->points[j], f->planepts[k]);
|
|
|
|
k++;
|
|
|
|
}
|
2010-09-29 20:09:11 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
if (k != 3) {
|
|
|
|
// Sys_Error ("getXYShearPoints: didn't get three points on plane");
|
2003-03-18 19:48:24 +00:00
|
|
|
numcontrolpoints = 0;
|
2010-09-28 19:43:35 +00:00
|
|
|
return;
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
for (j = 0; j < 3; j++) {
|
2010-09-11 10:03:41 +00:00
|
|
|
for (k = 0; k < 3; k++)
|
|
|
|
f->planepts[j][k] = rint (f->planepts[j][k]);
|
2010-09-29 20:09:11 +00:00
|
|
|
}
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
MULTIPLE BRUSH ACTIONS
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
*/
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
vec3_t region_min, region_max;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
===========
|
|
|
|
newRegion
|
|
|
|
|
|
|
|
Set the regioned flag based on if the object is containted in region_min/max
|
|
|
|
===========
|
|
|
|
*/
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) newRegion
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-11 10:03:41 +00:00
|
|
|
int i;
|
2010-09-29 20:09:11 +00:00
|
|
|
const char *name;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-10-11 12:11:33 +00:00
|
|
|
// filter away entities
|
2010-09-29 20:09:11 +00:00
|
|
|
if (parent != [map_i objectAtIndex: 0]) {
|
2010-09-11 10:03:41 +00:00
|
|
|
if (filter_entities) {
|
2003-03-18 19:48:24 +00:00
|
|
|
regioned = YES;
|
|
|
|
return self;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
name = [parent valueForQKey: "classname"];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
if ((filter_light && !strncmp (name, "light", 5))
|
2010-09-29 20:09:11 +00:00
|
|
|
|| (filter_path && !strncmp (name, "path", 4))) {
|
2003-03-18 19:48:24 +00:00
|
|
|
regioned = YES;
|
|
|
|
return self;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
} else if (filter_world) {
|
2003-03-18 19:48:24 +00:00
|
|
|
regioned = YES;
|
|
|
|
return self;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
if (filter_clip_brushes && !strcasecmp (faces[0].texture.texture, "clip")) {
|
2003-03-18 19:48:24 +00:00
|
|
|
regioned = YES;
|
|
|
|
return self;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
if (filter_water_brushes && faces[0].texture.texture[0] == '*') {
|
2003-03-18 19:48:24 +00:00
|
|
|
regioned = YES;
|
|
|
|
return self;
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
for (i = 0; i < 3; i++) {
|
|
|
|
if (region_min[i] >= bmaxs[i] || region_max[i] <= bmins[i]) {
|
2003-03-18 19:48:24 +00:00
|
|
|
if (selected)
|
|
|
|
[self deselect];
|
|
|
|
regioned = YES;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
regioned = NO;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
vec3_t select_min, select_max;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-28 19:43:35 +00:00
|
|
|
- (void) selectPartial
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
int i;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
for (i = 0; i < 3; i++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
if (select_min[i] >= bmaxs[i] || select_max[i] <= bmins[i])
|
2010-09-28 19:43:35 +00:00
|
|
|
return;
|
2010-09-29 20:09:11 +00:00
|
|
|
}
|
2003-03-18 19:48:24 +00:00
|
|
|
selected = YES;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (void) selectComplete
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
int i;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
for (i = 0; i < 3; i++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
if (select_min[i] > bmins[i] || select_max[i] < bmaxs[i])
|
2010-09-28 19:43:35 +00:00
|
|
|
return;
|
2010-09-29 20:09:11 +00:00
|
|
|
}
|
2003-03-18 19:48:24 +00:00
|
|
|
selected = YES;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (void) regionPartial
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
int i;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
for (i = 0; i < 3; i++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
if (select_min[i] >= bmaxs[i] || select_max[i] <= bmins[i])
|
2010-09-29 20:09:11 +00:00
|
|
|
return;
|
|
|
|
}
|
2003-03-18 19:48:24 +00:00
|
|
|
selected = YES;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (void) regionComplete
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
int i;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
for (i = 0; i < 3; i++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
if (select_min[i] > bmins[i] || select_max[i] < bmaxs[i])
|
2010-09-28 19:43:35 +00:00
|
|
|
return;
|
2010-09-29 20:09:11 +00:00
|
|
|
}
|
2003-03-18 19:48:24 +00:00
|
|
|
selected = YES;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
id sb_newowner;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-28 19:43:35 +00:00
|
|
|
- (void) moveToEntity
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
id eclass;
|
|
|
|
float *c;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
[parent removeObject: self];
|
2003-03-18 19:48:24 +00:00
|
|
|
parent = sb_newowner;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-10-11 12:11:33 +00:00
|
|
|
// hack to allow them to be copied to another map
|
2010-09-11 10:03:41 +00:00
|
|
|
if ([parent respondsToSelector: @selector (valueForQKey:)]) {
|
2010-09-29 20:09:11 +00:00
|
|
|
eclass = [entity_classes_i classForName: [parent valueForQKey: "classname"]];
|
|
|
|
c = [eclass drawColor];
|
|
|
|
[self setEntityColor: c];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
[parent addObject: self];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
vec3_t sb_translate;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-28 19:43:35 +00:00
|
|
|
- (void) translate
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
int i, j;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-10-11 12:11:33 +00:00
|
|
|
// move the planes
|
2010-09-29 20:09:11 +00:00
|
|
|
for (i = 0; i < numfaces; i++) {
|
|
|
|
for (j = 0; j < 3; j++)
|
|
|
|
VectorAdd (faces[i].planepts[j], sb_translate, faces[i].planepts[j]);
|
|
|
|
}
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
[self calcWindings];
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
vec3_t sb_mins, sb_maxs;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-28 19:43:35 +00:00
|
|
|
- (void) addToBBox
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
int k;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
if (numfaces < 4)
|
2010-09-28 19:43:35 +00:00
|
|
|
return;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
2010-09-11 10:03:41 +00:00
|
|
|
for (k = 0; k < 3; k++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
if (bmins[k] < sb_mins[k])
|
|
|
|
sb_mins[k] = bmins[k];
|
|
|
|
if (bmaxs[k] > sb_maxs[k])
|
|
|
|
sb_maxs[k] = bmaxs[k];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (void) flushTextures
|
|
|
|
{ // call when texture palette changes
|
|
|
|
int i;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
for (i = 0; i < MAX_FACES; i++)
|
2003-03-18 19:48:24 +00:00
|
|
|
faces[i].qtexture = NULL;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
[self calcWindings];
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (void) select
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
[map_i setCurrentEntity: parent];
|
2003-03-18 19:48:24 +00:00
|
|
|
selected = YES;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (void) deselect
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
selected = NO;
|
|
|
|
|
2010-10-11 12:11:33 +00:00
|
|
|
// the last selected brush determines
|
2003-03-18 19:48:24 +00:00
|
|
|
if (invalid)
|
|
|
|
printf ("WARNING: deselected invalid brush\n");
|
2010-09-29 20:09:11 +00:00
|
|
|
[map_i setCurrentMinZ: bmins[2]];
|
|
|
|
[map_i setCurrentMaxZ: bmaxs[2]];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (void) remove
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-10-11 12:11:33 +00:00
|
|
|
// the last selected brush determines
|
2010-09-11 10:03:41 +00:00
|
|
|
if (!invalid) {
|
2010-09-29 20:09:11 +00:00
|
|
|
[map_i setCurrentMinZ: bmins[2]];
|
|
|
|
[map_i setCurrentMaxZ: bmaxs[2]];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
[parent removeObject: self];
|
2010-09-28 19:43:35 +00:00
|
|
|
[self release];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
vec3_t sel_x, sel_y, sel_z;
|
|
|
|
vec3_t sel_org;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-28 19:43:35 +00:00
|
|
|
- (void) transform
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
int i, j;
|
|
|
|
vec3_t old;
|
|
|
|
float *p;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
for (i = 0; i < numfaces; i++) {
|
2010-09-11 10:03:41 +00:00
|
|
|
for (j = 0; j < 3; j++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
p = faces[i].planepts[j];
|
|
|
|
VectorCopy (p, old);
|
|
|
|
VectorSubtract (old, sel_org, old);
|
|
|
|
p[0] = DotProduct (old, sel_x);
|
|
|
|
p[1] = DotProduct (old, sel_y);
|
|
|
|
p[2] = DotProduct (old, sel_z);
|
|
|
|
VectorAdd (p, sel_org, p);
|
|
|
|
}
|
2010-09-29 20:09:11 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
[self calcWindings];
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (void) flipNormals // used after an inside-out transform
|
|
|
|
// (flip x/y/z)
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
int i;
|
|
|
|
vec3_t temp;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
for (i = 0; i < numfaces; i++) {
|
2003-03-18 19:48:24 +00:00
|
|
|
VectorCopy (faces[i].planepts[0], temp);
|
|
|
|
VectorCopy (faces[i].planepts[2], faces[i].planepts[0]);
|
|
|
|
VectorCopy (temp, faces[i].planepts[2]);
|
|
|
|
}
|
|
|
|
[self calcWindings];
|
|
|
|
}
|
|
|
|
|
2010-09-28 19:43:35 +00:00
|
|
|
- (void) carveByClipper
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
face_t face;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
if (![clipper_i getFace: &face])
|
2010-09-28 19:43:35 +00:00
|
|
|
return;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
[self addFace: &face];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-09-28 19:43:35 +00:00
|
|
|
- (void) takeCurrentTexture
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
texturedef_t td;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
[texturepalette_i getTextureDef: &td];
|
|
|
|
[self setTexturedef: &td];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
float sb_floor_dir, sb_floor_dist;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-28 19:43:35 +00:00
|
|
|
- (void) feetToFloor
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
float oldz;
|
|
|
|
vec3_t p1, p2;
|
|
|
|
int frontface, backface;
|
|
|
|
vec3_t frontpoint, backpoint;
|
|
|
|
float dist;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
[cameraview_i getOrigin: p1];
|
2003-03-18 19:48:24 +00:00
|
|
|
VectorCopy (p1, p2);
|
|
|
|
oldz = p1[2] - 48;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
p1[2] = 4096;
|
|
|
|
p2[2] = -4096;
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
[self clipRay: p1 : p2 : frontpoint : &frontface : backpoint : &backface];
|
2003-03-18 19:48:24 +00:00
|
|
|
if (frontface == -1)
|
2010-09-28 19:43:35 +00:00
|
|
|
return;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
dist = frontpoint[2] - oldz;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
|
|
|
if (sb_floor_dir == 1) {
|
2003-03-18 19:48:24 +00:00
|
|
|
if (dist > 0 && dist < sb_floor_dist)
|
2010-09-11 10:03:41 +00:00
|
|
|
sb_floor_dist = dist;
|
2010-09-29 20:09:11 +00:00
|
|
|
else if (dist < 0 && dist > sb_floor_dist)
|
2010-09-11 10:03:41 +00:00
|
|
|
sb_floor_dist = dist;
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============================================================================
|
|
|
|
|
|
|
|
BRUSH SUBTRACTION
|
|
|
|
|
|
|
|
===============================================================================
|
|
|
|
*/
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
vec3_t carvemin, carvemax;
|
|
|
|
int numcarvefaces;
|
|
|
|
face_t *carvefaces;
|
|
|
|
id carve_in, carve_out;
|
2003-03-18 19:48:24 +00:00
|
|
|
|
|
|
|
// returns the new brush formed after the addition of the given plane
|
|
|
|
// nil is returned if it faced all of the original setbrush
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) addFace: (face_t *)f
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
if (numfaces == MAX_FACES)
|
2010-09-09 11:46:38 +00:00
|
|
|
Sys_Error ("addFace: numfaces == MAX_FACES");
|
2003-03-18 19:48:24 +00:00
|
|
|
faces[numfaces] = *f;
|
|
|
|
faces[numfaces].texture = faces[0].texture;
|
|
|
|
faces[numfaces].qtexture = NULL;
|
|
|
|
faces[numfaces].w = NULL;
|
|
|
|
numfaces++;
|
|
|
|
[self calcWindings];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-10-11 12:11:33 +00:00
|
|
|
// remove any degenerate faces
|
2010-09-29 20:09:11 +00:00
|
|
|
return [self removeIfInvalid];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (void) clipByFace: (face_t *)fa
|
|
|
|
front: (id *)f
|
|
|
|
back: (id *)b
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
id front, back;
|
|
|
|
face_t fb;
|
|
|
|
vec3_t temp;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
fb = *fa;
|
|
|
|
VectorCopy (fb.planepts[0], temp);
|
|
|
|
VectorCopy (fb.planepts[2], fb.planepts[0]);
|
|
|
|
VectorCopy (temp, fb.planepts[2]);
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
front = [self copy];
|
|
|
|
back = [self copy];
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
*b = [back addFace: fa];
|
|
|
|
*f = [front addFace: &fb];
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (id) carve
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
2010-09-29 20:09:11 +00:00
|
|
|
int i;
|
|
|
|
id front, back;
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2003-03-18 19:48:24 +00:00
|
|
|
#if 0
|
2010-09-11 10:03:41 +00:00
|
|
|
if ((i = NSMallocCheck ()))
|
2010-09-09 11:46:38 +00:00
|
|
|
Sys_Error ("MallocCheck failure");
|
2003-03-18 19:48:24 +00:00
|
|
|
#endif
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
// check bboxes
|
|
|
|
for (i = 0; i < 3; i++) {
|
2010-09-11 10:03:41 +00:00
|
|
|
if (bmins[i] >= carvemax[i] || bmaxs[i] <= carvemin[i]) {
|
2010-09-29 20:09:11 +00:00
|
|
|
[carve_out addObject: self];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
2010-09-29 20:09:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// carve by the planes
|
2003-03-18 19:48:24 +00:00
|
|
|
back = self;
|
2010-09-11 10:03:41 +00:00
|
|
|
for (i = 0; i < numcarvefaces; i++) {
|
2010-09-29 20:09:11 +00:00
|
|
|
[back clipByFace: &carvefaces[i] front: &front back: &back];
|
2003-03-18 19:48:24 +00:00
|
|
|
if (front)
|
2010-09-29 20:09:11 +00:00
|
|
|
[carve_out addObject: front];
|
2003-03-18 19:48:24 +00:00
|
|
|
if (!back)
|
2010-09-29 20:09:11 +00:00
|
|
|
return nil; // nothing completely inside
|
2003-03-18 19:48:24 +00:00
|
|
|
}
|
2010-09-11 10:03:41 +00:00
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
[carve_in addObject: back];
|
2003-03-18 19:48:24 +00:00
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
setCarveVars
|
|
|
|
==================
|
|
|
|
*/
|
2010-09-28 19:43:35 +00:00
|
|
|
- (void) setCarveVars
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
VectorCopy (bmins, carvemin);
|
|
|
|
VectorCopy (bmaxs, carvemax);
|
|
|
|
numcarvefaces = numfaces;
|
|
|
|
carvefaces = faces;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (int) getNumBrushFaces
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
return numfaces;
|
|
|
|
}
|
|
|
|
|
2010-09-29 20:09:11 +00:00
|
|
|
- (face_t *) getBrushFace: (int)which
|
2003-03-18 19:48:24 +00:00
|
|
|
{
|
|
|
|
return &faces[which];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|