rename clamp macro to Clamp to fix compilation with g++11 (and clamp2 for consistency sake)

This commit is contained in:
withmorten
2021-06-28 13:57:05 +02:00
parent f8297df9c5
commit d17d437de3
41 changed files with 189 additions and 189 deletions

View File

@@ -493,7 +493,7 @@ CCoronas::RenderReflections(void)
if(spriteCoors.z < drawDist){
float fadeDistance = drawDist / 2.0f;
float distanceFade = spriteCoors.z < fadeDistance ? 1.0f : 1.0f - (spriteCoors.z - fadeDistance)/fadeDistance;
distanceFade = clamp(distanceFade, 0.0f, 1.0f);
distanceFade = Clamp(distanceFade, 0.0f, 1.0f);
float recipz = 1.0f/RwCameraGetNearClipPlane(Scene.camera);
float heightFade = (20.0f - aCoronas[i].heightAboveRoad)/20.0f;
int intensity = distanceFade*heightFade * 230.0 * CWeather::WetRoads;

View File

@@ -1155,7 +1155,7 @@ void CScriptPath::Update(void) {
return;
m_fPosition += m_fSpeed * CTimer::GetTimeStepInSeconds();
m_fPosition = clamp(m_fPosition, 0.0f, m_fTotalLength);
m_fPosition = Clamp(m_fPosition, 0.0f, m_fTotalLength);
if (m_pObjects[0] || m_pObjects[1] || m_pObjects[2] || m_pObjects[3]
|| m_pObjects[4] || m_pObjects[5]) {

View File

@@ -151,9 +151,9 @@ CFallingGlassPane::Render(void)
uint8 alpha = CGlass::CalcAlphaWithNormal(&fwdNorm);
#ifdef FIX_BUGS
uint16 time = clamp(CTimer::GetTimeInMilliseconds() > m_nTimer ? CTimer::GetTimeInMilliseconds() - m_nTimer : 0u, 0u, 500u);
uint16 time = Clamp(CTimer::GetTimeInMilliseconds() > m_nTimer ? CTimer::GetTimeInMilliseconds() - m_nTimer : 0u, 0u, 500u);
#else
uint16 time = clamp(CTimer::GetTimeInMilliseconds() - m_nTimer, 0, 500);
uint16 time = Clamp(CTimer::GetTimeInMilliseconds() - m_nTimer, 0, 500);
#endif
uint8 color = int32( float(alpha) * (float(time) / 500) );

View File

@@ -2070,7 +2070,7 @@ float CHud::DrawFadeState(DRAW_FADE_STATE fadingElement, int forceFadingIn)
break;
}
return clamp(alpha, 0.0f, 255.0f);
return Clamp(alpha, 0.0f, 255.0f);
}
void

View File

@@ -283,10 +283,10 @@ CMBlur::CreateImmediateModeData(RwCamera *cam, RwRect *rect, RwIm2DVertex *verts
v1 = y1/height + v1Off;
u2 = x2/width + u2Off;
v2 = y2/height + v2Off;
u1 = clamp(u1, 0.0f, 1.0f);
v1 = clamp(v1, 0.0f, 1.0f);
u2 = clamp(u2, 0.0f, 1.0f);
v2 = clamp(v2, 0.0f, 1.0f);
u1 = Clamp(u1, 0.0f, 1.0f);
v1 = Clamp(v1, 0.0f, 1.0f);
u2 = Clamp(u2, 0.0f, 1.0f);
v2 = Clamp(v2, 0.0f, 1.0f);
}
float recipz = 1.0f/z;
@@ -517,7 +517,7 @@ CMBlur::OverlayRender(RwCamera *cam, RwRaster *raster, RwRGBA color, int32 type,
void
CMBlur::SetDrunkBlur(float drunkness)
{
Drunkness = clamp(drunkness, 0.0f, 1.0f);
Drunkness = Clamp(drunkness, 0.0f, 1.0f);
}
void
@@ -598,9 +598,9 @@ CMBlur::OverlayRenderFx(RwCamera *cam, RwRaster *frontBuf)
int red = (0.75f*CTimeCycle::GetDirectionalRed() + CTimeCycle::GetAmbientRed())*0.55f * 255;
int green = (0.75f*CTimeCycle::GetDirectionalGreen() + CTimeCycle::GetAmbientGreen())*0.55f * 255;
int blue = (0.75f*CTimeCycle::GetDirectionalBlue() + CTimeCycle::GetAmbientBlue())*0.55f * 255;
red = clamp(red, 0, 255);
green = clamp(green, 0, 255);
blue = clamp(blue, 0, 255);
red = Clamp(red, 0, 255);
green = Clamp(green, 0, 255);
blue = Clamp(blue, 0, 255);
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
@@ -695,7 +695,7 @@ CMBlur::OverlayRenderFx(RwCamera *cam, RwRaster *frontBuf)
int alpha = FrontEndMenuManager.m_PrefsBrightness > 255 ?
FrontEndMenuManager.m_PrefsBrightness - 90 :
FrontEndMenuManager.m_PrefsBrightness - 130;
alpha = clamp(alpha, 16, 200)/2;
alpha = Clamp(alpha, 16, 200)/2;
CreateImmediateModeData(cam, &fxRect[i], verts, CRGBA(0, 0, 0, alpha), 0.0f, 0.0f, 0.0f, 0.0f, fxZ[i], true);
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, gpHeatHazeRaster);

View File

@@ -971,15 +971,15 @@ CParticle *CParticle::AddParticle(tParticleType type, CVector const &vecPos, CVe
int32 ColorVariation = CGeneral::GetRandomNumberInRange(-psystem->m_InitialColorVariation, psystem->m_InitialColorVariation);
//float ColorVariation = CGeneral::GetRandomNumberInRange((float)-psystem->m_InitialColorVariation, (float)psystem->m_InitialColorVariation);
pParticle->m_Color.red = clamp(pParticle->m_Color.red +
pParticle->m_Color.red = Clamp(pParticle->m_Color.red +
PERCENT(pParticle->m_Color.red, ColorVariation),
0, 255);
pParticle->m_Color.green = clamp(pParticle->m_Color.green +
pParticle->m_Color.green = Clamp(pParticle->m_Color.green +
PERCENT(pParticle->m_Color.green, ColorVariation),
0, 255);
pParticle->m_Color.blue = clamp(pParticle->m_Color.blue +
pParticle->m_Color.blue = Clamp(pParticle->m_Color.blue +
PERCENT(pParticle->m_Color.blue, ColorVariation),
0, 255);
}
@@ -1385,15 +1385,15 @@ void CParticle::Update()
{
float colorMul = 1.0f - float(particle->m_nTimeWhenColorWillBeChanged - CTimer::GetTimeInMilliseconds()) / float(psystem->m_ColorFadeTime);
particle->m_Color.red = clamp(
particle->m_Color.red = Clamp(
psystem->m_RenderColouring.red + int32(float(psystem->m_FadeDestinationColor.red - psystem->m_RenderColouring.red) * colorMul),
0, 255);
particle->m_Color.green = clamp(
particle->m_Color.green = Clamp(
psystem->m_RenderColouring.green + int32(float(psystem->m_FadeDestinationColor.green - psystem->m_RenderColouring.green) * colorMul),
0, 255);
particle->m_Color.blue = clamp(
particle->m_Color.blue = Clamp(
psystem->m_RenderColouring.blue + int32(float(psystem->m_FadeDestinationColor.blue - psystem->m_RenderColouring.blue) * colorMul),
0, 255);
}
@@ -1703,13 +1703,13 @@ void CParticle::Update()
if ( particle->m_nFadeToBlackTimer != 0 )
{
particle->m_nColorIntensity = clamp(particle->m_nColorIntensity - particle->m_nFadeToBlackTimer,
particle->m_nColorIntensity = Clamp(particle->m_nColorIntensity - particle->m_nFadeToBlackTimer,
0, 255);
}
if ( particle->m_nFadeAlphaTimer != 0 )
{
particle->m_nAlpha = clamp(particle->m_nAlpha - particle->m_nFadeAlphaTimer,
particle->m_nAlpha = Clamp(particle->m_nAlpha - particle->m_nFadeAlphaTimer,
0, 255);
if ( particle->m_nAlpha == 0 )
{

View File

@@ -401,13 +401,13 @@ CSprite::RenderBufferedOneXLUSprite_Rotate_2Colours(float x, float y, float z, f
// Colour factors, cx/y is the direction in which colours change from rgb1 to rgb2
cf[0] = (cx*(-c-s) + cy*(-c+s))*0.5f + 0.5f;
cf[0] = clamp(cf[0], 0.0f, 1.0f);
cf[0] = Clamp(cf[0], 0.0f, 1.0f);
cf[1] = (cx*(-c+s) + cy*( c+s))*0.5f + 0.5f;
cf[1] = clamp(cf[1], 0.0f, 1.0f);
cf[1] = Clamp(cf[1], 0.0f, 1.0f);
cf[2] = (cx*( c+s) + cy*( c-s))*0.5f + 0.5f;
cf[2] = clamp(cf[2], 0.0f, 1.0f);
cf[2] = Clamp(cf[2], 0.0f, 1.0f);
cf[3] = (cx*( c-s) + cy*(-c-s))*0.5f + 0.5f;
cf[3] = clamp(cf[3], 0.0f, 1.0f);
cf[3] = Clamp(cf[3], 0.0f, 1.0f);
float screenz = m_f2DNearScreenZ +
(z-CDraw::GetNearClipZ())*(m_f2DFarScreenZ-m_f2DNearScreenZ)*CDraw::GetFarClipZ() /

View File

@@ -179,10 +179,10 @@ CWaterLevel::Initialise(Const char *pWaterDat)
int32 t = WATER_HUGE_Y(ms_aWaterRects[i].top);
int32 b = WATER_HUGE_Y(ms_aWaterRects[i].bottom) + 1.0f;
l = clamp(l, 0, MAX_SMALL_SECTORS - 1);
r = clamp(r, 0, MAX_SMALL_SECTORS - 1);
t = clamp(t, 0, MAX_SMALL_SECTORS - 1);
b = clamp(b, 0, MAX_SMALL_SECTORS - 1);
l = Clamp(l, 0, MAX_SMALL_SECTORS - 1);
r = Clamp(r, 0, MAX_SMALL_SECTORS - 1);
t = Clamp(t, 0, MAX_SMALL_SECTORS - 1);
b = Clamp(b, 0, MAX_SMALL_SECTORS - 1);
for (int32 x = l; x <= r; x++)
{
@@ -991,10 +991,10 @@ CWaterLevel::RenderWater()
if ( bUseCamEndY )
nEndY = WATER_TO_HUGE_SECTOR_Y(camPos.y);
nStartX = clamp(nStartX, 0, MAX_HUGE_SECTORS - 1);
nEndX = clamp(nEndX, 0, MAX_HUGE_SECTORS - 1);
nStartY = clamp(nStartY, 0, MAX_HUGE_SECTORS - 1);
nEndY = clamp(nEndY, 0, MAX_HUGE_SECTORS - 1);
nStartX = Clamp(nStartX, 0, MAX_HUGE_SECTORS - 1);
nEndX = Clamp(nEndX, 0, MAX_HUGE_SECTORS - 1);
nStartY = Clamp(nStartY, 0, MAX_HUGE_SECTORS - 1);
nEndY = Clamp(nEndY, 0, MAX_HUGE_SECTORS - 1);
for ( int32 x = nStartX; x <= nEndX; x++ )
{
@@ -1259,10 +1259,10 @@ CWaterLevel::RenderTransparentWater(void)
if ( bUseCamEndY )
nEndY = WATER_TO_HUGE_SECTOR_Y(camPos.y );
nStartX = clamp(nStartX, 0, MAX_HUGE_SECTORS - 1);
nEndX = clamp(nEndX, 0, MAX_HUGE_SECTORS - 1);
nStartY = clamp(nStartY, 0, MAX_HUGE_SECTORS - 1);
nEndY = clamp(nEndY, 0, MAX_HUGE_SECTORS - 1);
nStartX = Clamp(nStartX, 0, MAX_HUGE_SECTORS - 1);
nEndX = Clamp(nEndX, 0, MAX_HUGE_SECTORS - 1);
nStartY = Clamp(nStartY, 0, MAX_HUGE_SECTORS - 1);
nEndY = Clamp(nEndY, 0, MAX_HUGE_SECTORS - 1);
for ( int32 x = nStartX; x <= nEndX; x++ )
@@ -2161,10 +2161,10 @@ CWaterLevel::PreCalcWaterGeometry(void)
float signX = CamFwdDir.x * 1.4144272f;
float signY = CamFwdDir.y * 1.4144272f;
signX = clamp(signX, -1.0f, 1.0f);
signX = Clamp(signX, -1.0f, 1.0f);
fCamX += 0.4f * signX * float(SMALL_SECTOR_SIZE * 2.0f);
signY = clamp(signY, -1.0f, 1.0f);
signY = Clamp(signY, -1.0f, 1.0f);
fCamY += 0.4f * signY * float(SMALL_SECTOR_SIZE * 2.0f);
int32 nBlock;
@@ -2578,7 +2578,7 @@ CWaterLevel::RenderBoatWakes(void)
float val = 500.0f - (CBoat::WAKE_LIFETIME - pBoat->m_afWakePointLifeTime[wake])
* 600.0f / CBoat::WAKE_LIFETIME;
fAplhaB = clamp(val, 0.0f, 255.0f);
fAplhaB = Clamp(val, 0.0f, 255.0f);
}
CVector2D vecDistB = pBoat->m_avec2dWakePoints[wake - 1] - pBoat->m_avec2dWakePoints[wake];
@@ -2888,10 +2888,10 @@ CWaterLevel::CalcDistanceToWater(float fX, float fY)
int32 nStartY = WATER_TO_SMALL_SECTOR_Y(fY - fSectorMaxRenderDist) - 1;
int32 nEndY = WATER_TO_SMALL_SECTOR_Y(fY + fSectorMaxRenderDist) + 1;
nStartX = clamp(nStartX, 0, MAX_SMALL_SECTORS - 1);
nEndX = clamp(nEndX, 0, MAX_SMALL_SECTORS - 1);
nStartY = clamp(nStartY, 0, MAX_SMALL_SECTORS - 1);
nEndY = clamp(nEndY, 0, MAX_SMALL_SECTORS - 1);
nStartX = Clamp(nStartX, 0, MAX_SMALL_SECTORS - 1);
nEndX = Clamp(nEndX, 0, MAX_SMALL_SECTORS - 1);
nStartY = Clamp(nStartY, 0, MAX_SMALL_SECTORS - 1);
nEndY = Clamp(nEndY, 0, MAX_SMALL_SECTORS - 1);
float fDistSqr = 1.0e10f;
@@ -2915,7 +2915,7 @@ CWaterLevel::CalcDistanceToWater(float fX, float fY)
}
}
return clamp(Sqrt(fDistSqr) - 23.0f, 0.0f, fSectorMaxRenderDist);
return Clamp(Sqrt(fDistSqr) - 23.0f, 0.0f, fSectorMaxRenderDist);
}
void

View File

@@ -281,7 +281,7 @@ void CWeather::Update(void)
if (SunGlare > 0.0f) {
SunGlare *= Min(1.0f, 7.0 * CTimeCycle::GetSunDirection().z);
SunGlare = clamp(SunGlare, 0.0f, 1.0f);
SunGlare = Clamp(SunGlare, 0.0f, 1.0f);
if (!CSpecialFX::bSnapShotActive)
SunGlare *= (1.0f - (CGeneral::GetRandomNumber()&0x1F)*0.007f);
}