- minor slope math optimization.

May save one division and merges the '<< 5' into the main calculation.
This commit is contained in:
Christoph Oelckers 2021-12-17 22:53:19 +01:00
parent 11f41a97d5
commit 24a6d45f97
2 changed files with 4 additions and 4 deletions

View file

@ -170,9 +170,9 @@ void calcSlope(const sectortype* sec, float xpos, float ypos, float* pceilz, flo
int len = wal->Length();
if (len != 0)
{
float den = (wal->deltax() * (float(ypos - wal->y)) - wal->deltay() * (float(xpos - wal->x))) * (1.f / 8.f);
if (pceilz && sec->ceilingstat & CSTAT_SECTOR_SLOPE) *pceilz += (sec->ceilingheinum * den) / len;
if (pflorz && sec->floorstat & CSTAT_SECTOR_SLOPE) *pflorz += (sec->floorheinum * den) / len;
float fac = (wal->deltax() * (float(ypos - wal->y)) - wal->deltay() * (float(xpos - wal->x))) * (1.f / 256.f) / len;
if (pceilz && sec->ceilingstat & CSTAT_SECTOR_SLOPE) *pceilz += (sec->ceilingheinum * fac);
if (pflorz && sec->floorstat & CSTAT_SECTOR_SLOPE) *pflorz += (sec->floorheinum * fac);
}
}
}

View file

@ -64,7 +64,7 @@ void walltype::calcLength()
lengthflags &= ~1;
point2Wall()->lengthflags &= ~2;
auto d = delta();
length = (int)sqrt(d.x * d.x + d.y * d.y) << 5;
length = (int)sqrt(d.x * d.x + d.y * d.y);
}
// needed for skipping over to get the map size first.