mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 15:01:41 +00:00
[renderer] Tidy up entity component access
Since entity_t has a pointer to the registry owning the entity, there's no need to access a global to get at the registry. Also move component getting closer to where it's used.
This commit is contained in:
parent
5b0810f4c2
commit
2a9fcf4f5f
23 changed files with 111 additions and 161 deletions
|
@ -166,7 +166,6 @@ typedef struct {
|
|||
int ambientlight;
|
||||
int drawflat;
|
||||
|
||||
struct scene_s *scene;
|
||||
struct model_s *worldmodel;
|
||||
} refdef_t;
|
||||
|
||||
|
|
|
@ -274,15 +274,13 @@ GL_DrawAliasShadow (transform_t transform, const aliashdr_t *paliashdr,
|
|||
static inline vert_order_t *
|
||||
GL_GetAliasFrameVerts16 (aliashdr_t *paliashdr, entity_t e)
|
||||
{
|
||||
animation_t *animation = Ent_GetComponent (e.id, scene_animation,
|
||||
r_refdef.scene->reg);
|
||||
float blend;
|
||||
animation_t *animation = Ent_GetComponent (e.id, scene_animation, e.reg);
|
||||
float blend = R_AliasGetLerpedFrames (animation, paliashdr);
|
||||
int count, i;
|
||||
trivertx16_t *verts;
|
||||
vert_order_t *vo;
|
||||
blended_vert_t *vo_v;
|
||||
|
||||
blend = R_AliasGetLerpedFrames (animation, paliashdr);
|
||||
|
||||
verts = (trivertx16_t *) ((byte *) paliashdr + paliashdr->posedata);
|
||||
|
||||
|
@ -341,15 +339,13 @@ GL_GetAliasFrameVerts16 (aliashdr_t *paliashdr, entity_t e)
|
|||
static inline vert_order_t *
|
||||
GL_GetAliasFrameVerts (aliashdr_t *paliashdr, entity_t e)
|
||||
{
|
||||
animation_t *animation = Ent_GetComponent (e.id, scene_animation,
|
||||
r_refdef.scene->reg);
|
||||
float blend;
|
||||
animation_t *animation = Ent_GetComponent (e.id, scene_animation, e.reg);
|
||||
float blend = R_AliasGetLerpedFrames (animation, paliashdr);
|
||||
int count, i;
|
||||
trivertx_t *verts;
|
||||
vert_order_t *vo;
|
||||
blended_vert_t *vo_v;
|
||||
|
||||
blend = R_AliasGetLerpedFrames (animation, paliashdr);
|
||||
|
||||
verts = (trivertx_t *) ((byte *) paliashdr + paliashdr->posedata);
|
||||
|
||||
|
@ -417,17 +413,14 @@ gl_R_DrawAliasModel (entity_t e)
|
|||
unsigned lnum;
|
||||
aliashdr_t *paliashdr;
|
||||
dlight_t *l;
|
||||
model_t *model;
|
||||
vec3_t dist, scale;
|
||||
vec4f_t origin;
|
||||
vert_order_t *vo;
|
||||
transform_t transform = Entity_Transform (e);
|
||||
renderer_t *renderer = Ent_GetComponent (e.id, scene_renderer,
|
||||
r_refdef.scene->reg);
|
||||
|
||||
model = renderer->model;
|
||||
renderer_t *renderer = Ent_GetComponent (e.id, scene_renderer, e.reg);
|
||||
model_t *model = renderer->model;
|
||||
|
||||
radius = model->radius;
|
||||
transform_t transform = Entity_Transform (e);
|
||||
origin = Transform_GetWorldPosition (transform);
|
||||
VectorCopy (Transform_GetWorldScale (transform), scale);
|
||||
//FIXME assumes uniform scale
|
||||
|
@ -570,9 +563,8 @@ gl_R_DrawAliasModel (entity_t e)
|
|||
} else {
|
||||
maliasskindesc_t *skindesc;
|
||||
animation_t *animation = Ent_GetComponent (e.id, scene_animation,
|
||||
r_refdef.scene->reg);
|
||||
skindesc = R_AliasGetSkindesc (animation, renderer->skinnum,
|
||||
paliashdr);
|
||||
e.reg);
|
||||
skindesc = R_AliasGetSkindesc (animation, renderer->skinnum, paliashdr);
|
||||
texture = skindesc->texnum;
|
||||
if (gl_fb_models && !is_fullbright) {
|
||||
fb_texture = skindesc->fb_texnum;
|
||||
|
|
|
@ -90,11 +90,7 @@ gl_draw_iqm_frame (iqm_t *iqm, gliqm_t *gl, iqmframe_t *frame, iqmmesh *mesh)
|
|||
void
|
||||
gl_R_DrawIQMModel (entity_t ent)
|
||||
{
|
||||
transform_t transform = Entity_Transform (ent);
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer,
|
||||
r_refdef.scene->reg);
|
||||
animation_t *animation = Ent_GetComponent (ent.id, scene_animation,
|
||||
r_refdef.scene->reg);
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer, ent.reg);
|
||||
model_t *model = renderer->model;
|
||||
iqm_t *iqm = (iqm_t *) model->aliashdr;
|
||||
gliqm_t *gl = (gliqm_t *) iqm->extra_data;
|
||||
|
@ -102,11 +98,14 @@ gl_R_DrawIQMModel (entity_t ent)
|
|||
iqmframe_t *frame;
|
||||
int i;
|
||||
|
||||
animation_t *animation = Ent_GetComponent (ent.id, scene_animation,
|
||||
ent.reg);
|
||||
blend = R_IQMGetLerpedFrames (animation, iqm);
|
||||
frame = R_IQMBlendPalette (iqm, animation->pose1, animation->pose2,
|
||||
blend, 0, gl->blend_palette, gl->palette_size);
|
||||
|
||||
qfglPushMatrix ();
|
||||
transform_t transform = Entity_Transform (ent);
|
||||
gl_R_RotateForEntity (Transform_GetWorldMatrixPtr (transform));
|
||||
|
||||
for (i = 0; i < iqm->num_meshes; i++) {
|
||||
|
|
|
@ -60,22 +60,20 @@ void (*gl_R_DrawSpriteModel) (struct entity_s ent);
|
|||
static void
|
||||
R_DrawSpriteModel_f (entity_t e)
|
||||
{
|
||||
transform_t transform = Entity_Transform (e);
|
||||
renderer_t *renderer = Ent_GetComponent (e.id, scene_renderer,
|
||||
r_refdef.scene->reg);
|
||||
animation_t *animation = Ent_GetComponent (e.id, scene_animation,
|
||||
r_refdef.scene->reg);
|
||||
renderer_t *renderer = Ent_GetComponent (e.id, scene_renderer, e.reg);
|
||||
msprite_t *sprite = renderer->model->cache.data;
|
||||
float modelalpha, color[4];
|
||||
vec4f_t cameravec = {};
|
||||
vec4f_t up = {}, right = {}, pn = {};
|
||||
vec4f_t origin, point;
|
||||
msprite_t *sprite = renderer->model->cache.data;
|
||||
mspriteframe_t *frame;
|
||||
|
||||
transform_t transform = Entity_Transform (e);
|
||||
origin = Transform_GetWorldPosition (transform);
|
||||
cameravec = r_refdef.frame.position - origin;
|
||||
|
||||
// don't bother culling, it's just a single polygon without a surface cache
|
||||
animation_t *animation = Ent_GetComponent (e.id, scene_animation, e.reg);
|
||||
frame = R_GetSpriteFrame (sprite, animation);
|
||||
|
||||
if (!R_BillboardFrame (transform, sprite->type, cameravec,
|
||||
|
@ -122,27 +120,25 @@ R_DrawSpriteModel_f (entity_t e)
|
|||
static void
|
||||
R_DrawSpriteModel_VA_f (entity_t e)
|
||||
{
|
||||
transform_t transform = Entity_Transform (e);
|
||||
renderer_t *renderer = Ent_GetComponent (e.id, scene_renderer,
|
||||
r_refdef.scene->reg);
|
||||
animation_t *animation = Ent_GetComponent (e.id, scene_animation,
|
||||
r_refdef.scene->reg);
|
||||
renderer_t *renderer = Ent_GetComponent (e.id, scene_renderer, e.reg);
|
||||
msprite_t *psprite = renderer->model->cache.data;
|
||||
unsigned char modelalpha, color[4];
|
||||
vec4f_t up = {}, right = {};
|
||||
vec4f_t origin, point;
|
||||
int i;
|
||||
// unsigned int vacount;
|
||||
msprite_t *psprite = renderer->model->cache.data;
|
||||
mspriteframe_t *frame;
|
||||
varray_t2f_c4ub_v3f_t *VA;
|
||||
|
||||
VA = gl_spriteVertexArray; // FIXME: Despair
|
||||
|
||||
// don't bother culling, it's just a single polygon without a surface cache
|
||||
animation_t *animation = Ent_GetComponent (e.id, scene_animation, e.reg);
|
||||
frame = R_GetSpriteFrame (psprite, animation);
|
||||
|
||||
qfglBindTexture (GL_TEXTURE_2D, frame->gl_texturenum); // FIXME: DESPAIR
|
||||
|
||||
transform_t transform = Entity_Transform (e);
|
||||
if (psprite->type == SPR_ORIENTED) { // bullet marks on walls
|
||||
up = Transform_Up (transform);
|
||||
right = Transform_Right (transform);
|
||||
|
|
|
@ -162,8 +162,7 @@ static void
|
|||
R_DrawViewModel (void)
|
||||
{
|
||||
entity_t ent = vr_data.view_model;
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer,
|
||||
r_refdef.scene->reg);
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer, ent.reg);
|
||||
if (vr_data.inhibit_viewmodel
|
||||
|| !r_drawviewmodel
|
||||
|| !r_drawentities
|
||||
|
|
|
@ -165,7 +165,6 @@ gl_R_NewScene (scene_t *scene)
|
|||
for (int i = 0; i < 256; i++)
|
||||
d_lightstylevalue[i] = 264; // normal light value
|
||||
|
||||
r_refdef.scene = scene;
|
||||
r_refdef.worldmodel = scene->worldmodel;
|
||||
brush = &scene->worldmodel->brush;
|
||||
|
||||
|
|
|
@ -501,19 +501,16 @@ gl_R_DrawBrushModel (entity_t e)
|
|||
{
|
||||
float dot, radius;
|
||||
transform_t transform = Entity_Transform (e);
|
||||
renderer_t *renderer = Ent_GetComponent (e.id, scene_renderer,
|
||||
r_refdef.scene->reg);
|
||||
animation_t *animation = Ent_GetComponent (e.id, scene_animation,
|
||||
r_refdef.scene->reg);
|
||||
msurface_t *surf;
|
||||
qboolean rotated;
|
||||
vec3_t mins, maxs;
|
||||
mat4f_t worldMatrix;
|
||||
renderer_t *renderer = Ent_GetComponent (e.id, scene_renderer, e.reg);
|
||||
model_t *model = renderer->model;
|
||||
mod_brush_t *brush = &model->brush;
|
||||
glbspctx_t bspctx = {
|
||||
brush,
|
||||
animation,
|
||||
Ent_GetComponent (e.id, scene_animation, e.reg),
|
||||
renderer->full_transform,
|
||||
renderer->colormod,
|
||||
};
|
||||
|
|
|
@ -157,16 +157,14 @@ calc_lighting (entity_t ent, float *ambient, float *shadelight,
|
|||
unsigned i;
|
||||
float add;
|
||||
vec3_t dist;
|
||||
vec4f_t entorigin;
|
||||
int light;
|
||||
transform_t transform = Entity_Transform (ent);
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer,
|
||||
r_refdef.scene->reg);
|
||||
|
||||
entorigin = Transform_GetWorldPosition (transform);
|
||||
transform_t transform = Entity_Transform (ent);
|
||||
vec4f_t entorigin = Transform_GetWorldPosition (transform);
|
||||
|
||||
VectorSet ( -1, 0, 0, lightvec); //FIXME
|
||||
light = R_LightPoint (&r_refdef.worldmodel->brush, entorigin);
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer, ent.reg);
|
||||
*ambient = max (light, max (renderer->model->min_light,
|
||||
renderer->min_light) * 128);
|
||||
*shadelight = *ambient;
|
||||
|
@ -245,15 +243,12 @@ glsl_R_DrawAlias (entity_t ent)
|
|||
|
||||
calc_lighting (ent, &ambient, &shadelight, lightvec);
|
||||
|
||||
transform_t transform = Entity_Transform (ent);
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer,
|
||||
r_refdef.scene->reg);
|
||||
animation_t *animation = Ent_GetComponent (ent.id, scene_animation,
|
||||
r_refdef.scene->reg);
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer, ent.reg);
|
||||
model_t *model = renderer->model;
|
||||
if (!(hdr = model->aliashdr))
|
||||
hdr = Cache_Get (&model->cache);
|
||||
|
||||
transform_t transform = Entity_Transform (ent);
|
||||
Transform_GetWorldMatrix (transform, worldMatrix);
|
||||
// we need only the rotation for normals.
|
||||
VectorCopy (worldMatrix[0], norm_mat + 0);
|
||||
|
@ -271,6 +266,8 @@ glsl_R_DrawAlias (entity_t ent)
|
|||
mmulf (mvp_mat, worldMatrix, mvp_mat);
|
||||
mmulf (mvp_mat, alias_vp, mvp_mat);
|
||||
|
||||
animation_t *animation = Ent_GetComponent (ent.id, scene_animation,
|
||||
ent.reg);
|
||||
colormap = glsl_colormap;
|
||||
if (renderer->skin && renderer->skin->auxtex)
|
||||
colormap = renderer->skin->auxtex;
|
||||
|
|
|
@ -654,11 +654,7 @@ R_DrawBrushModel (entity_t e)
|
|||
{
|
||||
float dot, radius;
|
||||
unsigned k;
|
||||
transform_t transform = Entity_Transform (e);
|
||||
renderer_t *renderer = Ent_GetComponent (e.id, scene_renderer,
|
||||
r_refdef.scene->reg);
|
||||
animation_t *animation = Ent_GetComponent (e.id, scene_animation,
|
||||
r_refdef.scene->reg);
|
||||
renderer_t *renderer = Ent_GetComponent (e.id, scene_renderer, e.reg);
|
||||
model_t *model = renderer->model;
|
||||
mod_brush_t *brush = &model->brush;
|
||||
plane_t *plane;
|
||||
|
@ -668,12 +664,13 @@ R_DrawBrushModel (entity_t e)
|
|||
vec4f_t org;
|
||||
glslbspctx_t bctx = {
|
||||
brush,
|
||||
animation,
|
||||
Ent_GetComponent (e.id, scene_animation, e.reg),
|
||||
renderer->full_transform,
|
||||
renderer->colormod,
|
||||
};
|
||||
|
||||
mat4f_t mat;
|
||||
transform_t transform = Entity_Transform (e);
|
||||
Transform_GetWorldMatrix (transform, mat);
|
||||
memcpy (renderer->full_transform, mat, sizeof (mat));//FIXME
|
||||
if (mat[0][0] != 1 || mat[1][1] != 1 || mat[2][2] != 1) {
|
||||
|
|
|
@ -206,13 +206,9 @@ set_arrays (iqm_t *iqm)
|
|||
void
|
||||
glsl_R_DrawIQM (entity_t ent)
|
||||
{
|
||||
transform_t transform = Entity_Transform (ent);
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer,
|
||||
r_refdef.scene->reg);
|
||||
animation_t *animation = Ent_GetComponent (ent.id, scene_animation,
|
||||
r_refdef.scene->reg);
|
||||
static quat_t color = { 1, 1, 1, 1};
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer, ent.reg);
|
||||
model_t *model = renderer->model;
|
||||
static quat_t color = { 1, 1, 1, 1};
|
||||
iqm_t *iqm = (iqm_t *) model->aliashdr;
|
||||
glsliqm_t *glsl = (glsliqm_t *) iqm->extra_data;
|
||||
dlight_t *lights[MAX_IQM_LIGHTS];
|
||||
|
@ -225,6 +221,7 @@ glsl_R_DrawIQM (entity_t ent)
|
|||
|
||||
// we need only the rotation for normals.
|
||||
mat4f_t mat;
|
||||
transform_t transform = Entity_Transform (ent);
|
||||
Transform_GetWorldMatrix (transform, mat);
|
||||
VectorCopy (mat[0], norm_mat + 0);
|
||||
VectorCopy (mat[1], norm_mat + 3);
|
||||
|
@ -236,6 +233,8 @@ glsl_R_DrawIQM (entity_t ent)
|
|||
VectorScale (ambientcolor, 1/255.0, ambientcolor);
|
||||
R_FindNearLights (entorigin, MAX_IQM_LIGHTS, lights);
|
||||
|
||||
animation_t *animation = Ent_GetComponent (ent.id, scene_animation,
|
||||
ent.reg);
|
||||
blend = R_IQMGetLerpedFrames (animation, iqm);
|
||||
frame = R_IQMBlendFrames (iqm, animation->pose1, animation->pose2,
|
||||
blend, 0);
|
||||
|
|
|
@ -118,8 +118,7 @@ static void
|
|||
R_DrawViewModel (void)
|
||||
{
|
||||
entity_t ent = vr_data.view_model;
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer,
|
||||
r_refdef.scene->reg);
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer, ent.reg);
|
||||
if (vr_data.inhibit_viewmodel
|
||||
|| !r_drawviewmodel
|
||||
|| !r_drawentities
|
||||
|
@ -199,7 +198,6 @@ glsl_R_NewScene (scene_t *scene)
|
|||
for (i = 0; i < 256; i++)
|
||||
d_lightstylevalue[i] = 264; // normal light value
|
||||
|
||||
r_refdef.scene = scene;
|
||||
r_refdef.worldmodel = scene->worldmodel;
|
||||
|
||||
// Force a vis update
|
||||
|
|
|
@ -134,7 +134,7 @@ R_GetSpriteFrames (entity_t ent, msprite_t *sprite, mspriteframe_t **frame1,
|
|||
mspriteframe_t **frame2, float *blend)
|
||||
{
|
||||
animation_t *animation = Ent_GetComponent (ent.id, scene_animation,
|
||||
r_refdef.scene->reg);
|
||||
ent.reg);
|
||||
int framenum = animation->frame;
|
||||
int pose;
|
||||
int i, numframes;
|
||||
|
@ -211,9 +211,7 @@ make_quad (mspriteframe_t *frame, vec4f_t origin, vec4f_t sright, vec4f_t sup, f
|
|||
void
|
||||
glsl_R_DrawSprite (entity_t ent)
|
||||
{
|
||||
transform_t transform = Entity_Transform (ent);
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer,
|
||||
r_refdef.scene->reg);
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer, ent.reg);
|
||||
msprite_t *sprite = (msprite_t *) renderer->model->cache.data;
|
||||
mspriteframe_t *frame1, *frame2;
|
||||
float blend;
|
||||
|
@ -230,6 +228,7 @@ glsl_R_DrawSprite (entity_t ent)
|
|||
{ 0, 1, 0, 1 },
|
||||
};
|
||||
|
||||
transform_t transform = Entity_Transform (ent);
|
||||
vec4f_t origin = Transform_GetWorldPosition (transform);
|
||||
cameravec = r_refdef.frame.position - origin;
|
||||
|
||||
|
|
|
@ -230,8 +230,8 @@ surfcache_t *
|
|||
D_CacheSurface (entity_t ent, msurface_t *surface, int miplevel)
|
||||
{
|
||||
surfcache_t *cache;
|
||||
animation_t *animation = Ent_GetComponent (ent.id, scene_animation, r_refdef.scene->reg);
|
||||
transform_t transform = Entity_Transform (ent);
|
||||
animation_t *animation = Ent_GetComponent (ent.id, scene_animation,
|
||||
ent.reg);
|
||||
|
||||
// if the surface is animating or flashing, flush the cache
|
||||
r_drawsurf.texture = R_TextureAnimation (animation, surface);
|
||||
|
@ -285,6 +285,7 @@ D_CacheSurface (entity_t ent, msurface_t *surface, int miplevel)
|
|||
r_drawsurf.surf = surface;
|
||||
|
||||
c_surf++;
|
||||
transform_t transform = Entity_Transform (ent);
|
||||
R_DrawSurface (transform);
|
||||
|
||||
return surface->cachespots[miplevel];
|
||||
|
|
|
@ -99,15 +99,13 @@ R_AliasCheckBBox (entity_t ent)
|
|||
qboolean zclipped, zfullyclipped;
|
||||
unsigned int anyclip, allclip;
|
||||
int minz;
|
||||
visibility_t *visibility = Ent_GetComponent (ent.id, scene_visibility,
|
||||
r_refdef.scene->reg);
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer,
|
||||
r_refdef.scene->reg);
|
||||
animation_t *animation = Ent_GetComponent (ent.id, scene_animation,
|
||||
r_refdef.scene->reg);
|
||||
|
||||
// expand, rotate, and translate points into worldspace
|
||||
visibility_t *visibility = Ent_GetComponent (ent.id, scene_visibility,
|
||||
ent.reg);
|
||||
visibility->trivial_accept = 0;
|
||||
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer, ent.reg);
|
||||
pmodel = renderer->model;
|
||||
if (!(pahdr = pmodel->aliashdr))
|
||||
pahdr = Cache_Get (&pmodel->cache);
|
||||
|
@ -116,6 +114,8 @@ R_AliasCheckBBox (entity_t ent)
|
|||
R_AliasSetUpTransform (ent, 0);
|
||||
|
||||
// construct the base bounding box for this frame
|
||||
animation_t *animation = Ent_GetComponent (ent.id, scene_animation,
|
||||
ent.reg);
|
||||
frame = animation->frame;
|
||||
// TODO: don't repeat this check when drawing?
|
||||
if ((frame >= pmdl->numframes) || (frame < 0)) {
|
||||
|
@ -531,11 +531,8 @@ R_AliasPrepareUnclippedPoints (void)
|
|||
static void
|
||||
R_AliasSetupSkin (entity_t ent)
|
||||
{
|
||||
int skinnum;
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer,
|
||||
r_refdef.scene->reg);
|
||||
|
||||
skinnum = renderer->skinnum;
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer, ent.reg);
|
||||
int skinnum = renderer->skinnum;
|
||||
if ((skinnum >= pmdl->numskins) || (skinnum < 0)) {
|
||||
Sys_MaskPrintf (SYS_dev, "R_AliasSetupSkin: no such skin # %d\n",
|
||||
skinnum);
|
||||
|
@ -543,7 +540,7 @@ R_AliasSetupSkin (entity_t ent)
|
|||
}
|
||||
|
||||
animation_t *animation = Ent_GetComponent (ent.id, scene_animation,
|
||||
r_refdef.scene->reg);
|
||||
ent.reg);
|
||||
pskindesc = R_AliasGetSkindesc (animation, skinnum, paliashdr);
|
||||
|
||||
a_skinwidth = pmdl->skinwidth;
|
||||
|
@ -607,7 +604,7 @@ R_AliasSetupFrame (entity_t ent)
|
|||
maliasframedesc_t *frame;
|
||||
|
||||
animation_t *animation = Ent_GetComponent (ent.id, scene_animation,
|
||||
r_refdef.scene->reg);
|
||||
ent.reg);
|
||||
frame = R_AliasGetFramedesc (animation, paliashdr);
|
||||
r_apverts = (trivertx_t *) ((byte *) paliashdr + frame->frame);
|
||||
}
|
||||
|
@ -618,13 +615,10 @@ R_AliasDrawModel (entity_t ent, alight_t *lighting)
|
|||
{
|
||||
int size;
|
||||
finalvert_t *finalverts;
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer,
|
||||
r_refdef.scene->reg);
|
||||
visibility_t *visibility = Ent_GetComponent (ent.id, scene_visibility,
|
||||
r_refdef.scene->reg);
|
||||
|
||||
r_amodels_drawn++;
|
||||
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer, ent.reg);
|
||||
if (!(paliashdr = renderer->model->aliashdr))
|
||||
paliashdr = Cache_Get (&renderer->model->cache);
|
||||
pmdl = (mdl_t *) ((byte *) paliashdr + paliashdr->model);
|
||||
|
@ -642,6 +636,8 @@ R_AliasDrawModel (entity_t ent, alight_t *lighting)
|
|||
pauxverts = (auxvert_t *) &pfinalverts[pmdl->numverts + 1];
|
||||
|
||||
R_AliasSetupSkin (ent);
|
||||
visibility_t *visibility = Ent_GetComponent (ent.id, scene_visibility,
|
||||
ent.reg);
|
||||
R_AliasSetUpTransform (ent, visibility->trivial_accept);
|
||||
R_AliasSetupLighting (lighting);
|
||||
R_AliasSetupFrame (ent);
|
||||
|
|
|
@ -356,8 +356,7 @@ R_RenderFace (entity_t ent, msurface_t *fa, int clipflags)
|
|||
vec3_t p_normal;
|
||||
medge_t *pedges, tedge;
|
||||
clipplane_t *pclip;
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer,
|
||||
r_refdef.scene->reg);
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer, ent.reg);
|
||||
mod_brush_t *brush = &renderer->model->brush;
|
||||
|
||||
// skip out if no more surfs
|
||||
|
@ -627,8 +626,7 @@ R_RenderPoly (entity_t ent, msurface_t *fa, int clipflags)
|
|||
polyvert_t pverts[100]; // FIXME: do real number, safely
|
||||
int vertpage, newverts, newpage, lastvert;
|
||||
qboolean visible;
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer,
|
||||
r_refdef.scene->reg);
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer, ent.reg);
|
||||
mod_brush_t *brush = &renderer->model->brush;
|
||||
|
||||
// FIXME: clean this up and make it faster
|
||||
|
|
|
@ -292,12 +292,7 @@ R_IQMSetUpTransform (entity_t ent, int trivial_accept)
|
|||
void
|
||||
R_IQMDrawModel (entity_t ent, alight_t *plighting)
|
||||
{
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer,
|
||||
r_refdef.scene->reg);
|
||||
visibility_t *visibility = Ent_GetComponent (ent.id, scene_visibility,
|
||||
r_refdef.scene->reg);
|
||||
animation_t *animation = Ent_GetComponent (ent.id, scene_animation,
|
||||
r_refdef.scene->reg);
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer, ent.reg);
|
||||
model_t *model = renderer->model;
|
||||
iqm_t *iqm = (iqm_t *) model->aliashdr;
|
||||
swiqm_t *sw = (swiqm_t *) iqm->extra_data;
|
||||
|
@ -308,6 +303,9 @@ R_IQMDrawModel (entity_t ent, alight_t *plighting)
|
|||
size = (CACHE_SIZE - 1)
|
||||
+ sizeof (finalvert_t) * (iqm->num_verts + 1)
|
||||
+ sizeof (auxvert_t) * iqm->num_verts;
|
||||
|
||||
animation_t *animation = Ent_GetComponent (ent.id, scene_animation,
|
||||
ent.reg);
|
||||
blend = R_IQMGetLerpedFrames (animation, iqm);
|
||||
frame = R_IQMBlendPalette (iqm, animation->pose1, animation->pose2,
|
||||
blend, size, sw->blend_palette,
|
||||
|
@ -318,6 +316,8 @@ R_IQMDrawModel (entity_t ent, alight_t *plighting)
|
|||
(((intptr_t) &pfinalverts[0] + CACHE_SIZE - 1) & ~(CACHE_SIZE - 1));
|
||||
pauxverts = (auxvert_t *) &pfinalverts[iqm->num_verts + 1];
|
||||
|
||||
visibility_t *visibility = Ent_GetComponent (ent.id, scene_visibility,
|
||||
ent.reg);
|
||||
R_IQMSetUpTransform (ent, visibility->trivial_accept);
|
||||
|
||||
R_IQMSetupLighting (ent, plighting);
|
||||
|
|
|
@ -152,7 +152,6 @@ R_NewScene (scene_t *scene)
|
|||
model_t *worldmodel = scene->worldmodel;
|
||||
mod_brush_t *brush = &worldmodel->brush;
|
||||
|
||||
r_refdef.scene = scene;
|
||||
r_refdef.worldmodel = worldmodel;
|
||||
|
||||
// clear out efrags in case the level hasn't been reloaded
|
||||
|
@ -234,8 +233,7 @@ setup_lighting (entity_t ent, alight_t *lighting)
|
|||
float add;
|
||||
float lightvec[3] = { -1, 0, 0 };
|
||||
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer,
|
||||
r_refdef.scene->reg);
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer, ent.reg);
|
||||
minlight = max (renderer->model->min_light, renderer->min_light);
|
||||
|
||||
// 128 instead of 255 due to clamping below
|
||||
|
@ -270,7 +268,7 @@ draw_alias_entity (entity_t ent)
|
|||
// see if the bounding box lets us trivially reject, also
|
||||
// sets trivial accept status
|
||||
visibility_t *visibility = Ent_GetComponent (ent.id, scene_visibility,
|
||||
r_refdef.scene->reg);
|
||||
ent.reg);
|
||||
visibility->trivial_accept = 0; //FIXME
|
||||
if (R_AliasCheckBBox (ent)) {
|
||||
alight_t lighting;
|
||||
|
@ -285,7 +283,7 @@ draw_iqm_entity (entity_t ent)
|
|||
// see if the bounding box lets us trivially reject, also
|
||||
// sets trivial accept status
|
||||
visibility_t *visibility = Ent_GetComponent (ent.id, scene_visibility,
|
||||
r_refdef.scene->reg);
|
||||
ent.reg);
|
||||
visibility->trivial_accept = 0; //FIXME
|
||||
|
||||
alight_t lighting;
|
||||
|
@ -339,11 +337,11 @@ R_DrawViewModel (void)
|
|||
viewent = vr_data.view_model;
|
||||
|
||||
renderer_t *renderer = Ent_GetComponent (viewent.id, scene_renderer,
|
||||
r_refdef.scene->reg);
|
||||
transform_t transform = Entity_Transform (viewent);
|
||||
viewent.reg);
|
||||
if (!renderer->model)
|
||||
return;
|
||||
|
||||
transform_t transform = Entity_Transform (viewent);
|
||||
VectorCopy (Transform_GetWorldPosition (transform), r_entorigin);
|
||||
|
||||
VectorNegate (vup, lighting.lightvec);
|
||||
|
@ -382,7 +380,7 @@ R_DrawViewModel (void)
|
|||
}
|
||||
|
||||
static int
|
||||
R_BmodelCheckBBox (entity_t ent, model_t *clmodel, float *minmaxs)
|
||||
R_BmodelCheckBBox (transform_t transform, model_t *clmodel, float *minmaxs)
|
||||
{
|
||||
int i, *pindex, clipflags;
|
||||
vec3_t acceptpt, rejectpt;
|
||||
|
@ -391,7 +389,6 @@ R_BmodelCheckBBox (entity_t ent, model_t *clmodel, float *minmaxs)
|
|||
|
||||
clipflags = 0;
|
||||
|
||||
transform_t transform = Entity_Transform (ent);
|
||||
Transform_GetWorldMatrix (transform, mat);
|
||||
if (mat[0][0] != 1 || mat[1][1] != 1 || mat[2][2] != 1) {
|
||||
for (i = 0; i < 4; i++) {
|
||||
|
@ -443,7 +440,6 @@ R_DrawBrushEntitiesOnList (entqueue_t *queue)
|
|||
int j, clipflags;
|
||||
unsigned int k;
|
||||
vec3_t origin;
|
||||
model_t *clmodel;
|
||||
float minmaxs[6];
|
||||
|
||||
if (!r_drawentities)
|
||||
|
@ -454,25 +450,23 @@ R_DrawBrushEntitiesOnList (entqueue_t *queue)
|
|||
for (size_t i = 0; i < queue->ent_queues[mod_brush].size; i++) {
|
||||
entity_t ent = queue->ent_queues[mod_brush].a[i];
|
||||
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer,
|
||||
r_refdef.scene->reg);
|
||||
transform_t transform = Entity_Transform (ent);
|
||||
visibility_t *visibility = Ent_GetComponent (ent.id, scene_visibility,
|
||||
r_refdef.scene->reg);
|
||||
VectorCopy (Transform_GetWorldPosition (transform), origin);
|
||||
clmodel = renderer->model;
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer,
|
||||
ent.reg);
|
||||
model_t *model = renderer->model;
|
||||
|
||||
// see if the bounding box lets us trivially reject, also
|
||||
// sets trivial accept status
|
||||
for (j = 0; j < 3; j++) {
|
||||
minmaxs[j] = origin[j] + clmodel->mins[j];
|
||||
minmaxs[3 + j] = origin[j] + clmodel->maxs[j];
|
||||
minmaxs[j] = origin[j] + model->mins[j];
|
||||
minmaxs[3 + j] = origin[j] + model->maxs[j];
|
||||
}
|
||||
|
||||
clipflags = R_BmodelCheckBBox (ent, clmodel, minmaxs);
|
||||
clipflags = R_BmodelCheckBBox (transform, model, minmaxs);
|
||||
|
||||
if (clipflags != BMODEL_FULLY_CLIPPED) {
|
||||
mod_brush_t *brush = &clmodel->brush;
|
||||
mod_brush_t *brush = &model->brush;
|
||||
VectorCopy (origin, r_entorigin);
|
||||
VectorSubtract (r_refdef.frame.position, r_entorigin, modelorg);
|
||||
|
||||
|
@ -502,8 +496,11 @@ R_DrawBrushEntitiesOnList (entqueue_t *queue)
|
|||
// Z-buffering is on at this point, so no clipping to the
|
||||
// world tree is needed, just frustum clipping
|
||||
if (r_drawpolys | r_drawculledpolys) {
|
||||
R_ZDrawSubmodelPolys (ent, clmodel);
|
||||
R_ZDrawSubmodelPolys (ent, model);
|
||||
} else {
|
||||
visibility_t *visibility = Ent_GetComponent (ent.id,
|
||||
scene_visibility,
|
||||
ent.reg);
|
||||
int topnode_id = visibility->topnode_id;
|
||||
mod_brush_t *brush = &r_refdef.worldmodel->brush;
|
||||
|
||||
|
@ -512,13 +509,13 @@ R_DrawBrushEntitiesOnList (entqueue_t *queue)
|
|||
// BSP
|
||||
mnode_t *node = brush->nodes + topnode_id;
|
||||
r_clipflags = clipflags;
|
||||
R_DrawSolidClippedSubmodelPolygons (ent, clmodel, node);
|
||||
R_DrawSolidClippedSubmodelPolygons (ent, model, node);
|
||||
} else {
|
||||
// falls entirely in one leaf, so we just put
|
||||
// all the edges in the edge list and let 1/z
|
||||
// sorting handle drawing order
|
||||
mleaf_t *leaf = brush->leafs + ~topnode_id;
|
||||
R_DrawSubmodelPolygons (ent, clmodel, clipflags, leaf);
|
||||
R_DrawSubmodelPolygons (ent, model, clipflags, leaf);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -245,23 +245,19 @@ R_SetupAndDrawSprite (const vec3_t relvieworg)
|
|||
void
|
||||
R_DrawSprite (entity_t ent)
|
||||
{
|
||||
transform_t transform = Entity_Transform (ent);
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer,
|
||||
r_refdef.scene->reg);
|
||||
animation_t *animation = Ent_GetComponent (ent.id, scene_animation,
|
||||
r_refdef.scene->reg);
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer, ent.reg);
|
||||
msprite_t *sprite = renderer->model->cache.data;
|
||||
|
||||
vec4f_t cameravec = r_refdef.frame.position - r_entorigin;
|
||||
|
||||
animation_t *animation = Ent_GetComponent (ent.id, scene_animation,
|
||||
ent.reg);
|
||||
r_spritedesc.pspriteframe = R_GetSpriteFrame (sprite, animation);
|
||||
|
||||
sprite_width = r_spritedesc.pspriteframe->width;
|
||||
sprite_height = r_spritedesc.pspriteframe->height;
|
||||
|
||||
vec4f_t up = {};
|
||||
vec4f_t right = {};
|
||||
vec4f_t fwd = {};
|
||||
vec4f_t up = {}, right = {}, fwd = {};
|
||||
vec4f_t cameravec = r_refdef.frame.position - r_entorigin;
|
||||
transform_t transform = Entity_Transform (ent);
|
||||
if (!R_BillboardFrame (transform, sprite->type, cameravec,
|
||||
&up, &right, &fwd)) {
|
||||
// the orientation is undefined so can't draw the sprite
|
||||
|
|
|
@ -120,14 +120,10 @@ emit_commands (VkCommandBuffer cmd, int pose1, int pose2,
|
|||
void
|
||||
Vulkan_DrawAlias (entity_t ent, qfv_renderframe_t *rFrame)
|
||||
{
|
||||
transform_t transform = Entity_Transform (ent);
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer,
|
||||
r_refdef.scene->reg);
|
||||
animation_t *animation = Ent_GetComponent (ent.id, scene_animation,
|
||||
r_refdef.scene->reg);
|
||||
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
|
||||
aliasctx_t *actx = ctx->alias_context;
|
||||
aliasframe_t *aframe = &actx->frames.a[ctx->curFrame];
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer, ent.reg);
|
||||
model_t *model = renderer->model;
|
||||
aliashdr_t *hdr;
|
||||
qfv_alias_skin_t *skin;
|
||||
|
@ -137,8 +133,11 @@ Vulkan_DrawAlias (entity_t ent, qfv_renderframe_t *rFrame)
|
|||
hdr = Cache_Get (&model->cache);
|
||||
}
|
||||
|
||||
animation_t *animation = Ent_GetComponent (ent.id, scene_animation,
|
||||
ent.reg);
|
||||
constants.blend = R_AliasGetLerpedFrames (animation, hdr);
|
||||
|
||||
transform_t transform = Entity_Transform (ent);
|
||||
qfv_push_constants_t push_constants[] = {
|
||||
{ VK_SHADER_STAGE_VERTEX_BIT,
|
||||
field_offset (alias_push_constants_t, mat),
|
||||
|
|
|
@ -588,12 +588,9 @@ static int
|
|||
R_DrawBrushModel (entity_t ent, bsp_pass_t *pass, vulkan_ctx_t *ctx)
|
||||
{
|
||||
transform_t transform = Entity_Transform (ent);
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer,
|
||||
r_refdef.scene->reg);
|
||||
animation_t *animation = Ent_GetComponent (ent.id, scene_animation,
|
||||
r_refdef.scene->reg);
|
||||
float radius;
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer, ent.reg);
|
||||
model_t *model = renderer->model;
|
||||
float radius;
|
||||
vec3_t mins, maxs;
|
||||
bspctx_t *bctx = ctx->bsp_context;
|
||||
|
||||
|
@ -614,6 +611,8 @@ R_DrawBrushModel (entity_t ent, bsp_pass_t *pass, vulkan_ctx_t *ctx)
|
|||
return 0;
|
||||
}
|
||||
|
||||
animation_t *animation = Ent_GetComponent (ent.id, scene_animation,
|
||||
ent.reg);
|
||||
pass->ent_frame = animation->frame & 1;
|
||||
pass->inst_id = model->render_id;
|
||||
pass->inst_id |= renderer->colormod[3] < 1 ? INST_ALPHA : 0;
|
||||
|
@ -1036,10 +1035,8 @@ ent_model_cmp (const void *_a, const void *_b)
|
|||
{
|
||||
const entity_t *a = _a;
|
||||
const entity_t *b = _b;
|
||||
renderer_t *ra = Ent_GetComponent (a->id, scene_renderer,
|
||||
r_refdef.scene->reg);
|
||||
renderer_t *rb = Ent_GetComponent (b->id, scene_renderer,
|
||||
r_refdef.scene->reg);
|
||||
renderer_t *ra = Ent_GetComponent (a->id, scene_renderer, a->reg);
|
||||
renderer_t *rb = Ent_GetComponent (b->id, scene_renderer, b->reg);
|
||||
return ra->model->render_id - rb->model->render_id;
|
||||
}
|
||||
|
||||
|
|
|
@ -130,16 +130,12 @@ emit_commands (VkCommandBuffer cmd, int pose1, int pose2,
|
|||
void
|
||||
Vulkan_DrawIQM (entity_t ent, qfv_renderframe_t *rFrame)
|
||||
{
|
||||
transform_t transform = Entity_Transform (ent);
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer,
|
||||
r_refdef.scene->reg);
|
||||
animation_t *animation = Ent_GetComponent (ent.id, scene_animation,
|
||||
r_refdef.scene->reg);
|
||||
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
|
||||
qfv_device_t *device = ctx->device;
|
||||
qfv_devfuncs_t *dfunc = device->funcs;
|
||||
iqmctx_t *ictx = ctx->iqm_context;
|
||||
iqm_frame_t *aframe = &ictx->frames.a[ctx->curFrame];
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer, ent.reg);
|
||||
model_t *model = renderer->model;
|
||||
iqm_t *iqm = (iqm_t *) model->aliashdr;
|
||||
qfv_iqm_t *mesh = iqm->extra_data;
|
||||
|
@ -147,6 +143,8 @@ Vulkan_DrawIQM (entity_t ent, qfv_renderframe_t *rFrame)
|
|||
iqm_push_constants_t constants = {};
|
||||
iqmframe_t *frame;
|
||||
|
||||
animation_t *animation = Ent_GetComponent (ent.id, scene_animation,
|
||||
ent.reg);
|
||||
constants.blend = R_IQMGetLerpedFrames (animation, iqm);
|
||||
frame = R_IQMBlendFrames (iqm, animation->pose1, animation->pose2,
|
||||
constants.blend, 0);
|
||||
|
@ -173,7 +171,7 @@ Vulkan_DrawIQM (entity_t ent, qfv_renderframe_t *rFrame)
|
|||
dfunc->vkFlushMappedMemoryRanges (device->dev, 1, &range);
|
||||
dfunc->vkUnmapMemory (device->dev, mesh->bones->memory);
|
||||
|
||||
|
||||
transform_t transform = Entity_Transform (ent);
|
||||
qfv_push_constants_t push_constants[] = {
|
||||
{ VK_SHADER_STAGE_VERTEX_BIT,
|
||||
field_offset (iqm_push_constants_t, mat),
|
||||
|
|
|
@ -108,8 +108,7 @@ static void
|
|||
Vulkan_DrawViewModel (vulkan_ctx_t *ctx)
|
||||
{
|
||||
entity_t ent = vr_data.view_model;
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer,
|
||||
r_refdef.scene->reg);
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer, ent.reg);
|
||||
if (vr_data.inhibit_viewmodel
|
||||
|| !r_drawviewmodel
|
||||
|| !r_drawentities
|
||||
|
@ -148,7 +147,6 @@ Vulkan_NewScene (scene_t *scene, vulkan_ctx_t *ctx)
|
|||
d_lightstylevalue[i] = 264; // normal light value
|
||||
}
|
||||
|
||||
r_refdef.scene = scene;
|
||||
r_refdef.worldmodel = scene->worldmodel;
|
||||
|
||||
// Force a vis update
|
||||
|
|
|
@ -107,14 +107,10 @@ emit_commands (VkCommandBuffer cmd, qfv_sprite_t *sprite,
|
|||
void
|
||||
Vulkan_DrawSprite (entity_t ent, qfv_renderframe_t *rFrame)
|
||||
{
|
||||
transform_t transform = Entity_Transform (ent);
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer,
|
||||
r_refdef.scene->reg);
|
||||
animation_t *animation = Ent_GetComponent (ent.id, scene_animation,
|
||||
r_refdef.scene->reg);
|
||||
vulkan_ctx_t *ctx = rFrame->vulkan_ctx;
|
||||
spritectx_t *sctx = ctx->sprite_context;
|
||||
spriteframe_t *sframe = &sctx->frames.a[ctx->curFrame];
|
||||
renderer_t *renderer = Ent_GetComponent (ent.id, scene_renderer, ent.reg);
|
||||
model_t *model = renderer->model;
|
||||
msprite_t *sprite = model->cache.data;
|
||||
|
||||
|
@ -126,8 +122,11 @@ Vulkan_DrawSprite (entity_t ent, qfv_renderframe_t *rFrame)
|
|||
64, sizeof (frame), &frame },
|
||||
};
|
||||
|
||||
animation_t *animation = Ent_GetComponent (ent.id, scene_animation,
|
||||
ent.reg);
|
||||
frame = (ptrdiff_t) R_GetSpriteFrame (sprite, animation);
|
||||
|
||||
transform_t transform = Entity_Transform (ent);
|
||||
mat[3] = Transform_GetWorldPosition (transform);
|
||||
vec4f_t cameravec = r_refdef.frame.position - mat[3];
|
||||
R_BillboardFrame (transform, sprite->type, cameravec,
|
||||
|
|
Loading…
Reference in a new issue