mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 08:51:24 +00:00
- floatify SW's sector object rotation.
This commit is contained in:
parent
a12093af04
commit
6e96b1ee81
10 changed files with 56 additions and 33 deletions
|
@ -399,11 +399,20 @@ void dragpoint(walltype* startwall, int newx, int newy)
|
|||
{
|
||||
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;
|
||||
});
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
|
|
|
@ -169,6 +169,7 @@ void GetFlatSpritePosition(const tspritetype* spr, vec2_t pos, vec2_t* out, int*
|
|||
void checkRotatedWalls();
|
||||
bool sectorsConnected(int sect1, int sect2);
|
||||
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);
|
||||
|
||||
// y is negated so that the orientation is the same as in GZDoom, in order to use its utilities.
|
||||
|
|
|
@ -417,7 +417,13 @@ struct walltype
|
|||
bool twoSided() const { return nextsector >= 0; }
|
||||
int Length();
|
||||
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();
|
||||
|
||||
Blood::XWALL& xw() const { return *_xw; }
|
||||
|
@ -553,7 +559,7 @@ inline void walltype::moved()
|
|||
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.Y = newy * maptoworld;
|
||||
|
|
|
@ -100,6 +100,7 @@ enum
|
|||
|
||||
|
||||
#define PRODUCTION_ASSERT(f) \
|
||||
assert(f);\
|
||||
do { \
|
||||
if (!(f)) \
|
||||
I_FatalError("Assertion failed: %s %s, line %u", #f, __FILE__, __LINE__); \
|
||||
|
|
|
@ -340,7 +340,9 @@ void so_updateinterpolations(void) // Stick at beginning of domovethings
|
|||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
data->oldipos = getvalue(*data);
|
||||
}
|
||||
|
||||
if (!interpolating)
|
||||
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
|
||||
void so_dointerpolations(int32_t smoothratio) // Stick at beginning of drawscreen
|
||||
{
|
||||
int32_t i, delta;
|
||||
int32_t i;
|
||||
SECTOR_OBJECT* sop;
|
||||
so_interp *interp;
|
||||
so_interp::interp_data *data;
|
||||
|
@ -445,8 +447,8 @@ void so_dointerpolations(int32_t smoothratio) // Stick at b
|
|||
}
|
||||
else
|
||||
{
|
||||
delta = data->lastipos - data->lastoldipos;
|
||||
setvalue(*data, data->lastoldipos + MulScale(delta, ratio, 16));
|
||||
double delta = data->lastipos - data->lastoldipos;
|
||||
setvalue(*data, data->lastoldipos + MulScaleF(delta, ratio, 16));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -473,7 +475,9 @@ void so_restoreinterpolations(void) // Stick at end of drawscree
|
|||
if (actorofang) actorofang->spr.ang = data->bakipos;
|
||||
}
|
||||
else
|
||||
{
|
||||
setvalue(*data, data->bakipos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3830,7 +3830,7 @@ int PlayerCanDiveNoWarp(PLAYER* pp)
|
|||
int GetOverlapSector(int x, int y, sectortype** over, sectortype** under)
|
||||
{
|
||||
int i, found = 0;
|
||||
sectortype* sf[2]= {nullptr,nullptr}; // sectors found
|
||||
sectortype* sf[3]= {nullptr,nullptr}; // sectors found
|
||||
auto secto = *over;
|
||||
auto sectu = *under;
|
||||
|
||||
|
@ -3859,7 +3859,7 @@ int GetOverlapSector(int x, int y, sectortype** over, sectortype** under)
|
|||
{
|
||||
sf[found] = §
|
||||
found++;
|
||||
PRODUCTION_ASSERT(found <= 2);
|
||||
if (found > 2) return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -274,11 +274,11 @@ int DoSlidorMoveWalls(DSWActor* actor, int amt)
|
|||
if (!wal->twoSided())
|
||||
{
|
||||
// white wall - move 4 points
|
||||
wal->move(wal->wall_int_pos().X - amt, wal->wall_int_pos().Y);
|
||||
pwal->move(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->movexy(wal->wall_int_pos().X - amt, wal->wall_int_pos().Y);
|
||||
pwal->movexy(pwal->wall_int_pos().X - amt, pwal->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();
|
||||
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
|
||||
{
|
||||
|
@ -299,11 +299,11 @@ int DoSlidorMoveWalls(DSWActor* actor, int amt)
|
|||
if (!wal->twoSided())
|
||||
{
|
||||
// white wall - move 4 points
|
||||
wal->move(wal->wall_int_pos().X + amt, wal->wall_int_pos().Y);
|
||||
pwal->move(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->movexy(wal->wall_int_pos().X + amt, wal->wall_int_pos().Y);
|
||||
pwal->movexy(pwal->wall_int_pos().X + amt, pwal->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();
|
||||
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
|
||||
{
|
||||
|
@ -323,11 +323,11 @@ int DoSlidorMoveWalls(DSWActor* actor, int amt)
|
|||
|
||||
if (!wal->twoSided())
|
||||
{
|
||||
wal->move(wal->wall_int_pos().X, wal->wall_int_pos().Y - amt);
|
||||
pwal->move(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->movexy(wal->wall_int_pos().X, wal->wall_int_pos().Y - amt);
|
||||
pwal->movexy(pwal->wall_int_pos().X, pwal->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();
|
||||
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
|
||||
{
|
||||
|
@ -346,11 +346,11 @@ int DoSlidorMoveWalls(DSWActor* actor, int amt)
|
|||
|
||||
if (!wal->twoSided())
|
||||
{
|
||||
wal->move(wal->wall_int_pos().X, wal->wall_int_pos().Y + amt);
|
||||
pwal->move(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->movexy(wal->wall_int_pos().X, wal->wall_int_pos().Y + amt);
|
||||
pwal->movexy(pwal->wall_int_pos().X, pwal->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();
|
||||
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
|
||||
{
|
||||
|
|
|
@ -1454,7 +1454,7 @@ void PreMapCombineFloors(void)
|
|||
|
||||
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())
|
||||
search.Add(wal.nextSector());
|
||||
|
|
|
@ -1610,6 +1610,8 @@ void MovePoints(SECTOR_OBJECT* sop, short delta_ang, int nx, int ny)
|
|||
if ((sop->flags & SOBJ_ZMID_FLOOR))
|
||||
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++)
|
||||
{
|
||||
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))
|
||||
{
|
||||
dragpoint(&wal, wal.wall_int_pos().X + nx, wal.wall_int_pos().Y + ny);
|
||||
dragpoint(&wal, wal.pos + move);
|
||||
}
|
||||
else
|
||||
{
|
||||
wal.move(wal.wall_int_pos().X + nx, wal.wall_int_pos().Y + ny);
|
||||
wal.move(wal.pos + move);
|
||||
}
|
||||
|
||||
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))
|
||||
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))
|
||||
{
|
||||
dragpoint(&wal, rxy.X, rxy.Y);
|
||||
dragpoint(&wal, vec);
|
||||
}
|
||||
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
|
||||
{
|
||||
wal.move(dx, dy);
|
||||
wal.movexy(dx, dy);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2018,7 +2020,7 @@ void CollapseSectorObject(SECTOR_OBJECT* sop, int nx, int ny)
|
|||
}
|
||||
else
|
||||
{
|
||||
wal.move(nx, ny);
|
||||
wal.movexy(nx, ny);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ int DoWallMove(DSWActor* actor)
|
|||
}
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue