precalculate smoe model specific info (wether the whole model is fullbright,

if it should have shadows, whether it should be scaled/translated (gl eyes),
and the minimum lighting (player)). give a 1.9% speedup in null renderer.
This commit is contained in:
Bill Currie 2001-11-20 08:02:35 +00:00
parent b69e372589
commit 5dab7ccaf7
8 changed files with 63 additions and 40 deletions

View file

@ -379,21 +379,20 @@ typedef struct model_s
int flags; int flags;
// // lighting info
float min_light;
byte shadow_alpha; // 255 = 1.0
byte fullbright;
// volume occupied by the model graphics // volume occupied by the model graphics
//
vec3_t mins, maxs; vec3_t mins, maxs;
float radius; float radius;
//
// solid volume for clipping // solid volume for clipping
//
qboolean clipbox; qboolean clipbox;
vec3_t clipmins, clipmaxs; vec3_t clipmins, clipmaxs;
//
// brush model // brush model
//
int firstmodelsurface, nummodelsurfaces; int firstmodelsurface, nummodelsurfaces;
int numsubmodels; int numsubmodels;
@ -441,9 +440,7 @@ typedef struct model_s
unsigned int checksum; unsigned int checksum;
unsigned int checksum2; unsigned int checksum2;
//
// additional model data // additional model data
//
cache_user_t cache; // only access through Mod_Extradata cache_user_t cache; // only access through Mod_Extradata
} model_t; } model_t;
@ -468,8 +465,9 @@ void *Mod_LoadAliasFrame (void *pin, int *posenum, maliasframedesc_t *frame);
void *Mod_LoadAliasGroup (void *pin, int *posenum, maliasframedesc_t *frame); void *Mod_LoadAliasGroup (void *pin, int *posenum, maliasframedesc_t *frame);
void *Mod_LoadAllSkins (int numskins, daliasskintype_t *pskintype, void *Mod_LoadAllSkins (int numskins, daliasskintype_t *pskintype,
int *pskinindex); int *pskinindex);
void GL_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m, void Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m,
int _s); int _s);
void Mod_FinalizeAliasModel (model_t *m, aliashdr_t *hdr);

View file

@ -342,7 +342,7 @@ BuildTris (void)
} }
void void
GL_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m, int _s) Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m, int _s)
{ {
int i, j; int i, j;
int *cmds; int *cmds;

View file

@ -297,3 +297,12 @@ Mod_LoadAliasGroup (void *pin, int *posenum, maliasframedesc_t *frame)
} }
return ptemp; return ptemp;
} }
void
Mod_FinalizeAliasModel (model_t *m, aliashdr_t *hdr)
{
if (strequal (m->name, "progs/eyes.mdl")) {
hdr->mdl.scale_origin[2] -= (22 + 8);
VectorScale (hdr->mdl.scale, 2, hdr->mdl.scale);
}
}

View file

@ -205,7 +205,9 @@ Mod_LoadAliasModel (model_t *mod, void *buffer, cache_allocator_t allocator)
mod->maxs[0] = mod->maxs[1] = mod->maxs[2] = 16; mod->maxs[0] = mod->maxs[1] = mod->maxs[2] = 16;
// build the draw lists // build the draw lists
GL_MakeAliasModelDisplayLists (mod, pheader, buffer, com_filesize); Mod_MakeAliasModelDisplayLists (mod, pheader, buffer, com_filesize);
Mod_FinalizeAliasModel (mod, pheader);
// move the complete, relocatable alias model to the cache // move the complete, relocatable alias model to the cache
end = Hunk_LowMark (); end = Hunk_LowMark ();

View file

@ -159,7 +159,7 @@ Mod_LoadAllSkins (int numskins, daliasskintype_t *pskintype, int *pskinindex)
} }
void void
GL_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m, int _s) Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m, int _s)
{ {
int i, j; int i, j;
stvert_t *pstverts; stvert_t *pstverts;
@ -279,3 +279,8 @@ Mod_LoadAliasGroup (void *pin, int *posenum, maliasframedesc_t *frame)
return ptemp; return ptemp;
} }
void
Mod_FinalizeAliasModel (model_t *m, aliashdr_t *hdr)
{
}

View file

@ -155,7 +155,7 @@ Mod_LoadAllSkins (int numskins, daliasskintype_t *pskintype, int *pskinindex)
} }
void void
GL_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m, int _s) Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m, int _s)
{ {
int i, j; int i, j;
stvert_t *pstverts; stvert_t *pstverts;
@ -274,3 +274,8 @@ Mod_LoadAliasGroup (void *pin, int *posenum, maliasframedesc_t *frame)
return ptemp; return ptemp;
} }
void
Mod_FinalizeAliasModel (model_t *m, aliashdr_t *hdr)
{
}

View file

