- floatify SW's sector object rotation.

This commit is contained in:
Christoph Oelckers 2022-01-27 20:40:44 +01:00
parent a12093af04
commit 6e96b1ee81
10 changed files with 56 additions and 33 deletions

View file

@ -399,7 +399,16 @@ void dragpoint(walltype* startwall, int newx, int newy)
{ {
vertexscan(startwall, [&](walltype* wal) vertexscan(startwall, [&](walltype* wal)
{ {
wal->move(newx, newy); wal->movexy(newx, newy);
wal->sectorp()->exflags |= SECTOREX_DRAGGED;
});
}
void dragpoint(walltype* startwall, const DVector2& pos)
{
vertexscan(startwall, [&](walltype* wal)
{
wal->move(pos);
wal->sectorp()->exflags |= SECTOREX_DRAGGED; wal->sectorp()->exflags |= SECTOREX_DRAGGED;
}); });
} }

View file

@ -169,6 +169,7 @@ void GetFlatSpritePosition(const tspritetype* spr, vec2_t pos, vec2_t* out, int*
void checkRotatedWalls(); void checkRotatedWalls();
bool sectorsConnected(int sect1, int sect2); bool sectorsConnected(int sect1, int sect2);
void dragpoint(walltype* wal, int newx, int newy); void dragpoint(walltype* wal, int newx, int newy);
void dragpoint(walltype* wal, const DVector2& pos);
DVector2 rotatepoint(const DVector2& pivot, const DVector2& point, binangle angle); DVector2 rotatepoint(const DVector2& pivot, const DVector2& point, binangle angle);
// y is negated so that the orientation is the same as in GZDoom, in order to use its utilities. // y is negated so that the orientation is the same as in GZDoom, in order to use its utilities.

View file

@ -417,7 +417,13 @@ struct walltype
bool twoSided() const { return nextsector >= 0; } bool twoSided() const { return nextsector >= 0; }
int Length(); int Length();
void calcLength(); // this is deliberately not inlined and stored in a file where it can't be found at compile time. void calcLength(); // this is deliberately not inlined and stored in a file where it can't be found at compile time.
void move(int newx, int newy); void movexy(int newx, int newy);
void move(const DVector2& vec)
{
pos = vec;
moved();
}
void moved(); void moved();
Blood::XWALL& xw() const { return *_xw; } Blood::XWALL& xw() const { return *_xw; }
@ -553,7 +559,7 @@ inline void walltype::moved()
sectorp()->dirty = EDirty::AllDirty; sectorp()->dirty = EDirty::AllDirty;
} }
inline void walltype::move(int newx, int newy) inline void walltype::movexy(int newx, int newy)
{ {
pos.X = newx * maptoworld; pos.X = newx * maptoworld;
pos.Y = newy * maptoworld; pos.Y = newy * maptoworld;

View file

@ -100,6 +100,7 @@ enum
#define PRODUCTION_ASSERT(f) \ #define PRODUCTION_ASSERT(f) \
assert(f);\
do { \ do { \
if (!(f)) \ if (!(f)) \
I_FatalError("Assertion failed: %s %s, line %u", #f, __FILE__, __LINE__); \ I_FatalError("Assertion failed: %s %s, line %u", #f, __FILE__, __LINE__); \

View file

@ -340,7 +340,9 @@ void so_updateinterpolations(void) // Stick at beginning of domovethings
} }
} }
else else
{
data->oldipos = getvalue(*data); data->oldipos = getvalue(*data);
}
if (!interpolating) if (!interpolating)
data->lastipos = data->lastoldipos = data->oldipos; data->lastipos = data->lastoldipos = data->oldipos;
@ -352,7 +354,7 @@ void so_updateinterpolations(void) // Stick at beginning of domovethings
// make sure you don't exit // make sure you don't exit
void so_dointerpolations(int32_t smoothratio) // Stick at beginning of drawscreen void so_dointerpolations(int32_t smoothratio) // Stick at beginning of drawscreen
{ {
int32_t i, delta; int32_t i;
SECTOR_OBJECT* sop; SECTOR_OBJECT* sop;
so_interp *interp; so_interp *interp;
so_interp::interp_data *data; so_interp::interp_data *data;
@ -445,8 +447,8 @@ void so_dointerpolations(int32_t smoothratio) // Stick at b
} }
else else
{ {
delta = data->lastipos - data->lastoldipos; double delta = data->lastipos - data->lastoldipos;
setvalue(*data, data->lastoldipos + MulScale(delta, ratio, 16)); setvalue(*data, data->lastoldipos + MulScaleF(delta, ratio, 16));
} }
} }
} }
@ -473,9 +475,11 @@ void so_restoreinterpolations(void) // Stick at end of drawscree
if (actorofang) actorofang->spr.ang = data->bakipos; if (actorofang) actorofang->spr.ang = data->bakipos;
} }
else else
{
setvalue(*data, data->bakipos); setvalue(*data, data->bakipos);
} }
} }
}
void so_serializeinterpolations(FSerializer& arc) void so_serializeinterpolations(FSerializer& arc)
{ {

View file

@ -3830,7 +3830,7 @@ int PlayerCanDiveNoWarp(PLAYER* pp)
int GetOverlapSector(int x, int y, sectortype** over, sectortype** under) int GetOverlapSector(int x, int y, sectortype** over, sectortype** under)
{ {
int i, found = 0; int i, found = 0;
sectortype* sf[2]= {nullptr,nullptr}; // sectors found sectortype* sf[3]= {nullptr,nullptr}; // sectors found
auto secto = *over; auto secto = *over;
auto sectu = *under; auto sectu = *under;
@ -3859,7 +3859,7 @@ int GetOverlapSector(int x, int y, sectortype** over, sectortype** under)
{ {
sf[found] = § sf[found] = §
found++; found++;
PRODUCTION_ASSERT(found <= 2); if (found > 2) return 0;
} }
} }
} }

