From d37768fc194ed203cc007c5724b57bc53211eada Mon Sep 17 00:00:00 2001 From: sigsegv Date: Sat, 15 Oct 2022 06:52:44 -0700 Subject: [PATCH] Fix even more build errors caused by c33f715: mathlib (#107) This fixes the mathlib build, at least for me. I didn't bother to fix code in e.g. raytrace or vgui_controls, so things are almost certainly still broken in there. --- mathlib/imagequant.cpp | 4 ++-- mathlib/mathlib_base.cpp | 10 +++++----- mathlib/quantize.cpp | 4 ++-- mathlib/simdvectormatrix.cpp | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/mathlib/imagequant.cpp b/mathlib/imagequant.cpp index fddafa74..158adb0f 100644 --- a/mathlib/imagequant.cpp +++ b/mathlib/imagequant.cpp @@ -46,7 +46,7 @@ void ColorQuantize(uint8 const *Image, val1+=PIXEL(x,y,c)*ExtraValueXForms[i*3+c]; val1>>=8; NthSample(s,y*Width+x,N_DIMENSIONS)->Value[c]=(uint8) - (min(255,max(0,val1))); + (V_min(255,V_max(0,val1))); } } struct QuantizedValue *q=Quantize(s,Width*Height,N_DIMENSIONS, @@ -76,7 +76,7 @@ void ColorQuantize(uint8 const *Image, tryc+=Error[x][c][ErrorUse]; Error[x][c][ErrorUse]=0; } - samp[c]=(uint8) min(255,max(0,tryc)); + samp[c]=(uint8) V_min(255,V_max(0,tryc)); } struct QuantizedValue *f=FindMatch(samp,3,Weights,q); out_pixels[Width*y+x]=(uint8) (f->value); diff --git a/mathlib/mathlib_base.cpp b/mathlib/mathlib_base.cpp index 47a913ef..41f65e26 100644 --- a/mathlib/mathlib_base.cpp +++ b/mathlib/mathlib_base.cpp @@ -1777,7 +1777,7 @@ void QuaternionScale( const Quaternion &p, float t, Quaternion &q ) // FIXME: nick, this isn't overly sensitive to accuracy, and it may be faster to // use the cos part (w) of the quaternion (sin(omega)*N,cos(omega)) to figure the new scale. float sinom = sqrt( DotProduct( &p.x, &p.x ) ); - sinom = min( sinom, 1.f ); + sinom = V_min( sinom, 1.f ); float sinsom = sin( asin( sinom ) * t ); @@ -4057,10 +4057,10 @@ void CalcTriangleTangentSpace( const Vector &p0, const Vector &p1, const Vector //----------------------------------------------------------------------------- void RGBtoHSV( const Vector &rgb, Vector &hsv ) { - float flMax = max( rgb.x, rgb.y ); - flMax = max( flMax, rgb.z ); - float flMin = min( rgb.x, rgb.y ); - flMin = min( flMin, rgb.z ); + float flMax = V_max( rgb.x, rgb.y ); + flMax = V_max( flMax, rgb.z ); + float flMin = V_min( rgb.x, rgb.y ); + flMin = V_min( flMin, rgb.z ); // hsv.z is the value hsv.z = flMax; diff --git a/mathlib/quantize.cpp b/mathlib/quantize.cpp index e1fd88dc..ee46bc89 100644 --- a/mathlib/quantize.cpp +++ b/mathlib/quantize.cpp @@ -411,8 +411,8 @@ static void Label(struct QuantizedValue *q, int updatecolor) else for(int i=0;iMins[i]=min(q->Children[0]->Mins[i],q->Children[1]->Mins[i]); - q->Maxs[i]=max(q->Children[0]->Maxs[i],q->Children[1]->Maxs[i]); + q->Mins[i]=V_min(q->Children[0]->Mins[i],q->Children[1]->Mins[i]); + q->Maxs[i]=V_max(q->Children[0]->Maxs[i],q->Children[1]->Maxs[i]); } } } diff --git a/mathlib/simdvectormatrix.cpp b/mathlib/simdvectormatrix.cpp index 7b200c2e..fd68f06e 100644 --- a/mathlib/simdvectormatrix.cpp +++ b/mathlib/simdvectormatrix.cpp @@ -48,7 +48,7 @@ void CSIMDVectorMatrix::CreateFromRGBA_FloatImageData(int srcwidth, int srcheigh { for(int cp=0;cp<4; cp++) { - int real_cp=min( cp, ntrailing_pixels_per_source_line-1 ); + int real_cp=V_min( cp, ntrailing_pixels_per_source_line-1 ); data_out[4*c+cp]= data_in[c+4*real_cp]; } }