1
0
mirror of https://github.com/alliedmodders/hl2sdk.git synced 2024-12-22 09:38:56 +08:00

Fix conflicts with std::min/max.

This commit is contained in:
David Anderson 2020-05-18 17:46:25 -07:00
parent 46713a22a0
commit c33f7155e9
3 changed files with 14 additions and 15 deletions

View File

@ -350,12 +350,12 @@ FORCEINLINE void VectorClear(vec_t *a)
FORCEINLINE float VectorMaximum(const vec_t *v)
{
return max( v[0], max( v[1], v[2] ) );
return V_max( v[0], V_max( v[1], v[2] ) );
}
FORCEINLINE float VectorMaximum(const Vector& v)
{
return max( v.x, max( v.y, v.z ) );
return V_max( v.x, V_max( v.y, v.z ) );
}
FORCEINLINE void VectorScale (const float* in, vec_t scale, float* out)
@ -380,7 +380,7 @@ inline void VectorNegate(vec_t *a)
}
//#define VectorMaximum(a) ( max( (a)[0], max( (a)[1], (a)[2] ) ) )
//#define VectorMaximum(a) ( V_max( (a)[0], V_max( (a)[1], (a)[2] ) ) )
#define Vector2Clear(x) {(x)[0]=(x)[1]=0;}
#define Vector2Negate(x) {(x)[0]=-((x)[0]);(x)[1]=-((x)[1]);}
#define Vector2Copy(a,b) {(b)[0]=(a)[0];(b)[1]=(a)[1];}
@ -1491,7 +1491,7 @@ FORCEINLINE unsigned char LinearToLightmap( float f )
FORCEINLINE void ColorClamp( Vector& color )
{
float maxc = max( color.x, max( color.y, color.z ) );
float maxc = V_max( color.x, V_max( color.y, color.z ) );
if ( maxc > 1.0f )
{
float ooMax = 1.0f / maxc;
@ -1987,10 +1987,10 @@ FORCEINLINE unsigned int * PackNormal_SHORT2( float nx, float ny, float nz, unsi
ny *= 16384.0f;
// '0' and '32768' values are invalid encodings
nx = max( nx, 1.0f ); // Make sure there are no zero values
ny = max( ny, 1.0f );
nx = min( nx, 32767.0f ); // Make sure there are no 32768 values
ny = min( ny, 32767.0f );
nx = V_max( nx, 1.0f ); // Make sure there are no zero values
ny = V_max( ny, 1.0f );
nx = V_min( nx, 32767.0f ); // Make sure there are no 32768 values
ny = V_min( ny, 32767.0f );
if ( nz < 0.0f )
nx = -nx; // Set the sign bit for z
@ -2181,6 +2181,5 @@ inline bool AlmostEqual( const Vector &a, const Vector &b, int maxUlps = 10)
AlmostEqual( a.z, b.z, maxUlps );
}
#endif // MATH_BASE_H

View File

@ -8,11 +8,11 @@
#ifndef MINMAX_H
#define MINMAX_H
#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
#ifndef V_min
#define V_min(a,b) (((a) < (b)) ? (a) : (b))
#endif
#ifndef max
#define max(a,b) (((a) > (b)) ? (a) : (b))
#ifndef V_max
#define V_max(a,b) (((a) > (b)) ? (a) : (b))
#endif
#endif // MINMAX_H

View File

@ -1771,7 +1771,7 @@ struct thinModelVertices_t
{
Assert( ( m_numBoneInfluences >= 1 ) && ( m_numBoneInfluences <= 3 ) );
Assert( ( boneWeights.numbones >= 1 ) && ( boneWeights.numbones <= m_numBoneInfluences ) );
int numStoredWeights = max( 0, ( m_numBoneInfluences - 1 ) );
int numStoredWeights = V_max( 0, ( m_numBoneInfluences - 1 ) );
float *pBaseWeight = m_boneWeights + vertIndex*numStoredWeights;
char *pBaseIndex = m_boneIndices + vertIndex*m_numBoneInfluences;
for ( int i = 0; i < m_numBoneInfluences; i++ )
@ -1841,7 +1841,7 @@ private:
Assert( pBoneWeights );
Assert( ( m_numBoneInfluences <= 1 ) || ( m_boneWeights != NULL ) );
Assert( ( m_numBoneInfluences <= 0 ) || ( m_boneIndices != NULL ) );
int numStoredWeights = max( 0, ( m_numBoneInfluences - 1 ) );
int numStoredWeights = V_max( 0, ( m_numBoneInfluences - 1 ) );
float *pBaseWeight = m_boneWeights + vertIndex*numStoredWeights;
char *pBaseIndex = m_boneIndices + vertIndex*m_numBoneInfluences;
float sum = 0.0f;