2002-08-25 23:06:23 +00:00
|
|
|
/*
|
|
|
|
vis.h
|
|
|
|
|
|
|
|
PVS/PHS generation tool
|
|
|
|
|
2002-09-25 01:51:58 +00:00
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
2002-08-25 23:06:23 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __vis_h
|
|
|
|
#define __vis_h
|
|
|
|
|
2002-09-20 19:03:06 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2012-08-19 04:40:42 +00:00
|
|
|
#if defined (HAVE_PTHREAD_H) && defined (HAVE_PTHREAD)
|
2002-08-25 23:06:23 +00:00
|
|
|
#include <pthread.h>
|
|
|
|
extern pthread_mutex_t *my_mutex;
|
2002-09-22 21:54:41 +00:00
|
|
|
#define LOCK do {if (options.threads > 1) pthread_mutex_lock (my_mutex); } while (0)
|
|
|
|
#define UNLOCK do {if (options.threads > 1) pthread_mutex_unlock (my_mutex); } while (0)
|
2002-08-25 23:06:23 +00:00
|
|
|
#else
|
|
|
|
#define LOCK
|
|
|
|
#define UNLOCK
|
|
|
|
#endif
|
|
|
|
|
2013-03-07 02:06:55 +00:00
|
|
|
#include "QF/set.h"
|
|
|
|
|
2002-08-25 23:06:23 +00:00
|
|
|
#define MAX_PORTALS 32768
|
2004-02-02 05:44:46 +00:00
|
|
|
#define PORTALFILE "PRT1"
|
|
|
|
#define PORTALFILE_AM "PRT1-AM"
|
2013-03-07 09:51:32 +00:00
|
|
|
#define PORTALFILE2 "PRT2"
|
2002-08-25 23:06:23 +00:00
|
|
|
#define ON_EPSILON 0.1
|
|
|
|
#define MAX_POINTS_ON_WINDING 64
|
2003-02-04 23:26:26 +00:00
|
|
|
#define MAX_PORTALS_ON_CLUSTER 128
|
2002-08-25 23:06:23 +00:00
|
|
|
|
|
|
|
typedef struct {
|
2002-09-21 21:27:38 +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;
|
|
|
|
|
2012-05-21 23:23:22 +00:00
|
|
|
typedef enum {
|
|
|
|
stat_none,
|
2002-09-22 21:54:41 +00:00
|
|
|
stat_selected,
|
2012-05-21 23:23:22 +00:00
|
|
|
stat_working,
|
|
|
|
stat_done
|
2002-08-25 23:06:23 +00:00
|
|
|
} vstatus_t;
|
|
|
|
|
|
|
|
typedef struct {
|
2002-09-21 21:27:38 +00:00
|
|
|
plane_t plane; // normal pointing into neighbor
|
2003-02-04 23:26:26 +00:00
|
|
|
int cluster; // neighbor
|
2013-03-13 12:32:18 +00:00
|
|
|
sphere_t sphere; // bounding sphere
|
2002-09-21 21:27:38 +00:00
|
|
|
winding_t *winding;
|
|
|
|
vstatus_t status;
|
2013-03-07 02:06:55 +00:00
|
|
|
set_t *visbits;
|
|
|
|
set_t *mightsee;
|
2002-09-21 21:27:38 +00:00
|
|
|
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;
|
2002-09-21 21:27:38 +00:00
|
|
|
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;
|
2003-02-04 23:26:26 +00:00
|
|
|
int from, to; // cluster numbers
|
2002-09-21 21:27:38 +00:00
|
|
|
sep_t *planes;
|
2002-08-25 23:06:23 +00:00
|
|
|
} passage_t;
|
|
|
|
|
2003-02-04 23:26:26 +00:00
|
|
|
typedef struct cluster_s {
|
2002-09-21 21:27:38 +00:00
|
|
|
int numportals;
|
|
|
|
passage_t *passages;
|
2003-02-04 23:26:26 +00:00
|
|
|
portal_t *portals[MAX_PORTALS_ON_CLUSTER];
|
|
|
|
int visofs;
|
|
|
|
} cluster_t;
|
2002-08-25 23:06:23 +00:00
|
|
|
|
|
|
|
typedef struct pstack_s {
|
2013-03-14 10:40:19 +00:00
|
|
|
struct pstack_s *next; ///< linked list of active stack objects
|
2003-02-04 23:26:26 +00:00
|
|
|
cluster_t *cluster;
|
2002-09-21 21:27:38 +00:00
|
|
|
portal_t *portal; // portal exiting
|
|
|
|
winding_t *source, *pass;
|
|
|
|
plane_t portalplane;
|
2013-03-08 13:20:29 +00:00
|
|
|
sep_t *separators[2];
|
2013-03-17 07:37:27 +00:00
|
|
|
set_t mightsee;
|
2002-08-25 23:06:23 +00:00
|
|
|
} pstack_t;
|
|
|
|
|
2013-03-14 02:33:47 +00:00
|
|
|
typedef struct {
|
2013-03-14 10:40:19 +00:00
|
|
|
int portaltest; ///< number of portals tested via separators
|
|
|
|
int portalpass; ///< number of portals through which vis passes
|
|
|
|
int portalcheck; ///< number of portal checks
|
2013-03-14 10:40:31 +00:00
|
|
|
int targettested; ///< number of times target portal tested
|
|
|
|
int targettrimmed; ///< number of times target portal trimmed
|
|
|
|
int targetclipped; ///< number of times target portal clipped away
|
|
|
|
int sourcetested; ///< number of times source portal tested
|
|
|
|
int sourcetrimmed; ///< number of times source portal trimmed
|
|
|
|
int sourceclipped; ///< number of times source portal clipped away
|
2013-03-14 10:40:19 +00:00
|
|
|
int chains; ///< number of visits to clusters
|
|
|
|
int mighttest; ///< amount mightsee is used for masked tests
|
|
|
|
int vistest; ///< amount visbits is used for masked tests
|
|
|
|
int mightseeupdate; ///< amount of updates to waiting portals
|
2013-03-14 02:33:47 +00:00
|
|
|
} visstat_t;
|
|
|
|
|
2013-03-08 13:20:29 +00:00
|
|
|
typedef struct threaddata_s {
|
2013-03-14 10:40:19 +00:00
|
|
|
visstat_t stats; ///< per-thread statistics merged on completion
|
|
|
|
set_t *clustervis; ///< clusters base portal can see
|
|
|
|
portal_t *base; ///< portal for which this thread is being run
|
2013-03-17 07:37:27 +00:00
|
|
|
pstack_t *pstack_head;
|
2013-03-14 10:40:19 +00:00
|
|
|
sep_t *sep_freelist; ///< per-thread list of free separators
|
2002-08-25 23:06:23 +00:00
|
|
|
} threaddata_t;
|
|
|
|
|
|
|
|
extern int numportals;
|
2003-02-04 23:26:26 +00:00
|
|
|
extern int portalclusters;
|
|
|
|
extern int numrealleafs;
|
2002-08-25 23:06:23 +00:00
|
|
|
extern int bitbytes;
|
2003-02-04 23:26:26 +00:00
|
|
|
extern int bitbytes_l;
|
2002-08-25 23:06:23 +00:00
|
|
|
extern int bitlongs;
|
2002-09-23 22:54:28 +00:00
|
|
|
extern struct bsp_s *bsp;
|
2002-08-25 23:06:23 +00:00
|
|
|
|
|
|
|
extern portal_t *portals;
|
2003-02-04 23:26:26 +00:00
|
|
|
extern cluster_t *clusters;
|
|
|
|
extern int *leafcluster;
|
2002-08-25 23:06:23 +00:00
|
|
|
extern byte *uncompressed;
|
|
|
|
|
2010-08-31 12:54:48 +00:00
|
|
|
void FreeWinding (winding_t *w);
|
2002-08-25 23:06:23 +00:00
|
|
|
winding_t *NewWinding (int points);
|
2013-03-15 06:28:25 +00:00
|
|
|
winding_t *ClipWinding (winding_t *in, const plane_t *split, qboolean keepon);
|
2013-03-15 10:25:24 +00:00
|
|
|
winding_t *CopyWinding (const winding_t *w);
|
2002-08-25 23:06:23 +00:00
|
|
|
|
2003-02-04 23:26:26 +00:00
|
|
|
void ClusterFlow (int clusternum);
|
2002-08-25 23:06:23 +00:00
|
|
|
void BasePortalVis (void);
|
2013-03-14 02:33:47 +00:00
|
|
|
void PortalFlow (threaddata_t *data, portal_t *portal);
|
2002-08-25 23:06:23 +00:00
|
|
|
void CalcAmbientSounds (void);
|
|
|
|
|
|
|
|
#endif// __vis_h
|