UFO: Alien Invasion
r_entity.cpp File Reference
#include "r_local.h"
#include "r_matrix.h"
#include "r_entity.h"
#include "r_mesh.h"
#include "r_mesh_anim.h"
#include "r_draw.h"
Include dependency graph for r_entity.cpp:

Go to the source code of this file.

Macros

#define MAX_ENTITIES   2048*2
 

Functions

void R_EntitySetOrigin (entity_t *ent, const vec3_t origin)
 setter for entity origin More...
 
void R_EntityAddToOrigin (entity_t *ent, const vec3_t offset)
 Translates the origin of the given entity by the given offset vector. More...
 
static void R_DrawBox (const entity_t *e)
 Draws the field marker entity is specified in CL_AddTargeting. More...
 
static void R_DrawFloor (const entity_t *e)
 Draws a marker on the ground to indicate pathing CL_AddPathingBox. More...
 
static void R_DrawArrow (const entity_t *e)
 Draws an arrow between two points. More...
 
void R_DrawEntityEffects (void)
 Draws shadow and highlight effects for the entities (actors) More...
 
void R_DrawMeshEntities (entity_t *ents)
 Draws the list of entities. More...
 
void R_DrawOpaqueMeshEntities (entity_t *ents)
 
static entity_tR_MergeSortMerge (entity_t *a, entity_t *b)
 
static entity_tR_MergeSortEntList (entity_t *c)
 Merge sort for the entity list. More...
 
void R_DrawBlendMeshEntities (entity_t *ents)
 
