DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
 
gl_rsurf.c File Reference
#include "quakedef.h"
#include "r_shadow.h"
#include "portals.h"
#include "csprogs.h"
#include "image.h"
+ Include dependency graph for gl_rsurf.c:

Go to the source code of this file.

Data Structures

struct  r_q1bsp_getlightinfo_t
 

Macros

#define BATCHSIZE   1024
 
#define GETLIGHTINFO_MAXNODESTACK   4096
 
#define RSURF_MAX_BATCHSURFACES   8192
 

Functions

void GL_Surf_Init (void)
 
void R_BuildLightMap (const entity_render_t *ent, msurface_t *surface, int combine)
 
static void R_DrawPortal_Callback (const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
 
void R_DrawPortals (void)
 
static void R_ListWorldTextures_f (cmd_state_t *cmd)
 
void R_Mod_CompileShadowMap (entity_render_t *ent, vec3_t relativelightorigin, vec3_t relativelightdirection, float lightradius, int numsurfaces, const int *surfacelist)
 
void R_Mod_Draw (entity_render_t *ent)
 
void R_Mod_DrawAddWaterPlanes (entity_render_t *ent)
 
void R_Mod_DrawDebug (entity_render_t *ent)
 
void R_Mod_DrawDepth (entity_render_t *ent)
 
void R_Mod_DrawLight (entity_render_t *ent, int numsurfaces, const int *surfacelist, const unsigned char *lighttrispvs)
 
void R_Mod_DrawPrepass (entity_render_t *ent)
 
void R_Mod_DrawShadowMap (int side, entity_render_t *ent, const vec3_t relativelightorigin, const vec3_t relativelightdirection, float lightradius, int modelnumsurfaces, const int *modelsurfacelist, const unsigned char *surfacesides, const vec3_t lightmins, const vec3_t lightmaxs)
 
void R_Mod_DrawSky (entity_render_t *ent)
 
void R_Mod_GetLightInfo (entity_render_t *ent, vec3_t relativelightorigin, float lightradius, vec3_t outmins, vec3_t outmaxs, int *outleaflist, unsigned char *outleafpvs, int *outnumleafspointer, int *outsurfacelist, unsigned char *outsurfacepvs, int *outnumsurfacespointer, unsigned char *outshadowtrispvs, unsigned char *outlighttrispvs, unsigned char *visitingleafpvs, int numfrustumplanes, const mplane_t *frustumplanes, qbool noocclusion)
 
static void R_Q1BSP_CallRecursiveGetLightInfo (r_q1bsp_getlightinfo_t *info, qbool use_svbsp)
 
static void R_Q1BSP_DrawLight_TransparentCallback (const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
 
static int R_Q1BSP_GetLightInfo_comparefunc (const void *ap, const void *bp)
 
static void R_Q1BSP_RecursiveGetLightInfo_BIH (r_q1bsp_getlightinfo_t *info, const bih_t *bih)
 
static void R_Q1BSP_RecursiveGetLightInfo_BSP (r_q1bsp_getlightinfo_t *info, qbool skipsurfaces)
 
static void R_ReplaceWorldTexture_f (cmd_state_t *cmd)
 
void R_Stain (const vec3_t origin, float radius, int cr1, int cg1, int cb1, int ca1, int cr2, int cg2, int cb2, int ca2)
 
static void R_StainNode (mnode_t *node, model_t *model, const vec3_t origin, float radius, const float fcolor[8])
 
void R_View_WorldVisibility (qbool forcenovis)
 
static void R_View_WorldVisibility_CullSurfaces (void)
 

Variables

static const msurface_tbatchsurfacelist [RSURF_MAX_BATCHSURFACES]
 
cvar_t r_ambient = {CF_CLIENT, "r_ambient", "0", "brightens map, value is 0-128"}
 
cvar_t r_lockpvs = {CF_CLIENT, "r_lockpvs", "0", "disables pvs switching, allows you to walk around and inspect what is visible from a given location in the map (anything not visible from your current location will not be drawn)"}
 
cvar_t r_lockvisibility = {CF_CLIENT, "r_lockvisibility", "0", "disables visibility updates, allows you to walk around and inspect what is visible from a given viewpoint in the map (anything offscreen at the moment this is enabled will not be drawn)"}
 
static msurface_tr_q1bsp_getlightinfo_surfaces
 
cvar_t r_q3bsp_renderskydepth = {CF_CLIENT, "r_q3bsp_renderskydepth", "0", "draws sky depth masking in q3 maps (as in q1 maps), this means for example that sky polygons can hide other things"}
 
cvar_t r_shadow_sortsurfaces
 
qbool r_shadow_usingdeferredprepass
 
cvar_t r_useportalculling = {CF_CLIENT, "r_useportalculling", "1", "improve framerate with r_novis 1 by using portal culling - still not as good as compiled visibility data in the map, but it helps (a value of 2 forces use of this even with vis data, which improves framerates in maps without too much complexity, but hurts in extremely complex maps, which is why 2 is not the default mode)"}
 
cvar_t r_usesurfaceculling = {CF_CLIENT, "r_usesurfaceculling", "1", "skip off-screen surfaces (1 = cull surfaces if the map is likely to benefit, 2 = always cull surfaces)"}
 
cvar_t r_vis_trace = {CF_CLIENT, "r_vis_trace", "0", "test if each portal or leaf is visible using tracelines"}
 
cvar_t r_vis_trace_delay = {CF_CLIENT, "r_vis_trace_delay", "1", "keep a portal visible for this many seconds"}
 
cvar_t r_vis_trace_enlarge = {CF_CLIENT, "r_vis_trace_enlarge", "0", "make portal bounds bigger for tests by (1+this)*size"}
 
cvar_t r_vis_trace_expand = {CF_CLIENT, "r_vis_trace_expand", "0", "make portal bounds bigger for tests by this many units"}
 
cvar_t r_vis_trace_eyejitter = {CF_CLIENT, "r_vis_trace_eyejitter", "8", "use a random offset of this much on the start of each traceline"}
 
cvar_t r_vis_trace_pad = {CF_CLIENT, "r_vis_trace_pad", "8", "accept traces that hit within this many units of the portal"}
 
cvar_t r_vis_trace_samples = {CF_CLIENT, "r_vis_trace_samples", "1", "use this many randomly positioned tracelines each frame to refresh the visible timer"}
 
cvar_t r_vis_trace_surfaces = {CF_CLIENT, "r_vis_trace_surfaces", "0", "also use tracelines to cull surfaces"}
 

Macro Definition Documentation

◆ BATCHSIZE

#define BATCHSIZE   1024

Definition at line 1366 of file gl_rsurf.c.

Referenced by R_Q1BSP_DrawLight_TransparentCallback().

◆ GETLIGHTINFO_MAXNODESTACK

#define GETLIGHTINFO_MAXNODESTACK   4096

◆ RSURF_MAX_BATCHSURFACES

#define RSURF_MAX_BATCHSURFACES   8192

Definition at line 1316 of file gl_rsurf.c.

Referenced by R_Mod_DrawLight(), and R_Mod_DrawShadowMap().

Function Documentation

◆ GL_Surf_Init()

void GL_Surf_Init ( void )

Definition at line 1564 of file gl_rsurf.c.

1565{
1566
1581
1582 Cmd_AddCommand(CF_CLIENT, "r_replacemaptexture", R_ReplaceWorldTexture_f, "override a map texture for testing purposes");
1583 Cmd_AddCommand(CF_CLIENT, "r_listmaptextures", R_ListWorldTextures_f, "list all textures used by the current map");
1584
1585 //R_RegisterModule("GL_Surf", gl_surf_start, gl_surf_shutdown, gl_surf_newmap);
1586}
void Cmd_AddCommand(unsigned flags, const char *cmd_name, xcommand_t function, const char *description)
called by the init functions of other parts of the program to register commands and functions to call...
Definition cmd.c:1661
#define CF_CLIENT
cvar/command that only the client can change/execute
Definition cmd.h:48
void Cvar_RegisterVariable(cvar_t *variable)
registers a cvar that already has the name, string, and optionally the archive elements set.
Definition cvar.c:599
cvar_t r_vis_trace_eyejitter
Definition gl_rsurf.c:36
cvar_t r_ambient
Definition gl_rsurf.c:28
cvar_t r_lockvisibility
Definition gl_rsurf.c:30
cvar_t r_usesurfaceculling
Definition gl_rsurf.c:32
cvar_t r_vis_trace_surfaces
Definition gl_rsurf.c:40
cvar_t r_useportalculling
Definition gl_rsurf.c:31
cvar_t r_vis_trace_delay
Definition gl_rsurf.c:35
cvar_t r_vis_trace_enlarge
Definition gl_rsurf.c:37
cvar_t r_vis_trace
Definition gl_rsurf.c:33
cvar_t r_vis_trace_samples
Definition gl_rsurf.c:34
cvar_t r_vis_trace_expand
Definition gl_rsurf.c:38
cvar_t r_vis_trace_pad
Definition gl_rsurf.c:39
cvar_t r_lockpvs
Definition gl_rsurf.c:29
cvar_t r_q3bsp_renderskydepth
Definition gl_rsurf.c:41
static void R_ListWorldTextures_f(cmd_state_t *cmd)
Definition gl_rsurf.c:1532
static void R_ReplaceWorldTexture_f(cmd_state_t *cmd)
Definition gl_rsurf.c:1483

References CF_CLIENT, Cmd_AddCommand(), Cvar_RegisterVariable(), r_ambient, R_ListWorldTextures_f(), r_lockpvs, r_lockvisibility, r_q3bsp_renderskydepth, R_ReplaceWorldTexture_f(), r_useportalculling, r_usesurfaceculling, r_vis_trace, r_vis_trace_delay, r_vis_trace_enlarge, r_vis_trace_expand, r_vis_trace_eyejitter, r_vis_trace_pad, r_vis_trace_samples, and r_vis_trace_surfaces.

Referenced by Render_Init().

◆ R_BuildLightMap()

void R_BuildLightMap ( const entity_render_t * ent,
msurface_t * surface,
int combine )

Definition at line 50 of file gl_rsurf.c.

51{
52 int smax, tmax, i, size, size3, maps, l;
53 int *bl, scale;
54 unsigned char *lightmap, *out, *stain;
55 model_t *model = ent->model;
56 int *intblocklights;
57 unsigned char *templight;
58
59 smax = (surface->lightmapinfo->extents[0]>>4)+1;
60 tmax = (surface->lightmapinfo->extents[1]>>4)+1;
61 size = smax*tmax;
62 size3 = size*3;
63
66
67 if (cl.buildlightmapmemorysize < size*sizeof(int[3]))
68 {
69 cl.buildlightmapmemorysize = size*sizeof(int[3]);
73 }
74
75 // these both point at the same buffer, templight is only used for final
76 // processing and can replace the intblocklights data as it goes
77 intblocklights = (int *)cl.buildlightmapmemory;
78 templight = (unsigned char *)cl.buildlightmapmemory;
79
80 // update cached lighting info
81 model->brushq1.lightmapupdateflags[surface - model->data_surfaces] = false;
82
83 lightmap = surface->lightmapinfo->samples;
84
85// set to full bright if no light data
86 bl = intblocklights;
87 if (!model->brushq1.lightdata)
88 {
89 for (i = 0;i < size3;i++)
90 bl[i] = 128*256;
91 }
92 else
93 {
94// clear to no light
95 memset(bl, 0, size3*sizeof(*bl));
96
97// add all the lightmaps
98 if (lightmap)
99 for (maps = 0;maps < MAXLIGHTMAPS && surface->lightmapinfo->styles[maps] != 255;maps++, lightmap += size3)
100 for (scale = r_refdef.scene.lightstylevalue[surface->lightmapinfo->styles[maps]], i = 0;i < size3;i++)
101 bl[i] += lightmap[i] * scale;
102 }
103
104 stain = surface->lightmapinfo->stainsamples;
105 bl = intblocklights;
106 out = templight;
107 // the >> 16 shift adjusts down 8 bits to account for the stainmap
108 // scaling, and remaps the 0-65536 (2x overbright) to 0-256, it will
109 // be doubled during rendering to achieve 2x overbright
110 // (0 = 0.0, 128 = 1.0, 256 = 2.0)
111 if (stain)
112 {
113 for (i = 0;i < size;i++, bl += 3, stain += 3, out += 4)
114 {
115 l = (bl[0] * stain[0]) >> 16;out[2] = min(l, 255);
116 l = (bl[1] * stain[1]) >> 16;out[1] = min(l, 255);
117 l = (bl[2] * stain[2]) >> 16;out[0] = min(l, 255);
118 out[3] = 255;
119 }
120 }
121 else
122 {
123 for (i = 0;i < size;i++, bl += 3, out += 4)
124 {
125 l = bl[0] >> 8;out[2] = min(l, 255);
126 l = bl[1] >> 8;out[1] = min(l, 255);
127 l = bl[2] >> 8;out[0] = min(l, 255);
128 out[3] = 255;
129 }
130 }
131
133 Image_MakesRGBColorsFromLinear_Lightmap(templight, templight, size);
134 R_UpdateTexture(surface->lightmaptexture, templight, surface->lightmapinfo->lightmaporigin[0], surface->lightmapinfo->lightmaporigin[1], 0, smax, tmax, 1, combine);
135
136 // update the surface's deluxemap if it has one
138 {
139 vec3_t n;
140 unsigned char *normalmap = surface->lightmapinfo->nmapsamples;
141 lightmap = surface->lightmapinfo->samples;
142 // clear to no normalmap
143 bl = intblocklights;
144 memset(bl, 0, size3*sizeof(*bl));
145 // add all the normalmaps
146 if (lightmap && normalmap)
147 {
148 for (maps = 0;maps < MAXLIGHTMAPS && surface->lightmapinfo->styles[maps] != 255;maps++, lightmap += size3, normalmap += size3)
149 {
150 for (scale = r_refdef.scene.lightstylevalue[surface->lightmapinfo->styles[maps]], i = 0;i < size;i++)
151 {
152 // add the normalmap with weighting proportional to the style's lightmap intensity
153 l = (int)(VectorLength(lightmap + i*3) * scale);
154 bl[i*3+0] += ((int)normalmap[i*3+0] - 128) * l;
155 bl[i*3+1] += ((int)normalmap[i*3+1] - 128) * l;
156 bl[i*3+2] += ((int)normalmap[i*3+2] - 128) * l;
157 }
158 }
159 }
160 bl = intblocklights;
161 out = templight;
162 // we simply renormalize the weighted normals to get a valid deluxemap
163 for (i = 0;i < size;i++, bl += 3, out += 4)
164 {
165 VectorCopy(bl, n);
167 l = (int)(n[0] * 128 + 128);out[2] = bound(0, l, 255);
168 l = (int)(n[1] * 128 + 128);out[1] = bound(0, l, 255);
169 l = (int)(n[2] * 128 + 128);out[0] = bound(0, l, 255);
170 out[3] = 255;
171 }
173 }
174}
#define MAXLIGHTMAPS
Definition bspfile.h:282
client_state_t cl
Definition cl_main.c:117
client_static_t cls
Definition cl_main.c:116
vector size
string model
float scale
#define n(x, y)
static int(ZEXPORT *qz_inflate)(z_stream *strm
rtexture_t * r_texture_blanknormalmap
Definition gl_rmain.c:272
cvar_t r_q1bsp_lightmap_updates_combine
Definition gl_rmain.c:258
r_refdef_t r_refdef
Definition gl_rmain.c:57
void R_UpdateTexture(rtexture_t *rt, const unsigned char *data, int x, int y, int z, int width, int height, int depth, int combine)
void Image_MakesRGBColorsFromLinear_Lightmap(unsigned char *pout, const unsigned char *pin, int numpixels)
Definition image.c:946
#define min(A, B)
Definition mathlib.h:37
#define VectorNormalize(v)
Definition mathlib.h:104
#define bound(min, num, max)
Definition mathlib.h:34
#define VectorLength(a)
Definition mathlib.h:109
#define VectorCopy(in, out)
Definition mathlib.h:101
int i
vec_t vec3_t[3]
Definition qtypes.h:71
@ r_stat_lightmapupdatepixels
Definition r_stats.h:20
@ r_stat_lightmapupdates
Definition r_stats.h:19
size_t buildlightmapmemorysize
Definition client.h:1132
unsigned char * buildlightmapmemory
Definition client.h:1133
mempool_t * levelmempool
Definition client.h:571
int integer
Definition cvar.h:73
model_t * model
Definition client.h:343
unsigned char * stainsamples
unsigned char styles[MAXLIGHTMAPS]
unsigned char * samples
unsigned char * nmapsamples
msurface_lightmapinfo_t * lightmapinfo
lightmaptexture rebuild information not used in q3bsp
struct rtexture_s * deluxemaptexture
the lighting direction texture fragment to use on the rendering mesh
struct rtexture_s * lightmaptexture
the lightmap texture fragment to use on the rendering mesh
unsigned short lightstylevalue[MAX_LIGHTSTYLES]
8.8 fraction of base light value
Definition render.h:380
int stats[r_stat_count]
Definition render.h:466
r_refdef_scene_t scene
Definition render.h:418
qbool sRGB3D
whether 3D rendering is sRGB corrected (based on sRGBcapable3D)
Definition vid.h:76
cvar_t vid_sRGB_fallback
Definition vid_shared.c:158
cvar_t vid_sRGB
Definition vid_shared.c:157
viddef_t vid
global video state
Definition vid_shared.c:64
#define Mem_Free(mem)
Definition zone.h:96
#define Mem_Alloc(pool, size)
Definition zone.h:92

References bound, client_state_t::buildlightmapmemory, client_state_t::buildlightmapmemorysize, cl, cls, msurface_t::deluxemaptexture, msurface_lightmapinfo_t::extents, i, Image_MakesRGBColorsFromLinear_Lightmap(), int(), cvar_t::integer, client_static_t::levelmempool, msurface_t::lightmapinfo, msurface_lightmapinfo_t::lightmaporigin, msurface_t::lightmaptexture, r_refdef_scene_t::lightstylevalue, MAXLIGHTMAPS, Mem_Alloc, Mem_Free, min, entity_render_t::model, model, n, msurface_lightmapinfo_t::nmapsamples, r_q1bsp_lightmap_updates_combine, r_refdef, r_stat_lightmapupdatepixels, r_stat_lightmapupdates, r_texture_blanknormalmap, R_UpdateTexture(), msurface_lightmapinfo_t::samples, scale, r_refdef_t::scene, size, viddef_t::sRGB3D, msurface_lightmapinfo_t::stainsamples, r_refdef_t::stats, msurface_lightmapinfo_t::styles, VectorCopy, VectorLength, VectorNormalize, vid, vid_sRGB, and vid_sRGB_fallback.

Referenced by R_DrawModelSurfaces().

◆ R_DrawPortal_Callback()

static void R_DrawPortal_Callback ( const entity_render_t * ent,
const rtlight_t * rtlight,
int numsurfaces,
int * surfacelist )
static

Definition at line 343 of file gl_rsurf.c.

344{
345 // due to the hacky nature of this function's parameters, this is never
346 // called with a batch, so numsurfaces is always 1, and the surfacelist
347 // contains only a leaf number for coloring purposes
348 const mportal_t *portal = (mportal_t *)ent;
349 qbool isvis;
350 int i, numpoints;
351 float *v;
352 float vertex3f[POLYGONELEMENTS_MAXPOINTS*3];
355 GL_DepthMask(false);
356 GL_DepthRange(0, 1);
358 GL_DepthTest(true);
361
362 numpoints = min(portal->numpoints, POLYGONELEMENTS_MAXPOINTS);
363
364// R_Mesh_ResetTextureState();
365
366 isvis = (portal->here->clusterindex >= 0 && portal->past->clusterindex >= 0 && portal->here->clusterindex != portal->past->clusterindex);
367
368 i = surfacelist[0] >> 1;
369 GL_Color(((i & 0x0007) >> 0) * (1.0f / 7.0f) * r_refdef.view.colorscale,
370 ((i & 0x0038) >> 3) * (1.0f / 7.0f) * r_refdef.view.colorscale,
371 ((i & 0x01C0) >> 6) * (1.0f / 7.0f) * r_refdef.view.colorscale,
372 isvis ? 0.125f : 0.03125f);
373 for (i = 0, v = vertex3f;i < numpoints;i++, v += 3)
374 VectorCopy(portal->points[i].position, v);
375 R_Mesh_PrepareVertices_Generic_Arrays(numpoints, vertex3f, NULL, NULL);
377 R_Mesh_Draw(0, numpoints, 0, numpoints - 2, polygonelement3i, NULL, 0, polygonelement3s, NULL, 0);
378}
void GL_CullFace(int state)
unsigned short polygonelement3s[(POLYGONELEMENTS_MAXPOINTS-2) *3]
Definition gl_backend.c:241
void GL_DepthMask(int state)
int polygonelement3i[(POLYGONELEMENTS_MAXPOINTS-2) *3]
Definition gl_backend.c:240
void R_Mesh_Draw(int firstvertex, int numvertices, int firsttriangle, int numtriangles, const int *element3i, const r_meshbuffer_t *element3i_indexbuffer, int element3i_bufferoffset, const unsigned short *element3s, const r_meshbuffer_t *element3s_indexbuffer, int element3s_bufferoffset)
void GL_DepthTest(int state)
void GL_DepthRange(float nearfrac, float farfrac)
void GL_PolygonOffset(float planeoffset, float depthoffset)
void GL_Color(float cr, float cg, float cb, float ca)
void GL_BlendFunc(int blendfunc1, int blendfunc2)
void R_Mesh_PrepareVertices_Generic_Arrays(int numvertices, const float *vertex3f, const float *color4f, const float *texcoord2f)
void R_EntityMatrix(const matrix4x4_t *matrix)
Definition gl_rmain.c:4417
#define POLYGONELEMENTS_MAXPOINTS
Definition gl_backend.h:15
void R_SetupShader_Generic_NoTexture(qbool usegamma, qbool notrippy)
Definition gl_rmain.c:1488
#define GL_NONE
Definition glquake.h:127
#define CHECKGLERROR
Definition glquake.h:1059
const GLdouble * v
Definition glquake.h:762
#define GL_SRC_ALPHA
Definition glquake.h:79
#define GL_ONE_MINUS_SRC_ALPHA
Definition glquake.h:80
const matrix4x4_t identitymatrix
Definition matrixlib.c:9
#define NULL
Definition qtypes.h:12
bool qbool
Definition qtypes.h:9
int clusterindex
mleaf_t * here
mvertex_t * points
mleaf_t * past
vec3_t position
Definition model_brush.h:43
float polygonoffset
Definition render.h:459
r_refdef_view_t view
Definition render.h:406
float polygonfactor
Definition render.h:458
float colorscale
global RGB color multiplier for rendering
Definition render.h:302

References CHECKGLERROR, mleaf_t::clusterindex, r_refdef_view_t::colorscale, GL_BlendFunc(), GL_Color(), GL_CullFace(), GL_DepthMask(), GL_DepthRange(), GL_DepthTest(), GL_NONE, GL_ONE_MINUS_SRC_ALPHA, GL_PolygonOffset(), GL_SRC_ALPHA, mportal_t::here, i, identitymatrix, min, NULL, mportal_t::numpoints, mportal_t::past, mportal_t::points, polygonelement3i, polygonelement3s, POLYGONELEMENTS_MAXPOINTS, r_refdef_t::polygonfactor, r_refdef_t::polygonoffset, mvertex_t::position, R_EntityMatrix(), R_Mesh_Draw(), R_Mesh_PrepareVertices_Generic_Arrays(), r_refdef, R_SetupShader_Generic_NoTexture(), v, VectorCopy, and r_refdef_t::view.

Referenced by R_DrawPortals().

◆ R_DrawPortals()

void R_DrawPortals ( void )

Definition at line 381 of file gl_rsurf.c.

382{
383 int i, leafnum;
384 mportal_t *portal;
385 float center[3], f;
387 if (model == NULL)
388 return;
389 for (leafnum = 0;leafnum < model->brush.num_leafs;leafnum++)
390 {
392 {
393 //for (portalnum = 0, portal = model->brush.data_portals;portalnum < model->brush.num_portals;portalnum++, portal++)
394 for (portal = model->brush.data_leafs[leafnum].portals;portal;portal = portal->next)
395 {
397 if (!R_CullFrustum(portal->mins, portal->maxs))
398 {
399 VectorClear(center);
400 for (i = 0;i < portal->numpoints;i++)
401 VectorAdd(center, portal->points[i].position, center);
402 f = ixtable[portal->numpoints];
403 VectorScale(center, f, center);
405 }
406 }
407 }
408 }
409}
rsurfacestate_t rsurface
Definition gl_rmain.c:6919
qbool R_CullFrustum(const vec3_t mins, const vec3_t maxs)
Definition gl_rmain.c:3464
static void R_DrawPortal_Callback(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
Definition gl_rsurf.c:343
float ixtable[4096]
Definition mathlib.c:27
#define VectorClear(a)
Definition mathlib.h:97
#define VectorScale(in, scale, out)
Definition mathlib.h:111
#define VectorAdd(a, b, out)
Definition mathlib.h:100
void R_MeshQueue_AddTransparent(dptransparentsortcategory_t category, const vec3_t center, void(*callback)(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist), const entity_render_t *ent, int surfacenumber, const rtlight_t *rtlight)
Definition meshqueue.c:33
@ TRANSPARENTSORT_DISTANCE
Definition r_qshader.h:194
float f
vec3_t mins
struct mportal_s * next
vec3_t maxs
model_t * worldmodel
same as worldentity->model
Definition render.h:358
r_refdef_viewcache_t viewcache
Definition render.h:407
unsigned char * world_leafvisible
Definition render.h:341
const rtlight_t * rtlight
Definition render.h:748

References f, i, ixtable, mportal_t::maxs, mportal_t::mins, model, mportal_t::next, NULL, mportal_t::numpoints, mportal_t::points, POLYGONELEMENTS_MAXPOINTS, mvertex_t::position, R_CullFrustum(), R_DrawPortal_Callback(), R_MeshQueue_AddTransparent(), r_refdef, rsurface, rsurfacestate_t::rtlight, r_refdef_t::scene, TRANSPARENTSORT_DISTANCE, VectorAdd, VectorClear, VectorScale, r_refdef_t::viewcache, r_refdef_viewcache_t::world_leafvisible, and r_refdef_scene_t::worldmodel.

Referenced by R_RenderScene().

◆ R_ListWorldTextures_f()

static void R_ListWorldTextures_f ( cmd_state_t * cmd)
static

Definition at line 1532 of file gl_rsurf.c.

1533{
1534 model_t *m;
1535 texture_t *t;
1536 int i;
1538 {
1539 Con_Printf("There is no worldmodel\n");
1540 return;
1541 }
1543
1544 Con_Print("Worldmodel textures :\n");
1545 for(i=0,t=m->data_textures;i<m->num_textures;i++,t++)
1546 if (t->name[0] && strcasecmp(t->name, "NO TEXTURE FOUND"))
1547 Con_Printf("%s\n", t->name);
1548}
void Con_Print(const char *msg)
Prints to all appropriate console targets, and adds timestamps.
Definition console.c:1504
void Con_Printf(const char *fmt,...)
Prints to all appropriate console targets.
Definition console.c:1514
texture_t * data_textures
char name[64]

References Con_Print(), Con_Printf(), model_t::data_textures, i, texture_t::name, r_refdef, r_refdef_t::scene, and r_refdef_scene_t::worldmodel.

Referenced by GL_Surf_Init().

◆ R_Mod_CompileShadowMap()

void R_Mod_CompileShadowMap ( entity_render_t * ent,
vec3_t relativelightorigin,
vec3_t relativelightdirection,
float lightradius,
int numsurfaces,
const int * surfacelist )

Definition at line 1286 of file gl_rsurf.c.

1287{
1288 model_t *model = ent->model;
1289 msurface_t *surface;
1290 int surfacelistindex;
1291 int sidetotals[6] = { 0, 0, 0, 0, 0, 0 }, sidemasks = 0;
1292 int i;
1293 // FIXME: the sidetotals code incorrectly assumes that static_meshchain is
1294 // a single mesh - to prevent that from crashing (sideoffsets, sidetotals
1295 // exceeding the number of triangles in a single mesh) we have to make sure
1296 // that we make only a single mesh - so over-estimate the size of the mesh
1297 // to match the model.
1298 // bones_was_here: +128 works around BUG https://github.com/DarkPlacesEngine/darkplaces/issues/119
1299 // +64 was enough to start the map without triggering ASan, +96 was enough to also edit the light.
1300 // See also: warning in Mod_ShadowMesh_AddMesh
1301 r_shadow_compilingrtlight->static_meshchain_shadow_shadowmap = Mod_ShadowMesh_Begin(r_main_mempool, model->surfmesh.num_vertices, model->surfmesh.num_triangles + 128);
1302 R_Shadow_PrepareShadowSides(model->surfmesh.num_triangles);
1303 for (surfacelistindex = 0;surfacelistindex < numsurfaces;surfacelistindex++)
1304 {
1305 surface = model->data_surfaces + surfacelist[surfacelistindex];
1306 sidemasks |= R_Shadow_ChooseSidesFromBox(surface->num_firsttriangle, surface->num_triangles, model->surfmesh.data_vertex3f, model->surfmesh.data_element3i, &r_shadow_compilingrtlight->matrix_worldtolight, relativelightorigin, relativelightdirection, r_shadow_compilingrtlight->cullmins, r_shadow_compilingrtlight->cullmaxs, surface->mins, surface->maxs, surface->texture->basematerialflags & MATERIALFLAG_NOSHADOW ? NULL : sidetotals);
1307 }
1308 R_Shadow_ShadowMapFromList(model->surfmesh.num_vertices, model->surfmesh.num_triangles, model->surfmesh.data_vertex3f, model->surfmesh.data_element3i, numshadowsides, sidetotals, shadowsides, shadowsideslist);
1311 for(i = 0;i<6;i++)
1312 if(!sidetotals[i])
1314}
mempool_t * r_main_mempool
Definition gl_rmain.c:42
#define MATERIALFLAG_NOSHADOW
shadowmesh_t * Mod_ShadowMesh_Finish(shadowmesh_t *mesh, qbool createvbo)
shadowmesh_t * Mod_ShadowMesh_Begin(mempool_t *mempool, int maxverts, int maxtriangles)
void R_Shadow_PrepareShadowSides(int numtris)
Definition r_shadow.c:848
int R_Shadow_ChooseSidesFromBox(int firsttriangle, int numtris, const float *invertex3f, const int *elements, const matrix4x4_t *worldtolight, const vec3_t projectorigin, const vec3_t projectdirection, const vec3_t lightmins, const vec3_t lightmaxs, const vec3_t surfacemins, const vec3_t surfacemaxs, int *totals)
Definition r_shadow.c:1058
int numshadowsides
Definition r_shadow.c:83
rtlight_t * r_shadow_compilingrtlight
Definition r_shadow.c:272
unsigned char * shadowsides
Definition r_shadow.c:84
int * shadowsideslist
Definition r_shadow.c:85
void R_Shadow_ShadowMapFromList(int numverts, int numtris, const float *vertex3f, const int *elements, int numsidetris, const int *sidetotals, const unsigned char *sides, const int *sidetris)
Definition r_shadow.c:1162
describes the textures to use on a range of triangles in the model, and mins/maxs (AABB) for culling.
int num_firsttriangle
int num_triangles
range of triangles and vertices in model->surfmesh
texture_t * texture
the texture to use on the surface
vec3_t mins
bounding box for onscreen checks
int static_shadowmap_receivers
masks of all shadowmap sides that have any potential static receivers or casters
Definition client.h:215
int static_shadowmap_casters
Definition client.h:216
vec3_t cullmins
culling
Definition client.h:140
shadowmesh_t * static_meshchain_shadow_shadowmap
optimized and culled mesh to render for world entity shadows
Definition client.h:192
vec3_t cullmaxs
Definition client.h:141
matrix4x4_t matrix_worldtolight
matrix for transforming world coordinates to light filter coordinates
Definition client.h:112
int basematerialflags

References texture_t::basematerialflags, rtlight_t::cullmaxs, rtlight_t::cullmins, i, MATERIALFLAG_NOSHADOW, rtlight_t::matrix_worldtolight, msurface_t::maxs, msurface_t::mins, Mod_ShadowMesh_Begin(), Mod_ShadowMesh_Finish(), entity_render_t::model, model, NULL, msurface_t::num_firsttriangle, msurface_t::num_triangles, numshadowsides, r_main_mempool, R_Shadow_ChooseSidesFromBox(), r_shadow_compilingrtlight, R_Shadow_PrepareShadowSides(), R_Shadow_ShadowMapFromList(), shadowsides, shadowsideslist, rtlight_t::static_meshchain_shadow_shadowmap, rtlight_t::static_shadowmap_casters, rtlight_t::static_shadowmap_receivers, and msurface_t::texture.

Referenced by Mod_DARKPLACESMODEL_Load(), Mod_IDP0_Load(), Mod_IDP2_Load(), Mod_IDP3_Load(), Mod_INTERQUAKEMODEL_Load(), Mod_OBJ_Load(), Mod_PSKMODEL_Load(), Mod_Q1BSP_Load(), Mod_Q2BSP_Load(), Mod_Q3BSP_Load(), Mod_VBSP_Load(), and Mod_ZYMOTICMODEL_Load().

◆ R_Mod_Draw()

void R_Mod_Draw ( entity_render_t * ent)

Definition at line 637 of file gl_rsurf.c.

638{
639 model_t *model = ent->model;
640 if (model == NULL)
641 return;
642 R_DrawModelSurfaces(ent, false, true, false, false, false, false);
643}
void R_DrawModelSurfaces(entity_render_t *ent, qbool skysurfaces, qbool writedepth, qbool depthonly, qbool debug, qbool prepass, qbool ui)
Definition gl_rmain.c:9970

References entity_render_t::model, model, NULL, and R_DrawModelSurfaces().

Referenced by Mod_DARKPLACESMODEL_Load(), Mod_IDP0_Load(), Mod_IDP2_Load(), Mod_IDP3_Load(), Mod_INTERQUAKEMODEL_Load(), Mod_Mesh_Create(), Mod_OBJ_Load(), Mod_PSKMODEL_Load(), Mod_Q1BSP_Load(), Mod_Q2BSP_Load(), Mod_Q3BSP_Load(), Mod_VBSP_Load(), and Mod_ZYMOTICMODEL_Load().

◆ R_Mod_DrawAddWaterPlanes()

void R_Mod_DrawAddWaterPlanes ( entity_render_t * ent)

Definition at line 603 of file gl_rsurf.c.

604{
605 int i, n, flagsmask;
606 model_t *model = ent->model;
607 msurface_t *surfaces;
608 if (model == NULL)
609 return;
610
611 RSurf_ActiveModelEntity(ent, true, false, false);
612
613 surfaces = model->data_surfaces;
615
616 // add visible surfaces to draw list
617 if (ent == r_refdef.scene.worldentity)
618 {
619 for (i = model->submodelsurfaces_start;i < model->submodelsurfaces_end;i++)
621 if (surfaces[i].texture->basematerialflags & flagsmask)
622 R_Water_AddWaterPlane(surfaces + i, 0);
623 }
624 else
625 {
626 if(ent->entitynumber >= MAX_EDICTS) // && CL_VM_TransformView(ent->entitynumber - MAX_EDICTS, NULL, NULL, NULL))
627 n = ent->entitynumber;
628 else
629 n = 0;
630 for (i = model->submodelsurfaces_start;i < model->submodelsurfaces_end;i++)
631 if (surfaces[i].texture->basematerialflags & flagsmask)
632 R_Water_AddWaterPlane(surfaces + i, n);
633 }
634 rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveModelEntity
635}
void R_Water_AddWaterPlane(msurface_t *surface, int entno)
Definition gl_rmain.c:4640
void RSurf_ActiveModelEntity(const entity_render_t *ent, qbool wantnormals, qbool wanttangents, qbool prepass)
Definition gl_rmain.c:6921
GLenum GLenum GLuint texture
Definition glquake.h:613
#define MATERIALFLAG_REFRACTION
#define MATERIALFLAG_WATERSHADER
#define MATERIALFLAG_CAMERA
#define MATERIALFLAG_REFLECTION
#define MAX_EDICTS
max number of objects in game world at once (32768 protocol limit)
Definition qdefs.h:105
entity_render_t * worldentity
the world
Definition render.h:355
unsigned char * world_surfacevisible
Definition render.h:342
entity_render_t * entity
Definition render.h:767

References rsurfacestate_t::entity, entity_render_t::entitynumber, i, MATERIALFLAG_CAMERA, MATERIALFLAG_REFLECTION, MATERIALFLAG_REFRACTION, MATERIALFLAG_WATERSHADER, MAX_EDICTS, entity_render_t::model, model, n, NULL, r_refdef, R_Water_AddWaterPlane(), RSurf_ActiveModelEntity(), rsurface, r_refdef_t::scene, texture, r_refdef_t::viewcache, r_refdef_viewcache_t::world_surfacevisible, and r_refdef_scene_t::worldentity.

Referenced by Mod_Mesh_AddSurface(), and Mod_SetDrawSkyAndWater().

◆ R_Mod_DrawDebug()

◆ R_Mod_DrawDepth()

void R_Mod_DrawDepth ( entity_render_t * ent)

Definition at line 645 of file gl_rsurf.c.

646{
647 model_t *model = ent->model;
648 if (model == NULL || model->surfmesh.isanimated)
649 return;
650 GL_ColorMask(0,0,0,0);
651 GL_Color(1,1,1,1);
652 GL_DepthTest(true);
654 GL_DepthMask(true);
655// R_Mesh_ResetTextureState();
656 R_DrawModelSurfaces(ent, false, false, true, false, false, false);
658}
void GL_ColorMask(int r, int g, int b, int a)
#define GL_ZERO
Definition glquake.h:73
#define GL_ONE
Definition glquake.h:74
int colormask[4]
which color components to allow (for anaglyph glasses)
Definition render.h:299

References r_refdef_view_t::colormask, GL_BlendFunc(), GL_Color(), GL_ColorMask(), GL_DepthMask(), GL_DepthTest(), GL_ONE, GL_ZERO, entity_render_t::model, model, NULL, R_DrawModelSurfaces(), r_refdef, and r_refdef_t::view.

Referenced by Mod_DARKPLACESMODEL_Load(), Mod_IDP0_Load(), Mod_IDP2_Load(), Mod_IDP3_Load(), Mod_INTERQUAKEMODEL_Load(), Mod_Mesh_Create(), Mod_OBJ_Load(), Mod_PSKMODEL_Load(), Mod_Q1BSP_Load(), Mod_Q2BSP_Load(), Mod_Q3BSP_Load(), Mod_VBSP_Load(), and Mod_ZYMOTICMODEL_Load().

◆ R_Mod_DrawLight()

void R_Mod_DrawLight ( entity_render_t * ent,
int numsurfaces,
const int * surfacelist,
const unsigned char * lighttrispvs )

Definition at line 1399 of file gl_rsurf.c.

1400{
1401 model_t *model = ent->model;
1402 const msurface_t *surface;
1403 int i, k, kend, l, endsurface, batchnumsurfaces, texturenumsurfaces;
1404 const msurface_t **texturesurfacelist;
1405 texture_t *tex;
1408 // this is a double loop because non-visible surface skipping has to be
1409 // fast, and even if this is not the world model (and hence no visibility
1410 // checking) the input surface list and batch buffer are different formats
1411 // so some processing is necessary. (luckily models have few surfaces)
1412 for (i = 0;i < numsurfaces;)
1413 {
1414 batchnumsurfaces = 0;
1415 endsurface = min(i + RSURF_MAX_BATCHSURFACES, numsurfaces);
1416 if (ent == r_refdef.scene.worldentity)
1417 {
1418 for (;i < endsurface;i++)
1419 if (r_refdef.viewcache.world_surfacevisible[surfacelist[i]])
1420 batchsurfacelist[batchnumsurfaces++] = model->data_surfaces + surfacelist[i];
1421 }
1422 else
1423 {
1424 for (;i < endsurface;i++)
1425 batchsurfacelist[batchnumsurfaces++] = model->data_surfaces + surfacelist[i];
1426 }
1427 if (!batchnumsurfaces)
1428 continue;
1429 for (k = 0;k < batchnumsurfaces;k = kend)
1430 {
1431 surface = batchsurfacelist[k];
1432 tex = surface->texture;
1434 // gather surfaces into a batch range
1435 for (kend = k;kend < batchnumsurfaces && tex == batchsurfacelist[kend]->texture;kend++)
1436 ;
1437 // now figure out what to do with this particular range of surfaces
1438 // VorteX: added MATERIALFLAG_NORTLIGHT
1440 continue;
1442 continue;
1444 {
1445 vec3_t tempcenter, center;
1446 for (l = k;l < kend;l++)
1447 {
1448 surface = batchsurfacelist[l];
1450 {
1451 tempcenter[0] = bound(surface->mins[0], rsurface.localvieworigin[0], surface->maxs[0]);
1452 tempcenter[1] = bound(surface->mins[1], rsurface.localvieworigin[1], surface->maxs[1]);
1453 tempcenter[2] = bound(surface->mins[2], rsurface.localvieworigin[2], surface->maxs[2]);
1454 }
1455 else
1456 {
1457 tempcenter[0] = (surface->mins[0] + surface->maxs[0]) * 0.5f;
1458 tempcenter[1] = (surface->mins[1] + surface->maxs[1]) * 0.5f;
1459 tempcenter[2] = (surface->mins[2] + surface->maxs[2]) * 0.5f;
1460 }
1461 Matrix4x4_Transform(&rsurface.matrix, tempcenter, center);
1462 if (ent->transparent_offset) // transparent offset
1463 {
1464 center[0] += r_refdef.view.forward[0]*ent->transparent_offset;
1465 center[1] += r_refdef.view.forward[1]*ent->transparent_offset;
1466 center[2] += r_refdef.view.forward[2]*ent->transparent_offset;
1467 }
1469 }
1470 continue;
1471 }
1473 continue;
1474 texturenumsurfaces = kend - k;
1475 texturesurfacelist = batchsurfacelist + k;
1476 R_Shadow_RenderLighting(texturenumsurfaces, texturesurfacelist);
1477 }
1478 }
1480}
void R_FrameData_SetMark(void)
set a marker that allows you to discard the following temporary memory allocations
Definition gl_rmain.c:3581
void R_FrameData_ReturnToMark(void)
discard recent memory allocations (rewind to marker)
Definition gl_rmain.c:3588
r_framebufferstate_t r_fb
Definition gl_rmain.c:265
cvar_t r_transparent_sortsurfacesbynearest
Definition gl_rmain.c:80
texture_t * R_GetCurrentTexture(texture_t *t)
Definition gl_rmain.c:6549
#define RSURF_MAX_BATCHSURFACES
Definition gl_rsurf.c:1316
qbool r_shadow_usingdeferredprepass
Definition r_shadow.c:64
static void R_Q1BSP_DrawLight_TransparentCallback(const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
Definition gl_rsurf.c:1368
static const msurface_t * batchsurfacelist[RSURF_MAX_BATCHSURFACES]
Definition gl_rsurf.c:1318
void Matrix4x4_Transform(const matrix4x4_t *in, const float v[3], float out[3])
Definition matrixlib.c:1657
#define MATERIALFLAGMASK_DEPTHSORTED
#define MATERIALFLAG_NODEPTHTEST
Definition model_brush.h:83
#define MATERIALFLAG_WALL
Definition model_brush.h:89
#define MATERIALFLAG_NORTLIGHT
#define RENDER_WORLDOBJECT
Definition protocol.h:362
@ TRANSPARENTSORT_SKY
Definition r_qshader.h:193
@ TRANSPARENTSORT_HUD
Definition r_qshader.h:195
void R_Shadow_RenderLighting(int texturenumsurfaces, const msurface_t **texturesurfacelist)
Definition r_shadow.c:2936
float transparent_offset
Definition client.h:340
r_waterstate_t water
Definition render.h:898
vec3_t forward
Definition render.h:268
qbool renderingscene
Definition render.h:876
vec3_t localvieworigin
Definition render.h:728
const msurface_t * modelsurfaces
Definition render.h:658
matrix4x4_t matrix
Definition render.h:719
texture_t * texture
Definition render.h:733
dptransparentsortcategory_t transparentsort
int currentmaterialflags

References batchsurfacelist, bound, CHECKGLERROR, texture_t::currentmaterialflags, rsurfacestate_t::entity, entity_render_t::flags, r_refdef_view_t::forward, i, cvar_t::integer, rsurfacestate_t::localvieworigin, MATERIALFLAG_CAMERA, MATERIALFLAG_NODEPTHTEST, MATERIALFLAG_NORTLIGHT, MATERIALFLAG_REFLECTION, MATERIALFLAG_REFRACTION, MATERIALFLAG_WALL, MATERIALFLAG_WATERSHADER, MATERIALFLAGMASK_DEPTHSORTED, rsurfacestate_t::matrix, Matrix4x4_Transform(), msurface_t::maxs, min, msurface_t::mins, entity_render_t::model, model, rsurfacestate_t::modelsurfaces, r_fb, R_FrameData_ReturnToMark(), R_FrameData_SetMark(), R_GetCurrentTexture(), R_MeshQueue_AddTransparent(), R_Q1BSP_DrawLight_TransparentCallback(), r_refdef, R_Shadow_RenderLighting(), r_shadow_usingdeferredprepass, r_transparent_sortsurfacesbynearest, RENDER_WORLDOBJECT, r_waterstate_t::renderingscene, RSURF_MAX_BATCHSURFACES, rsurface, rsurfacestate_t::rtlight, r_refdef_t::scene, msurface_t::texture, rsurfacestate_t::texture, entity_render_t::transparent_offset, texture_t::transparentsort, TRANSPARENTSORT_HUD, TRANSPARENTSORT_SKY, r_refdef_t::view, r_refdef_t::viewcache, r_framebufferstate_t::water, r_refdef_viewcache_t::world_surfacevisible, and r_refdef_scene_t::worldentity.

Referenced by Mod_DARKPLACESMODEL_Load(), Mod_IDP0_Load(), Mod_IDP2_Load(), Mod_IDP3_Load(), Mod_INTERQUAKEMODEL_Load(), Mod_Mesh_Create(), Mod_OBJ_Load(), Mod_PSKMODEL_Load(), Mod_Q1BSP_Load(), Mod_Q2BSP_Load(), Mod_Q3BSP_Load(), Mod_VBSP_Load(), and Mod_ZYMOTICMODEL_Load().

◆ R_Mod_DrawPrepass()

◆ R_Mod_DrawShadowMap()

void R_Mod_DrawShadowMap ( int side,
entity_render_t * ent,
const vec3_t relativelightorigin,
const vec3_t relativelightdirection,
float lightradius,
int modelnumsurfaces,
const int * modelsurfacelist,
const unsigned char * surfacesides,
const vec3_t lightmins,
const vec3_t lightmaxs )

Definition at line 1320 of file gl_rsurf.c.

1321{
1322 model_t *model = ent->model;
1323 const msurface_t *surface;
1324 int modelsurfacelistindex, batchnumsurfaces;
1325 // check the box in modelspace, it was already checked in worldspace
1326 if (!BoxesOverlap(model->normalmins, model->normalmaxs, lightmins, lightmaxs))
1327 return;
1329 // identify lit faces within the bounding box
1330 for (modelsurfacelistindex = 0;modelsurfacelistindex < modelnumsurfaces;modelsurfacelistindex++)
1331 {
1332 surface = model->data_surfaces + modelsurfacelist[modelsurfacelistindex];
1333 if (surfacesides && !(surfacesides[modelsurfacelistindex] & (1 << side)))
1334 continue;
1337 continue;
1338 if (!BoxesOverlap(lightmins, lightmaxs, surface->mins, surface->maxs))
1339 continue;
1342 batchsurfacelist[0] = surface;
1343 batchnumsurfaces = 1;
1344 while(++modelsurfacelistindex < modelnumsurfaces && batchnumsurfaces < RSURF_MAX_BATCHSURFACES)
1345 {
1346 surface = model->data_surfaces + modelsurfacelist[modelsurfacelistindex];
1347 if (surfacesides && !(surfacesides[modelsurfacelistindex] & (1 << side)))
1348 continue;
1349 if (surface->texture != batchsurfacelist[0]->texture)
1350 break;
1351 if (!BoxesOverlap(lightmins, lightmaxs, surface->mins, surface->maxs))
1352 continue;
1355 batchsurfacelist[batchnumsurfaces++] = surface;
1356 }
1357 --modelsurfacelistindex;
1362 }
1364}
void R_Mesh_PrepareVertices_Vertex3f(int numvertices, const float *vertex3f, const r_meshbuffer_t *vertexbuffer, int bufferoffset)
void RSurf_PrepareVerticesForBatch(int batchneed, int texturenumsurfaces, const msurface_t **texturesurfacelist)
Definition gl_rmain.c:7388
void RSurf_DrawBatch(void)
Definition gl_rmain.c:8477
#define BoxesOverlap(a, b, c, d)
Definition mathlib.h:122
#define MATERIALFLAG_NOCULLFACE
@ r_stat_lights_dynamicshadowtriangles
Definition r_stats.h:32
@ r_stat_lights_shadowtriangles
Definition r_stats.h:31
#define BATCHNEED_ALLOWMULTIDRAW
Definition render.h:795
#define BATCHNEED_ARRAY_VERTEX
Definition render.h:785
int cullface_back
Definition render.h:318
int batchvertex3f_bufferoffset
Definition render.h:675
int batchnumvertices
Definition render.h:670
const r_meshbuffer_t * batchvertex3f_vertexbuffer
Definition render.h:674
float * batchvertex3f
Definition render.h:673

References BATCHNEED_ALLOWMULTIDRAW, BATCHNEED_ARRAY_VERTEX, rsurfacestate_t::batchnumvertices, batchsurfacelist, rsurfacestate_t::batchvertex3f, rsurfacestate_t::batchvertex3f_bufferoffset, rsurfacestate_t::batchvertex3f_vertexbuffer, BoxesOverlap, r_refdef_view_t::cullface_back, texture_t::currentmaterialflags, GL_CullFace(), GL_NONE, MATERIALFLAG_NOCULLFACE, MATERIALFLAG_NOSHADOW, msurface_t::maxs, msurface_t::mins, entity_render_t::model, model, msurface_t::num_triangles, R_FrameData_ReturnToMark(), R_FrameData_SetMark(), R_GetCurrentTexture(), R_Mesh_PrepareVertices_Vertex3f(), r_refdef, r_stat_lights_dynamicshadowtriangles, r_stat_lights_shadowtriangles, RSurf_DrawBatch(), RSURF_MAX_BATCHSURFACES, RSurf_PrepareVerticesForBatch(), rsurface, r_refdef_t::stats, msurface_t::texture, rsurfacestate_t::texture, and r_refdef_t::view.

Referenced by Mod_DARKPLACESMODEL_Load(), Mod_IDP0_Load(), Mod_IDP2_Load(), Mod_IDP3_Load(), Mod_INTERQUAKEMODEL_Load(), Mod_Mesh_Create(), Mod_OBJ_Load(), Mod_PSKMODEL_Load(), Mod_Q1BSP_Load(), Mod_Q2BSP_Load(), Mod_Q3BSP_Load(), Mod_VBSP_Load(), and Mod_ZYMOTICMODEL_Load().

◆ R_Mod_DrawSky()

void R_Mod_DrawSky ( entity_render_t * ent)

Definition at line 596 of file gl_rsurf.c.

597{
598 if (ent->model == NULL)
599 return;
600 R_DrawModelSurfaces(ent, true, true, false, false, false, false);
601}

References entity_render_t::model, NULL, and R_DrawModelSurfaces().

Referenced by Mod_Mesh_AddSurface(), and Mod_SetDrawSkyAndWater().

◆ R_Mod_GetLightInfo()

void R_Mod_GetLightInfo ( entity_render_t * ent,
vec3_t relativelightorigin,
float lightradius,
vec3_t outmins,
vec3_t outmaxs,
int * outleaflist,
unsigned char * outleafpvs,
int * outnumleafspointer,
int * outsurfacelist,
unsigned char * outsurfacepvs,
int * outnumsurfacespointer,
unsigned char * outshadowtrispvs,
unsigned char * outlighttrispvs,
unsigned char * visitingleafpvs,
int numfrustumplanes,
const mplane_t * frustumplanes,
qbool noocclusion )

Definition at line 1202 of file gl_rsurf.c.

1203{
1206 info.noocclusion = noocclusion || !info.frontsidecasting;
1207 VectorCopy(relativelightorigin, info.relativelightorigin);
1208 info.lightradius = lightradius;
1209 info.lightmins[0] = info.relativelightorigin[0] - info.lightradius;
1210 info.lightmins[1] = info.relativelightorigin[1] - info.lightradius;
1211 info.lightmins[2] = info.relativelightorigin[2] - info.lightradius;
1212 info.lightmaxs[0] = info.relativelightorigin[0] + info.lightradius;
1213 info.lightmaxs[1] = info.relativelightorigin[1] + info.lightradius;
1214 info.lightmaxs[2] = info.relativelightorigin[2] + info.lightradius;
1215 if (ent->model == NULL)
1216 {
1217 VectorCopy(info.lightmins, outmins);
1218 VectorCopy(info.lightmaxs, outmaxs);
1219 *outnumleafspointer = 0;
1220 *outnumsurfacespointer = 0;
1221 return;
1222 }
1223 info.model = ent->model;
1224 info.outleaflist = outleaflist;
1225 info.outleafpvs = outleafpvs;
1226 info.outnumleafs = 0;
1227 info.visitingleafpvs = visitingleafpvs;
1228 info.outsurfacelist = outsurfacelist;
1229 info.outsurfacepvs = outsurfacepvs;
1230 info.outshadowtrispvs = outshadowtrispvs;
1231 info.outlighttrispvs = outlighttrispvs;
1232 info.outnumsurfaces = 0;
1233 info.numfrustumplanes = numfrustumplanes;
1234 info.frustumplanes = frustumplanes;
1237 memset(visitingleafpvs, 0, (info.model->brush.num_leafs + 7) >> 3);
1238 memset(outleafpvs, 0, (info.model->brush.num_leafs + 7) >> 3);
1239 memset(outsurfacepvs, 0, (info.model->num_surfaces + 7) >> 3);
1240 memset(outshadowtrispvs, 0, (info.model->surfmesh.num_triangles + 7) >> 3);
1241 memset(outlighttrispvs, 0, (info.model->surfmesh.num_triangles + 7) >> 3);
1242 if (info.model->brush.GetPVS && !info.noocclusion)
1243 info.pvs = info.model->brush.GetPVS(info.model, info.relativelightorigin);
1244 else
1245 info.pvs = NULL;
1246 RSurf_ActiveModelEntity(r_refdef.scene.worldentity, false, false, false);
1247
1249 {
1250 // use portal recursion for exact light volume culling, and exact surface checking
1252 }
1254 {
1255 // use portal recursion for exact light volume culling, but not the expensive exact surface checking
1257 }
1258 else
1259 {
1260 // recurse the bsp tree, checking leafs and surfaces for visibility
1261 // optionally using svbsp for exact culling of compiled lights
1262 // (or if the user enables dlight svbsp culling, which is mostly for
1263 // debugging not actual use)
1265 }
1266
1267 rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveModelEntity
1268
1269 // limit combined leaf box to light boundaries
1270 outmins[0] = max(info.outmins[0] - 1, info.lightmins[0]);
1271 outmins[1] = max(info.outmins[1] - 1, info.lightmins[1]);
1272 outmins[2] = max(info.outmins[2] - 1, info.lightmins[2]);
1273 outmaxs[0] = min(info.outmaxs[0] + 1, info.lightmaxs[0]);
1274 outmaxs[1] = min(info.outmaxs[1] + 1, info.lightmaxs[1]);
1275 outmaxs[2] = min(info.outmaxs[2] + 1, info.lightmaxs[2]);
1276
1277 *outnumleafspointer = info.outnumleafs;
1278 *outnumsurfacespointer = info.outnumsurfaces;
1279
1280 // now sort surfaces by texture for faster rendering
1284}
static msurface_t * r_q1bsp_getlightinfo_surfaces
Definition gl_rsurf.c:1185
static int R_Q1BSP_GetLightInfo_comparefunc(const void *ap, const void *bp)
Definition gl_rsurf.c:1187
cvar_t r_shadow_sortsurfaces
Definition r_shadow.c:188
static void R_Q1BSP_CallRecursiveGetLightInfo(r_q1bsp_getlightinfo_t *info, qbool use_svbsp)
Definition gl_rsurf.c:1100
#define max(A, B)
Definition mathlib.h:38
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 portals.c:423
cvar_t r_shadow_realtime_world_compileportalculling
Definition r_shadow.c:170
cvar_t r_shadow_realtime_dlight_svbspculling
Definition r_shadow.c:161
cvar_t r_shadow_realtime_world_compilesvbsp
Definition r_shadow.c:169
cvar_t r_shadow_frontsidecasting
Definition r_shadow.c:158
cvar_t r_shadow_realtime_dlight_portalculling
Definition r_shadow.c:162
mportal_t * data_portals
unsigned char *(* GetPVS)(struct model_s *model, const vec3_t p)
model_brush_t brush
surfmesh_t surfmesh
msurface_t * data_surfaces
int num_surfaces
unsigned char * outlighttrispvs
Definition gl_rsurf.c:688
const mplane_t * frustumplanes
Definition gl_rsurf.c:700
unsigned char * outleafpvs
Definition gl_rsurf.c:681
const unsigned char * pvs
Definition gl_rsurf.c:694
unsigned char * outshadowtrispvs
Definition gl_rsurf.c:687
unsigned char * outsurfacepvs
Definition gl_rsurf.c:685
unsigned char * visitingleafpvs
Definition gl_rsurf.c:683
int num_triangles

References model_t::brush, model_brush_t::data_portals, model_t::data_surfaces, rsurfacestate_t::entity, r_q1bsp_getlightinfo_t::frontsidecasting, r_q1bsp_getlightinfo_t::frustumplanes, model_brush_t::GetPVS, cvar_t::integer, r_q1bsp_getlightinfo_t::lightmaxs, r_q1bsp_getlightinfo_t::lightmins, r_q1bsp_getlightinfo_t::lightradius, max, min, entity_render_t::model, r_q1bsp_getlightinfo_t::model, r_q1bsp_getlightinfo_t::noocclusion, NULL, model_brush_t::num_leafs, model_t::num_surfaces, surfmesh_t::num_triangles, r_q1bsp_getlightinfo_t::numfrustumplanes, r_q1bsp_getlightinfo_t::outleaflist, r_q1bsp_getlightinfo_t::outleafpvs, r_q1bsp_getlightinfo_t::outlighttrispvs, r_q1bsp_getlightinfo_t::outmaxs, r_q1bsp_getlightinfo_t::outmins, r_q1bsp_getlightinfo_t::outnumleafs, r_q1bsp_getlightinfo_t::outnumsurfaces, r_q1bsp_getlightinfo_t::outshadowtrispvs, r_q1bsp_getlightinfo_t::outsurfacelist, r_q1bsp_getlightinfo_t::outsurfacepvs, Portal_Visibility(), r_q1bsp_getlightinfo_t::pvs, R_Q1BSP_CallRecursiveGetLightInfo(), R_Q1BSP_GetLightInfo_comparefunc(), r_q1bsp_getlightinfo_surfaces, r_refdef, r_shadow_compilingrtlight, r_shadow_frontsidecasting, r_shadow_realtime_dlight_portalculling, r_shadow_realtime_dlight_svbspculling, r_shadow_realtime_world_compileportalculling, r_shadow_realtime_world_compilesvbsp, r_shadow_sortsurfaces, r_q1bsp_getlightinfo_t::relativelightorigin, RSurf_ActiveModelEntity(), rsurface, r_refdef_t::scene, model_t::surfmesh, VectorCopy, r_q1bsp_getlightinfo_t::visitingleafpvs, and r_refdef_scene_t::worldentity.

Referenced by Mod_Mesh_Create(), Mod_OBJ_Load(), Mod_Q1BSP_Load(), Mod_Q2BSP_Load(), Mod_Q3BSP_Load(), and Mod_VBSP_Load().

◆ R_Q1BSP_CallRecursiveGetLightInfo()

static void R_Q1BSP_CallRecursiveGetLightInfo ( r_q1bsp_getlightinfo_t * info,
qbool use_svbsp )
static

Definition at line 1100 of file gl_rsurf.c.

1101{
1103 if (use_svbsp)
1104 {
1105 float origin[3];
1109 info->svbsp_active = true;
1110 info->svbsp_insertoccluder = true;
1111 for (;;)
1112 {
1115 // if that failed, retry with more nodes
1117 {
1118 // an upper limit is imposed
1119 if (r_svbsp.maxnodes >= 2<<22)
1120 break;
1121 r_svbsp.maxnodes *= 2;
1123 //Mem_Free(r_svbsp.nodes);
1124 //r_svbsp.nodes = (svbsp_node_t*) Mem_Alloc(tempmempool, r_svbsp.maxnodes * sizeof(svbsp_node_t));
1125 }
1126 else
1127 break;
1128 }
1129 // now clear the visibility arrays because we need to redo it
1130 info->outnumleafs = 0;
1131 info->outnumsurfaces = 0;
1132 memset(info->outleafpvs, 0, (info->model->brush.num_leafs + 7) >> 3);
1133 memset(info->outsurfacepvs, 0, (info->model->num_surfaces + 7) >> 3);
1134 memset(info->outshadowtrispvs, 0, (info->model->surfmesh.num_triangles + 7) >> 3);
1135 memset(info->outlighttrispvs, 0, (info->model->surfmesh.num_triangles + 7) >> 3);
1136 }
1137 else
1138 info->svbsp_active = false;
1139
1140 // we HAVE to mark the leaf the light is in as lit, because portals are
1141 // irrelevant to a leaf that the light source is inside of
1142 // (and they are all facing away, too)
1143 {
1144 mnode_t *node = info->model->brush.data_nodes;
1145 mleaf_t *leaf;
1146 while (node->plane)
1147 node = node->children[(node->plane->type < 3 ? info->relativelightorigin[node->plane->type] : DotProduct(info->relativelightorigin,node->plane->normal)) < node->plane->dist];
1148 leaf = (mleaf_t *)node;
1149 info->outmins[0] = min(info->outmins[0], leaf->mins[0]);
1150 info->outmins[1] = min(info->outmins[1], leaf->mins[1]);
1151 info->outmins[2] = min(info->outmins[2], leaf->mins[2]);
1152 info->outmaxs[0] = max(info->outmaxs[0], leaf->maxs[0]);
1153 info->outmaxs[1] = max(info->outmaxs[1], leaf->maxs[1]);
1154 info->outmaxs[2] = max(info->outmaxs[2], leaf->maxs[2]);
1155 if (info->outleafpvs)
1156 {
1157 int leafindex = leaf - info->model->brush.data_leafs;
1158 if (!CHECKPVSBIT(info->outleafpvs, leafindex))
1159 {
1160 SETPVSBIT(info->outleafpvs, leafindex);
1161 info->outleaflist[info->outnumleafs++] = leafindex;
1162 }
1163 }
1164 }
1165
1166 info->svbsp_insertoccluder = false;
1167 // use BIH culling on single leaf maps (generally this only happens if running a model as a map), otherwise use BSP culling to make use of vis data
1169 {
1172 }
1173 else
1175 // we're using temporary framedata memory, so this pointer will be invalid soon, clear it
1176 r_svbsp.nodes = NULL;
1177 if (developer_extra.integer && use_svbsp)
1178 {
1179 Con_DPrintf("GetLightInfo: svbsp built with %i nodes, polygon stats:\n", r_svbsp.numnodes);
1180 Con_DPrintf("occluders: %i accepted, %i rejected, %i fragments accepted, %i fragments rejected.\n", r_svbsp.stat_occluders_accepted, r_svbsp.stat_occluders_rejected, r_svbsp.stat_occluders_fragments_accepted, r_svbsp.stat_occluders_fragments_rejected);
1181 Con_DPrintf("queries : %i accepted, %i rejected, %i fragments accepted, %i fragments rejected.\n", r_svbsp.stat_queries_accepted, r_svbsp.stat_queries_rejected, r_svbsp.stat_queries_fragments_accepted, r_svbsp.stat_queries_fragments_rejected);
1182 }
1183}
void Con_DPrintf(const char *fmt,...)
A Con_Printf that only shows up if the "developer" cvar is set.
Definition console.c:1544
vector origin
void * R_FrameData_Alloc(size_t size)
allocate some temporary memory for your purposes
Definition gl_rmain.c:3539
svbsp_t r_svbsp
shadow volume bsp struct with automatically growing nodes buffer
Definition gl_rmain.c:268
static void R_Q1BSP_RecursiveGetLightInfo_BSP(r_q1bsp_getlightinfo_t *info, qbool skipsurfaces)
Definition gl_rsurf.c:706
static void R_Q1BSP_RecursiveGetLightInfo_BIH(r_q1bsp_getlightinfo_t *info, const bih_t *bih)
Definition gl_rsurf.c:970
cvar_t developer_extra
Definition host.c:49
#define DotProduct(a, b)
Definition mathlib.h:98
#define CHECKPVSBIT(pvs, b)
#define SETPVSBIT(pvs, b)
cvar_t r_shadow_usebihculling
Definition r_shadow.c:145
bih_leaf_t * leafs
Definition bih.h:74
Definition cvar.h:66
vec3_t mins
vec3_t maxs
struct mnode_s * children[2]
mplane_t * plane
mleaf_t * data_leafs
mnode_t * data_nodes
bih_t render_bih
vec3_t normal
Definition model_brush.h:59
vec_t dist
Definition model_brush.h:60
int stat_occluders_fragments_accepted
Definition svbsp.h:40
int numnodes
Definition svbsp.h:26
int stat_occluders_accepted
Definition svbsp.h:38
int ranoutofnodes
Definition svbsp.h:32
int stat_occluders_rejected
Definition svbsp.h:37
int stat_occluders_fragments_rejected
Definition svbsp.h:39
int stat_queries_fragments_rejected
Definition svbsp.h:43
svbsp_node_t * nodes
Definition svbsp.h:30
int stat_queries_rejected
Definition svbsp.h:41
int maxnodes
Definition svbsp.h:28
int stat_queries_fragments_accepted
Definition svbsp.h:44
int stat_queries_accepted
Definition svbsp.h:42
void SVBSP_Init(svbsp_t *b, const float *origin, int maxnodes, svbsp_node_t *nodes)
Definition svbsp.c:99

References model_t::brush, CHECKPVSBIT, mnode_t::children, Con_DPrintf(), model_brush_t::data_leafs, model_brush_t::data_nodes, developer_extra, mplane_t::dist, DotProduct, cvar_t::integer, bih_t::leafs, max, svbsp_t::maxnodes, mleaf_t::maxs, min, mleaf_t::mins, r_q1bsp_getlightinfo_t::model, svbsp_t::nodes, mplane_t::normal, NULL, model_brush_t::num_leafs, model_t::num_surfaces, surfmesh_t::num_triangles, svbsp_t::numnodes, origin, r_q1bsp_getlightinfo_t::outleaflist, r_q1bsp_getlightinfo_t::outleafpvs, r_q1bsp_getlightinfo_t::outlighttrispvs, r_q1bsp_getlightinfo_t::outmaxs, r_q1bsp_getlightinfo_t::outmins, r_q1bsp_getlightinfo_t::outnumleafs, r_q1bsp_getlightinfo_t::outnumsurfaces, r_q1bsp_getlightinfo_t::outshadowtrispvs, r_q1bsp_getlightinfo_t::outsurfacepvs, mnode_t::plane, R_FrameData_Alloc(), R_Q1BSP_RecursiveGetLightInfo_BIH(), R_Q1BSP_RecursiveGetLightInfo_BSP(), r_shadow_usebihculling, r_svbsp, svbsp_t::ranoutofnodes, r_q1bsp_getlightinfo_t::relativelightorigin, model_t::render_bih, SETPVSBIT, svbsp_t::stat_occluders_accepted, svbsp_t::stat_occluders_fragments_accepted, svbsp_t::stat_occluders_fragments_rejected, svbsp_t::stat_occluders_rejected, svbsp_t::stat_queries_accepted, svbsp_t::stat_queries_fragments_accepted, svbsp_t::stat_queries_fragments_rejected, svbsp_t::stat_queries_rejected, model_t::surfmesh, r_q1bsp_getlightinfo_t::svbsp_active, SVBSP_Init(), r_q1bsp_getlightinfo_t::svbsp_insertoccluder, mplane_t::type, and VectorCopy.

Referenced by R_Mod_GetLightInfo().

◆ R_Q1BSP_DrawLight_TransparentCallback()

static void R_Q1BSP_DrawLight_TransparentCallback ( const entity_render_t * ent,
const rtlight_t * rtlight,
int numsurfaces,
int * surfacelist )
static

Definition at line 1368 of file gl_rsurf.c.

1369{
1370 int i, j, endsurface;
1371 texture_t *t;
1372 const msurface_t *surface;
1374 // note: in practice this never actually receives batches
1379 for (i = 0;i < numsurfaces;i = j)
1380 {
1381 j = i + 1;
1382 surface = rsurface.modelsurfaces + surfacelist[i];
1383 t = surface->texture;
1385 endsurface = min(j + BATCHSIZE, numsurfaces);
1386 for (j = i;j < endsurface;j++)
1387 {
1388 surface = rsurface.modelsurfaces + surfacelist[j];
1389 if (t != surface->texture)
1390 break;
1391 R_Shadow_RenderLighting(1, &surface);
1392 }
1393 }
1396}
#define BATCHSIZE
Definition gl_rsurf.c:1366
#define RENDER_NOSELFSHADOW
Definition protocol.h:367
void R_Shadow_RenderMode_Begin(void)
Definition r_shadow.c:1369
void R_Shadow_RenderMode_Lighting(qbool transparent, qbool shadowmapping, qbool noselfshadowpass)
Definition r_shadow.c:1597
void R_Shadow_SetupEntityLight(const entity_render_t *ent)
Definition r_shadow.c:3357
void R_Shadow_RenderMode_ActiveLight(const rtlight_t *rtlight)
Definition r_shadow.c:1404
void R_Shadow_RenderMode_End(void)
Definition r_shadow.c:2872
int shadowmapatlassidesize
size of one side of this light in the shadowmap atlas (for omnidirectional shadowmaps this is the min...
Definition client.h:190

References BATCHSIZE, entity_render_t::flags, i, min, rsurfacestate_t::modelsurfaces, R_FrameData_ReturnToMark(), R_FrameData_SetMark(), R_GetCurrentTexture(), R_Shadow_RenderLighting(), R_Shadow_RenderMode_ActiveLight(), R_Shadow_RenderMode_Begin(), R_Shadow_RenderMode_End(), R_Shadow_RenderMode_Lighting(), R_Shadow_SetupEntityLight(), RENDER_NOSELFSHADOW, rsurface, rtlight_t::shadowmapatlassidesize, msurface_t::texture, and rsurfacestate_t::texture.

Referenced by R_Mod_DrawLight().

◆ R_Q1BSP_GetLightInfo_comparefunc()

static int R_Q1BSP_GetLightInfo_comparefunc ( const void * ap,
const void * bp )
static

Definition at line 1187 of file gl_rsurf.c.

1188{
1189 int a = *(int*)ap;
1190 int b = *(int*)bp;
1193 if (as->texture < bs->texture)
1194 return -1;
1195 if (as->texture > bs->texture)
1196 return 1;
1197 return a - b;
1198}
dp_FragColor b
ret a

References a, b, r_q1bsp_getlightinfo_surfaces, and msurface_t::texture.

Referenced by R_Mod_GetLightInfo().

◆ R_Q1BSP_RecursiveGetLightInfo_BIH()

static void R_Q1BSP_RecursiveGetLightInfo_BIH ( r_q1bsp_getlightinfo_t * info,
const bih_t * bih )
static

Definition at line 970 of file gl_rsurf.c.

971{
972 bih_leaf_t *leaf;
973 bih_node_t *node;
974 int nodenum;
975 int axis;
976 int surfaceindex;
977 int t;
978 int nodeleafindex;
979 int currentmaterialflags;
980 qbool castshadow;
981 qbool noocclusion = info->noocclusion;
982 qbool frontsidecasting = info->frontsidecasting;
983 msurface_t *surface;
984 const int *e;
985 const vec_t *v[3];
986 float v2[3][3];
987 int nodestack[GETLIGHTINFO_MAXNODESTACK];
988 int nodestackpos = 0;
989 // note: because the BSP leafs are not in the BIH tree, the _BSP function
990 // must be called to mark leafs visible for entity culling...
991 // we start at the root node
992 nodestack[nodestackpos++] = bih->rootnode;
993 // we'll be done when the stack is empty
994 while (nodestackpos)
995 {
996 // pop one off the stack to process
997 nodenum = nodestack[--nodestackpos];
998 // node
999 node = bih->nodes + nodenum;
1000 if (node->type == BIH_UNORDERED)
1001 {
1002 for (nodeleafindex = 0;nodeleafindex < BIH_MAXUNORDEREDCHILDREN && node->children[nodeleafindex] >= 0;nodeleafindex++)
1003 {
1004 leaf = bih->leafs + node->children[nodeleafindex];
1005 if (leaf->type != BIH_RENDERTRIANGLE)
1006 continue;
1007#if 1
1008 if (!BoxesOverlap(info->lightmins, info->lightmaxs, leaf->mins, leaf->maxs))
1009 continue;
1010#endif
1011#if 1
1012 if (!r_shadow_compilingrtlight && R_CullBox(leaf->mins, leaf->maxs, info->numfrustumplanes, info->frustumplanes))
1013 continue;
1014#endif
1015 surfaceindex = leaf->surfaceindex;
1016 surface = info->model->data_surfaces + surfaceindex;
1017 currentmaterialflags = R_GetCurrentTexture(surface->texture)->currentmaterialflags;
1018 castshadow = !(currentmaterialflags & MATERIALFLAG_NOSHADOW);
1019 t = leaf->itemindex;
1020 e = info->model->surfmesh.data_element3i + t * 3;
1021 v[0] = info->model->surfmesh.data_vertex3f + e[0] * 3;
1022 v[1] = info->model->surfmesh.data_vertex3f + e[1] * 3;
1023 v[2] = info->model->surfmesh.data_vertex3f + e[2] * 3;
1024 VectorCopy(v[0], v2[0]);
1025 VectorCopy(v[1], v2[1]);
1026 VectorCopy(v[2], v2[2]);
1027 if (info->svbsp_insertoccluder)
1028 {
1029 if (castshadow)
1030 SVBSP_AddPolygon(&r_svbsp, 3, v2[0], true, NULL, NULL, 0);
1031 continue;
1032 }
1033 if (info->svbsp_active && !(SVBSP_AddPolygon(&r_svbsp, 3, v2[0], false, NULL, NULL, 0) & 2))
1034 continue;
1035 // we don't occlude triangles from lighting even
1036 // if they are backfacing, because when using
1037 // shadowmapping they are often not fully occluded
1038 // on the horizon of an edge
1039 SETPVSBIT(info->outlighttrispvs, t);
1040 if (castshadow)
1041 {
1042 if (noocclusion || (currentmaterialflags & MATERIALFLAG_NOCULLFACE))
1043 {
1044 // if the material is double sided we
1045 // can't cull by direction
1046 SETPVSBIT(info->outshadowtrispvs, t);
1047 }
1048 else if (frontsidecasting)
1049 {
1050 // front side casting occludes backfaces,
1051 // so they are completely useless as both
1052 // casters and lit polygons
1053 if (PointInfrontOfTriangle(info->relativelightorigin, v2[0], v2[1], v2[2]))
1054 SETPVSBIT(info->outshadowtrispvs, t);
1055 }
1056 else
1057 {
1058 // back side casting does not occlude
1059 // anything so we can't cull lit polygons
1060 if (!PointInfrontOfTriangle(info->relativelightorigin, v2[0], v2[1], v2[2]))
1061 SETPVSBIT(info->outshadowtrispvs, t);
1062 }
1063 }
1064 if (!CHECKPVSBIT(info->outsurfacepvs, surfaceindex))
1065 {
1066 SETPVSBIT(info->outsurfacepvs, surfaceindex);
1067 info->outsurfacelist[info->outnumsurfaces++] = surfaceindex;
1068 }
1069 }
1070 }
1071 else
1072 {
1073 axis = node->type - BIH_SPLITX;
1074#if 0
1075 if (!BoxesOverlap(info->lightmins, info->lightmaxs, node->mins, node->maxs))
1076 continue;
1077#endif
1078#if 0
1079 if (!r_shadow_compilingrtlight && R_CullBox(node->mins, node->maxs, rtlight->cached_numfrustumplanes, rtlight->cached_frustumplanes))
1080 continue;
1081#endif
1082 if (info->lightmins[axis] <= node->backmax)
1083 {
1084 if (info->lightmaxs[axis] >= node->frontmin && nodestackpos < GETLIGHTINFO_MAXNODESTACK-1)
1085 nodestack[nodestackpos++] = node->front;
1086 nodestack[nodestackpos++] = node->back;
1087 continue;
1088 }
1089 else if (info->lightmaxs[axis] >= node->frontmin)
1090 {
1091 nodestack[nodestackpos++] = node->front;
1092 continue;
1093 }
1094 else
1095 continue; // light falls between children, nothing here
1096 }
1097 }
1098}
@ BIH_RENDERTRIANGLE
Definition bih.h:31
#define BIH_MAXUNORDEREDCHILDREN
Definition bih.h:9
@ BIH_UNORDERED
Definition bih.h:23
@ BIH_SPLITX
Definition bih.h:20
qbool R_CullBox(const vec3_t mins, const vec3_t maxs, int numplanes, const mplane_t *planes)
Definition gl_rmain.c:3470
#define GETLIGHTINFO_MAXNODESTACK
Definition gl_rsurf.c:704
GLfloat GLfloat GLfloat v2
Definition glquake.h:747
#define PointInfrontOfTriangle(p, a, b, c)
Definition mathlib.h:143
float vec_t
Definition qtypes.h:68
float maxs[3]
Definition bih.h:61
bih_leaftype_t type
Definition bih.h:59
int surfaceindex
Definition bih.h:64
int itemindex
Definition bih.h:65
float mins[3]
Definition bih.h:60
float maxs[3]
Definition bih.h:41
float mins[3]
Definition bih.h:40
float backmax
Definition bih.h:49
int children[BIH_MAXUNORDEREDCHILDREN]
Definition bih.h:52
int front
Definition bih.h:45
bih_nodetype_t type
Definition bih.h:37
int back
Definition bih.h:46
float frontmin
Definition bih.h:48
bih_node_t * nodes
Definition bih.h:77
int rootnode
Definition bih.h:78
int * data_element3i
float * data_vertex3f
int SVBSP_AddPolygon(svbsp_t *b, int numpoints, const float *points, int insertoccluder, void(*fragmentcallback)(void *fragmentcallback_pointer1, int fragmentcallback_number1, svbsp_t *b, int numpoints, const float *points), void *fragmentcallback_pointer1, int fragmentcallback_number1)
Definition svbsp.c:403

References bih_node_t::back, bih_node_t::backmax, BIH_MAXUNORDEREDCHILDREN, BIH_RENDERTRIANGLE, BIH_SPLITX, BIH_UNORDERED, BoxesOverlap, CHECKPVSBIT, bih_node_t::children, texture_t::currentmaterialflags, surfmesh_t::data_element3i, model_t::data_surfaces, surfmesh_t::data_vertex3f, bih_node_t::front, bih_node_t::frontmin, r_q1bsp_getlightinfo_t::frontsidecasting, r_q1bsp_getlightinfo_t::frustumplanes, GETLIGHTINFO_MAXNODESTACK, bih_leaf_t::itemindex, bih_t::leafs, r_q1bsp_getlightinfo_t::lightmaxs, r_q1bsp_getlightinfo_t::lightmins, MATERIALFLAG_NOCULLFACE, MATERIALFLAG_NOSHADOW, bih_leaf_t::maxs, bih_node_t::maxs, bih_leaf_t::mins, bih_node_t::mins, r_q1bsp_getlightinfo_t::model, bih_t::nodes, r_q1bsp_getlightinfo_t::noocclusion, NULL, r_q1bsp_getlightinfo_t::numfrustumplanes, r_q1bsp_getlightinfo_t::outlighttrispvs, r_q1bsp_getlightinfo_t::outnumsurfaces, r_q1bsp_getlightinfo_t::outshadowtrispvs, r_q1bsp_getlightinfo_t::outsurfacelist, r_q1bsp_getlightinfo_t::outsurfacepvs, PointInfrontOfTriangle, R_CullBox(), R_GetCurrentTexture(), r_shadow_compilingrtlight, r_svbsp, r_q1bsp_getlightinfo_t::relativelightorigin, bih_t::rootnode, SETPVSBIT, bih_leaf_t::surfaceindex, model_t::surfmesh, r_q1bsp_getlightinfo_t::svbsp_active, SVBSP_AddPolygon(), r_q1bsp_getlightinfo_t::svbsp_insertoccluder, msurface_t::texture, bih_leaf_t::type, bih_node_t::type, v, v2, and VectorCopy.

Referenced by R_Q1BSP_CallRecursiveGetLightInfo().

◆ R_Q1BSP_RecursiveGetLightInfo_BSP()

static void R_Q1BSP_RecursiveGetLightInfo_BSP ( r_q1bsp_getlightinfo_t * info,
qbool skipsurfaces )
static

Definition at line 706 of file gl_rsurf.c.

707{
708 // nodestack
710 int nodestackpos = 0;
711 // node processing
712 mplane_t *plane;
713 mnode_t *node;
714 int sides;
715 // leaf processing
716 mleaf_t *leaf;
717 const msurface_t *surface;
718 const msurface_t *surfaces = info->model->data_surfaces;
719 int numleafsurfaces;
720 int leafsurfaceindex;
721 int surfaceindex;
722 int triangleindex, t;
723 int currentmaterialflags;
724 qbool castshadow;
725 const int *e;
726 const vec_t *v[3];
727 float v2[3][3];
728 qbool insidebox;
729 qbool noocclusion = info->noocclusion;
730 qbool frontsidecasting = info->frontsidecasting;
731 qbool svbspactive = info->svbsp_active;
732 qbool svbspinsertoccluder = info->svbsp_insertoccluder;
733 const int *leafsurfaceindices;
734 qbool addedtris;
735 int i;
736 mportal_t *portal;
737 static float points[128][3];
738 // push the root node onto our nodestack
739 nodestack[nodestackpos++] = info->model->brush.data_nodes;
740 // we'll be done when the nodestack is empty
741 while (nodestackpos)
742 {
743 // get a node from the stack to process
744 node = nodestack[--nodestackpos];
745 // is it a node or a leaf?
746 plane = node->plane;
747 if (plane)
748 {
749 // node
750#if 0
751 if (!BoxesOverlap(info->lightmins, info->lightmaxs, node->mins, node->maxs))
752 continue;
753#endif
754#if 0
755 if (!r_shadow_compilingrtlight && R_CullBox(node->mins, node->maxs, rtlight->cached_numfrustumplanes, rtlight->cached_frustumplanes))
756 continue;
757#endif
758 // axial planes can be processed much more quickly
759 if (plane->type < 3)
760 {
761 // axial plane
762 if (info->lightmins[plane->type] > plane->dist)
763 nodestack[nodestackpos++] = node->children[0];
764 else if (info->lightmaxs[plane->type] < plane->dist)
765 nodestack[nodestackpos++] = node->children[1];
766 else
767 {
768 // recurse front side first because the svbsp building prefers it
769 if (info->relativelightorigin[plane->type] >= plane->dist)
770 {
771 if (nodestackpos < GETLIGHTINFO_MAXNODESTACK-1)
772 nodestack[nodestackpos++] = node->children[0];
773 nodestack[nodestackpos++] = node->children[1];
774 }
775 else
776 {
777 if (nodestackpos < GETLIGHTINFO_MAXNODESTACK-1)
778 nodestack[nodestackpos++] = node->children[1];
779 nodestack[nodestackpos++] = node->children[0];
780 }
781 }
782 }
783 else
784 {
785 // sloped plane
786 sides = BoxOnPlaneSide(info->lightmins, info->lightmaxs, plane);
787 switch (sides)
788 {
789 default:
790 continue; // ERROR: NAN bounding box!
791 case 1:
792 nodestack[nodestackpos++] = node->children[0];
793 break;
794 case 2:
795 nodestack[nodestackpos++] = node->children[1];
796 break;
797 case 3:
798 // recurse front side first because the svbsp building prefers it
799 if (PlaneDist(info->relativelightorigin, plane) >= 0)
800 {
801 if (nodestackpos < GETLIGHTINFO_MAXNODESTACK-1)
802 nodestack[nodestackpos++] = node->children[0];
803 nodestack[nodestackpos++] = node->children[1];
804 }
805 else
806 {
807 if (nodestackpos < GETLIGHTINFO_MAXNODESTACK-1)
808 nodestack[nodestackpos++] = node->children[1];
809 nodestack[nodestackpos++] = node->children[0];
810 }
811 break;
812 }
813 }
814 }
815 else
816 {
817 // leaf
818 leaf = (mleaf_t *)node;
819#if 1
820 if (!info->noocclusion && info->pvs != NULL && !CHECKPVSBIT(info->pvs, leaf->clusterindex))
821 continue;
822#endif
823#if 1
824 if (!BoxesOverlap(info->lightmins, info->lightmaxs, leaf->mins, leaf->maxs))
825 continue;
826#endif
827#if 1
829 continue;
830#endif
831
832 if (svbspactive)
833 {
834 // we can occlusion test the leaf by checking if all of its portals
835 // are occluded (unless the light is in this leaf - but that was
836 // already handled by the caller)
837 for (portal = leaf->portals;portal;portal = portal->next)
838 {
839 for (i = 0;i < portal->numpoints;i++)
840 VectorCopy(portal->points[i].position, points[i]);
841 if (SVBSP_AddPolygon(&r_svbsp, portal->numpoints, points[0], false, NULL, NULL, 0) & 2)
842 break;
843 }
844 if (leaf->portals && portal == NULL)
845 continue; // no portals of this leaf visible
846 }
847
848 // add this leaf to the reduced light bounds
849 info->outmins[0] = min(info->outmins[0], leaf->mins[0]);
850 info->outmins[1] = min(info->outmins[1], leaf->mins[1]);
851 info->outmins[2] = min(info->outmins[2], leaf->mins[2]);
852 info->outmaxs[0] = max(info->outmaxs[0], leaf->maxs[0]);
853 info->outmaxs[1] = max(info->outmaxs[1], leaf->maxs[1]);
854 info->outmaxs[2] = max(info->outmaxs[2], leaf->maxs[2]);
855
856 // mark this leaf as being visible to the light
857 if (info->outleafpvs)
858 {
859 int leafindex = leaf - info->model->brush.data_leafs;
860 if (!CHECKPVSBIT(info->outleafpvs, leafindex))
861 {
862 SETPVSBIT(info->outleafpvs, leafindex);
863 info->outleaflist[info->outnumleafs++] = leafindex;
864 }
865 }
866
867 // when using BIH, we skip the surfaces here
868 if (skipsurfaces)
869 continue;
870
871 // iterate the surfaces linked by this leaf and check their triangles
872 leafsurfaceindices = leaf->firstleafsurface;
873 numleafsurfaces = leaf->numleafsurfaces;
874 if (svbspinsertoccluder)
875 {
876 for (leafsurfaceindex = 0;leafsurfaceindex < numleafsurfaces;leafsurfaceindex++)
877 {
878 surfaceindex = leafsurfaceindices[leafsurfaceindex];
879 if (CHECKPVSBIT(info->outsurfacepvs, surfaceindex))
880 continue;
881 SETPVSBIT(info->outsurfacepvs, surfaceindex);
882 surface = surfaces + surfaceindex;
883 if (!BoxesOverlap(info->lightmins, info->lightmaxs, surface->mins, surface->maxs))
884 continue;
885 currentmaterialflags = R_GetCurrentTexture(surface->texture)->currentmaterialflags;
886 castshadow = !(currentmaterialflags & MATERIALFLAG_NOSHADOW);
887 if (!castshadow)
888 continue;
889 insidebox = BoxInsideBox(surface->mins, surface->maxs, info->lightmins, info->lightmaxs);
890 for (triangleindex = 0, t = surface->num_firsttriangle, e = info->model->surfmesh.data_element3i + t * 3;triangleindex < surface->num_triangles;triangleindex++, t++, e += 3)
891 {
892 v[0] = info->model->surfmesh.data_vertex3f + e[0] * 3;
893 v[1] = info->model->surfmesh.data_vertex3f + e[1] * 3;
894 v[2] = info->model->surfmesh.data_vertex3f + e[2] * 3;
895 VectorCopy(v[0], v2[0]);
896 VectorCopy(v[1], v2[1]);
897 VectorCopy(v[2], v2[2]);
898 if (insidebox || TriangleBBoxOverlapsBox(v2[0], v2[1], v2[2], info->lightmins, info->lightmaxs))
899 SVBSP_AddPolygon(&r_svbsp, 3, v2[0], true, NULL, NULL, 0);
900 }
901 }
902 }
903 else
904 {
905 for (leafsurfaceindex = 0;leafsurfaceindex < numleafsurfaces;leafsurfaceindex++)
906 {
907 surfaceindex = leafsurfaceindices[leafsurfaceindex];
908 surface = surfaces + surfaceindex;
909 if(!surface->texture)
910 continue;
911 if (CHECKPVSBIT(info->outsurfacepvs, surfaceindex))
912 continue;
913 SETPVSBIT(info->outsurfacepvs, surfaceindex);
914 if (!BoxesOverlap(info->lightmins, info->lightmaxs, surface->mins, surface->maxs))
915 continue;
916 addedtris = false;
917 currentmaterialflags = R_GetCurrentTexture(surface->texture)->currentmaterialflags;
918 castshadow = !(currentmaterialflags & MATERIALFLAG_NOSHADOW);
919 insidebox = BoxInsideBox(surface->mins, surface->maxs, info->lightmins, info->lightmaxs);
920 for (triangleindex = 0, t = surface->num_firsttriangle, e = info->model->surfmesh.data_element3i + t * 3;triangleindex < surface->num_triangles;triangleindex++, t++, e += 3)
921 {
922 v[0] = info->model->surfmesh.data_vertex3f + e[0] * 3;
923 v[1] = info->model->surfmesh.data_vertex3f + e[1] * 3;
924 v[2] = info->model->surfmesh.data_vertex3f + e[2] * 3;
925 VectorCopy(v[0], v2[0]);
926 VectorCopy(v[1], v2[1]);
927 VectorCopy(v[2], v2[2]);
928 if (!insidebox && !TriangleBBoxOverlapsBox(v2[0], v2[1], v2[2], info->lightmins, info->lightmaxs))
929 continue;
930 if (svbspactive && !(SVBSP_AddPolygon(&r_svbsp, 3, v2[0], false, NULL, NULL, 0) & 2))
931 continue;
932 // we don't omit triangles from lighting even if they are
933 // backfacing, because when using shadowmapping they are often
934 // not fully occluded on the horizon of an edge
935 SETPVSBIT(info->outlighttrispvs, t);
936 addedtris = true;
937 if (castshadow)
938 {
939 if (noocclusion || (currentmaterialflags & MATERIALFLAG_NOCULLFACE))
940 {
941 // if the material is double sided we
942 // can't cull by direction
943 SETPVSBIT(info->outshadowtrispvs, t);
944 }
945 else if (frontsidecasting)
946 {
947 // front side casting occludes backfaces,
948 // so they are completely useless as both
949 // casters and lit polygons
950 if (PointInfrontOfTriangle(info->relativelightorigin, v2[0], v2[1], v2[2]))
951 SETPVSBIT(info->outshadowtrispvs, t);
952 }
953 else
954 {
955 // back side casting does not occlude
956 // anything so we can't cull lit polygons
957 if (!PointInfrontOfTriangle(info->relativelightorigin, v2[0], v2[1], v2[2]))
958 SETPVSBIT(info->outshadowtrispvs, t);
959 }
960 }
961 }
962 if (addedtris)
963 info->outsurfacelist[info->outnumsurfaces++] = surfaceindex;
964 }
965 }
966 }
967 }
968}
int BoxOnPlaneSide(const vec3_t emins, const vec3_t emaxs, const mplane_t *p)
Definition mathlib.c:331
#define PlaneDist(point, plane)
Definition mathlib.h:256
#define BoxInsideBox(a, b, c, d)
Definition mathlib.h:123
#define TriangleBBoxOverlapsBox(a, b, c, d, e)
Definition mathlib.h:124
int * firstleafsurface
int numleafsurfaces
struct mportal_s * portals
vec3_t maxs
vec3_t mins

References BoxesOverlap, BoxInsideBox, BoxOnPlaneSide(), model_t::brush, CHECKPVSBIT, mnode_t::children, mleaf_t::clusterindex, texture_t::currentmaterialflags, surfmesh_t::data_element3i, model_brush_t::data_leafs, model_brush_t::data_nodes, model_t::data_surfaces, surfmesh_t::data_vertex3f, mplane_t::dist, mleaf_t::firstleafsurface, r_q1bsp_getlightinfo_t::frontsidecasting, r_q1bsp_getlightinfo_t::frustumplanes, GETLIGHTINFO_MAXNODESTACK, i, r_q1bsp_getlightinfo_t::lightmaxs, r_q1bsp_getlightinfo_t::lightmins, MATERIALFLAG_NOCULLFACE, MATERIALFLAG_NOSHADOW, max, mleaf_t::maxs, mnode_t::maxs, msurface_t::maxs, min, mleaf_t::mins, mnode_t::mins, msurface_t::mins, r_q1bsp_getlightinfo_t::model, mportal_t::next, r_q1bsp_getlightinfo_t::noocclusion, NULL, msurface_t::num_firsttriangle, r_q1bsp_getlightinfo_t::numfrustumplanes, mleaf_t::numleafsurfaces, mportal_t::numpoints, r_q1bsp_getlightinfo_t::outleaflist, r_q1bsp_getlightinfo_t::outleafpvs, r_q1bsp_getlightinfo_t::outlighttrispvs, r_q1bsp_getlightinfo_t::outmaxs, r_q1bsp_getlightinfo_t::outmins, r_q1bsp_getlightinfo_t::outnumleafs, r_q1bsp_getlightinfo_t::outnumsurfaces, r_q1bsp_getlightinfo_t::outshadowtrispvs, r_q1bsp_getlightinfo_t::outsurfacelist, r_q1bsp_getlightinfo_t::outsurfacepvs, mnode_t::plane, PlaneDist, PointInfrontOfTriangle, mportal_t::points, mleaf_t::portals, mvertex_t::position, r_q1bsp_getlightinfo_t::pvs, R_CullBox(), R_GetCurrentTexture(), r_shadow_compilingrtlight, r_svbsp, r_q1bsp_getlightinfo_t::relativelightorigin, SETPVSBIT, model_t::surfmesh, r_q1bsp_getlightinfo_t::svbsp_active, SVBSP_AddPolygon(), r_q1bsp_getlightinfo_t::svbsp_insertoccluder, msurface_t::texture, TriangleBBoxOverlapsBox, mplane_t::type, v, v2, and VectorCopy.

Referenced by R_Q1BSP_CallRecursiveGetLightInfo().

◆ R_ReplaceWorldTexture_f()

static void R_ReplaceWorldTexture_f ( cmd_state_t * cmd)
static

Definition at line 1483 of file gl_rsurf.c.

1484{
1485 model_t *m;
1486 texture_t *t;
1487 int i;
1488 const char *r, *newt;
1489 skinframe_t *skinframe;
1491 {
1492 Con_Printf("There is no worldmodel\n");
1493 return;
1494 }
1496
1497 if(Cmd_Argc(cmd) < 2)
1498 {
1499 Con_Print("r_replacemaptexture <texname> <newtexname> - replaces texture\n");
1500 Con_Print("r_replacemaptexture <texname> - switch back to default texture\n");
1501 return;
1502 }
1503 if(!cl.islocalgame || !cl.worldmodel)
1504 {
1505 Con_Print("This command works only in singleplayer\n");
1506 return;
1507 }
1508 r = Cmd_Argv(cmd, 1);
1509 newt = Cmd_Argv(cmd, 2);
1510 if(!newt[0])
1511 newt = r;
1512 for(i=0,t=m->data_textures;i<m->num_textures;i++,t++)
1513 {
1514 if(/*t->width && !strcasecmp(t->name, r)*/ matchpattern( t->name, r, true ) )
1515 {
1516 if ((skinframe = R_SkinFrame_LoadExternal(newt, TEXF_MIPMAP | TEXF_ALPHA | TEXF_PICMIP, true, false)))
1517 {
1518// t->skinframes[0] = skinframe;
1519 t->currentskinframe = skinframe;
1520 Con_Printf("%s replaced with %s\n", r, newt);
1521 }
1522 else
1523 {
1524 Con_Printf("%s was not found\n", newt);
1525 return;
1526 }
1527 }
1528 }
1529}
static int Cmd_Argc(cmd_state_t *cmd)
Definition cmd.h:249
static const char * Cmd_Argv(cmd_state_t *cmd, int arg)
Cmd_Argv(cmd, ) will return an empty string (not a NULL) if arg > argc, so string operations are alwa...
Definition cmd.h:254
int matchpattern(const char *in, const char *pattern, int caseinsensitive)
Definition filematch.c:16
skinframe_t * R_SkinFrame_LoadExternal(const char *name, int textureflags, qbool complain, qbool fallbacknotexture)
Definition gl_rmain.c:2314
void cmd(string command,...)
#define TEXF_PICMIP
Definition r_textures.h:21
#define TEXF_ALPHA
Definition r_textures.h:9
#define TEXF_MIPMAP
Definition r_textures.h:11
dp_FragColor r
struct model_s * worldmodel
Definition client.h:934
int islocalgame
Definition client.h:746
struct skinframe_s * currentskinframe

References cl, cmd(), Cmd_Argc(), Cmd_Argv(), Con_Print(), Con_Printf(), texture_t::currentskinframe, model_t::data_textures, i, client_state_t::islocalgame, matchpattern(), texture_t::name, r, r_refdef, R_SkinFrame_LoadExternal(), r_refdef_t::scene, TEXF_ALPHA, TEXF_MIPMAP, TEXF_PICMIP, client_state_t::worldmodel, and r_refdef_scene_t::worldmodel.

Referenced by GL_Surf_Init().

◆ R_Stain()

void R_Stain ( const vec3_t origin,
float radius,
int cr1,
int cg1,
int cb1,
int ca1,
int cr2,
int cg2,
int cb2,
int ca2 )

Definition at line 298 of file gl_rsurf.c.

299{
300 int n;
301 float fcolor[8];
302 entity_render_t *ent;
303 model_t *model;
304 vec3_t org;
306 return;
307 fcolor[0] = cr1;
308 fcolor[1] = cg1;
309 fcolor[2] = cb1;
310 fcolor[3] = ca1 * (1.0f / 64.0f);
311 fcolor[4] = cr2 - cr1;
312 fcolor[5] = cg2 - cg1;
313 fcolor[6] = cb2 - cb1;
314 fcolor[7] = (ca2 - ca1) * (1.0f / 64.0f);
315
317
318 // look for embedded bmodels
319 for (n = 0;n < cl.num_brushmodel_entities;n++)
320 {
322 model = ent->model;
323 if (model && model->name[0] == '*')
324 {
325 if (model->brush.data_nodes)
326 {
328 R_StainNode(model->brush.data_nodes + model->brushq1.hulls[0].firstclipnode, model, org, radius, fcolor);
329 }
330 }
331 }
332}
static void R_StainNode(mnode_t *node, model_t *model, const vec3_t origin, float radius, const float fcolor[8])
Definition gl_rsurf.c:176
int num_brushmodel_entities
Definition client.h:1005
int * brushmodel_entities
Definition client.h:999
entity_t * entities
Definition client.h:991
matrix4x4_t inversematrix
Definition client.h:334
entity_render_t render
Definition client.h:477
int firstclipnode
hull_t hulls[MAX_MAP_HULLS]
Definition model_q1bsp.h:26
unsigned char * lightdata
Definition model_q1bsp.h:32
model_brushq1_t brushq1

References model_t::brush, client_state_t::brushmodel_entities, model_t::brushq1, cl, model_brush_t::data_nodes, client_state_t::entities, hull_t::firstclipnode, model_brushq1_t::hulls, entity_render_t::inversematrix, model_brushq1_t::lightdata, Matrix4x4_Transform(), entity_render_t::model, model, n, NULL, client_state_t::num_brushmodel_entities, origin, r_refdef, R_StainNode(), entity_t::render, r_refdef_t::scene, and r_refdef_scene_t::worldmodel.

Referenced by CL_ParticleEffect_Fallback(), CL_ParticleExplosion(), and R_DrawParticles().

◆ R_StainNode()

static void R_StainNode ( mnode_t * node,
model_t * model,
const vec3_t origin,
float radius,
const float fcolor[8] )
static

Definition at line 176 of file gl_rsurf.c.

177{
178 float ndist, a, ratio, maxdist, maxdist2, maxdist3, invradius, sdtable[256], td, dist2;
179 msurface_t *surface, *endsurface;
180 int i, s, t, smax, tmax, smax3, impacts, impactt, stained;
181 unsigned char *bl;
182 vec3_t impact;
183
184 maxdist = radius * radius;
185 invradius = 1.0f / radius;
186
187loc0:
188 if (!node->plane)
189 return;
190 ndist = PlaneDiff(origin, node->plane);
191 if (ndist > radius)
192 {
193 node = node->children[0];
194 goto loc0;
195 }
196 if (ndist < -radius)
197 {
198 node = node->children[1];
199 goto loc0;
200 }
201
202 dist2 = ndist * ndist;
203 maxdist3 = maxdist - dist2;
204
205 if (node->plane->type < 3)
206 {
207 VectorCopy(origin, impact);
208 impact[node->plane->type] -= ndist;
209 }
210 else
211 {
212 impact[0] = origin[0] - node->plane->normal[0] * ndist;
213 impact[1] = origin[1] - node->plane->normal[1] * ndist;
214 impact[2] = origin[2] - node->plane->normal[2] * ndist;
215 }
216
217 for (surface = model->data_surfaces + node->firstsurface, endsurface = surface + node->numsurfaces;surface < endsurface;surface++)
218 {
219 if (surface->lightmapinfo->stainsamples)
220 {
221 smax = (surface->lightmapinfo->extents[0] >> 4) + 1;
222 tmax = (surface->lightmapinfo->extents[1] >> 4) + 1;
223
224 impacts = (int)(DotProduct (impact, surface->lightmapinfo->texinfo->vecs[0]) + surface->lightmapinfo->texinfo->vecs[0][3] - surface->lightmapinfo->texturemins[0]);
225 impactt = (int)(DotProduct (impact, surface->lightmapinfo->texinfo->vecs[1]) + surface->lightmapinfo->texinfo->vecs[1][3] - surface->lightmapinfo->texturemins[1]);
226
227 s = bound(0, impacts, smax * 16) - impacts;
228 t = bound(0, impactt, tmax * 16) - impactt;
229 i = (int)(s * s + t * t + dist2);
230 if ((i > maxdist) || (smax > (int)(sizeof(sdtable)/sizeof(sdtable[0])))) // smax overflow fix from Andreas Dehmel
231 continue;
232
233 // reduce calculations
234 for (s = 0, i = impacts; s < smax; s++, i -= 16)
235 sdtable[s] = i * i + dist2;
236
237 bl = surface->lightmapinfo->stainsamples;
238 smax3 = smax * 3;
239 stained = false;
240
241 i = impactt;
242 for (t = 0;t < tmax;t++, i -= 16)
243 {
244 td = i * i;
245 // make sure some part of it is visible on this line
246 if (td < maxdist3)
247 {
248 maxdist2 = maxdist - td;
249 for (s = 0;s < smax;s++)
250 {
251 if (sdtable[s] < maxdist2)
252 {
253 ratio = lhrandom(0.0f, 1.0f);
254 a = (fcolor[3] + ratio * fcolor[7]) * (1.0f - sqrt(sdtable[s] + td) * invradius);
255 if (a >= (1.0f / 64.0f))
256 {
257 if (a > 1)
258 a = 1;
259 bl[0] = (unsigned char) ((float) bl[0] + a * ((fcolor[0] + ratio * fcolor[4]) - (float) bl[0]));
260 bl[1] = (unsigned char) ((float) bl[1] + a * ((fcolor[1] + ratio * fcolor[5]) - (float) bl[1]));
261 bl[2] = (unsigned char) ((float) bl[2] + a * ((fcolor[2] + ratio * fcolor[6]) - (float) bl[2]));
262 stained = true;
263 }
264 }
265 bl += 3;
266 }
267 }
268 else // skip line
269 bl += smax3;
270 }
271 // force lightmap upload
272 if (stained)
273 model->brushq1.lightmapupdateflags[surface - model->data_surfaces] = true;
274 }
275 }
276
277 if (node->children[0]->plane)
278 {
279 if (node->children[1]->plane)
280 {
281 R_StainNode(node->children[0], model, origin, radius, fcolor);
282 node = node->children[1];
283 goto loc0;
284 }
285 else
286 {
287 node = node->children[0];
288 goto loc0;
289 }
290 }
291 else if (node->children[1]->plane)
292 {
293 node = node->children[1];
294 goto loc0;
295 }
296}
#define lhrandom(MIN, MAX)
LadyHavoc: this function never returns exactly MIN or exactly MAX, because of a QuakeC bug in id1 whe...
Definition mathlib.h:48
#define PlaneDiff(point, plane)
Definition mathlib.h:257
float sqrt(float f)
unsigned int numsurfaces
unsigned int firstsurface
float vecs[2][4]

References a, bound, mnode_t::children, DotProduct, msurface_lightmapinfo_t::extents, mnode_t::firstsurface, i, int(), lhrandom, msurface_t::lightmapinfo, model, mplane_t::normal, mnode_t::numsurfaces, origin, mnode_t::plane, PlaneDiff, R_StainNode(), sqrt(), msurface_lightmapinfo_t::stainsamples, msurface_lightmapinfo_t::texinfo, msurface_lightmapinfo_t::texturemins, mplane_t::type, mtexinfo_t::vecs, and VectorCopy.

Referenced by R_Stain(), and R_StainNode().

◆ R_View_WorldVisibility()

void R_View_WorldVisibility ( qbool forcenovis)

Definition at line 436 of file gl_rsurf.c.

437{
438 int i, j, *mark;
439 mleaf_t *leaf;
440 mleaf_t *viewleaf;
442
443 if (!model)
444 return;
445
447 return;
448
449 // clear the visible surface and leaf flags arrays
450 memset(r_refdef.viewcache.world_surfacevisible, 0, model->num_surfaces);
451 if(!r_lockpvs.integer)
452 memset(r_refdef.viewcache.world_leafvisible, 0, model->brush.num_leafs);
453
455
457 {
458 // simply cull each marked leaf to the frustum (view pyramid)
459 for (j = 0, leaf = model->brush.data_leafs;j < model->brush.num_leafs;j++, leaf++)
460 {
461 // if leaf is in current pvs and on the screen, mark its surfaces
463 {
466 if (leaf->numleafsurfaces)
467 for (i = 0, mark = leaf->firstleafsurface;i < leaf->numleafsurfaces;i++, mark++)
469 }
470 }
471 }
472 else
473 {
474 // if possible find the leaf the view origin is in
475 viewleaf = model->brush.PointInLeaf ? model->brush.PointInLeaf(model, r_refdef.view.origin) : NULL;
476 // if possible fetch the visible cluster bits
477 if (!r_lockpvs.integer && model->brush.FatPVS)
479
480 // if floating around in the void (no pvs data available, and no
481 // portals available), simply use all on-screen leafs.
482 if (!viewleaf || viewleaf->clusterindex < 0 || forcenovis || !r_refdef.view.usevieworiginculling)
483 {
484 // no visibility method: (used when floating around in the void)
485 // simply cull each leaf to the frustum (view pyramid)
486 // similar to quake's RecursiveWorldNode but without cache misses
488 for (j = 0, leaf = model->brush.data_leafs;j < model->brush.num_leafs;j++, leaf++)
489 {
490 if (leaf->clusterindex < 0)
491 continue;
492 // if leaf is in current pvs and on the screen, mark its surfaces
493 if (!R_CullFrustum(leaf->mins, leaf->maxs))
494 {
497 if (leaf->numleafsurfaces)
498 for (i = 0, mark = leaf->firstleafsurface;i < leaf->numleafsurfaces;i++, mark++)
500 }
501 }
502 }
503 // just check if each leaf in the PVS is on screen
504 // (unless portal culling is enabled)
505 else if (!model->brush.data_portals || r_useportalculling.integer < 1 || (r_useportalculling.integer < 2 && !r_novis.integer))
506 {
507 // pvs method:
508 // simply check if each leaf is in the Potentially Visible Set,
509 // and cull to frustum (view pyramid)
510 // similar to quake's RecursiveWorldNode but without cache misses
511 for (j = 0, leaf = model->brush.data_leafs;j < model->brush.num_leafs;j++, leaf++)
512 {
513 if (leaf->clusterindex < 0)
514 continue;
515 // if leaf is in current pvs and on the screen, mark its surfaces
517 {
520 if (leaf->numleafsurfaces)
521 for (i = 0, mark = leaf->firstleafsurface;i < leaf->numleafsurfaces;i++, mark++)
523 }
524 }
525 }
526 // if desired use a recursive portal flow, culling each portal to
527 // frustum and checking if the leaf the portal leads to is in the pvs
528 else
529 {
530 int leafstackpos;
531 mportal_t *p;
532 mleaf_t *leafstack[8192];
533 vec3_t cullmins, cullmaxs;
534 float cullbias = r_nearclip.value * 2.0f; // the nearclip plane can easily end up culling portals in certain perfectly-aligned views, causing view blackouts
535 // simple-frustum portal method:
536 // follows portals leading outward from viewleaf, does not venture
537 // offscreen or into leafs that are not visible, faster than
538 // Quake's RecursiveWorldNode and vastly better in unvised maps,
539 // often culls some surfaces that pvs alone would miss
540 // (such as a room in pvs that is hidden behind a wall, but the
541 // passage leading to the room is off-screen)
542 leafstack[0] = viewleaf;
543 leafstackpos = 1;
544 while (leafstackpos)
545 {
546 leaf = leafstack[--leafstackpos];
547 if (r_refdef.viewcache.world_leafvisible[leaf - model->brush.data_leafs])
548 continue;
549 if (leaf->clusterindex < 0)
550 continue;
552 r_refdef.viewcache.world_leafvisible[leaf - model->brush.data_leafs] = true;
553 // mark any surfaces bounding this leaf
554 if (leaf->numleafsurfaces)
555 for (i = 0, mark = leaf->firstleafsurface;i < leaf->numleafsurfaces;i++, mark++)
557 // follow portals into other leafs
558 // the checks are:
559 // the leaf has not been visited yet
560 // and the leaf is visible in the pvs
561 // the portal polygon's bounding box is on the screen
562 for (p = leaf->portals;p;p = p->next)
563 {
565 if (r_refdef.viewcache.world_leafvisible[p->past - model->brush.data_leafs])
566 continue;
568 continue;
569 cullmins[0] = p->mins[0] - cullbias;
570 cullmins[1] = p->mins[1] - cullbias;
571 cullmins[2] = p->mins[2] - cullbias;
572 cullmaxs[0] = p->maxs[0] + cullbias;
573 cullmaxs[1] = p->maxs[1] + cullbias;
574 cullmaxs[2] = p->maxs[2] + cullbias;
575 if (R_CullFrustum(cullmins, cullmaxs))
576 continue;
578 {
582 continue;
583 }
584 if (leafstackpos >= (int)(sizeof(leafstack) / sizeof(leafstack[0])))
585 break;
586 leafstack[leafstackpos++] = p->past;
587 }
588 }
589 }
590 }
591
592 // Cull the rest
594}
qbool R_CanSeeBox(int numsamples, vec_t eyejitter, vec_t entboxenlarge, vec_t entboxexpand, vec_t pad, vec3_t eye, vec3_t entboxmins, vec3_t entboxmaxs)
Definition gl_rmain.c:3888
cvar_t r_nearclip
Definition gl_rmain.c:76
static void R_View_WorldVisibility_CullSurfaces(void)
Definition gl_rsurf.c:411
host_static_t host
Definition host.c:41
cvar_t r_novis
Definition model_brush.c:31
@ r_stat_world_portals
Definition r_stats.h:16
@ r_stat_world_leafs
Definition r_stats.h:15
float value
Definition cvar.h:74
double realtime
the accumulated mainloop time since application started (with filtering), without any slowmo or clamp...
Definition host.h:46
double tracetime
qbool usecustompvs
uses r_refdef.viewcache.pvsbits as-is rather than computing it
Definition render.h:275
vec3_t origin
Definition render.h:267
int usevieworiginculling
allows visibility culling based on the view origin (e.g.
Definition render.h:286
unsigned char * world_pvsbits
Definition render.h:340
qbool world_novis
if true, the view is currently in a leaf without pvs data
Definition render.h:344

References CHECKPVSBIT, mleaf_t::clusterindex, mleaf_t::firstleafsurface, host, i, cvar_t::integer, mleaf_t::maxs, mportal_t::maxs, mleaf_t::mins, mportal_t::mins, model, mportal_t::next, NULL, mleaf_t::numleafsurfaces, r_refdef_view_t::origin, mportal_t::past, mleaf_t::portals, R_CanSeeBox(), R_CullFrustum(), r_lockpvs, r_lockvisibility, r_main_mempool, r_nearclip, r_novis, r_refdef, r_stat_world_leafs, r_stat_world_portals, r_useportalculling, R_View_WorldVisibility_CullSurfaces(), r_vis_trace, r_vis_trace_delay, r_vis_trace_enlarge, r_vis_trace_expand, r_vis_trace_eyejitter, r_vis_trace_pad, r_vis_trace_samples, host_static_t::realtime, r_refdef_t::scene, r_refdef_t::stats, mportal_t::tracetime, r_refdef_view_t::usecustompvs, r_refdef_view_t::usevieworiginculling, cvar_t::value, r_refdef_t::view, r_refdef_t::viewcache, r_refdef_viewcache_t::world_leafvisible, r_refdef_viewcache_t::world_novis, r_refdef_viewcache_t::world_pvsbits, r_refdef_viewcache_t::world_surfacevisible, and r_refdef_scene_t::worldmodel.

Referenced by R_View_Update().

◆ R_View_WorldVisibility_CullSurfaces()

static void R_View_WorldVisibility_CullSurfaces ( void )
static

Definition at line 411 of file gl_rsurf.c.

412{
413 int surfaceindex;
414 unsigned char *surfacevisible;
415 msurface_t *surfaces;
417 if (!model)
418 return;
419 if (r_trippy.integer)
420 return;
422 return;
423 surfaces = model->data_surfaces;
424 surfacevisible = r_refdef.viewcache.world_surfacevisible;
425 for (surfaceindex = model->submodelsurfaces_start; surfaceindex < model->submodelsurfaces_end; surfaceindex++)
426 {
427 if (surfacevisible[surfaceindex])
428 {
429 if (R_CullFrustum(surfaces[surfaceindex].mins, surfaces[surfaceindex].maxs)
431 surfacevisible[surfaceindex] = 0;
432 }
433 }
434}
vector mins
vector maxs
cvar_t r_trippy
Definition model_brush.c:29

References cvar_t::integer, maxs, msurface_t::maxs, mins, msurface_t::mins, model, r_refdef_view_t::origin, R_CanSeeBox(), R_CullFrustum(), r_refdef, r_trippy, r_usesurfaceculling, r_vis_trace_enlarge, r_vis_trace_expand, r_vis_trace_eyejitter, r_vis_trace_pad, r_vis_trace_samples, r_vis_trace_surfaces, r_refdef_t::scene, cvar_t::value, r_refdef_t::view, r_refdef_t::viewcache, r_refdef_viewcache_t::world_surfacevisible, and r_refdef_scene_t::worldmodel.

Referenced by R_View_WorldVisibility().

Variable Documentation

◆ batchsurfacelist

const msurface_t* batchsurfacelist[RSURF_MAX_BATCHSURFACES]
static

Definition at line 1318 of file gl_rsurf.c.

Referenced by R_Mod_DrawLight(), and R_Mod_DrawShadowMap().

◆ r_ambient

cvar_t r_ambient = {CF_CLIENT, "r_ambient", "0", "brightens map, value is 0-128"}

Definition at line 28 of file gl_rsurf.c.

28{CF_CLIENT, "r_ambient", "0", "brightens map, value is 0-128"};

Referenced by GL_Surf_Init(), and R_UpdateVariables().

◆ r_lockpvs

cvar_t r_lockpvs = {CF_CLIENT, "r_lockpvs", "0", "disables pvs switching, allows you to walk around and inspect what is visible from a given location in the map (anything not visible from your current location will not be drawn)"}

Definition at line 29 of file gl_rsurf.c.

29{CF_CLIENT, "r_lockpvs", "0", "disables pvs switching, allows you to walk around and inspect what is visible from a given location in the map (anything not visible from your current location will not be drawn)"};

Referenced by GL_Surf_Init(), R_View_WorldVisibility(), and R_Water_StartFrame().

◆ r_lockvisibility

cvar_t r_lockvisibility = {CF_CLIENT, "r_lockvisibility", "0", "disables visibility updates, allows you to walk around and inspect what is visible from a given viewpoint in the map (anything offscreen at the moment this is enabled will not be drawn)"}

Definition at line 30 of file gl_rsurf.c.

30{CF_CLIENT, "r_lockvisibility", "0", "disables visibility updates, allows you to walk around and inspect what is visible from a given viewpoint in the map (anything offscreen at the moment this is enabled will not be drawn)"};

Referenced by GL_Surf_Init(), R_View_SetFrustum(), R_View_WorldVisibility(), and R_Water_StartFrame().

◆ r_q1bsp_getlightinfo_surfaces

msurface_t* r_q1bsp_getlightinfo_surfaces
static

Definition at line 1185 of file gl_rsurf.c.

Referenced by R_Mod_GetLightInfo(), and R_Q1BSP_GetLightInfo_comparefunc().

◆ r_q3bsp_renderskydepth

cvar_t r_q3bsp_renderskydepth = {CF_CLIENT, "r_q3bsp_renderskydepth", "0", "draws sky depth masking in q3 maps (as in q1 maps), this means for example that sky polygons can hide other things"}

Definition at line 41 of file gl_rsurf.c.

41{CF_CLIENT, "r_q3bsp_renderskydepth", "0", "draws sky depth masking in q3 maps (as in q1 maps), this means for example that sky polygons can hide other things"};

Referenced by GL_Surf_Init(), and R_DrawTextureSurfaceList_Sky().

◆ r_shadow_sortsurfaces

cvar_t r_shadow_sortsurfaces
extern

Definition at line 188 of file r_shadow.c.

188{CF_CLIENT, "r_shadow_sortsurfaces", "1", "improve performance by sorting illuminated surfaces by texture"};

Referenced by R_Mod_GetLightInfo(), and R_Shadow_Init().

◆ r_shadow_usingdeferredprepass

qbool r_shadow_usingdeferredprepass
extern

Definition at line 64 of file r_shadow.c.

Referenced by R_Mod_DrawLight().

◆ r_useportalculling

cvar_t r_useportalculling = {CF_CLIENT, "r_useportalculling", "1", "improve framerate with r_novis 1 by using portal culling - still not as good as compiled visibility data in the map, but it helps (a value of 2 forces use of this even with vis data, which improves framerates in maps without too much complexity, but hurts in extremely complex maps, which is why 2 is not the default mode)"}

Definition at line 31 of file gl_rsurf.c.

31{CF_CLIENT, "r_useportalculling", "1", "improve framerate with r_novis 1 by using portal culling - still not as good as compiled visibility data in the map, but it helps (a value of 2 forces use of this even with vis data, which improves framerates in maps without too much complexity, but hurts in extremely complex maps, which is why 2 is not the default mode)"};

Referenced by GL_Surf_Init(), and R_View_WorldVisibility().

◆ r_usesurfaceculling

cvar_t r_usesurfaceculling = {CF_CLIENT, "r_usesurfaceculling", "1", "skip off-screen surfaces (1 = cull surfaces if the map is likely to benefit, 2 = always cull surfaces)"}

Definition at line 32 of file gl_rsurf.c.

32{CF_CLIENT, "r_usesurfaceculling", "1", "skip off-screen surfaces (1 = cull surfaces if the map is likely to benefit, 2 = always cull surfaces)"};

Referenced by GL_Surf_Init(), and R_View_WorldVisibility_CullSurfaces().

◆ r_vis_trace

cvar_t r_vis_trace = {CF_CLIENT, "r_vis_trace", "0", "test if each portal or leaf is visible using tracelines"}

Definition at line 33 of file gl_rsurf.c.

33{CF_CLIENT, "r_vis_trace", "0", "test if each portal or leaf is visible using tracelines"};

Referenced by GL_Surf_Init(), and R_View_WorldVisibility().

◆ r_vis_trace_delay

cvar_t r_vis_trace_delay = {CF_CLIENT, "r_vis_trace_delay", "1", "keep a portal visible for this many seconds"}

Definition at line 35 of file gl_rsurf.c.

35{CF_CLIENT, "r_vis_trace_delay", "1", "keep a portal visible for this many seconds"};

Referenced by GL_Surf_Init(), and R_View_WorldVisibility().

◆ r_vis_trace_enlarge

cvar_t r_vis_trace_enlarge = {CF_CLIENT, "r_vis_trace_enlarge", "0", "make portal bounds bigger for tests by (1+this)*size"}

Definition at line 37 of file gl_rsurf.c.

37{CF_CLIENT, "r_vis_trace_enlarge", "0", "make portal bounds bigger for tests by (1+this)*size"};

Referenced by GL_Surf_Init(), R_View_WorldVisibility(), and R_View_WorldVisibility_CullSurfaces().

◆ r_vis_trace_expand

cvar_t r_vis_trace_expand = {CF_CLIENT, "r_vis_trace_expand", "0", "make portal bounds bigger for tests by this many units"}

Definition at line 38 of file gl_rsurf.c.

38{CF_CLIENT, "r_vis_trace_expand", "0", "make portal bounds bigger for tests by this many units"};

Referenced by GL_Surf_Init(), R_View_WorldVisibility(), and R_View_WorldVisibility_CullSurfaces().

◆ r_vis_trace_eyejitter

cvar_t r_vis_trace_eyejitter = {CF_CLIENT, "r_vis_trace_eyejitter", "8", "use a random offset of this much on the start of each traceline"}

Definition at line 36 of file gl_rsurf.c.

36{CF_CLIENT, "r_vis_trace_eyejitter", "8", "use a random offset of this much on the start of each traceline"};

Referenced by GL_Surf_Init(), R_View_WorldVisibility(), and R_View_WorldVisibility_CullSurfaces().

◆ r_vis_trace_pad

cvar_t r_vis_trace_pad = {CF_CLIENT, "r_vis_trace_pad", "8", "accept traces that hit within this many units of the portal"}

Definition at line 39 of file gl_rsurf.c.

39{CF_CLIENT, "r_vis_trace_pad", "8", "accept traces that hit within this many units of the portal"};

Referenced by GL_Surf_Init(), R_View_WorldVisibility(), and R_View_WorldVisibility_CullSurfaces().

◆ r_vis_trace_samples

cvar_t r_vis_trace_samples = {CF_CLIENT, "r_vis_trace_samples", "1", "use this many randomly positioned tracelines each frame to refresh the visible timer"}

Definition at line 34 of file gl_rsurf.c.

34{CF_CLIENT, "r_vis_trace_samples", "1", "use this many randomly positioned tracelines each frame to refresh the visible timer"};

Referenced by GL_Surf_Init(), R_View_WorldVisibility(), and R_View_WorldVisibility_CullSurfaces().

◆ r_vis_trace_surfaces

cvar_t r_vis_trace_surfaces = {CF_CLIENT, "r_vis_trace_surfaces", "0", "also use tracelines to cull surfaces"}

Definition at line 40 of file gl_rsurf.c.

40{CF_CLIENT, "r_vis_trace_surfaces", "0", "also use tracelines to cull surfaces"};

Referenced by GL_Surf_Init(), and R_View_WorldVisibility_CullSurfaces().