UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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"

Go to the source code of this file.

Functions

static void R_ModLoadLighting (const lump_t *l)
 Load the lightmap data. More...
 
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. More...
 
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[]. More...
 
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. More...
 
static void R_LoadBspVertexArrays (model_t *mod)
 Puts the map data into buffers. More...
 
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. More...
 
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. More...
 
static void R_SetupWorldModel (void)
 Sets up surface range for the world model. More...
 
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. More...
 
void R_ModReloadSurfacesArrays (void)
 

Variables

static const bytemod_base
 The model base pointer - bases for the lump offsets. More...
 
static ipos3_t shift
 The shift array is used for random map assemblies (RMA) to shift the mins/maxs and stuff like that. More...
 
static model_tr_worldmodel
 The currently loaded world model for the actual tile. More...
 
static int totalBspTriangles
 

Detailed Description

brush model loading

Definition in file r_model_brush.cpp.

Function Documentation

static 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_s::bsp, DotProduct, mBspModel_s::edges, mBspSurface_s::firstedge, mBspSurface_s::firstTriangle, mBspTexInfo_s::flags, mBspSurface_s::flags, image_s::height, i, mBspTexInfo_s::image, mBspSurface_s::index, index, mBspModel_s::indexes, mBspSurface_s::isOriginBrushModel, mBspSurface_s::light_s, mBspSurface_s::light_t, mBspSurface_s::lightmap_scale, mBspModel_s::lmtexcoord_buffer, mBspModel_s::lmtexcoords, Mem_PoolAllocTypeN, MSURF_LIGHTMAP, mBspVertex_s::normal, mBspSurface_s::normal, mBspModel_s::normal_buffer, mBspModel_s::normals, mBspSurface_s::numedges, mBspModel_s::numsurfaces, mBspVertex_s::position, r_lightmaps, R_ReallocateStateArrays(), 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, VectorAdd, VectorCopy, VectorNotEmpty, 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
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, 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().

static void R_ModEndLoading ( const char *  mapName)
static
static void R_ModLoadLighting ( const lump_t l)
static
void R_ModReloadSurfacesArrays ( void  )
Todo:
fix this for threaded renderer mode

Definition at line 1167 of file r_model_brush.cpp.

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.

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 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().

static 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().

static 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_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
See also
R_SetParent

Definition at line 877 of file r_model_brush.cpp.

References mBspNode_s::children, mBspNode_s::contents, CONTENTS_NODE, and mBspNode_s::model.

Referenced by R_RecursiveSetModel().

static 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 model_s::bsp, Com_DPrintf(), Com_Printf(), DEBUG_RENDERER, mBspHeader_s::firstface, mBspModel_s::firstmodelsurface, i, NUM_REGULAR_MODELS, mBspHeader_s::numfaces, mBspModel_s::nummodelsurfaces, mBspModel_s::numsubmodels, mBspModel_s::numsurfaces, and mBspModel_s::submodels.

Referenced by R_ModAddMapTile().

static void R_SortSurfacesArrays ( const model_t mod)
static
static void R_SortSurfacesArrays_ ( mBspSurfaces_t surfs,
mBspSurfaces_t **  r_sorted_surfaces 
)
static

Variable Documentation

model_t* r_worldmodel
static

The currently loaded world model for the actual tile.

See also
r_mapTiles

Definition at line 51 of file r_model_brush.cpp.

Referenced by R_ModAddMapTile(), and R_SetupSubmodels().

ipos3_t shift
static

The shift array is used for random map assemblies (RMA) to shift the mins/maxs and stuff like that.

Definition at line 46 of file r_model_brush.cpp.

Referenced by CL_ClipMoveToLEs(), CM_AddMapTile(), R_LoadBspVertexArrays(), R_ModAddMapTile(), R_ModLoadLeafs(), R_ModLoadNodes(), R_ModLoadSubmodels(), R_ModShiftTile(), R_SetSurfaceExtents(), and TexinfoForBrushTexture().

int totalBspTriangles
static

Definition at line 803 of file r_model_brush.cpp.

Referenced by R_GenerateTriangleSoup(), and R_GenerateTriangleSoup_().