mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
[model] Add a function to "unload" models
The model system is rather clunky as it is focused around caching, so unloading is more of a suggestion than anything, but it was good enough for testing loading and unloading of IQM models in Vulkan.
This commit is contained in:
parent
bbca22c722
commit
ecf33fe8e3
2 changed files with 31 additions and 11 deletions
|
@ -438,6 +438,7 @@ void Mod_Init_Cvars (void);
|
|||
void Mod_ClearAll (void);
|
||||
model_t *Mod_ForName (const char *name, qboolean crash);
|
||||
void Mod_TouchModel (const char *name);
|
||||
void Mod_UnloadModel (model_t *model);
|
||||
// brush specific
|
||||
mleaf_t *Mod_PointInLeaf (const vec3_t p, model_t *model) __attribute__((pure));
|
||||
struct set_s *Mod_LeafPVS (const mleaf_t *leaf, const model_t *model);
|
||||
|
|
|
@ -138,22 +138,31 @@ Mod_Init_Cvars (void)
|
|||
Cvar_Register (&gl_textures_external_cvar, 0, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
mod_unload_model (size_t ind)
|
||||
{
|
||||
model_t *mod = mod_known.a[ind];
|
||||
|
||||
//FIXME this seems to be correct but need to double check the behavior
|
||||
//with alias models
|
||||
if (!mod->needload && mod->clear) {
|
||||
mod->clear (mod, mod->data);
|
||||
}
|
||||
if (mod->type != mod_alias) {
|
||||
mod->needload = true;
|
||||
}
|
||||
if (mod->type == mod_sprite) {
|
||||
mod->cache.data = 0;
|
||||
}
|
||||
}
|
||||
|
||||
VISIBLE void
|
||||
Mod_ClearAll (void)
|
||||
{
|
||||
size_t i;
|
||||
model_t **mod;
|
||||
|
||||
for (i = 0, mod = mod_known.a; i < mod_numknown; i++, mod++) {
|
||||
//FIXME this seems to be correct but need to double check the behavior
|
||||
//with alias models
|
||||
if (!(*mod)->needload && (*mod)->clear) {
|
||||
(*mod)->clear (*mod, (*mod)->data);
|
||||
}
|
||||
if ((*mod)->type != mod_alias)
|
||||
(*mod)->needload = true;
|
||||
if ((*mod)->type == mod_sprite)
|
||||
(*mod)->cache.data = 0;
|
||||
for (i = 0; i < mod_numknown; i++) {
|
||||
mod_unload_model (i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -323,6 +332,16 @@ Mod_TouchModel (const char *name)
|
|||
}
|
||||
}
|
||||
|
||||
VISIBLE void
|
||||
Mod_UnloadModel (model_t *model)
|
||||
{
|
||||
for (size_t i = 0; i < mod_numknown; i++) {
|
||||
if (mod_known.a[i] == model) {
|
||||
mod_unload_model (i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VISIBLE void
|
||||
Mod_Print (void)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue