- floatified some parts of the SO interface for consistent use of MAXSO.

This commit is contained in:
Christoph Oelckers 2022-08-20 10:03:21 +02:00
parent b9dbcebe2e
commit e71254dfa6
5 changed files with 21 additions and 24 deletions

View file

@ -371,10 +371,6 @@ FGameTexture* BuildTiles::ValidateCustomTile(int tilenum, ReplacementType type)
{
// Creates an empty writable tile.
// Current use cases are:
// Camera textures (should be made to be creatable by the hardware renderer instead of falling back on the software renderer.)
// thumbnails for savegame and loadgame (should bypass the texture manager entirely.)
// view tilting in the software renderer (this should just use a local buffer instead of relying on the texture manager.)
// Movie playback (like thumbnails this should bypass the texture manager entirely.)
// Blood's 'lens' effect (apparently MP only) - combination of a camera texture with a distortion map - should be made a shader effect to be applied to the camera texture.
replacement = new FImageTexture(new FWritableTile);
}

View file

@ -1569,7 +1569,9 @@ enum
// #define SO_SPEED_BOAT 99
};
constexpr double MAXSO = INT32_MAX / 32; // make sure this does not overflow when converted to a Build int coordinate.
// make sure this does not overflow when converted to a Build int coordinate and survives a round trip through conversions.
constexpr double MAXSO = 0x7fffffe0 / 32;
static_assert(MAXSO == int(MAXSO * worldtoint) * inttoworld);
inline bool SO_EMPTY(SECTOR_OBJECT* sop) { return (sop->pmid.X == MAXSO); }

View file

@ -48,7 +48,7 @@ int ActorFollowTrack(DSWActor*, short locktics);
void ActorLeaveTrack(DSWActor*);
void RefreshPoints(SECTOR_OBJECT* sop, int nx, int ny, bool dynamic);
void TrackSetup(void);
void PlaceSectorObject(SECTOR_OBJECT* sop, int newx, int newy);
void PlaceSectorObject(SECTOR_OBJECT* sop, const DVector2& newpos);
void PlaceSectorObjectsOnTracks(void);
void PlaceActorsOnTracks(void);
void SetupSectorObject(sectortype* sect, short tag);

View file

@ -161,7 +161,7 @@ void DoPlayerBeginDive(PLAYER* pp);
void DoPlayerDive(PLAYER* pp);
void DoPlayerTeleportPause(PLAYER* pp);
bool PlayerFlyKey(void);
void OperateSectorObject(SECTOR_OBJECT* sop, short newang, int newx, int newy);
void OperateSectorObject(SECTOR_OBJECT* sop, short newang, const DVector2& newpos);
void CheckFootPrints(PLAYER* pp);
bool DoPlayerTestCrawl(PLAYER* pp);
void DoPlayerDeathFlip(PLAYER* pp);
@ -1566,7 +1566,7 @@ void DoPlayerTurnTurret(PLAYER* pp, float avel)
pp->actor->set_int_ang(pp->angle.ang.Buildang());
}
OperateSectorObject(pp->sop, pp->angle.ang.Buildang(), pp->sop->int_pmid().X, pp->sop->int_pmid().Y);
OperateSectorObject(pp->sop, pp->angle.ang.Buildang(), pp->sop->pmid);
}
void SlipSlope(PLAYER* pp)
@ -2581,7 +2581,7 @@ void DoPlayerMoveVehicle(PLAYER* pp)
}
auto save_sect = pp->cursector;
OperateSectorObject(pp->sop, pp->angle.ang.Buildang(), MAXSO, MAXSO);
OperateSectorObject(pp->sop, pp->angle.ang.Buildang(), { MAXSO, MAXSO });
pp->setcursector(pp->sop->op_main_sector); // for speed
floor_dist = labs(z - pp->sop->floor_loz);
@ -2686,7 +2686,7 @@ void DoPlayerMoveVehicle(PLAYER* pp)
}
}
OperateSectorObject(pp->sop, pp->angle.ang.Buildang(), pp->pos.X, pp->pos.Y);
OperateSectorObject(pp->sop, pp->angle.ang.Buildang(), { pp->pos.X * inttoworld, pp->pos.Y * inttoworld });
pp->cursector = save_sect; // for speed
if (!SyncInput())
@ -4821,17 +4821,16 @@ void FindMainSector(SECTOR_OBJECT* sop)
// find the main sector - only do this once for each sector object
if (sop->op_main_sector == nullptr)
{
int sx = sop->int_pmid().X;
int sy = sop->int_pmid().Y;
auto oldpos = sop->pmid;
PlaceSectorObject(sop, MAXSO, MAXSO);
PlaceSectorObject(sop, { MAXSO, MAXSO });
// set it to something valid
sop->op_main_sector = &sector[0];
updatesectorz(sx, sy, sop->int_pmid().Z, &sop->op_main_sector);
updatesectorz(oldpos, &sop->op_main_sector);
PlaceSectorObject(sop, sx, sy);
PlaceSectorObject(sop, oldpos.XY());
}
}

