summaryrefslogtreecommitdiffstats
path: root/src/vehicles
diff options
context:
space:
mode:
authorwithmorten <morten.with@gmail.com>2021-06-28 13:57:05 +0200
committerwithmorten <morten.with@gmail.com>2021-06-28 13:57:05 +0200
commitd17d437de319ca4c388dc724cffea91702d3a699 (patch)
tree806104fa5fe0e994cd7f55f1b7b48dc64a998c44 /src/vehicles
parentRedo ReadSaveBuf + common.h cleanup (diff)
downloadre3-d17d437de319ca4c388dc724cffea91702d3a699.tar
re3-d17d437de319ca4c388dc724cffea91702d3a699.tar.gz
re3-d17d437de319ca4c388dc724cffea91702d3a699.tar.bz2
re3-d17d437de319ca4c388dc724cffea91702d3a699.tar.lz
re3-d17d437de319ca4c388dc724cffea91702d3a699.tar.xz
re3-d17d437de319ca4c388dc724cffea91702d3a699.tar.zst
re3-d17d437de319ca4c388dc724cffea91702d3a699.zip
Diffstat (limited to 'src/vehicles')
-rw-r--r--src/vehicles/Automobile.cpp20
-rw-r--r--src/vehicles/Bike.cpp16
-rw-r--r--src/vehicles/Boat.cpp22
-rw-r--r--src/vehicles/Door.cpp4
-rw-r--r--src/vehicles/Heli.cpp2
-rw-r--r--src/vehicles/Vehicle.cpp14
6 files changed, 39 insertions, 39 deletions
diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp
index 14f2909b..8a50ddcf 100644
--- a/src/vehicles/Automobile.cpp
+++ b/src/vehicles/Automobile.cpp
@@ -2261,7 +2261,7 @@ CAutomobile::PreRender(void)
// 1.0 if directly behind car, -1.0 if in front
float behindness = DotProduct(lookVector, GetForward());
- behindness = clamp(behindness, -1.0f, 1.0f); // shouldn't be necessary
+ behindness = Clamp(behindness, -1.0f, 1.0f); // shouldn't be necessary
// 0.0 if behind car, PI if in front
// Abs not necessary
float angle = Abs(Acos(behindness));
@@ -2619,7 +2619,7 @@ CAutomobile::PreRender(void)
float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale;
if(GetModelIndex() == MI_VOODOO)
groundOffset *= 0.6f;
- mat.RotateY(Asin(clamp(-groundOffset, -1.0f, 1.0f)));
+ mat.RotateY(Asin(Clamp(-groundOffset, -1.0f, 1.0f)));
}
}
if(pHandling->Flags & HANDLING_FAT_REARW)
@@ -2660,7 +2660,7 @@ CAutomobile::PreRender(void)
float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale;
if(GetModelIndex() == MI_VOODOO)
groundOffset *= 0.6f;
- mat.RotateY(Asin(clamp(groundOffset, -1.0f, 1.0f)));
+ mat.RotateY(Asin(Clamp(groundOffset, -1.0f, 1.0f)));
}
}
if(pHandling->Flags & HANDLING_FAT_REARW)
@@ -2693,7 +2693,7 @@ CAutomobile::PreRender(void)
float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale;
if(GetModelIndex() == MI_VOODOO)
groundOffset *= 0.6f;
- mat.RotateY(Asin(clamp(-groundOffset, -1.0f, 1.0f)));
+ mat.RotateY(Asin(Clamp(-groundOffset, -1.0f, 1.0f)));
}
}
if(pHandling->Flags & HANDLING_FAT_REARW)
@@ -2727,7 +2727,7 @@ CAutomobile::PreRender(void)
float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale;
if(GetModelIndex() == MI_VOODOO)
groundOffset *= 0.6f;
- mat.RotateY(Asin(clamp(groundOffset, -1.0f, 1.0f)));
+ mat.RotateY(Asin(Clamp(groundOffset, -1.0f, 1.0f)));
}
}
if(pHandling->Flags & HANDLING_FAT_REARW)
@@ -2861,7 +2861,7 @@ CAutomobile::PreRender(void)
float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale;
if(GetModelIndex() == MI_VOODOO)
groundOffset *= 0.6f;
- mat.RotateY(Asin(clamp(-groundOffset, -1.0f, 1.0f)));
+ mat.RotateY(Asin(Clamp(-groundOffset, -1.0f, 1.0f)));
}
}
if(pHandling->Flags & HANDLING_NARROW_FRONTW)
@@ -2902,7 +2902,7 @@ CAutomobile::PreRender(void)
float groundOffset = pos.z + m_fHeightAboveRoad - 0.5f*mi->m_wheelScale;
if(GetModelIndex() == MI_VOODOO)
groundOffset *= 0.6f;
- mat.RotateY(Asin(clamp(groundOffset, -1.0f, 1.0f)));
+ mat.RotateY(Asin(Clamp(groundOffset, -1.0f, 1.0f)));
}
}
if(pHandling->Flags & HANDLING_NARROW_FRONTW)
@@ -3120,7 +3120,7 @@ CAutomobile::ProcessControlInputs(uint8 pad)
0.2f*CTimer::GetTimeStep();
nLastControlInput = 0;
}
- m_fSteerInput = clamp(m_fSteerInput, -1.0f, 1.0f);
+ m_fSteerInput = Clamp(m_fSteerInput, -1.0f, 1.0f);
// Accelerate/Brake
float acceleration = (CPad::GetPad(pad)->GetAccelerate() - CPad::GetPad(pad)->GetBrake())/255.0f;
@@ -3239,7 +3239,7 @@ CAutomobile::FireTruckControl(void)
m_fCarGunLR += CPad::GetPad(0)->GetCarGunLeftRight() * 0.00025f * CTimer::GetTimeStep();
m_fCarGunUD += CPad::GetPad(0)->GetCarGunUpDown() * 0.0001f * CTimer::GetTimeStep();
}
- m_fCarGunUD = clamp(m_fCarGunUD, 0.05f, 0.3f);
+ m_fCarGunUD = Clamp(m_fCarGunUD, 0.05f, 0.3f);
CVector cannonPos(0.0f, 1.5f, 1.9f);
@@ -3664,7 +3664,7 @@ CAutomobile::HydraulicControl(void)
float limitDiff = extendedLowerLimit - normalLowerLimit;
if(limitDiff != 0.0f && Abs(maxDelta/limitDiff) > 0.01f){
float f = (maxDelta + limitDiff)/2.0f/limitDiff;
- f = clamp(f, 0.0f, 1.0f);
+ f = Clamp(f, 0.0f, 1.0f);
DMAudio.PlayOneShot(m_audioEntityId, SOUND_CAR_HYDRAULIC_3, f);
if(f < 0.4f || f > 0.6f)
setPrevRatio = true;
diff --git a/src/vehicles/Bike.cpp b/src/vehicles/Bike.cpp
index e5bb3622..c42d342e 100644
--- a/src/vehicles/Bike.cpp
+++ b/src/vehicles/Bike.cpp
@@ -533,7 +533,7 @@ CBike::ProcessControl(void)
m_fWheelAngle += DEGTORAD(1.0f)*CTimer::GetTimeStep();
if(bIsStanding){
float f = Pow(0.97f, CTimer::GetTimeStep());
- m_fLeanLRAngle2 = m_fLeanLRAngle2*f - (Asin(clamp(GetRight().z,-1.0f,1.0f))+DEGTORAD(15.0f))*(1.0f-f);
+ m_fLeanLRAngle2 = m_fLeanLRAngle2*f - (Asin(Clamp(GetRight().z,-1.0f,1.0f))+DEGTORAD(15.0f))*(1.0f-f);
m_fLeanLRAngle = m_fLeanLRAngle2;
}
}else{
@@ -1028,9 +1028,9 @@ CBike::ProcessControl(void)
lean = DotProduct(m_vecMoveSpeed-initialMoveSpeed, m_vecAvgSurfaceRight);
lean /= GRAVITY*Max(CTimer::GetTimeStep(), 0.01f);
if(m_wheelStatus[BIKEWHEEL_FRONT] == WHEEL_STATUS_BURST)
- lean = clamp(lean, -0.4f*pBikeHandling->fMaxLean, 0.4f*pBikeHandling->fMaxLean);
+ lean = Clamp(lean, -0.4f*pBikeHandling->fMaxLean, 0.4f*pBikeHandling->fMaxLean);
else
- lean = clamp(lean, -pBikeHandling->fMaxLean, pBikeHandling->fMaxLean);
+ lean = Clamp(lean, -pBikeHandling->fMaxLean, pBikeHandling->fMaxLean);
float f = Pow(pBikeHandling->fDesLean, CTimer::GetTimeStep());
m_fLeanLRAngle2 = (Asin(lean) - idleAngle)*(1.0f-f) + m_fLeanLRAngle2*f;
}else{
@@ -1053,11 +1053,11 @@ CBike::ProcessControl(void)
if(m_aSuspensionSpringRatio[BIKESUSP_R1] < 1.0f || m_aSuspensionSpringRatio[BIKESUSP_R2] < 1.0f){
// BUG: this clamp makes no sense and the arguments seem swapped too
ApplyTurnForce(contactPoints[BIKESUSP_R1],
- m_fTurnMass*Sin(m_fBrakeDestabilization)*clamp(fwdSpeed, 0.5f, 0.2f)*0.013f*GetRight()*CTimer::GetTimeStep());
+ m_fTurnMass*Sin(m_fBrakeDestabilization)*Clamp(fwdSpeed, 0.5f, 0.2f)*0.013f*GetRight()*CTimer::GetTimeStep());
}else{
// BUG: this clamp makes no sense and the arguments seem swapped too
ApplyTurnForce(contactPoints[BIKESUSP_R1],
- m_fTurnMass*Sin(m_fBrakeDestabilization)*clamp(fwdSpeed, 0.5f, 0.2f)*0.003f*GetRight()*CTimer::GetTimeStep());
+ m_fTurnMass*Sin(m_fBrakeDestabilization)*Clamp(fwdSpeed, 0.5f, 0.2f)*0.003f*GetRight()*CTimer::GetTimeStep());
}
}else
m_fBrakeDestabilization = 0.0f;
@@ -1220,7 +1220,7 @@ CBike::ProcessControl(void)
// Balance bike
if(bBalancedByRider || bIsBeingPickedUp || bIsStanding){
float onSideness = DotProduct(GetRight(), m_vecAvgSurfaceNormal);
- onSideness = clamp(onSideness, -1.0f, 1.0f);
+ onSideness = Clamp(onSideness, -1.0f, 1.0f);
CVector worldCOM = Multiply3x3(GetMatrix(), m_vecCentreOfMass);
// Keep bike upright
if(bBalancedByRider){
@@ -1840,7 +1840,7 @@ CBike::ProcessControlInputs(uint8 pad)
0.2f*CTimer::GetTimeStep();
nLastControlInput = 0;
}
- m_fSteerInput = clamp(m_fSteerInput, -1.0f, 1.0f);
+ m_fSteerInput = Clamp(m_fSteerInput, -1.0f, 1.0f);
// Lean forward/backward
float updown;
@@ -1850,7 +1850,7 @@ CBike::ProcessControlInputs(uint8 pad)
#endif
updown = -CPad::GetPad(pad)->GetSteeringUpDown()/128.0f + CPad::GetPad(pad)->GetCarGunUpDown()/128.0f;
m_fLeanInput += (updown - m_fLeanInput)*0.2f*CTimer::GetTimeStep();
- m_fLeanInput = clamp(m_fLeanInput, -1.0f, 1.0f);
+ m_fLeanInput = Clamp(m_fLeanInput, -1.0f, 1.0f);
// Accelerate/Brake
float acceleration = (CPad::GetPad(pad)->GetAccelerate() - CPad::GetPad(pad)->GetBrake())/255.0f;
diff --git a/src/vehicles/Boat.cpp b/src/vehicles/Boat.cpp
index b768db29..85a41099 100644
--- a/src/vehicles/Boat.cpp
+++ b/src/vehicles/Boat.cpp
@@ -158,9 +158,9 @@ CBoat::ProcessControl(void)
r = 127.5f*(CTimeCycle::GetAmbientRed_Obj() + 0.5f*CTimeCycle::GetDirectionalRed());
g = 127.5f*(CTimeCycle::GetAmbientGreen_Obj() + 0.5f*CTimeCycle::GetDirectionalGreen());
b = 127.5f*(CTimeCycle::GetAmbientBlue_Obj() + 0.5f*CTimeCycle::GetDirectionalBlue());
- r = clamp(r, 0, 255);
- g = clamp(g, 0, 255);
- b = clamp(b, 0, 255);
+ r = Clamp(r, 0, 255);
+ g = Clamp(g, 0, 255);
+ b = Clamp(b, 0, 255);
splashColor.red = r;
splashColor.green = g;
splashColor.blue = b;
@@ -169,9 +169,9 @@ CBoat::ProcessControl(void)
r = 229.5f*(CTimeCycle::GetAmbientRed() + 0.85f*CTimeCycle::GetDirectionalRed());
g = 229.5f*(CTimeCycle::GetAmbientGreen() + 0.85f*CTimeCycle::GetDirectionalGreen());
b = 229.5f*(CTimeCycle::GetAmbientBlue() + 0.85f*CTimeCycle::GetDirectionalBlue());
- r = clamp(r, 0, 255);
- g = clamp(g, 0, 255);
- b = clamp(b, 0, 255);
+ r = Clamp(r, 0, 255);
+ g = Clamp(g, 0, 255);
+ b = Clamp(b, 0, 255);
jetColor.red = r;
jetColor.green = g;
jetColor.blue = b;
@@ -387,7 +387,7 @@ CBoat::ProcessControl(void)
if(CPad::GetPad(0)->GetHandBrake())
steerLoss *= 0.5f;
steerFactor -= steerLoss;
- steerFactor = clamp(steerFactor, 0.0f, 1.0f);
+ steerFactor = Clamp(steerFactor, 0.0f, 1.0f);
}
CVector boundMin = GetColModel()->boundingBox.min;
@@ -771,17 +771,17 @@ CBoat::ProcessControlInputs(uint8 pad)
m_nPadID = 3;
m_fBrake += (CPad::GetPad(pad)->GetBrake()/255.0f - m_fBrake)*0.1f;
- m_fBrake = clamp(m_fBrake, 0.0f, 1.0f);
+ m_fBrake = Clamp(m_fBrake, 0.0f, 1.0f);
if(m_fBrake < 0.05f){
m_fBrake = 0.0f;
m_fAccelerate += (CPad::GetPad(pad)->GetAccelerate()/255.0f - m_fAccelerate)*0.1f;
- m_fAccelerate = clamp(m_fAccelerate, 0.0f, 1.0f);
+ m_fAccelerate = Clamp(m_fAccelerate, 0.0f, 1.0f);
}else
m_fAccelerate = -m_fBrake*0.3f;
m_fSteeringLeftRight += (-CPad::GetPad(pad)->GetSteeringLeftRight()/128.0f - m_fSteeringLeftRight)*0.2f;
- m_fSteeringLeftRight = clamp(m_fSteeringLeftRight, -1.0f, 1.0f);
+ m_fSteeringLeftRight = Clamp(m_fSteeringLeftRight, -1.0f, 1.0f);
float steeringSq = m_fSteeringLeftRight < 0.0f ? -SQR(m_fSteeringLeftRight) : SQR(m_fSteeringLeftRight);
m_fSteerAngle = pHandling->fSteeringLock * DEGTORAD(steeringSq);
@@ -1064,7 +1064,7 @@ CBoat::PreRender(void)
rot = CGeneral::LimitRadianAngle(rot);
if(rot > HALFPI) rot = PI;
else if(rot < -HALFPI) rot = -PI;
- rot = clamp(rot, -DEGTORAD(63.0f), DEGTORAD(63.0f));
+ rot = Clamp(rot, -DEGTORAD(63.0f), DEGTORAD(63.0f));
m_fMovingSpeed += (0.008f * CWeather::Wind + 0.002f) * rot;
m_fMovingSpeed *= Pow(0.9985f, CTimer::GetTimeStep())/(500.0f*SQR(m_fMovingSpeed) + 1.0f);
diff --git a/src/vehicles/Door.cpp b/src/vehicles/Door.cpp
index c80965aa..1b3f9e8f 100644
--- a/src/vehicles/Door.cpp
+++ b/src/vehicles/Door.cpp
@@ -52,11 +52,11 @@ CDoor::Process(CVehicle *vehicle)
fSpeedDiff = vecSpeedDiff.y - vecSpeedDiff.x;
break;
}
- fSpeedDiff = clamp(fSpeedDiff, -0.2f, 0.2f);
+ fSpeedDiff = Clamp(fSpeedDiff, -0.2f, 0.2f);
if(Abs(fSpeedDiff) > 0.002f)
m_fAngVel += fSpeedDiff;
m_fAngVel *= 0.945f;
- m_fAngVel = clamp(m_fAngVel, -0.3f, 0.3f);
+ m_fAngVel = Clamp(m_fAngVel, -0.3f, 0.3f);
m_fAngle += m_fAngVel;
m_nDoorState = DOORST_SWINGING;
diff --git a/src/vehicles/Heli.cpp b/src/vehicles/Heli.cpp
index bf14416c..f51c8481 100644
--- a/src/vehicles/Heli.cpp
+++ b/src/vehicles/Heli.cpp
@@ -260,7 +260,7 @@ CHeli::ProcessControl(void)
// Move up if too low
if(GetPosition().z - 2.0f < groundZ && m_heliStatus != HELI_STATUS_SHOT_DOWN)
m_vecMoveSpeed.z += CTimer::GetTimeStep()*0.01f;
- m_vecMoveSpeed.z = clamp(m_vecMoveSpeed.z, -0.3f, 0.3f);
+ m_vecMoveSpeed.z = Clamp(m_vecMoveSpeed.z, -0.3f, 0.3f);
}
float fTargetDist = vTargetDist.Magnitude();
diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp
index 8fbf8224..a41e0fa0 100644
--- a/src/vehicles/Vehicle.cpp
+++ b/src/vehicles/Vehicle.cpp
@@ -479,11 +479,11 @@ CVehicle::FlyingControl(eFlightModel flightModel)
ApplyMoveForce(GRAVITY * GetUp() * fThrust * m_fMass * CTimer::GetTimeStep());
if (GetUp().z > 0.0f){
- float upRight = clamp(GetRight().z, -flyingHandling->fFormLift, flyingHandling->fFormLift);
+ float upRight = Clamp(GetRight().z, -flyingHandling->fFormLift, flyingHandling->fFormLift);
float upImpulseRight = -upRight * flyingHandling->fAttackLift * m_fTurnMass * CTimer::GetTimeStep();
ApplyTurnForce(upImpulseRight * GetUp(), GetRight());
- float upFwd = clamp(GetForward().z, -flyingHandling->fFormLift, flyingHandling->fFormLift);
+ float upFwd = Clamp(GetForward().z, -flyingHandling->fFormLift, flyingHandling->fFormLift);
float upImpulseFwd = -upFwd * flyingHandling->fAttackLift * m_fTurnMass * CTimer::GetTimeStep();
ApplyTurnForce(upImpulseFwd * GetUp(), GetForward());
}else{
@@ -522,8 +522,8 @@ CVehicle::FlyingControl(eFlightModel flightModel)
fPitch = -CPad::GetPad(0)->GetCarGunUpDown() / 128.0f;
if (CPad::GetPad(0)->GetHorn()) {
fYaw = 0.0f;
- fPitch = clamp(flyingHandling->fPitchStab * DotProduct(m_vecMoveSpeed, GetForward()), -200.0f, 1.3f);
- fRoll = clamp(flyingHandling->fRollStab * DotProduct(m_vecMoveSpeed, GetRight()), -200.0f, 1.3f);
+ fPitch = Clamp(flyingHandling->fPitchStab * DotProduct(m_vecMoveSpeed, GetForward()), -200.0f, 1.3f);
+ fRoll = Clamp(flyingHandling->fRollStab * DotProduct(m_vecMoveSpeed, GetRight()), -200.0f, 1.3f);
}
ApplyTurnForce(fPitch * GetUp() * flyingHandling->fPitch * m_fTurnMass * CTimer::GetTimeStep(), GetForward());
ApplyTurnForce(fRoll * GetUp() * flyingHandling->fRoll * m_fTurnMass * CTimer::GetTimeStep(), GetRight());
@@ -2162,9 +2162,9 @@ CVehicle::HeliDustGenerate(CEntity *heli, float radius, float ground, int rnd)
float red = (0.3*CTimeCycle::GetDirectionalRed() + CTimeCycle::GetAmbientRed_Obj())*255.0f/4.0f;
float green = (0.3*CTimeCycle::GetDirectionalGreen() + CTimeCycle::GetAmbientGreen_Obj())*255.0f/4.0f;
float blue = (0.3*CTimeCycle::GetDirectionalBlue() + CTimeCycle::GetAmbientBlue_Obj())*255.0f/4.0f;
- r = clamp(red, 0.0f, 255.0f);
- g = clamp(green, 0.0f, 255.0f);
- b = clamp(blue, 0.0f, 255.0f);
+ r = Clamp(red, 0.0f, 255.0f);
+ g = Clamp(green, 0.0f, 255.0f);
+ b = Clamp(blue, 0.0f, 255.0f);
RwRGBA col1 = { r, g, b, (RwUInt8)CGeneral::GetRandomNumberInRange(8, 32) };
RwRGBA col2 = { 255, 255, 255, 32 };