cliptrace.fraction = 1;
cliptrace.realfraction = 1;
- Mod_CheckLoaded(cl.worldmodel);
if (cl.worldmodel && cl.worldmodel->TraceBox)
cl.worldmodel->TraceBox(cl.worldmodel, 0, &cliptrace, startmins, startmaxs, endmins, endmaxs, hitsupercontentsmask);
if (hitent)
*hitent = 0;
- Mod_CheckLoaded(cl.worldmodel);
if (cl.worldmodel && cl.worldmodel->TraceBox)
cl.worldmodel->TraceBox(cl.worldmodel, 0, &trace, start, start, end, end, SUPERCONTENTS_SOLID);
e->render.model = cl.model_precache[e->state_current.modelindex];
if (e->render.model)
{
- Mod_CheckLoaded(e->render.model);
// if model is alias or this is a tenebrae-like dlight, reverse pitch direction
if (e->render.model->type == mod_alias || (e->state_current.lightpflags & PFLAGS_FULLDYNAMIC))
angles[0] = -angles[0];
entity_t *e;
for (i = 0, e = cl_static_entities;i < cl_num_static_entities && r_refdef.numentities < r_refdef.maxentities;i++, e++)
{
- Mod_CheckLoaded(e->render.model);
e->render.flags = 0;
// transparent stuff can't be lit during the opaque stage
if (e->render.effects & (EF_ADDITIVE | EF_NODEPTHTEST) || e->render.alpha < 1)
}
model = cl.model_precache[s->modelindex];
- Mod_CheckLoaded(model);
if (model && model->type && s->frame >= model->numframes)
{
Con_DPrintf("CL_ValidateState: no such frame %i in \"%s\" (which has %i frames)\n", s->frame, model->name, model->numframes);
for (i = 0;i < r_refdef.numentities;i++)
{
ent = r_refdef.entities[i];
- Mod_CheckLoaded(ent->model);
// some of the renderer still relies on origin...
Matrix4x4_OriginFromMatrix(&ent->matrix, ent->origin);
// some of the renderer still relies on scale...
for (i = 0;i < r_refdef.numentities;i++)
{
ent = r_refdef.entities[i];
- Mod_CheckLoaded(ent->model);
// some of the renderer still relies on origin...
Matrix4x4_OriginFromMatrix(&ent->matrix, ent->origin);
// some of the renderer still relies on scale...
model = ent->model;
if (model && model->name[0] == '*')
{
- Mod_CheckLoaded(model);
if (model->brush.data_nodes)
{
Matrix4x4_Transform(&ent->inversematrix, origin, org);
if (model == NULL)
return NULL;
- Mod_CheckLoaded(model);
-
// LordHavoc: modified to start at first clip node,
// in other words: first node of the (sub)model
node = model->brush.data_nodes + model->brushq1.hulls[0].firstclipnode;
static qbyte *Mod_Q1BSP_GetPVS(model_t *model, const vec3_t p)
{
mnode_t *node;
- Mod_CheckLoaded(model);
node = model->brush.data_nodes;
while (node->plane)
node = node->children[(node->plane->type < 3 ? p[node->plane->type] : DotProduct(p,node->plane->normal)) < node->plane->dist];
static void mod_start(void)
{
int i;
- for (i = 0;i < MAX_MOD_KNOWN;i++)
- if (mod_known[i].name[0])
- Mod_UnloadModel(&mod_known[i]);
- Mod_LoadModels();
+ model_t *mod;
+
+ for (i = 0, mod = mod_known;i < MAX_MOD_KNOWN;i++, mod++)
+ if (mod->name[0])
+ if (mod->used)
+ Mod_LoadModel(mod, true, false, mod->isworldmodel);
}
static void mod_shutdown(void)
{
int i;
- for (i = 0;i < MAX_MOD_KNOWN;i++)
- if (mod_known[i].name[0])
- Mod_UnloadModel(&mod_known[i]);
+ model_t *mod;
+
+ for (i = 0, mod = mod_known;i < MAX_MOD_KNOWN;i++, mod++)
+ if (mod->loaded)
+ Mod_UnloadModel(mod);
}
static void mod_newmap(void)
R_RegisterModule("Models", mod_start, mod_shutdown, mod_newmap);
}
-void Mod_FreeModel (model_t *mod)
-{
- R_FreeTexturePool(&mod->texturepool);
- Mem_FreePool(&mod->mempool);
-
- // clear the struct to make it available
- memset(mod, 0, sizeof(model_t));
-}
-
void Mod_UnloadModel (model_t *mod)
{
char name[MAX_QPATH];
strcpy(name, mod->name);
isworldmodel = mod->isworldmodel;
used = mod->used;
- Mod_FreeModel(mod);
+ // free textures/memory attached to the model
+ R_FreeTexturePool(&mod->texturepool);
+ Mem_FreePool(&mod->mempool);
+ // clear the struct to make it available
+ memset(mod, 0, sizeof(model_t));
+ // restore the fields we want to preserve
strcpy(mod->name, name);
mod->isworldmodel = isworldmodel;
mod->used = used;
void Mod_ClearUsed(void)
{
+#if 0
int i;
model_t *mod;
for (i = 0, mod = mod_known;i < MAX_MOD_KNOWN;i++, mod++)
if (mod->name[0])
mod->used = false;
+#endif
}
void Mod_PurgeUnused(void)
for (i = 0, mod = mod_known;i < MAX_MOD_KNOWN;i++, mod++)
if (mod->name[0])
if (!mod->used)
- Mod_FreeModel(mod);
+ Mod_UnloadModel(mod);
}
// only used during loading!
void Mod_RemoveStaleWorldModels(model_t *skip)
-{
- int i;
- for (i = 0;i < MAX_MOD_KNOWN;i++)
- if (mod_known[i].isworldmodel && skip != &mod_known[i])
- Mod_UnloadModel(mod_known + i);
-}
-
-void Mod_LoadModels(void)
{
int i;
model_t *mod;
for (i = 0, mod = mod_known;i < MAX_MOD_KNOWN;i++, mod++)
- if (mod->name[0])
- if (mod->used)
- Mod_CheckLoaded(mod);
+ {
+ if (mod->isworldmodel && mod->loaded && skip != mod)
+ {
+ Mod_UnloadModel(mod);
+ mod->isworldmodel = false;
+ mod->used = false;
+ }
+ }
}
/*
*/
model_t *Mod_ForName(const char *name, qboolean crash, qboolean checkdisk, qboolean isworldmodel)
{
- return Mod_LoadModel(Mod_FindName(name), crash, checkdisk, isworldmodel);
+ model_t *model;
+ model = Mod_FindName(name);
+ if (!model->loaded || checkdisk)
+ Mod_LoadModel(model, crash, checkdisk, isworldmodel);
+ return model;
}
qbyte *mod_base;
extern cvar_t r_fullbrights;
void Mod_Init (void);
-#define Mod_CheckLoaded(mod) (mod ? (mod->loaded ? (mod->used = true) : (Mod_LoadModel(mod, true, true, mod->isworldmodel), true)) : false)
model_t *Mod_LoadModel(model_t *mod, qboolean crash, qboolean checkdisk, qboolean isworldmodel);
void Mod_ClearAll (void);
model_t *Mod_FindName (const char *name);
void Mod_ClearUsed(void);
void Mod_PurgeUnused(void);
void Mod_RemoveStaleWorldModels(model_t *skip); // only used during loading!
-void Mod_LoadModels(void);
extern model_t *loadmodel;
extern char loadname[32]; // for hunk tags
portal_markid++;
- Mod_CheckLoaded(model);
Portal_PolygonRecursiveMarkLeafs(model->brush.data_nodes, polypoints, numpoints);
eyeleaf = model->brush.PointInLeaf(model, eye);
return;
}
- Mod_CheckLoaded(model);
-
if (!model->brush.data_nodes)
{
Con_Print("Portal_Visibility: not a brush model\n");
// generate much traffic (in old protocols they hog bandwidth)
else if (!(s->effects & EF_NODEPTHTEST) && !((isbmodel = (model = sv.models[s->modelindex]) != NULL && model->name[0] == '*') && (sv.protocol != PROTOCOL_QUAKE && sv.protocol != PROTOCOL_QUAKEDP && sv.protocol != PROTOCOL_NEHAHRAMOVIE)))
{
- Mod_CheckLoaded(model);
// entity has survived every check so far, check if visible
ed = PRVM_EDICT_NUM(s->number);
sv_writeentitiestoclient_visibleentities = 0;
sv_writeentitiestoclient_totalentities = 0;
- Mod_CheckLoaded(sv.worldmodel);
-
// find the client's PVS
// the real place being tested from
VectorAdd(clent->fields.server->origin, clent->fields.server->view_ofs, sv_writeentitiestoclient_testeye);
*/
void SV_ClearWorld (void)
{
- Mod_CheckLoaded(sv.worldmodel);
SV_CreateAreaGrid(sv.worldmodel->normalmins, sv.worldmodel->normalmaxs);
}
model = sv.models[modelindex];
if (model != NULL)
{
- Mod_CheckLoaded(model);
if (!model->TraceBox)
Con_Printf("edict %i: SOLID_BSP with non-collidable model\n", PRVM_NUM_FOR_EDICT(ent));
return trace;
}
- Mod_CheckLoaded(model);
if ((int) ent->fields.server->solid == SOLID_BSP)
{
if (!model->TraceBox)