mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-28 06:53:58 +00:00
- 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:
parent
dc37f78566
commit
6132f6971a
4 changed files with 34 additions and 95 deletions
|
@ -4184,12 +4184,12 @@ bool DLevelScript::DoCheckActorTexture(int tid, AActor *activator, int string, b
|
|||
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
return tex == TexMan[secpic];
|
||||
|
|
|
@ -261,51 +261,24 @@ static bool PIT_FindFloorCeiling(FMultiBlockLinesIterator::CheckResult &cres, co
|
|||
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;
|
||||
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.thing->ceilingz = sec->ceilingplane.ZatPoint(tmf.x, tmf.y);
|
||||
tmf.ceilingsector = tmf.floorsector = sec;
|
||||
tmf.floorpic = *fff->top.texture;
|
||||
tmf.floorterrain = fff->model->GetTerrain(fff->top.isceiling);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmf.floorz = tmf.dropoffz = sec->LowestFloorAt(tmf.x, tmf.y, &tmf.floorsector);
|
||||
tmf.ceilingz = sec->HighestCeilingAt(tmf.x, tmf.y, &tmf.ceilingsector);
|
||||
tmf.floorpic = tmf.floorsector->GetTexture(sector_t::floor);
|
||||
tmf.floorterrain = tmf.floorsector->GetTerrain(sector_t::floor);
|
||||
}
|
||||
tmf.floorpic = tmf.floorsector->GetTexture(sector_t::floor);
|
||||
tmf.floorterrain = tmf.floorsector->GetTerrain(sector_t::floor);
|
||||
tmf.ceilingpic = tmf.ceilingsector->GetTexture(sector_t::ceiling);
|
||||
|
||||
tmf.ceilingpic = ffc ? *ffc->bottom.texture : tmf.ceilingsector->GetTexture(sector_t::ceiling);
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "farchive.h"
|
||||
#include "r_utility.h"
|
||||
#include "a_sharedglobal.h"
|
||||
#include "p_local.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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
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
|
||||
if (resultffloor) *resultffloor = NULL;
|
||||
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;
|
||||
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];
|
||||
|
||||
fixed_t ffz = ff->top.plane->ZatPoint(x, y);
|
||||
if ((ff->flags & (FF_EXISTS | FF_SOLID)) == (FF_EXISTS | FF_SOLID) && z >= ffz)
|
||||
{ // This floor is beneath our feet.
|
||||
if (resultsec) *resultsec = sec;
|
||||
if (resultffloor) *resultffloor = ff;
|
||||
return ffz;
|
||||
fixed_t ffb = ff->bottom.plane->ZatPoint(x, y);
|
||||
|
||||
// either with feet above the 3D floor or feet with less than 'stepheight' map units inside
|
||||
if ((ff->flags & (FF_EXISTS | FF_SOLID)) == (FF_EXISTS | FF_SOLID))
|
||||
{
|
||||
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
|
||||
if (resultffloor) *resultffloor = NULL;
|
||||
if (resultsec) *resultsec = sec;
|
||||
|
@ -1217,44 +1224,3 @@ int side_t::GetLightLevel (bool foggy, int baselight, bool is3dlight, int *pfake
|
|||
}
|
||||
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);
|
||||
}
|
||||
|
|
12
src/r_defs.h
12
src/r_defs.h
|
@ -796,17 +796,17 @@ struct sector_t
|
|||
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 NextLowestFloorAt(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, 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
|
||||
|
|
Loading…
Reference in a new issue