- SW: simplified rotation interpolation functions.

This commit is contained in:
Christoph Oelckers 2021-11-24 16:39:29 +01:00
parent 33c707c708
commit a93dbaf5fe
5 changed files with 25 additions and 35 deletions

View file

@ -777,6 +777,11 @@ inline walltype* sectortype::firstWall() const
return &wall[wallptr]; // cannot be -1 in a proper map return &wall[wallptr]; // cannot be -1 in a proper map
} }
inline walltype* sectortype::lastWall() const
{
return &wall[wallptr + wallnum - 1]; // cannot be -1 in a proper map
}
inline int cansee(int x1, int y1, int z1, sectortype* sect1, int x2, int y2, int z2, sectortype* sect2) inline int cansee(int x1, int y1, int z1, sectortype* sect1, int x2, int y2, int z2, sectortype* sect2)
{ {
return cansee(x1, y1, z1, sector.IndexOf(sect1), x2, y2, z2, sector.IndexOf(sect2)); return cansee(x1, y1, z1, sector.IndexOf(sect1), x2, y2, z2, sector.IndexOf(sect2));

View file

@ -142,7 +142,8 @@ struct sectortype
void addfloorypan(float add) { floorypan_ = fmodf(floorypan_ + add + 512, 256); } // +512 is for handling negative offsets void addfloorypan(float add) { floorypan_ = fmodf(floorypan_ + add + 512, 256); } // +512 is for handling negative offsets
void addceilingxpan(float add) { ceilingxpan_ = fmodf(ceilingxpan_ + add + 512, 256); } // +512 is for handling negative offsets void addceilingxpan(float add) { ceilingxpan_ = fmodf(ceilingxpan_ + add + 512, 256); } // +512 is for handling negative offsets
void addceilingypan(float add) { ceilingypan_ = fmodf(ceilingypan_ + add + 512, 256); } // +512 is for handling negative offsets void addceilingypan(float add) { ceilingypan_ = fmodf(ceilingypan_ + add + 512, 256); } // +512 is for handling negative offsets
walltype *firstWall() const; walltype* firstWall() const;
walltype* lastWall() const;
// These will unfortunately have to be within the base struct to refactor Blood properly. They can later be removed again, once everything is done. // These will unfortunately have to be within the base struct to refactor Blood properly. They can later be removed again, once everything is done.

View file

@ -76,6 +76,9 @@ struct Collision
int setSprite(DSWActor* num); int setSprite(DSWActor* num);
int setSky(); int setSky();
int setFromEngine(int value); int setFromEngine(int value);
walltype* wall() const { assert(type == kHitWall); return &::wall[index]; }
sectortype* sector() const { assert(type == kHitSector); return &::sector[index]; }
}; };
typedef struct typedef struct

View file

@ -234,22 +234,17 @@ bool TestRotatorMatchActive(short match)
void DoRotatorSetInterp(DSWActor* actor) void DoRotatorSetInterp(DSWActor* actor)
{ {
SPRITEp sp = &actor->s(); SPRITEp sp = &actor->s();
short w,startwall,endwall;
startwall = sp->sector()->wallptr; for(auto& wal : wallsofsector(sp->sector()))
endwall = startwall + sp->sector()->wallnum - 1;
// move points
for (w = startwall; w <= endwall; w++)
{ {
StartInterpolation(w, Interp_Wall_X); StartInterpolation(&wal, Interp_Wall_X);
StartInterpolation(w, Interp_Wall_Y); StartInterpolation(&wal, Interp_Wall_Y);
uint16_t const nextwall = wall[w].nextwall; if (wal.twoSided())
if (validWallIndex(nextwall))
{ {
StartInterpolation(wall[nextwall].point2, Interp_Wall_X); auto w2 = wal.nextWall()->point2Wall();
StartInterpolation(wall[nextwall].point2, Interp_Wall_Y); StartInterpolation(w2, Interp_Wall_X);
StartInterpolation(w2, Interp_Wall_Y);
} }
} }
} }
@ -257,22 +252,16 @@ void DoRotatorSetInterp(DSWActor* actor)
void DoRotatorStopInterp(DSWActor* actor) void DoRotatorStopInterp(DSWActor* actor)
{ {
SPRITEp sp = &actor->s(); SPRITEp sp = &actor->s();
short w,startwall,endwall; for (auto& wal : wallsofsector(sp->sector()))
startwall = sp->sector()->wallptr;
endwall = startwall + sp->sector()->wallnum - 1;
// move points
for (w = startwall; w <= endwall; w++)
{ {
StopInterpolation(w, Interp_Wall_X); StopInterpolation(&wal, Interp_Wall_X);
StopInterpolation(w, Interp_Wall_Y); StopInterpolation(&wal, Interp_Wall_Y);
uint16_t const nextwall = wall[w].nextwall; if (wal.twoSided())
if (validWallIndex(nextwall))
{ {
StopInterpolation(wall[nextwall].point2, Interp_Wall_X); auto w2 = wal.nextWall()->point2Wall();
StopInterpolation(wall[nextwall].point2, Interp_Wall_Y); StopInterpolation(w2, Interp_Wall_X);
StopInterpolation(w2, Interp_Wall_Y);
} }
} }
} }

View file

@ -19601,15 +19601,7 @@ int DoItemFly(DSWActor* actor)
case kHitWall: case kHitWall:
{ {
short hit_wall,nw,wall_ang; int wall_ang = NORM_ANGLE(getangle(u->coll.wall()->delta())+512);
WALLp wph;
hit_wall = u->coll.index;
wph = &wall[hit_wall];
nw = wall[hit_wall].point2;
wall_ang = NORM_ANGLE(getangle(wall[nw].x - wph->x, wall[nw].y - wph->y)+512);
WallBounce(actor, wall_ang); WallBounce(actor, wall_ang);
ScaleSpriteVector(actor, 32000); ScaleSpriteVector(actor, 32000);
break; break;