80 for (
int i = 0;
i <
count;
i++, in++, out++) {
102 for (
int i = 0;
i <
count;
i++, in++, out++) {
113 for (
int i = 0;
i < 3;
i++)
114 corner[
i] = fabsf(mins[
i]) > fabsf(maxs[
i]) ? fabsf(mins[
i]) : fabsf(maxs[
i]);
137 for (
int i = 0;
i <
count;
i++, in++, out++) {
139 for (
int j = 0; j < 3; j++) {
164 for (
int i = 0;
i <
count;
i++, in++, out++) {
186 for (
int i = 0;
i <
count;
i++, in++, out++) {
188 for (
int j = 0; j < 3; j++) {
218 VectorSet(maxs, -999999, -999999, -999999);
236 for (
int j = 0; j < 3; j++) {
237 position[j] += (float)
shift[j];
238 if (position[j] > maxs[j])
239 maxs[j] = position[j];
240 if (position[j] < mins[j])
241 mins[j] = position[j];
247 stmins[0] = std::min(valS, stmins[0]);
248 stmaxs[0] = std::max(valS, stmaxs[0]);
249 stmins[1] = std::min(valT, stmins[1]);
250 stmaxs[1] = std::max(valT, stmaxs[1]);
257 for (
i = 0;
i < 2;
i++) {
281 for (
int surfnum = 0; surfnum <
count; surfnum++, in++, out++) {
352 for (
int i = 0;
i <
count;
i++, in++, out++) {
360 out->
plane =
nullptr;
370 for (j = 0; j < 3; j++) {
378 for (j = 0; j < 2; j++) {
381 assert(p2 < r_worldmodel->bsp.numnodes);
404 for (
int i = 0;
i <
count;
i++, in++, out++) {
405 for (
int j = 0; j < 3; j++) {
450 for (
int i = 0;
i <
count;
i++, in++, out++) {
451 for (
int j = 0; j < 3; j++)
476 for (j = 0; j < 3; j++)
481 for (j = 0; j < 3; j++)
496 int vertOfs, texCoordOfs, tangOfs;
498 float soff, toff, s, t;
499 float* point, *sdir, *tdir;
504 int vertexCount, indexCount;
506 vertOfs = texCoordOfs = tangOfs = 0;
507 vertexCount = indexCount = 0;
510 const int numedges = surf->
numedges;
511 vertexCount += numedges;
513 indexCount += (numedges - 2) * 3;
527 surf->
index = vertOfs / 3;
530 for (
int j = 0; j < surf->
numedges; j++) {
546 vecShifted = &mod->
bsp.
verts[vertOfs];
612 qglBufferData(GL_ARRAY_BUFFER, vertOfs *
sizeof(GLfloat), mod->
bsp.
verts, GL_STATIC_DRAW);
616 qglBufferData(GL_ARRAY_BUFFER, texCoordOfs *
sizeof(GLfloat), mod->
bsp.
texcoords, GL_STATIC_DRAW);
620 qglBufferData(GL_ARRAY_BUFFER, texCoordOfs *
sizeof(GLfloat), mod->
bsp.
lmtexcoords, GL_STATIC_DRAW);
624 qglBufferData(GL_ARRAY_BUFFER, vertOfs *
sizeof(GLfloat), mod->
bsp.
normals, GL_STATIC_DRAW);
628 qglBufferData(GL_ARRAY_BUFFER, tangOfs *
sizeof(GLfloat), mod->
bsp.
tangents, GL_STATIC_DRAW);
630 qglBindBuffer(GL_ARRAY_BUFFER, 0);
638 for (
i = 0;
i < surfs->
count;
i++) {
649 if (sorted && sorted->
count) {
650 for (
int j = 0; j < sorted->
count; j++)
673 for (
i = 0, surf = s;
i < ns;
i++, surf++) {
678 r_sorted_surfaces[
index] = surfs;
729 for (
i = 0, surf = s;
i < ns;
i++, surf++) {
734 mod->
bsp.blend_warp_surfaces->count++;
736 mod->
bsp.blend_surfaces->count++;
739 mod->
bsp.opaque_warp_surfaces->count++;
741 mod->
bsp.alpha_test_surfaces->count++;
743 mod->
bsp.opaque_surfaces->count++;
747 mod->
bsp.material_surfaces->count++;
750 mod->
bsp.flare_surfaces->count++;
756 if (surfaces->
count) {
764 for (
i = 0, surf = s;
i < ns;
i++, surf++) {
816 for (
int j = 0; j < surfaces->
count; j++) {
831 for (
int k = 0; k < numTris; k++) {
866 qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bsp->
index_buffer);
870 qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
958 int first = surfCount, last = -1;
963 int lastFace = firstFace + sub->
numfaces;
965 if (lastFace <= firstFace)
968 if (last >= 0 && (firstFace > last || lastFace < first))
969 Com_Printf(
"Warning: submodels may not combine to contigous range in the surface array, some world geometry could be missing as a result (submodel %i)\n",
i);
971 if (firstFace < first)
982 Com_Printf(
"Warning: %i surfaces are lost, some world geometry could be missing as a result\n",
r_worldmodel->bsp.numsurfaces - last);
1126 if (token[0] ==
'-') {
1132 if (token[0] ==
'+')
1137 if (pos && pos[0]) {
1140 for (
int i = 0;
i < 3;
i++) {
1144 sh[
i] = atoi(token);
1147 Com_Error(
ERR_DROP,
"R_ModBeginLoading: invalid x position given: %i\n", sh[0]);
1149 Com_Error(
ERR_DROP,
"R_ModBeginLoading: invalid y position given: %i\n", sh[1]);
1151 Com_Error(
ERR_DROP,
"R_ModBeginLoading: invalid z position given: %i\n", sh[2]);
1172 for (
int j = 0; j <
size; j++)
memPool_t * vid_modelPool
memPool_t * vid_lightPool
void getCenter(vec3_t center) const
Calculates the center of the bounding box.
void set(const AABB &other)
Copies the values from the given aabb.
void Com_DPrintf(int level, const char *fmt,...)
A Com_Printf that only shows up if the "developer" cvar is set.
void Com_Error(int code, const char *fmt,...)
void Com_Printf(const char *const fmt,...)
#define LUMP_LIGHTING_NIGHT
#define MAX_MAP_SURFEDGES
#define PATHFINDING_WIDTH
absolute max
#define NUM_REGULAR_MODELS
#define LUMP_LIGHTING_DAY
#define PATHFINDING_HEIGHT
15 max, adjusting above 8 will require a rewrite to the DV code
int FS_LoadFile(const char *path, byte **buffer)
Filenames are relative to the quake search path.
void FS_FreeFile(void *buffer)
vec_t VectorLength(const vec3_t v)
Calculate the length of a vector.
void TangentVectors(const vec3_t normal, const vec3_t sdir, const vec3_t tdir, vec4_t tangent, vec3_t binormal)
Projects the normalized directional vectors on to the normal's plane. The fourth component of the res...
#define Mem_PoolAllocTypeN(type, n, pool)
#define Mem_AllocTypeN(type, n)
#define Mem_PoolAllocType(type, pool)
const char * Com_Parse(const char *data_p[], char *target, size_t size, bool replaceWhitespaces)
Parse a token out of a string.
Shared parsing functions.
#define BSP_SwapHeader(header, name)
QGL_EXTERN int GLboolean GLfloat * v
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Pseudoinstanced grass generation and rendering.
image_t * R_FindImage(const char *pname, imagetype_t type)
Finds or loads the given image.
int R_GetImageIndex(image_t *imagePtr)
Returns an index of the image pointer in the r_images linked list, as if r_images would be a plain co...
void R_ClearStaticLights(void)
Remove all static light data.
void R_BeginBuildingLightmaps(void)
void R_CreateSurfaceLightmap(mBspSurface_t *surf)
void R_EndBuildingLightmaps(void)
local graphics definitions
void R_LoadMaterials(const char *map)
Load material definitions for each map that has one.
model_t r_modelsInline[MAX_MOD_KNOWN]
model_t * r_mapTiles[MAX_MAPTILES]
The world model(s).
model_t * R_AllocModelSlot(void)
static void R_SortSurfacesArrays(const model_t *mod)
Reorders all surfaces arrays for the specified model, grouping the surface pointers by texture....
static void R_SetSurfaceExtents(mBspSurface_t *surf, const model_t *mod)
Fills in s->stmins[] and s->stmaxs[].
static void R_SetupWorldModel(void)
Sets up surface range for the world model.
static void R_ModLoadSurfaces(bool day, const lump_t *l)
static void R_SetupSubmodels(void)
Sets up bmodels (brush models) like doors and breakable objects.
static void R_LoadSurfacesArrays_(model_t *mod)
static void R_ModLoadPlanes(const lump_t *l)
static void R_LoadBspVertexArrays(model_t *mod)
Puts the map data into buffers.
static void R_LoadSurfacesArrays(void)
static const byte * mod_base
The model base pointer - bases for the lump offsets.
static model_t * r_worldmodel
The currently loaded world model for the actual tile.
static int totalBspTriangles
static void R_SetModel(mBspNode_t *node, model_t *mod)
static float R_RadiusFromBounds(const vec3_t mins, const vec3_t maxs)
static void R_RecursiveSetModel(mBspNode_t *node, model_t *mod)
static void R_ModAddMapTile(const char *name, const char *mapZone, bool day, int sX, int sY, int sZ)
static void R_ModLoadEdges(const lump_t *l)
static void R_ModLoadLeafs(const lump_t *l)
void R_ModReloadSurfacesArrays(void)
static void R_GenerateTriangleSoup_(model_t *mod)
static void R_ModShiftTile(void)
Shift the verts for map assemblies.
void R_ModBeginLoading(const char *tiles, bool day, const char *pos, const char *mapName, const char *mapZone)
Specifies the model that will be used as the world.
static void R_GenerateTriangleSoup()
static void R_ModLoadNodes(const lump_t *l)
static void R_ModLoadNormals(const lump_t *l)
static void R_ModLoadSubmodels(const lump_t *l)
Loads brush entities like func_door and func_breakable.
static void R_SortSurfacesArrays_(mBspSurfaces_t *surfs, mBspSurfaces_t **r_sorted_surfaces)
static void R_ModLoadTexinfo(const char *mapZone, const lump_t *l)
static void R_ModEndLoading(const char *mapName)
static ipos3_t shift
The shift array is used for random map assemblies (RMA) to shift the mins/maxs and stuff like that.
static void R_ModLoadSurfedges(const lump_t *l)
static void R_ModLoadVertexes(const lump_t *l)
static void R_ModLoadLighting(const lump_t *l)
Load the lightmap data.
#define R_AddSurfaceToArray(array, surf)
#define CONTENTS_PATHFINDING_NODE
void R_ReallocateStateArrays(int size)
Reallocate arrays of GL primitives if needed.
#define Q_strvalid(string)
void Q_strncpyz(char *dest, const char *src, size_t destsize)
Safe strncpy that ensures a trailing zero.
bool Com_sprintf(char *dest, size_t size, const char *fmt,...)
copies formatted string with buffer-size checking
convex region of space in the BSP tree
int lightofs[LIGHTMAP_MAX]
Directory of the different data blocks.
glElementIndex_t * indexes
unsigned int tangent_buffer
unsigned int normal_buffer
mBspSurfaces_t * sorted_surfaces[NUM_SURFACES_ARRAYS]
unsigned int index_buffer
unsigned int vertex_buffer
unsigned int texcoord_buffer
unsigned int lmtexcoord_buffer
unsigned short firstsurface
struct mBspNode_s * children[2]
unsigned short numsurfaces
unsigned int numTriangles
surfaces are assigned to arrays based on their primary rendering type and then sorted by world textur...
mBspSurface_t ** surfaces
static const char * mapName
#define VectorNegate(src, dest)
#define VectorNotEmpty(a)
#define VectorCopy(src, dest)
#define Vector2Set(v, x, y)
#define VectorAdd(a, b, dest)
#define DotProduct(x, y)
Returns the distance between two 3-dimensional vectors.
#define VectorSet(v, x, y, z)