new cvar: gl_mesh_cache. controls minimum triangle count in a model before

the model is cached or cache checks are done for that model. 0 disables
caching entrirely.
This commit is contained in:
Bill Currie 2001-08-14 20:02:54 +00:00
parent b277881832
commit 9f2418d873
2 changed files with 110 additions and 95 deletions

View file

@ -39,6 +39,7 @@
#include <stdio.h>
#include "QF/console.h"
#include "QF/cvar.h"
#include "QF/mdfour.h"
#include "QF/model.h"
#include "QF/sys.h"
@ -50,6 +51,8 @@
ALIAS MODEL DISPLAY LIST GENERATION
*/
extern cvar_t *gl_mesh_cache;
model_t *aliasmodel;
aliashdr_t *paliashdr;
@ -350,10 +353,15 @@ GL_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m, int _s)
unsigned char model_digest[MDFOUR_DIGEST_BYTES];
unsigned char mesh_digest[MDFOUR_DIGEST_BYTES];
qboolean remesh = true;
qboolean do_cache = false;
aliasmodel = m;
paliashdr = hdr; // (aliashdr_t *)Mod_Extradata (m);
if (gl_mesh_cache->int_val
&& gl_mesh_cache->int_val <= paliashdr->mdl.numtris) {
do_cache = true;
mdfour (model_digest, (unsigned char *) _m, _s);
// look for a cached version
@ -429,12 +437,14 @@ GL_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m, int _s)
}
}
}
}
if (remesh) {
// build it from scratch
Con_Printf ("meshing %s...\n", m->name);
BuildTris (); // trifans or lists
if (do_cache) {
// save out the cached version
snprintf (fullpath, sizeof (fullpath), "%s/%s", com_gamedir, cache);
f = Qopen (fullpath, "wbz9");
@ -471,6 +481,7 @@ GL_MakeAliasModelDisplayLists (model_t *m, aliashdr_t *hdr, void *_m, int _s)
Qclose (f);
}
}
}
// save the data out
paliashdr->poseverts = numorder;

View file

@ -60,6 +60,7 @@ model_t mod_known[MAX_MOD_KNOWN];
int mod_numknown;
cvar_t *gl_subdivide_size;
cvar_t *gl_mesh_cache;
extern byte mod_novis[MAX_MAP_LEAFS / 8];
@ -106,6 +107,9 @@ Mod_Init_Cvars (void)
gl_subdivide_size =
Cvar_Get ("gl_subdivide_size", "128", CVAR_ARCHIVE, NULL,
"Sets the division value for the sky brushes.");
gl_mesh_cache = Cvar_Get ("gl_mesh_cache", "256", CVAR_ARCHIVE, NULL,
"minimum triangle count in a model for its mesh"
" to be cached. 0 to disable caching");
}
void