From 5611df1f3ebd26565f0f6e2e5157dae3f0e7fa2e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 17 Feb 2016 00:29:50 +0100 Subject: [PATCH] - fixed the portal aware ceiling and floor functions. --- src/p_sectors.cpp | 10 ++++++++-- src/r_defs.h | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/p_sectors.cpp b/src/p_sectors.cpp index 606e85575..db439f4a5 100644 --- a/src/p_sectors.cpp +++ b/src/p_sectors.cpp @@ -935,6 +935,8 @@ fixed_t sector_t::LowestFloorAt(fixed_t x, fixed_t y, sector_t **resultsec) fixed_t sector_t::NextHighestCeilingAt(fixed_t x, fixed_t y, fixed_t z, sector_t **resultsec, F3DFloor **resultffloor) { sector_t *sec = this; + fixed_t planeheight = FIXED_MIN; + while (true) { // Looking through planes from bottom to top @@ -950,7 +952,7 @@ fixed_t sector_t::NextHighestCeilingAt(fixed_t x, fixed_t y, fixed_t z, sector_t return ffz; } } - if (sec->PortalBlocksMovement(sector_t::ceiling)) + if (sec->PortalBlocksMovement(ceiling) || planeheight >= sec->SkyBoxes[ceiling]->threshold) { // Use sector's floor if (resultffloor) *resultffloor = NULL; if (resultsec) *resultsec = sec; @@ -961,6 +963,8 @@ fixed_t sector_t::NextHighestCeilingAt(fixed_t x, fixed_t y, fixed_t z, sector_t FDisplacement &disp = sec->CeilingDisplacement(); x += disp.pos.x; y += disp.pos.y; + planeheight = sec->SkyBoxes[ceiling]->threshold; + sec = P_PointInSector(x, y); } } } @@ -968,6 +972,7 @@ fixed_t sector_t::NextHighestCeilingAt(fixed_t x, fixed_t y, fixed_t z, sector_t fixed_t sector_t::NextLowestFloorAt(fixed_t x, fixed_t y, fixed_t z, sector_t **resultsec, F3DFloor **resultffloor) { sector_t *sec = this; + fixed_t planeheight = FIXED_MAX; while (true) { // Looking through planes from top to bottom @@ -984,7 +989,7 @@ fixed_t sector_t::NextLowestFloorAt(fixed_t x, fixed_t y, fixed_t z, sector_t ** return ffz; } } - if (sec->PortalBlocksMovement(sector_t::floor)) + if (sec->PortalBlocksMovement(sector_t::floor) || planeheight <= sec->SkyBoxes[floor]->threshold) { // Use sector's floor if (resultffloor) *resultffloor = NULL; if (resultsec) *resultsec = sec; @@ -995,6 +1000,7 @@ fixed_t sector_t::NextLowestFloorAt(fixed_t x, fixed_t y, fixed_t z, sector_t ** FDisplacement &disp = sec->FloorDisplacement(); x += disp.pos.x; y += disp.pos.y; + planeheight = sec->SkyBoxes[floor]->threshold; sec = P_PointInSector(x, y); } } diff --git a/src/r_defs.h b/src/r_defs.h index eb08cec7b..6376dd71e 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -757,7 +757,7 @@ struct sector_t fixed_t HighestCeilingAt(AActor *a, sector_t **resultsec = NULL) { - return HighestCeilingAt(a->X(), a->X(), resultsec); + return HighestCeilingAt(a->X(), a->Y(), resultsec); } fixed_t LowestFloorAt(AActor *a, sector_t **resultsec = NULL)