- added a few more direct native entry points.

This commit is contained in:
Christoph Oelckers 2018-11-29 00:27:09 +01:00 committed by drfrag
parent 03b7d84058
commit 4ac866aedc
12 changed files with 97 additions and 75 deletions

View file

@ -45,11 +45,11 @@ inline double secplane_t::ZatPoint(const AActor *ac) const
inline double sector_t::HighestCeilingAt(AActor *a, sector_t **resultsec)
{
return HighestCeilingAt(a->Pos(), resultsec);
return ::HighestCeilingAt(this, a->X(), a->Y(), resultsec);
}
inline double sector_t::LowestFloorAt(AActor *a, sector_t **resultsec)
{
return LowestFloorAt(a->Pos(), resultsec);
return ::LowestFloorAt(this, a->X(), a->Y(), resultsec);
}

View file

@ -4715,7 +4715,7 @@ bool DLevelScript::DoCheckActorTexture(int tid, AActor *activator, int string, b
if (floor)
{
actor->Sector->NextLowestFloorAt(actor->X(), actor->Y(), actor->Z(), 0, actor->MaxStepHeight, &resultsec, &resffloor);
NextLowestFloorAt(actor->Sector, actor->X(), actor->Y(), actor->Z(), 0, actor->MaxStepHeight, &resultsec, &resffloor);
secpic = resffloor ? *resffloor->top.texture : resultsec->planes[sector_t::floor].Texture;
}
else

View file

@ -592,7 +592,7 @@ DEFINE_ACTION_FUNCTION(AActor, GetZAt)
}
else if (flags & GZF_NO3DFLOOR)
{
z = sec->HighestCeilingAt(pos);
z = HighestCeilingAt(sec, pos.X, pos.Y);
}
else
{ // [MC] Handle strict 3D floors and portal toggling via the flags passed to it.
@ -607,11 +607,11 @@ DEFINE_ACTION_FUNCTION(AActor, GetZAt)
}
else if (flags & GZF_NO3DFLOOR)
{
z = sec->LowestFloorAt(pos);
z = LowestFloorAt(sec, pos.X, pos.Y);
}
else
{
z = sec->NextLowestFloorAt(pos.X, pos.Y, mobj->Z(), pflags, mobj->MaxStepHeight);
z = NextLowestFloorAt(sec, pos.X, pos.Y, mobj->Z(), pflags, mobj->MaxStepHeight);
}
}
}

View file

@ -408,7 +408,7 @@ DDoor::DDoor (sector_t *sec, EVlDoor type, double speed, int delay, int lightTag
}
else
{
height = sec->FindLowestCeilingPoint(&m_BotSpot);
height = FindLowestCeilingPoint(sec, &m_BotSpot);
m_BotDist = sec->ceilingplane.PointToDist (m_BotSpot, height);
}
m_OldFloorDist = sec->floorplane.fD();

View file

