@@ -57,12 +57,13 @@ using bool8_t = uint8_t;
5757#define MAX_ENTITIES MAX_REF_ENTITIES // RB: for compatibility
5858
5959// renderfx flags
60- #define RF_THIRD_PERSON 0x000002 // don't draw through eyes, only mirrors (player bodies, chat sprites)
61- #define RF_FIRST_PERSON 0x000004 // only draw through eyes (view weapon, damage blood blob)
62- #define RF_DEPTHHACK 0x000008 // for view weapon Z crunching
63- #define RF_NOSHADOW 0x000010 // don't add stencil shadows
64-
65- #define RF_SWAPCULL 0x000040 // swap CT_FRONT_SIDED and CT_BACK_SIDED
60+ enum RenderFx : uint8_t {
61+ RF_THIRD_PERSON = 0x000001 , // don't draw through eyes, only mirrors (player bodies, chat sprites)
62+ RF_FIRST_PERSON = 0x000002 , // only draw through eyes (view weapon, damage blood blob)
63+ RF_DEPTHHACK = 0x000004 , // for view weapon Z crunching
64+ RF_NOSHADOW = 0x000008 , // don't add stencil shadows
65+ RF_SWAPCULL = 0x000010 // swap CT_FRONT_SIDED and CT_BACK_SIDED
66+ };
6667
6768// refdef flags
6869#define RDF_NOWORLDMODEL ( 1 << 0 ) // used for player configuration screen
@@ -120,7 +121,7 @@ struct poly_t
120121 polyVert_t *verts;
121122};
122123
123- enum class refEntityType_t
124+ enum class refEntityType_t : int8_t
124125{
125126 RT_MODEL,
126127
@@ -188,24 +189,21 @@ struct alignas(16) refSkeleton_t
188189
189190// XreaL END
190191
191- enum class EntityTag {
192+ enum EntityTag : uint8_t {
192193 NONE,
193194 ON_TAG,
194195 ON_TAG_ROTATED
195196};
196197
197198struct refEntity_t
198199{
199- refEntityType_t reType;
200- int renderfx;
201-
202- qhandle_t hModel; // opaque type outside refresh
200+ qhandle_t hModel; // opaque type outside refresh
203201
204202 // most recent data
205- int frame;
203+ int16_t frame;
206204
207205 // previous data for frame interpolation
208- int oldframe;
206+ int16_t oldframe;
209207 float backlerp; // 0.0 = current, 1.0 = old
210208
211209 // texturing
@@ -225,40 +223,48 @@ struct refEntity_t
225223
226224 // Skeleton information
227225 qhandle_t animationHandle;
228- int startFrame;
229- int endFrame;
226+ int16_t startFrame;
227+ int16_t endFrame;
230228 float lerp;
231- int clearOrigin;
232229
233230 qhandle_t animationHandle2;
234- int startFrame2;
235- int endFrame2;
231+ int16_t startFrame2;
232+ int16_t endFrame2;
236233 float lerp2;
237- int clearOrigin2;
238234
239235 float blendLerp;
240236 float scale;
241237
242- int boundsAdd;
238+ // All of the 1-byte types are placed below for better packing
239+ refEntityType_t reType;
240+
241+ uint8_t renderfx;
243242
244243 EntityTag positionOnTag;
245- int attachmentEntity;
246244
247- vec4_t dynamicLight;
245+ int8_t clearOrigin;
246+ int8_t clearOrigin2;
248247
249- vec3_t lightingOrigin; // so multi-part models can be lit identically (RF_LIGHTING_ORIGIN)
248+ int8_t boundsAdd;
250249
251- vec3_t axis[3 ]; // rotation vectors
252- bool8_t nonNormalizedAxes; // axis are not normalized, i.e. they have scale
250+ int8_t nonNormalizedAxes; // axis are not normalized, i.e. they have scale
253251
254- vec3_t origin;
255- vec3_t oldorigin; // also used as MODEL_BEAM's "to"
252+ int8_t active;
253+
254+ uint16_t attachmentEntity;
255+
256+ uint16_t padding; // for better address alignment of shaderRGBA
256257
257258 Color::Color32Bit shaderRGBA; // colors used by rgbgen entity shaders
258259
259- bool8_t active;
260+ vec4_t dynamicLight; // r, g, b, radius; pre-multiplied by intensity
261+
262+ vec3_t axis[3 ]; // rotation vectors
263+
264+ vec3_t origin;
265+ vec3_t oldorigin; // also used as MODEL_BEAM's "to"
260266
261- vec3_t boundsRotation;
267+ vec3_t boundsRotation;
262268
263269 std::string tag;
264270
0 commit comments