@@ -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,25 +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;
209- float backlerp; // 0.0 = current, 1.0 = old
206+ int16_t oldframe;
210207
211208 // texturing
212209 int skinNum; // inline skin index
@@ -222,43 +219,53 @@ struct refEntity_t
222219 float rotation;
223220
224221 int altShaderIndex;
222+ float scale;
223+
224+ // All of the 1-byte types are placed below for better packing
225+ refEntityType_t reType;
226+
227+ uint8_t renderfx;
228+
229+ EntityTag positionOnTag;
230+
231+ int8_t clearOrigin;
232+ int8_t clearOrigin2;
233+
234+ int8_t boundsAdd;
235+
236+ int8_t nonNormalizedAxes; // axis are not normalized, i.e. they have scale
237+
238+ int8_t active;
239+
240+ uint16_t attachmentEntity;
241+
242+ uint16_t padding; // for better address alignment
243+
244+ float backlerp; // 0.0 = current, 1.0 = old
225245
226246 // Skeleton information
227247 qhandle_t animationHandle;
228- int startFrame;
229- int endFrame;
248+ int16_t startFrame;
249+ int16_t endFrame;
230250 float lerp;
231- int clearOrigin;
232251
233252 qhandle_t animationHandle2;
234- int startFrame2;
235- int endFrame2;
253+ int16_t startFrame2;
254+ int16_t endFrame2;
236255 float lerp2;
237- int clearOrigin2;
238256
239257 float blendLerp;
240- float scale;
241-
242- int boundsAdd;
243258
244- EntityTag positionOnTag;
245- int attachmentEntity;
246-
247- vec4_t dynamicLight;
259+ Color::Color32Bit shaderRGBA; // colors used by rgbgen entity shaders
248260
249- vec3_t lightingOrigin ; // so multi-part models can be lit identically (RF_LIGHTING_ORIGIN)
261+ vec4_t dynamicLight ; // r, g, b, radius; pre-multiplied by intensity
250262
251263 vec3_t axis[3 ]; // rotation vectors
252- bool8_t nonNormalizedAxes; // axis are not normalized, i.e. they have scale
253264
254265 vec3_t origin;
255266 vec3_t oldorigin; // also used as MODEL_BEAM's "to"
256267
257- Color::Color32Bit shaderRGBA; // colors used by rgbgen entity shaders
258-
259- bool8_t active;
260-
261- vec3_t boundsRotation;
268+ vec3_t boundsRotation;
262269
263270 std::string tag;
264271
0 commit comments