mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-17 01:11:45 +00:00
turns out the sprite models are /not/ relocatable, so back out that change
in favor of cleaning up the accessors
This commit is contained in:
parent
896d304ac9
commit
ea614fc2c6
5 changed files with 17 additions and 21 deletions
|
@ -49,7 +49,7 @@
|
||||||
#include "QF/vfs.h"
|
#include "QF/vfs.h"
|
||||||
|
|
||||||
void Mod_LoadAliasModel (model_t *mod, void *buf, cache_allocator_t allocator);
|
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);
|
void Mod_LoadBrushModel (model_t *mod, void *buf);
|
||||||
model_t *Mod_RealLoadModel (model_t *mod, qboolean crash, cache_allocator_t allocator);
|
model_t *Mod_RealLoadModel (model_t *mod, qboolean crash, cache_allocator_t allocator);
|
||||||
void Mod_CallbackLoad (void *object, 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)
|
Mod_LoadModel (model_t *mod, qboolean crash)
|
||||||
{
|
{
|
||||||
if (!mod->needload) {
|
if (!mod->needload) {
|
||||||
if (mod->type == mod_alias || mod->type == mod_sprite) {
|
if (mod->type == mod_alias) {
|
||||||
if (Cache_Check (&mod->cache))
|
if (Cache_Check (&mod->cache))
|
||||||
return mod;
|
return mod;
|
||||||
} else
|
} else
|
||||||
return mod; // not cached at all
|
return mod; // not cached at all
|
||||||
}
|
}
|
||||||
if (Cache_Check (&mod->cache))
|
|
||||||
Cache_Free (&mod->cache);
|
|
||||||
return Mod_RealLoadModel (mod, crash, Cache_Alloc);
|
return Mod_RealLoadModel (mod, crash, Cache_Alloc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,7 +201,7 @@ Mod_RealLoadModel (model_t *mod, qboolean crash, cache_allocator_t allocator)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IDSPRITEHEADER:
|
case IDSPRITEHEADER:
|
||||||
Mod_LoadSpriteModel (mod, buf, allocator);
|
Mod_LoadSpriteModel (mod, buf);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -222,8 +220,8 @@ Mod_RealLoadModel (model_t *mod, qboolean crash, cache_allocator_t allocator)
|
||||||
void
|
void
|
||||||
Mod_CallbackLoad (void *object, cache_allocator_t allocator)
|
Mod_CallbackLoad (void *object, cache_allocator_t allocator)
|
||||||
{
|
{
|
||||||
if (((model_t *)object)->type == mod_brush)
|
if (((model_t *)object)->type != mod_alias)
|
||||||
Sys_Error ("Mod_CallbackLoad for mod_brush not yet supported. FIXME!\n");
|
Sys_Error ("Mod_CallbackLoad for non-alias model? FIXME!\n");
|
||||||
// FIXME: do we want crash set to true?
|
// FIXME: do we want crash set to true?
|
||||||
Mod_RealLoadModel (object, true, allocator);
|
Mod_RealLoadModel (object, true, allocator);
|
||||||
}
|
}
|
||||||
|
@ -265,6 +263,6 @@ Mod_Print (void)
|
||||||
|
|
||||||
Con_Printf ("Cached models:\n");
|
Con_Printf ("Cached models:\n");
|
||||||
for (i = 0, mod = mod_known; i < mod_numknown; i++, mod++) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ Mod_LoadSpriteGroup (void *pin, mspriteframe_t **ppframe, int framenum)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Mod_LoadSpriteModel (model_t *mod, void *buffer, cache_allocator_t allocator)
|
Mod_LoadSpriteModel (model_t *mod, void *buffer)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int version;
|
int version;
|
||||||
|
@ -111,7 +111,9 @@ Mod_LoadSpriteModel (model_t *mod, void *buffer, cache_allocator_t allocator)
|
||||||
|
|
||||||
size = field_offset (msprite_t, frames[numframes]);
|
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->type = LittleLong (pin->type);
|
||||||
psprite->maxwidth = LittleLong (pin->width);
|
psprite->maxwidth = LittleLong (pin->width);
|
||||||
|
|
|
@ -133,13 +133,15 @@ R_RotateForEntity (entity_t *e)
|
||||||
}
|
}
|
||||||
|
|
||||||
static mspriteframe_t *
|
static mspriteframe_t *
|
||||||
R_GetSpriteFrame (entity_t *currententity, msprite_t *psprite)
|
R_GetSpriteFrame (entity_t *currententity)
|
||||||
{
|
{
|
||||||
|
msprite_t *psprite;
|
||||||
mspritegroup_t *pspritegroup;
|
mspritegroup_t *pspritegroup;
|
||||||
mspriteframe_t *pspriteframe;
|
mspriteframe_t *pspriteframe;
|
||||||
int i, numframes, frame;
|
int i, numframes, frame;
|
||||||
float *pintervals, fullinterval, targettime, time;
|
float *pintervals, fullinterval, targettime, time;
|
||||||
|
|
||||||
|
psprite = currententity->model->cache.data;
|
||||||
frame = currententity->frame;
|
frame = currententity->frame;
|
||||||
|
|
||||||
if ((frame >= psprite->numframes) || (frame < 0)) {
|
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
|
// don't even bother culling, because it's just a single
|
||||||
// polygon without a surface cache
|
// polygon without a surface cache
|
||||||
psprite = Cache_Get (¤tentity->model->cache);
|
frame = R_GetSpriteFrame (e);
|
||||||
frame = R_GetSpriteFrame (e, psprite);
|
psprite = currententity->model->cache.data;
|
||||||
|
|
||||||
if (psprite->type == SPR_ORIENTED) { // bullet marks on walls
|
if (psprite->type == SPR_ORIENTED) { // bullet marks on walls
|
||||||
AngleVectors (currententity->angles, v_forward, v_right, v_up);
|
AngleVectors (currententity->angles, v_forward, v_right, v_up);
|
||||||
|
@ -224,8 +226,6 @@ R_DrawSpriteModel (entity_t *e)
|
||||||
qfglEnd ();
|
qfglEnd ();
|
||||||
|
|
||||||
qfglDisable (GL_ALPHA_TEST);
|
qfglDisable (GL_ALPHA_TEST);
|
||||||
|
|
||||||
Cache_Release (¤tentity->model->cache);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -282,7 +282,7 @@ R_DrawSprite (void)
|
||||||
vec3_t tvec;
|
vec3_t tvec;
|
||||||
float dot, angle, sr, cr;
|
float dot, angle, sr, cr;
|
||||||
|
|
||||||
psprite = Cache_Get (¤tentity->model->cache);
|
psprite = currententity->model->cache.data;
|
||||||
|
|
||||||
r_spritedesc.pspriteframe = R_GetSpriteframe (psprite);
|
r_spritedesc.pspriteframe = R_GetSpriteframe (psprite);
|
||||||
|
|
||||||
|
@ -378,6 +378,4 @@ R_DrawSprite (void)
|
||||||
R_RotateSprite (psprite->beamlength);
|
R_RotateSprite (psprite->beamlength);
|
||||||
|
|
||||||
R_SetupAndDrawSprite ();
|
R_SetupAndDrawSprite ();
|
||||||
|
|
||||||
Cache_Release (¤tentity->model->cache);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -282,7 +282,7 @@ R_DrawSprite (void)
|
||||||
vec3_t tvec;
|
vec3_t tvec;
|
||||||
float dot, angle, sr, cr;
|
float dot, angle, sr, cr;
|
||||||
|
|
||||||
psprite = Cache_Get (¤tentity->model->cache);
|
psprite = currententity->model->cache.data;
|
||||||
|
|
||||||
r_spritedesc.pspriteframe = R_GetSpriteframe (psprite);
|
r_spritedesc.pspriteframe = R_GetSpriteframe (psprite);
|
||||||
|
|
||||||
|
@ -378,6 +378,4 @@ R_DrawSprite (void)
|
||||||
R_RotateSprite (psprite->beamlength);
|
R_RotateSprite (psprite->beamlength);
|
||||||
|
|
||||||
R_SetupAndDrawSprite ();
|
R_SetupAndDrawSprite ();
|
||||||
|
|
||||||
Cache_Release (¤tentity->model->cache);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue