Skip to content

Commit d0f24b6

Browse files
authored
fix(view): Prevent float division by zero in W3DView::setupWaypointPath() (TheSuperHackers#2274)
1 parent 3e0a5be commit d0f24b6

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

  • Core/GameEngineDevice/Source/W3DDevice/GameClient

Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2818,14 +2818,14 @@ void W3DView::setupWaypointPath(Bool orient)
28182818
Real angle = getAngle();
28192819
for (i=1; i<m_mcwpInfo.numWaypoints; i++) {
28202820
Vector2 dir(m_mcwpInfo.waypoints[i+1].x-m_mcwpInfo.waypoints[i].x, m_mcwpInfo.waypoints[i+1].y-m_mcwpInfo.waypoints[i].y);
2821-
m_mcwpInfo.waySegLength[i] = dir.Length();
2821+
const Real dirLength = dir.Length();
2822+
m_mcwpInfo.waySegLength[i] = dirLength;
28222823
m_mcwpInfo.totalDistance += m_mcwpInfo.waySegLength[i];
2823-
if (orient) {
2824-
angle = WWMath::Acos(dir.X/m_mcwpInfo.waySegLength[i]);
2824+
if (orient && dirLength >= 0.1f) {
2825+
angle = WWMath::Acos(dir.X/dirLength);
28252826
if (dir.Y<0.0f) {
28262827
angle = -angle;
28272828
}
2828-
28292829
// Default camera is rotated 90 degrees, so match.
28302830
angle -= PI/2;
28312831
normAngle(angle);

0 commit comments

Comments
 (0)