From 4c9569c2544a8464bf542190a323a2487b66cde3 Mon Sep 17 00:00:00 2001 From: Shpoike Date: Wed, 24 Jun 2020 02:57:44 +0100 Subject: [PATCH] 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. --- Quake/cl_parse.c | 9 ++++++--- Quake/gl_mesh.c | 1 + Quake/gl_model.h | 2 +- Quake/modelgen.h | 2 +- Quake/r_alias.c | 7 +++++-- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Quake/cl_parse.c b/Quake/cl_parse.c index 99f788de..57303a10 100644 --- a/Quake/cl_parse.c +++ b/Quake/cl_parse.c @@ -554,8 +554,6 @@ static void CL_EntitiesDeltaed(void) ent->msgtime = cl.mtime[0]; - ent->frame = ent->netstate.frame; - i = ent->netstate.colormap; if (!i) ent->colormap = vid.colormap; @@ -611,7 +609,9 @@ static void CL_EntitiesDeltaed(void) // or randomized 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; else 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 } + else if (model && model->synctype == ST_FRAMETIME && ent->frame != ent->netstate.frame) + ent->syncbase = -cl.time; + ent->frame = ent->netstate.frame; if ( forcelink ) { // didn't have an update last message diff --git a/Quake/gl_mesh.c b/Quake/gl_mesh.c index 58981db7..06ea77b7 100644 --- a/Quake/gl_mesh.c +++ b/Quake/gl_mesh.c @@ -1285,6 +1285,7 @@ void Mod_LoadIQMModel (qmodel_t *mod, const void *buffer) 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_CalcAliasBounds (outhdr); //johnfitz diff --git a/Quake/gl_model.h b/Quake/gl_model.h index 312143c0..992d1207 100644 --- a/Quake/gl_model.h +++ b/Quake/gl_model.h @@ -357,7 +357,7 @@ typedef struct { int numverts; int numtris; int numframes; - synctype_t synctype; +// synctype_t synctype; int flags; float size; diff --git a/Quake/modelgen.h b/Quake/modelgen.h index 92dbcf4c..dbba7bd3 100644 --- a/Quake/modelgen.h +++ b/Quake/modelgen.h @@ -54,7 +54,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // must match definition in spritegn.h #ifndef 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 typedef enum { ALIAS_SINGLE=0, ALIAS_GROUP } aliasframetype_t; diff --git a/Quake/r_alias.c b/Quake/r_alias.c index 121bc55b..1f4e1367 100644 --- a/Quake/r_alias.c +++ b/Quake/r_alias.c @@ -746,8 +746,11 @@ void R_SetupAliasFrame (aliashdr_t *paliashdr, int frame, lerpdata_t *lerpdata) if (numposes > 1) { - e->lerptime = paliashdr->frames[frame].interval; - posenum += (int)(cl.time / e->lerptime) % numposes; + float time = cl.time + e->syncbase; //Spike: Readded syncbase + 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 e->lerptime = 0.1;