Skip to content

Commit c23638a

Browse files
better hitnormal calc
based on documentation /// If the hit parameter is zero, then the start position is on the wall that /// was hit and the value of @p hitNormal is undefined. /// /// If 0 < t < 1.0 then the following applies: /// /// @code /// distanceToHitBorder = distanceToEndPosition * t /// hitPoint = startPos + (endPos - startPos) * t /// @Endcode
1 parent 5d9b9c9 commit c23638a

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/game/Maps/Map.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3234,11 +3234,16 @@ bool Map::GetWalkHitPosition(GenericTransport* transport, float srcX, float srcY
32343234
return false;
32353235
}
32363236

3237+
if (t == 0)
3238+
{
3239+
return false;
3240+
}
3241+
32373242
// We hit a wall - calculate new endposition
32383243
if ((t < 1) && (t > 0))
32393244
{
32403245
for (int i = 0; i < 3; ++i)
3241-
endPosition[i] = point[i] + (endPosition[i] - point[i]) * hitNormal[i];
3246+
endPosition[i] = point[i] + (endPosition[i] - point[i]) * t;
32423247
}
32433248

32443249
if (dtStatusFailed(navMeshQuery->closestPointOnPoly(visited[visitedCount - 1], endPosition, endPosition, nullptr)))

0 commit comments

Comments
 (0)