]> git.xonotic.org Git - xonotic/netradiant.git/blob - tools/quake2/extra/bsp/qrad3/qrad.h
Q2Tools source - didn't import this in initially
[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 "cmdlib.h"
24 #include "mathlib.h"
25 #include "bspfile.h"
26 #include "polylib.h"
27 #include "threads.h"
28 #include "lbmlib.h"
29
30 #ifdef WIN32
31 #include <windows.h>
32 #endif
33
34 typedef enum
35 {
36         emit_surface,
37         emit_point,
38         emit_spotlight
39 } emittype_t;
40
41
42
43 typedef struct directlight_s
44 {
45         struct directlight_s *next;
46         emittype_t      type;
47
48         float           intensity;
49         int                     style;
50         vec3_t          origin;
51         vec3_t          color;
52         vec3_t          normal;         // for surfaces and spotlights
53         float           stopdot;                // for spotlights
54 } directlight_t;
55
56
57 // the sum of all tranfer->transfer values for a given patch
58 // should equal exactly 0x10000, showing that all radiance
59 // reaches other patches
60 typedef struct
61 {
62         unsigned short  patch;
63         unsigned short  transfer;
64 } transfer_t;
65
66
67 #define MAX_PATCHES     65000                   // larger will cause 32 bit overflows
68
69 typedef struct patch_s
70 {
71         winding_t       *winding;
72         struct patch_s          *next;          // next in face
73         int                     numtransfers;
74         transfer_t      *transfers;
75
76         int                     cluster;                        // for pvs checking
77         vec3_t          origin;
78         dplane_t        *plane;
79
80         qboolean        sky;
81
82         vec3_t          totallight;                     // accumulated by radiosity
83                                                                         // does NOT include light
84                                                                         // accounted for by direct lighting
85         float           area;
86
87         // illuminance * reflectivity = radiosity
88         vec3_t          reflectivity;
89         vec3_t          baselight;                      // emissivity only
90
91         // each style 0 lightmap sample in the patch will be
92         // added up to get the average illuminance of the entire patch
93         vec3_t          samplelight;
94         int                     samples;                // for averaging direct light
95 } patch_t;
96
97 extern  patch_t         *face_patches[MAX_MAP_FACES];
98 extern  entity_t        *face_entity[MAX_MAP_FACES];
99 extern  vec3_t          face_offset[MAX_MAP_FACES];             // for rotating bmodels
100 extern  patch_t         patches[MAX_PATCHES];
101 extern  unsigned        num_patches;
102
103 extern  int             leafparents[MAX_MAP_LEAFS];
104 extern  int             nodeparents[MAX_MAP_NODES];
105
106 extern  float   lightscale;
107
108
109 void MakeShadowSplits (void);
110
111 //==============================================
112
113
114 void BuildVisMatrix (void);
115 qboolean CheckVisBit (unsigned p1, unsigned p2);
116
117 //==============================================
118
119 extern  float ambient, maxlight;
120
121 void LinkPlaneFaces (void);
122
123 extern  qboolean        extrasamples;
124 extern int numbounce;
125
126 extern  directlight_t   *directlights[MAX_MAP_LEAFS];
127
128 extern  byte    nodehit[MAX_MAP_NODES];
129
130 void BuildLightmaps (void);
131
132 void BuildFacelights (int facenum);
133
134 void FinalLightFace (int facenum);
135
136 qboolean PvsForOrigin (vec3_t org, byte *pvs);
137
138 int TestLine_r (int node, vec3_t start, vec3_t stop);
139
140 void CreateDirectLights (void);
141
142 dleaf_t         *PointInLeaf (vec3_t point);
143
144
145 extern  dplane_t        backplanes[MAX_MAP_PLANES];
146 extern  int                     fakeplanes;                                     // created planes for origin offset 
147
148 extern  float   subdiv;
149
150 extern  float   direct_scale;
151 extern  float   entity_scale;
152
153 int     PointInLeafnum (vec3_t point);
154 void MakeTnodes (dmodel_t *bm);
155 void MakePatches (void);
156 void SubdividePatches (void);
157 void PairEdges (void);
158 void CalcTextureReflectivity (void);