Rename mplane_t to plane_t and clean up the mess.

I got rather tired of there being multiple definitions of mostly compatible
plane types (and I need a common type anyway). dplane_t still exists for
now because I want to be careful when messing with the actual bsp format.
This commit is contained in:
Bill Currie 2011-11-14 11:18:22 +09:00
parent 2f23cfa4d0
commit 91e65b6c80
28 changed files with 72 additions and 89 deletions

View File

@ -249,7 +249,7 @@ void AngleVectors (const vec3_t angles, vec3_t forward, vec3_t right,
void AngleQuat (const vec3_t angles, quat_t q);
void VectorVectors (const vec3_t forward, vec3_t right, vec3_t up);
int BoxOnPlaneSide (const vec3_t emins, const vec3_t emaxs,
struct mplane_s *plane);
struct plane_s *plane);
float anglemod (float a);
void RotatePointAroundVector (vec3_t dst, const vec3_t axis,
@ -288,7 +288,7 @@ void QuatToMatrix (const quat_t q, vec_t *m, int homogenous, int vertical);
VectorNegate ((sp)->normal, (dp)->normal); \
} while (0)
extern mplane_t * const frustum;
extern plane_t * const frustum;
extern inline qboolean R_CullBox (const vec3_t mins, const vec3_t maxs);
extern inline qboolean R_CullSphere (const vec3_t origin, const float radius);
extern inline float VectorNormalize (vec3_t v); // returns vector length

View File

