UFO: Alien Invasion
Loading...
Searching...
No Matches
r_model_brush.cpp File Reference

brush model loading More...

#include "r_local.h"
#include "r_lightmap.h"
#include "../../shared/parse.h"
#include "r_light.h"
#include "r_grass.h"
Include dependency graph for r_model_brush.cpp:

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 char *mapZone, 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 (bool 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, mBspSurfaces_t **r_sorted_surfaces)
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_GenerateTriangleSoup_ (model_t *mod)
static void R_GenerateTriangleSoup ()
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_SetupWorldModel (void)
 Sets up surface range for the world model.
static void R_ModAddMapTile (const char *name, const char *mapZone, bool day, int sX, int sY, int sZ)
static void R_ModEndLoading (const char *mapName)
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.
void R_ModReloadSurfacesArrays (void)

Variables

static const bytemod_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_tr_worldmodel
 The currently loaded world model for the actual tile.
static int totalBspTriangles

Detailed Description

brush model loading

Definition in file r_model_brush.cpp.

Function Documentation

◆ R_GenerateTriangleSoup()

◆ R_GenerateTriangleSoup_()

◆ R_LoadBspVertexArrays()

void R_LoadBspVertexArrays ( model_t * mod)
static

Puts the map data into buffers.

See also
R_ModAddMapTile
Note
Shift the verts after the texcoords for diffuse and lightmap are loaded
See also
R_ModShiftTile
Todo

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 493 of file r_model_brush.cpp.

References model_t::bsp, DotProduct, mBspModel_t::edges, mBspSurface_t::firstedge, mBspSurface_t::firstTriangle, mBspSurface_t::flags, mBspTexInfo_t::flags, image_t::height, i, mBspTexInfo_t::image, index, mBspSurface_t::index, mBspModel_t::indexes, mBspSurface_t::isOriginBrushModel, mBspSurface_t::light_s, mBspSurface_t::light_t, mBspSurface_t::lightmap_scale, mBspModel_t::lmtexcoord_buffer, mBspModel_t::lmtexcoords, Mem_PoolAllocTypeN, MSURF_LIGHTMAP, mBspSurface_t::normal, mBspVertex_t::normal, mBspModel_t::normal_buffer, mBspModel_t::normals, mBspSurface_t::numedges, mBspModel_t::numsurfaces, mBspVertex_t::position, r_lightmaps, R_ReallocateStateArrays(), shift, mBspSurface_t::stmins, SURF_PHONG, mBspModel_t::surfaces, mBspModel_t::surfedges, mBspModel_t::tangent_buffer, mBspModel_t::tangents, TangentVectors(), mBspModel_t::texcoord_buffer, mBspModel_t::texcoords, mBspSurface_t::texinfo, mBspTexInfo_t::u_offset, mBspTexInfo_t::uv, mBspEdge_t::v, mBspTexInfo_t::v_offset, VectorAdd, VectorCopy, VectorNotEmpty, mBspModel_t::vertex_buffer, mBspModel_t::vertexes, mBspModel_t::verts, vid_modelPool, mBspTexInfo_t::vv, and image_t::width.

Referenced by R_ModAddMapTile().

◆ R_LoadSurfacesArrays()

void R_LoadSurfacesArrays ( void )
static

◆ R_LoadSurfacesArrays_()

◆ R_ModAddMapTile()

◆ R_ModBeginLoading()

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.

Parameters
[in]tilesThe 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]dayLoad the day lightmap
[in]posIn 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]mapNameThe mapname that the get from the server (used to identify the correct name for the materials in case of a random assembly).
[in]mapZoneThe terrain type for texture replacement
See also
R_ModAddMapTile
CM_LoadMap
Note
This function is called for listen servers, too. This loads the bsp struct for rendering it. The CM_LoadMap code only loads the collision and pathfinding stuff.
See also
UI_BuildRadarImageList

Definition at line 1098 of file r_model_brush.cpp.

References Com_Error(), Com_Parse(), Com_sprintf(), ERR_DROP, i, mapName, MAX_QPATH, MAX_VAR, name, PATHFINDING_HEIGHT, PATHFINDING_WIDTH, Q_strncpyz(), R_BeginBuildingLightmaps(), R_ClearGrass(), R_ClearStaticLights(), R_ModAddMapTile(), R_ModEndLoading(), r_numMapTiles, and r_numModelsInline.