@ -348,7 +348,7 @@ bool P_CreateFloor(sector_t *sec, DFloor::EFloor floortype, line_t *line,
case DFloor::floorRaiseToLowestCeiling:
floor->m_Direction = 1;
newheight = sec->FindLowestCeilingSurrounding(&spot) - height;
ceilingheight = sec->FindLowestCeilingPoint(&spot2);
ceilingheight = FindLowestCeilingPoint(sec, &spot2);
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
if (sec->floorplane.ZatPointDist(spot2, floor->m_FloorDestDist) > ceilingheight)
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot2, ceilingheight - height);
@ -374,13 +374,13 @@ bool P_CreateFloor(sector_t *sec, DFloor::EFloor floortype, line_t *line,
case DFloor::floorRaiseAndCrush:
floor->m_Direction = 1;
newheight = sec->FindLowestCeilingPoint(&spot) - 8;
newheight = FindLowestCeilingPoint(sec, &spot) - 8;
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
break;
case DFloor::floorRaiseToCeiling:
floor->m_Direction = 1;
newheight = sec->FindLowestCeilingPoint(&spot) - height;
newheight = FindLowestCeilingPoint(sec, &spot) - height;
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
break;
@ -399,7 +399,7 @@ bool P_CreateFloor(sector_t *sec, DFloor::EFloor floortype, line_t *line,
case DFloor::floorLowerToCeiling:
// [RH] Essentially instantly raises the floor to the ceiling
floor->m_Direction = -1;
newheight = sec->FindLowestCeilingPoint(&spot) - height;
newheight = FindLowestCeilingPoint(sec, &spot) - height;
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
break;

View file

@ -351,7 +351,7 @@ void P_GetFloorCeilingZ(FCheckPosition &tmf, int flags)
F3DFloor *ffc, *fff;
tmf.ceilingz = NextHighestCeilingAt(sec, tmf.pos.X, tmf.pos.Y, tmf.pos.Z, tmf.pos.Z + tmf.thing->Height, flags, &tmf.ceilingsector, &ffc);
tmf.floorz = tmf.dropoffz = sec->NextLowestFloorAt(tmf.pos.X, tmf.pos.Y, tmf.pos.Z, flags, tmf.thing->MaxStepHeight, &tmf.floorsector, &fff);
tmf.floorz = tmf.dropoffz = NextLowestFloorAt(sec, tmf.pos.X, tmf.pos.Y, tmf.pos.Z, flags, tmf.thing->MaxStepHeight, &tmf.floorsector, &fff);
if (fff)
{
@ -1826,8 +1826,8 @@ bool P_CheckPosition(AActor *thing, const DVector2 &pos, FCheckPosition &tm, boo
else
{
// With noclip2, we must ignore 3D floors and go right to the uppermost ceiling and lowermost floor.
tm.floorz = tm.dropoffz = newsec->LowestFloorAt(pos, &tm.floorsector);
tm.ceilingz = newsec->HighestCeilingAt(pos, &tm.ceilingsector);
tm.floorz = tm.dropoffz = LowestFloorAt(newsec, pos.X, pos.Y, &tm.floorsector);
tm.ceilingz = HighestCeilingAt(newsec, pos.X, pos.Y, &tm.ceilingsector);
tm.floorpic = tm.floorsector->GetTexture(sector_t::floor);
tm.floorterrain = tm.floorsector->GetTerrain(sector_t::floor);
tm.ceilingpic = tm.ceilingsector->GetTexture(sector_t::ceiling);

View file

@ -211,7 +211,7 @@ void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef, co
{
// We must check through the portal for the actual dropoff.
// If there's no lines in the lower sections we'd never get a usable value otherwise.
open.lowfloor = back->NextLowestFloorAt(pos.X, pos.Y, back->GetPortalPlaneZ(sector_t::floor) - EQUAL_EPSILON);
open.lowfloor = NextLowestFloorAt(back, pos.X, pos.Y, back->GetPortalPlaneZ(sector_t::floor) - EQUAL_EPSILON);
}
}
else
@ -225,7 +225,7 @@ void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef, co
{
// We must check through the portal for the actual dropoff.
// If there's no lines in the lower sections we'd never get a usable value otherwise.
open.lowfloor = front->NextLowestFloorAt(pos.X, pos.Y, front->GetPortalPlaneZ(sector_t::floor) - EQUAL_EPSILON);
open.lowfloor = NextLowestFloorAt(front, pos.X, pos.Y, front->GetPortalPlaneZ(sector_t::floor) - EQUAL_EPSILON);
}
}
open.frontfloorplane = front->floorplane;

View file

@ -360,7 +360,7 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, double height,
plat->m_Crush = 10; //jff 3/14/98 crush anything in the way
// set up toggling between ceiling, floor inclusive
newheight = sec->FindLowestCeilingPoint (&spot);
newheight = FindLowestCeilingPoint(sec, &spot);
plat->m_Low = sec->floorplane.PointToDist (spot, newheight);
plat->m_High = sec->floorplane.fD();
plat->m_Status = DPlat::down;

View file

@ -654,38 +654,38 @@ double sector_t::FindHighestFloorPoint (vertex_t **v) const
//
// Find the lowest point on the ceiling of the sector
//
double sector_t::FindLowestCeilingPoint (vertex_t **v) const
double FindLowestCeilingPoint (const sector_t *sector, vertex_t **v)
{
double height = FLT_MAX;
double probeheight;
vertex_t *spot = NULL;
vertex_t *spot = nullptr;
if (!ceilingplane.isSlope())
if (!sector->ceilingplane.isSlope())
{
if (v != NULL)
if (v != nullptr)
{
if (Lines.Size() == 0) *v = &level.vertexes[0];
else *v = Lines[0]->v1;
if (sector->Lines.Size() == 0) *v = &level.vertexes[0];
else *v = sector->Lines[0]->v1;
}
return ceilingplane.fD();
return sector->ceilingplane.fD();
}
for (auto line : Lines)
for (auto line : sector->Lines)
{
probeheight = ceilingplane.ZatPoint(line->v1);
probeheight = sector->ceilingplane.ZatPoint(line->v1);
if (probeheight < height)
{
height = probeheight;
spot = line->v1;
}
probeheight = ceilingplane.ZatPoint(line->v2);
probeheight = sector->ceilingplane.ZatPoint(line->v2);
if (probeheight < height)
{
height = probeheight;
spot = line->v2;
}
}
if (v != NULL)
if (v != nullptr)
*v = spot;
return height;
}
@ -932,17 +932,16 @@ void CheckPortalPlane(sector_t *sector, int plane)
//
//===========================================================================
double sector_t::HighestCeilingAt(const DVector2 &p, sector_t **resultsec)
double HighestCeilingAt(sector_t *check, double x, double y, sector_t **resultsec)
{
sector_t *check = this;
double planeheight = -FLT_MAX;
DVector2 pos = p;
DVector2 pos(x, y);
// Continue until we find a blocking portal or a portal below where we actually are.
while (!check->PortalBlocksMovement(ceiling) && planeheight < check->GetPortalPlaneZ(ceiling))
while (!check->PortalBlocksMovement(sector_t::ceiling) && planeheight < check->GetPortalPlaneZ(sector_t::ceiling))
{
pos += check->GetPortalDisplacement(ceiling);
planeheight = check->GetPortalPlaneZ(ceiling);
pos += check->GetPortalDisplacement(sector_t::ceiling);
planeheight = check->GetPortalPlaneZ(sector_t::ceiling);
check = P_PointInSector(pos);
}
if (resultsec) *resultsec = check;
@ -955,17 +954,16 @@ double sector_t::HighestCeilingAt(const DVector2 &p, sector_t **resultsec)
//
//===========================================================================
double sector_t::LowestFloorAt(const DVector2 &p, sector_t **resultsec)
double LowestFloorAt(sector_t *check, double x, double y, sector_t **resultsec)
{
sector_t *check = this;
double planeheight = FLT_MAX;
DVector2 pos = p;
DVector2 pos(x, y);
// Continue until we find a blocking portal or a portal above where we actually are.
while (!check->PortalBlocksMovement(floor) && planeheight > check->GetPortalPlaneZ(floor))
while (!check->PortalBlocksMovement(sector_t::floor) && planeheight > check->GetPortalPlaneZ(sector_t::floor))
{
pos += check->GetPortalDisplacement(floor);
planeheight = check->GetPortalPlaneZ(ceiling);
pos += check->GetPortalDisplacement(sector_t::floor);
planeheight = check->GetPortalPlaneZ(sector_t::ceiling);
check = P_PointInSector(pos);
}
if (resultsec) *resultsec = check;
@ -1025,9 +1023,8 @@ double NextHighestCeilingAt(sector_t *sec, double x, double y, double bottomz, d
//
//=====================================================================================
double sector_t::NextLowestFloorAt(double x, double y, double z, int flags, double steph, sector_t **resultsec, F3DFloor **resultffloor)
double NextLowestFloorAt(sector_t *sec, double x, double y, double z, int flags, double steph, sector_t **resultsec, F3DFloor **resultffloor)
{
sector_t *sec = this;
double planeheight = FLT_MAX;
while (true)
{
@ -1053,7 +1050,7 @@ double sector_t::NextLowestFloorAt(double x, double y, double z, int flags, doub
}
}
}
if ((flags & FFCF_NOPORTALS) || sec->PortalBlocksMovement(sector_t::floor) || planeheight <= sec->GetPortalPlaneZ(floor))
if ((flags & FFCF_NOPORTALS) || sec->PortalBlocksMovement(sector_t::floor) || planeheight <= sec->GetPortalPlaneZ(sector_t::floor))
{ // Use sector's floor
if (resultffloor) *resultffloor = NULL;
if (resultsec) *resultsec = sec;
@ -1061,10 +1058,10 @@ double sector_t::NextLowestFloorAt(double x, double y, double z, int flags, doub
}
else
{
DVector2 pos = sec->GetPortalDisplacement(floor);
DVector2 pos = sec->GetPortalDisplacement(sector_t::floor);
x += pos.X;
y += pos.Y;
planeheight = sec->GetPortalPlaneZ(floor);
planeheight = sec->GetPortalPlaneZ(sector_t::floor);
sec = P_PointInSector(x, y);
}
}
@ -1076,14 +1073,14 @@ double sector_t::NextLowestFloorAt(double x, double y, double z, int flags, doub
//
//===========================================================================
double sector_t::GetFriction(int plane, double *pMoveFac) const
double GetFriction(const sector_t *self, int plane, double *pMoveFac)
{
if (Flags & SECF_FRICTION)
if (self->Flags & SECF_FRICTION)
{
if (pMoveFac) *pMoveFac = movefactor;
return friction;
if (pMoveFac) *pMoveFac = self->movefactor;
return self->friction;
}
FTerrainDef *terrain = &Terrains[GetTerrain(plane)];
FTerrainDef *terrain = &Terrains[self->GetTerrain(plane)];
if (terrain->Friction != 0)
{
if (pMoveFac) *pMoveFac = terrain->MoveFactor;

View file

@ -632,7 +632,6 @@ public:
double FindNextHighestCeiling(vertex_t **v) const; // jff 2/04/98
int FindMinSurroundingLight (int max) const;
sector_t *NextSpecialSector (int type, sector_t *prev) const; // [RH]
double FindLowestCeilingPoint(vertex_t **v) const;
double FindHighestFloorPoint(vertex_t **v) const;
void RemoveForceField();
int Index() const;
@ -958,10 +957,6 @@ public:
void SetSpecial(const secspecial_t *spec);
bool PlaneMoving(int pos);
// Portal-aware height calculation
double HighestCeilingAt(const DVector2 &a, sector_t **resultsec = NULL);
double LowestFloorAt(const DVector2 &a, sector_t **resultsec = NULL);
inline double HighestCeilingAt(AActor *a, sector_t **resultsec = NULL);
inline double LowestFloorAt(AActor *a, sector_t **resultsec = NULL);
@ -970,8 +965,6 @@ public:
return floorplane.Normal() == -ceilingplane.Normal() && floorplane.D == -ceilingplane.D;
}
double NextLowestFloorAt(double x, double y, double z, int flags = 0, double steph = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL);
// Member variables
double CenterFloor() const { return floorplane.ZatPoint(centerspot); }
double CenterCeiling() const { return ceilingplane.ZatPoint(centerspot); }
@ -1616,8 +1609,10 @@ double FindShortestTextureAround(sector_t *sector); // jff 2/04/98
double FindShortestUpperAround(sector_t *sector); // jff 2/04/98
sector_t *FindModelFloorSector(sector_t *sec, double floordestheight); // jff 2/04/98
sector_t *FindModelCeilingSector(sector_t *sec, double floordestheight); // jff 2/04/98
double FindLowestCeilingPoint(const sector_t *sec, vertex_t **v);
double NextHighestCeilingAt(sector_t *sec, double x, double y, double bottomz, double topz, int flags = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL);
double NextLowestFloorAt(sector_t *sec, double x, double y, double z, int flags = 0, double steph = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL);
// This setup is to allow the VM call directily into the implementation.
// With a member function this may be subject to OS implementation details, e.g. on Windows 32 bit members use a different calling convention than regular functions.
@ -1633,7 +1628,9 @@ void SetColor(sector_t *sector, int color, int desat);
void SetFade(sector_t *sector, int color);
int GetFloorLight(const sector_t *);
int GetCeilingLight(const sector_t *);
double GetFriction(const sector_t *self, int plane, double *movefac);
double HighestCeilingAt(sector_t *sec, double x, double y, sector_t **resultsec = nullptr);
double LowestFloorAt(sector_t *sec, double x, double y, sector_t **resultsec = nullptr);
inline void sector_t::RemoveForceField() { return ::RemoveForceField(this); }
inline bool sector_t::PlaneMoving(int pos) { return ::PlaneMoving(this, pos); }
@ -1647,6 +1644,7 @@ inline void sector_t::SetColor(PalEntry pe, int desat) { ::SetColor(this, pe, de
inline void sector_t::SetFade(PalEntry pe) { ::SetFade(this, pe); }
inline int sector_t::GetFloorLight() const { return ::GetFloorLight(this); }
inline int sector_t::GetCeilingLight() const { return ::GetCeilingLight(this); }
inline double sector_t::GetFriction(int plane, double *movefac) const { return ::GetFriction(this, plane, movefac); }
#endif

View file

@ -127,34 +127,34 @@ DEFINE_ACTION_FUNCTION(_Sector, FindHighestFloorPoint)
if (numret > 1) ret[1].SetPointer(v);
return numret;
}
DEFINE_ACTION_FUNCTION(_Sector, FindLowestCeilingPoint)
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, FindLowestCeilingPoint, FindLowestCeilingPoint)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
vertex_t *v;
double h = self->FindLowestCeilingPoint(&v);
double h = FindLowestCeilingPoint(self, &v);
if (numret > 0) ret[0].SetFloat(h);
if (numret > 1) ret[1].SetPointer(v);
return numret;
}
DEFINE_ACTION_FUNCTION(_Sector, HighestCeilingAt)
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, HighestCeilingAt, HighestCeilingAt)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
PARAM_FLOAT(x);
PARAM_FLOAT(y);
sector_t *s;
double h = self->HighestCeilingAt(DVector2(x, y), &s);
double h = HighestCeilingAt(self, x, y, &s);
if (numret > 0) ret[0].SetFloat(h);
if (numret > 1) ret[1].SetPointer(s);
return numret;
}
DEFINE_ACTION_FUNCTION(_Sector, LowestFloorAt)
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, LowestFloorAt, LowestFloorAt)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
PARAM_FLOAT(x);
PARAM_FLOAT(y);
sector_t *s;
double h = self->LowestFloorAt(DVector2(x, y), &s);
double h = LowestFloorAt(self, x, y, &s);
if (numret > 0) ret[0].SetFloat(h);
if (numret > 1) ret[1].SetPointer(s);
return numret;
@ -177,7 +177,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, NextHighestCeilingAt, NextHighestCeilingA
if (numret > 0) ret[0].SetFloat(resultheight);
return numret;
}
DEFINE_ACTION_FUNCTION(_Sector, NextLowestFloorAt)
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, NextLowestFloorAt, NextLowestFloorAt)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
PARAM_FLOAT(x);
@ -187,7 +187,7 @@ DEFINE_ACTION_FUNCTION(_Sector, NextLowestFloorAt)
PARAM_FLOAT(steph);
sector_t *resultsec;
F3DFloor *resultff;
double resultheight = self->NextLowestFloorAt(x, y, z, flags, steph, &resultsec, &resultff);
double resultheight = NextLowestFloorAt(self, x, y, z, flags, steph, &resultsec, &resultff);
if (numret > 2) ret[2].SetPointer(resultff);
if (numret > 1) ret[1].SetPointer(resultsec);
@ -195,7 +195,7 @@ DEFINE_ACTION_FUNCTION(_Sector, NextLowestFloorAt)
return numret;
}
DEFINE_ACTION_FUNCTION(_Sector, GetFriction)
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, GetFriction, GetFriction)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
PARAM_INT(plane);
@ -205,15 +205,14 @@ DEFINE_ACTION_FUNCTION(_Sector, GetFriction)
if (numret > 1) ret[1].SetFloat(mf);
return numret;
}
DEFINE_ACTION_FUNCTION(_Sector, TriggerSectorActions)
static void GetPortalDisplacement(sector_t *sec, int plane, DVector2 *result)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
PARAM_OBJECT(thing, AActor);
PARAM_INT(activation);
ACTION_RETURN_BOOL(self->TriggerSectorActions(thing, activation));
*result = sec->GetPortalDisplacement(plane);
}
DEFINE_ACTION_FUNCTION(_Sector, GetPortalDisplacement)
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, GetPortalDisplacement, GetPortalDisplacement)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
PARAM_INT(pos);

View file

@ -431,7 +431,6 @@ struct Sector native play
native int GetOppositePortalGroup(int plane);
native double CenterFloor();
native double CenterCeiling();
native bool TriggerSectorActions(Actor thing, int activation);
native int MoveFloor(double speed, double dest, int crush, int direction, bool hexencrush, bool instant = false);
native int MoveCeiling(double speed, double dest, int crush, int direction, bool hexencrush);
@ -490,7 +489,36 @@ struct Sector native play
{
return Level.GetUDMFString(LevelLocals.UDMF_Sector, Index(), nm);
}
//===========================================================================
//
//
//
//===========================================================================
bool TriggerSectorActions(Actor thing, int activation)
{
let act = SecActTarget;
bool res = false;
while (act != null)
{
Actor next = act.tracer;
if (act.TriggerAction(thing, activation))
{
if (act.bStandStill)
{
act.Destroy();
}
res = true;
}
act = SectorAction(next);
}
return res;
}
native clearscope int GetHealth(SectorPart part);
native void SetHealth(SectorPart part, int newhealth);
}