--- code/qcommon/q_shared.h Tue Jan 20 00:26:32 1970 +++ code/qcommon/q_shared.h Tue Jan 20 00:26:32 1970 @@ -1418,8 +1418,10 @@ #define CDKEY_LEN 16 #define CDCHKSUM_LEN 2 #define LERP( a, b, w ) ( ( a ) * ( 1.0f - ( w ) ) + ( b ) * ( w ) ) #define LUMA( red, green, blue ) ( 0.2126f * ( red ) + 0.7152f * ( green ) + 0.0722f * ( blue ) ) +#define MASK_32BITS(shift) ( ( ( (1 << (shift)) ) ^ ( ((shift) & 32) >> 5 ) ) - 1 ) + #endif // __Q_SHARED_H --- code/renderergl1/tr_world.c Tue Jan 20 00:26:32 1970 +++ code/renderergl1/tr_world.c Tue Jan 20 00:26:32 1970 @@ -657,12 +657,12 @@ // determine which leaves are in the PVS / areamask R_MarkLeaves (); // clear out the visible min/max ClearBounds( tr.viewParms.visBounds[0], tr.viewParms.visBounds[1] ); // perform frustum culling and add all the potentially visible surfaces - if ( tr.refdef.num_dlights > 32 ) { - tr.refdef.num_dlights = 32 ; + if ( tr.refdef.num_dlights > MAX_DLIGHTS ) { + tr.refdef.num_dlights = MAX_DLIGHTS ; } - R_RecursiveWorldNode( tr.world->nodes, 15, ( 1 << tr.refdef.num_dlights ) - 1 ); + R_RecursiveWorldNode( tr.world->nodes, 15, MASK_32BITS( tr.refdef.num_dlights ) ); } --- code/renderergl2/tr_world.c Tue Jan 20 00:26:32 1970 +++ code/renderergl2/tr_world.c Tue Jan 20 00:26:32 1970 @@ -778,16 +778,16 @@ if (!(tr.viewParms.flags & VPF_DEPTHSHADOW)) R_MarkLeaves (); // clear out the visible min/max ClearBounds( tr.viewParms.visBounds[0], tr.viewParms.visBounds[1] ); // perform frustum culling and flag all the potentially visible surfaces - if ( tr.refdef.num_dlights > 32 ) { - tr.refdef.num_dlights = 32 ; + if ( tr.refdef.num_dlights > MAX_DLIGHTS ) { + tr.refdef.num_dlights = MAX_DLIGHTS ; } if ( tr.refdef.num_pshadows > 32 ) { tr.refdef.num_pshadows = 32 ; } planeBits = (tr.viewParms.flags & VPF_FARPLANEFRUSTUM) ? 31 : 15; @@ -795,20 +795,20 @@ if ( tr.viewParms.flags & VPF_DEPTHSHADOW ) { dlightBits = 0; pshadowBits = 0; } else if ( !(tr.viewParms.flags & VPF_SHADOWMAP) ) { - dlightBits = ( 1 << tr.refdef.num_dlights ) - 1; - pshadowBits = ( 1 << tr.refdef.num_pshadows ) - 1; + dlightBits = MASK_32BITS( tr.refdef.num_dlights ); + pshadowBits = MASK_32BITS( tr.refdef.num_pshadows ); } else { - dlightBits = ( 1 << tr.refdef.num_dlights ) - 1; + dlightBits = MASK_32BITS( tr.refdef.num_dlights ); pshadowBits = 0; } R_RecursiveWorldNode( tr.world->nodes, planeBits, dlightBits, pshadowBits); // now add all the potentially visible surfaces // also mask invisible dlights for next frame