/
r_defs.h
1681 lines (1394 loc) · 41.7 KB
/
r_defs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//-----------------------------------------------------------------------------
//
// Copyright 1993-1996 id Software
// Copyright 1994-1996 Raven Software
// Copyright 1998-1998 Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
// Copyright 1999-2016 Randy Heit
// Copyright 2002-2016 Christoph Oelckers
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see http://www.gnu.org/licenses/
//
//-----------------------------------------------------------------------------
//
// DESCRIPTION:
// Refresh/rendering module, shared data struct definitions.
//
//-----------------------------------------------------------------------------
#ifndef __R_DEFS_H__
#define __R_DEFS_H__
#include "doomdef.h"
#include "templates.h"
#include "m_bbox.h"
#include "dobjgc.h"
// Some more or less basic data types
// we depend on.
#include "m_fixed.h"
// We rely on the thinker data struct
// to handle sound origins in sectors.
// SECTORS do store MObjs anyway.
struct FLightNode;
struct FGLSection;
class FSerializer;
struct FSectorPortalGroup;
struct FSectorPortal;
struct FLinePortal;
struct seg_t;
struct sector_t;
class AActor;
struct FSection;
struct FLevelLocals;
#define MAXWIDTH 12000
#define MAXHEIGHT 5000
const uint16_t NO_INDEX = 0xffffu;
const uint32_t NO_SIDE = 0xffffffffu;
// Silhouette, needed for clipping Segs (mainly)
// and sprites representing things.
enum
{
SIL_NONE,
SIL_BOTTOM,
SIL_TOP,
SIL_BOTH
};
struct FDisplacement;
//
// INTERNAL MAP TYPES
// used by play and refresh
//
//
// Your plain vanilla vertex.
// Note: transformed values not buffered locally,
// like some DOOM-alikes ("wt", "WebView") did.
//
enum
{
VERTEXFLAG_ZCeilingEnabled = 0x01,
VERTEXFLAG_ZFloorEnabled = 0x02
};
struct vertexdata_t
{
double zCeiling, zFloor;
uint32_t flags;
};
struct vertex_t
{
DVector2 p;
int vertexnum;
angle_t viewangle; // precalculated angle for clipping
int angletime; // recalculation time for view angle
bool dirty; // something has changed and needs to be recalculated
int numheights;
int numsectors;
sector_t ** sectors;
float * heightlist;
void set(fixed_t x, fixed_t y)
{
p.X = x / 65536.;
p.Y = y / 65536.;
}
void set(double x, double y)
{
p.X = x;
p.Y = y;
}
void set(const DVector2 &pos)
{
p = pos;
}
double fX() const
{
return p.X;
}
double fY() const
{
return p.Y;
}
fixed_t fixX() const
{
return FLOAT2FIXED(p.X);
}
fixed_t fixY() const
{
return FLOAT2FIXED(p.Y);
}
DVector2 fPos() const
{
return p;
}
int Index() const { return vertexnum; }
void RecalcVertexHeights();
vertex_t()
{
p = { 0,0 };
angletime = 0;
viewangle = 0;
dirty = true;
numheights = numsectors = 0;
sectors = NULL;
heightlist = NULL;
}
~vertex_t()
{
if (sectors != nullptr) delete[] sectors;
if (heightlist != nullptr) delete[] heightlist;
}
bool operator== (const vertex_t &other)
{
return p == other.p;
}
bool operator!= (const vertex_t &other)
{
return p != other.p;
}
void clear()
{
p.Zero();
}
};
// Forward of LineDefs, for Sectors.
struct line_t;
class player_t;
class FScanner;
class FBitmap;
struct FCopyInfo;
class DInterpolation;
enum
{
UDMF_Line,
UDMF_Side,
UDMF_Sector,
UDMF_Thing
};
struct FUDMFKey
{
enum
{
UDMF_Int,
UDMF_Float,
UDMF_String
};
FName Key;
int Type;
int IntVal;
double FloatVal;
FString StringVal;
FUDMFKey()
{
}
FUDMFKey& operator =(int val)
{
Type = UDMF_Int;
IntVal = val;
FloatVal = val;
StringVal = "";
return *this;
}
FUDMFKey& operator =(double val)
{
Type = UDMF_Float;
IntVal = int(val);
FloatVal = val;
StringVal = "";
return *this;
}
FUDMFKey& operator =(const FString &val)
{
Type = UDMF_String;
IntVal = (int)strtoll(val.GetChars(), NULL, 0);
FloatVal = strtod(val.GetChars(), NULL);
StringVal = val;
return *this;
}
};
class FUDMFKeys : public TArray<FUDMFKey>
{
bool mSorted = false;
public:
void Sort();
FUDMFKey *Find(FName key);
};
//
// The SECTORS record, at runtime.
// Stores things/mobjs.
//
class DSectorEffect;
struct FRemapTable;
enum
{
SECSPAC_Enter = 1<< 0, // Trigger when player enters
SECSPAC_Exit = 1<< 1, // Trigger when player exits
SECSPAC_HitFloor = 1<< 2, // Trigger when player hits floor
SECSPAC_HitCeiling = 1<< 3, // Trigger when player hits ceiling
SECSPAC_Use = 1<< 4, // Trigger when player uses
SECSPAC_UseWall = 1<< 5, // Trigger when player uses a wall
SECSPAC_EyesDive = 1<< 6, // Trigger when player eyes go below fake floor
SECSPAC_EyesSurface = 1<< 7, // Trigger when player eyes go above fake floor
SECSPAC_EyesBelowC = 1<< 8, // Trigger when player eyes go below fake ceiling
SECSPAC_EyesAboveC = 1<< 9, // Trigger when player eyes go above fake ceiling
SECSPAC_HitFakeFloor= 1<<10, // Trigger when player hits fake floor
SECSPAC_DamageFloor = 1<<11, // Trigger when floor is damaged
SECSPAC_DamageCeiling=1<<12, // Trigger when ceiling is damaged
SECSPAC_DeathFloor = 1<<13, // Trigger when floor has 0 hp
SECSPAC_DeathCeiling= 1<<14, // Trigger when ceiling has 0 hp
SECSPAC_Damage3D = 1<<15, // Trigger when controlled 3d floor is damaged
SECSPAC_Death3D = 1<<16 // Trigger when controlled 3d floor has 0 hp
};
struct secplane_t
{
// the plane is defined as a*x + b*y + c*z + d = 0
// ic is 1/c, for faster Z calculations
//private:
DVector3 normal;
double D, negiC; // negative iC because that also saves a negation in all methods using this.
public:
friend FSerializer &Serialize(FSerializer &arc, const char *key, secplane_t &p, secplane_t *def);
void set(double aa, double bb, double cc, double dd)
{
normal.X = aa;
normal.Y = bb;
normal.Z = cc;
D = dd;
negiC = -1 / cc;
}
void setD(double dd)
{
D = dd;
}
double fC() const
{
return normal.Z;
}
double fD() const
{
return D;
}
bool isSlope() const
{
return !normal.XY().isZero();
}
const DVector3 &Normal() const
{
return normal;
}
// Returns < 0 : behind; == 0 : on; > 0 : in front
int PointOnSide(const DVector3 &pos) const
{
double v = (normal | pos) + D;
return v < -EQUAL_EPSILON ? -1 : v > EQUAL_EPSILON ? 1 : 0;
}
// Returns the value of z at (0,0) This is used by the 3D floor code which does not handle slopes
double Zat0() const
{
return negiC*D;
}
// Returns the value of z at (x,y)
fixed_t ZatPoint(fixed_t x, fixed_t y) const = delete; // it is not allowed to call this.
// Returns the value of z at (x,y) as a double
double ZatPoint (double x, double y) const
{
return (D + normal.X*x + normal.Y*y) * negiC;
}
double ZatPoint(const DVector2 &pos) const
{
return (D + normal.X*pos.X + normal.Y*pos.Y) * negiC;
}
double ZatPoint(const FVector2 &pos) const
{
return (D + normal.X*pos.X + normal.Y*pos.Y) * negiC;
}
double ZatPoint(const vertex_t *v) const
{
return (D + normal.X*v->fX() + normal.Y*v->fY()) * negiC;
}
// Returns the value of z at vertex v if d is equal to dist
double ZatPointDist(const vertex_t *v, double dist)
{
return (dist + normal.X*v->fX() + normal.Y*v->fY()) * negiC;
}
// Flips the plane's vertical orientiation, so that if it pointed up,
// it will point down, and vice versa.
void FlipVert ()
{
normal = -normal;
D = -D;
negiC = -negiC;
}
// Returns true if 2 planes are the same
bool operator== (const secplane_t &other) const
{
return normal == other.normal && D == other.D;
}
// Returns true if 2 planes are different
bool operator!= (const secplane_t &other) const
{
return normal != other.normal || D != other.D;
}
// Moves a plane up/down by hdiff units
void ChangeHeight(double hdiff)
{
D = D - hdiff * normal.Z;
}
// Moves a plane up/down by hdiff units
double GetChangedHeight(double hdiff) const
{
return D - hdiff * normal.Z;
}
// Returns how much this plane's height would change if d were set to oldd
double HeightDiff(double oldd) const
{
return (D - oldd) * negiC;
}
// Returns how much this plane's height would change if d were set to oldd
double HeightDiff(double oldd, double newd) const
{
return (newd - oldd) * negiC;
}
double PointToDist(const DVector2 &xy, double z) const
{
return -(normal.X * xy.X + normal.Y * xy.Y + normal.Z * z);
}
double PointToDist(const vertex_t *v, double z) const
{
return -(normal.X * v->fX() + normal.Y * v->fY() + normal.Z * z);
}
void SetAtHeight(double height, int ceiling)
{
normal.X = normal.Y = 0;
if (ceiling)
{
normal.Z = -1;
negiC = 1;
D = height;
}
else
{
normal.Z = 1;
negiC = -1;
D = -height;
}
}
bool CopyPlaneIfValid (secplane_t *dest, const secplane_t *opp) const;
inline double ZatPoint(const AActor *ac) const;
};
#include "p_3dfloors.h"
struct subsector_t;
struct side_t;
extern bool gl_plane_reflection_i;
// Ceiling/floor flags
enum
{
PLANEF_ABSLIGHTING = 1, // floor/ceiling light is absolute, not relative
PLANEF_BLOCKED = 2, // can not be moved anymore.
PLANEF_ADDITIVE = 4, // rendered additive
// linked portal stuff
PLANEF_NORENDER = 8,
PLANEF_NOPASS = 16,
PLANEF_BLOCKSOUND = 32,
PLANEF_DISABLED = 64,
PLANEF_OBSTRUCTED = 128, // if the portal plane is beyond the sector's floor or ceiling.
PLANEF_LINKED = 256 // plane is flagged as a linked portal
};
// Internal sector flags
enum
{
SECMF_FAKEFLOORONLY = 2, // when used as heightsec in R_FakeFlat, only copies floor
SECMF_CLIPFAKEPLANES = 4, // as a heightsec, clip planes to target sector's planes
SECMF_NOFAKELIGHT = 8, // heightsec does not change lighting
SECMF_IGNOREHEIGHTSEC = 16, // heightsec is only for triggering sector actions
SECMF_UNDERWATER = 32, // sector is underwater
SECMF_FORCEDUNDERWATER = 64, // sector is forced to be underwater
SECMF_UNDERWATERMASK = 32+64,
SECMF_DRAWN = 128, // sector has been drawn at least once
SECMF_HIDDEN = 256, // Do not draw on textured automap
SECMF_OVERLAPPING = 512, // floor and ceiling overlap and require special renderer action.
};
enum
{
SECF_SILENT = 1, // actors in sector make no noise
SECF_NOFALLINGDAMAGE= 2, // No falling damage in this sector
SECF_FLOORDROP = 4, // all actors standing on this floor will remain on it when it lowers very fast.
SECF_NORESPAWN = 8, // players can not respawn in this sector
SECF_FRICTION = 16, // sector has friction enabled
SECF_PUSH = 32, // pushers enabled
SECF_SILENTMOVE = 64, // Sector movement makes mo sound (Eternity got this so this may be useful for an extended cross-port standard.)
SECF_DMGTERRAINFX = 128, // spawns terrain splash when inflicting damage
SECF_ENDGODMODE = 256, // getting damaged by this sector ends god mode
SECF_ENDLEVEL = 512, // ends level when health goes below 10
SECF_HAZARD = 1024, // Change to Strife's delayed damage handling.
SECF_NOATTACK = 2048, // monsters cannot start attacks in this sector.
SECF_WASSECRET = 1 << 30, // a secret that was discovered
SECF_SECRET = 1 << 31, // a secret sector
SECF_DAMAGEFLAGS = SECF_ENDGODMODE|SECF_ENDLEVEL|SECF_DMGTERRAINFX|SECF_HAZARD,
SECF_NOMODIFY = SECF_SECRET|SECF_WASSECRET, // not modifiable by Sector_ChangeFlags
SECF_SPECIALFLAGS = SECF_DAMAGEFLAGS|SECF_FRICTION|SECF_PUSH, // these flags originate from 'special and must be transferrable by floor thinkers
};
enum
{
PL_SKYFLAT = 0x40000000
};
struct FDynamicColormap;
struct FLinkedSector
{
sector_t *Sector;
int Type;
};
// this substructure contains a few sector properties that are stored in dynamic arrays
// These must not be copied by R_FakeFlat etc. or bad things will happen.
struct extsector_t
{
// Boom sector transfer information
struct fakefloor
{
TArray<sector_t *> Sectors;
} FakeFloor;
// 3DMIDTEX information
struct midtex
{
struct plane
{
TArray<sector_t *> AttachedSectors; // all sectors containing 3dMidtex lines attached to this sector
TArray<line_t *> AttachedLines; // all 3dMidtex lines attached to this sector
} Floor, Ceiling;
} Midtex;
// Linked sector information
struct linked
{
struct plane
{
TArray<FLinkedSector> Sectors;
} Floor, Ceiling;
} Linked;
// 3D floors
struct xfloor
{
TDeletingArray<F3DFloor *> ffloors; // 3D floors in this sector
TArray<lightlist_t> lightlist; // 3D light list
TArray<sector_t*> attached; // 3D floors attached to this sector
} XFloor;
TArray<vertex_t *> vertices;
};
struct FTransform
{
// killough 3/7/98: floor and ceiling texture offsets
double xOffs, yOffs, baseyOffs;
// [RH] floor and ceiling texture scales
double xScale, yScale;
// [RH] floor and ceiling texture rotation
DAngle Angle, baseAngle;
finline bool operator == (const FTransform &other) const
{
return xOffs == other.xOffs && yOffs + baseyOffs == other.yOffs + other.baseyOffs &&
xScale == other.xScale && yScale == other.yScale && Angle + baseAngle == other.Angle + other.baseAngle;
}
finline bool operator != (const FTransform &other) const
{
return !(*this == other);
}
};
struct secspecial_t
{
FName damagetype; // [RH] Means-of-death for applied damage
int damageamount; // [RH] Damage to do while standing on floor
short special;
short damageinterval; // Interval for damage application
short leakydamage; // chance of leaking through radiation suit
int Flags;
};
FSerializer &Serialize(FSerializer &arc, const char *key, secspecial_t &spec, secspecial_t *def);
enum class EMoveResult { ok, crushed, pastdest };
struct sector_t
{
enum
{
floor,
ceiling,
// only used for specialcolors array
walltop,
wallbottom,
sprites
};
enum
{
CeilingMove,
FloorMove,
CeilingScroll,
FloorScroll
};
enum
{
vbo_fakefloor = floor + 2,
vbo_fakeceiling = ceiling + 2,
};
enum
{
INVALIDATE_PLANES = 1,
INVALIDATE_OTHER = 2
};
struct splane
{
FTransform xform;
int Flags;
int Light;
double alpha;
double TexZ;
PalEntry GlowColor;
float GlowHeight;
FTextureID Texture;
};
splane planes[2];
FLevelLocals *Level;
extsector_t * e; // This stores data that requires construction/destruction. Such data must not be copied by R_FakeFlat.
secplane_t floorplane, ceilingplane; // [RH] store floor and ceiling planes instead of heights
DVector2 centerspot; // origin for any sounds played by the sector
TStaticPointedArray<line_t *> Lines;
sector_t *heightsec; // killough 3/7/98: support flat heights drawn at another sector's heights other sector, or NULL if no other sector
struct msecnode_t *sectorportal_thinglist; // for cross-portal rendering.
struct msecnode_t *touching_renderthings; // this is used to allow wide things to be rendered not only from their main sector.
PalEntry SpecialColors[5]; // Doom64 style colors
PalEntry AdditiveColors[5];
FColormap Colormap; // Sector's own color/fog info.
short special; // map-defined sector special type
short lightlevel;
int sky; // MBF sky transfer info.
int validcount; // if == validcount, already checked
uint32_t bottommap, midmap, topmap; // killough 4/4/98: dynamic colormaps
// [RH] these can also be blend values if
// the alpha mask is non-zero
bool transdoor; // For transparent door hacks
uint16_t MoreFlags; // [RH] Internal sector flags
uint32_t Flags; // Sector flags
// [RH] The portal or skybox to render for this sector.
unsigned Portals[2];
int PortalGroup;
int sectornum; // for comparing sector copies
// GL only stuff starts here
float reflect[2];
int subsectorcount; // list of subsectors
double transdoorheight; // for transparent door hacks
subsector_t ** subsectors;
FSectorPortalGroup * portals[2]; // floor and ceiling portals
int vboindex[4]; // VBO indices of the 4 planes this sector uses during rendering. This is only needed for updating plane heights.
int iboindex[4]; // IBO indices of the 4 planes this sector uses during rendering
double vboheight[2]; // Last calculated height for the 2 planes of this actual sector
int vbocount[2]; // Total count of vertices belonging to this sector's planes. This is used when a sector height changes and also contains all attached planes.
int ibocount; // number of indices per plane (identical for all planes.) If this is -1 the index buffer is not in use.
// Below are all properties which are not used by the renderer.
TObjPtr<AActor*> SoundTarget;
AActor* thinglist; // list of actors in sector
double gravity; // [RH] Sector gravity (1.0 is normal)
// thinker_t for reversable actions
TObjPtr<DSectorEffect*> floordata; // jff 2/22/98 make thinkers on
TObjPtr<DSectorEffect*> ceilingdata; // floors, ceilings, lighting,
TObjPtr<DSectorEffect*> lightingdata; // independent of one another
TObjPtr<DInterpolation*> interpolations[4];
// list of mobjs that are at least partially in the sector
// thinglist is a subset of touching_thinglist
struct msecnode_t *touching_thinglist; // phares 3/14/98
// [RH] Action specials for sectors. Like Skull Tag, but more
// flexible in a Bloody way. SecActTarget forms a list of actors
// joined by their tracer fields. When a potential sector action
// occurs, SecActTarget's TriggerAction method is called.
TObjPtr<AActor*> SecActTarget;
// killough 8/28/98: friction is a sector property, not an actor property.
// these fields used to be in AActor, but presented performance problems
// when processed as mobj properties. Fix is to make them sector properties.
double friction, movefactor;
int terrainnum[2];
FName SeqName; // Sound sequence name. Setting seqType non-negative will override this.
short seqType; // this sector's sound sequence
uint8_t soundtraversed; // 0 = untraversed, 1,2 = sndlines -1
int8_t stairlock; // jff 2/26/98 lockout machinery for stairbuilding: -2 on first locked, -1 after thinker done, 0 normally
int prevsec; // -1 or number of sector for previous step
int nextsec; // -1 or number of next step sector
FName damagetype; // [RH] Means-of-death for applied damage
int damageamount; // [RH] Damage to do while standing on floor
short damageinterval; // Interval for damage application
short leakydamage; // chance of leaking through radiation suit
uint16_t ZoneNumber; // [RH] Zone this sector belongs to
// [ZZ] these are for destructible sectors.
// default is 0, which means no special behavior
int healthfloor;
int healthceiling;
int health3d;
int healthfloorgroup;
int healthceilinggroup;
int health3dgroup;
// Member functions
private:
bool MoveAttached(int crush, double move, int floorOrCeiling, bool resetfailed, bool instant = false);
public:
EMoveResult MoveFloor(double speed, double dest, int crush, int direction, bool hexencrush, bool instant = false);
EMoveResult MoveCeiling(double speed, double dest, int crush, int direction, bool hexencrush);
inline EMoveResult MoveFloor(double speed, double dest, int direction)
{
return MoveFloor(speed, dest, -1, direction, false);
}
inline EMoveResult MoveCeiling(double speed, double dest, int direction)
{
return MoveCeiling(speed, dest, -1, direction, false);
}
bool IsLinked(sector_t *other, bool ceiling) const;
sector_t *NextSpecialSector (int type, sector_t *prev) const; // [RH]
void RemoveForceField();
int Index() const { return sectornum; }
void AdjustFloorClip () const;
void SetColor(PalEntry pe, int desat);
void SetFade(PalEntry pe);
void SetFogDensity(int dens);
void ClosestPoint(const DVector2 &pos, DVector2 &out) const;
int GetFloorLight() const;
int GetCeilingLight() const;
sector_t *GetHeightSec() const
{
return (MoreFlags & SECMF_IGNOREHEIGHTSEC)? nullptr : heightsec;
}
double GetFriction(int plane = sector_t::floor, double *movefac = NULL) const;
bool TriggerSectorActions(AActor *thing, int activation);
DInterpolation *SetInterpolation(int position, bool attach);
FSectorPortal *ValidatePortal(int which);
void CheckPortalPlane(int plane);
int CheckSpriteGlow(int lightlevel, const DVector3 &pos);
bool GetWallGlow(float *topglowcolor, float *bottomglowcolor);
void SetXOffset(int pos, double o)
{
planes[pos].xform.xOffs = o;
}
void AddXOffset(int pos, double o)
{
planes[pos].xform.xOffs += o;
}
double GetXOffset(int pos) const
{
return planes[pos].xform.xOffs;
}
void SetYOffset(int pos, double o)
{
planes[pos].xform.yOffs = o;
}
void AddYOffset(int pos, double o)
{
planes[pos].xform.yOffs += o;
}
double GetYOffset(int pos, bool addbase = true) const
{
if (!addbase)
{
return planes[pos].xform.yOffs;
}
else
{
return planes[pos].xform.yOffs + planes[pos].xform.baseyOffs;
}
}
void SetXScale(int pos, double o)
{
planes[pos].xform.xScale = o;
}
double GetXScale(int pos) const
{
return planes[pos].xform.xScale;
}
void SetYScale(int pos, double o)
{
planes[pos].xform.yScale = o;
}
double GetYScale(int pos) const
{
return planes[pos].xform.yScale;
}
void SetAngle(int pos, DAngle o)
{
planes[pos].xform.Angle = o;
}
DAngle GetAngle(int pos, bool addbase = true) const
{
if (!addbase)
{
return planes[pos].xform.Angle;
}
else
{
return planes[pos].xform.Angle + planes[pos].xform.baseAngle;
}
}
void SetBase(int pos, double y, DAngle o)
{
planes[pos].xform.baseyOffs = y;
planes[pos].xform.baseAngle = o;
}
void SetAlpha(int pos, double o)
{
planes[pos].alpha = o;
}
double GetAlpha(int pos) const
{
return planes[pos].alpha;
}
int GetFlags(int pos) const
{
return planes[pos].Flags;
}
// like the previous one but masks out all flags which are not relevant for rendering.
int GetVisFlags(int pos) const
{
return planes[pos].Flags & ~(PLANEF_BLOCKED | PLANEF_NOPASS | PLANEF_BLOCKSOUND | PLANEF_LINKED);
}
void ChangeFlags(int pos, int And, int Or)
{
planes[pos].Flags &= ~And;
planes[pos].Flags |= Or;
}
int GetPlaneLight(int pos) const
{
return planes[pos].Light;
}
void SetPlaneLight(int pos, int level)
{
planes[pos].Light = level;
}
double GetGlowHeight(int pos)
{
return planes[pos].GlowHeight;
}
PalEntry GetGlowColor(int pos)
{
return planes[pos].GlowColor;
}
void SetGlowHeight(int pos, float height)
{
planes[pos].GlowHeight = height;
}
void SetGlowColor(int pos, PalEntry color)
{
planes[pos].GlowColor = color;
}
FTextureID GetTexture(int pos) const
{
return planes[pos].Texture;
}
void SetTexture(int pos, FTextureID tex, bool floorclip = true)
{
FTextureID old = planes[pos].Texture;
planes[pos].Texture = tex;
if (floorclip && pos == floor && tex != old) AdjustFloorClip();
}
double GetPlaneTexZ(int pos) const
{
return planes[pos].TexZ;
}
void SetPlaneTexZQuick(int pos, double val) // For the *FakeFlat functions which do not need to have the overlap checked.
{
planes[pos].TexZ = val;
}
void SetPlaneTexZ(int pos, double val, bool dirtify = false) // This mainly gets used by init code. The only place where it must set the vertex to dirty is the interpolation code.
{
planes[pos].TexZ = val;
if (dirtify) SetAllVerticesDirty();
CheckOverlap();
}
void ChangePlaneTexZ(int pos, double val)
{
planes[pos].TexZ += val;
SetAllVerticesDirty();
CheckOverlap();
}
static inline short ClampLight(int level)
{
return (short)clamp(level, SHRT_MIN, SHRT_MAX);
}
void ChangeLightLevel(int newval)
{
lightlevel = ClampLight(lightlevel + newval);
}
void SetLightLevel(int newval)
{
lightlevel = ClampLight(newval);
}
int GetLightLevel() const
{
return lightlevel;
}
secplane_t &GetSecPlane(int pos)
{