brush model loading More...
#include "r_local.h"
#include "r_lightmap.h"
#include "../../shared/parse.h"
#include "r_light.h"
Go to the source code of this file.
Functions | |
static void | R_ModLoadLighting (const lump_t *l) |
Load the lightmap data. | |
static void | R_ModLoadVertexes (const lump_t *l) |
static void | R_ModLoadNormals (const lump_t *l) |
static float | R_RadiusFromBounds (const vec3_t mins, const vec3_t maxs) |
static void | R_ModLoadSubmodels (const lump_t *l) |
Loads brush entities like func_door and func_breakable. | |
static void | R_ModLoadEdges (const lump_t *l) |
static void | R_ModLoadTexinfo (const lump_t *l) |
static void | R_SetSurfaceExtents (mBspSurface_t *surf, const model_t *mod) |
Fills in s->stmins[] and s->stmaxs[]. | |
static void | R_ModLoadSurfaces (qboolean day, const lump_t *l) |
static void | R_ModLoadNodes (const lump_t *l) |
static void | R_ModLoadLeafs (const lump_t *l) |
static void | R_ModLoadSurfedges (const lump_t *l) |
static void | R_ModLoadPlanes (const lump_t *l) |
static void | R_ModShiftTile (void) |
Shift the verts for map assemblies. | |
static void | R_LoadBspVertexArrays (model_t *mod) |
Puts the map data into buffers. | |
static void | R_SortSurfacesArrays_ (mBspSurfaces_t *surfs) |
static void | R_SortSurfacesArrays (const model_t *mod) |
Reorders all surfaces arrays for the specified model, grouping the surface pointers by texture. This dramatically reduces glBindTexture calls. | |
static void | R_LoadSurfacesArrays_ (model_t *mod) |
static void | R_LoadSurfacesArrays (void) |
static void | R_SetModel (mBspNode_t *node, model_t *mod) |
static void | R_RecursiveSetModel (mBspNode_t *node, model_t *mod) |
static void | R_SetupSubmodels (void) |
Sets up bmodels (brush models) like doors and breakable objects. | |
static void | R_ModAddMapTile (const char *name, qboolean day, int sX, int sY, int sZ) |
static void | R_ModEndLoading (const char *mapName) |
void | R_ModBeginLoading (const char *tiles, qboolean day, const char *pos, const char *mapName) |
Specifies the model that will be used as the world. | |
void | R_ModReloadSurfacesArrays (void) |
Variables | |
static const byte * | mod_base |
The model base pointer - bases for the lump offsets. | |
static ipos3_t | shift |
The shift array is used for random map assemblies (RMA) to shift the mins/maxs and stuff like that. | |
static model_t * | r_worldmodel |
The currently loaded world model for the actual tile. | |
static mBspSurfaces_t * | r_sorted_surfaces [MAX_GL_TEXTURES] |
temporary space for sorting surfaces by texture index |
brush model loading
Definition in file r_model_brush.c.
static void R_LoadBspVertexArrays | ( | model_t * | mod | ) | [static] |
Puts the map data into buffers.
Don't use the buffers from r_state here - they might overflow
Decrease MAX_GL_ARRAY_LENGTH to 32768 again when this is fixed
Definition at line 525 of file r_model_brush.c.
References model_s::bsp, Com_Error(), DotProduct, mBspModel_s::edges, ERR_DROP, mBspSurface_s::firstedge, mBspTexInfo_s::flags, mBspSurface_s::flags, image_s::height, i, mBspTexInfo_s::image, mBspSurface_s::index, mBspSurface_s::isOriginBrushModel, mBspSurface_s::light_s, mBspSurface_s::light_t, mBspSurface_s::lightmap_scale, mBspModel_s::lmtexcoord_buffer, mBspModel_s::lmtexcoords, MAX_GL_ARRAY_LENGTH, Mem_PoolAlloc, MSURF_LIGHTMAP, mBspSurface_s::normal, mBspVertex_s::normal, mBspModel_s::normal_buffer, mBspModel_s::normals, mBspSurface_s::numedges, mBspModel_s::numsurfaces, mBspVertex_s::position, r_lightmaps, shift, lightmaps_s::size, mBspSurface_s::stmins, SURF_PHONG, mBspModel_s::surfaces, mBspModel_s::surfedges, mBspModel_s::tangent_buffer, mBspModel_s::tangents, TangentVectors(), mBspModel_s::texcoord_buffer, mBspModel_s::texcoords, mBspSurface_s::texinfo, mBspTexInfo_s::u_offset, mBspTexInfo_s::uv, mBspEdge_s::v, mBspTexInfo_s::v_offset, vec3_origin, VectorAdd, VectorCompare, VectorCopy, mBspModel_s::vertex_buffer, mBspModel_s::vertexes, mBspModel_s::verts, vid_modelPool, mBspTexInfo_s::vv, and image_s::width.
Referenced by R_ModAddMapTile().
static void R_LoadSurfacesArrays | ( | void | ) | [static] |
Definition at line 829 of file r_model_brush.c.
References i, R_LoadSurfacesArrays_(), r_mapTiles, r_modelsInline, r_numMapTiles, and r_numModelsInline.
Referenced by R_ModEndLoading(), and R_ModReloadSurfacesArrays().
static void R_LoadSurfacesArrays_ | ( | model_t * | mod | ) | [static] |
Definition at line 746 of file r_model_brush.c.
References model_s::bsp, mBspSurfaces_s::count, mBspModel_s::firstmodelsurface, material_s::flags, mBspTexInfo_s::flags, i, mBspTexInfo_s::image, image_s::material, material, Mem_PoolAlloc, mod_bsp, NUM_SURFACES_ARRAYS, mBspModel_s::nummodelsurfaces, mBspModel_s::numsurfaces, R_SortSurfacesArrays(), R_SurfaceToSurfaces, mBspModel_s::sorted_surfaces, STAGE_FLARE, STAGE_RENDER, SURF_ALPHATEST, SURF_BLEND33, SURF_BLEND66, SURF_WARP, mBspSurfaces_s::surfaces, mBspModel_s::surfaces, mBspSurface_s::texinfo, model_s::type, and vid_modelPool.
Referenced by R_LoadSurfacesArrays().
static void R_ModAddMapTile | ( | const char * | name, | |
qboolean | day, | |||
int | sX, | |||
int | sY, | |||
int | sZ | |||
) | [static] |
[in] | name | The name of the map. Relative to maps/ and without extension |
[in] | day | Load the day lightmap |
[in] | sX | Shift x grid units |
[in] | sY | Shift y grid units |
[in] | sZ | Shift z grid units |
Definition at line 924 of file r_model_brush.c.
References BSPVERSION, byte, Com_Error(), Com_sprintf(), ERR_DROP, FS_FreeFile(), FS_LoadFile(), header, i, int(), LittleLong(), LUMP_EDGES, LUMP_FACES, LUMP_LEAFS, LUMP_LIGHTING_DAY, LUMP_LIGHTING_NIGHT, LUMP_MODELS, LUMP_NODES, LUMP_NORMALS, LUMP_PLANES, LUMP_SURFEDGES, LUMP_TEXINFO, LUMP_VERTEXES, dBspHeader_t::lumps, MAX_MOD_KNOWN, mod_base, mod_bsp, model_s::name, R_LoadBspVertexArrays(), r_mapTiles, r_models, R_ModLoadEdges(), R_ModLoadLeafs(), R_ModLoadLighting(), R_ModLoadNodes(), R_ModLoadNormals(), R_ModLoadPlanes(), R_ModLoadSubmodels(), R_ModLoadSurfaces(), R_ModLoadSurfedges(), R_ModLoadTexinfo(), R_ModLoadVertexes(), R_ModShiftTile(), r_numMapTiles, r_numModels, R_SetupSubmodels(), shift, model_s::type, UNIT_SIZE, VectorNotEmpty, VectorSet, and dBspHeader_t::version.
Referenced by R_ModBeginLoading().
void R_ModBeginLoading | ( | const char * | tiles, | |
qboolean | day, | |||
const char * | pos, | |||
const char * | mapName | |||
) |
Specifies the model that will be used as the world.
[in] | tiles | The tiles string can be only one map or a list of space seperated map tiles for random assembly. In case of random assembly we also need the pos string. Every tile needs an entry in the pos string, too. |
[in] | day | Load the day lightmap |
[in] | pos | In case of a random map assembly this is the string that holds the world grid positions of the tiles. The positions are x, y and z values. They are just written one after another for every tile in the tiles string and every of the three components must exists for every tile. |
[in] | mapName | The mapname that the get from the server (used to identify the correct name for the materials in case of a random assembly). |
CM_LoadMap
code only loads the collision and pathfinding stuff. Definition at line 1017 of file r_model_brush.c.
References Com_Error(), Com_Parse(), Com_sprintf(), ERR_DROP, i, MAX_QPATH, MAX_VAR, name, PATHFINDING_HEIGHT, PATHFINDING_WIDTH, Q_strncpyz(), R_BeginBuildingLightmaps(), R_ClearActiveLights(), R_FreeWorldImages(), R_ModAddMapTile(), R_ModEndLoading(), r_numMapTiles, and r_numModelsInline.
Referenced by CL_ViewLoadMedia().
static void R_ModEndLoading | ( | const char * | mapName | ) | [static] |
Definition at line 991 of file r_model_brush.c.
References R_EndBuildingLightmaps(), R_LoadMaterials(), and R_LoadSurfacesArrays().
Referenced by R_ModBeginLoading().
static void R_ModLoadEdges | ( | const lump_t * | l | ) | [static] |
Definition at line 161 of file r_model_brush.c.
References model_s::bsp, Com_DPrintf(), Com_Error(), count, DEBUG_RENDERER, mBspModel_s::edges, ERR_DROP, lump_t::filelen, lump_t::fileofs, i, LittleShort(), Mem_PoolAlloc, mod_base, model_s::name, mBspModel_s::numedges, mBspEdge_s::v, and vid_modelPool.
Referenced by R_ModAddMapTile().
static void R_ModLoadLeafs | ( | const lump_t * | l | ) | [static] |
Definition at line 413 of file r_model_brush.c.
References model_s::bsp, Com_DPrintf(), Com_Error(), mBspLeaf_s::contents, count, DEBUG_RENDERER, ERR_DROP, lump_t::filelen, lump_t::fileofs, i, mBspModel_s::leafs, LittleLong(), LittleShort(), Mem_PoolAlloc, mBspLeaf_s::minmaxs, mod_base, model_s::name, mBspModel_s::numleafs, shift, and vid_modelPool.
Referenced by R_ModAddMapTile().
static void R_ModLoadLighting | ( | const lump_t * | l | ) | [static] |
Load the lightmap data.
Definition at line 55 of file r_model_brush.c.
References model_s::bsp, byte, lump_t::filelen, lump_t::fileofs, mBspModel_s::lightdata, mBspModel_s::lightquant, Mem_PoolAlloc, mod_base, and vid_lightPool.
Referenced by R_ModAddMapTile().
static void R_ModLoadNodes | ( | const lump_t * | l | ) | [static] |
Definition at line 357 of file r_model_brush.c.
References model_s::bsp, mBspNode_s::children, Com_DPrintf(), Com_Error(), mBspNode_s::contents, CONTENTS_NODE, CONTENTS_PATHFINDING_NODE, count, DEBUG_RENDERER, ERR_DROP, lump_t::filelen, lump_t::fileofs, mBspNode_s::firstsurface, i, LEAFNODE, mBspModel_s::leafs, LittleLong(), LittleShort(), Mem_PoolAlloc, mBspNode_s::minmaxs, mod_base, model_s::name, mBspModel_s::nodes, mBspModel_s::numleafs, mBspModel_s::numnodes, mBspNode_s::numsurfaces, mBspNode_s::parent, mBspNode_s::plane, PLANENUM_LEAF, mBspModel_s::planes, shift, and vid_modelPool.
Referenced by R_ModAddMapTile().
static void R_ModLoadNormals | ( | const lump_t * | l | ) | [static] |
Definition at line 89 of file r_model_brush.c.
References model_s::bsp, Com_Error(), count, ERR_DROP, lump_t::filelen, lump_t::fileofs, i, LittleFloat(), mod_base, model_s::name, mBspVertex_s::normal, mBspModel_s::numvertexes, and mBspModel_s::vertexes.
Referenced by R_ModAddMapTile().
static void R_ModLoadPlanes | ( | const lump_t * | l | ) | [static] |
Definition at line 465 of file r_model_brush.c.
References model_s::bsp, Com_DPrintf(), Com_Error(), count, DEBUG_RENDERER, cBspPlane_s::dist, ERR_DROP, lump_t::filelen, lump_t::fileofs, i, LittleFloat(), LittleLong(), Mem_PoolAlloc, mod_base, model_s::name, cBspPlane_s::normal, mBspModel_s::numplanes, mBspModel_s::planes, cBspPlane_s::type, and vid_modelPool.
Referenced by R_ModAddMapTile().
static void R_ModLoadSubmodels | ( | const lump_t * | l | ) | [static] |
Loads brush entities like func_door and func_breakable.
Definition at line 131 of file r_model_brush.c.
References model_s::bsp, Com_DPrintf(), Com_Error(), count, DEBUG_RENDERER, ERR_DROP, lump_t::filelen, lump_t::fileofs, mBspHeader_s::firstface, mBspHeader_s::headnode, i, LittleFloat(), LittleLong(), mBspHeader_s::maxs, Mem_PoolAlloc, mBspHeader_s::mins, mod_base, model_s::name, mBspHeader_s::numfaces, mBspModel_s::numsubmodels, mBspHeader_s::origin, R_RadiusFromBounds(), mBspHeader_s::radius, shift, mBspModel_s::submodels, and vid_modelPool.
Referenced by R_ModAddMapTile().
Definition at line 286 of file r_model_brush.c.
References model_s::bsp, Com_DPrintf(), Com_Error(), count, DEBUG_RENDERER, ERR_DROP, lump_t::filelen, lump_t::fileofs, mBspSurface_s::firstedge, mBspTexInfo_s::flags, mBspSurface_s::flags, i, mBspModel_s::lightdata, LIGHTMAP_DAY, LIGHTMAP_NIGHT, mBspSurface_s::lightmap_scale, mBspModel_s::lightquant, LittleLong(), LittleShort(), Mem_PoolAlloc, mod_base, MSURF_LIGHTMAP, MSURF_PLANEBACK, model_s::name, mBspSurface_s::normal, cBspPlane_s::normal, mBspSurface_s::numedges, mBspModel_s::numsurfaces, mBspModel_s::numtexinfo, mBspSurface_s::plane, mBspModel_s::planes, R_CreateSurfaceLightmap(), r_numMapTiles, R_SetSurfaceExtents(), mBspSurface_s::samples, SURF_WARP, mBspModel_s::surfaces, mBspModel_s::texinfo, mBspSurface_s::texinfo, mBspSurface_s::tile, VectorCopy, VectorNegate, and vid_modelPool.
Referenced by R_ModAddMapTile().
static void R_ModLoadSurfedges | ( | const lump_t * | l | ) | [static] |
Definition at line 439 of file r_model_brush.c.
References model_s::bsp, Com_DPrintf(), Com_Error(), count, DEBUG_RENDERER, ERR_DROP, lump_t::filelen, lump_t::fileofs, i, LittleLong(), MAX_MAP_SURFEDGES, Mem_PoolAlloc, mod_base, model_s::name, mBspModel_s::numsurfedges, mBspModel_s::surfedges, and vid_modelPool.
Referenced by R_ModAddMapTile().
static void R_ModLoadTexinfo | ( | const lump_t * | l | ) | [static] |
Definition at line 186 of file r_model_brush.c.
References model_s::bsp, Com_DPrintf(), Com_Error(), Com_sprintf(), count, DEBUG_RENDERER, ERR_DROP, lump_t::filelen, lump_t::fileofs, mBspTexInfo_s::flags, i, mBspTexInfo_s::image, it_world, LittleFloat(), LittleLong(), rendererData_t::mapZone, MAX_QPATH, Mem_PoolAlloc, mod_base, model_s::name, name, mBspModel_s::numtexinfo, R_FindImage(), refdef, mBspModel_s::texinfo, mBspTexInfo_s::u_offset, mBspTexInfo_s::uv, mBspTexInfo_s::v_offset, vid_modelPool, and mBspTexInfo_s::vv.
Referenced by R_ModAddMapTile().
static void R_ModLoadVertexes | ( | const lump_t * | l | ) | [static] |
Definition at line 66 of file r_model_brush.c.
References model_s::bsp, Com_DPrintf(), Com_Error(), count, DEBUG_RENDERER, ERR_DROP, lump_t::filelen, lump_t::fileofs, i, LittleFloat(), Mem_PoolAlloc, mod_base, model_s::name, mBspModel_s::numvertexes, mBspVertex_s::position, mBspModel_s::vertexes, and vid_modelPool.
Referenced by R_ModAddMapTile().
void R_ModReloadSurfacesArrays | ( | void | ) |
Definition at line 1087 of file r_model_brush.c.
References model_s::bsp, i, lengthof, Mem_Free, R_LoadSurfacesArrays(), r_mapTiles, r_numMapTiles, and mBspModel_s::sorted_surfaces.
Referenced by UI_MaterialEditorChangeValue_f().
static void R_ModShiftTile | ( | void | ) | [static] |
Shift the verts for map assemblies.
Definition at line 499 of file r_model_brush.c.
References model_s::bsp, cBspPlane_s::dist, i, cBspPlane_s::normal, mBspModel_s::planes, mBspVertex_s::position, shift, and mBspModel_s::vertexes.
Referenced by R_ModAddMapTile().
Definition at line 115 of file r_model_brush.c.
References i, and VectorLength().
Referenced by R_ModLoadSubmodels().
static void R_RecursiveSetModel | ( | mBspNode_t * | node, | |
model_t * | mod | |||
) | [static] |
Definition at line 858 of file r_model_brush.c.
References mBspNode_s::children, mBspNode_s::contents, CONTENTS_PATHFINDING_NODE, and R_SetModel().
Referenced by R_SetupSubmodels().
static void R_SetModel | ( | mBspNode_t * | node, | |
model_t * | mod | |||
) | [static] |
Definition at line 843 of file r_model_brush.c.
References mBspNode_s::children, mBspNode_s::contents, CONTENTS_NODE, and mBspNode_s::model.
Referenced by R_RecursiveSetModel().
static void R_SetSurfaceExtents | ( | mBspSurface_t * | surf, | |
const model_t * | mod | |||
) | [static] |
Fills in s->stmins[] and s->stmaxs[].
Definition at line 226 of file r_model_brush.c.
References model_s::bsp, mBspSurface_s::center, DotProduct, mBspModel_s::edges, mBspSurface_s::firstedge, i, mBspSurface_s::lightmap_scale, mBspSurface_s::maxs, mBspSurface_s::mins, mBspSurface_s::numedges, mBspVertex_s::position, shift, mBspSurface_s::stcenter, mBspSurface_s::stextents, mBspSurface_s::stmaxs, mBspSurface_s::stmins, mBspModel_s::surfedges, mBspSurface_s::texinfo, mBspTexInfo_s::u_offset, mBspTexInfo_s::uv, mBspEdge_s::v, mBspTexInfo_s::v_offset, Vector2Set, VectorCenterFromMinsMaxs(), VectorCopy, VectorSet, mBspModel_s::vertexes, and mBspTexInfo_s::vv.
Referenced by R_ModLoadSurfaces().
static void R_SetupSubmodels | ( | void | ) | [static] |
Sets up bmodels (brush models) like doors and breakable objects.
Definition at line 872 of file r_model_brush.c.
References model_s::bsp, Com_Error(), Com_sprintf(), ERR_DROP, mBspHeader_s::firstface, mBspModel_s::firstmodelsurface, mBspModel_s::firstnode, mBspTexInfo_s::flags, mBspHeader_s::headnode, i, mBspSurface_s::isOriginBrushModel, mBspModel_s::maptile, model_s::maxs, mBspHeader_s::maxs, model_s::mins, mBspHeader_s::mins, mod_bsp_submodel, model_s::name, mBspModel_s::nodes, NUM_REGULAR_MODELS, mBspHeader_s::numfaces, mBspModel_s::nummodelsurfaces, mBspModel_s::numnodes, mBspModel_s::numsubmodels, r_modelsInline, r_numMapTiles, r_numModelsInline, R_RecursiveSetModel(), mBspHeader_s::radius, model_s::radius, mBspModel_s::submodels, SURF_ORIGIN, mBspModel_s::surfaces, mBspSurface_s::texinfo, model_s::type, and VectorCopy.
Referenced by R_ModAddMapTile().
static void R_SortSurfacesArrays | ( | const model_t * | mod | ) | [static] |
Reorders all surfaces arrays for the specified model, grouping the surface pointers by texture. This dramatically reduces glBindTexture calls.
Definition at line 691 of file r_model_brush.c.
References model_s::bsp, Com_DPrintf(), mBspSurfaces_s::count, DEBUG_RENDERER, mBspModel_s::firstmodelsurface, i, mBspTexInfo_s::image, Mem_Free, Mem_PoolAlloc, mod_bsp, NUM_SURFACES_ARRAYS, mBspModel_s::nummodelsurfaces, mBspModel_s::numsurfaces, r_images, r_numImages, R_SortSurfacesArrays_(), mBspModel_s::sorted_surfaces, mBspSurfaces_s::surfaces, mBspModel_s::surfaces, mBspSurface_s::texinfo, image_s::texnum, model_s::type, and vid_modelPool.
Referenced by R_LoadSurfacesArrays_().
static void R_SortSurfacesArrays_ | ( | mBspSurfaces_t * | surfs | ) | [static] |
Definition at line 665 of file r_model_brush.c.
References mBspSurfaces_s::count, i, mBspTexInfo_s::image, r_images, r_numImages, R_SurfaceToSurfaces, mBspSurfaces_s::surfaces, mBspSurface_s::texinfo, and image_s::texnum.
Referenced by R_SortSurfacesArrays().
The model base pointer - bases for the lump offsets.
Definition at line 40 of file r_model_brush.c.
Referenced by R_ModAddMapTile(), R_ModLoadEdges(), R_ModLoadLeafs(), R_ModLoadLighting(), R_ModLoadNodes(), R_ModLoadNormals(), R_ModLoadPlanes(), R_ModLoadSubmodels(), R_ModLoadSurfaces(), R_ModLoadSurfedges(), R_ModLoadTexinfo(), and R_ModLoadVertexes().
mBspSurfaces_t* r_sorted_surfaces[MAX_GL_TEXTURES] [static] |
temporary space for sorting surfaces by texture index
Definition at line 663 of file r_model_brush.c.
model_t* r_worldmodel [static] |
The currently loaded world model for the actual tile.
Definition at line 50 of file r_model_brush.c.
The shift array is used for random map assemblies (RMA) to shift the mins/maxs and stuff like that.
Definition at line 45 of file r_model_brush.c.
Referenced by CL_ClipMoveToLEs(), CM_AddMapTile(), R_LoadBspVertexArrays(), R_ModAddMapTile(), R_ModLoadLeafs(), R_ModLoadNodes(), R_ModLoadSubmodels(), R_ModShiftTile(), R_SetSurfaceExtents(), and TexinfoForBrushTexture().