Skip to content

Commit

Permalink
- engine stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Dec 5, 2021
1 parent 9bd019d commit a24f97e
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions source/build/src/engine.cpp
Expand Up @@ -1130,16 +1130,12 @@ int32_t getsectordist(vec2_t const in, int const sectnum, vec2_t * const out /*=

int32_t distance = INT32_MAX;

auto const sec = (usectorptr_t)&sector[sectnum];
int const startwall = sec->wallptr;
int const endwall = sec->wallptr + sec->wallnum;
auto uwal = (uwallptr_t)&wall[startwall];
vec2_t closest = {};

for (int j = startwall; j < endwall; j++, uwal++)
for (auto& wal : wallsofsector(sectnum))
{
vec2_t p;
int32_t const walldist = getwalldist(in, j, &p);
int32_t const walldist = getwalldist(in, wallnum(&wal), &p);

if (walldist < distance)
{
Expand Down Expand Up @@ -1402,19 +1398,20 @@ void getzsofslopeptr(usectorptr_t sec, int32_t dax, int32_t day, int32_t *ceilz,
//
void alignceilslope(int16_t dasect, int32_t x, int32_t y, int32_t z)
{
auto const wal = (uwallptr_t)&wall[sector[dasect].wallptr];
auto sect = &sector[dasect];
auto const wal = (uwallptr_t)sect->firstWall();
const int32_t dax = wal->point2Wall()->x-wal->x;
const int32_t day = wal->point2Wall()->y-wal->y;

const int32_t i = (y-wal->y)*dax - (x-wal->x)*day;
if (i == 0)
return;

sector[dasect].ceilingheinum = Scale((z-sector[dasect].ceilingz)<<8,
sect->ceilingheinum = Scale((z-sect->ceilingz)<<8,
ksqrt(uhypsq(dax,day)), i);
if (sector[dasect].ceilingheinum == 0)
sector[dasect].ceilingstat &= ~2;
else sector[dasect].ceilingstat |= 2;
if (sect->ceilingheinum == 0)
sect->ceilingstat &= ~2;
else sect->ceilingstat |= 2;
}


Expand All @@ -1423,19 +1420,20 @@ void alignceilslope(int16_t dasect, int32_t x, int32_t y, int32_t z)
//
void alignflorslope(int16_t dasect, int32_t x, int32_t y, int32_t z)
{
auto const wal = (uwallptr_t)&wall[sector[dasect].wallptr];
auto sect = &sector[dasect];
auto const wal = (uwallptr_t)sect->firstWall();
const int32_t dax = wal->point2Wall()->x-wal->x;
const int32_t day = wal->point2Wall()->y-wal->y;

const int32_t i = (y-wal->y)*dax - (x-wal->x)*day;
if (i == 0)
return;

sector[dasect].floorheinum = Scale((z-sector[dasect].floorz)<<8,
sect->floorheinum = Scale((z-sect->floorz)<<8,
ksqrt(uhypsq(dax,day)), i);
if (sector[dasect].floorheinum == 0)
sector[dasect].floorstat &= ~2;
else sector[dasect].floorstat |= 2;
if (sect->floorheinum == 0)
sect->floorstat &= ~2;
else sect->floorstat |= 2;
}


Expand Down

0 comments on commit a24f97e

Please sign in to comment.