summaryrefslogtreecommitdiffstats
path: root/src/control
diff options
context:
space:
mode:
authorNikolay Korolev <nickvnuk@gmail.com>2020-09-26 12:28:33 +0200
committerNikolay Korolev <nickvnuk@gmail.com>2020-09-26 12:28:33 +0200
commiteefb0c817f1c86cb24d3a730da848e1f98277948 (patch)
treed4872bafd56e69213a6e973ac539c01942042a01 /src/control
parentMerge remote-tracking branch 'upstream/master' (diff)
parentFix MASTER build with glfw (diff)
downloadre3-eefb0c817f1c86cb24d3a730da848e1f98277948.tar
re3-eefb0c817f1c86cb24d3a730da848e1f98277948.tar.gz
re3-eefb0c817f1c86cb24d3a730da848e1f98277948.tar.bz2
re3-eefb0c817f1c86cb24d3a730da848e1f98277948.tar.lz
re3-eefb0c817f1c86cb24d3a730da848e1f98277948.tar.xz
re3-eefb0c817f1c86cb24d3a730da848e1f98277948.tar.zst
re3-eefb0c817f1c86cb24d3a730da848e1f98277948.zip
Diffstat (limited to 'src/control')
-rw-r--r--src/control/CarCtrl.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp
index c6d90dd9..5a2def05 100644
--- a/src/control/CarCtrl.cpp
+++ b/src/control/CarCtrl.cpp
@@ -1080,11 +1080,11 @@ void CCarCtrl::SlowCarDownForCarsSectorList(CPtrList& lst, CVehicle* pVehicle, f
void CCarCtrl::SlowCarDownForOtherCar(CEntity* pOtherEntity, CVehicle* pVehicle, float* pSpeed, float curSpeed)
{
CVector forwardA = pVehicle->GetForward();
- ((CVector2D)forwardA).Normalise();
+ ((CVector2D)forwardA).NormaliseSafe();
if (DotProduct2D(pOtherEntity->GetPosition() - pVehicle->GetPosition(), forwardA) < 0.0f)
return;
CVector forwardB = pOtherEntity->GetForward();
- ((CVector2D)forwardB).Normalise();
+ ((CVector2D)forwardB).NormaliseSafe();
forwardA.z = forwardB.z = 0.0f;
CVehicle* pOtherVehicle = (CVehicle*)pOtherEntity;
/* why is the argument CEntity if it's always CVehicle anyway and is casted? */
@@ -1337,7 +1337,7 @@ void CCarCtrl::WeaveForOtherCar(CEntity* pOtherEntity, CVehicle* pVehicle, float
pVehicle->GetModelInfo()->GetColModel()->boundingSphere.radius < distance)
return;
CVector2D forward = pVehicle->GetForward();
- forward.Normalise();
+ forward.NormaliseSafe();
float forwardAngle = CGeneral::GetATanOfXY(forward.x, forward.y);
float angleDiff = angleBetweenVehicles - forwardAngle;
float lenProjection = ABS(pOtherCar->GetColModel()->boundingBox.max.y * sin(angleDiff));
@@ -2276,7 +2276,7 @@ float CCarCtrl::FindMaxSteerAngle(CVehicle* pVehicle)
void CCarCtrl::SteerAICarWithPhysicsFollowPath(CVehicle* pVehicle, float* pSwerve, float* pAccel, float* pBrake, bool* pHandbrake)
{
CVector2D forward = pVehicle->GetForward();
- forward.Normalise();
+ forward.NormaliseSafe();
CCarPathLink* pCurrentLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo];
CCarPathLink* pNextLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo];
CVector2D currentPathLinkForward(pCurrentLink->GetDirX() * pVehicle->AutoPilot.m_nCurrentDirection,
@@ -2410,7 +2410,7 @@ void CCarCtrl::SteerAICarWithPhysicsHeadingForTarget(CVehicle* pVehicle, CPhysic
{
*pHandbrake = false;
CVector2D forward = pVehicle->GetForward();
- forward.Normalise();
+ forward.NormaliseSafe();
float angleToTarget = CGeneral::GetATanOfXY(targetX - pVehicle->GetPosition().x, targetY - pVehicle->GetPosition().y);
float angleForward = CGeneral::GetATanOfXY(forward.x, forward.y);
if (pVehicle->AutoPilot.m_nDrivingStyle == DRIVINGSTYLE_AVOID_CARS)
@@ -2497,7 +2497,7 @@ void CCarCtrl::SteerAICarWithPhysicsTryingToBlockTarget_Stop(CVehicle* pVehicle,
void CCarCtrl::SteerAIBoatWithPhysicsHeadingForTarget(CBoat* pBoat, float targetX, float targetY, float* pSwerve, float* pAccel, float* pBrake)
{
CVector2D forward(pBoat->GetForward());
- forward.Normalise();
+ forward.NormaliseSafe();
CVector2D distanceToTarget = CVector2D(targetX, targetY) - pBoat->GetPosition();
float angleToTarget = CGeneral::GetATanOfXY(distanceToTarget.x, distanceToTarget.y);
float angleForward = CGeneral::GetATanOfXY(forward.x, forward.y);
@@ -2733,7 +2733,7 @@ bool CCarCtrl::GenerateOneEmergencyServicesCar(uint32 mi, CVector vecPos)
pVehicle->AutoPilot.m_nTempAction = TEMPACT_NONE;
pVehicle->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_AVOID_CARS;
CVector2D direction = vecPos - spawnPos;
- direction.Normalise();
+ direction.NormaliseSafe();
pVehicle->GetForward() = CVector(direction.x, direction.y, 0.0f);
pVehicle->GetRight() = CVector(direction.y, -direction.x, 0.0f);
pVehicle->GetUp() = CVector(0.0f, 0.0f, 1.0f);