From 1f7bc6d69ee88b7ba04282b59bc8d91a2663a1a7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 11 Sep 2020 22:54:52 +0200 Subject: [PATCH] - interpolation fix from EDuke: "Patch from Striker to improve sprite interpolation" Fixes #109 --- source/games/duke/src/actors.cpp | 31 ++++++++++++++++++++++ source/games/duke/src/actors_d.cpp | 1 + source/games/duke/src/actors_r.cpp | 1 + source/games/duke/src/animatesprites_d.cpp | 5 ++-- source/games/duke/src/animatesprites_r.cpp | 3 +-- source/games/duke/src/funct.h | 1 + 6 files changed, 37 insertions(+), 5 deletions(-) diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index c59123564..77e1b2a4d 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -5080,6 +5080,12 @@ void fall_common(int g_i, int g_p, int JIBS6, int DRONE, int BLOODPOOL, int SHOT } } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + int LocateTheLocator(int n, int sn) { int i; @@ -5094,6 +5100,31 @@ int LocateTheLocator(int n, int sn) return -1; } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void recordoldspritepos() +{ + + for (int statNum = 0; statNum < MAXSTATUS; statNum++) + { + int spriteNum = headspritestat[statNum]; + + while (spriteNum >= 0) + { + int const nextSprite = nextspritestat[spriteNum]; + hittype[spriteNum].bposx = sprite[spriteNum].x; + hittype[spriteNum].bposy = sprite[spriteNum].y; + hittype[spriteNum].bposz = sprite[spriteNum].z; + + spriteNum = nextSprite; + } + } +} + END_DUKE_NS diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 2045325d4..15495575e 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -4388,6 +4388,7 @@ void think_d(void) { thinktime.Reset(); thinktime.Clock(); + recordoldspritepos(); movefta_d(); //ST 2 moveweapons_d(); //ST 4 diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index c13cef900..25f2de03e 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -4681,6 +4681,7 @@ void think_r(void) { thinktime.Reset(); thinktime.Clock(); + recordoldspritepos(); movefta_r(); //ST 2 moveweapons_r(); //ST 4 diff --git a/source/games/duke/src/animatesprites_d.cpp b/source/games/duke/src/animatesprites_d.cpp index 379fb4a28..d463481fa 100644 --- a/source/games/duke/src/animatesprites_d.cpp +++ b/source/games/duke/src/animatesprites_d.cpp @@ -60,7 +60,7 @@ void animatesprites_d(int x,int y,int a,int smoothratio) { case DEVELOPERCOMMENTARY: case DEVELOPERCOMMENTARY + 1: - if(!isWorldTour() || !dukewt_commentary) + if(isWorldTour() && !dukewt_commentary) t->xrepeat = t->yrepeat = 0; break; case BLOODPOOL: @@ -175,8 +175,7 @@ void animatesprites_d(int x,int y,int a,int smoothratio) t->z = ps[s->yvel].oposz + mulscale16(smoothratio,ps[s->yvel].posz-ps[s->yvel].oposz); t->z += (40<<8); } - else if( ( s->statnum == STAT_DEFAULT && s->picnum != CRANEPOLE) || s->statnum == STAT_PLAYER || - s->statnum == STAT_STANDABLE || s->statnum == STAT_PROJECTILE || s->statnum == STAT_MISC || s->statnum == STAT_ACTOR ) + else if(s->picnum != CRANEPOLE) { t->x -= mulscale16(MaxSmoothRatio-smoothratio,s->x-hittype[i].bposx); t->y -= mulscale16(MaxSmoothRatio-smoothratio,s->y-hittype[i].bposy); diff --git a/source/games/duke/src/animatesprites_r.cpp b/source/games/duke/src/animatesprites_r.cpp index c1645ca21..a0cc0acfb 100644 --- a/source/games/duke/src/animatesprites_r.cpp +++ b/source/games/duke/src/animatesprites_r.cpp @@ -162,8 +162,7 @@ void animatesprites_r(int x,int y,int a,int smoothratio) s->xrepeat = 24; s->yrepeat = 17; } - else if ((s->statnum == STAT_DEFAULT && s->picnum != CRANEPOLE) || s->statnum == STAT_PLAYER || - s->statnum == STAT_STANDABLE || s->statnum == STAT_PROJECTILE || s->statnum == STAT_MISC || s->statnum == STAT_ACTOR) + else if (s->picnum != CRANEPOLE) { t->x -= mulscale16(MaxSmoothRatio-smoothratio,s->x-hittype[i].bposx); t->y -= mulscale16(MaxSmoothRatio-smoothratio,s->y-hittype[i].bposy); diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index 691a89360..23b0767fa 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -232,6 +232,7 @@ void calcviewpitch(player_struct* p, double factor); void sethorizon(int snum, ESyncBits actions, double factor, fixed_t adjustment); bool movementBlocked(int snum); void loadcons(); +void recordoldspritepos(); void updateinterpolations(); void restoreinterpolations();