38#define BACKFACE_EPSILON 0.01
40#define MAX_BSPS_TO_RENDER 1024
42typedef struct bspRenderRef_s {
69 cullState |= planeSide;
93 if (!(clipflags & bit))
111 if (!e->
model->bsp.nummodelsurfaces)
136 const vec4_t color = {1.0, 0.0, 0.0, 1.0};
161 if (k >
r_state.array_size - 512) {
162 glDrawArrays(GL_LINES, 0, k / 3);
168 for (
int j = 0; j < surf->
numedges; j++) {
170 const GLfloat* vertex = &bsp->
verts[(surf->
index + j) * 3];
171 const GLfloat* normal = &bsp->
normals[(surf->
index + j) * 3];
173 VectorMA(vertex, 12.0, normal, end);
176 memcpy(&
r_state.vertex_array_3d[k + 3], end,
sizeof(
vec3_t));
182 glDrawArrays(GL_LINES, 0, k / 3);
286 const int mask = 1 <<
refdef.worldlevel;
292 if (
i && !(
i & mask))
327 Com_Printf(
"Cannot add BSP model rendering reference: MAX_BSPS_TO_RENDER exceeded\n");
341 if (!forceVisibility)
359 glEnable(GL_CULL_FACE);
360 glCullFace(GL_FRONT);
404 glDisable(GL_CULL_FACE);
void R_Color(const vec4_t rgba)
Change the color to given value.
const vec3_t & getMaxs() const
const vec3_t & getMins() const
void shift(const vec3_t shiftVec)
shove the whole box by the given vector
void expand(const float byVal)
expand the box in all directions, but clip them to the maximum boundaries
void Com_Printf(const char *const fmt,...)
#define LEVEL_LASTVISIBLE
void VectorMA(const vec3_t veca, const float scale, const vec3_t vecb, vec3_t outVector)
Sets vector_out (vc) to vevtor1 (va) + scale * vector2 (vb).
void R_SetArrayState(const mBspModel_t *bsp)
void R_ResetArrayState(void)
static void R_RecursiveVisibleWorldNode(const mBspNode_t *node, int tile)
Recurse down the bsp tree and mark all surfaces as visible for being rendered.
void R_RenderBlendWarpBspRRefs(void)
Draw all warped translucent bsp surfaces via warp shader and with blend enabled.
void R_RenderOpaqueBspRRefs(void)
Draw all simple opaque bsp surfaces with multitexture enabled and light enabled.
void R_GetLevelSurfaceLists(void)
Fills the surface chains for the current worldlevel and hide other levels.
#define MAX_BSPS_TO_RENDER
void R_RenderOpaqueWarpBspRRefs(void)
Draw all warped opaque bsp surfaces via warp shader.
static void R_RecursiveWorldNode(const mBspNode_t *node, int tile)
Recurse down the bsp tree and mark surfaces that are visible (not culled) for being rendered.
void R_DrawBspNormals(int tile)
Developer tool for viewing BSP vertex normals. Only Phong interpolated surfaces show their normals wh...
bool R_CullBspModel(const entity_t *e)
Returns true if the specified entity is completely culled by the view frustum, false otherwise.
static int R_CullBox(const vec3_t mins, const vec3_t maxs)
Returns whether if the specified bounding box is completely culled by the view frustum (PSIDE_BACK),...
static void R_RecurseWorld(const mBspNode_t *node, int tile)
Wrapper that recurses the bsp nodes but skip the pathfinding nodes.
void R_RenderMaterialBspRRefs(void)
void R_RenderBlendBspRRefs(void)
Draw all translucent bsp surfaces with multitexture enabled and blend enabled.
static bspRenderRef_t bspRRefs[MAX_BSPS_TO_RENDER]
bool R_CullSphere(const vec3_t centre, const float radius, const unsigned int clipflags)
Performs a spherical frustum check.
void R_AddBspRRef(const mBspModel_t *model, const vec3_t origin, const vec3_t angles, const bool forceVisibility)
Adds bsp render references.
void R_RenderAlphaTestBspRRefs(void)
static void R_RenderBspRRefs(drawSurfaceFunc drawFunc, surfaceArrayType_t surfType)
void R_ClearBspRRefs(void)
void(* drawSurfaceFunc)(const mBspSurfaces_t *surfs, glElementIndex_t *indexPtr)
void R_RenderFlareBspRRefs(void)
void R_DrawBoundingBox(const AABB &absBox)
Draws the model bounding box.
void R_DrawFlareSurfaces(const mBspSurfaces_t *surfs, glElementIndex_t *indexPtr)
Flares are batched by their texture. Usually, this means one draw operation for all flares in view....
QGL_EXTERN void(APIENTRY *qglActiveTexture)(GLenum texture)
void R_EnableWorldLights(void)
Set up lighting data for the GLSL world shader.
local graphics definitions
void R_DrawSurfaces(const mBspSurfaces_t *surfs, glElementIndex_t *indexPtr)
General surface drawing function, that draw the surface chains.
void R_DrawMaterialSurfaces(const mBspSurfaces_t *surfs, glElementIndex_t *indexPtr)
Iterates the specified surfaces list, updating materials as they are encountered, and rendering all v...
Header file for the render material subsystem.
model_t * r_mapTiles[MAX_MAPTILES]
The world model(s).
#define CONTENTS_PATHFINDING_NODE
void R_EnableAlphaTest(bool enable)
void R_EnableTexture(gltexunit_t *texunit, bool enable)
void R_EnableGlowMap(const image_t *image)
bool R_EnableLighting(r_program_t *program, bool enable)
Enables hardware-accelerated lighting with the specified program. This should be called after any tex...
void R_EnableWarp(r_program_t *program, bool enable)
void R_ReallocateStateArrays(int size)
Reallocate arrays of GL primitives if needed.
glElementIndex_t * indexes
mBspSurfaces_t * sorted_surfaces[NUM_SURFACES_ARRAYS]
unsigned short firstsurface
struct mBspNode_s * children[2]
unsigned short numsurfaces
surfaces are assigned to arrays based on their primary rendering type and then sorted by world textur...
int TR_BoxOnPlaneSide(const vec3_t mins, const vec3_t maxs, const TR_PLANE_TYPE *plane)
Returns PSIDE_FRONT, PSIDE_BACK, or PSIDE_BOTH.
#define VectorCopy(src, dest)
#define DotProduct(x, y)
Returns the distance between two 3-dimensional vectors.