2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
model.c
|
|
|
|
|
|
|
|
model loading and caching
|
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
2002-08-25 14:25:38 +00:00
|
|
|
// Models are the only shared resource between a client and server running
|
|
|
|
// on the same machine.
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2003-01-15 15:31:36 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
|
|
|
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/cvar.h"
|
2021-02-01 06:02:42 +00:00
|
|
|
#include "QF/darray.h"
|
2012-04-27 05:40:06 +00:00
|
|
|
#include "QF/iqm.h"
|
2001-04-10 06:55:28 +00:00
|
|
|
#include "QF/model.h"
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/qendian.h"
|
2002-08-27 07:16:28 +00:00
|
|
|
#include "QF/quakefs.h"
|
2001-05-10 06:01:11 +00:00
|
|
|
#include "QF/sys.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2012-02-14 12:25:19 +00:00
|
|
|
#include "QF/plugin/vid_render.h"
|
|
|
|
|
2001-11-20 08:02:35 +00:00
|
|
|
#include "compat.h"
|
2021-02-01 05:39:00 +00:00
|
|
|
#include "mod_internal.h"
|
2001-11-20 08:02:35 +00:00
|
|
|
|
2012-02-14 12:25:19 +00:00
|
|
|
vid_model_funcs_t *mod_funcs;
|
|
|
|
|
2010-11-23 03:48:53 +00:00
|
|
|
#define MOD_BLOCK 16 // allocate 16 models at a time
|
2021-02-01 06:02:42 +00:00
|
|
|
static struct DARRAY_TYPE (model_t *) mod_known = {0, 0, MOD_BLOCK};
|
2023-03-05 08:26:03 +00:00
|
|
|
static struct DARRAY_TYPE (model_t *) mod_blocks = {0, 0, MOD_BLOCK};
|
2021-02-01 06:02:42 +00:00
|
|
|
static size_t mod_numknown;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2007-03-10 12:00:59 +00:00
|
|
|
VISIBLE texture_t *r_notexture_mip;
|
2002-08-20 00:48:59 +00:00
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
int gl_mesh_cache;
|
|
|
|
static cvar_t gl_mesh_cache_cvar = {
|
|
|
|
.name = "gl_mesh_cache",
|
|
|
|
.description =
|
|
|
|
"minimum triangle count in a model for its mesh to be cached. 0 to "
|
|
|
|
"disable caching",
|
|
|
|
.default_value = "256",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &gl_mesh_cache },
|
|
|
|
};
|
|
|
|
float gl_subdivide_size;
|
|
|
|
static cvar_t gl_subdivide_size_cvar = {
|
|
|
|
.name = "gl_subdivide_size",
|
|
|
|
.description =
|
|
|
|
"Sets the division value for the sky brushes.",
|
|
|
|
.default_value = "128",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
|
|
|
.value = { .type = &cexpr_float, .value = &gl_subdivide_size },
|
|
|
|
};
|
|
|
|
int gl_alias_render_tri;
|
|
|
|
static cvar_t gl_alias_render_tri_cvar = {
|
|
|
|
.name = "gl_alias_render_tri",
|
|
|
|
.description =
|
|
|
|
"When loading alias models mesh for pure triangle rendering",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &gl_alias_render_tri },
|
|
|
|
};
|
|
|
|
int gl_textures_external;
|
|
|
|
static cvar_t gl_textures_external_cvar = {
|
|
|
|
.name = "gl_textures_external",
|
|
|
|
.description =
|
|
|
|
"Use external textures to replace BSP textures",
|
|
|
|
.default_value = "1",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &gl_textures_external },
|
|
|
|
};
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-11-05 19:12:51 +00:00
|
|
|
static void Mod_CallbackLoad (void *object, cache_allocator_t allocator);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2023-03-05 08:26:03 +00:00
|
|
|
static void
|
|
|
|
mod_shutdown (void *data)
|
|
|
|
{
|
2023-03-05 16:52:57 +00:00
|
|
|
Mod_ClearAll ();
|
2023-03-05 08:26:03 +00:00
|
|
|
for (size_t i = 0; i < mod_blocks.size; i++) {
|
|
|
|
free (mod_blocks.a[i]);
|
|
|
|
}
|
|
|
|
DARRAY_CLEAR (&mod_known);
|
|
|
|
DARRAY_CLEAR (&mod_blocks);
|
|
|
|
}
|
|
|
|
|
2007-03-10 12:00:59 +00:00
|
|
|
VISIBLE void
|
2001-02-19 21:15:25 +00:00
|
|
|
Mod_Init (void)
|
|
|
|
{
|
2002-08-22 18:45:58 +00:00
|
|
|
byte *dest;
|
|
|
|
int m, x, y;
|
2002-08-22 19:08:33 +00:00
|
|
|
int mip0size = 16*16, mip1size = 8*8, mip2size = 4*4, mip3size = 2*2;
|
2001-05-16 17:08:56 +00:00
|
|
|
|
2023-03-05 08:26:03 +00:00
|
|
|
Sys_RegisterShutdown (mod_shutdown, 0);
|
|
|
|
|
2021-07-28 06:01:45 +00:00
|
|
|
r_notexture_mip = Hunk_AllocName (0,
|
|
|
|
sizeof (texture_t) + mip0size + mip1size
|
2001-05-31 18:11:05 +00:00
|
|
|
+ mip2size + mip3size, "notexture");
|
2001-05-16 17:08:56 +00:00
|
|
|
|
|
|
|
r_notexture_mip->width = r_notexture_mip->height = 16;
|
|
|
|
r_notexture_mip->offsets[0] = sizeof (texture_t);
|
|
|
|
|
2001-05-31 18:11:05 +00:00
|
|
|
r_notexture_mip->offsets[1] = r_notexture_mip->offsets[0] + mip0size;
|
|
|
|
r_notexture_mip->offsets[2] = r_notexture_mip->offsets[1] + mip1size;
|
|
|
|
r_notexture_mip->offsets[3] = r_notexture_mip->offsets[2] + mip2size;
|
2001-05-16 17:08:56 +00:00
|
|
|
|
|
|
|
for (m = 0; m < 4; m++) {
|
|
|
|
dest = (byte *) r_notexture_mip + r_notexture_mip->offsets[m];
|
|
|
|
for (y = 0; y < (16 >> m); y++)
|
|
|
|
for (x = 0; x < (16 >> m); x++) {
|
|
|
|
if ((y < (8 >> m)) ^ (x < (8 >> m)))
|
|
|
|
*dest++ = 0;
|
|
|
|
else
|
|
|
|
*dest++ = 0xff;
|
|
|
|
}
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2007-03-10 12:00:59 +00:00
|
|
|
VISIBLE void
|
2001-02-19 21:15:25 +00:00
|
|
|
Mod_Init_Cvars (void)
|
|
|
|
{
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
Cvar_Register (&gl_subdivide_size_cvar, 0, 0);
|
|
|
|
Cvar_Register (&gl_mesh_cache_cvar, 0, 0);
|
|
|
|
Cvar_Register (&gl_alias_render_tri_cvar, 0, 0);
|
|
|
|
Cvar_Register (&gl_textures_external_cvar, 0, 0);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2022-05-04 05:13:18 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-10 12:00:59 +00:00
|
|
|
VISIBLE void
|
2001-02-19 21:15:25 +00:00
|
|
|
Mod_ClearAll (void)
|
|
|
|
{
|
2021-02-01 06:02:42 +00:00
|
|
|
size_t i;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-05-04 05:13:18 +00:00
|
|
|
for (i = 0; i < mod_numknown; i++) {
|
|
|
|
mod_unload_model (i);
|
2004-01-17 07:14:42 +00:00
|
|
|
}
|
2023-03-06 12:04:00 +00:00
|
|
|
mod_numknown = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2004-02-08 02:49:38 +00:00
|
|
|
model_t *
|
2001-07-15 07:04:17 +00:00
|
|
|
Mod_FindName (const char *name)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2021-02-01 06:02:42 +00:00
|
|
|
size_t i;
|
2010-11-23 03:48:53 +00:00
|
|
|
model_t **mod;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (!name[0])
|
2001-08-31 03:48:26 +00:00
|
|
|
Sys_Error ("Mod_FindName: empty name");
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-07-22 05:40:34 +00:00
|
|
|
// search the currently loaded models
|
2021-02-01 06:02:42 +00:00
|
|
|
for (i = 0, mod = mod_known.a; i < mod_numknown; i++, mod++)
|
2021-02-01 05:39:00 +00:00
|
|
|
if (!strcmp ((*mod)->path, name))
|
2001-02-19 21:15:25 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
if (i == mod_numknown) {
|
2021-02-01 06:02:42 +00:00
|
|
|
if (mod_numknown == mod_known.size) {
|
|
|
|
model_t *block = calloc (MOD_BLOCK, sizeof (model_t));
|
|
|
|
for (i = 0; i < MOD_BLOCK; i++) {
|
|
|
|
DARRAY_APPEND (&mod_known, &block[i]);
|
|
|
|
}
|
|
|
|
mod = &mod_known.a[mod_numknown];
|
2023-03-05 08:26:03 +00:00
|
|
|
DARRAY_APPEND (&mod_blocks, block);
|
2010-11-23 03:48:53 +00:00
|
|
|
}
|
2021-01-20 04:55:50 +00:00
|
|
|
memset ((*mod), 0, sizeof (model_t));
|
2021-02-01 05:39:00 +00:00
|
|
|
strncpy ((*mod)->path, name, sizeof (*mod)->path - 1);
|
2010-11-23 03:48:53 +00:00
|
|
|
(*mod)->needload = true;
|
2001-02-19 21:15:25 +00:00
|
|
|
mod_numknown++;
|
2010-11-23 03:48:53 +00:00
|
|
|
Cache_Add (&(*mod)->cache, *mod, Mod_CallbackLoad);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2010-11-23 03:48:53 +00:00
|
|
|
return *mod;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static model_t *
|
2023-06-13 09:06:11 +00:00
|
|
|
Mod_RealLoadModel (model_t *mod, bool crash, cache_allocator_t allocator)
|
2001-08-31 12:22:45 +00:00
|
|
|
{
|
2010-08-23 02:58:49 +00:00
|
|
|
uint32_t *buf;
|
2002-08-22 18:45:58 +00:00
|
|
|
|
2001-07-22 05:40:34 +00:00
|
|
|
// load the file
|
2021-02-01 05:39:00 +00:00
|
|
|
buf = (uint32_t *) QFS_LoadFile (QFS_FOpenFile (mod->path), 0);
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!buf) {
|
|
|
|
if (crash)
|
2021-02-01 05:39:00 +00:00
|
|
|
Sys_Error ("Mod_LoadModel: %s not found", mod->path);
|
2001-02-19 21:15:25 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2001-07-22 05:40:34 +00:00
|
|
|
|
2021-02-01 05:39:00 +00:00
|
|
|
char *name = QFS_FileBase (mod->path);
|
2022-03-30 15:30:00 +00:00
|
|
|
strncpy (mod->name, name, sizeof (mod->name) - 1);
|
2021-02-01 05:39:00 +00:00
|
|
|
mod->name[sizeof (mod->name) - 1] = 0;
|
|
|
|
free (name);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-07-22 05:40:34 +00:00
|
|
|
// fill it in
|
2014-01-23 00:16:05 +00:00
|
|
|
mod->vpath = qfs_foundfile.vpath;
|
2004-02-08 02:49:38 +00:00
|
|
|
mod->fullbright = 0;
|
|
|
|
mod->shadow_alpha = 255;
|
|
|
|
mod->min_light = 0.0;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-07-22 05:40:34 +00:00
|
|
|
// call the apropriate loader
|
2001-02-19 21:15:25 +00:00
|
|
|
mod->needload = false;
|
|
|
|
mod->hasfullbrights = false;
|
|
|
|
|
2010-08-23 02:58:49 +00:00
|
|
|
switch (LittleLong (*buf)) {
|
2012-04-27 05:40:06 +00:00
|
|
|
case IQM_SMAGIC:
|
|
|
|
if (strequal ((char *) buf, IQM_MAGIC)) {
|
|
|
|
if (mod_funcs)
|
|
|
|
mod_funcs->Mod_LoadIQM (mod, buf);
|
|
|
|
}
|
|
|
|
break;
|
2004-02-08 02:49:38 +00:00
|
|
|
case IDHEADER_MDL: // Type 6: Quake 1 .mdl
|
|
|
|
case HEADER_MDL16: // QF Type 6 extended for 16bit precision
|
2021-02-01 05:39:00 +00:00
|
|
|
if (strequal (mod->path, "progs/grenade.mdl")) {
|
2004-02-08 02:49:38 +00:00
|
|
|
mod->fullbright = 0;
|
2012-07-17 08:12:34 +00:00
|
|
|
mod->shadow_alpha = 255;
|
2021-02-01 05:39:00 +00:00
|
|
|
} else if (strnequal (mod->path, "progs/flame", 11)
|
|
|
|
|| strnequal (mod->path, "progs/bolt", 10)) {
|
2004-02-08 02:49:38 +00:00
|
|
|
mod->fullbright = 1;
|
|
|
|
mod->shadow_alpha = 0;
|
|
|
|
}
|
2021-02-01 05:39:00 +00:00
|
|
|
if (strnequal (mod->path, "progs/v_", 8)) {
|
2004-02-08 02:49:38 +00:00
|
|
|
mod->min_light = 0.12;
|
2021-02-01 05:39:00 +00:00
|
|
|
} else if (strequal (mod->path, "progs/player.mdl")) {
|
2004-02-08 02:49:38 +00:00
|
|
|
mod->min_light = 0.04;
|
|
|
|
}
|
2012-04-15 05:12:00 +00:00
|
|
|
if (mod_funcs)
|
|
|
|
mod_funcs->Mod_LoadAliasModel (mod, buf, allocator);
|
2001-02-19 21:15:25 +00:00
|
|
|
break;
|
2004-02-08 02:49:38 +00:00
|
|
|
case IDHEADER_MD2: // Type 8: Quake 2 .md2
|
|
|
|
// Mod_LoadMD2 (mod, buf, allocator);
|
|
|
|
break;
|
|
|
|
case IDHEADER_SPR: // Type 1: Quake 1 .spr
|
2012-04-15 05:12:00 +00:00
|
|
|
if (mod_funcs)
|
|
|
|
mod_funcs->Mod_LoadSpriteModel (mod, buf);
|
2001-02-19 21:15:25 +00:00
|
|
|
break;
|
2004-02-08 02:49:38 +00:00
|
|
|
case IDHEADER_SP2: // Type 2: Quake 2 .sp2
|
|
|
|
// Mod_LoadSP2 (mod, buf);
|
|
|
|
break;
|
|
|
|
default: // Version 29: Quake 1 .bsp
|
|
|
|
// Version 38: Quake 2 .bsp
|
2001-02-19 21:15:25 +00:00
|
|
|
Mod_LoadBrushModel (mod, buf);
|
|
|
|
break;
|
|
|
|
}
|
2002-10-11 02:54:02 +00:00
|
|
|
free (buf);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
return mod;
|
|
|
|
}
|
|
|
|
|
2002-11-05 19:12:51 +00:00
|
|
|
/*
|
|
|
|
Mod_LoadModel
|
|
|
|
|
|
|
|
Loads a model into the cache
|
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static model_t *
|
2023-06-13 09:06:11 +00:00
|
|
|
Mod_LoadModel (model_t *mod, bool crash)
|
2002-11-05 19:12:51 +00:00
|
|
|
{
|
|
|
|
if (!mod->needload) {
|
2012-01-29 13:32:35 +00:00
|
|
|
if (mod->type == mod_alias && !mod->aliashdr) {
|
2002-11-05 19:12:51 +00:00
|
|
|
if (Cache_Check (&mod->cache))
|
|
|
|
return mod;
|
|
|
|
} else
|
|
|
|
return mod; // not cached at all
|
|
|
|
}
|
|
|
|
return Mod_RealLoadModel (mod, crash, Cache_Alloc);
|
|
|
|
}
|
|
|
|
|
2001-08-31 12:22:45 +00:00
|
|
|
/*
|
|
|
|
Mod_CallbackLoad
|
|
|
|
|
|
|
|
Callback used to load model automatically
|
|
|
|
*/
|
2002-11-05 19:12:51 +00:00
|
|
|
static void
|
2001-08-31 12:22:45 +00:00
|
|
|
Mod_CallbackLoad (void *object, cache_allocator_t allocator)
|
|
|
|
{
|
2001-08-31 17:33:25 +00:00
|
|
|
if (((model_t *)object)->type != mod_alias)
|
2002-05-14 06:12:29 +00:00
|
|
|
Sys_Error ("Mod_CallbackLoad for non-alias model? FIXME!");
|
2001-08-31 12:22:45 +00:00
|
|
|
// FIXME: do we want crash set to true?
|
|
|
|
Mod_RealLoadModel (object, true, allocator);
|
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
Mod_ForName
|
|
|
|
|
|
|
|
Loads in a model for the given name
|
|
|
|
*/
|
2007-03-10 12:00:59 +00:00
|
|
|
VISIBLE model_t *
|
2023-06-13 09:06:11 +00:00
|
|
|
Mod_ForName (const char *name, bool crash)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
model_t *mod;
|
|
|
|
|
|
|
|
mod = Mod_FindName (name);
|
|
|
|
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, "Mod_ForName: %s, %p\n", name, mod);
|
2001-02-19 21:15:25 +00:00
|
|
|
return Mod_LoadModel (mod, crash);
|
|
|
|
}
|
|
|
|
|
2007-03-10 12:00:59 +00:00
|
|
|
VISIBLE void
|
2001-07-15 07:04:17 +00:00
|
|
|
Mod_TouchModel (const char *name)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
model_t *mod;
|
|
|
|
|
|
|
|
mod = Mod_FindName (name);
|
|
|
|
|
|
|
|
if (!mod->needload) {
|
|
|
|
if (mod->type == mod_alias)
|
|
|
|
Cache_Check (&mod->cache);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-04 05:13:18 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-10 12:00:59 +00:00
|
|
|
VISIBLE void
|
2001-02-19 21:15:25 +00:00
|
|
|
Mod_Print (void)
|
|
|
|
{
|
2021-02-01 06:02:42 +00:00
|
|
|
size_t i;
|
2010-11-23 03:48:53 +00:00
|
|
|
model_t **mod;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-09-21 04:22:46 +00:00
|
|
|
Sys_Printf ("Cached models:\n");
|
2021-02-01 06:02:42 +00:00
|
|
|
for (i = 0, mod = mod_known.a; i < mod_numknown; i++, mod++) {
|
2021-02-01 05:39:00 +00:00
|
|
|
Sys_Printf ("%8p : %s\n", (*mod)->cache.data, (*mod)->path);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
2002-08-20 00:48:59 +00:00
|
|
|
|
|
|
|
float
|
|
|
|
RadiusFromBounds (const vec3_t mins, const vec3_t maxs)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
vec3_t corner;
|
|
|
|
|
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
corner[i] = max (fabs (mins[i]), fabs (maxs[i]));
|
2002-08-20 02:22:40 +00:00
|
|
|
return VectorLength (corner);
|
2002-08-20 00:48:59 +00:00
|
|
|
}
|