From 80949930bd59948bd3c7c7e2d7e4180965fb12d7 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Thu, 12 Jan 2012 20:48:38 +0000 Subject: [PATCH] Temporarily disable the 'model thinning-out' feature intended to save memory. It turns out that with model interpolation, out-of-bounds frame numbers may be generated with thinned out models, so disable it until I can sort out what's wrong with it. Also, minor code cleanup. git-svn-id: https://svn.eduke32.com/eduke32@2251 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/mdsprite.h | 8 ++++---- polymer/eduke32/build/src/defs.c | 11 +++++++---- polymer/eduke32/build/src/mdsprite.c | 17 ++++++++++------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/polymer/eduke32/build/include/mdsprite.h b/polymer/eduke32/build/include/mdsprite.h index 499da8e3a..b9a57b1d9 100644 --- a/polymer/eduke32/build/include/mdsprite.h +++ b/polymer/eduke32/build/include/mdsprite.h @@ -204,12 +204,12 @@ typedef struct EXTERN mdmodel_t **models; -void updateanimation(md2model_t *m, spritetype *tspr); +void updateanimation(md2model_t *m, const spritetype *tspr); int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf); void mdinit(void); void freeallmodels(void); void clearskins(void); -int32_t mddraw(spritetype *tspr); +int32_t mddraw(const spritetype *tspr); typedef struct { float xadd, yadd, zadd; int16_t angadd, flags, fov; } hudtyp; @@ -221,9 +221,9 @@ EXTERN voxmodel_t *voxmodels[MAXVOXELS]; void voxfree(voxmodel_t *m); voxmodel_t *voxload(const char *filnam); -int32_t voxdraw(voxmodel_t *m, spritetype *tspr); +int32_t voxdraw(voxmodel_t *m, const spritetype *tspr); int md3postload_polymer(md3model_t* m); -int32_t md_thinoutmodel(int32_t modelid, uint8_t *usedframebitmap); +//int32_t md_thinoutmodel(int32_t modelid, uint8_t *usedframebitmap); #endif // !_mdsprite_h_ diff --git a/polymer/eduke32/build/src/defs.c b/polymer/eduke32/build/src/defs.c index 5e2378715..ab0e390d6 100644 --- a/polymer/eduke32/build/src/defs.c +++ b/polymer/eduke32/build/src/defs.c @@ -1347,22 +1347,25 @@ static int32_t defsparser(scriptfile *script) md_setmisc(lastmodelid,(float)scale,shadeoffs,(float)mzadd,flags); // thin out the loaded model by throwing away unused frames + // FIXME: CURRENTLY DISABLED: interpolation may access frames we consider 'unused'? +# if 0 if (models[lastmodelid]->mdnum==3 && ((md3model_t *)models[lastmodelid])->numframes <= 1024) { -#ifdef DEBUG_MODEL_MEM +# ifdef DEBUG_MODEL_MEM md3model_t *m = (md3model_t *)models[lastmodelid]; int32_t i, onumframes; onumframes = m->numframes; i = -#endif +# endif md_thinoutmodel(lastmodelid, usedframebitmap); -#ifdef DEBUG_MODEL_MEM +# ifdef DEBUG_MODEL_MEM if (i>=0 && i voxmodel_t *voxmodels[MAXVOXELS]; -int32_t curextra=MAXTILES; +static int32_t curextra=MAXTILES; // nedpool *model_data_pool; // #define MODEL_POOL_SIZE 20971520 #define model_data_pool (nedpool *) 0 // take it out of the system pool @@ -74,7 +74,6 @@ static GLuint *vertvbos = NULL; static GLuint *indexvbos = NULL; static mdmodel_t *mdload(const char *); -int32_t mddraw(spritetype *); static void mdfree(mdmodel_t *); int32_t globalnoeffect=0; @@ -323,6 +322,8 @@ int32_t md_defineanimation(int32_t modelid, const char *framestart, const char * return(0); } +#if 0 +// FIXME: CURRENTLY DISABLED: interpolation may access frames we consider 'unused'? int32_t md_thinoutmodel(int32_t modelid, uint8_t *usedframebitmap) { md3model_t *m; @@ -424,6 +425,7 @@ int32_t md_thinoutmodel(int32_t modelid, uint8_t *usedframebitmap) //////////// return usedframes; } +#endif int32_t md_defineskin(int32_t modelid, const char *skinfn, int32_t palnum, int32_t skinnum, int32_t surfnum, float param, float specpower, float specfactor) { @@ -898,7 +900,7 @@ int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf) } //Note: even though it says md2model, it works for both md2model&md3model -void updateanimation(md2model_t *m, spritetype *tspr) +void updateanimation(md2model_t *m, const spritetype *tspr) { mdanim_t *anim; int32_t i, j, k; @@ -1870,7 +1872,7 @@ int md3postload_polymer(md3model_t *m) } -static int32_t md3draw(md3model_t *m, spritetype *tspr) +static int32_t md3draw(md3model_t *m, const spritetype *tspr) { point3d fp, fp1, fp2, m0, m1, a0; md3xyzn_t *v0, *v1; @@ -1901,7 +1903,8 @@ static int32_t md3draw(md3model_t *m, spritetype *tspr) m->cframe < 0 || m->cframe >= m->numframes || m->nframe < 0 || m->nframe >= m->numframes) { - OSD_Printf("%s: Model frame out of bounds!\n", m->head.nam); + OSD_Printf("%s: mdframe oob: c:%d n:%d total:%d interpol:%.02f\n", + m->head.nam, m->cframe, m->nframe, m->numframes, m->interpol); if (m->interpol < 0) m->interpol = 0; if (m->interpol > 1) @@ -3116,7 +3119,7 @@ voxmodel_t *voxload(const char *filnam) } //Draw voxel model as perfect cubes -int32_t voxdraw(voxmodel_t *m, spritetype *tspr) +int32_t voxdraw(voxmodel_t *m, const spritetype *tspr) { point3d fp, m0, a0; int32_t i, j, fi, xx, yy, zz; @@ -3321,7 +3324,7 @@ mdmodel_t *mdload(const char *filnam) return(vm); } -int32_t mddraw(spritetype *tspr) +int32_t mddraw(const spritetype *tspr) { mdmodel_t *vm; int32_t i;