mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-28 06:53:29 +00:00
Duke: lower the coordinate precision for calculating the sector's center for ST09 to original Build.
This is needed so that some maps with not quite correct setups still work. Found in Roch3.
This commit is contained in:
parent
f3cad8426c
commit
97a71bad5d
1 changed files with 7 additions and 7 deletions
|
@ -566,15 +566,15 @@ static void handle_st09(sectortype* sptr, DDukeActor* actor)
|
||||||
|
|
||||||
sp = (sptr->extra >> 4) / 16.;
|
sp = (sptr->extra >> 4) / 16.;
|
||||||
|
|
||||||
//first find center point by averaging all points
|
//first find center point by averaging all points (in Build coordinate system to ensure the higher precision does not affect the result)
|
||||||
dax = 0, day = 0;
|
int idax = 0, iday = 0;
|
||||||
for (auto& wal : sptr->walls)
|
for (auto& wal : sptr->walls)
|
||||||
{
|
{
|
||||||
dax += wal.pos.X;
|
idax += int(wal.pos.X * 16);
|
||||||
day += wal.pos.Y;
|
iday += int(wal.pos.Y * 16);
|
||||||
}
|
}
|
||||||
dax /= sptr->walls.Size();
|
dax = (idax / (int)sptr->walls.Size()) / 16.;
|
||||||
day /= sptr->walls.Size();
|
day = (iday / (int)sptr->walls.Size()) / 16.;
|
||||||
|
|
||||||
//find any points with either same x or same y coordinate
|
//find any points with either same x or same y coordinate
|
||||||
// as center (dax, day) - should be 2 points found.
|
// as center (dax, day) - should be 2 points found.
|
||||||
|
@ -598,7 +598,7 @@ static void handle_st09(sectortype* sptr, DDukeActor* actor)
|
||||||
auto prevwall = wal - 1;
|
auto prevwall = wal - 1;
|
||||||
if (prevwall < sptr->walls.Data()) prevwall += sptr->walls.Size();
|
if (prevwall < sptr->walls.Data()) prevwall += sptr->walls.Size();
|
||||||
|
|
||||||
if ((wal->pos.X == dax) && (wal->pos.Y == day))
|
if (abs(wal->pos.X - dax) <= (1 / 32.) && abs(wal->pos.Y - day) <= (1 / 32.))
|
||||||
{
|
{
|
||||||
dax2 = ((prevwall->pos.X + wal->point2Wall()->pos.X) * 0.5) - wal->pos.X;
|
dax2 = ((prevwall->pos.X + wal->point2Wall()->pos.X) * 0.5) - wal->pos.X;
|
||||||
day2 = ((prevwall->pos.Y + wal->point2Wall()->pos.Y) * 0.5) - wal->pos.Y;
|
day2 = ((prevwall->pos.Y + wal->point2Wall()->pos.Y) * 0.5) - wal->pos.Y;
|
||||||
|
|
Loading…
Reference in a new issue