DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
 
portals.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int Portal_CheckBox (model_t *model, vec3_t eye, vec3_t a, vec3_t b)
 
int Portal_CheckPolygon (model_t *model, vec3_t eye, float *polypoints, int numpoints)
 
void Portal_Visibility (model_t *model, const vec3_t eye, int *leaflist, unsigned char *leafpvs, int *numleafspointer, int *surfacelist, unsigned char *surfacepvs, int *numsurfacespointer, const mplane_t *frustumplanes, int numfrustumplanes, int exact, const float *boxmins, const float *boxmaxs, float *updateleafsmins, float *updateleafsmaxs, unsigned char *shadowtrispvs, unsigned char *lighttrispvs, unsigned char *visitingleafpvs)
 

Function Documentation

◆ Portal_CheckBox()

int Portal_CheckBox ( model_t * model,
vec3_t eye,
vec3_t a,
vec3_t b )

Definition at line 208 of file portals.c.

209{
210 if (eye[0] >= (a[0] - 1.0f) && eye[0] < (b[0] + 1.0f)
211 && eye[1] >= (a[1] - 1.0f) && eye[1] < (b[1] + 1.0f)
212 && eye[2] >= (a[2] - 1.0f) && eye[2] < (b[2] + 1.0f))
213 return true;
214
216 (
217 0, a[0],
218 a[0], a[1], a[2],
219 a[0], b[1], a[2],
220 a[0], b[1], b[2],
221 a[0], a[1], b[2]
222 );
224 (
225 0, b[0],
226 b[0], b[1], a[2],
227 b[0], a[1], a[2],
228 b[0], a[1], b[2],
229 b[0], b[1], b[2]
230 );
232 (
233 1, a[1],
234 b[0], a[1], a[2],
235 a[0], a[1], a[2],
236 a[0], a[1], b[2],
237 b[0], a[1], b[2]
238 );
240 (
241 1, b[1],
242 a[0], b[1], a[2],
243 b[0], b[1], a[2],
244 b[0], b[1], b[2],
245 a[0], b[1], b[2]
246 );
248 (
249 2, a[2],
250 a[0], a[1], a[2],
251 b[0], a[1], a[2],
252 b[0], b[1], a[2],
253 a[0], b[1], a[2]
254 );
256 (
257 2, b[2],
258 b[0], a[1], b[2],
259 a[0], a[1], b[2],
260 a[0], b[1], b[2],
261 b[0], b[1], b[2]
262 );
263
264 return false;
265}
#define Portal_MinsBoxPolygon(axis, axisvalue, x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4)
Definition portals.c:182
#define Portal_MaxsBoxPolygon(axis, axisvalue, x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4)
Definition portals.c:195
dp_FragColor b
ret a

References a, b, Portal_MaxsBoxPolygon, and Portal_MinsBoxPolygon.

◆ Portal_CheckPolygon()

int Portal_CheckPolygon ( model_t * model,
vec3_t eye,
float * polypoints,
int numpoints )

Definition at line 131 of file portals.c.

