-/*\r
-Copyright (C) 1999-2007 id Software, Inc. and contributors.\r
-For a list of contributors, see the accompanying CONTRIBUTORS file.\r
-\r
-This file is part of GtkRadiant.\r
-\r
-GtkRadiant is free software; you can redistribute it and/or modify\r
-it under the terms of the GNU General Public License as published by\r
-the Free Software Foundation; either version 2 of the License, or\r
-(at your option) any later version.\r
-\r
-GtkRadiant is distributed in the hope that it will be useful,\r
-but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
-GNU General Public License for more details.\r
-\r
-You should have received a copy of the GNU General Public License\r
-along with GtkRadiant; if not, write to the Free Software\r
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\r
-*/\r
-/* Files:\r
-\r
-flow.c\r
-qvis3.c\r
-\r
-*/\r
-\r
-#include "cmdlib.h"\r
-#include "mathlib.h"\r
-#include "bspfile.h"\r
-#include "inout.h"\r
-\r
-#ifdef _WIN32\r
- #ifdef NDEBUG // Don't show in a Release build\r
- #pragma warning(disable : 4305) // truncate from double to float\r
- #pragma warning(disable : 4244) // conversion from double to float\r
- #pragma warning(disable : 4018) // signed/unsigned mismatch\r
- #endif\r
-#endif\r
-\r
-#define MAX_PORTALS 32768\r
-\r
-#define PORTALFILE "PRT1"\r
-\r
-#define ON_EPSILON 0.1\r
-\r
-typedef struct\r
-{\r
- vec3_t normal;\r
- float dist;\r
-} plane_t;\r
-\r
-#define MAX_POINTS_ON_WINDING 64\r
-#define MAX_POINTS_ON_FIXED_WINDING 12\r
-\r
-typedef struct\r
-{\r
- qboolean original; // don't free, it's part of the portal\r
- int numpoints;\r
- vec3_t points[MAX_POINTS_ON_FIXED_WINDING]; // variable sized\r
-} winding_t;\r
-\r
-winding_t *NewWinding (int points);\r
-void FreeWinding (winding_t *w);\r
-winding_t *CopyWinding (winding_t *w);\r
-\r
-\r
-typedef enum {stat_none, stat_working, stat_done} vstatus_t;\r
-typedef struct\r
-{\r
- plane_t plane; // normal pointing into neighbor\r
- int leaf; // neighbor\r
- \r
- vec3_t origin; // for fast clip testing\r
- float radius;\r
-\r
- winding_t *winding;\r
- vstatus_t status;\r
- byte *portalfront; // [portals], preliminary\r
- byte *portalflood; // [portals], intermediate\r
- byte *portalvis; // [portals], final\r
-\r
- int nummightsee; // bit count on portalflood for sort\r
-} portal_t;\r
-\r
-typedef struct seperating_plane_s\r
-{\r
- struct seperating_plane_s *next;\r
- plane_t plane; // from portal is on positive side\r
-} sep_t;\r
-\r
-\r
-typedef struct passage_s\r
-{\r
- struct passage_s *next;\r
- int from, to; // leaf numbers\r
- sep_t *planes;\r
-} passage_t;\r
-\r
-#define MAX_PORTALS_ON_LEAF 128\r
-typedef struct leaf_s\r
-{\r
- int numportals;\r
- passage_t *passages;\r
- portal_t *portals[MAX_PORTALS_ON_LEAF];\r
-} leaf_t;\r
-\r
- \r
-typedef struct pstack_s\r
-{\r
- byte mightsee[MAX_PORTALS/8]; // bit string\r
- struct pstack_s *next;\r
- leaf_t *leaf;\r
- portal_t *portal; // portal exiting\r
- winding_t *source;\r
- winding_t *pass;\r
-\r
- winding_t windings[3]; // source, pass, temp in any order\r
- int freewindings[3];\r
-\r
- plane_t portalplane;\r
-} pstack_t;\r
-\r
-typedef struct\r
-{\r
- portal_t *base;\r
- int c_chains;\r
- pstack_t pstack_head;\r
-} threaddata_t;\r
-\r
-\r
-\r
-extern int numportals;\r
-extern int portalclusters;\r
-\r
-extern portal_t *portals;\r
-extern leaf_t *leafs;\r
-\r
-extern int c_portaltest, c_portalpass, c_portalcheck;\r
-extern int c_portalskip, c_leafskip;\r
-extern int c_vistest, c_mighttest;\r
-extern int c_chains;\r
-\r
-extern byte *vismap, *vismap_p, *vismap_end; // past visfile\r
-\r
-extern int testlevel;\r
-\r
-extern byte *uncompressed;\r
-\r
-extern int leafbytes, leaflongs;\r
-extern int portalbytes, portallongs;\r
-\r
-\r
-void LeafFlow (int leafnum);\r
-\r
-\r
-void BasePortalVis (int portalnum);\r
-void BetterPortalVis (int portalnum);\r
-void PortalFlow (int portalnum);\r
-\r
-extern portal_t *sorted_portals[MAX_MAP_PORTALS*2];\r
-\r
-int CountBits (byte *bits, int numbits);\r
-\r
-//=============================================================================\r
-\r
-// externs\r
-\r
-extern char *mapname;\r
+/*
+Copyright (C) 1999-2007 id Software, Inc. and contributors.
+For a list of contributors, see the accompanying CONTRIBUTORS file.
+
+This file is part of GtkRadiant.
+
+GtkRadiant 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.
+
+GtkRadiant 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 GtkRadiant; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+/* Files:
+
+flow.c
+qvis3.c
+
+*/
+
+#include "cmdlib.h"
+#include "mathlib.h"
+#include "bspfile.h"
+#include "inout.h"
+
+#ifdef _WIN32
+ #ifdef NDEBUG // Don't show in a Release build
+ #pragma warning(disable : 4305) // truncate from double to float
+ #pragma warning(disable : 4244) // conversion from double to float
+ #pragma warning(disable : 4018) // signed/unsigned mismatch
+ #endif
+#endif
+
+#define MAX_PORTALS 32768
+
+#define PORTALFILE "PRT1"
+
+#define ON_EPSILON 0.1
+
+typedef struct
+{
+ vec3_t normal;
+ float dist;
+} plane_t;
+
+#define MAX_POINTS_ON_WINDING 64
+#define MAX_POINTS_ON_FIXED_WINDING 12
+
+typedef struct
+{
+ qboolean original; // don't free, it's part of the portal
+ int numpoints;
+ vec3_t points[MAX_POINTS_ON_FIXED_WINDING]; // variable sized
+} winding_t;
+
+winding_t *NewWinding (int points);
+void FreeWinding (winding_t *w);
+winding_t *CopyWinding (winding_t *w);
+
+
+typedef enum {stat_none, stat_working, stat_done} vstatus_t;
+typedef struct
+{
+ plane_t plane; // normal pointing into neighbor
+ int leaf; // neighbor
+
+ vec3_t origin; // for fast clip testing
+ float radius;
+
+ winding_t *winding;
+ vstatus_t status;
+ byte *portalfront; // [portals], preliminary
+ byte *portalflood; // [portals], intermediate
+ byte *portalvis; // [portals], final
+
+ int nummightsee; // bit count on portalflood for sort
+} portal_t;
+
+typedef struct seperating_plane_s
+{
+ struct seperating_plane_s *next;
+ plane_t plane; // from portal is on positive side
+} sep_t;
+
+
+typedef struct passage_s
+{
+ struct passage_s *next;
+ int from, to; // leaf numbers
+ sep_t *planes;
+} passage_t;
+
+#define MAX_PORTALS_ON_LEAF 128
+typedef struct leaf_s
+{
+ int numportals;
+ passage_t *passages;
+ portal_t *portals[MAX_PORTALS_ON_LEAF];
+} leaf_t;
+
+
+typedef struct pstack_s
+{
+ byte mightsee[MAX_PORTALS/8]; // bit string
+ struct pstack_s *next;
+ leaf_t *leaf;
+ portal_t *portal; // portal exiting
+ winding_t *source;
+ winding_t *pass;
+
+ winding_t windings[3]; // source, pass, temp in any order
+ int freewindings[3];
+
+ plane_t portalplane;
+} pstack_t;
+
+typedef struct
+{
+ portal_t *base;
+ int c_chains;
+ pstack_t pstack_head;
+} threaddata_t;
+
+
+
+extern int numportals;
+extern int portalclusters;
+
+extern portal_t *portals;
+extern leaf_t *leafs;
+
+extern int c_portaltest, c_portalpass, c_portalcheck;
+extern int c_portalskip, c_leafskip;
+extern int c_vistest, c_mighttest;
+extern int c_chains;
+
+extern byte *vismap, *vismap_p, *vismap_end; // past visfile
+
+extern int testlevel;
+
+extern byte *uncompressed;
+
+extern int leafbytes, leaflongs;
+extern int portalbytes, portallongs;
+
+
+void LeafFlow (int leafnum);
+
+
+void BasePortalVis (int portalnum);
+void BetterPortalVis (int portalnum);
+void PortalFlow (int portalnum);
+
+extern portal_t *sorted_portals[MAX_MAP_PORTALS*2];
+
+int CountBits (byte *bits, int numbits);
+
+//=============================================================================
+
+// externs
+
+extern char *mapname;