@@ -57,12 +57,21 @@ 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
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+ };
67+
68+ inline RenderFx operator |( const RenderFx& lhs, const RenderFx& rhs ) {
69+ return ( RenderFx ) ( ( uint8_t ) lhs | ( uint8_t ) rhs );
70+ }
6471
65- #define RF_SWAPCULL 0x000040 // swap CT_FRONT_SIDED and CT_BACK_SIDED
72+ inline RenderFx operator |=( const RenderFx& lhs, const RenderFx& rhs ) {
73+ return ( RenderFx ) ( ( uint8_t ) lhs | ( uint8_t ) rhs );
74+ }
6675
6776// refdef flags
6877#define RDF_NOWORLDMODEL ( 1 << 0 ) // used for player configuration screen
@@ -120,7 +129,7 @@ struct poly_t
120129 polyVert_t *verts;
121130};
122131
123- enum class refEntityType_t
132+ enum class refEntityType_t : int8_t
124133{
125134 RT_MODEL,
126135
@@ -188,24 +197,21 @@ struct alignas(16) refSkeleton_t
188197
189198// XreaL END
190199
191- enum class EntityTag {
200+ enum EntityTag : uint8_t {
192201 NONE,
193202 ON_TAG,
194203 ON_TAG_ROTATED
195204};
196205
197206struct refEntity_t
198207{
199- refEntityType_t reType;
200- int renderfx;
201-
202- qhandle_t hModel; // opaque type outside refresh
208+ qhandle_t hModel; // opaque type outside refresh
203209
204210 // most recent data
205- int frame;
211+ int16_t frame;
206212
207213 // previous data for frame interpolation
208- int oldframe;
214+ int16_t oldframe;
209215 float backlerp; // 0.0 = current, 1.0 = old
210216
211217 // texturing
@@ -225,40 +231,48 @@ struct refEntity_t
225231
226232 // Skeleton information
227233 qhandle_t animationHandle;
228- int startFrame;
229- int endFrame;
234+ int16_t startFrame;
235+ int16_t endFrame;
230236 float lerp;
231- int clearOrigin;
232237
233238 qhandle_t animationHandle2;
234- int startFrame2;
235- int endFrame2;
239+ int16_t startFrame2;
240+ int16_t endFrame2;
236241 float lerp2;
237- int clearOrigin2;
238242
239243 float blendLerp;
240244 float scale;
241245
242- int boundsAdd;
246+ // All of the 1-byte types are placed below for better packing
247+ refEntityType_t reType;
248+
249+ RenderFx renderfx;
243250
244251 EntityTag positionOnTag;
245- int attachmentEntity;
246252
247- vec4_t dynamicLight;
253+ int8_t clearOrigin;
254+ int8_t clearOrigin2;
248255
249- vec3_t lightingOrigin; // so multi-part models can be lit identically (RF_LIGHTING_ORIGIN)
256+ int8_t boundsAdd;
250257
251- vec3_t axis[3 ]; // rotation vectors
252- bool8_t nonNormalizedAxes; // axis are not normalized, i.e. they have scale
258+ int8_t nonNormalizedAxes; // axis are not normalized, i.e. they have scale
253259
254- vec3_t origin;
255- vec3_t oldorigin; // also used as MODEL_BEAM's "to"
260+ int8_t active;
261+
262+ uint16_t attachmentEntity;
263+
264+ uint16_t padding; // for better address alignment of shaderRGBA
256265
257266 Color::Color32Bit shaderRGBA; // colors used by rgbgen entity shaders
258267
259- bool8_t active;
268+ vec4_t dynamicLight; // r, g, b, radius; pre-multiplied by intensity
269+
270+ vec3_t axis[3 ]; // rotation vectors
271+
272+ vec3_t origin;
273+ vec3_t oldorigin; // also used as MODEL_BEAM's "to"
260274
261- vec3_t boundsRotation;
275+ vec3_t boundsRotation;
262276
263277 std::string tag;
264278
0 commit comments