@ -48,6 +48,8 @@ static const char rcsid[] =
#include "QF/sys.h" #include "QF/sys.h"
#include "QF/vfs.h" #include "QF/vfs.h"
#include "compat.h"
void Mod_LoadAliasModel (model_t *mod, void *buf, cache_allocator_t allocator); void Mod_LoadAliasModel (model_t *mod, void *buf, cache_allocator_t allocator);
void Mod_LoadSpriteModel (model_t *mod, void *buf); void Mod_LoadSpriteModel (model_t *mod, void *buf);
void Mod_LoadBrushModel (model_t *mod, void *buf); void Mod_LoadBrushModel (model_t *mod, void *buf);
@ -189,6 +191,23 @@ Mod_RealLoadModel (model_t *mod, qboolean crash, cache_allocator_t allocator)
loadmodel = mod; loadmodel = mod;
// fill it in // fill it in
if (strequal (mod->name, "progs/grenade.mdl")) {
mod->shadow_alpha = 0;
} else {
mod->shadow_alpha = 255;
}
if (strnequal (mod->name, "progs/flame", 11)
|| strnequal (mod->name, "progs/bolt", 10)) {
mod->fullbright = 1;
mod->shadow_alpha = 0;
} else {
mod->fullbright = 0;
}
if (strequal (mod->name, "progs/player.mdl")) {
mod->min_light = 8;
} else {
mod->min_light = 0;
}
// call the apropriate loader // call the apropriate loader
mod->needload = false; mod->needload = false;

View file

@ -387,7 +387,6 @@ R_DrawAliasModel (entity_t *e, qboolean cull)
int fb_texture = 0; int fb_texture = 0;
aliashdr_t *paliashdr; aliashdr_t *paliashdr;
model_t *clmodel; model_t *clmodel;
qboolean modelIsFullbright = false;
vec3_t dist, mins, maxs; vec3_t dist, mins, maxs;
vert_order_t *vo; vert_order_t *vo;
@ -409,9 +408,7 @@ R_DrawAliasModel (entity_t *e, qboolean cull)
VectorCopy (e->origin, r_entorigin); VectorCopy (e->origin, r_entorigin);
VectorSubtract (r_origin, r_entorigin, modelorg); VectorSubtract (r_origin, r_entorigin, modelorg);
if (strnequal (clmodel->name, "progs/flame", 11) if (clmodel->fullbright) {
|| strnequal (clmodel->name, "progs/bolt", 10)) {
modelIsFullbright = true;
shadelight = 1.0; // make certain models full brightness always shadelight = 1.0; // make certain models full brightness always
} else { } else {
// get lighting information // get lighting information
@ -436,9 +433,8 @@ R_DrawAliasModel (entity_t *e, qboolean cull)
shadelight = min (shadelight, 100); // was 200 shadelight = min (shadelight, 100); // was 200
// never allow players to go totally black // never allow players to go totally black
if (strequal (clmodel->name, "progs/player.mdl")) { shadelight = max (shadelight, clmodel->min_light);
shadelight = max (shadelight, 8);
}
shadelight *= 0.005; shadelight *= 0.005;
shadedots = r_avertexnormal_dots[(int) (e->angles[1] * shadedots = r_avertexnormal_dots[(int) (e->angles[1] *
@ -459,20 +455,11 @@ R_DrawAliasModel (entity_t *e, qboolean cull)
qfglPushMatrix (); qfglPushMatrix ();
R_RotateForEntity (e); R_RotateForEntity (e);
if (strequal (clmodel->name, "progs/eyes.mdl")) { qfglTranslatef (paliashdr->mdl.scale_origin[0],
qfglTranslatef (paliashdr->mdl.scale_origin[0], paliashdr->mdl.scale_origin[1],
paliashdr->mdl.scale_origin[1], paliashdr->mdl.scale_origin[2]);
paliashdr->mdl.scale_origin[2] - (22 + 8)); qfglScalef (paliashdr->mdl.scale[0], paliashdr->mdl.scale[1],
// double size of eyes, since they are really hard to see in GL paliashdr->mdl.scale[2]);
qfglScalef (paliashdr->mdl.scale[0] * 2, paliashdr->mdl.scale[1] * 2,
paliashdr->mdl.scale[2] * 2);
} else {
qfglTranslatef (paliashdr->mdl.scale_origin[0],
paliashdr->mdl.scale_origin[1],
paliashdr->mdl.scale_origin[2]);
qfglScalef (paliashdr->mdl.scale[0], paliashdr->mdl.scale[1],
paliashdr->mdl.scale[2]);
}
anim = (int) (r_realtime * 10) & 3; anim = (int) (r_realtime * 10) & 3;
@ -483,7 +470,7 @@ R_DrawAliasModel (entity_t *e, qboolean cull)
} }
texture = paliashdr->gl_texturenum[skinnum][anim]; texture = paliashdr->gl_texturenum[skinnum][anim];
if (gl_fb_models->int_val && !modelIsFullbright) if (gl_fb_models->int_val && !clmodel->fullbright)
fb_texture = paliashdr->gl_fb_texturenum[skinnum][anim]; fb_texture = paliashdr->gl_fb_texturenum[skinnum][anim];
// we can't dynamically colormap textures, so they are cached // we can't dynamically colormap textures, so they are cached
@ -519,16 +506,14 @@ R_DrawAliasModel (entity_t *e, qboolean cull)
if (r_shadows->int_val) { if (r_shadows->int_val) {
// torches, grenades, and lightning bolts do not have shadows // torches, grenades, and lightning bolts do not have shadows
if (modelIsFullbright) if (!clmodel->shadow_alpha)
return;
if (strequal (clmodel->name, "progs/grenade.mdl"))
return; return;
qfglPushMatrix (); qfglPushMatrix ();
R_RotateForEntity (e); R_RotateForEntity (e);
qfglDisable (GL_TEXTURE_2D); qfglDisable (GL_TEXTURE_2D);
color_black[3] = 128; color_black[3] = (clmodel->shadow_alpha + 1) / 2;
qfglColor4ubv (color_black); qfglColor4ubv (color_black);
if (gl_lerp_anim->int_val) { if (gl_lerp_anim->int_val) {