From 639fb436821f439d7c47bf4fca833840b2082fe7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 5 Jan 2019 13:27:32 +0100 Subject: [PATCH] -reordered sector_t so that the internal declarations are at the top, followed by the member variables and the methods. Also tried to sort them by renderer use but that turned out to be without any performance effect, even though the struct is a bit better aligned now and several bytes shorter. --- src/r_defs.h | 301 ++++++++++++++++++++++++++------------------------- src/tarray.h | 3 +- 2 files changed, 152 insertions(+), 152 deletions(-) diff --git a/src/r_defs.h b/src/r_defs.h index e8c51846d..04a14b90b 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -150,6 +150,7 @@ struct vertex_t int numsectors; sector_t ** sectors; float * heightlist; + int vertexnum; vertex_t() { @@ -604,6 +605,155 @@ 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]; + + 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 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 SoundTarget; + AActor* thinglist; // list of actors in sector + double gravity; // [RH] Sector gravity (1.0 is normal) + + // thinker_t for reversable actions + TObjPtr floordata; // jff 2/22/98 make thinkers on + TObjPtr ceilingdata; // floors, ceilings, lighting, + TObjPtr lightingdata; // independent of one another + + TObjPtr 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 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: @@ -654,32 +804,6 @@ public: bool GetWallGlow(float *topglowcolor, float *bottomglowcolor); - enum - { - floor, - ceiling, - // only used for specialcolors array - walltop, - wallbottom, - sprites - - }; - - struct splane - { - FTransform xform; - int Flags; - int Light; - double alpha; - double TexZ; - PalEntry GlowColor; - float GlowHeight; - FTextureID Texture; - }; - - - splane planes[2]; - void SetXOffset(int pos, double o) { planes[pos].xform.xOffs = o; @@ -977,132 +1101,9 @@ public: Colormap = other->Colormap; } - // [RH] store floor and ceiling planes instead of heights - secplane_t floorplane, ceilingplane; - - // [RH] give floor and ceiling even more properties - PalEntry SpecialColors[5]; - PalEntry AdditiveColors[5]; - FColormap Colormap; - - TObjPtr SoundTarget; - - short special; - short lightlevel; - short seqType; // this sector's sound sequence - - int sky; - FName SeqName; // Sound sequence name. Setting seqType non-negative will override this. - - DVector2 centerspot; // origin for any sounds played by the sector - int validcount; // if == validcount, already checked - AActor* thinglist; // list of mobjs in sector - - // killough 8/28/98: friction is a sector property, not an mobj 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]; - - // thinker_t for reversable actions - TObjPtr floordata; // jff 2/22/98 make thinkers on - TObjPtr ceilingdata; // floors, ceilings, lighting, - TObjPtr lightingdata; // independent of one another - - enum - { - CeilingMove, - FloorMove, - CeilingScroll, - FloorScroll - }; - TObjPtr interpolations[4]; - - int prevsec; // -1 or number of sector for previous step - int nextsec; // -1 or number of next step sector - uint8_t soundtraversed; // 0 = untraversed, 1,2 = sndlines -1 - // jff 2/26/98 lockout machinery for stairbuilding - int8_t stairlock; // -2 on first locked -1 after thinker done 0 normally - - TStaticPointedArray Lines; - - // killough 3/7/98: support flat heights drawn at another sector's heights - sector_t *heightsec; // other sector, or NULL if no other sector - - 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 - - // 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 - 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. - - double gravity; // [RH] Sector gravity (1.0 is normal) - 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 - uint16_t MoreFlags; // [RH] Internal sector flags - uint32_t Flags; // Sector flags - - // [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 SecActTarget; - - // [RH] The portal or skybox to render for this sector. - unsigned Portals[2]; - int PortalGroup; - - int sectornum; // for comparing sector copies - - extsector_t * e; // This stores data that requires construction/destruction. Such data must not be copied by R_FakeFlat. - - // GL only stuff starts here - float reflect[2]; - - bool transdoor; // For transparent door hacks - int subsectorcount; // list of subsectors - double transdoorheight; // for transparent door hacks - subsector_t ** subsectors; - FSectorPortalGroup * portals[2]; // floor and ceiling portals - - enum - { - vbo_fakefloor = floor+2, - vbo_fakeceiling = ceiling+2, - }; - - 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. - - float GetReflect(int pos) { return gl_plane_reflection_i? reflect[pos] : 0; } + float GetReflect(int pos) { return gl_plane_reflection_i ? reflect[pos] : 0; } FSectorPortalGroup *GetPortalGroup(int plane) { return portals[plane]; } - enum - { - INVALIDATE_PLANES = 1, - INVALIDATE_OTHER = 2 - }; - - // [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; - }; struct ReverbContainer; diff --git a/src/tarray.h b/src/tarray.h index 255fa9f0a..ea927db75 100644 --- a/src/tarray.h +++ b/src/tarray.h @@ -586,8 +586,7 @@ public: }; // This is only used for exposing the sector's Lines array to ZScript. -// This also must be trivial so that sector_t remains trivial. -// For other uses TArrayView should be preferred. +// Unlike TArrayView, its members are public as needed by the map loader. template class TStaticPointedArray