View file

@ -1856,7 +1856,7 @@ void RefreshPoints(SECTOR_OBJECT* sop, int nx, int ny, bool dynamic)
}
}
if (wal.extra && (wal.extra & WALLFX_LOOP_OUTER))
if (wal.extra & WALLFX_LOOP_OUTER)
{
dragpoint(&wal, dx, dy);
}
@ -2568,7 +2568,7 @@ void DoTrack(SECTOR_OBJECT* sop, short locktics, int *nx, int *ny)
}
void OperateSectorObjectForTics(SECTOR_OBJECT* sop, short newang, int newx, int newy, short locktics)
void OperateSectorObjectForTics(SECTOR_OBJECT* sop, short newang, const DVector2& pos, short locktics)
{
int i;
sectortype* *sectp;
@ -2604,18 +2604,18 @@ void OperateSectorObjectForTics(SECTOR_OBJECT* sop, short newang, int newx, int
sop->spin_ang = 0;
sop->ang = newang;
RefreshPoints(sop, newx - sop->int_pmid().X, newy - sop->int_pmid().Y, false);
RefreshPoints(sop, int((pos.X - sop->pmid.X) * worldtoint), int((pos.Y - sop->pmid.Y) * worldtoint), false);
}
void OperateSectorObject(SECTOR_OBJECT* sop, short newang, int newx, int newy)
void OperateSectorObject(SECTOR_OBJECT* sop, short newang, const DVector2& pos)
{
OperateSectorObjectForTics(sop, newang, newx, newy, synctics);
OperateSectorObjectForTics(sop, newang, pos, synctics);
}
void PlaceSectorObject(SECTOR_OBJECT* sop, int newx, int newy)
void PlaceSectorObject(SECTOR_OBJECT* sop, const DVector2& pos)
{
so_setinterpolationtics(sop, synctics);
RefreshPoints(sop, newx - sop->int_pmid().X, newy - sop->int_pmid().Y, false);
RefreshPoints(sop, int((pos.X - sop->pmid.X) * worldtoint), int((pos.Y - sop->pmid.Y) * worldtoint), false);
}
void VehicleSetSmoke(SECTOR_OBJECT* sop, ANIMATOR* animator)
@ -2707,7 +2707,7 @@ void DoTornadoObject(SECTOR_OBJECT* sop)
pos.Y = sop->int_pmid().Y;
pos.Z = floor_dist;
PlaceSectorObject(sop, MAXSO, MAXSO);
PlaceSectorObject(sop, {MAXSO, MAXSO});
Collision coll;
clipmove(pos, &cursect, xvect, yvect, (int)sop->clipdist, Z(0), floor_dist, CLIPMASK_ACTOR, coll);
@ -2810,7 +2810,7 @@ void DoAutoTurretObject(SECTOR_OBJECT* sop)
}
}
OperateSectorObjectForTics(sop, sop->ang, sop->int_pmid().X, sop->int_pmid().Y, 2*synctics);
OperateSectorObjectForTics(sop, sop->ang, sop->pmid, 2*synctics);
}
}