qzdoom-gpl/src/po_man.h
Christoph Oelckers 6a27267500 - changed handling of one-time, one-way door polyobjects to be more efficient.
The old code kept the dead thinker, resulting in constant deletion and recreation of the subsector links and PolyBSP because the interpolation kept running.
Changed it so that the thinker is destroyed and the polyobject gets blocked by setting a new flag.
2016-04-17 01:24:07 +02:00

146 lines
No EOL
3.4 KiB
C++

#ifndef __PO_MAN_H
#define __PO_MAN_H
#include "tarray.h"
#include "r_defs.h"
#include "m_bbox.h"
class DPolyAction;
struct FPolyVertex
{
DVector2 pos;
FPolyVertex &operator=(vertex_t *v)
{
pos = v->fPos();
return *this;
}
};
struct FPolySeg
{
FPolyVertex v1;
FPolyVertex v2;
side_t *wall;
};
//
// Linked lists of polyobjects
//
struct FPolyObj;
struct FPolyNode
{
FPolyObj *poly; // owning polyobject
FPolyNode *pnext; // next polyobj in list
FPolyNode *pprev; // previous polyobj
subsector_t *subsector; // containimg subsector
FPolyNode *snext; // next subsector
TArray<FPolySeg> segs; // segs for this node
int state;
};
// ===== Polyobj data =====
struct FPolyObj
{
TArray<side_t *> Sidedefs;
TArray<line_t *> Linedefs;
TArray<vertex_t *> Vertices;
TArray<FPolyVertex> OriginalPts;
TArray<FPolyVertex> PrevPts;
FPolyVertex StartSpot;
FPolyVertex CenterSpot;
FBoundingBox Bounds; // Bounds in map coordinates
subsector_t *CenterSubsector;
int MirrorNum;
DAngle Angle;
int tag; // reference tag assigned in HereticEd
int bbox[4]; // bounds in blockmap coordinates
int validcount;
int crush; // should the polyobj attempt to crush mobjs?
bool bHurtOnTouch; // should the polyobj hurt anything it touches?
bool bBlocked;
int seqType;
double Size; // polyobj size (area of POLY_AREAUNIT == size of FRACUNIT)
FPolyNode *subsectorlinks;
DPolyAction *specialdata; // pointer to a thinker, if the poly is moving
TObjPtr<DInterpolation> interpolation;
FPolyObj();
DInterpolation *SetInterpolation();
void StopInterpolation();
int GetMirror();
bool MovePolyobj (const DVector2 &pos, bool force = false);
bool RotatePolyobj (DAngle angle, bool fromsave = false);
void ClosestPoint(const DVector2 &fpos, DVector2 &out, side_t **side) const;
void LinkPolyobj ();
void RecalcActorFloorCeil(FBoundingBox bounds) const;
void CreateSubsectorLinks();
void ClearSubsectorLinks();
void CalcCenter();
static void ClearAllSubsectorLinks();
private:
void ThrustMobj (AActor *actor, side_t *side);
void UpdateBBox ();
void DoMovePolyobj (const DVector2 &pos);
void UnLinkPolyobj ();
bool CheckMobjBlocking (side_t *sd);
};
extern FPolyObj *polyobjs; // list of all poly-objects on the level
struct polyblock_t
{
FPolyObj *polyobj;
struct polyblock_t *prev;
struct polyblock_t *next;
};
void PO_LinkToSubsectors();
FArchive &operator<< (FArchive &arc, FPolyObj *&poly);
FArchive &operator<< (FArchive &arc, const FPolyObj *&poly);
// ===== PO_MAN =====
typedef enum
{
PODOOR_NONE,
PODOOR_SLIDE,
PODOOR_SWING,
} podoortype_t;
bool EV_RotatePoly (line_t *line, int polyNum, int speed, int byteAngle, int direction, bool overRide);
bool EV_MovePoly (line_t *line, int polyNum, double speed, DAngle angle, double dist, bool overRide);
bool EV_MovePolyTo (line_t *line, int polyNum, double speed, const DVector2 &pos, bool overRide);
bool EV_OpenPolyDoor (line_t *line, int polyNum, double speed, DAngle angle, int delay, double distance, podoortype_t type);
bool EV_StopPoly (int polyNum);
// [RH] Data structure for P_SpawnMapThing() to keep track
// of polyobject-related things.
struct polyspawns_t
{
polyspawns_t *next;
DVector2 pos;
short angle;
short type;
};
extern int po_NumPolyobjs;
extern polyspawns_t *polyspawns; // [RH] list of polyobject things to spawn
void PO_Init ();
bool PO_Busy (int polyobj);
FPolyObj *PO_GetPolyobj(int polyNum);
#endif