Exported LinePortals

Added helper functions for lines related to portals
This commit is contained in:
Boondorl 2023-01-15 15:29:23 -05:00 committed by Christoph Oelckers
commit dd7cb8649f
7 changed files with 110 additions and 0 deletions

View file

@ -845,11 +845,31 @@ inline line_t *line_t::getPortalDestination() const
return portalindex >= GetLevel()->linePortals.Size() ? (line_t*)nullptr : GetLevel()->linePortals[portalindex].mDestination;
}
inline int line_t::getPortalFlags() const
{
return portalindex >= GetLevel()->linePortals.Size() ? 0 : GetLevel()->linePortals[portalindex].mFlags;
}
inline int line_t::getPortalAlignment() const
{
return portalindex >= GetLevel()->linePortals.Size() ? 0 : GetLevel()->linePortals[portalindex].mAlign;
}
inline int line_t::getPortalType() const
{
return portalindex >= GetLevel()->linePortals.Size() ? 0 : GetLevel()->linePortals[portalindex].mType;
}
inline DVector2 line_t::getPortalDisplacement() const
{
return portalindex >= GetLevel()->linePortals.Size() ? DVector2(0., 0.) : GetLevel()->linePortals[portalindex].mDisplacement;
}
inline DAngle line_t::getPortalAngleDiff() const
{
return portalindex >= GetLevel()->linePortals.Size() ? DAngle::fromDeg(0.) : GetLevel()->linePortals[portalindex].mAngleDiff;
}
inline bool line_t::hitSkyWall(AActor* mo) const
{
return backsector &&

View file

@ -1504,7 +1504,11 @@ struct line_t : public linebase_t
inline bool isLinePortal() const;
inline bool isVisualPortal() const;
inline line_t *getPortalDestination() const;
inline int getPortalFlags() const;
inline int getPortalAlignment() const;
inline int getPortalType() const;
inline DVector2 getPortalDisplacement() const;
inline DAngle getPortalAngleDiff() const;
inline bool hitSkyWall(AActor* mo) const;
int Index() const { return linenum; }

View file

@ -51,6 +51,17 @@ DEFINE_FIELD(FSectorPortal, mDisplacement);
DEFINE_FIELD(FSectorPortal, mPlaneZ);
DEFINE_FIELD(FSectorPortal, mSkybox);
DEFINE_FIELD(FLinePortal, mOrigin);
DEFINE_FIELD(FLinePortal, mDestination);
DEFINE_FIELD(FLinePortal, mDisplacement);
DEFINE_FIELD(FLinePortal, mType);
DEFINE_FIELD(FLinePortal, mFlags);
DEFINE_FIELD(FLinePortal, mDefFlags);
DEFINE_FIELD(FLinePortal, mAlign);
DEFINE_FIELD(FLinePortal, mAngleDiff);
DEFINE_FIELD(FLinePortal, mSinRot);
DEFINE_FIELD(FLinePortal, mCosRot);
//============================================================================
//
// BuildBlockmap

View file

@ -708,6 +708,10 @@ void InitThingdef()
sectorportalstruct->Size = sizeof(FSectorPortal);
sectorportalstruct->Align = alignof(FSectorPortal);
auto lineportalstruct = NewStruct("LinePortal", nullptr, true);
lineportalstruct->Size = sizeof(FLinePortal);
lineportalstruct->Align = alignof(FLinePortal);
auto playerclassstruct = NewStruct("PlayerClass", nullptr, true);
playerclassstruct->Size = sizeof(FPlayerClass);
playerclassstruct->Align = alignof(FPlayerClass);

View file

@ -1199,12 +1199,36 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, SetXOffset, SetXOffset)
return self->getPortalAlignment();
}
DEFINE_ACTION_FUNCTION(_Line, getPortalFlags)
{
PARAM_SELF_STRUCT_PROLOGUE(line_t);
ACTION_RETURN_INT(self->getPortalFlags());
}
DEFINE_ACTION_FUNCTION_NATIVE(_Line, getPortalAlignment, getPortalAlignment)
{
PARAM_SELF_STRUCT_PROLOGUE(line_t);
ACTION_RETURN_INT(self->getPortalAlignment());
}
DEFINE_ACTION_FUNCTION(_Line, getPortalType)
{
PARAM_SELF_STRUCT_PROLOGUE(line_t);
ACTION_RETURN_INT(self->getPortalType());
}
DEFINE_ACTION_FUNCTION(_Line, getPortalDisplacement)
{
PARAM_SELF_STRUCT_PROLOGUE(line_t);
ACTION_RETURN_VEC2(self->getPortalDisplacement());
}
DEFINE_ACTION_FUNCTION(_Line, getPortalAngleDiff)
{
PARAM_SELF_STRUCT_PROLOGUE(line_t);
ACTION_RETURN_FLOAT(self->getPortalAngleDiff().Degrees());
}
static int LineIndex(line_t *self)
{
return self->Index();
@ -2719,6 +2743,7 @@ DEFINE_FIELD(FLevelLocals, sectors)
DEFINE_FIELD(FLevelLocals, lines)
DEFINE_FIELD(FLevelLocals, sides)
DEFINE_FIELD(FLevelLocals, vertexes)
DEFINE_FIELD(FLevelLocals, linePortals)
DEFINE_FIELD(FLevelLocals, sectorPortals)
DEFINE_FIELD(FLevelLocals, time)
DEFINE_FIELD(FLevelLocals, maptime)