Skip to content

Commit a52a60e

Browse files
committed
Merge master into for-0.56.0/sync
2 parents 5bb6b8b + f160c3a commit a52a60e

File tree

7 files changed

+45
-64
lines changed

7 files changed

+45
-64
lines changed

cmake/DaemonGame.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ function(gameSubProject)
156156
-DBUILD_CLIENT=OFF
157157
-DBUILD_TTY_CLIENT=OFF
158158
-DBUILD_SERVER=OFF
159+
-DBUILD_DUMMY_GAMELOGIC=${BUILD_DUMMY_GAMELOGIC}
159160
${ARGV}
160161
${INHERITED_OPTION_ARGS}
161162
INSTALL_COMMAND ""

src/engine/qcommon/q_math.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -627,16 +627,16 @@ float AngleSubtract( float a1, float a2 )
627627
return a - 360.0f * floor( ( a + 180.0f ) / 360.0f );
628628
}
629629

630-
void AnglesSubtract( vec3_t v1, vec3_t v2, vec3_t v3 )
630+
void AnglesSubtract( const vec3_t v1, const vec3_t v2, vec3_t v3 )
631631
{
632632
v3[ 0 ] = AngleSubtract( v1[ 0 ], v2[ 0 ] );
633633
v3[ 1 ] = AngleSubtract( v1[ 1 ], v2[ 1 ] );
634634
v3[ 2 ] = AngleSubtract( v1[ 2 ], v2[ 2 ] );
635635
}
636636

637-
float AngleMod( float a )
637+
DEPRECATED float AngleMod( float a )
638638
{
639-
return ( ( 360.0f / 65536 ) * ( ( int )( a * ( 65536 / 360.0f ) ) & 65535 ) );
639+
return AngleNormalize360( a );
640640
}
641641

642642
/*
@@ -1453,7 +1453,7 @@ void MatrixTranspose( const matrix_t in, matrix_t out )
14531453
}
14541454

14551455
// helper functions for MatrixInverse from GtkRadiant C mathlib
1456-
static float m3_det( matrix3x3_t mat )
1456+
WARN_UNUSED_RESULT static float m3_det( const matrix3x3_t mat )
14571457
{
14581458
float det;
14591459

@@ -1489,7 +1489,7 @@ static float m3_det( matrix3x3_t mat )
14891489
* return 0;
14901490
* }*/
14911491

1492-
static void m4_submat( matrix_t mr, matrix3x3_t mb, int i, int j )
1492+
static void m4_submat( const matrix_t mr, matrix3x3_t mb, int i, int j )
14931493
{
14941494
int ti, tj, idst = 0, jdst = 0;
14951495

@@ -1525,7 +1525,7 @@ static void m4_submat( matrix_t mr, matrix3x3_t mb, int i, int j )
15251525
}
15261526
}
15271527

