- added support for FFCF_NOPORTALS and FFCF_3DRESTRICT to FindNextLowestFloorAt and FindNextHighestCeilingAt

- use these functions in P_GetFloorCeiling instead of duplicating all this code.
- removed some debug CCMDs.
This commit is contained in:
Christoph Oelckers 2016-02-19 22:03:29 +01:00
parent dc37f78566
commit 6132f6971a
4 changed files with 34 additions and 95 deletions

View file

@ -4184,12 +4184,12 @@ bool DLevelScript::DoCheckActorTexture(int tid, AActor *activator, int string, b
if (floor) if (floor)
{ {
actor->Sector->NextLowestFloorAt(actor, actor->Z(), &resultsec, &resffloor); actor->Sector->NextLowestFloorAt(actor, actor->Z(), 0, &resultsec, &resffloor);
secpic = resffloor ? *resffloor->top.texture : resultsec->planes[sector_t::floor].Texture; secpic = resffloor ? *resffloor->top.texture : resultsec->planes[sector_t::floor].Texture;
} }
else else
{ {
actor->Sector->NextHighestCeilingAt(actor, actor->Top(), &resultsec, &resffloor); actor->Sector->NextHighestCeilingAt(actor, actor->Top(), 0, &resultsec, &resffloor);
secpic = resffloor ? *resffloor->bottom.texture : resultsec->planes[sector_t::ceiling].Texture; secpic = resffloor ? *resffloor->bottom.texture : resultsec->planes[sector_t::ceiling].Texture;
} }
return tex == TexMan[secpic]; return tex == TexMan[secpic];

View file

@ -261,51 +261,24 @@ static bool PIT_FindFloorCeiling(FMultiBlockLinesIterator::CheckResult &cres, co
void P_GetFloorCeilingZ(FCheckPosition &tmf, int flags) void P_GetFloorCeilingZ(FCheckPosition &tmf, int flags)
{ {
sector_t *sec = (!(flags & FFCF_SAMESECTOR) || tmf.thing->Sector == NULL)? P_PointInSector(tmf.x, tmf.y) : tmf.thing->Sector; sector_t *sec = (!(flags & FFCF_SAMESECTOR) || tmf.thing->Sector == NULL)? P_PointInSector(tmf.x, tmf.y) : tmf.thing->Sector;
F3DFloor *ffc, *fff;
if (flags & FFCF_NOPORTALS) tmf.ceilingz = sec->NextHighestCeilingAt(tmf.thing, tmf.z + tmf.thing->height, flags, &tmf.floorsector, &ffc);
tmf.floorz = tmf.dropoffz = sec->NextLowestFloorAt(tmf.thing, tmf.z, flags, &tmf.ceilingsector, &fff);
if (fff)
{ {
tmf.thing->dropoffz = tmf.thing->floorz = sec->floorplane.ZatPoint(tmf.x, tmf.y); tmf.floorpic = *fff->top.texture;
tmf.thing->ceilingz = sec->ceilingplane.ZatPoint(tmf.x, tmf.y); tmf.floorterrain = fff->model->GetTerrain(fff->top.isceiling);
tmf.ceilingsector = tmf.floorsector = sec;
} }
else else
{ {
tmf.floorz = tmf.dropoffz = sec->LowestFloorAt(tmf.x, tmf.y, &tmf.floorsector); tmf.floorpic = tmf.floorsector->GetTexture(sector_t::floor);
tmf.ceilingz = sec->HighestCeilingAt(tmf.x, tmf.y, &tmf.ceilingsector); tmf.floorterrain = tmf.floorsector->GetTerrain(sector_t::floor);
} }
tmf.floorpic = tmf.floorsector->GetTexture(sector_t::floor); tmf.ceilingpic = ffc ? *ffc->bottom.texture : tmf.ceilingsector->GetTexture(sector_t::ceiling);
tmf.floorterrain = tmf.floorsector->GetTerrain(sector_t::floor);
tmf.ceilingpic = tmf.ceilingsector->GetTexture(sector_t::ceiling);
tmf.sector = sec; tmf.sector = sec;
for (unsigned int i = 0; i<sec->e->XFloor.ffloors.Size(); i++)
{
F3DFloor* rover = sec->e->XFloor.ffloors[i];
if (!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue;
fixed_t ff_bottom = rover->bottom.plane->ZatPoint(tmf.x, tmf.y);
fixed_t ff_top = rover->top.plane->ZatPoint(tmf.x, tmf.y);
if (ff_top > tmf.floorz)
{
// either with feet above the 3D floor or feet with less than 'stepheight' map units inside
if (ff_top <= tmf.z || (!(flags & FFCF_3DRESTRICT) && (ff_bottom < tmf.z && ff_top < tmf.z + tmf.thing->MaxStepHeight)))
{
tmf.dropoffz = tmf.floorz = ff_top;
tmf.floorpic = *rover->top.texture;
tmf.floorterrain = rover->model->GetTerrain(rover->top.isceiling);
tmf.floorsector = sec;
}
}
if (ff_bottom <= tmf.ceilingz && ff_bottom > tmf.z + tmf.thing->height)
{
tmf.ceilingz = ff_bottom;
tmf.ceilingpic = *rover->bottom.texture;
tmf.ceilingsector = sec;
}
}
} }
//========================================================================== //==========================================================================

View file

@ -31,6 +31,7 @@
#include "farchive.h" #include "farchive.h"
#include "r_utility.h" #include "r_utility.h"
#include "a_sharedglobal.h" #include "a_sharedglobal.h"
#include "p_local.h"
#include "r_data/colormaps.h" #include "r_data/colormaps.h"
@ -931,7 +932,7 @@ 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) fixed_t sector_t::NextHighestCeilingAt(fixed_t x, fixed_t y, fixed_t z, int flags, sector_t **resultsec, F3DFloor **resultffloor)
{ {
sector_t *sec = this; sector_t *sec = this;
fixed_t planeheight = FIXED_MIN; fixed_t planeheight = FIXED_MIN;
@ -951,7 +952,7 @@ fixed_t sector_t::NextHighestCeilingAt(fixed_t x, fixed_t y, fixed_t z, sector_t
return ffz; return ffz;
} }
} }
if (sec->PortalBlocksMovement(ceiling) || planeheight >= sec->SkyBoxes[ceiling]->threshold) if ((flags & FFCF_NOPORTALS) || sec->PortalBlocksMovement(ceiling) || planeheight >= sec->SkyBoxes[ceiling]->threshold)
{ // Use sector's floor { // Use sector's floor
if (resultffloor) *resultffloor = NULL; if (resultffloor) *resultffloor = NULL;
if (resultsec) *resultsec = sec; if (resultsec) *resultsec = sec;
@ -968,7 +969,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) fixed_t sector_t::NextLowestFloorAt(fixed_t x, fixed_t y, fixed_t z, int flags, fixed_t steph, sector_t **resultsec, F3DFloor **resultffloor)
{ {
sector_t *sec = this; sector_t *sec = this;
fixed_t planeheight = FIXED_MAX; fixed_t planeheight = FIXED_MAX;
@ -981,14 +982,20 @@ fixed_t sector_t::NextLowestFloorAt(fixed_t x, fixed_t y, fixed_t z, sector_t **
F3DFloor *ff = sec->e->XFloor.ffloors[i]; F3DFloor *ff = sec->e->XFloor.ffloors[i];
fixed_t ffz = ff->top.plane->ZatPoint(x, y); fixed_t ffz = ff->top.plane->ZatPoint(x, y);
if ((ff->flags & (FF_EXISTS | FF_SOLID)) == (FF_EXISTS | FF_SOLID) && z >= ffz) fixed_t ffb = ff->bottom.plane->ZatPoint(x, y);
{ // This floor is beneath our feet.
if (resultsec) *resultsec = sec; // either with feet above the 3D floor or feet with less than 'stepheight' map units inside
if (resultffloor) *resultffloor = ff; if ((ff->flags & (FF_EXISTS | FF_SOLID)) == (FF_EXISTS | FF_SOLID))
return ffz; {
if (z >= ffz || (!(flags & FFCF_3DRESTRICT) && (ffb < z && ffz < z + steph)))
{ // This floor is beneath our feet.
if (resultsec) *resultsec = sec;
if (resultffloor) *resultffloor = ff;
return ffz;
}
} }
} }
if (sec->PortalBlocksMovement(sector_t::floor) || planeheight <= sec->SkyBoxes[floor]->threshold) if ((flags & FFCF_NOPORTALS) || sec->PortalBlocksMovement(sector_t::floor) || planeheight <= sec->SkyBoxes[floor]->threshold)
{ // Use sector's floor { // Use sector's floor
if (resultffloor) *resultffloor = NULL; if (resultffloor) *resultffloor = NULL;
if (resultsec) *resultsec = sec; if (resultsec) *resultsec = sec;
@ -1217,44 +1224,3 @@ int side_t::GetLightLevel (bool foggy, int baselight, bool is3dlight, int *pfake
} }
return baselight; return baselight;
} }
#include "c_dispatch.h"
#include "d_player.h"
CCMD(highestceiling)
{
sector_t *sec;
fixed_t h = players[consoleplayer].mo->Sector->HighestCeilingAt(players[consoleplayer].mo, &sec);
Printf("Check at position %f,%f, height = %f, srcsector = %d dstsector = %d, srcgroup = %d, dstgroup = %d\n",
players[consoleplayer].mo->X() / 65536., players[consoleplayer].mo->Y() / 65536., h / 65536.,
players[consoleplayer].mo->Sector->sectornum, sec->sectornum, players[consoleplayer].mo->Sector->PortalGroup, sec->PortalGroup);
}
CCMD(lowestfloor)
{
sector_t *sec;
fixed_t h = players[consoleplayer].mo->Sector->LowestFloorAt(players[consoleplayer].mo, &sec);
Printf("Check at position %f,%f, height = %f, srcsector = %d dstsector = %d, srcgroup = %d, dstgroup = %d\n",
players[consoleplayer].mo->X() / 65536., players[consoleplayer].mo->Y() / 65536., h / 65536.,
players[consoleplayer].mo->Sector->sectornum, sec->sectornum, players[consoleplayer].mo->Sector->PortalGroup, sec->PortalGroup);
}
CCMD(nexthighestceiling)
{
sector_t *sec;
F3DFloor *ff;
fixed_t h = players[consoleplayer].mo->Sector->NextHighestCeilingAt(players[consoleplayer].mo, players[consoleplayer].mo->Top(), &sec, &ff);
Printf("Check at position %f,%f, height = %f, srcsector = %d dstsector = %d, srcgroup = %d, dstgroup = %d, 3dfloor = %d\n",
players[consoleplayer].mo->X() / 65536., players[consoleplayer].mo->Y() / 65536., h / 65536.,
players[consoleplayer].mo->Sector->sectornum, sec->sectornum, players[consoleplayer].mo->Sector->PortalGroup, sec->PortalGroup, !!ff);
}
CCMD(nextlowestfloor)
{
sector_t *sec;
F3DFloor *ff;
fixed_t h = players[consoleplayer].mo->Sector->NextLowestFloorAt(players[consoleplayer].mo, players[consoleplayer].mo->Z(), &sec, &ff);
Printf("Check at position %f,%f, height = %f, srcsector = %d dstsector = %d, srcgroup = %d, dstgroup = %d, 3dfloor = %d\n",
players[consoleplayer].mo->X() / 65536., players[consoleplayer].mo->Y() / 65536., h / 65536.,
players[consoleplayer].mo->Sector->sectornum, sec->sectornum, players[consoleplayer].mo->Sector->PortalGroup, sec->PortalGroup, !!ff);
}