View file

@ -274,11 +274,11 @@ int DoSlidorMoveWalls(DSWActor* actor, int amt)
if (!wal->twoSided()) if (!wal->twoSided())
{ {
// white wall - move 4 points // white wall - move 4 points
wal->move(wal->wall_int_pos().X - amt, wal->wall_int_pos().Y); wal->movexy(wal->wall_int_pos().X - amt, wal->wall_int_pos().Y);
pwal->move(pwal->wall_int_pos().X - amt, pwal->wall_int_pos().Y); pwal->movexy(pwal->wall_int_pos().X - amt, pwal->wall_int_pos().Y);
wal->point2Wall()->move(wal->point2Wall()->wall_int_pos().X - amt, wal->point2Wall()->wall_int_pos().Y); wal->point2Wall()->movexy(wal->point2Wall()->wall_int_pos().X - amt, wal->point2Wall()->wall_int_pos().Y);
auto pwal2 = wal->point2Wall()->point2Wall(); auto pwal2 = wal->point2Wall()->point2Wall();
pwal2->move(pwal2->wall_int_pos().X - amt, pwal2->wall_int_pos().Y); pwal2->movexy(pwal2->wall_int_pos().X - amt, pwal2->wall_int_pos().Y);
} }
else else
{ {
@ -299,11 +299,11 @@ int DoSlidorMoveWalls(DSWActor* actor, int amt)
if (!wal->twoSided()) if (!wal->twoSided())
{ {
// white wall - move 4 points // white wall - move 4 points
wal->move(wal->wall_int_pos().X + amt, wal->wall_int_pos().Y); wal->movexy(wal->wall_int_pos().X + amt, wal->wall_int_pos().Y);
pwal->move(pwal->wall_int_pos().X + amt, pwal->wall_int_pos().Y); pwal->movexy(pwal->wall_int_pos().X + amt, pwal->wall_int_pos().Y);
wal->point2Wall()->move(wal->point2Wall()->wall_int_pos().X + amt, wal->point2Wall()->wall_int_pos().Y); wal->point2Wall()->movexy(wal->point2Wall()->wall_int_pos().X + amt, wal->point2Wall()->wall_int_pos().Y);
auto pwal2 = wal->point2Wall()->point2Wall(); auto pwal2 = wal->point2Wall()->point2Wall();
pwal2->move(pwal2->wall_int_pos().X + amt, pwal2->wall_int_pos().Y); pwal2->movexy(pwal2->wall_int_pos().X + amt, pwal2->wall_int_pos().Y);
} }
else else
{ {
@ -323,11 +323,11 @@ int DoSlidorMoveWalls(DSWActor* actor, int amt)
if (!wal->twoSided()) if (!wal->twoSided())
{ {
wal->move(wal->wall_int_pos().X, wal->wall_int_pos().Y - amt); wal->movexy(wal->wall_int_pos().X, wal->wall_int_pos().Y - amt);
pwal->move(pwal->wall_int_pos().X, pwal->wall_int_pos().Y - amt); pwal->movexy(pwal->wall_int_pos().X, pwal->wall_int_pos().Y - amt);
wal->point2Wall()->move(wal->point2Wall()->wall_int_pos().X, wal->point2Wall()->wall_int_pos().Y - amt); wal->point2Wall()->movexy(wal->point2Wall()->wall_int_pos().X, wal->point2Wall()->wall_int_pos().Y - amt);
auto pwal2 = wal->point2Wall()->point2Wall(); auto pwal2 = wal->point2Wall()->point2Wall();
pwal2->move(pwal2->wall_int_pos().X, pwal2->wall_int_pos().Y - amt); pwal2->movexy(pwal2->wall_int_pos().X, pwal2->wall_int_pos().Y - amt);
} }
else else
{ {
@ -346,11 +346,11 @@ int DoSlidorMoveWalls(DSWActor* actor, int amt)
if (!wal->twoSided()) if (!wal->twoSided())
{ {
wal->move(wal->wall_int_pos().X, wal->wall_int_pos().Y + amt); wal->movexy(wal->wall_int_pos().X, wal->wall_int_pos().Y + amt);
pwal->move(pwal->wall_int_pos().X, pwal->wall_int_pos().Y + amt); pwal->movexy(pwal->wall_int_pos().X, pwal->wall_int_pos().Y + amt);
wal->point2Wall()->move(wal->point2Wall()->wall_int_pos().X, wal->point2Wall()->wall_int_pos().Y + amt); wal->point2Wall()->movexy(wal->point2Wall()->wall_int_pos().X, wal->point2Wall()->wall_int_pos().Y + amt);
auto pwal2 = wal->point2Wall()->point2Wall(); auto pwal2 = wal->point2Wall()->point2Wall();
pwal2->move(pwal2->wall_int_pos().X, pwal2->wall_int_pos().Y + amt); pwal2->movexy(pwal2->wall_int_pos().X, pwal2->wall_int_pos().Y + amt);
} }
else else
{ {

View file

@ -1454,7 +1454,7 @@ void PreMapCombineFloors(void)
for (auto& wal : wallsofsector(dasect)) for (auto& wal : wallsofsector(dasect))
{ {
wal.move(wal.wall_int_pos().X + dx, wal.wall_int_pos().Y + dy); wal.movexy(wal.wall_int_pos().X + dx, wal.wall_int_pos().Y + dy);
if (wal.twoSided()) if (wal.twoSided())
search.Add(wal.nextSector()); search.Add(wal.nextSector());

View file

@ -1610,6 +1610,8 @@ void MovePoints(SECTOR_OBJECT* sop, short delta_ang, int nx, int ny)
if ((sop->flags & SOBJ_ZMID_FLOOR)) if ((sop->flags & SOBJ_ZMID_FLOOR))
sop->pmid.Z = sop->mid_sector->floorz; sop->pmid.Z = sop->mid_sector->floorz;
DVector2 pivot = { sop->pmid.X * maptoworld, sop->pmid.Y * maptoworld };
DVector2 move = { nx * maptoworld, ny * maptoworld };
for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++) for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++)
{ {
if ((sop->flags & (SOBJ_SPRITE_OBJ | SOBJ_DONT_ROTATE))) if ((sop->flags & (SOBJ_SPRITE_OBJ | SOBJ_DONT_ROTATE)))
@ -1623,11 +1625,11 @@ void MovePoints(SECTOR_OBJECT* sop, short delta_ang, int nx, int ny)
if (wal.extra && (wal.extra & WALLFX_LOOP_OUTER)) if (wal.extra && (wal.extra & WALLFX_LOOP_OUTER))
{ {
dragpoint(&wal, wal.wall_int_pos().X + nx, wal.wall_int_pos().Y + ny); dragpoint(&wal, wal.pos + move);
} }
else else
{ {
wal.move(wal.wall_int_pos().X + nx, wal.wall_int_pos().Y + ny); wal.move(wal.pos + move);
} }
rot_ang = delta_ang; rot_ang = delta_ang;
@ -1641,15 +1643,15 @@ void MovePoints(SECTOR_OBJECT* sop, short delta_ang, int nx, int ny)
if ((wal.extra & WALLFX_LOOP_SPIN_4X)) if ((wal.extra & WALLFX_LOOP_SPIN_4X))
rot_ang = NORM_ANGLE(rot_ang * 4); rot_ang = NORM_ANGLE(rot_ang * 4);
rotatepoint(sop->pmid.vec2, wal.wall_int_pos(), rot_ang, &rxy); auto vec = rotatepoint(pivot, wal.pos, buildang(rot_ang));
if (wal.extra && (wal.extra & WALLFX_LOOP_OUTER)) if (wal.extra && (wal.extra & WALLFX_LOOP_OUTER))
{ {
dragpoint(&wal, rxy.X, rxy.Y); dragpoint(&wal, vec);
} }
else else
{ {
wal.move(rxy.X, rxy.Y); wal.move(vec);
} }
} }
@ -1870,7 +1872,7 @@ void RefreshPoints(SECTOR_OBJECT* sop, int nx, int ny, bool dynamic)
} }
else else
{ {
wal.move(dx, dy); wal.movexy(dx, dy);
} }
} }
@ -2018,7 +2020,7 @@ void CollapseSectorObject(SECTOR_OBJECT* sop, int nx, int ny)
} }
else else
{ {
wal.move(nx, ny); wal.movexy(nx, ny);
} }
} }
} }

View file

@ -115,7 +115,7 @@ int DoWallMove(DSWActor* actor)
} }
else else
{ {
wal.move(actor->spr.pos.X + nx, actor->spr.pos.Y + ny); wal.movexy(actor->spr.pos.X + nx, actor->spr.pos.Y + ny);
} }
if (shade1) if (shade1)