Referenced by CL_ViewLoadMedia().

◆ R_ModEndLoading()

void R_ModEndLoading ( const char * mapName)
static

◆ R_ModLoadEdges()

◆ R_ModLoadLeafs()

◆ R_ModLoadLighting()

void R_ModLoadLighting ( const lump_t * l)
static

Load the lightmap data.

Definition at line 56 of file r_model_brush.cpp.

References lump_t::filelen, lump_t::fileofs, Mem_PoolAllocTypeN, mod_base, r_worldmodel, and vid_lightPool.

Referenced by R_ModAddMapTile().

◆ R_ModLoadNodes()

◆ R_ModLoadNormals()

void R_ModLoadNormals ( const lump_t * l)
static

◆ R_ModLoadPlanes()

◆ R_ModLoadSubmodels()

◆ R_ModLoadSurfaces()

◆ R_ModLoadSurfedges()

◆ R_ModLoadTexinfo()

◆ R_ModLoadVertexes()

◆ R_ModReloadSurfacesArrays()

void R_ModReloadSurfacesArrays ( void )
Todo
fix this for threaded renderer mode

Definition at line 1167 of file r_model_brush.cpp.

References model_t::bsp, i, lengthof, Mem_Free, R_LoadSurfacesArrays(), r_mapTiles, r_numMapTiles, and mBspModel_t::sorted_surfaces.

Referenced by UI_MaterialEditorChangeValue_f().

◆ R_ModShiftTile()

void R_ModShiftTile ( void )
static

Shift the verts for map assemblies.

Note
This is needed because you want to place a bsp file to a given position on the grid - see R_ModAddMapTile for the shift vector calculation This vector differs for every map - and depends on the grid position the bsp map tile is placed in the world
Call this after the buffers were generated in R_LoadBspVertexArrays
See also
R_LoadBspVertexArrays

Definition at line 467 of file r_model_brush.cpp.

References cBspPlane_t::dist, i, cBspPlane_t::normal, mBspVertex_t::position, r_worldmodel, and shift.

Referenced by R_ModAddMapTile().

◆ R_RadiusFromBounds()

float R_RadiusFromBounds ( const vec3_t mins,
const vec3_t maxs )
inlinestatic

Definition at line 109 of file r_model_brush.cpp.

References i, and VectorLength().

Referenced by R_ModLoadSubmodels().

◆ R_RecursiveSetModel()

void R_RecursiveSetModel ( mBspNode_t * node,
model_t * mod )
static
See also
R_RecurseSetParent

Definition at line 892 of file r_model_brush.cpp.

References mBspNode_t::children, mBspNode_t::contents, CONTENTS_PATHFINDING_NODE, R_RecursiveSetModel(), and R_SetModel().

Referenced by R_RecursiveSetModel(), and R_SetupSubmodels().

◆ R_SetModel()

void R_SetModel ( mBspNode_t * node,
model_t * mod )
static
See also
R_SetParent

Definition at line 877 of file r_model_brush.cpp.

References mBspNode_t::children, mBspNode_t::contents, CONTENTS_NODE, mBspNode_t::model, and R_SetModel().

Referenced by R_RecursiveSetModel(), and R_SetModel().

◆ R_SetSurfaceExtents()

◆ R_SetupSubmodels()

◆ R_SetupWorldModel()

void R_SetupWorldModel ( void )
static

Sets up surface range for the world model.

Note
Depends on ufo2map to store all world model surfaces before submodel ones

Definition at line 951 of file r_model_brush.cpp.

References Com_DPrintf(), Com_Printf(), DEBUG_RENDERER, mBspHeader_t::firstface, i, NUM_REGULAR_MODELS, mBspHeader_t::numfaces, and r_worldmodel.

Referenced by R_ModAddMapTile().

◆ R_SortSurfacesArrays()

void R_SortSurfacesArrays ( const model_t * mod)
static

◆ R_SortSurfacesArrays_()

Variable Documentation

◆ mod_base

◆ r_worldmodel

◆ shift

◆ totalBspTriangles

int totalBspTriangles
static

Definition at line 803 of file r_model_brush.cpp.

Referenced by R_GenerateTriangleSoup(), and R_GenerateTriangleSoup_().