summaryrefslogtreecommitdiffstats
path: root/src/vehicles
diff options
context:
space:
mode:
authorSergeanur <s.anureev@yandex.ua>2021-06-30 20:26:36 +0200
committerSergeanur <s.anureev@yandex.ua>2021-06-30 20:26:36 +0200
commit138abb91f6232ef40e1093b3c37122e1b0bf2cf1 (patch)
treec4c694734bb56c29ddf8b5bbd891741540a7c68b /src/vehicles
parentFix script load (diff)
parentPause radio when game is paused (diff)
downloadre3-138abb91f6232ef40e1093b3c37122e1b0bf2cf1.tar
re3-138abb91f6232ef40e1093b3c37122e1b0bf2cf1.tar.gz
re3-138abb91f6232ef40e1093b3c37122e1b0bf2cf1.tar.bz2
re3-138abb91f6232ef40e1093b3c37122e1b0bf2cf1.tar.lz
re3-138abb91f6232ef40e1093b3c37122e1b0bf2cf1.tar.xz
re3-138abb91f6232ef40e1093b3c37122e1b0bf2cf1.tar.zst
re3-138abb91f6232ef40e1093b3c37122e1b0bf2cf1.zip
Diffstat (limited to 'src/vehicles')
-rw-r--r--src/vehicles/Automobile.cpp22
-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/Transmission.cpp2
-rw-r--r--src/vehicles/Vehicle.cpp14
7 files changed, 41 insertions, 41 deletions
diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp
index 2112e666..ef7fded0 100644
--- a/src/vehicles/Automobile.cpp
+++ b/src/vehicles/Automobile.cpp
@@ -933,7 +933,7 @@ CAutomobile::ProcessControl(void)
float adhesion = CSurfaceTable::GetAdhesiveLimit(point);
// i have no idea what's going on here
float magic = traction * adhesion * 16.0f / SQR(fwdSpeed);
- magic = clamp(magic, -1.0f, 1.0f);
+ magic = Clamp(magic, -1.0f, 1.0f);
magic = Asin(magic);
if(m_fSteerAngle < 0.0f && rightSpeed > 0.05f ||
m_fSteerAngle > 0.0f && rightSpeed < -0.05f ||
@@ -2081,7 +2081,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));
@@ -2439,7 +2439,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)
@@ -2480,7 +2480,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)
@@ -2513,7 +2513,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)
@@ -2547,7 +2547,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)
@@ -2681,7 +2681,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)
@@ -2722,7 +2722,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)
@@ -2948,7 +2948,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;
@@ -3068,7 +3068,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);
@@ -3493,7 +3493,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 fdcf1960..627cddbb 100644
--- a/src/vehicles/Bike.cpp
+++ b/src/vehicles/Bike.cpp
@@ -536,7 +536,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{
@@ -1031,9 +1031,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{
@@ -1056,11 +1056,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;
@@ -1223,7 +1223,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){
@@ -1843,7 +1843,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;
@@ -1853,7 +1853,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 14999293..ab70f19b 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;
@@ -772,17 +772,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);
@@ -1065,7 +1065,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 72a30339..6e35c951 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 3f01ff41..a8423855 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/Transmission.cpp b/src/vehicles/Transmission.cpp
index f7851f47..efc32079 100644
--- a/src/vehicles/Transmission.cpp
+++ b/src/vehicles/Transmission.cpp
@@ -150,7 +150,7 @@ cTransmission::CalculateDriveAcceleration(const float &gasPedal, uint8 &gear, fl
else if(cheat == 2)
inertiaMult *= TRANSMISSION_NITROS_INERTIA_MULT;
float var2target = 1.0f - inertiaMult*fEngineInertia;
- var2target = clamp(var2target, 0.1f, 1.0f);
+ var2target = Clamp(var2target, 0.1f, 1.0f);
*inertiaVar2 = (1.0f-TRANSMISSION_SMOOTHER_FRAC)*var2target + TRANSMISSION_SMOOTHER_FRAC*(*inertiaVar2);
*inertiaVar1 = var1;
fAcceleration *= *inertiaVar2;
diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp
index 9a701b44..e684aad7 100644
--- a/src/vehicles/Vehicle.cpp
+++ b/src/vehicles/Vehicle.cpp
@@ -480,11 +480,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{
@@ -523,8 +523,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());
@@ -2174,9 +2174,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 };