From 6a4add81bd1806ff6ee275cfb67972d4abf37c9b Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sun, 23 Dec 2012 19:24:21 +0000 Subject: [PATCH] Fix rotation-fixed useractors (those having usertype bit 4 set). Rotation-fixing happens for a couple of hard-coded statnums that presumably never move (DEFAULT, STANDABLE, FX, FALLER, LIGHT), but for actors it wouldn't make sense since the common case is that they do move. For this reason, bit 4 was introduced in r1934. The position of such useractors will not diverge due to error roundoff accumulation in rotating sectors (SE0, train). git-svn-id: https://svn.eduke32.com/eduke32@3316 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/actors.c | 14 +++++++------- polymer/eduke32/source/actors.h | 3 +++ polymer/eduke32/source/duke3d.h | 3 ++- polymer/eduke32/source/gamedef.c | 3 +++ polymer/eduke32/source/premap.c | 6 +++--- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/polymer/eduke32/source/actors.c b/polymer/eduke32/source/actors.c index 7956fe0bd..d7d7e5d9e 100644 --- a/polymer/eduke32/source/actors.c +++ b/polymer/eduke32/source/actors.c @@ -632,12 +632,12 @@ void Sect_ClearInterpolation(int32_t sectnum) } } -static int32_t move_fixed_sprite(int32_t j, int32_t pivotspr, int32_t daang) +static int32_t move_rotfixed_sprite(int32_t j, int32_t pivotspr, int32_t daang) { - if ((FIXSPR_STATNUMP(sprite[j].statnum) || + if ((ROTFIXSPR_STATNUMP(sprite[j].statnum) || ((sprite[j].statnum==STAT_ACTOR || sprite[j].statnum==STAT_ZOMBIEACTOR) && - A_CheckSpriteTileFlags(sprite[j].picnum, SPRITE_BADGUY))) - && actor[j].t_data[7]==(0x18190000|pivotspr)) + A_CheckSpriteTileFlags(sprite[j].picnum, SPRITE_ROTFIXED))) + && actor[j].t_data[7]==(ROTFIXSPR_MAGIC|pivotspr)) { rotatepoint(0,0, actor[j].t_data[8],actor[j].t_data[9], daang&2047, &sprite[j].x,&sprite[j].y); sprite[j].x += sprite[pivotspr].x; @@ -1440,7 +1440,7 @@ ACTOR_STATIC void G_MoveStandables(void) KILLIT(i); // 'fixed' sprites in rotating sectors already have bpos* updated - if ((t[7]&(0xffff0000))!=0x18190000) + if ((t[7]&(0xffff0000))!=ROTFIXSPR_MAGIC) Bmemcpy(&actor[i].bpos.x, s, sizeof(vec3_t)); IFWITHIN(CRANE,CRANE+3) @@ -5685,7 +5685,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 actor[p].bpos.x = sprite[p].x; actor[p].bpos.y = sprite[p].y; - if (move_fixed_sprite(p, j, t[2])) + if (move_rotfixed_sprite(p, j, t[2])) rotatepoint(sprite[j].x,sprite[j].y,sprite[p].x,sprite[p].y,(q*l),&sprite[p].x,&sprite[p].y); } } @@ -5913,7 +5913,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 actor[j].bpos.y = sprite[j].y; } - if (move_fixed_sprite(j, s-sprite, t[2])) + if (move_rotfixed_sprite(j, s-sprite, t[2])) rotatepoint(s->x,s->y,sprite[j].x,sprite[j].y,q,&sprite[j].x,&sprite[j].y); sprite[j].x+= m; diff --git a/polymer/eduke32/source/actors.h b/polymer/eduke32/source/actors.h index 1956a6ef4..b8fffa13d 100644 --- a/polymer/eduke32/source/actors.h +++ b/polymer/eduke32/source/actors.h @@ -209,6 +209,9 @@ enum sflags_t { SPRITE_NOTELEPORT = 0x00004000, SPRITE_BADGUYSTAYPUT = 0x00008000, SPRITE_CACHE = 0x00010000, + // rotation-fixed wrt a pivot point to prevent position diverging due to + // roundoff error accumulation: + SPRITE_ROTFIXED = 0x00020000, }; // custom projectiles diff --git a/polymer/eduke32/source/duke3d.h b/polymer/eduke32/source/duke3d.h index 96b1ec8a6..c81662135 100644 --- a/polymer/eduke32/source/duke3d.h +++ b/polymer/eduke32/source/duke3d.h @@ -98,8 +98,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define TILE_VIEWSCR (MAXTILES-5) // sprites with these statnums should be considered for fixing (bitmap) -#define FIXSPR_STATNUMP(k) ((k)==STAT_DEFAULT || (k)==STAT_STANDABLE || (k)==STAT_FX || \ +#define ROTFIXSPR_STATNUMP(k) ((k)==STAT_DEFAULT || (k)==STAT_STANDABLE || (k)==STAT_FX || \ (k)==STAT_FALLER || (k)==STAT_LIGHT) +#define ROTFIXSPR_MAGIC 0x18190000 // JBF 20040604: sync is a function on some platforms #define sync dsync diff --git a/polymer/eduke32/source/gamedef.c b/polymer/eduke32/source/gamedef.c index 0d2cccbc9..faacc7dae 100644 --- a/polymer/eduke32/source/gamedef.c +++ b/polymer/eduke32/source/gamedef.c @@ -2771,6 +2771,9 @@ static int32_t C_ParseCommand(int32_t loop) if (j & 2) g_tile[*g_scriptPtr].flags |= (SPRITE_BADGUY|SPRITE_BADGUYSTAYPUT); + + if (j & 4) + g_tile[*g_scriptPtr].flags |= SPRITE_ROTFIXED; } for (j=0; j<4; j++) diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index 95e72a797..b4ce013a3 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -1003,9 +1003,9 @@ static void premap_setup_fixed_sprites(void) { // TRIPBOMB uses t_data[7] for its own purposes. Wouldn't be // too useful with moving sectors anyway - if ((FIXSPR_STATNUMP(sprite[j].statnum) && sprite[j].picnum!=TRIPBOMB) || + if ((ROTFIXSPR_STATNUMP(sprite[j].statnum) && sprite[j].picnum!=TRIPBOMB) || ((sprite[j].statnum==STAT_ACTOR || sprite[j].statnum==STAT_ZOMBIEACTOR) && - A_CheckSpriteTileFlags(sprite[j].picnum, SPRITE_BADGUY))) + A_CheckSpriteTileFlags(sprite[j].picnum, SPRITE_ROTFIXED))) { pivot = i; if (sprite[i].lotag==0) @@ -1013,7 +1013,7 @@ static void premap_setup_fixed_sprites(void) if (j!=i && j!=pivot && pivot>=0 && pivot