More documentation and move some functions.

This commit is contained in:
Bill Currie 2010-08-29 12:43:07 +09:00
parent 2e6eb419ca
commit a5c96cb825
12 changed files with 175 additions and 109 deletions

View file

@ -47,6 +47,12 @@ typedef struct brushset_s {
extern int numbrushplanes;
extern plane_t planes[MAX_MAP_PLANES];
/** Allocate a new brush.
\return Pointer to the new brush.
*/
brush_t *AllocBrush (void);
brushset_t *Brush_LoadEntity (entity_t *ent, int hullnum);
/** Determine the primary axis of the normal.

View file

@ -80,25 +80,25 @@ typedef struct surface_s {
#define PLANENUM_LEAF -1
typedef struct node_s {
vec3_t mins,maxs; // bounding volume, not just points inside
vec3_t mins,maxs; ///< bounding volume, not just points inside
// information for decision nodes
int planenum; // -1 = leaf node
int outputplanenum; // valid only after WriteNodePlanes
int firstface; // decision node only
int numfaces; // decision node only
struct node_s *children[2]; // valid only for decision nodes
face_t *faces; // decision nodes only, list for both sides
int planenum; ///< -1 = leaf node
int outputplanenum; ///< valid only after WriteNodePlanes
int firstface; ///< decision node only
int numfaces; ///< decision node only
struct node_s *children[2]; ///< valid only for decision nodes
face_t *faces; ///< decision nodes only, list for both sides
// information for leafs
int contents; // leaf nodes (0 for decision nodes)
face_t **markfaces; // leaf nodes only, point to node faces
int contents; ///< leaf nodes (0 for decision nodes)
face_t **markfaces; ///< leaf nodes only, point to node faces
struct portal_s *portals;
int visleafnum; // -1 = solid
int valid; // for flood filling
int occupied; // light number in leaf for outside filling
int o_dist; // distance to nearest entity
int detail; // 1 if created by detail split
int visleafnum; ///< -1 = solid
int valid; ///< for flood filling
int occupied; ///< light number in leaf for outside filling
int o_dist; ///< distance to nearest entity
int detail; ///< 1 if created by detail split
} node_t;
@ -106,7 +106,11 @@ typedef struct node_s {
extern struct brushset_s *brushset;
void qprintf (const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); // prints only if verbose
/** Formatted printing with verbosity control.
Behaves the same as printf except it prints only when verbose is true.
*/
void qprintf (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
extern int valid;
@ -114,17 +118,11 @@ extern qboolean worldmodel;
// misc functions
face_t *AllocFace (void);
void FreeFace (face_t *f);
struct portal_s *AllocPortal (void);
void FreePortal (struct portal_s *p);
surface_t *AllocSurface (void);
void FreeSurface (surface_t *s);
/** Allocate a new node.
\return Pointer to the new node.
*/
node_t *AllocNode (void);
struct brush_s *AllocBrush (void);
//=============================================================================

View file

@ -34,6 +34,25 @@ typedef struct portal_s {
extern struct node_s outside_node; // portals outside the world face this
/** Allocate a new portal.
Increases \c c_activeportals by one.
\return Pointer to the new portal.
*/
portal_t *AllocPortal (void);
/** Free a portal.
Only the first portal will be freed. If the portal is linked to other
portals, those portals will have to be freed seperately.
Reduces \c c_activeportals by one.
\param p The portal to free.
*/
void FreePortal (portal_t *p);
void PortalizeWorld (struct node_s *headnode);
void PortalizeWorldDetail (struct node_s *headnode); // stop at detail nodes
void WritePortalfile (struct node_s *headnode);

View file

@ -36,6 +36,44 @@ extern struct visfacet_s *edgefaces[MAX_MAP_EDGES][2];
extern int firstmodeledge;
extern int firstmodelface;
/** Allocate a new face.
Increases \c c_activefaces by one.
\return Pointer to the new face.
*/
face_t *AllocFace (void);
/** Free a face.
Only the first face will be freed. If the face is linked to another face,
that face will have to be freed seperately.
Reduces \c c_activefaces by one.
\param f The face to free.
*/
void FreeFace (face_t *f);
/** Allocate a new surface.
Increases \c c_activesurfaces by one.
\return Pointer to the new surface.
*/
surface_t *AllocSurface (void);
/** Free a surface.
Only the first surface will be freed. If the surface is linked to another
surface, that surface will have to be freed seperately.
Reduces \c c_activefaces by one.
\param s The face to free.
*/
void FreeSurface (surface_t *s);
void SubdivideFace (struct visfacet_s *f, struct visfacet_s **prevptr);
struct surface_s *GatherNodeFaces (struct node_s *headnode);

View file

@ -35,6 +35,7 @@
#include "bsp5.h"
#include "draw.h"
#include "options.h"
#include "surfaces.h"
#include "winding.h"
int numbrushplanes;
@ -45,6 +46,17 @@ mface_t faces[MAX_FACES]; // beveled clipping hull can generate many extra
static entity_t *CurrentEntity;
brush_t *
AllocBrush (void)
{
brush_t *b;
b = malloc (sizeof (brush_t));
memset (b, 0, sizeof (brush_t));
return b;
}
/*
CheckFace

View file

@ -25,7 +25,7 @@ static __attribute__ ((used)) const char rcsid[] =
"$Id$";
#ifdef HAVE_STRING_H
# include "string.h"
# include <string.h>
#endif
#include "QF/sys.h"
@ -36,6 +36,7 @@ static __attribute__ ((used)) const char rcsid[] =
#include "draw.h"
#include "merge.h"
#include "solidbsp.h"
#include "surfaces.h"
#include "winding.h"
/*

View file

@ -31,6 +31,7 @@ static __attribute__ ((used)) const char rcsid[] =
#include "csg4.h"
#include "draw.h"
#include "merge.h"
#include "surfaces.h"
#include "winding.h"
#define CONTINUOUS_EPSILON 0.001

View file

@ -25,8 +25,9 @@ static __attribute__ ((used)) const char rcsid[] =
"$Id$";
#ifdef HAVE_STRING_H
# include "string.h"
# include <string.h>
#endif
#include <stdlib.h>
#include "QF/sys.h"
@ -37,8 +38,32 @@ static __attribute__ ((used)) const char rcsid[] =
#include "portals.h"
#include "winding.h"
int c_activeportals, c_peakportals;
node_t outside_node; // portals outside the world face this
portal_t *
AllocPortal (void)
{
portal_t *p;
c_activeportals++;
if (c_activeportals > c_peakportals)
c_peakportals = c_activeportals;
p = malloc (sizeof (portal_t));
memset (p, 0, sizeof (portal_t));
return p;
}
void
FreePortal (portal_t *p)
{
c_activeportals--;
free (p);
}
static void
AddPortalToNodes (portal_t *p, node_t *front, node_t *back)

View file

@ -65,9 +65,6 @@ bsp_t *bsp;
brushset_t *brushset;
int c_activefaces, c_peakfaces;
int c_activesurfaces, c_peaksurfaces;
int c_activeportals, c_peakportals;
int valid;
char *argv0; // changed after fork();
@ -77,73 +74,6 @@ qboolean worldmodel;
int hullnum;
face_t *
AllocFace (void)
{
face_t *f;
c_activefaces++;
if (c_activefaces > c_peakfaces)
c_peakfaces = c_activefaces;
f = malloc (sizeof (face_t));
memset (f, 0, sizeof (face_t));
f->planenum = -1;
return f;
}
void
FreeFace (face_t *f)
{
c_activefaces--;
free (f);
}
surface_t *
AllocSurface (void)
{
surface_t *s;
s = malloc (sizeof (surface_t));
memset (s, 0, sizeof (surface_t));
c_activesurfaces++;
if (c_activesurfaces > c_peaksurfaces)
c_peaksurfaces = c_activesurfaces;
return s;
}
void
FreeSurface (surface_t *s)
{
c_activesurfaces--;
free (s);
}
portal_t *
AllocPortal (void)
{
portal_t *p;
c_activeportals++;
if (c_activeportals > c_peakportals)
c_peakportals = c_activeportals;
p = malloc (sizeof (portal_t));
memset (p, 0, sizeof (portal_t));
return p;
}
void
FreePortal (portal_t *p)
{
c_activeportals--;
free (p);
}
node_t *
AllocNode (void)
{
@ -155,17 +85,6 @@ AllocNode (void)
return n;
}
brush_t *
AllocBrush (void)
{
brush_t *b;
b = malloc (sizeof (brush_t));
memset (b, 0, sizeof (brush_t));
return b;
}
static void
ProcessEntity (int entnum)
{

View file

@ -25,7 +25,7 @@ static __attribute__ ((used)) const char rcsid[] =
"$Id$";
#ifdef HAVE_STRING_H
# include "string.h"
# include <string.h>
#endif
#include "QF/sys.h"

View file

@ -46,8 +46,55 @@ static __attribute__ ((used)) const char rcsid[] =
*/
surface_t newcopy_t;
int subdivides;
int c_activefaces, c_peakfaces;
int c_activesurfaces, c_peaksurfaces;
face_t *
AllocFace (void)
{
face_t *f;
c_activefaces++;
if (c_activefaces > c_peakfaces)
c_peakfaces = c_activefaces;
f = malloc (sizeof (face_t));
memset (f, 0, sizeof (face_t));
f->planenum = -1;
return f;
}
void
FreeFace (face_t *f)
{
c_activefaces--;
free (f);
}
surface_t *
AllocSurface (void)
{
surface_t *s;
s = malloc (sizeof (surface_t));
memset (s, 0, sizeof (surface_t));
c_activesurfaces++;
if (c_activesurfaces > c_peaksurfaces)
c_peaksurfaces = c_activesurfaces;
return s;
}
void
FreeSurface (surface_t *s)
{
c_activesurfaces--;
free (s);
}
/*
SubdivideFace

View file

@ -25,7 +25,7 @@ static __attribute__ ((used)) const char rcsid[] =
"$Id$";
#ifdef HAVE_STRING_H
# include "string.h"
# include <string.h>
#endif
#include "QF/sys.h"