mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 07:11:39 +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 {
|
typedef struct BPACK {
|
||||||
unsigned long mdanimtims;
|
unsigned long mdanimtims;
|
||||||
short mdanimcur;
|
short mdanimcur;
|
||||||
short mdcurframe, mdoldframe;
|
|
||||||
short mdsmooth;
|
|
||||||
short angoff;
|
short angoff;
|
||||||
short pitch, roll;
|
short pitch, roll;
|
||||||
long xoff, yoff, zoff;
|
long xoff, yoff, zoff;
|
||||||
unsigned char flags;
|
unsigned char flags;
|
||||||
char filler[3];
|
char filler[3];
|
||||||
} spriteexttype;
|
} spriteexttype;
|
||||||
|
|
||||||
|
typedef struct BPACK {
|
||||||
|
short mdcurframe, mdoldframe;
|
||||||
|
short mdsmooth;
|
||||||
|
float smoothduration;
|
||||||
|
} spritesmoothtype;
|
||||||
|
|
||||||
#define SPREXT_NOTMD 1
|
#define SPREXT_NOTMD 1
|
||||||
#define SPREXT_NOMDANIM 2
|
#define SPREXT_NOMDANIM 2
|
||||||
EXTERN spriteexttype spriteext[MAXSPRITES+MAXUNIQHUDID];
|
EXTERN spriteexttype spriteext[MAXSPRITES+MAXUNIQHUDID];
|
||||||
|
EXTERN spritesmoothtype spritesmooth[MAXSPRITES+MAXUNIQHUDID];
|
||||||
EXTERN long guniqhudid;
|
EXTERN long guniqhudid;
|
||||||
|
|
||||||
EXTERN sectortype sector[MAXSECTORS];
|
EXTERN sectortype sector[MAXSECTORS];
|
||||||
|
@ -517,7 +523,7 @@ int hicclearsubst(long picnum, long palnum);
|
||||||
int md_loadmodel(const char *fn);
|
int md_loadmodel(const char *fn);
|
||||||
int md_setmisc(int modelid, float scale, int shadeoff, float zadd);
|
int md_setmisc(int modelid, float scale, int shadeoff, float zadd);
|
||||||
int md_tilehasmodel(int tilenume);
|
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_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_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);
|
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_SCALE,
|
||||||
T_SHADE,
|
T_SHADE,
|
||||||
T_FRAME,
|
T_FRAME,
|
||||||
|
T_SMOOTHDURATION,
|
||||||
T_ANIM,
|
T_ANIM,
|
||||||
T_SKIN,
|
T_SKIN,
|
||||||
T_SURF,
|
T_SURF,
|
||||||
|
@ -132,6 +133,7 @@ static tokenlist modelframetokens[] = {
|
||||||
{ "tile", T_TILE },
|
{ "tile", T_TILE },
|
||||||
{ "tile0", T_TILE0 },
|
{ "tile0", T_TILE0 },
|
||||||
{ "tile1", T_TILE1 },
|
{ "tile1", T_TILE1 },
|
||||||
|
{ "smoothduration", T_SMOOTHDURATION },
|
||||||
};
|
};
|
||||||
|
|
||||||
static tokenlist modelanimtokens[] = {
|
static tokenlist modelanimtokens[] = {
|
||||||
|
@ -534,7 +536,7 @@ static int defsparser(scriptfile *script)
|
||||||
}
|
}
|
||||||
#if defined(POLYMOST) && defined(USE_OPENGL)
|
#if defined(POLYMOST) && defined(USE_OPENGL)
|
||||||
for (tilex = ftilenume; tilex <= ltilenume && happy; tilex++) {
|
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:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case -1:
|
case -1:
|
||||||
|
@ -730,6 +732,7 @@ static int defsparser(scriptfile *script)
|
||||||
char *frametokptr = script->ltextptr;
|
char *frametokptr = script->ltextptr;
|
||||||
char *frameend, *framename = 0, happy=1;
|
char *frameend, *framename = 0, happy=1;
|
||||||
int ftilenume = -1, ltilenume = -1, tilex = 0;
|
int ftilenume = -1, ltilenume = -1, tilex = 0;
|
||||||
|
double smoothduration = 0.0f;
|
||||||
|
|
||||||
if (scriptfile_getbraces(script,&frameend)) break;
|
if (scriptfile_getbraces(script,&frameend)) break;
|
||||||
while (script->textptr < frameend) {
|
while (script->textptr < frameend) {
|
||||||
|
@ -742,6 +745,8 @@ static int defsparser(scriptfile *script)
|
||||||
scriptfile_getsymbol(script,&ftilenume); break; //first tile number
|
scriptfile_getsymbol(script,&ftilenume); break; //first tile number
|
||||||
case T_TILE1:
|
case T_TILE1:
|
||||||
scriptfile_getsymbol(script,<ilenume); break; //last tile number (inclusive)
|
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)
|
#if defined(POLYMOST) && defined(USE_OPENGL)
|
||||||
for (tilex = ftilenume; tilex <= ltilenume && happy; tilex++) {
|
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:
|
case 0:
|
||||||
break;
|
break;
|
||||||
case -1:
|
case -1:
|
||||||
|
|
|
@ -6655,6 +6655,7 @@ long loadboard(char *filename, char fromwhere, long *daposx, long *daposy, long
|
||||||
|
|
||||||
#if defined(POLYMOST) && defined(USE_OPENGL)
|
#if defined(POLYMOST) && defined(USE_OPENGL)
|
||||||
memset(spriteext, 0, sizeof(spriteext));
|
memset(spriteext, 0, sizeof(spriteext));
|
||||||
|
memset(spritesmooth, 0, sizeof(spritesmooth));
|
||||||
|
|
||||||
if (rendmode == 4)
|
if (rendmode == 4)
|
||||||
polymer_loadboard();
|
polymer_loadboard();
|
||||||
|
@ -7125,6 +7126,7 @@ if (numsprites > MAXSPRITES) { kclose(fil); return(-1); }
|
||||||
|
|
||||||
#if defined(POLYMOST) && defined(USE_OPENGL)
|
#if defined(POLYMOST) && defined(USE_OPENGL)
|
||||||
memset(spriteext, 0, sizeof(spriteext));
|
memset(spriteext, 0, sizeof(spriteext));
|
||||||
|
memset(spritesmooth, 0, sizeof(spritesmooth));
|
||||||
#endif
|
#endif
|
||||||
guniqhudid = 0;
|
guniqhudid = 0;
|
||||||
|
|
||||||
|
@ -7175,6 +7177,7 @@ long loadmaphack(char *filename)
|
||||||
if (!script) return -1;
|
if (!script) return -1;
|
||||||
|
|
||||||
memset(spriteext, 0, sizeof(spriteext));
|
memset(spriteext, 0, sizeof(spriteext));
|
||||||
|
memset(spritesmooth, 0, sizeof(spritesmooth));
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
tok = scriptfile_gettoken(script);
|
tok = scriptfile_gettoken(script);
|
||||||
|
|
|
@ -183,6 +183,7 @@ typedef struct
|
||||||
int modelid;
|
int modelid;
|
||||||
int skinnum;
|
int skinnum;
|
||||||
int framenum; // calculate the number from the name when declaring
|
int framenum; // calculate the number from the name when declaring
|
||||||
|
float smoothduration;
|
||||||
} tile2model_t;
|
} tile2model_t;
|
||||||
static tile2model_t tile2model[MAXTILES];
|
static tile2model_t tile2model[MAXTILES];
|
||||||
|
|
||||||
|
@ -357,7 +358,7 @@ static long framename2index (mdmodel *vm, const char *nam)
|
||||||
return(i);
|
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;
|
void *vm;
|
||||||
md2model *m;
|
md2model *m;
|
||||||
|
@ -382,6 +383,7 @@ int md_defineframe (int modelid, const char *framename, int tilenume, int skinnu
|
||||||
tile2model[tilenume].modelid = modelid;
|
tile2model[tilenume].modelid = modelid;
|
||||||
tile2model[tilenume].framenum = i;
|
tile2model[tilenume].framenum = i;
|
||||||
tile2model[tilenume].skinnum = skinnum;
|
tile2model[tilenume].skinnum = skinnum;
|
||||||
|
tile2model[tilenume].smoothduration = smoothduration;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -865,6 +867,7 @@ static void updateanimation (md2model *m, spritetype *tspr)
|
||||||
{
|
{
|
||||||
// spriteext[tspr->owner].mdanimtims = mdtims;
|
// spriteext[tspr->owner].mdanimtims = mdtims;
|
||||||
m->interpol = 0;
|
m->interpol = 0;
|
||||||
|
spriteext[tspr->owner].mdanimtims = mdtims;
|
||||||
m->nframe = m->cframe;
|
m->nframe = m->cframe;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -875,31 +878,31 @@ static void updateanimation (md2model *m, spritetype *tspr)
|
||||||
anim && anim->startframe != m->cframe;
|
anim && anim->startframe != m->cframe;
|
||||||
anim = anim->next) ;
|
anim = anim->next) ;
|
||||||
if (!anim) {
|
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;
|
spriteext[tspr->owner].mdanimtims = mdtims;
|
||||||
m->interpol = 0;
|
m->interpol = 0;
|
||||||
spriteext[tspr->owner].mdsmooth = 1;
|
spritesmooth[tspr->owner].mdsmooth = 1;
|
||||||
spriteext[tspr->owner].mdcurframe = m->cframe;
|
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;
|
spriteext[tspr->owner].mdanimtims = mdtims;
|
||||||
m->interpol = 0;
|
m->interpol = 0;
|
||||||
spriteext[tspr->owner].mdsmooth = 1;
|
spritesmooth[tspr->owner].mdsmooth = 1;
|
||||||
spriteext[tspr->owner].mdoldframe = spriteext[tspr->owner].mdcurframe;
|
spritesmooth[tspr->owner].mdoldframe = spritesmooth[tspr->owner].mdcurframe;
|
||||||
spriteext[tspr->owner].mdcurframe = m->cframe;
|
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;
|
spriteext[tspr->owner].mdanimtims = mdtims;
|
||||||
m->interpol = 0;
|
m->interpol = 0;
|
||||||
spriteext[tspr->owner].mdsmooth = 1;
|
spritesmooth[tspr->owner].mdsmooth = 1;
|
||||||
spriteext[tspr->owner].mdoldframe = spriteext[tspr->owner].mdcurframe;
|
spritesmooth[tspr->owner].mdoldframe = spritesmooth[tspr->owner].mdcurframe;
|
||||||
spriteext[tspr->owner].mdcurframe = m->cframe;
|
spritesmooth[tspr->owner].mdcurframe = m->cframe;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -911,33 +914,33 @@ static void updateanimation (md2model *m, spritetype *tspr)
|
||||||
if (anim && ((long)spriteext[tspr->owner].mdanimcur) != anim->startframe ||
|
if (anim && ((long)spriteext[tspr->owner].mdanimcur) != anim->startframe ||
|
||||||
(spriteext[tspr->owner].flags & SPREXT_NOMDANIM))
|
(spriteext[tspr->owner].flags & SPREXT_NOMDANIM))
|
||||||
{
|
{
|
||||||
if (spriteext[tspr->owner].flags & SPREXT_NOMDANIM) OSD_Printf("SPREXT_NOMDANIM\n");
|
//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);
|
//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].mdanimcur = (short)anim->startframe;
|
||||||
spriteext[tspr->owner].mdanimtims = mdtims;
|
spriteext[tspr->owner].mdanimtims = mdtims;
|
||||||
m->interpol = 0;
|
m->interpol = 0;
|
||||||
if (!r_animsmoothing)
|
if (!r_animsmoothing || (tile2model[tspr->picnum].smoothduration == 0))
|
||||||
{
|
{
|
||||||
m->cframe = m->nframe = anim->startframe;
|
m->cframe = m->nframe = anim->startframe;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m->nframe = anim->startframe;
|
m->nframe = anim->startframe;
|
||||||
m->cframe = spriteext[tspr->owner].mdoldframe;
|
m->cframe = spritesmooth[tspr->owner].mdoldframe;
|
||||||
spriteext[tspr->owner].mdsmooth = 1;
|
spritesmooth[tspr->owner].mdsmooth = 1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spriteext[tspr->owner].mdsmooth)
|
if (spritesmooth[tspr->owner].mdsmooth)
|
||||||
fps = ((anim) ? anim->fpssc : 1500) / r_animsmoothing;
|
fps = (1.0f / (float)(tile2model[tspr->picnum].smoothduration)) * 66;
|
||||||
else
|
else
|
||||||
fps = anim->fpssc;
|
fps = anim->fpssc;
|
||||||
|
|
||||||
i = (mdtims-spriteext[tspr->owner].mdanimtims)*((fps*timerticspersec)/120);
|
i = (mdtims-spriteext[tspr->owner].mdanimtims)*((fps*timerticspersec)/120);
|
||||||
|
|
||||||
if (anim)
|
if (spritesmooth[tspr->owner].mdsmooth)
|
||||||
j = ((anim->endframe+1-anim->startframe)<<16);
|
j = 65536;
|
||||||
else
|
else
|
||||||
j = 65535;
|
j = ((anim->endframe+1-anim->startframe)<<16);
|
||||||
//Just in case you play the game for a VERY long time...
|
//Just in case you play the game for a VERY long time...
|
||||||
if (i < 0) { i = 0; spriteext[tspr->owner].mdanimtims = mdtims; }
|
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
|
//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; }
|
{ if (i > j-65536) i = j-65536; }
|
||||||
else { if (i >= j) { i -= j; if (i >= j) i %= j; } }
|
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->nframe = (anim) ? anim->startframe : spritesmooth[tspr->owner].mdcurframe;
|
||||||
m->cframe = spriteext[tspr->owner].mdoldframe;
|
m->cframe = spritesmooth[tspr->owner].mdoldframe;
|
||||||
//OSD_Printf("smoothing... cframe %i nframe %i\n", m->cframe, m->nframe);
|
//OSD_Printf("smoothing... cframe %i nframe %i\n", m->cframe, m->nframe);
|
||||||
if (k > 65535)
|
if (k > 65535)
|
||||||
{
|
{
|
||||||
spriteext[tspr->owner].mdanimtims = mdtims;
|
spriteext[tspr->owner].mdanimtims = mdtims;
|
||||||
m->interpol = 0;
|
m->interpol = 0;
|
||||||
spriteext[tspr->owner].mdsmooth = 0;
|
spritesmooth[tspr->owner].mdsmooth = 0;
|
||||||
m->cframe = m->nframe = (anim) ? anim->startframe : spriteext[tspr->owner].mdcurframe;
|
m->cframe = m->nframe = (anim) ? anim->startframe : spritesmooth[tspr->owner].mdcurframe;
|
||||||
spriteext[tspr->owner].mdoldframe = m->cframe;
|
spritesmooth[tspr->owner].mdoldframe = m->cframe;
|
||||||
//OSD_Printf("smooth stopped !\n");
|
//OSD_Printf("smooth stopped !\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -970,7 +973,7 @@ else { if (i >= j) { i -= j; if (i >= j) i %= j; } }
|
||||||
{
|
{
|
||||||
m->cframe = (i>>16)+anim->startframe;
|
m->cframe = (i>>16)+anim->startframe;
|
||||||
m->nframe = m->cframe+1; if (m->nframe > anim->endframe) m->nframe = 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);
|
//OSD_Printf("not smoothing... cframe %i nframe %i\n", m->cframe, m->nframe);
|
||||||
}
|
}
|
||||||
m->interpol = ((float)(i&65535))/65536.f;
|
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")) {
|
else if (!Bstrcasecmp(parm->name, "r_animsmoothing")) {
|
||||||
if (showval) { OSD_Printf("r_animsmoothing is %d\n", 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 != 0);
|
||||||
else r_animsmoothing = val;
|
|
||||||
return OSDCMD_OK;
|
return OSDCMD_OK;
|
||||||
}
|
}
|
||||||
else if (!Bstrcasecmp(parm->name, "glpolygonmode")) {
|
else if (!Bstrcasecmp(parm->name, "glpolygonmode")) {
|
||||||
|
|
Loading…
Reference in a new issue