]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - tools/quake2/extra/bsp/qrad3/qrad.h
Centralise compile checks
[xonotic/netradiant.git] / tools / quake2 / extra / bsp / qrad3 / qrad.h
1 /*
2 ===========================================================================
3 Copyright (C) 1997-2006 Id Software, Inc.
4
5 This file is part of Quake 2 Tools source code.
6
7 Quake 2 Tools source code is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the License,
10 or (at your option) any later version.
11
12 Quake 2 Tools source code is distributed in the hope that it will be
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Quake 2 Tools source code; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20 ===========================================================================
21 */
22
23 #include "globaldefs.h"
24 #include "cmdlib.h"
25 #include "mathlib.h"
26 #include "bspfile.h"
27 #include "polylib.h"
28 #include "threads.h"
29 #include "lbmlib.h"
30
31 #if GDEF_OS_WINDOWS
32 #include <windows.h>
33 #endif
34
35 typedef enum
36 {
37         emit_surface,
38         emit_point,
39         emit_spotlight
40 } emittype_t;
41
42
43
44 typedef struct directlight_s
45 {
46         struct directlight_s *next;
47         emittype_t      type;
48
49         float           intensity;
50         int                     style;
51         vec3_t          origin;
52         vec3_t          color;
53         vec3_t          normal;         // for surfaces and spotlights
54         float           stopdot;                // for spotlights
55 } directlight_t;
56
57
58 // the sum of all tranfer->transfer values for a given patch
59 // should equal exactly 0x10000, showing that all radiance
60 // reaches other patches
61 typedef struct
62 {
63         unsigned short  patch;
64         unsigned short  transfer;
65 } transfer_t;
66
67
68 #define MAX_PATCHES     65000                   // larger will cause 32 bit overflows
69
70 typedef struct patch_s
71 {
72         winding_t       *winding;
73         struct patch_s          *next;          // next in face
74         int                     numtransfers;
75         transfer_t      *transfers;
76
77         int                     cluster;                        // for pvs checking
78         vec3_t          origin;
79         dplane_t        *plane;
80
81         qboolean        sky;
82
83         vec3_t          totallight;                     // accumulated by radiosity
84                                                                         // does NOT include light
85                                                                         // accounted for by direct lighting
86         float           area;
87
88         // illuminance * reflectivity = radiosity
89         vec3_t          reflectivity;
90         vec3_t          baselight;                      // emissivity only
91
92         // each style 0 lightmap sample in the patch will be
93         // added up to get the average illuminance of the entire patch
94         vec3_t          samplelight;
95         int                     samples;                // for averaging direct light
96 } patch_t;
97
98 extern  patch_t         *face_patches[MAX_MAP_FACES];
99 extern  entity_t        *face_entity[MAX_MAP_FACES];
100 extern  vec3_t          face_offset[MAX_MAP_FACES];             // for rotating bmodels
101 extern  patch_t         patches[MAX_PATCHES];
102 extern  unsigned        num_patches;
103
104 extern  int             leafparents[MAX_MAP_LEAFS];
105 extern  int             nodeparents[MAX_MAP_NODES];
106
107 extern  float   lightscale;
108
109
110 void MakeShadowSplits (void);
111
112 //==============================================
113
114
115 void BuildVisMatrix (void);
116 qboolean CheckVisBit (unsigned p1, unsigned p2);
117
118 //==============================================
119
120 extern  float ambient, maxlight;
121
122 void LinkPlaneFaces (void);
123
124 extern  qboolean        extrasamples;
125 extern int numbounce;
126
127 extern  directlight_t   *directlights[MAX_MAP_LEAFS];
128
129 extern  byte    nodehit[MAX_MAP_NODES];
130
131 void BuildLightmaps (void);
132
133 void BuildFacelights (int facenum);
134
135 void FinalLightFace (int facenum);
136
137 qboolean PvsForOrigin (vec3_t org, byte *pvs);
138
139 int TestLine_r (int node, vec3_t start, vec3_t stop);
140
141 void CreateDirectLights (void);
142
143 dleaf_t         *PointInLeaf (vec3_t point);
144
145
146 extern  dplane_t        backplanes[MAX_MAP_PLANES];
147 extern  int                     fakeplanes;                                     // created planes for origin offset 
148
149 extern  float   subdiv;
150
151 extern  float   direct_scale;
152 extern  float   entity_scale;
153
154 int     PointInLeafnum (vec3_t point);
155 void MakeTnodes (dmodel_t *bm);
156 void MakePatches (void);
157 void SubdividePatches (void);
158 void PairEdges (void);
159 void CalcTextureReflectivity (void);