static void R_DrawNullModel (const entity_t *e)
 Draw replacement model (e.g. when model wasn't found) More...
 
void R_DrawSpecialEntities (const entity_t *ents)
 
void R_DrawNullEntities (const entity_t *ents)
 Draw entities which models couldn't be loaded. More...
 
void R_TransformForEntity (const entity_t *e, const vec3_t in, vec3_t out)
 
static float * R_CalcTransform (entity_t *e)
 Calculates transformation matrix for the model and its tags. More...
 
static bool R_CullEntity (entity_t *e)
 Perform a frustum cull check for a given entity. More...
 
void R_GetEntityLists (void)
 Primary entry point for drawing all entities. More...
 
entity_tR_GetFreeEntity (void)
 Get the next free entry in the entity list (the last one) More...
 
entity_tR_GetEntity (int id)
 Returns a specific entity from the list. More...
 
int R_AddEntity (const entity_t *ent)
 Adds a copy of the specified entity to the list of all known render entities. More...
 

Variables

static entity_t r_entities [MAX_ENTITIES]
 
entity_tr_opaque_mesh_entities
 
entity_tr_blend_mesh_entities
 
entity_tr_null_entities
 
entity_tr_special_entities
 
static image_tselectedActorIndicator
 
static image_tactorIndicator
 

Macro Definition Documentation

◆ MAX_ENTITIES

#define MAX_ENTITIES   2048*2

Definition at line 33 of file r_entity.cpp.

Function Documentation

◆ R_AddEntity()

int R_AddEntity ( const entity_t ent)

Adds a copy of the specified entity to the list of all known render entities.

See also
R_GetFreeEntity
Returns
The position of the entity in the render entity array or -1 in case the entity wasn't added.

Definition at line 706 of file r_entity.cpp.

References Com_Error(), ERR_DROP, MAX_ENTITIES, mod_bsp, entity_t::model, rendererData_t::numEntities, r_entities, and refdef.

Referenced by CL_AddActor(), CL_AddArrow(), CL_AddPathingBox(), CL_AddTargetingBox(), CL_AddUGV(), LE_AddEdictHighlight(), LE_AddToScene(), LE_BrushModelAction(), LM_AddToSceneOrder(), and SEQ_Render3D().

◆ R_CalcTransform()

◆ R_CullEntity()

static bool R_CullEntity ( entity_t e)
static

Perform a frustum cull check for a given entity.

Parameters
[in,out]eThe entity to perform the frustum cull check for
Returns
false if visible, true is the origin of the entity is outside the current frustum view

Definition at line 604 of file r_entity.cpp.

References cvar_t::integer, mod_bsp_submodel, entity_t::model, R_CullBspModel(), R_CullMeshModel(), r_nocull, RDF_NOWORLDMODEL, refdef, and rendererData_t::rendererFlags.

Referenced by R_GetEntityLists().

◆ R_DrawArrow()

static void R_DrawArrow ( const entity_t e)
static

◆ R_DrawBlendMeshEntities()

◆ R_DrawBox()

◆ R_DrawEntityEffects()

◆ R_DrawFloor()

static void R_DrawFloor ( const entity_t e)
static

Draws a marker on the ground to indicate pathing CL_AddPathingBox.

See also
CL_AddPathing
RF_BOX
Todo:
use default_texcoords

Definition at line 131 of file r_entity.cpp.

References entity_t::alpha, rendererData_t::batchCount, entity_t::color, GLint, it_pic, entity_t::origin, PLAYER_WIDTH, R_BindArray(), R_BindDefaultArray(), R_BindTexture, R_Color(), R_FindImage(), refdef, and image_t::texnum.

Referenced by R_DrawSpecialEntities().

◆ R_DrawMeshEntities()

void R_DrawMeshEntities ( entity_t ents)

Draws the list of entities.

Parameters
[in,out]entsThe list of entities that are going to get rendered
See also
R_GetEntityLists

Definition at line 316 of file r_entity.cpp.

References mod_alias_md2, mod_alias_md3, mod_obj, entity_t::model, entity_t::next, and R_DrawAliasModel().

Referenced by R_DrawBlendMeshEntities(), and R_DrawOpaqueMeshEntities().

◆ R_DrawNullEntities()

void R_DrawNullEntities ( const entity_t ents)

Draw entities which models couldn't be loaded.

Definition at line 503 of file r_entity.cpp.

References entity_t::next, and R_DrawNullModel().

Referenced by R_RenderFrame().

◆ R_DrawNullModel()

static void R_DrawNullModel ( const entity_t e)
static

Draw replacement model (e.g. when model wasn't found)

See also
R_DrawNullEntities

Definition at line 434 of file r_entity.cpp.

References rendererData_t::batchCount, i, M_PI, transform_t::matrix, R_BindArray(), R_BindDefaultArray(), R_EnableTexture(), refdef, texunit_diffuse, entity_t::transform, and VectorSet.

Referenced by R_DrawNullEntities().

◆ R_DrawOpaqueMeshEntities()

◆ R_DrawSpecialEntities()

void R_DrawSpecialEntities ( const entity_t ents)

◆ R_EntityAddToOrigin()

void R_EntityAddToOrigin ( entity_t ent,
const vec3_t  offset 
)

Translates the origin of the given entity by the given offset vector.

Parameters
[in,out]entThe entity to translate
[in]offsetThe translation vector

Definition at line 57 of file r_entity.cpp.

References entity_t::origin, and VectorAdd.

◆ R_EntitySetOrigin()

void R_EntitySetOrigin ( entity_t ent,
const vec3_t  origin 
)

setter for entity origin

Parameters
[out]entThe entity to set the origin for
[in]originThe new origin for the given entity

Definition at line 47 of file r_entity.cpp.

References entity_t::origin, and VectorCopy.

Referenced by CL_AddEdictFunc(), LE_AddToScene(), LM_AddToSceneOrder(), and SEQ_Render3D().

◆ R_GetEntity()

entity_t * R_GetEntity ( int  id)

Returns a specific entity from the list.

Definition at line 694 of file r_entity.cpp.

References id, rendererData_t::numEntities, r_entities, and refdef.

Referenced by LM_AddToSceneOrder(), and R_Trace().

◆ R_GetEntityLists()

◆ R_GetFreeEntity()

entity_t * R_GetFreeEntity ( void  )

Get the next free entry in the entity list (the last one)

Note
This can't overflow, because R_AddEntity checks the bounds
See also
R_AddEntity

Definition at line 684 of file r_entity.cpp.

References Com_Error(), ERR_DROP, MAX_ENTITIES, rendererData_t::numEntities, r_entities, and refdef.

Referenced by CL_AddActor(), CL_AddUGV(), and SEQ_Render3D().

◆ R_MergeSortEntList()

static entity_t * R_MergeSortEntList ( entity_t c)
static

Merge sort for the entity list.

Note
We can't use in-place merging of the entities array because there are references in this array that must stay intact (references for tagged models e.g.).
Returns
the first entity to render

Definition at line 386 of file r_entity.cpp.

References entity_t::next, R_MergeSortEntList(), and R_MergeSortMerge().

Referenced by R_DrawBlendMeshEntities(), and R_MergeSortEntList().

◆ R_MergeSortMerge()

static entity_t * R_MergeSortMerge ( entity_t a,
entity_t b 
)
static

Merge sort merge helper function.

Definition at line 357 of file r_entity.cpp.

References entity_t::distanceFromViewOrigin, entity_t::next, and R_MergeSortMerge().

Referenced by R_MergeSortEntList(), and R_MergeSortMerge().

◆ R_TransformForEntity()

void R_TransformForEntity ( const entity_t e,
const vec3_t  in,
vec3_t  out 
)

Transforms a point by the inverse of the world-model matrix for the specified entity.

Definition at line 522 of file r_entity.cpp.

References entity_t::angles, entity_t::getScaleX(), Matrix4x4_CreateFromQuakeEntity(), Matrix4x4_Invert_Simple(), Matrix4x4_Transform(), and entity_t::origin.

Referenced by R_RotateForMeshShadow().

Variable Documentation

◆ actorIndicator

image_t* actorIndicator
static

Definition at line 202 of file r_entity.cpp.

Referenced by R_DrawEntityEffects().

◆ r_blend_mesh_entities

entity_t* r_blend_mesh_entities

Definition at line 38 of file r_entity.cpp.

Referenced by R_GetEntityLists(), and R_RenderFrame().

◆ r_entities

entity_t r_entities[MAX_ENTITIES]
static

◆ r_null_entities

entity_t* r_null_entities

Definition at line 39 of file r_entity.cpp.

Referenced by R_GetEntityLists(), and R_RenderFrame().

◆ r_opaque_mesh_entities

entity_t* r_opaque_mesh_entities

Definition at line 37 of file r_entity.cpp.

Referenced by R_GetEntityLists(), and R_RenderFrame().

◆ r_special_entities

entity_t* r_special_entities

Definition at line 40 of file r_entity.cpp.

Referenced by R_GetEntityLists(), and R_RenderFrame().

◆ selectedActorIndicator

image_t* selectedActorIndicator
static

Definition at line 201 of file r_entity.cpp.

Referenced by R_DrawEntityEffects().