Try to make IQM animations sync to when the frame is changed (like FTE or DP) so that the animations can actually be used for non-static things. There are still no 4-way blends, however.

This commit is contained in:
Shpoike 2020-06-24 02:57:44 +01:00
parent 0f39ae9565
commit 4c9569c254
5 changed files with 14 additions and 7 deletions

View file

@ -554,8 +554,6 @@ static void CL_EntitiesDeltaed(void)
ent->msgtime = cl.mtime[0]; ent->msgtime = cl.mtime[0];
ent->frame = ent->netstate.frame;
i = ent->netstate.colormap; i = ent->netstate.colormap;
if (!i) if (!i)
ent->colormap = vid.colormap; ent->colormap = vid.colormap;
@ -611,7 +609,9 @@ static void CL_EntitiesDeltaed(void)
// or randomized // or randomized
if (model) if (model)
{ {
if (model->synctype == ST_RAND) if (model->synctype == ST_FRAMETIME)
ent->syncbase = -cl.time;
else if (model->synctype == ST_RAND)
ent->syncbase = (float)(rand()&0x7fff) / 0x7fff; ent->syncbase = (float)(rand()&0x7fff) / 0x7fff;
else else
ent->syncbase = 0.0; ent->syncbase = 0.0;
@ -623,6 +623,9 @@ static void CL_EntitiesDeltaed(void)
ent->lerpflags |= LERP_RESETANIM; //johnfitz -- don't lerp animation across model changes ent->lerpflags |= LERP_RESETANIM; //johnfitz -- don't lerp animation across model changes
} }
else if (model && model->synctype == ST_FRAMETIME && ent->frame != ent->netstate.frame)
ent->syncbase = -cl.time;
ent->frame = ent->netstate.frame;
if ( forcelink ) if ( forcelink )
{ // didn't have an update last message { // didn't have an update last message

View file

@ -1285,6 +1285,7 @@ void Mod_LoadIQMModel (qmodel_t *mod, const void *buffer)
mod->flags = LittleLong (pinheader->flags); mod->flags = LittleLong (pinheader->flags);
mod->synctype = ST_FRAMETIME; //keep IQM animations synced to when .frame is changed. framegroups are otherwise not very useful.
mod->type = mod_alias; mod->type = mod_alias;
Mod_CalcAliasBounds (outhdr); //johnfitz Mod_CalcAliasBounds (outhdr); //johnfitz

View file

@ -357,7 +357,7 @@ typedef struct {
int numverts; int numverts;
int numtris; int numtris;
int numframes; int numframes;
synctype_t synctype; // synctype_t synctype;
int flags; int flags;
float size; float size;

View file

@ -54,7 +54,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// must match definition in spritegn.h // must match definition in spritegn.h
#ifndef SYNCTYPE_T #ifndef SYNCTYPE_T
#define SYNCTYPE_T #define SYNCTYPE_T
typedef enum {ST_SYNC=0, ST_RAND } synctype_t; typedef enum {ST_SYNC=0, ST_RAND, ST_FRAMETIME/*sync to when .frame changes*/ } synctype_t;
#endif #endif
typedef enum { ALIAS_SINGLE=0, ALIAS_GROUP } aliasframetype_t; typedef enum { ALIAS_SINGLE=0, ALIAS_GROUP } aliasframetype_t;

View file

@ -746,8 +746,11 @@ void R_SetupAliasFrame (aliashdr_t *paliashdr, int frame, lerpdata_t *lerpdata)
if (numposes > 1) if (numposes > 1)
{ {
e->lerptime = paliashdr->frames[frame].interval; float time = cl.time + e->syncbase; //Spike: Readded syncbase
posenum += (int)(cl.time / e->lerptime) % numposes; if (time < 0)
time = 0; //just in case...
e->lerptime = paliashdr->frames[frame].interval; //FIXME: no per-frame intervals
posenum += (int)(time / e->lerptime) % numposes;
} }
else else
e->lerptime = 0.1; e->lerptime = 0.1;