2002-08-25 23:06:23 +00:00
|
|
|
/*
|
|
|
|
vis.h
|
|
|
|
|
|
|
|
PVS/PHS generation tool
|
|
|
|
|
|
|
|
Copyright (C) 2002 Colin Thompson
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __vis_h
|
|
|
|
#define __vis_h
|
|
|
|
|
|
|
|
#ifdef __alpha
|
|
|
|
#include <pthread.h>
|
|
|
|
extern pthread_mutex_t *my_mutex;
|
|
|
|
#define LOCK pthread_mutex_lock (my_mutex)
|
|
|
|
#define UNLOCK pthread_mutex_unlock (my_mutex)
|
|
|
|
#else
|
|
|
|
#define LOCK
|
|
|
|
#define UNLOCK
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define MAX_PORTALS 32768
|
|
|
|
#define PORTALFILE "PRT1"
|
|
|
|
#define ON_EPSILON 0.1
|
|
|
|
#define MAX_POINTS_ON_WINDING 64
|
|
|
|
#define MAX_PORTALS_ON_LEAF 128
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
vec3_t normal;
|
|
|
|
float dist;
|
|
|
|
} plane_t;
|
|
|
|
|
|
|
|
typedef struct {
|
2002-09-19 02:37:52 +00:00
|
|
|
qboolean original; // don't free, it's part of the portal
|
|
|
|
int numpoints;
|
|
|
|
vec3_t points[8]; // variable sized
|
2002-08-25 23:06:23 +00:00
|
|
|
} winding_t;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
stat_none,
|
|
|
|
stat_working,
|
|
|
|
stat_done
|
|
|
|
} vstatus_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
plane_t plane; // normal pointing into neighbor
|
|
|
|
int leaf; // neighbor
|
2002-09-19 02:37:52 +00:00
|
|
|
winding_t *winding;
|
|
|
|
vstatus_t status;
|
|
|
|
byte *visbits;
|
|
|
|
byte *mightsee;
|
|
|
|
int nummightsee;
|
|
|
|
int numcansee;
|
2002-08-25 23:06:23 +00:00
|
|
|
} portal_t;
|
|
|
|
|
|
|
|
typedef struct seperating_plane_s {
|
2002-09-19 02:37:52 +00:00
|
|
|
struct seperating_plane_s *next;
|
|
|
|
plane_t plane; // from portal is on positive side
|
2002-08-25 23:06:23 +00:00
|
|
|
} sep_t;
|
|
|
|
|
|
|
|
typedef struct passage_s {
|
2002-09-19 02:37:52 +00:00
|
|
|
struct passage_s *next;
|
|
|
|
int from, to; // leaf numbers
|
|
|
|
sep_t *planes;
|
2002-08-25 23:06:23 +00:00
|
|
|
} passage_t;
|
|
|
|
|
|
|
|
typedef struct leaf_s {
|
2002-09-19 02:37:52 +00:00
|
|
|
int numportals;
|
|
|
|
passage_t *passages;
|
|
|
|
portal_t *portals[MAX_PORTALS_ON_LEAF];
|
2002-08-25 23:06:23 +00:00
|
|
|
} leaf_t;
|
|
|
|
|
|
|
|
typedef struct pstack_s {
|
2002-09-19 02:37:52 +00:00
|
|
|
struct pstack_s *next;
|
|
|
|
leaf_t *leaf;
|
|
|
|
portal_t *portal; // portal exiting
|
|
|
|
winding_t *source, *pass;
|
|
|
|
plane_t portalplane;
|
|
|
|
byte *mightsee; // bit string
|
2002-08-25 23:06:23 +00:00
|
|
|
} pstack_t;
|
|
|
|
|
|
|
|
typedef struct {
|
2002-09-19 02:37:52 +00:00
|
|
|
byte *leafvis; // bit string
|
|
|
|
portal_t *base;
|
|
|
|
pstack_t pstack_head;
|
2002-08-25 23:06:23 +00:00
|
|
|
} threaddata_t;
|
|
|
|
|
|
|
|
extern int numportals;
|
|
|
|
extern int portalleafs;
|
|
|
|
extern int c_portaltest;
|
|
|
|
extern int c_portalpass;
|
|
|
|
extern int c_portalcheck;
|
|
|
|
extern int bitbytes;
|
|
|
|
extern int bitlongs;
|
|
|
|
|
|
|
|
extern portal_t *portals;
|
|
|
|
extern leaf_t *leafs;
|
|
|
|
extern qboolean showgetleaf;
|
|
|
|
extern byte *vismap, *vismap_p, *vismap_end; // past visfile
|
|
|
|
extern byte *uncompressed;
|
|
|
|
|
|
|
|
extern int c_portalskip, c_leafskip;
|
|
|
|
extern int c_vistest, c_mighttest;
|
|
|
|
extern int c_chains;
|
|
|
|
|
|
|
|
void FreeWinding (winding_t *winding);
|
|
|
|
winding_t *NewWinding (int points);
|
|
|
|
winding_t *ClipWinding (winding_t *in, plane_t *split, qboolean keepon);
|
|
|
|
winding_t *CopyWinding (winding_t *winding);
|
|
|
|
|
|
|
|
void LeafFlow (int leafnum);
|
|
|
|
void BasePortalVis (void);
|
|
|
|
void PortalFlow (portal_t *portal);
|
|
|
|
void CalcAmbientSounds (void);
|
|
|
|
|
|
|
|
#endif// __vis_h
|