diff --git a/libs/models/model.c b/libs/models/model.c index 849f7d6ed..b2edb7322 100644 --- a/libs/models/model.c +++ b/libs/models/model.c @@ -49,7 +49,7 @@ #include "QF/vfs.h" void Mod_LoadAliasModel (model_t *mod, void *buf, cache_allocator_t allocator); -void Mod_LoadSpriteModel (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); model_t *Mod_RealLoadModel (model_t *mod, qboolean crash, cache_allocator_t allocator); void Mod_CallbackLoad (void *object, cache_allocator_t allocator); @@ -160,14 +160,12 @@ model_t * Mod_LoadModel (model_t *mod, qboolean crash) { if (!mod->needload) { - if (mod->type == mod_alias || mod->type == mod_sprite) { + if (mod->type == mod_alias) { if (Cache_Check (&mod->cache)) return mod; } else return mod; // not cached at all } - if (Cache_Check (&mod->cache)) - Cache_Free (&mod->cache); return Mod_RealLoadModel (mod, crash, Cache_Alloc); } @@ -203,7 +201,7 @@ Mod_RealLoadModel (model_t *mod, qboolean crash, cache_allocator_t allocator) break; case IDSPRITEHEADER: - Mod_LoadSpriteModel (mod, buf, allocator); + Mod_LoadSpriteModel (mod, buf); break; default: @@ -222,8 +220,8 @@ Mod_RealLoadModel (model_t *mod, qboolean crash, cache_allocator_t allocator) void Mod_CallbackLoad (void *object, cache_allocator_t allocator) { - if (((model_t *)object)->type == mod_brush) - Sys_Error ("Mod_CallbackLoad for mod_brush not yet supported. FIXME!\n"); + if (((model_t *)object)->type != mod_alias) + Sys_Error ("Mod_CallbackLoad for non-alias model? FIXME!\n"); // FIXME: do we want crash set to true? Mod_RealLoadModel (object, true, allocator); } @@ -265,6 +263,6 @@ Mod_Print (void) Con_Printf ("Cached models:\n"); for (i = 0, mod = mod_known; i < mod_numknown; i++, mod++) { - Con_Printf ("%8p : %s\n", Cache_Check (&mod->cache), mod->name); + Con_Printf ("%8p : %s\n", mod->cache.data, mod->name); } } diff --git a/libs/models/sprite/model_sprite.c b/libs/models/sprite/model_sprite.c index 096158b30..7ee30bdd5 100644 --- a/libs/models/sprite/model_sprite.c +++ b/libs/models/sprite/model_sprite.c @@ -90,7 +90,7 @@ Mod_LoadSpriteGroup (void *pin, mspriteframe_t **ppframe, int framenum) } void -Mod_LoadSpriteModel (model_t *mod, void *buffer, cache_allocator_t allocator) +Mod_LoadSpriteModel (model_t *mod, void *buffer) { int i; int version; @@ -111,7 +111,9 @@ Mod_LoadSpriteModel (model_t *mod, void *buffer, cache_allocator_t allocator) size = field_offset (msprite_t, frames[numframes]); - psprite = allocator (&mod->cache, size, loadname); + psprite = Hunk_AllocName (size, loadname); + + mod->cache.data = psprite; psprite->type = LittleLong (pin->type); psprite->maxwidth = LittleLong (pin->width); diff --git a/libs/video/renderer/gl/gl_rmain.c b/libs/video/renderer/gl/gl_rmain.c index c52c8a9f8..5d009b751 100644 --- a/libs/video/renderer/gl/gl_rmain.c +++ b/libs/video/renderer/gl/gl_rmain.c @@ -133,13 +133,15 @@ R_RotateForEntity (entity_t *e) } static mspriteframe_t * -R_GetSpriteFrame (entity_t *currententity, msprite_t *psprite) +R_GetSpriteFrame (entity_t *currententity) { + msprite_t *psprite; mspritegroup_t *pspritegroup; mspriteframe_t *pspriteframe; int i, numframes, frame; float *pintervals, fullinterval, targettime, time; + psprite = currententity->model->cache.data; frame = currententity->frame; if ((frame >= psprite->numframes) || (frame < 0)) { @@ -184,8 +186,8 @@ R_DrawSpriteModel (entity_t *e) // don't even bother culling, because it's just a single // polygon without a surface cache - psprite = Cache_Get (¤tentity->model->cache); - frame = R_GetSpriteFrame (e, psprite); + frame = R_GetSpriteFrame (e); + psprite = currententity->model->cache.data; if (psprite->type == SPR_ORIENTED) { // bullet marks on walls AngleVectors (currententity->angles, v_forward, v_right, v_up); @@ -224,8 +226,6 @@ R_DrawSpriteModel (entity_t *e) qfglEnd (); qfglDisable (GL_ALPHA_TEST); - - Cache_Release (¤tentity->model->cache); } /* diff --git a/libs/video/renderer/sw/sw_rsprite.c b/libs/video/renderer/sw/sw_rsprite.c index 3eb03ceed..316598c7a 100644 --- a/libs/video/renderer/sw/sw_rsprite.c +++ b/libs/video/renderer/sw/sw_rsprite.c @@ -282,7 +282,7 @@ R_DrawSprite (void) vec3_t tvec; float dot, angle, sr, cr; - psprite = Cache_Get (¤tentity->model->cache); + psprite = currententity->model->cache.data; r_spritedesc.pspriteframe = R_GetSpriteframe (psprite); @@ -378,6 +378,4 @@ R_DrawSprite (void) R_RotateSprite (psprite->beamlength); R_SetupAndDrawSprite (); - - Cache_Release (¤tentity->model->cache); } diff --git a/libs/video/renderer/sw32/sw32_rsprite.c b/libs/video/renderer/sw32/sw32_rsprite.c index f7985b141..ba697da67 100644 --- a/libs/video/renderer/sw32/sw32_rsprite.c +++ b/libs/video/renderer/sw32/sw32_rsprite.c @@ -282,7 +282,7 @@ R_DrawSprite (void) vec3_t tvec; float dot, angle, sr, cr; - psprite = Cache_Get (¤tentity->model->cache); + psprite = currententity->model->cache.data; r_spritedesc.pspriteframe = R_GetSpriteframe (psprite); @@ -378,6 +378,4 @@ R_DrawSprite (void) R_RotateSprite (psprite->beamlength); R_SetupAndDrawSprite (); - - Cache_Release (¤tentity->model->cache); }