- Added 3D Floor + Portal awareness, along with flags to turn off detection of both features.

This commit is contained in:
MajorCooke 2016-05-12 13:23:10 -05:00 committed by Christoph Oelckers
parent b91ed5dc5d
commit 2ba26693d1
2 changed files with 42 additions and 12 deletions

View file

@ -395,9 +395,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetGibHealth)
//==========================================================================
enum GZFlags
{
GZF_ABSOLUTEPOS = 1,
GZF_ABSOLUTEANG = 1 << 1,
GZF_CEILING = 1 << 2,
GZF_ABSOLUTEPOS = 1, // Use the absolute position instead of an offsetted one.
GZF_ABSOLUTEANG = 1 << 1, // Don't add the actor's angle to the parameter.
GZF_CEILING = 1 << 2, // Check the ceiling instead of the floor.
GZF_3DRESTRICT = 1 << 3, // Ignore midtextures and 3D floors above the pointer's z.
GZF_NOPORTALS = 1 << 4, // Don't pass through any portals.
GZF_NO3DFLOOR = 1 << 5, // Pass all 3D floors.
};
DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetZAt)
@ -419,9 +422,13 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetZAt)
}
else
{
// [MC] At any time, the NextLowest/Highest functions could be changed to include
// more FFC flags to check. Don't risk it by just passing flags straight to it.
DVector2 pos = { px, py };
int secnum;
double z = 0.;
int pflags = (flags & GZF_3DRESTRICT) ? FFCF_3DRESTRICT : 0;
if (flags & GZF_NOPORTALS) pflags |= FFCF_NOPORTALS;
if (!(flags & GZF_ABSOLUTEPOS))
{
@ -435,20 +442,40 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetZAt)
pos = mobj->Vec2Offset(pos.X * c + pos.Y * s, pos.X * s - pos.Y * c);
}
secnum = int(P_PointInSector(pos.X, pos.Y) - sectors);
int secnum = int(P_PointInSector(pos) - sectors);
if (secnum >= 0)
{
if (flags & GZF_CEILING)
{
//z = mobj->Sector->ceilingplane.ZatPoint(pos.X, pos.Y);
if ((flags & GZF_NO3DFLOOR) && (flags & GZF_NOPORTALS))
{
z = sectors[secnum].ceilingplane.ZatPoint(pos);
}
else if (flags & GZF_NO3DFLOOR)
{
z = sectors[secnum].HighestCeilingAt(pos);
}
else
{ // [MC] Handle strict 3D floors and portal toggling via the flags passed to it.
z = sectors[secnum].NextHighestCeilingAt(pos.X, pos.Y, mobj->Z(), mobj->Top(), pflags);
}
}
else
{
//z = mobj->Sector->floorplane.ZatPoint(pos.X, pos.Y);
if ((flags & GZF_NO3DFLOOR) && (flags & GZF_NOPORTALS))
{
z = sectors[secnum].floorplane.ZatPoint(pos);
}
else if (flags & GZF_NO3DFLOOR)
{
z = sectors[secnum].LowestFloorAt(pos);
}
else
{
z = sectors[secnum].NextLowestFloorAt(pos.X, pos.Y, mobj->Z(), pflags, mobj->MaxStepHeight);
}
}
}
ret->SetFloat(z);
return 1;

View file

@ -554,7 +554,10 @@ enum
// Flags for GetZAt
enum
{
GZF_ABSOLUTEPOS = 1,
GZF_ABSOLUTEANG = 1 << 1,
GZF_CEILING = 1 << 2,
GZF_ABSOLUTEPOS = 1, // Use the absolute position instead of an offsetted one.
GZF_ABSOLUTEANG = 1 << 1, // Don't add the actor's angle to the parameter.
GZF_CEILING = 1 << 2, // Check the ceiling instead of the floor.
GZF_3DRESTRICT = 1 << 3, // Ignore midtextures and 3D floors above the pointer's z.
GZF_NOPORTALS = 1 << 4, // Don't pass through any portals.
GZF_NO3DFLOOR = 1 << 5, // Pass all 3D floors.
};