View file

@ -796,17 +796,17 @@ struct sector_t
return LowestFloorAt(a->X(), a->Y(), resultsec); return LowestFloorAt(a->X(), a->Y(), resultsec);
} }
fixed_t NextHighestCeilingAt(fixed_t x, fixed_t y, fixed_t z, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL); fixed_t NextHighestCeilingAt(fixed_t x, fixed_t y, fixed_t z, int flags = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL);
fixed_t NextLowestFloorAt(fixed_t x, fixed_t y, fixed_t z, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL); fixed_t NextLowestFloorAt(fixed_t x, fixed_t y, fixed_t z, int flags = 0, fixed_t steph = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL);
fixed_t NextHighestCeilingAt(AActor *a, fixed_t z, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL) fixed_t NextHighestCeilingAt(AActor *a, fixed_t z, int flags = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL)
{ {
return NextHighestCeilingAt(a->X(), a->Y(), z, resultsec, resultffloor); return NextHighestCeilingAt(a->X(), a->Y(), z, flags, resultsec, resultffloor);
} }
fixed_t NextLowestFloorAt(AActor *a, fixed_t z, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL) fixed_t NextLowestFloorAt(AActor *a, fixed_t z, int flags, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL)
{ {
return NextLowestFloorAt(a->X(), a->Y(), z, resultsec, resultffloor); return NextLowestFloorAt(a->X(), a->Y(), z, flags, a->MaxStepHeight, resultsec, resultffloor);
} }
// Member variables // Member variables