1528-
static float m4_det( matrix_t mr )
1528+
WARN_UNUSED_RESULT static float m4_det( const matrix_t mr )
15291529
{
15301530
float det, result = 0, i = 1;
15311531
matrix3x3_t msub3;

src/engine/qcommon/q_shared.h

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ float Q_rsqrt( float n )
403403
The relative error bound is: 6.50196699×10⁻⁴ */
404404

405405
// Compute approximate inverse square root.
406-
inline float Q_rsqrt_fast( const float n )
406+
WARN_UNUSED_RESULT inline float Q_rsqrt_fast( const float n )
407407
{
408408
#if defined(DAEMON_USE_ARCH_INTRINSICS_i686_sse)
409409
float o;
@@ -422,7 +422,7 @@ inline float Q_rsqrt_fast( const float n )
422422
return o;
423423
}
424424

425-
inline float Q_rsqrt( const float n )
425+
WARN_UNUSED_RESULT inline float Q_rsqrt( const float n )
426426
{
427427
/* When using the magic constants, the relative error bound after the
428428
iteration is expected to be at most 5×10⁻⁶. It was achieved with the
@@ -440,19 +440,19 @@ inline float Q_rsqrt( const float n )
440440
return o;
441441
}
442442

443-
inline float Q_fabs( float x )
443+
WARN_UNUSED_RESULT inline float Q_fabs( float x )
444444
{
445445
return fabsf( x );
446446
}
447447

448-
byte ClampByte( int i );
449-
signed char ClampChar( int i );
448+
WARN_UNUSED_RESULT byte ClampByte( int i );
449+
WARN_UNUSED_RESULT signed char ClampChar( int i );
450450

451451
// this isn't a real cheap function to call!
452-
int DirToByte( vec3_t const dir );
452+
WARN_UNUSED_RESULT int DirToByte( vec3_t const dir );
453453
void ByteToDir( int b, vec3_t dir );
454454

455-
inline vec_t DotProduct( const vec3_t x, const vec3_t y )
455+
WARN_UNUSED_RESULT inline vec_t DotProduct( const vec3_t x, const vec3_t y )
456456
{
457457
return x[ 0 ] * y[ 0 ] + x[ 1 ] * y[ 1 ] + x[ 2 ] * y[ 2 ];
458458
}
@@ -465,7 +465,7 @@ inline void CrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross )
465465
}
466466

467467
template<typename A>
468-
decltype(std::declval<A>() * std::declval<A>()) Square( const A &a )
468+
WARN_UNUSED_RESULT decltype(std::declval<A>() * std::declval<A>()) Square( const A &a )
469469
{
470470
return a * a;
471471
}
@@ -587,16 +587,16 @@ void SnapVector( V &&v )
587587
( r )[ 1 ] = ( s )[ 1 ] + ( f ) * (( e )[ 1 ] - ( s )[ 1 ] ), \
588588
( r )[ 2 ] = ( s )[ 2 ] + ( f ) * (( e )[ 2 ] - ( s )[ 2 ] ))
589589

590-
float RadiusFromBounds( const vec3_t mins, const vec3_t maxs );
590+
WARN_UNUSED_RESULT float RadiusFromBounds( const vec3_t mins, const vec3_t maxs );
591591
void ZeroBounds( vec3_t mins, vec3_t maxs );
592592
void ClearBounds( vec3_t mins, vec3_t maxs );
593593
void AddPointToBounds( const vec3_t v, vec3_t mins, vec3_t maxs );
594594

595595
void BoundsAdd( vec3_t mins, vec3_t maxs, const vec3_t mins2, const vec3_t maxs2 );
596-
bool BoundsIntersect( const vec3_t mins, const vec3_t maxs, const vec3_t mins2, const vec3_t maxs2 );
597-
bool BoundsIntersectSphere( const vec3_t mins, const vec3_t maxs, const vec3_t origin, vec_t radius );
598-
bool BoundsIntersectPoint( const vec3_t mins, const vec3_t maxs, const vec3_t origin );
599-
float BoundsMaxExtent( const vec3_t mins, const vec3_t maxs );
596+
WARN_UNUSED_RESULT bool BoundsIntersect( const vec3_t mins, const vec3_t maxs, const vec3_t mins2, const vec3_t maxs2 );
597+
WARN_UNUSED_RESULT bool BoundsIntersectSphere( const vec3_t mins, const vec3_t maxs, const vec3_t origin, vec_t radius );
598+
WARN_UNUSED_RESULT bool BoundsIntersectPoint( const vec3_t mins, const vec3_t maxs, const vec3_t origin );
599+
WARN_UNUSED_RESULT float BoundsMaxExtent( const vec3_t mins, const vec3_t maxs );
600600

601601
inline void BoundsToCorners( const vec3_t mins, const vec3_t maxs, vec3_t corners[ 8 ] )
602602
{
@@ -617,7 +617,7 @@ void SnapVector( V &&v )
617617
out[ 2 ] = from[ 2 ] + ( ( to[ 2 ] - from[ 2 ] ) * frac );
618618
}
619619

620-
inline int VectorCompareEpsilon( const vec3_t v1, const vec3_t v2, float epsilon )
620+
WARN_UNUSED_RESULT inline int VectorCompareEpsilon( const vec3_t v1, const vec3_t v2, float epsilon )
621621
{
622622
vec3_t d;
623623

@@ -648,29 +648,29 @@ void SnapVector( V &&v )
648648
out[2] = a[2] > b[2] ? a[2] : b[2];
649649
}
650650

651-
inline int VectorCompare( const vec3_t v1, const vec3_t v2 )
651+
WARN_UNUSED_RESULT inline bool VectorCompare( const vec3_t v1, const vec3_t v2 )
652652
{
653653
return !( v1[ 0 ] != v2[ 0 ] || v1[ 1 ] != v2[ 1 ] || v1[ 2 ] != v2[ 2 ] );
654654
}
655655

656-
inline vec_t VectorLengthSquared( const vec3_t v )
656+
WARN_UNUSED_RESULT inline vec_t VectorLengthSquared( const vec3_t v )
657657
{
658658
return v[ 0 ] * v[ 0 ] + v[ 1 ] * v[ 1 ] + v[ 2 ] * v[ 2 ];
659659
}
660660

661-
inline vec_t VectorLength( const vec3_t v )
661+
WARN_UNUSED_RESULT inline vec_t VectorLength( const vec3_t v )
662662
{
663663
return sqrtf( VectorLengthSquared( v ) );
664664
}
665665

666-
inline vec_t Distance( const vec3_t p1, const vec3_t p2 )
666+
WARN_UNUSED_RESULT inline vec_t Distance( const vec3_t p1, const vec3_t p2 )
667667
{
668668
vec3_t v;
669669
VectorSubtract( p2, p1, v );
670670
return VectorLength( v );
671671
}
672672

673-
inline vec_t DistanceSquared( const vec3_t p1, const vec3_t p2 )
673+
WARN_UNUSED_RESULT inline vec_t DistanceSquared( const vec3_t p1, const vec3_t p2 )
674674
{
675675
vec3_t v;
676676
VectorSubtract( p2, p1, v );
@@ -735,7 +735,7 @@ inline vec_t VectorNormalize2( const vec3_t v, vec3_t out )
735735
return length;
736736
}
737737

738-
int NearestPowerOfTwo( int val );
738+
WARN_UNUSED_RESULT int NearestPowerOfTwo( int val );
739739

740740
int Q_rand( int *seed );
741741
float Q_random( int *seed );
@@ -757,17 +757,17 @@ inline vec_t VectorNormalize2( const vec3_t v, vec3_t out )
757757
void AxisCopy( const vec3_t in[ 3 ], vec3_t out[ 3 ] );
758758

759759
void SetPlaneSignbits( struct cplane_t *out );
760-
int BoxOnPlaneSide( const vec3_t emins, const vec3_t emaxs, const struct cplane_t *plane );
760+
WARN_UNUSED_RESULT int BoxOnPlaneSide( const vec3_t emins, const vec3_t emaxs, const struct cplane_t *plane );
761761

762-
float AngleMod( float a );
763-
float LerpAngle( float from, float to, float frac );
764-
float AngleSubtract( float a1, float a2 );
765-
void AnglesSubtract( vec3_t v1, vec3_t v2, vec3_t v3 );
762+
WARN_UNUSED_RESULT DEPRECATED float AngleMod( float a );
763+
WARN_UNUSED_RESULT float LerpAngle( float from, float to, float frac );
764+
WARN_UNUSED_RESULT float AngleSubtract( float a1, float a2 );
765+
void AnglesSubtract( const vec3_t v1, const vec3_t v2, vec3_t v3 );
766766

767-
float AngleNormalize360( float angle );
768-
float AngleNormalize180( float angle );
769-
float AngleDelta( float angle1, float angle2 );
770-
float AngleBetweenVectors( const vec3_t a, const vec3_t b );
767+
WARN_UNUSED_RESULT float AngleNormalize360( float angle );
768+
WARN_UNUSED_RESULT float AngleNormalize180( float angle );
769+
WARN_UNUSED_RESULT float AngleDelta( float angle1, float angle2 );
770+
WARN_UNUSED_RESULT float AngleBetweenVectors( const vec3_t a, const vec3_t b );
771771
void AngleVectors( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up );
772772

773773
void PlaneSet( plane_t &out, const vec_t x, const vec_t y, const vec_t z, const vec_t dist );
@@ -804,13 +804,10 @@ inline vec_t VectorNormalize2( const vec3_t v, vec3_t out )
804804
void AxisMultiply( const float in1[ 3 ][ 3 ], const float in2[ 3 ][ 3 ], float out[ 3 ][ 3 ] );
805805
void PerpendicularVector( vec3_t dst, const vec3_t src );
806806

807-
// Ridah
808807
void GetPerpendicularViewVector( const vec3_t point, const vec3_t p1, const vec3_t p2, vec3_t up );
809808
void ProjectPointOntoVector( const vec3_t point, const vec3_t vStart, const vec3_t vEnd, vec3_t vProj );
810809
void ProjectPointOntoVectorBounded( const vec3_t point, const vec3_t vStart, const vec3_t vEnd, vec3_t vProj );
811-
float DistanceFromLineSquared( const vec3_t p, const vec3_t lp1, const vec3_t lp2 );
812-
813-
// done.
810+
WARN_UNUSED_RESULT float DistanceFromLineSquared( const vec3_t p, const vec3_t lp1, const vec3_t lp2 );
814811

815812
vec_t DistanceBetweenLineSegmentsSquared( const vec3_t sP0, const vec3_t sP1,
816813
const vec3_t tP0, const vec3_t tP1, float *s, float *t );
@@ -822,7 +819,7 @@ inline vec_t VectorNormalize2( const vec3_t v, vec3_t out )
822819
void MatrixIdentity( matrix_t m );
823820
void MatrixClear( matrix_t m );
824821
void MatrixCopy( const matrix_t in, matrix_t out );
825-
bool MatrixCompare( const matrix_t a, const matrix_t b );
822+
WARN_UNUSED_RESULT bool MatrixCompare( const matrix_t a, const matrix_t b );
826823
void MatrixTransposeIntoXMM( const matrix_t m );
827824
void MatrixTranspose( const matrix_t in, matrix_t out );
828825

@@ -961,7 +958,7 @@ inline vec_t VectorNormalize2( const vec3_t v, vec3_t out )
961958
q[ 3 ] = -q[ 3 ];
962959
}
963960

964-
inline vec_t QuatLength( const quat_t q )
961+
WARN_UNUSED_RESULT inline vec_t QuatLength( const quat_t q )
965962
{
966963
return ( vec_t ) sqrt( q[ 0 ] * q[ 0 ] + q[ 1 ] * q[ 1 ] + q[ 2 ] * q[ 2 ] + q[ 3 ] * q[ 3 ] );
967964
}

src/engine/renderer/Material.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,12 +776,14 @@ static std::string GetStageInfo( const shaderStage_t* pStage, const uint32_t dyn
776776
"base variant ",
777777
"vertex overbright ",
778778
"vertex-lit ",
779-
"fullbright ",
780779
"vertex overbright vertex-lit ",
780+
"fullbright ",
781781
"vertex overbright fullbright ",
782782
"vertex-lit fullbright ",
783783
"vertex overbright vertex-lit fullbright"
784784
};
785+
static_assert( ARRAY_LEN( stageVariants ) == ShaderStageVariant::ALL,
786+
"update stage variant text descriptions" );
785787

786788
uint32_t variants = 0;
787789
for ( int i = 0; i < ShaderStageVariant::ALL && variants < pStage->variantOffset; i++ ) {

src/engine/renderer/gl_shader.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2738,7 +2738,6 @@ struct colorModulation_t {
27382738
float alphaGen = 0.0f;
27392739
float lightFactor = 1.0f;
27402740
bool useVertexLightFactor = false;
2741-
bool alphaAddOne = true;
27422741
};
27432742

27442743
static colorModulation_t ColorModulateColorGen(
@@ -2752,8 +2751,6 @@ static colorModulation_t ColorModulateColorGen(
27522751
switch ( colorGen )
27532752
{
27542753
case colorGen_t::CGEN_VERTEX:
2755-
colorModulation.alphaAddOne = false;
2756-
27572754
if ( vertexOverbright )
27582755
{
27592756
// vertexOverbright is only needed for non-lightmapped cases. When there is a
@@ -2768,7 +2765,6 @@ static colorModulation_t ColorModulateColorGen(
27682765
break;
27692766

27702767
case colorGen_t::CGEN_ONE_MINUS_VERTEX:
2771-
colorModulation.alphaAddOne = false;
27722768
colorModulation.colorGen = -1.0f;
27732769
break;
27742770

@@ -2785,12 +2781,10 @@ static colorModulation_t ColorModulateColorGen(
27852781
switch ( alphaGen )
27862782
{
27872783
case alphaGen_t::AGEN_VERTEX:
2788-
colorModulation.alphaAddOne = false;;
27892784
colorModulation.alphaGen = 1.0f;
27902785
break;
27912786

27922787
case alphaGen_t::AGEN_ONE_MINUS_VERTEX:
2793-
colorModulation.alphaAddOne = false;;
27942788
colorModulation.alphaGen = -1.0f;
27952789
break;
27962790

@@ -2827,7 +2821,7 @@ class u_ColorModulateColorGen_Float :
28272821
colorModulate_Float[ 0 ] = colorModulation.colorGen;
28282822
colorModulate_Float[ 1 ] = colorModulation.lightFactor;
28292823
colorModulate_Float[ 1 ] *= colorModulation.useVertexLightFactor ? -1.0f : 1.0f;
2830-
colorModulate_Float[ 2 ] = colorModulation.alphaAddOne;
2824+
colorModulate_Float[ 2 ] = {};
28312825
colorModulate_Float[ 3 ] = colorModulation.alphaGen;
28322826

28332827
this->SetValue( colorModulate_Float );
@@ -2859,7 +2853,6 @@ class u_ColorModulateColorGen_Uint :
28592853
COLOR_MINUS_ONE = 1,
28602854
ALPHA_ONE = 2,
28612855
ALPHA_MINUS_ONE = 3,
2862-
ALPHA_ADD_ONE = 4,
28632856
// <-- Insert new bits there.
28642857
IS_LIGHT_STYLE = 27,
28652858
LIGHTFACTOR_BIT0 = 28,
@@ -2879,8 +2872,6 @@ class u_ColorModulateColorGen_Uint :
28792872
<< Util::ordinal( ColorModulate_Bit::ALPHA_ONE );
28802873
colorModulate_Uint |= ( colorModulation.alphaGen == -1.0f )
28812874
<< Util::ordinal( ColorModulate_Bit::ALPHA_MINUS_ONE );
2882-
colorModulate_Uint |= colorModulation.alphaAddOne
2883-
<< Util::ordinal( ColorModulate_Bit::ALPHA_ADD_ONE );
28842875
colorModulate_Uint |= colorModulation.useVertexLightFactor
28852876
<< Util::ordinal( ColorModulate_Bit::IS_LIGHT_STYLE );
28862877
colorModulate_Uint |= uint32_t( colorModulation.lightFactor )

src/engine/renderer/glsl_source/common.glsl

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ colorMod << 0: color * 1
6868
colorMod << 1: color * ( -1 )
6969
colorMod << 2: alpha * 1
7070
colorMod << 3: alpha * ( -1 )
71-
colorMod << 4: alpha = 1
72-
colorMod << 5-26: available for future usage
71+
colorMod << 4-26: available for future usage
7372
colorMod << 27: color += lightFactor
7473
colorMod << 28-31: lightFactor
7574
@@ -78,7 +77,6 @@ colorMod float format:
7877
colorMod[ 0 ]: color * f
7978
colorMod[ 1 ] absolute value: lightFactor
8079
colorMod[ 1 ] minus sign: color += lightFactor
81-
colorMod[ 2 ]: alpha = 1
8280
colorMod[ 3 ]: alpha * f */
8381

8482
vec4 ColorModulateToColor( const in colorModulatePack colorMod )
@@ -101,7 +99,6 @@ vec4 ColorModulateToColor( const in colorModulatePack colorMod )
10199

102100
struct ModBits_t
103101
{
104-
bool alphaAddOne;
105102
bool useVertexLightFactor;
106103
};
107104

@@ -110,10 +107,8 @@ ModBits_t ColorModulateToBits( const in colorModulatePack colorMod )
110107
ModBits_t modBits;
111108

112109
#if defined(HAVE_EXT_gpu_shader4)
113-
modBits.alphaAddOne = bool( ( colorMod >> 4u ) & 1u );
114110
modBits.useVertexLightFactor = bool( ( colorMod >> 27u ) & 1u );
115111
#else
116-
modBits.alphaAddOne = colorMod.b != 0;
117112
modBits.useVertexLightFactor = colorMod.g < 0;
118113
#endif
119114

@@ -159,9 +154,6 @@ void ColorModulateColor_lightFactor(
159154
ModBits_t modBits = ColorModulateToBits( colorMod );
160155
float lightFactor = ColorModulateToLightFactor( colorMod );
161156

162-
// This is used to skip vertex colours if the colorMod doesn't need them.
163-
color.a = modBits.alphaAddOne ? 1.0 : color.a;
164-
165157
colorModulation.rgb += vec3( modBits.useVertexLightFactor ? lightFactor : 0 );
166158

167159
vec4 unpackedColor = UnpackColor( packedColor );

src/engine/renderer/glsl_source/generic_fp.glsl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,7 @@ void main()
8383
outputColor = color;
8484

8585
// Debugging.
86-
#if defined(r_showVertexColors)
87-
outputColor = vec4(0.0, 0.0, 0.0, 0.0);
88-
#elif defined(USE_MATERIAL_SYSTEM) && defined(r_showGlobalMaterials)
86+
#if defined(USE_MATERIAL_SYSTEM) && defined(r_showGlobalMaterials)
8987
outputColor.rgb = u_MaterialColour;
9088
#endif
9189
}

0 commit comments

Comments
 (0)