mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-18 14:41:55 +00:00
- use actor pointers in animation system.
This commit is contained in:
parent
826b514571
commit
1152ec0b54
4 changed files with 62 additions and 88 deletions
|
@ -1831,38 +1831,6 @@ struct SECTOR_OBJECTstruct
|
|||
extern SECTOR_OBJECT SectorObject[MAX_SECTOR_OBJECTS];
|
||||
|
||||
|
||||
struct ANIMstruct
|
||||
{
|
||||
int animtype, index;
|
||||
int goal;
|
||||
int vel;
|
||||
short vel_adj;
|
||||
ANIM_CALLBACKp callback;
|
||||
SECTOR_OBJECTp callbackdata; // only gets used in one place for this so having a proper type makes serialization easier.
|
||||
|
||||
int& Addr()
|
||||
{
|
||||
switch (animtype)
|
||||
{
|
||||
case ANIM_Floorz:
|
||||
return sector[index].floorz;
|
||||
case ANIM_SopZ:
|
||||
return SectorObject[index].zmid;
|
||||
case ANIM_Spritez:
|
||||
return sprite[index].z;
|
||||
case ANIM_Userz:
|
||||
return User[index]->sz;
|
||||
case ANIM_SUdepth:
|
||||
return SectUser[index]->depth_fixed;
|
||||
default:
|
||||
return index;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
extern ANIM Anim[MAXANIM];
|
||||
extern short AnimCnt;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Prototypes
|
||||
|
@ -1941,9 +1909,9 @@ void PlayerUpdateKills(PLAYERp pp, short value);
|
|||
void RefreshInfoLine(PLAYERp pp);
|
||||
|
||||
void DoAnim(int numtics);
|
||||
void AnimDelete(int animtype, int animindex);
|
||||
short AnimGetGoal(int animtype, int animindex);
|
||||
short AnimSet(int animtype, int animindex, int thegoal, int thevel);
|
||||
void AnimDelete(int animtype, int animindex, DSWActor*);
|
||||
short AnimGetGoal(int animtype, int animindex, DSWActor*);
|
||||
short AnimSet(int animtype, int animindex, DSWActor* animactor, int thegoal, int thevel);
|
||||
short AnimSetCallback(short anim_ndx, ANIM_CALLBACKp call, SECTOR_OBJECTp data);
|
||||
short AnimSetVelAdj(short anim_ndx, short vel_adj);
|
||||
|
||||
|
@ -2300,6 +2268,39 @@ inline bool PLAYER_MOVING(PLAYERp pp)
|
|||
return (pp->xvect | pp->yvect);
|
||||
}
|
||||
|
||||
struct ANIMstruct
|
||||
{
|
||||
int animtype, animindex;
|
||||
int goal;
|
||||
int vel;
|
||||
short vel_adj;
|
||||
DSWActor* animactor;
|
||||
ANIM_CALLBACKp callback;
|
||||
SECTOR_OBJECTp callbackdata; // only gets used in one place for this so having a proper type makes serialization easier.
|
||||
|
||||
int& Addr()
|
||||
{
|
||||
switch (animtype)
|
||||
{
|
||||
case ANIM_Floorz:
|
||||
return sector[animindex].floorz;
|
||||
case ANIM_SopZ:
|
||||
return SectorObject[animindex].zmid;
|
||||
case ANIM_Spritez:
|
||||
return animactor->s().z;
|
||||
case ANIM_Userz:
|
||||
return animactor->u()->sz;
|
||||
case ANIM_SUdepth:
|
||||
return SectUser[animindex]->depth_fixed;
|
||||
default:
|
||||
return animindex;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
extern ANIM Anim[MAXANIM];
|
||||
extern short AnimCnt;
|
||||
|
||||
|
||||
END_SW_NS
|
||||
#endif
|
||||
|
|
|
@ -643,36 +643,8 @@ void
|
|||
DoSpringBoard(PLAYERp pp/*, short sectnum*/)
|
||||
{
|
||||
|
||||
#if 0
|
||||
int sb;
|
||||
int i;
|
||||
i = AnimGetGoal(§or[sectnum].floorz);
|
||||
|
||||
// if in motion return
|
||||
if (i >= 0)
|
||||
return;
|
||||
|
||||
AnimSet(§or[sectnum].floorz, sector[sectnum].floorz - Z(32), 512);
|
||||
|
||||
for (sb = 0; sb < SIZ(SpringBoard); sb++)
|
||||
{
|
||||
// if empty set up an entry to close the sb later
|
||||
if (SpringBoard[sb].Sector == -1)
|
||||
{
|
||||
pp->jump_speed = -sector[pp->cursectnum].hitag;
|
||||
DoPlayerBeginForceJump(pp);
|
||||
|
||||
SpringBoard[sb].Sector = sectnum;
|
||||
SpringBoard[sb].TimeOut = 1 * 120;
|
||||
|
||||
sector[sectnum].lotag = 0;
|
||||
}
|
||||
}
|
||||
#else
|
||||
pp->jump_speed = -sector[pp->cursectnum].hitag;
|
||||
DoPlayerBeginForceJump(pp);
|
||||
#endif
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -696,7 +668,7 @@ DoSpringBoardDown(void)
|
|||
|
||||
destz = sector[nextsectorneighborz(sbp->Sector, sector[sbp->Sector].floorz, 1, 1)].floorz;
|
||||
|
||||
AnimSet(ANIM_Floorz, sbp->Sector, destz, 256);
|
||||
AnimSet(ANIM_Floorz, sbp->Sector, nullptr, destz, 256);
|
||||
|
||||
sector[sbp->Sector].lotag = TAG_SPRING_BOARD;
|
||||
|
||||
|
@ -2871,14 +2843,14 @@ AnimClear(void)
|
|||
}
|
||||
|
||||
short
|
||||
AnimGetGoal(int animtype, int animindex)
|
||||
AnimGetGoal(int animtype, int animindex, DSWActor* animactor)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
j = -1;
|
||||
for (i = 0; i < AnimCnt; i++)
|
||||
{
|
||||
if (animtype == Anim[i].animtype && animindex == Anim[i].index)
|
||||
if (animtype == Anim[i].animtype && animindex == Anim[i].animindex && animactor == Anim[i].animactor )
|
||||
{
|
||||
j = i;
|
||||
break;
|
||||
|
@ -2889,14 +2861,14 @@ AnimGetGoal(int animtype, int animindex)
|
|||
}
|
||||
|
||||
void
|
||||
AnimDelete(int animtype, int animindex)
|
||||
AnimDelete(int animtype, int animindex, DSWActor* animactor)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
j = -1;
|
||||
for (i = 0; i < AnimCnt; i++)
|
||||
{
|
||||
if (animtype == Anim[i].animtype && animindex == Anim[i].index)
|
||||
if (animtype == Anim[i].animtype && animindex == Anim[i].animindex && animactor == Anim[i].animactor )
|
||||
{
|
||||
j = i;
|
||||
break;
|
||||
|
@ -2919,7 +2891,7 @@ AnimDelete(int animtype, int animindex)
|
|||
|
||||
|
||||
short
|
||||
AnimSet(int animtype, int animindex, fixed_t thegoal, int thevel)
|
||||
AnimSet(int animtype, int animindex, DSWActor* animactor, fixed_t thegoal, int thevel)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
|
@ -2930,7 +2902,7 @@ AnimSet(int animtype, int animindex, fixed_t thegoal, int thevel)
|
|||
// look for existing animation and reset it
|
||||
for (i = 0; i < AnimCnt; i++)
|
||||
{
|
||||
if (animtype == Anim[i].animtype && animindex == Anim[i].index)
|
||||
if (animtype == Anim[i].animtype && animindex == Anim[i].animindex && animactor == Anim[i].animactor )
|
||||
{
|
||||
j = i;
|
||||
break;
|
||||
|
@ -2938,7 +2910,8 @@ AnimSet(int animtype, int animindex, fixed_t thegoal, int thevel)
|
|||
}
|
||||
|
||||
Anim[j].animtype = animtype;
|
||||
Anim[j].index = animindex;
|
||||
Anim[j].animindex = animindex;
|
||||
Anim[j].animactor = animactor;
|
||||
Anim[j].goal = thegoal;
|
||||
Anim[j].vel = Z(thevel);
|
||||
Anim[j].vel_adj = 0;
|
||||
|
|
|
@ -659,8 +659,8 @@ void KillSprite(int16_t SpriteNum)
|
|||
|
||||
// for attached sprites that are getable make sure they don't have
|
||||
// any Anims attached
|
||||
AnimDelete(ANIM_Userz, SpriteNum);
|
||||
AnimDelete(ANIM_Spritez, SpriteNum);
|
||||
AnimDelete(ANIM_Userz, 0, actor);
|
||||
AnimDelete(ANIM_Spritez, 0, actor);
|
||||
StopInterpolation(SpriteNum, Interp_Sprite_Z);
|
||||
|
||||
//if (TEST(u->Flags2, SPR2_DONT_TARGET_OWNER))
|
||||
|
|
|
@ -2188,7 +2188,7 @@ MoveZ(SECTOR_OBJECTp sop)
|
|||
|
||||
if (TEST(sop->flags, SOBJ_MOVE_VERTICAL))
|
||||
{
|
||||
i = AnimGetGoal (ANIM_SopZ, int(sop - SectorObject));
|
||||
i = AnimGetGoal (ANIM_SopZ, int(sop - SectorObject), nullptr);
|
||||
if (i < 0)
|
||||
RESET(sop->flags, SOBJ_MOVE_VERTICAL);
|
||||
}
|
||||
|
@ -2203,7 +2203,7 @@ MoveZ(SECTOR_OBJECTp sop)
|
|||
{
|
||||
for (i = 0, sectp = &sop->sectp[0]; *sectp; sectp++, i++)
|
||||
{
|
||||
AnimSet(ANIM_Floorz, int(*sectp - sector), sop->zorig_floor[i] + sop->z_tgt, sop->z_rate);
|
||||
AnimSet(ANIM_Floorz, int(*sectp - sector), nullptr, sop->zorig_floor[i] + sop->z_tgt, sop->z_rate);
|
||||
}
|
||||
|
||||
RESET(sop->flags, SOBJ_ZDOWN);
|
||||
|
@ -2212,7 +2212,7 @@ MoveZ(SECTOR_OBJECTp sop)
|
|||
{
|
||||
for (i = 0, sectp = &sop->sectp[0]; *sectp; sectp++, i++)
|
||||
{
|
||||
AnimSet(ANIM_Floorz, int(*sectp - sector), sop->zorig_floor[i] + sop->z_tgt, sop->z_rate);
|
||||
AnimSet(ANIM_Floorz, int(*sectp - sector), nullptr, sop->zorig_floor[i] + sop->z_tgt, sop->z_rate);
|
||||
}
|
||||
|
||||
RESET(sop->flags, SOBJ_ZUP);
|
||||
|
@ -2247,7 +2247,7 @@ void CallbackSOsink(ANIMp ap, void *data)
|
|||
|
||||
for (i = 0; sop->sector[i] != -1; i++)
|
||||
{
|
||||
if (ap->animtype == ANIM_Floorz && ap->index == sop->sector[i])
|
||||
if (ap->animtype == ANIM_Floorz && ap->animindex == sop->sector[i])
|
||||
{
|
||||
dest_sector = sop->sector[i];
|
||||
break;
|
||||
|
@ -2275,7 +2275,7 @@ void CallbackSOsink(ANIMp ap, void *data)
|
|||
{
|
||||
if (sectnum == dest_sector)
|
||||
{
|
||||
ndx = AnimSet(ANIM_SUdepth, dest_sector, IntToFixed(tgt_depth), (ap->vel << 8) >> 8);
|
||||
ndx = AnimSet(ANIM_SUdepth, dest_sector, nullptr, IntToFixed(tgt_depth), (ap->vel << 8) >> 8);
|
||||
AnimSetVelAdj(ndx, ap->vel_adj);
|
||||
found = true;
|
||||
break;
|
||||
|
@ -2284,17 +2284,17 @@ void CallbackSOsink(ANIMp ap, void *data)
|
|||
|
||||
ASSERT(found);
|
||||
|
||||
SectIterator it(dest_sector);
|
||||
while ((i = it.NextIndex()) >= 0)
|
||||
SWSectIterator it(dest_sector);
|
||||
while (auto actor = it.Next())
|
||||
{
|
||||
sp = &sprite[i];
|
||||
u = User[i].Data();
|
||||
sp = &actor->s();
|
||||
u = actor->u();
|
||||
|
||||
if (!u || u->PlayerP || !TEST(u->Flags, SPR_SO_ATTACHED))
|
||||
continue;
|
||||
|
||||
// move sprite WAY down in water
|
||||
ndx = AnimSet(ANIM_Userz, i, -u->sz - SPRITEp_SIZE_Z(sp) - Z(100), ap->vel>>8);
|
||||
ndx = AnimSet(ANIM_Userz, 0, actor, -u->sz - SPRITEp_SIZE_Z(sp) - Z(100), ap->vel>>8);
|
||||
AnimSetVelAdj(ndx, ap->vel_adj);
|
||||
}
|
||||
|
||||
|
@ -2551,7 +2551,7 @@ void DoTrack(SECTOR_OBJECTp sop, short locktics, int *nx, int *ny)
|
|||
if (SectUser[sop->sector[i]].Data() && TEST(SectUser[sop->sector[i]]->flags, SECTFU_SO_DONT_SINK))
|
||||
continue;
|
||||
|
||||
ndx = AnimSet(ANIM_Floorz, int(*sectp-sector), sector[dest_sector].floorz, tpoint->tag_high);
|
||||
ndx = AnimSet(ANIM_Floorz, int(*sectp-sector), nullptr, sector[dest_sector].floorz, tpoint->tag_high);
|
||||
AnimSetCallback(ndx, CallbackSOsink, sop);
|
||||
AnimSetVelAdj(ndx, 6);
|
||||
}
|
||||
|
@ -2572,7 +2572,7 @@ void DoTrack(SECTOR_OBJECTp sop, short locktics, int *nx, int *ny)
|
|||
|
||||
if (sectu && sectu->stag == SECT_SO_FORM_WHIRLPOOL)
|
||||
{
|
||||
AnimSet(ANIM_Floorz, int(*sectp - sector), (*sectp)->floorz + Z(sectu->height), 128);
|
||||
AnimSet(ANIM_Floorz, int(*sectp - sector), nullptr, (*sectp)->floorz + Z(sectu->height), 128);
|
||||
(*sectp)->floorshade += sectu->height/6;
|
||||
|
||||
RESET((*sectp)->extra, SECTFX_NO_RIDE);
|
||||
|
@ -2597,7 +2597,7 @@ void DoTrack(SECTOR_OBJECTp sop, short locktics, int *nx, int *ny)
|
|||
tpoint = Track[sop->track].TrackPoint + sop->point;
|
||||
|
||||
// set anim
|
||||
AnimSet(ANIM_SopZ, int(sop-SectorObject), tpoint->z, zr);
|
||||
AnimSet(ANIM_SopZ, int(sop-SectorObject), nullptr, tpoint->z, zr);
|
||||
|
||||
// move back to current point by reversing direction
|
||||
sop->dir *= -1;
|
||||
|
@ -2693,14 +2693,14 @@ void DoTrack(SECTOR_OBJECTp sop, short locktics, int *nx, int *ny)
|
|||
if (TEST(sop->flags, SOBJ_SPRITE_OBJ))
|
||||
{
|
||||
// only modify zmid for sprite_objects
|
||||
AnimSet(ANIM_SopZ, int(sop - SectorObject), dz, sop->z_rate);
|
||||
AnimSet(ANIM_SopZ, int(sop - SectorObject), nullptr, dz, sop->z_rate);
|
||||
}
|
||||
else
|
||||
{
|
||||
// churn through sectors setting their new z values
|
||||
for (i = 0; sop->sector[i] != -1; i++)
|
||||
{
|
||||
AnimSet(ANIM_Floorz, sop->sector[i], dz - (sector[sop->mid_sector].floorz - sector[sop->sector[i]].floorz), sop->z_rate);
|
||||
AnimSet(ANIM_Floorz, sop->sector[i], nullptr, dz - (sector[sop->mid_sector].floorz - sector[sop->sector[i]].floorz), sop->z_rate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue