mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
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:
parent
b69e372589
commit
5dab7ccaf7
8 changed files with 63 additions and 40 deletions
|
@ -379,21 +379,20 @@ typedef struct model_s
|
|||
|
||||
int flags;
|
||||
|
||||
//
|
||||
// lighting info
|
||||
float min_light;
|
||||
byte shadow_alpha; // 255 = 1.0
|
||||
byte fullbright;
|
||||
|
||||
// volume occupied by the model graphics
|
||||
//
|
||||
vec3_t mins, maxs;
|
||||
float radius;
|
||||
|
||||
//
|
||||
// solid volume for clipping
|
||||
//
|
||||
qboolean clipbox;
|
||||
vec3_t clipmins, clipmaxs;
|
||||
|
||||
//
|
||||
// brush model
|
||||
//
|
||||
int firstmodelsurface, nummodelsurfaces;
|
||||
|
||||
int numsubmodels;
|
||||
|
@ -441,9 +440,7 @@ typedef struct model_s
|
|||
unsigned int checksum;
|
||||
unsigned int checksum2;
|
||||
|
||||
//
|
||||
// additional model data
|
||||
//
|
||||
cache_user_t cache; // only access through Mod_Extradata
|
||||
|
||||
} 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_LoadAllSkins (int numskins, daliasskintype_t *pskintype,
|
||||
int *pskinindex);
|
||||
void GL_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m,
|
||||
int _s);
|
||||
void Mod_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m,
|
||||
int _s);
|
||||
void Mod_FinalizeAliasModel (model_t *m, aliashdr_t *hdr);
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -342,7 +342,7 @@ BuildTris (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 *cmds;
|
||||
|
|
|
@ -297,3 +297,12 @@ Mod_LoadAliasGroup (void *pin, int *posenum, maliasframedesc_t *frame)
|
|||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
// 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
|
||||
end = Hunk_LowMark ();
|
||||
|
|
|
@ -159,7 +159,7 @@ Mod_LoadAllSkins (int numskins, daliasskintype_t *pskintype, int *pskinindex)
|
|||
}
|
||||
|
||||
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;
|
||||
stvert_t *pstverts;
|
||||
|
@ -279,3 +279,8 @@ Mod_LoadAliasGroup (void *pin, int *posenum, maliasframedesc_t *frame)
|
|||
|
||||
return ptemp;
|
||||
}
|
||||
|
||||
void
|
||||
Mod_FinalizeAliasModel (model_t *m, aliashdr_t *hdr)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ Mod_LoadAllSkins (int numskins, daliasskintype_t *pskintype, int *pskinindex)
|
|||
}
|
||||
|
||||
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;
|
||||
stvert_t *pstverts;
|
||||
|
@ -274,3 +274,8 @@ Mod_LoadAliasGroup (void *pin, int *posenum, maliasframedesc_t *frame)
|
|||
|
||||
return ptemp;
|
||||
}
|
||||
|
||||
void
|
||||
Mod_FinalizeAliasModel (model_t *m, aliashdr_t *hdr)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -48,6 +48,8 @@ static const char rcsid[] =
|
|||
#include "QF/sys.h"
|
||||
#include "QF/vfs.h"
|
||||
|
||||
#include "compat.h"
|
||||
|
||||
void Mod_LoadAliasModel (model_t *mod, void *buf, cache_allocator_t allocator);
|
||||
void Mod_LoadSpriteModel (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;
|
||||
|
||||
// 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
|
||||
mod->needload = false;
|
||||
|
|
|
@ -387,7 +387,6 @@ R_DrawAliasModel (entity_t *e, qboolean cull)
|
|||
int fb_texture = 0;
|
||||
aliashdr_t *paliashdr;
|
||||
model_t *clmodel;
|
||||
qboolean modelIsFullbright = false;
|
||||
vec3_t dist, mins, maxs;
|
||||
vert_order_t *vo;
|
||||
|
||||
|
@ -409,9 +408,7 @@ R_DrawAliasModel (entity_t *e, qboolean cull)
|
|||
VectorCopy (e->origin, r_entorigin);
|
||||
VectorSubtract (r_origin, r_entorigin, modelorg);
|
||||
|
||||
if (strnequal (clmodel->name, "progs/flame", 11)
|
||||
|| strnequal (clmodel->name, "progs/bolt", 10)) {
|
||||
modelIsFullbright = true;
|
||||
if (clmodel->fullbright) {
|
||||
shadelight = 1.0; // make certain models full brightness always
|
||||
} else {
|
||||
// get lighting information
|
||||
|
@ -436,9 +433,8 @@ R_DrawAliasModel (entity_t *e, qboolean cull)
|
|||
shadelight = min (shadelight, 100); // was 200
|
||||
|
||||
// never allow players to go totally black
|
||||
if (strequal (clmodel->name, "progs/player.mdl")) {
|
||||
shadelight = max (shadelight, 8);
|
||||
}
|
||||
shadelight = max (shadelight, clmodel->min_light);
|
||||
|
||||
shadelight *= 0.005;
|
||||
|
||||
shadedots = r_avertexnormal_dots[(int) (e->angles[1] *
|
||||
|
@ -459,20 +455,11 @@ R_DrawAliasModel (entity_t *e, qboolean cull)
|
|||
qfglPushMatrix ();
|
||||
R_RotateForEntity (e);
|
||||
|
||||
if (strequal (clmodel->name, "progs/eyes.mdl")) {
|
||||
qfglTranslatef (paliashdr->mdl.scale_origin[0],
|
||||
paliashdr->mdl.scale_origin[1],
|
||||
paliashdr->mdl.scale_origin[2] - (22 + 8));
|
||||
// double size of eyes, since they are really hard to see in GL
|
||||
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]);
|
||||
}
|
||||
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;
|
||||
|
||||
|
@ -483,7 +470,7 @@ R_DrawAliasModel (entity_t *e, qboolean cull)
|
|||
}
|
||||
|
||||
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];
|
||||
|
||||
// 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) {
|
||||
// torches, grenades, and lightning bolts do not have shadows
|
||||
if (modelIsFullbright)
|
||||
return;
|
||||
if (strequal (clmodel->name, "progs/grenade.mdl"))
|
||||
if (!clmodel->shadow_alpha)
|
||||
return;
|
||||
|
||||
qfglPushMatrix ();
|
||||
R_RotateForEntity (e);
|
||||
|
||||
qfglDisable (GL_TEXTURE_2D);
|
||||
color_black[3] = 128;
|
||||
color_black[3] = (clmodel->shadow_alpha + 1) / 2;
|
||||
qfglColor4ubv (color_black);
|
||||
|
||||
if (gl_lerp_anim->int_val) {
|
||||
|
|
Loading…
Reference in a new issue