132{
133 int i, prev, returnvalue;
134 mleaf_t *eyeleaf;
135 vec3_t center, v1, v2;
136
137 // if there is no model, it can not block visibility
138 if (model == NULL || !model->brush.PointInLeaf)
139 return true;
140
142
143 Portal_PolygonRecursiveMarkLeafs(model->brush.data_nodes, polypoints, numpoints);
144
145 eyeleaf = model->brush.PointInLeaf(model, eye);
146
147 // find the center by averaging
148 VectorClear(center);
149 for (i = 0;i < numpoints;i++)
150 VectorAdd(center, (&polypoints[i * 3]), center);
151 // ixtable is a 1.0f / N table
152 VectorScale(center, ixtable[numpoints], center);
153
154 // calculate the planes, and make sure the polygon can see it's own center
155 for (prev = numpoints - 1, i = 0;i < numpoints;prev = i, i++)
156 {
157 VectorSubtract(eye, (&polypoints[i * 3]), v1);
158 VectorSubtract((&polypoints[prev * 3]), (&polypoints[i * 3]), v2);
162 if (DotProduct(portalplanes[i].normal, center) <= portalplanes[i].dist)
163 {
164 // polygon can't see it's own center, discard
165 return false;
166 }
167 }
168
169 ranoutofportalplanes = false;
170 ranoutofportals = false;
171
172 returnvalue = Portal_RecursiveFlowSearch(eyeleaf, eye, 0, numpoints);
173
175 Con_Printf("Portal_RecursiveFlowSearch: ran out of %d plane stack when recursing through portals\n", MAXRECURSIVEPORTALPLANES);
176 if (ranoutofportals)
177 Con_Printf("Portal_RecursiveFlowSearch: ran out of %d portal stack when recursing through portals\n", MAXRECURSIVEPORTALS);
178
179 return returnvalue;
180}
void Con_Printf(const char *fmt,...)
Prints to all appropriate console targets.
Definition console.c:1514
string model
GLfloat GLfloat GLfloat v2
Definition glquake.h:747
GLfloat GLfloat v1
Definition glquake.h:743
float ixtable[4096]
Definition mathlib.c:27
#define VectorNormalize(v)
Definition mathlib.h:104
#define VectorClear(a)
Definition mathlib.h:97
#define VectorSubtract(a, b, out)
Definition mathlib.h:99
#define CrossProduct(a, b, out)
Definition mathlib.h:103
#define DotProduct(a, b)
Definition mathlib.h:98
#define VectorScale(in, scale, out)
Definition mathlib.h:111
#define VectorAdd(a, b, out)
Definition mathlib.h:100
static int ranoutofportals
Definition portals.c:11
static int ranoutofportalplanes
Definition portals.c:10
#define MAXRECURSIVEPORTALS
Definition portals.c:7
static tinyplane_t portalplanes[MAXRECURSIVEPORTALPLANES]
Definition portals.c:9
static int portal_markid
Definition portals.c:14
#define MAXRECURSIVEPORTALPLANES
Definition portals.c:6
static void Portal_PolygonRecursiveMarkLeafs(mnode_t *node, float *polypoints, int numpoints)
Definition portals.c:99
static int Portal_RecursiveFlowSearch(mleaf_t *leaf, vec3_t eye, int firstclipplane, int numclipplanes)
Definition portals.c:38
int i
#define NULL
Definition qtypes.h:12
vec_t vec3_t[3]
Definition qtypes.h:71
vec3 normal
float dist
Definition mathlib.h:262

References Con_Printf(), CrossProduct, tinyplane_t::dist, DotProduct, i, ixtable, MAXRECURSIVEPORTALPLANES, MAXRECURSIVEPORTALS, model, normal, NULL, portal_markid, Portal_PolygonRecursiveMarkLeafs(), Portal_RecursiveFlowSearch(), portalplanes, ranoutofportalplanes, ranoutofportals, v1, v2, VectorAdd, VectorClear, VectorNormalize, VectorScale, and VectorSubtract.

◆ Portal_Visibility()

void Portal_Visibility ( model_t * model,
const vec3_t eye,
int * leaflist,
unsigned char * leafpvs,
int * numleafspointer,
int * surfacelist,
unsigned char * surfacepvs,
int * numsurfacespointer,
const mplane_t * frustumplanes,
int numfrustumplanes,
int exact,
const float * boxmins,
const float * boxmaxs,
float * updateleafsmins,
float * updateleafsmaxs,
unsigned char * shadowtrispvs,
unsigned char * lighttrispvs,
unsigned char * visitingleafpvs )

Definition at line 423 of file portals.c.

