mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-16 09:21:36 +00:00
smoothduration def token for model frame definitions (defaults at 0)
git-svn-id: https://svn.eduke32.com/eduke32@531 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
fc613042a0
commit
a71d347f83
5 changed files with 61 additions and 45 deletions
|
@ -153,17 +153,23 @@ typedef struct BPACK
|
|||
typedef struct BPACK {
|
||||
unsigned long mdanimtims;
|
||||
short mdanimcur;
|
||||
short mdcurframe, mdoldframe;
|
||||
short mdsmooth;
|
||||
short angoff;
|
||||
short pitch, roll;
|
||||
long xoff, yoff, zoff;
|
||||
unsigned char flags;
|
||||
char filler[3];
|
||||
} spriteexttype;
|
||||
|
||||
typedef struct BPACK {
|
||||
short mdcurframe, mdoldframe;
|
||||
short mdsmooth;
|
||||
float smoothduration;
|
||||
} spritesmoothtype;
|
||||
|
||||
#define SPREXT_NOTMD 1
|
||||
#define SPREXT_NOMDANIM 2
|
||||
EXTERN spriteexttype spriteext[MAXSPRITES+MAXUNIQHUDID];
|
||||
EXTERN spritesmoothtype spritesmooth[MAXSPRITES+MAXUNIQHUDID];
|
||||
EXTERN long guniqhudid;
|
||||
|
||||
EXTERN sectortype sector[MAXSECTORS];
|
||||
|
@ -517,7 +523,7 @@ int hicclearsubst(long picnum, long palnum);
|
|||
int md_loadmodel(const char *fn);
|
||||
int md_setmisc(int modelid, float scale, int shadeoff, float zadd);
|
||||
int md_tilehasmodel(int tilenume);
|
||||
int md_defineframe(int modelid, const char *framename, int tilenume, int skinnum);
|
||||
int md_defineframe(int modelid, const char *framename, int tilenume, int skinnum, float smoothduration);
|
||||
int md_defineanimation(int modelid, const char *framestart, const char *frameend, int fps, int flags);
|
||||
int md_defineskin(int modelid, const char *skinfn, int palnum, int skinnum, int surfnum, float param);
|
||||
int md_definehud (int modelid, int tilex, double xadd, double yadd, double zadd, double angadd, int flags);
|
||||
|
|
|
@ -31,6 +31,7 @@ enum {
|
|||
T_SCALE,
|
||||
T_SHADE,
|
||||
T_FRAME,
|
||||
T_SMOOTHDURATION,
|
||||
T_ANIM,
|
||||
T_SKIN,
|
||||
T_SURF,
|
||||
|
@ -127,11 +128,12 @@ static tokenlist modeltokens[] = {
|
|||
};
|
||||
|
||||
static tokenlist modelframetokens[] = {
|
||||
{ "frame", T_FRAME },
|
||||
{ "name", T_FRAME },
|
||||
{ "tile", T_TILE },
|
||||
{ "tile0", T_TILE0 },
|
||||
{ "tile1", T_TILE1 },
|
||||
{ "frame", T_FRAME },
|
||||
{ "name", T_FRAME },
|
||||
{ "tile", T_TILE },
|
||||
{ "tile0", T_TILE0 },
|
||||
{ "tile1", T_TILE1 },
|
||||
{ "smoothduration", T_SMOOTHDURATION },
|
||||
};
|
||||
|
||||
static tokenlist modelanimtokens[] = {
|
||||
|
@ -534,7 +536,7 @@ static int defsparser(scriptfile *script)
|
|||
}
|
||||
#if defined(POLYMOST) && defined(USE_OPENGL)
|
||||
for (tilex = ftilenume; tilex <= ltilenume && happy; tilex++) {
|
||||
switch (md_defineframe(lastmodelid, framename, tilex, max(0,modelskin))) {
|
||||
switch (md_defineframe(lastmodelid, framename, tilex, max(0,modelskin), 0.0f)) {
|
||||
case 0:
|
||||
break;
|
||||
case -1:
|
||||
|
@ -730,6 +732,7 @@ static int defsparser(scriptfile *script)
|
|||
char *frametokptr = script->ltextptr;
|
||||
char *frameend, *framename = 0, happy=1;
|
||||
int ftilenume = -1, ltilenume = -1, tilex = 0;
|
||||
double smoothduration = 0.0f;
|
||||
|
||||
if (scriptfile_getbraces(script,&frameend)) break;
|
||||
while (script->textptr < frameend) {
|
||||
|
@ -742,6 +745,8 @@ static int defsparser(scriptfile *script)
|
|||
scriptfile_getsymbol(script,&ftilenume); break; //first tile number
|
||||
case T_TILE1:
|
||||
scriptfile_getsymbol(script,<ilenume); break; //last tile number (inclusive)
|
||||
case T_SMOOTHDURATION:
|
||||
scriptfile_getdouble(script,&smoothduration); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -762,7 +767,7 @@ static int defsparser(scriptfile *script)
|
|||
}
|
||||
#if defined(POLYMOST) && defined(USE_OPENGL)
|
||||
for (tilex = ftilenume; tilex <= ltilenume && happy; tilex++) {
|
||||
switch (md_defineframe(lastmodelid, framename, tilex, max(0,modelskin))) {
|
||||
switch (md_defineframe(lastmodelid, framename, tilex, max(0,modelskin), smoothduration)) {
|
||||
case 0:
|
||||
break;
|
||||
case -1:
|
||||
|
|
|
@ -6655,6 +6655,7 @@ long loadboard(char *filename, char fromwhere, long *daposx, long *daposy, long
|
|||
|
||||
#if defined(POLYMOST) && defined(USE_OPENGL)
|
||||
memset(spriteext, 0, sizeof(spriteext));
|
||||
memset(spritesmooth, 0, sizeof(spritesmooth));
|
||||
|
||||
if (rendmode == 4)
|
||||
polymer_loadboard();
|
||||
|
@ -7125,6 +7126,7 @@ if (numsprites > MAXSPRITES) { kclose(fil); return(-1); }
|
|||
|
||||
#if defined(POLYMOST) && defined(USE_OPENGL)
|
||||
memset(spriteext, 0, sizeof(spriteext));
|
||||
memset(spritesmooth, 0, sizeof(spritesmooth));
|
||||
#endif
|
||||
guniqhudid = 0;
|
||||
|
||||
|
@ -7175,6 +7177,7 @@ long loadmaphack(char *filename)
|
|||
if (!script) return -1;
|
||||
|
||||
memset(spriteext, 0, sizeof(spriteext));
|
||||
memset(spritesmooth, 0, sizeof(spritesmooth));
|
||||
|
||||
while (1) {
|
||||
tok = scriptfile_gettoken(script);
|
||||
|
|
|
@ -180,9 +180,10 @@ static voxmodel *voxmodels[MAXVOXELS];
|
|||
|
||||
typedef struct
|
||||
{ // maps build tiles to particular animation frames of a model
|
||||
int modelid;
|
||||
int skinnum;
|
||||
int framenum; // calculate the number from the name when declaring
|
||||
int modelid;
|
||||
int skinnum;
|
||||
int framenum; // calculate the number from the name when declaring
|
||||
float smoothduration;
|
||||
} tile2model_t;
|
||||
static tile2model_t tile2model[MAXTILES];
|
||||
|
||||
|
@ -357,7 +358,7 @@ static long framename2index (mdmodel *vm, const char *nam)
|
|||
return(i);
|
||||
}
|
||||
|
||||
int md_defineframe (int modelid, const char *framename, int tilenume, int skinnum)
|
||||
int md_defineframe (int modelid, const char *framename, int tilenume, int skinnum, float smoothduration)
|
||||
{
|
||||
void *vm;
|
||||
md2model *m;
|
||||
|
@ -382,6 +383,7 @@ int md_defineframe (int modelid, const char *framename, int tilenume, int skinnu
|
|||
tile2model[tilenume].modelid = modelid;
|
||||
tile2model[tilenume].framenum = i;
|
||||
tile2model[tilenume].skinnum = skinnum;
|
||||
tile2model[tilenume].smoothduration = smoothduration;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -865,6 +867,7 @@ static void updateanimation (md2model *m, spritetype *tspr)
|
|||
{
|
||||
// spriteext[tspr->owner].mdanimtims = mdtims;
|
||||
m->interpol = 0;
|
||||
spriteext[tspr->owner].mdanimtims = mdtims;
|
||||
m->nframe = m->cframe;
|
||||
return;
|
||||
}
|
||||
|
@ -875,31 +878,31 @@ static void updateanimation (md2model *m, spritetype *tspr)
|
|||
anim && anim->startframe != m->cframe;
|
||||
anim = anim->next) ;
|
||||
if (!anim) {
|
||||
if (r_animsmoothing && (spriteext[tspr->owner].mdoldframe != m->cframe))
|
||||
if (r_animsmoothing && (tile2model[tspr->picnum].smoothduration != 0) && (spritesmooth[tspr->owner].mdoldframe != m->cframe))
|
||||
{
|
||||
if (spriteext[tspr->owner].mdsmooth == 0)
|
||||
if (spritesmooth[tspr->owner].mdsmooth == 0)
|
||||
{
|
||||
spriteext[tspr->owner].mdanimtims = mdtims;
|
||||
m->interpol = 0;
|
||||
spriteext[tspr->owner].mdsmooth = 1;
|
||||
spriteext[tspr->owner].mdcurframe = m->cframe;
|
||||
spritesmooth[tspr->owner].mdsmooth = 1;
|
||||
spritesmooth[tspr->owner].mdcurframe = m->cframe;
|
||||
}
|
||||
if (r_animsmoothing && (spriteext[tspr->owner].mdcurframe != m->cframe))
|
||||
if (r_animsmoothing && (tile2model[tspr->picnum].smoothduration != 0) && (spritesmooth[tspr->owner].mdcurframe != m->cframe))
|
||||
{
|
||||
spriteext[tspr->owner].mdanimtims = mdtims;
|
||||
m->interpol = 0;
|
||||
spriteext[tspr->owner].mdsmooth = 1;
|
||||
spriteext[tspr->owner].mdoldframe = spriteext[tspr->owner].mdcurframe;
|
||||
spriteext[tspr->owner].mdcurframe = m->cframe;
|
||||
spritesmooth[tspr->owner].mdsmooth = 1;
|
||||
spritesmooth[tspr->owner].mdoldframe = spritesmooth[tspr->owner].mdcurframe;
|
||||
spritesmooth[tspr->owner].mdcurframe = m->cframe;
|
||||
}
|
||||
}
|
||||
else if (r_animsmoothing && (spriteext[tspr->owner].mdcurframe != m->cframe))
|
||||
else if (r_animsmoothing && (tile2model[tspr->picnum].smoothduration != 0) && (spritesmooth[tspr->owner].mdcurframe != m->cframe))
|
||||
{
|
||||
spriteext[tspr->owner].mdanimtims = mdtims;
|
||||
m->interpol = 0;
|
||||
spriteext[tspr->owner].mdsmooth = 1;
|
||||
spriteext[tspr->owner].mdoldframe = spriteext[tspr->owner].mdcurframe;
|
||||
spriteext[tspr->owner].mdcurframe = m->cframe;
|
||||
spritesmooth[tspr->owner].mdsmooth = 1;
|
||||
spritesmooth[tspr->owner].mdoldframe = spritesmooth[tspr->owner].mdcurframe;
|
||||
spritesmooth[tspr->owner].mdcurframe = m->cframe;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -911,33 +914,33 @@ static void updateanimation (md2model *m, spritetype *tspr)
|
|||
if (anim && ((long)spriteext[tspr->owner].mdanimcur) != anim->startframe ||
|
||||
(spriteext[tspr->owner].flags & SPREXT_NOMDANIM))
|
||||
{
|
||||
if (spriteext[tspr->owner].flags & SPREXT_NOMDANIM) OSD_Printf("SPREXT_NOMDANIM\n");
|
||||
OSD_Printf("smooth launched ! oldanim %i new anim %i\n", spriteext[tspr->owner].mdanimcur, anim->startframe);
|
||||
//if (spriteext[tspr->owner].flags & SPREXT_NOMDANIM) OSD_Printf("SPREXT_NOMDANIM\n");
|
||||
//OSD_Printf("smooth launched ! oldanim %i new anim %i\n", spriteext[tspr->owner].mdanimcur, anim->startframe);
|
||||
spriteext[tspr->owner].mdanimcur = (short)anim->startframe;
|
||||
spriteext[tspr->owner].mdanimtims = mdtims;
|
||||
m->interpol = 0;
|
||||
if (!r_animsmoothing)
|
||||
if (!r_animsmoothing || (tile2model[tspr->picnum].smoothduration == 0))
|
||||
{
|
||||
m->cframe = m->nframe = anim->startframe;
|
||||
return;
|
||||
}
|
||||
m->nframe = anim->startframe;
|
||||
m->cframe = spriteext[tspr->owner].mdoldframe;
|
||||
spriteext[tspr->owner].mdsmooth = 1;
|
||||
m->cframe = spritesmooth[tspr->owner].mdoldframe;
|
||||
spritesmooth[tspr->owner].mdsmooth = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
if (spriteext[tspr->owner].mdsmooth)
|
||||
fps = ((anim) ? anim->fpssc : 1500) / r_animsmoothing;
|
||||
if (spritesmooth[tspr->owner].mdsmooth)
|
||||
fps = (1.0f / (float)(tile2model[tspr->picnum].smoothduration)) * 66;
|
||||
else
|
||||
fps = anim->fpssc;
|
||||
|
||||
i = (mdtims-spriteext[tspr->owner].mdanimtims)*((fps*timerticspersec)/120);
|
||||
|
||||
if (anim)
|
||||
j = ((anim->endframe+1-anim->startframe)<<16);
|
||||
if (spritesmooth[tspr->owner].mdsmooth)
|
||||
j = 65536;
|
||||
else
|
||||
j = 65535;
|
||||
j = ((anim->endframe+1-anim->startframe)<<16);
|
||||
//Just in case you play the game for a VERY long time...
|
||||
if (i < 0) { i = 0; spriteext[tspr->owner].mdanimtims = mdtims; }
|
||||
//compare with j*2 instead of j to ensure i stays > j-65536 for MDANIM_ONESHOT
|
||||
|
@ -950,18 +953,18 @@ static void updateanimation (md2model *m, spritetype *tspr)
|
|||
{ if (i > j-65536) i = j-65536; }
|
||||
else { if (i >= j) { i -= j; if (i >= j) i %= j; } }
|
||||
|
||||
if (r_animsmoothing && spriteext[tspr->owner].mdsmooth)
|
||||
if (r_animsmoothing && spritesmooth[tspr->owner].mdsmooth)
|
||||
{
|
||||
m->nframe = (anim) ? anim->startframe : spriteext[tspr->owner].mdcurframe;
|
||||
m->cframe = spriteext[tspr->owner].mdoldframe;
|
||||
m->nframe = (anim) ? anim->startframe : spritesmooth[tspr->owner].mdcurframe;
|
||||
m->cframe = spritesmooth[tspr->owner].mdoldframe;
|
||||
//OSD_Printf("smoothing... cframe %i nframe %i\n", m->cframe, m->nframe);
|
||||
if (k > 65535)
|
||||
{
|
||||
spriteext[tspr->owner].mdanimtims = mdtims;
|
||||
m->interpol = 0;
|
||||
spriteext[tspr->owner].mdsmooth = 0;
|
||||
m->cframe = m->nframe = (anim) ? anim->startframe : spriteext[tspr->owner].mdcurframe;
|
||||
spriteext[tspr->owner].mdoldframe = m->cframe;
|
||||
spritesmooth[tspr->owner].mdsmooth = 0;
|
||||
m->cframe = m->nframe = (anim) ? anim->startframe : spritesmooth[tspr->owner].mdcurframe;
|
||||
spritesmooth[tspr->owner].mdoldframe = m->cframe;
|
||||
//OSD_Printf("smooth stopped !\n");
|
||||
return;
|
||||
}
|
||||
|
@ -970,7 +973,7 @@ else { if (i >= j) { i -= j; if (i >= j) i %= j; } }
|
|||
{
|
||||
m->cframe = (i>>16)+anim->startframe;
|
||||
m->nframe = m->cframe+1; if (m->nframe > anim->endframe) m->nframe = anim->startframe;
|
||||
spriteext[tspr->owner].mdoldframe = m->cframe;
|
||||
spritesmooth[tspr->owner].mdoldframe = m->cframe;
|
||||
//OSD_Printf("not smoothing... cframe %i nframe %i\n", m->cframe, m->nframe);
|
||||
}
|
||||
m->interpol = ((float)(i&65535))/65536.f;
|
||||
|
|
|
@ -5379,8 +5379,7 @@ static int osdcmd_polymostvars(const osdfuncparm_t *parm)
|
|||
}
|
||||
else if (!Bstrcasecmp(parm->name, "r_animsmoothing")) {
|
||||
if (showval) { OSD_Printf("r_animsmoothing is %d\n", r_animsmoothing); }
|
||||
else if (val < 0) { OSD_Printf("Value out of range.\n"); }
|
||||
else r_animsmoothing = val;
|
||||
else r_animsmoothing = (val != 0);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
else if (!Bstrcasecmp(parm->name, "glpolygonmode")) {
|
||||
|
|
Loading…
Reference in a new issue