@ -122,7 +122,7 @@ typedef struct glpoly_s {
typedef struct msurface_s {
int visframe; // should be drawn when node is crossed
mplane_t *plane;
plane_t *plane;
int flags;
int firstedge; // look up in model->surfedges[], negative numbers
@ -162,7 +162,7 @@ typedef struct mnode_s {
struct mnode_s *parent;
// node specific
mplane_t *plane;
plane_t *plane;
struct mnode_s *children[2];
unsigned short firstsurface;
@ -197,7 +197,7 @@ typedef struct mclipnode_s {
typedef struct hull_s {
mclipnode_t *clipnodes;
mplane_t *planes;
plane_t *planes;
int firstclipnode;
int lastclipnode;
vec3_t clip_mins;
@ -357,7 +357,7 @@ typedef struct model_s {
dmodel_t *submodels;
int numplanes;
mplane_t *planes;
plane_t *planes;
int numleafs; // number of visible leafs, not counting 0
mleaf_t *leafs;

View File

@ -89,12 +89,12 @@ typedef int fixed16_t;
// plane_t structure
// !!! if this is changed, it must be changed in asm_i386.h too !!!
typedef struct mplane_s {
typedef struct plane_s {
vec3_t normal;
float dist;
byte type; // for texture axis selection and fast side tests
byte signbits; // signx + signy<<1 + signz<<1
byte pad[2];
} mplane_t;
} plane_t;
#endif // __qtypes_h

View File

@ -128,7 +128,7 @@ void R_RenderWorld (void);
//=============================================================================
extern mplane_t screenedge[4];
extern plane_t screenedge[4];
extern vec3_t r_origin;
@ -158,7 +158,7 @@ void R_DrawSprite (void);
void R_RenderFace (msurface_t *fa, int clipflags);
void R_RenderPoly (msurface_t *fa, int clipflags);
void R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf);
void R_TransformPlane (mplane_t *p, float *normal, float *dist);
void R_TransformPlane (plane_t *p, float *normal, float *dist);
void R_TransformFrustum (void);
void R_SetSkyFrame (void);
void R_DrawSurfaceBlock (void);

View File

@ -33,12 +33,6 @@
#include "QF/mathlib.h"
#include "QF/model.h"
typedef struct
{
vec3_t normal;
vec_t dist;
} plane_t;
typedef enum {
tr_point,
tr_box,
@ -77,7 +71,7 @@ extern areanode_t sv_areanodes[AREA_NODES];
void SV_FreeAllEdictLeafs (void);
void SV_InitHull (hull_t *hull, mclipnode_t *clipnodes, mplane_t *planes);
void SV_InitHull (hull_t *hull, mclipnode_t *clipnodes, plane_t *planes);
void SV_ClearWorld (void);
// called after the world model has been loaded, before linking any entities

View File

@ -63,7 +63,7 @@ Mod_PointInLeaf (const vec3_t p, model_t *model)
{
float d;
mnode_t *node;
mplane_t *plane;
plane_t *plane;
if (!model || !model->nodes)
Sys_Error ("Mod_PointInLeaf: bad model");
@ -837,7 +837,7 @@ Mod_LoadPlanes (bsp_t *bsp)
{
dplane_t *in;
int bits, count, i, j;
mplane_t *out;
plane_t *out;
in = bsp->planes;
count = bsp->numplanes;

View File

@ -47,7 +47,7 @@ MOD_Alloc_Hull (int nodes, int planes)
int size, i;
size = sizeof (hull_t);
size += sizeof (mclipnode_t) * nodes + sizeof (mplane_t) * planes;
size += sizeof (mclipnode_t) * nodes + sizeof (plane_t) * planes;
size *= MAX_MAP_HULLS;
size += sizeof (clip_hull_t);
@ -58,11 +58,11 @@ MOD_Alloc_Hull (int nodes, int planes)
for (i = 1; i < MAX_MAP_HULLS; i++)
ch->hulls[i] = &ch->hulls[i - 1][1];
ch->hulls[0]->clipnodes = (mclipnode_t *) &ch->hulls[i - 1][1];
ch->hulls[0]->planes = (mplane_t *) &ch->hulls[0]->clipnodes[nodes];
ch->hulls[0]->planes = (plane_t *) &ch->hulls[0]->clipnodes[nodes];
for (i = 1; i < MAX_MAP_HULLS; i++) {
ch->hulls[i]->clipnodes =
(mclipnode_t *) &ch->hulls[i - 1]->planes[planes];
ch->hulls[i]->planes = (mplane_t *) &ch->hulls[i]->clipnodes[nodes];
ch->hulls[i]->planes = (plane_t *) &ch->hulls[i]->clipnodes[nodes];
}
return ch;
}

View File

@ -60,11 +60,11 @@ typedef struct {
vec_t start_frac;
int side;
int num;
mplane_t *plane;
plane_t *plane;
} tracestack_t;
static inline float
calc_offset (trace_t *trace, mplane_t *plane)
calc_offset (trace_t *trace, plane_t *plane)
{
vec_t d = 0;
vec3_t Rn;
@ -92,7 +92,7 @@ calc_offset (trace_t *trace, mplane_t *plane)
static inline void
calc_impact (trace_t *trace, const vec3_t start, const vec3_t end,
mplane_t *plane)
plane_t *plane)
{
vec_t t1, t2, frac, offset;
vec3_t dist;
@ -135,7 +135,7 @@ MOD_TraceLine (hull_t *hull, int num,
tracestack_t *tstack;
tracestack_t tracestack[256];
mclipnode_t *node;
mplane_t *plane, *split_plane;
plane_t *plane, *split_plane;
VectorCopy (start_point, start);
VectorCopy (end_point, end);

View File

@ -48,8 +48,8 @@ static __attribute__ ((used)) const char rcsid[] =
#include "QF/sys.h"
VISIBLE int nanmask = 255 << 23;
static mplane_t _frustum[4];
VISIBLE mplane_t *const frustum = _frustum;
static plane_t _frustum[4];
VISIBLE plane_t *const frustum = _frustum;
static vec3_t _vec3_origin = { 0, 0, 0 };
VISIBLE const vec_t * const vec3_origin = _vec3_origin;
static vec3_t _quat_origin = { 0, 0, 0 };
@ -269,7 +269,7 @@ BOPS_Error (void)
Returns 1, 2, or 1 + 2
*/
VISIBLE int
BoxOnPlaneSide (const vec3_t emins, const vec3_t emaxs, mplane_t *p)
BoxOnPlaneSide (const vec3_t emins, const vec3_t emaxs, plane_t *p)
{
float dist1, dist2;
int sides;

View File

@ -83,7 +83,7 @@ qboolean envmap; // true during envmap command capture
int mirrortexturenum; // quake texturenum, not gltexturenum
qboolean mirror;
mplane_t *mirror_plane;
plane_t *mirror_plane;
// view origin
VISIBLE vec3_t vup;
@ -360,7 +360,7 @@ R_DrawViewModel (void)
}
static inline int
SignbitsForPlane (mplane_t *out)
SignbitsForPlane (plane_t *out)
{
int bits, j;

View File

@ -370,7 +370,7 @@ R_DrawBrushModel (entity_t *e)
int i;
unsigned int k;
model_t *model;
mplane_t *pplane;
plane_t *pplane;
msurface_t *psurf;
qboolean rotated;
vec3_t mins, maxs;
@ -571,7 +571,7 @@ static inline int
get_side (mnode_t *node)
{
// find which side of the node we are on
mplane_t *plane = node->plane;
plane_t *plane = node->plane;
if (plane->type < 3)
return (modelorg[plane->type] - plane->dist) < 0;

View File

@ -125,7 +125,7 @@ static void
R_SplitEntityOnNode (mnode_t *node)
{
efrag_t *ef;
mplane_t *splitplane;
plane_t *splitplane;
mleaf_t *leaf;
int sides;

View File

@ -152,7 +152,7 @@ R_RecursiveMarkLights (const vec3_t lightorigin, dlight_t *light, int bit,
{
int i;
float ndist, maxdist;
mplane_t *splitplane;
plane_t *splitplane;
msurface_t *surf;
//XXX mvertex_t *vertices;
@ -276,7 +276,7 @@ R_PushDlights (const vec3_t entorigin)
/* LIGHT SAMPLING */
mplane_t *lightplane;
plane_t *lightplane;
vec3_t lightspot;
static int
@ -345,12 +345,12 @@ calc_lighting_3 (msurface_t *surf, int ds, int dt)
static int
RecursiveLightPoint (mnode_t *node, const vec3_t start, const vec3_t end)
{
int i, r, s, t, ds, dt, side;
float front, back, frac;
mplane_t *plane;
msurface_t *surf;
mtexinfo_t *tex;
vec3_t mid;
int i, r, s, t, ds, dt, side;
float front, back, frac;
plane_t *plane;
msurface_t *surf;
mtexinfo_t *tex;
vec3_t mid;
loop:
if (node->contents < 0)
return -1; // didn't hit anything

View File

@ -155,7 +155,7 @@ R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *psurf)
bedge_t *psideedges[2], *pnextedge, *ptedge;
int i, side, lastside;
float dist, frac, lastdist;
mplane_t *splitplane, tplane;
plane_t *splitplane, tplane;
mvertex_t *pvert, *plastvert, *ptvert;
mnode_t *pn;
@ -301,7 +301,7 @@ R_DrawSolidClippedSubmodelPolygons (model_t *pmodel)
vec_t dot;
msurface_t *psurf;
int numsurfaces;
mplane_t *pplane;
plane_t *pplane;
mvertex_t bverts[MAX_BMODEL_VERTS];
bedge_t bedges[MAX_BMODEL_EDGES], *pbedge;
medge_t *pedge, *pedges;
@ -370,7 +370,7 @@ R_DrawSubmodelPolygons (model_t *pmodel, int clipflags)
vec_t dot;
msurface_t *psurf;
int numsurfaces;
mplane_t *pplane;
plane_t *pplane;
// FIXME: use bounding-box-based frustum clipping info?
@ -409,7 +409,7 @@ static inline int
get_side (mnode_t *node)
{
// find which side of the node we are on
mplane_t *plane = node->plane;
plane_t *plane = node->plane;
if (plane->type < 3)
return (modelorg[plane->type] - plane->dist) < 0;
@ -560,7 +560,7 @@ R_RecursiveWorldNode (mnode_t *node, int clipflags)
{
int i, c, side, *pindex;
vec3_t acceptpt, rejectpt;
mplane_t *plane;
plane_t *plane;
msurface_t *surf;
mleaf_t *pleaf;
double d, dot;

View File

@ -353,7 +353,7 @@ R_RenderFace (msurface_t *fa, int clipflags)
{
int i, lindex;
unsigned int mask;
mplane_t *pplane;
plane_t *pplane;
float distinv;
vec3_t p_normal;
medge_t *pedges, tedge;
@ -519,7 +519,7 @@ R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf)
{
int i;
unsigned int mask;
mplane_t *pplane;
plane_t *pplane;
float distinv;
vec3_t p_normal;
medge_t tedge;
@ -623,7 +623,7 @@ R_RenderPoly (msurface_t *fa, int clipflags)
vec3_t local, transformed;
clipplane_t *pclip;
medge_t *pedges;
mplane_t *pplane;
plane_t *pplane;
mvertex_t verts[2][100]; // FIXME: do real number
polyvert_t pverts[100]; // FIXME: do real number, safely
int vertpage, newverts, newpage, lastvert;
@ -787,7 +787,7 @@ R_ZDrawSubmodelPolys (model_t *pmodel)
int i, numsurfaces;
msurface_t *psurf;
float dot;
mplane_t *pplane;
plane_t *pplane;
psurf = &pmodel->surfaces[pmodel->firstmodelsurface];
numsurfaces = pmodel->nummodelsurfaces;

View File

@ -116,7 +116,7 @@ float screenAspect;
float verticalFieldOfView;
float xOrigin, yOrigin;
mplane_t screenedge[4];
plane_t screenedge[4];
// refresh flags
int r_framecount = 1; // so frame counts initialized to 0 don't match

View File

@ -175,7 +175,7 @@ TransformVector (const vec3_t in, vec3_t out)
#endif
void
R_TransformPlane (mplane_t *p, float *normal, float *dist)
R_TransformPlane (plane_t *p, float *normal, float *dist)
{
float d;

View File

@ -155,7 +155,7 @@ R_RecursiveClipBPoly (bedge_t *pedges, mnode_t *pnode, msurface_t *psurf)
bedge_t *psideedges[2], *pnextedge, *ptedge;
int i, side, lastside;
float dist, frac, lastdist;
mplane_t *splitplane, tplane;
plane_t *splitplane, tplane;
mvertex_t *pvert, *plastvert, *ptvert;
mnode_t *pn;
@ -301,7 +301,7 @@ R_DrawSolidClippedSubmodelPolygons (model_t *pmodel)
vec_t dot;
msurface_t *psurf;
int numsurfaces;
mplane_t *pplane;
plane_t *pplane;
mvertex_t bverts[MAX_BMODEL_VERTS];
bedge_t bedges[MAX_BMODEL_EDGES], *pbedge;
medge_t *pedge, *pedges;
@ -370,7 +370,7 @@ R_DrawSubmodelPolygons (model_t *pmodel, int clipflags)
vec_t dot;
msurface_t *psurf;
int numsurfaces;
mplane_t *pplane;
plane_t *pplane;
// FIXME: use bounding-box-based frustum clipping info?
@ -409,7 +409,7 @@ static inline int
get_side (mnode_t *node)
{
// find which side of the node we are on
mplane_t *plane = node->plane;
plane_t *plane = node->plane;
if (plane->type < 3)
return (modelorg[plane->type] - plane->dist) < 0;
@ -560,7 +560,7 @@ R_RecursiveWorldNode (mnode_t *node, int clipflags)
{
int i, c, side, *pindex;
vec3_t acceptpt, rejectpt;
mplane_t *plane;
plane_t *plane;
msurface_t *surf;
mleaf_t *pleaf;
double d, dot;

View File

@ -346,7 +346,7 @@ R_RenderFace (msurface_t *fa, int clipflags)
{
int i, lindex;
unsigned int mask;
mplane_t *pplane;
plane_t *pplane;
float distinv;
vec3_t p_normal;
medge_t *pedges, tedge;
@ -513,7 +513,7 @@ R_RenderBmodelFace (bedge_t *pedges, msurface_t *psurf)
{
int i;
unsigned int mask;
mplane_t *pplane;
plane_t *pplane;
float distinv;
vec3_t p_normal;
medge_t tedge;
@ -618,7 +618,7 @@ R_RenderPoly (msurface_t *fa, int clipflags)
vec3_t local, transformed;
clipplane_t *pclip;
medge_t *pedges;
mplane_t *pplane;
plane_t *pplane;
mvertex_t verts[2][100]; // FIXME: do real number
polyvert_t pverts[100]; // FIXME: do real number, safely
int vertpage, newverts, newpage, lastvert;
@ -782,7 +782,7 @@ R_ZDrawSubmodelPolys (model_t *pmodel)
int i, numsurfaces;
msurface_t *psurf;
float dot;
mplane_t *pplane;
plane_t *pplane;
psurf = &pmodel->surfaces[pmodel->firstmodelsurface];
numsurfaces = pmodel->nummodelsurfaces;

View File

@ -110,7 +110,7 @@ float screenAspect;
float verticalFieldOfView;
float xOrigin, yOrigin;
mplane_t screenedge[4];
plane_t screenedge[4];
// refresh flags
VISIBLE int r_framecount = 1; // so frame counts initialized to 0 don't match

View File

@ -169,7 +169,7 @@ TransformVector (const vec3_t in, vec3_t out)
}
void
R_TransformPlane (mplane_t *p, float *normal, float *dist)
R_TransformPlane (plane_t *p, float *normal, float *dist)
{
float d;

View File

@ -390,7 +390,7 @@ SV_AddToFatPVS (vec3_t org, mnode_t *node)
int i;
float d;
byte *pvs;
mplane_t *plane;
plane_t *plane;
while (1) {
// if this is a leaf, accumulate the pvs bits

View File

@ -136,7 +136,7 @@ typedef struct {
static hull_t box_hull;
static mclipnode_t box_clipnodes[6];
static mplane_t box_planes[6];
static plane_t box_planes[6];
/*
@ -146,7 +146,7 @@ static mplane_t box_planes[6];
can just be stored out and get a proper hull_t structure.
*/
void
SV_InitHull (hull_t *hull, mclipnode_t *clipnodes, mplane_t *planes)
SV_InitHull (hull_t *hull, mclipnode_t *clipnodes, plane_t *planes)
{
int side, i;
@ -412,7 +412,7 @@ SV_FindTouchedLeafs (edict_t *ent, mnode_t *node)
{
int sides;
mleaf_t *leaf;
mplane_t *splitplane;
plane_t *splitplane;
edict_leaf_t *edict_leaf;
if (node->contents == CONTENTS_SOLID)
@ -531,7 +531,7 @@ SV_HullPointContents (hull_t *hull, int num, const vec3_t p)
{
float d;
mclipnode_t *node;
mplane_t *plane;
plane_t *plane;
while (num >= 0) {
//if (num < hull->firstclipnode || num > hull->lastclipnode)

View File

@ -49,7 +49,7 @@ static __attribute__ ((used)) const char rcsid[] =
static hull_t box_hull;
static mclipnode_t box_clipnodes[6];
static mplane_t box_planes[6];
static plane_t box_planes[6];
/*
@ -107,9 +107,9 @@ PM_HullForBox (const vec3_t mins, const vec3_t maxs)
inline int
PM_HullPointContents (hull_t *hull, int num, const vec3_t p)
{
float d;
float d;
mclipnode_t *node;
mplane_t *plane;
plane_t *plane;
while (num >= 0) {
node = hull->clipnodes + num;
@ -135,7 +135,7 @@ PM_PointContents (const vec3_t p)
int num;
mclipnode_t *node;
hull_t *hull;
mplane_t *plane;
plane_t *plane;
hull = &pmove.physents[0].model->hulls[0];

View File

@ -66,7 +66,7 @@ SV_AddToFatPVS (vec3_t org, mnode_t *node)
byte *pvs;
int i;
float d;
mplane_t *plane;
plane_t *plane;
while (1) {
// if this is a leaf, accumulate the pvs bits

View File

@ -136,7 +136,7 @@ typedef struct {
static hull_t box_hull;
static mclipnode_t box_clipnodes[6];
static mplane_t box_planes[6];
static plane_t box_planes[6];
/*
@ -146,7 +146,7 @@ static mplane_t box_planes[6];
can just be stored out and get a proper hull_t structure.
*/
void
SV_InitHull (hull_t *hull, mclipnode_t *clipnodes, mplane_t *planes)
SV_InitHull (hull_t *hull, mclipnode_t *clipnodes, plane_t *planes)
{
int side, i;
@ -412,7 +412,7 @@ SV_FindTouchedLeafs (edict_t *ent, mnode_t *node)
{
int sides;
mleaf_t *leaf;
mplane_t *splitplane;
plane_t *splitplane;
edict_leaf_t *edict_leaf;
if (node->contents == CONTENTS_SOLID)
@ -531,7 +531,7 @@ SV_HullPointContents (hull_t *hull, int num, const vec3_t p)
{
float d;
mclipnode_t *node;
mplane_t *plane;
plane_t *plane;
while (num >= 0) {
//if (num < hull->firstclipnode || num > hull->lastclipnode)

View File

@ -34,12 +34,6 @@
*/
//@{
typedef struct plane_s {
vec3_t normal;
vec_t dist;
int type;
} plane_t;
#define MAX_THREADS 4
#define ON_EPSILON 0.05

View File

@ -51,11 +51,6 @@ extern pthread_mutex_t *my_mutex;
#define MAX_POINTS_ON_WINDING 64
#define MAX_PORTALS_ON_CLUSTER 128
typedef struct {
vec3_t normal;
float dist;
} plane_t;
typedef struct {
qboolean original; // don't free, it's part of the portal
int numpoints;