mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-23 04:22:34 +00:00
- completed work on P_FindFloorCeiling and all functions it calls.
Note: The debug output is left in so that in cases of an error it can still be used.
This commit is contained in:
parent
d876a95152
commit
cfbb3bcbb2
3 changed files with 50 additions and 11 deletions
|
@ -194,8 +194,9 @@ static inline fixedvec2 FindRefPoint(line_t *ld, fixedvec2 pos)
|
|||
// only3d set means to only check against 3D floors and midtexes.
|
||||
//
|
||||
//==========================================================================
|
||||
bool ffcf_verbose;
|
||||
|
||||
static bool PIT_FindFloorCeiling(FMultiBlockLinesIterator::CheckResult &cres, const FBoundingBox &box, FCheckPosition &tmf, int flags)
|
||||
static bool PIT_FindFloorCeiling(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::CheckResult &cres, const FBoundingBox &box, FCheckPosition &tmf, int flags)
|
||||
{
|
||||
line_t *ld = cres.line;
|
||||
|
||||
|
@ -210,6 +211,12 @@ static bool PIT_FindFloorCeiling(FMultiBlockLinesIterator::CheckResult &cres, co
|
|||
|
||||
// A line has been hit
|
||||
|
||||
if (ffcf_verbose)
|
||||
{
|
||||
Printf("Hit line %d at position %f,%f, group %d\n",
|
||||
int(ld - lines), FIXED2FLOAT(cres.position.x), FIXED2FLOAT(cres.position.y), ld->frontsector->PortalGroup);
|
||||
}
|
||||
|
||||
if (!ld->backsector)
|
||||
{ // One sided line
|
||||
return true;
|
||||
|
@ -227,6 +234,8 @@ static bool PIT_FindFloorCeiling(FMultiBlockLinesIterator::CheckResult &cres, co
|
|||
{
|
||||
tmf.ceilingz = open.top;
|
||||
if (open.topsec != NULL) tmf.floorsector = open.topsec;
|
||||
if (ffcf_verbose) Printf(" Adjust ceilingz to %f\n", FIXED2FLOAT(open.top));
|
||||
mit.StopUp();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -238,6 +247,8 @@ static bool PIT_FindFloorCeiling(FMultiBlockLinesIterator::CheckResult &cres, co
|
|||
if (open.bottomsec != NULL) tmf.floorsector = open.bottomsec;
|
||||
tmf.touchmidtex = open.touchmidtex;
|
||||
tmf.abovemidtex = open.abovemidtex;
|
||||
if (ffcf_verbose) Printf(" Adjust floorz to %f\n", FIXED2FLOAT(open.bottom));
|
||||
if (tmf.floorz > tmf.dropoffz + tmf.thing->MaxDropOffHeight) mit.StopDown();
|
||||
}
|
||||
else if (open.bottom == tmf.floorz)
|
||||
{
|
||||
|
@ -245,9 +256,11 @@ static bool PIT_FindFloorCeiling(FMultiBlockLinesIterator::CheckResult &cres, co
|
|||
tmf.abovemidtex |= open.abovemidtex;
|
||||
}
|
||||
|
||||
if (open.lowfloor < tmf.dropoffz)
|
||||
if (open.lowfloor < tmf.dropoffz && open.lowfloor > FIXED_MIN)
|
||||
{
|
||||
tmf.dropoffz = open.lowfloor;
|
||||
if (ffcf_verbose) Printf(" Adjust dropoffz to %f\n", FIXED2FLOAT(open.bottom));
|
||||
if (tmf.floorz > tmf.dropoffz + tmf.thing->MaxDropOffHeight) mit.StopDown();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -266,8 +279,8 @@ 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;
|
||||
|
||||
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);
|
||||
tmf.ceilingz = sec->NextHighestCeilingAt(tmf.thing, tmf.z + tmf.thing->height, flags, &tmf.ceilingsector, &ffc);
|
||||
tmf.floorz = tmf.dropoffz = sec->NextLowestFloorAt(tmf.thing, tmf.z, flags, &tmf.floorsector, &fff);
|
||||
|
||||
if (fff)
|
||||
{
|
||||
|
@ -314,6 +327,7 @@ void P_FindFloorCeiling(AActor *actor, int flags)
|
|||
actor->floorsector = tmf.floorsector;
|
||||
actor->ceilingpic = tmf.ceilingpic;
|
||||
actor->ceilingsector = tmf.ceilingsector;
|
||||
if (ffcf_verbose) Printf("Starting with ceilingz = %f, floorz = %f\n", FIXED2FLOAT(tmf.ceilingz), FIXED2FLOAT(tmf.floorz));
|
||||
|
||||
tmf.touchmidtex = false;
|
||||
tmf.abovemidtex = false;
|
||||
|
@ -330,7 +344,7 @@ void P_FindFloorCeiling(AActor *actor, int flags)
|
|||
|
||||
while ((mit.Next(&cres)))
|
||||
{
|
||||
PIT_FindFloorCeiling(cres, mit.Box(), tmf, flags|cres.portalflags);
|
||||
PIT_FindFloorCeiling(mit, cres, mit.Box(), tmf, flags|cres.portalflags);
|
||||
}
|
||||
|
||||
if (tmf.touchmidtex) tmf.dropoffz = tmf.floorz;
|
||||
|
@ -355,6 +369,13 @@ void P_FindFloorCeiling(AActor *actor, int flags)
|
|||
}
|
||||
}
|
||||
|
||||
// Debug CCMD for checking errors in the MultiBlockLinesIterator (needs to be removed when this code is complete)
|
||||
CCMD(ffcf)
|
||||
{
|
||||
ffcf_verbose = true;
|
||||
P_FindFloorCeiling(players[0].mo, 0);
|
||||
ffcf_verbose = false;
|
||||
}
|
||||
//==========================================================================
|
||||
//
|
||||
// TELEPORT MOVE
|
||||
|
@ -404,7 +425,7 @@ bool P_TeleportMove(AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefra
|
|||
|
||||
while (mit.Next(&cres))
|
||||
{
|
||||
PIT_FindFloorCeiling(cres, mit.Box(), tmf, 0);
|
||||
PIT_FindFloorCeiling(mit, cres, mit.Box(), tmf, 0);
|
||||
}
|
||||
thing->SetZ(savedz);
|
||||
|
||||
|
|
|
@ -162,10 +162,28 @@ void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef,
|
|||
front = linedef->frontsector;
|
||||
back = linedef->backsector;
|
||||
|
||||
fc = front->ceilingplane.ZatPoint (x, y);
|
||||
ff = front->floorplane.ZatPoint (x, y);
|
||||
bc = back->ceilingplane.ZatPoint (x, y);
|
||||
bf = back->floorplane.ZatPoint (x, y);
|
||||
if (!(flags & FFCF_NOPORTALS) && !linedef->frontsector->PortalBlocksMovement(sector_t::ceiling) &&
|
||||
linedef->backsector->SkyBoxes[sector_t::ceiling] &&
|
||||
linedef->frontsector->SkyBoxes[sector_t::ceiling]->Sector->PortalGroup == linedef->backsector->SkyBoxes[sector_t::ceiling]->Sector->PortalGroup)
|
||||
{
|
||||
fc = bc = FIXED_MAX;
|
||||
}
|
||||
else
|
||||
{
|
||||
fc = front->ceilingplane.ZatPoint(x, y);
|
||||
bc = back->ceilingplane.ZatPoint(x, y);
|
||||
}
|
||||
if (!(flags & FFCF_NOPORTALS) && !linedef->frontsector->PortalBlocksMovement(sector_t::floor) &&
|
||||
linedef->backsector->SkyBoxes[sector_t::floor] &&
|
||||
linedef->frontsector->SkyBoxes[sector_t::floor]->Sector->PortalGroup == linedef->backsector->SkyBoxes[sector_t::floor]->Sector->PortalGroup)
|
||||
{
|
||||
ff = bf = FIXED_MIN;
|
||||
}
|
||||
else
|
||||
{
|
||||
ff = front->floorplane.ZatPoint(x, y);
|
||||
bf = back->floorplane.ZatPoint(x, y);
|
||||
}
|
||||
|
||||
/*Printf ("]]]]]] %d %d\n", ff, bf);*/
|
||||
|
||||
|
|
|
@ -205,7 +205,7 @@ class FMultiBlockLinesIterator
|
|||
fixedvec2 offset;
|
||||
short basegroup;
|
||||
short portalflags;
|
||||
WORD index;
|
||||
short index;
|
||||
bool continueup;
|
||||
bool continuedown;
|
||||
FBlockLinesIterator blockIterator;
|
||||
|
|
Loading…
Reference in a new issue