1 #ifndef __PO_MAN_H
2 #define __PO_MAN_H
3 
4 #include "tarray.h"
5 #include "r_defs.h"
6 #include "m_bbox.h"
7 
8 
9 struct FPolyVertex
10 {
11 	fixed_t x, y;
12 
13 	FPolyVertex &operator=(vertex_t *v)
14 	{
15 		x = v->x;
16 		y = v->y;
17 		return *this;
18 	}
19 };
20 
21 struct FPolySeg
22 {
23 	FPolyVertex v1;
24 	FPolyVertex v2;
25 	side_t *wall;
26 };
27 
28 //
29 // Linked lists of polyobjects
30 //
31 struct FPolyObj;
32 struct FPolyNode
33 {
34 	FPolyObj *poly;				// owning polyobject
35 	FPolyNode *pnext;			// next polyobj in list
36 	FPolyNode *pprev;			// previous polyobj
37 
38 	subsector_t *subsector;		// containimg subsector
39 	FPolyNode *snext;			// next subsector
40 
41 	TArray<FPolySeg> segs;		// segs for this node
42 	int state;
43 };
44 
45 // ===== Polyobj data =====
46 struct FPolyObj
47 {
48 	TArray<side_t *>		Sidedefs;
49 	TArray<line_t *>		Linedefs;
50 	TArray<vertex_t *>		Vertices;
51 	TArray<FPolyVertex>		OriginalPts;
52 	TArray<FPolyVertex>		PrevPts;
53 	FPolyVertex				StartSpot;
54 	FPolyVertex				CenterSpot;
55 	FBoundingBox			Bounds;	// Bounds in map coordinates
56 	subsector_t				*CenterSubsector;
57 	int						MirrorNum;
58 
59 	angle_t		angle;
60 	int			tag;			// reference tag assigned in HereticEd
61 	int			bbox[4];		// bounds in blockmap coordinates
62 	int			validcount;
63 	int			crush; 			// should the polyobj attempt to crush mobjs?
64 	bool		bHurtOnTouch;	// should the polyobj hurt anything it touches?
65 	int			seqType;
66 	fixed_t		size;			// polyobj size (area of POLY_AREAUNIT == size of FRACUNIT)
67 	FPolyNode	*subsectorlinks;
68 	DPolyAction	*specialdata;	// pointer to a thinker, if the poly is moving
69 	TObjPtr<DInterpolation> interpolation;
70 
71 	FPolyObj();
72 	DInterpolation *SetInterpolation();
73 	void StopInterpolation();
74 
75 	int GetMirror();
76 	bool MovePolyobj (int x, int y, bool force = false);
77 	bool RotatePolyobj (angle_t angle, bool fromsave = false);
78 	void ClosestPoint(fixed_t fx, fixed_t fy, fixed_t &ox, fixed_t &oy, side_t **side) const;
79 	void LinkPolyobj ();
80 	void RecalcActorFloorCeil(FBoundingBox bounds) const;
81 	void CreateSubsectorLinks();
82 	void ClearSubsectorLinks();
83 	void CalcCenter();
84 	static void ClearAllSubsectorLinks();
85 
86 private:
87 
88 	void ThrustMobj (AActor *actor, side_t *side);
89 	void UpdateBBox ();
90 	void DoMovePolyobj (int x, int y);
91 	void UnLinkPolyobj ();
92 	bool CheckMobjBlocking (side_t *sd);
93 
94 };
95 extern FPolyObj *polyobjs;		// list of all poly-objects on the level
96 
97 struct polyblock_t
98 {
99 	FPolyObj *polyobj;
100 	struct polyblock_t *prev;
101 	struct polyblock_t *next;
102 };
103 
104 
105 void PO_LinkToSubsectors();
106 FArchive &operator<< (FArchive &arc, FPolyObj *&poly);
107 FArchive &operator<< (FArchive &arc, const FPolyObj *&poly);
108 
109 
110 #endif