424{
425 int i;
427
428 // if there is no model, it can not block visibility
429 if (model == NULL)
430 {
431 Con_Print("Portal_Visibility: NULL model\n");
432 return;
433 }
434
435 if (!model->brush.data_nodes)
436 {
437 Con_Print("Portal_Visibility: not a brush model\n");
438 return;
439 }
440
441 // put frustum planes (if any) into tinyplane format at start of buffer
442 for (i = 0;i < numfrustumplanes;i++)
443 {
444 VectorCopy(frustumplanes[i].normal, portalplanes[i].normal);
445 portalplanes[i].dist = frustumplanes[i].dist;
446 }
447
448 ranoutofportalplanes = false;
449 ranoutofportals = false;
450
451 VectorCopy(boxmins, info.boxmins);
452 VectorCopy(boxmaxs, info.boxmaxs);
453 info.exact = exact;
454 info.numsurfaces = 0;
455 info.surfacelist = surfacelist;
456 info.surfacepvs = surfacepvs;
457 info.numleafs = 0;
458 info.visitingleafpvs = visitingleafpvs;
459 info.leaflist = leaflist;
460 info.leafpvs = leafpvs;
461 info.model = model;
462 VectorCopy(eye, info.eye);
463 info.numfrustumplanes = numfrustumplanes;
464 info.updateleafsmins = updateleafsmins;
465 info.updateleafsmaxs = updateleafsmaxs;
466 info.shadowtrispvs = shadowtrispvs;
467 info.lighttrispvs = lighttrispvs;
468
469 Portal_RecursiveFindLeafForFlow(&info, model->brush.data_nodes);
470
472 Con_Printf("Portal_RecursiveFlow: ran out of %d plane stack when recursing through portals\n", MAXRECURSIVEPORTALPLANES);
473 if (ranoutofportals)
474 Con_Printf("Portal_RecursiveFlow: ran out of %d portal stack when recursing through portals\n", MAXRECURSIVEPORTALS);
475 if (numsurfacespointer)
476 *numsurfacespointer = info.numsurfaces;
477 if (numleafspointer)
478 *numleafspointer = info.numleafs;
479}
void Con_Print(const char *msg)
Prints to all appropriate console targets, and adds timestamps.
Definition console.c:1504
#define VectorCopy(in, out)
Definition mathlib.h:101
static void Portal_RecursiveFindLeafForFlow(portalrecursioninfo_t *info, mnode_t *node)
Definition portals.c:405
vec_t dist
Definition model_brush.h:60
unsigned char * leafpvs
Definition portals.c:279
unsigned char * shadowtrispvs
Definition portals.c:280
float * updateleafsmins
Definition portals.c:284
unsigned char * lighttrispvs
Definition portals.c:281
float * updateleafsmaxs
Definition portals.c:285
unsigned char * surfacepvs
Definition portals.c:275
unsigned char * visitingleafpvs
Definition portals.c:277

References portalrecursioninfo_t::boxmaxs, portalrecursioninfo_t::boxmins, Con_Print(), Con_Printf(), mplane_t::dist, tinyplane_t::dist, portalrecursioninfo_t::exact, portalrecursioninfo_t::eye, i, portalrecursioninfo_t::leaflist, portalrecursioninfo_t::leafpvs, portalrecursioninfo_t::lighttrispvs, MAXRECURSIVEPORTALPLANES, MAXRECURSIVEPORTALS, model, portalrecursioninfo_t::model, normal, NULL, portalrecursioninfo_t::numfrustumplanes, portalrecursioninfo_t::numleafs, portalrecursioninfo_t::numsurfaces, Portal_RecursiveFindLeafForFlow(), portalplanes, ranoutofportalplanes, ranoutofportals, portalrecursioninfo_t::shadowtrispvs, portalrecursioninfo_t::surfacelist, portalrecursioninfo_t::surfacepvs, portalrecursioninfo_t::updateleafsmaxs, portalrecursioninfo_t::updateleafsmins, VectorCopy, and portalrecursioninfo_t::visitingleafpvs.

Referenced by R_Mod_GetLightInfo().