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

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

#define MAX_ENTITIES   2048*2

Definition at line 33 of file r_entity.cpp.

Referenced by R_AddEntity(), and R_GetFreeEntity().

Function Documentation

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, rendererData_t::numEntities, 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().

static float* R_CalcTransform ( entity_t e)
static
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_s::integer, mod_bsp_submodel, R_CullBspModel(), R_CullMeshModel(), r_nocull, RDF_NOWORLDMODEL, refdef, and rendererData_t::rendererFlags.

Referenced by R_GetEntityLists().

static void R_DrawArrow ( const entity_t e)
static

Draws an arrow between two points.

See also
CL_AddArrow
RF_BOX

Definition at line 175 of file r_entity.cpp.

References rendererData_t::batchCount, entity_t::origin, R_BindArray(), R_BindDefaultArray(), R_Color(), and refdef.

Referenced by R_DrawSpecialEntities().

static void R_DrawBox ( const entity_t e)
static

Draws the field marker entity is specified in CL_AddTargeting.

See also
CL_AddTargeting
RF_BOX
Todo:
fill one array

Definition at line 67 of file r_entity.cpp.

References rendererData_t::batchCount, f, entity_t::origin, R_BindArray(), R_BindDefaultArray(), R_BindTexture, R_Color(), R_DrawBoundingBox(), R_DrawTexturedBox(), refdef, and VectorNotEmpty.

Referenced by R_DrawSpecialEntities().

void R_DrawEntityEffects ( void  )

Draws shadow and highlight effects for the entities (actors)

Note
The origins are already transformed
Todo:
use default_texcoords
Todo:
use default_texcoords

Definition at line 208 of file r_entity.cpp.

References rendererData_t::batchCount, i, cvar_s::integer, it_effect, rendererData_t::numEntities, R_BindArray(), R_BindDefaultArray(), R_BindTexture, R_Color(), R_EnableBlend(), R_EnableDrawAsGlow(), R_FindImage(), r_stencilshadows, refdef, RF_ACTOR, RF_ALLIED, RF_BLOOD, RF_BOX, RF_MEMBER, RF_NEUTRAL, RF_OPPONENT, RF_SELECTED, RF_SHADOW, SELECTION_DELTA, shadow, image_s::texnum, and Vector4Set.

Referenced by R_RenderFrame().

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 rendererData_t::batchCount, f, it_pic, entity_t::origin, PLAYER_WIDTH, R_BindArray(), R_BindDefaultArray(), R_BindTexture, R_Color(), R_FindImage(), refdef, and image_s::texnum.

Referenced by R_DrawSpecialEntities().

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, and R_DrawAliasModel().

Referenced by R_DrawBlendMeshEntities(), and R_DrawOpaqueMeshEntities().

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

Referenced by R_RenderFrame().

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, R_BindArray(), R_BindDefaultArray(), R_EnableTexture(), refdef, texunit_diffuse, and VectorSet.

Referenced by R_DrawNullEntities().

void R_DrawSpecialEntities ( const entity_t ents)
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.

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

entity_t* R_GetEntity ( int  id)

Returns a specific entity from the list.

Definition at line 694 of file r_entity.cpp.

References rendererData_t::numEntities, and refdef.

Referenced by LM_AddToSceneOrder(), and R_Trace().

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, and refdef.

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

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

Referenced by R_DrawBlendMeshEntities().

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.

Referenced by R_MergeSortEntList().

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 Matrix4x4_CreateFromQuakeEntity(), Matrix4x4_Invert_Simple(), Matrix4x4_Transform(), and entity_t::origin.

Referenced by R_RotateForMeshShadow().

Variable Documentation

image_t* actorIndicator
static

Definition at line 202 of file r_entity.cpp.

entity_t* r_blend_mesh_entities

Definition at line 38 of file r_entity.cpp.

Referenced by R_GetEntityLists(), and R_RenderFrame().

entity_t r_entities[MAX_ENTITIES]
static

Definition at line 35 of file r_entity.cpp.

entity_t* r_null_entities

Definition at line 39 of file r_entity.cpp.

Referenced by R_GetEntityLists(), and R_RenderFrame().

entity_t* r_opaque_mesh_entities

Definition at line 37 of file r_entity.cpp.

Referenced by R_GetEntityLists(), and R_RenderFrame().

entity_t* r_special_entities

Definition at line 40 of file r_entity.cpp.

Referenced by R_GetEntityLists(), and R_RenderFrame().

image_t* selectedActorIndicator
static

Definition at line 201 of file r_entity.cpp.