@@ -373,7 +373,7 @@ void LimbPath::Restart() {
373
373
bool LimbPath::RestartFree (Vector& limbPos, MOID MOIDToIgnore, int ignoreTeam) {
374
374
std::deque<Vector>::iterator prevSeg = m_CurrentSegment;
375
375
float prevProg = m_SegProgress;
376
- m_SegProgress = 0 ;
376
+ m_SegProgress = 0 . 0F ;
377
377
bool found = false ;
378
378
float result = 0 ;
379
379
@@ -387,8 +387,9 @@ bool LimbPath::RestartFree(Vector& limbPos, MOID MOIDToIgnore, int ignoreTeam) {
387
387
result = g_SceneMan.CastObstacleRay (beginPos, targetPos - beginPos, notUsed, limbPos, MOIDToIgnore, ignoreTeam, g_MaterialGrass);
388
388
389
389
// Only indicate that we found free position if there were any free pixels encountered
390
- if (result < 0 || result > 0 )
390
+ if (result < 0 || result > 0 ) {
391
391
found = true ;
392
+ }
392
393
} else {
393
394
Vector notUsed;
394
395
@@ -398,14 +399,18 @@ bool LimbPath::RestartFree(Vector& limbPos, MOID MOIDToIgnore, int ignoreTeam) {
398
399
// Find the first start segment that has an obstacle on it
399
400
int i = 0 ;
400
401
for (; i < m_StartSegCount; ++i) {
401
- Vector offsetSegment = (*m_CurrentSegment) * GetTotalScaleMultiplier ();
402
- result = g_SceneMan.CastObstacleRay (GetProgressPos (), offsetSegment, notUsed, limbPos, MOIDToIgnore, ignoreTeam, g_MaterialGrass);
402
+ Vector segmentStart = GetProgressPos ();
403
+ ++m_CurrentSegment;
404
+ Vector segmentEnd = GetProgressPos ();
405
+ --m_CurrentSegment;
406
+ Vector currentSegment = segmentEnd - segmentStart;
407
+ result = g_SceneMan.CastObstacleRay (segmentStart, currentSegment, notUsed, limbPos, MOIDToIgnore, ignoreTeam, g_MaterialGrass);
403
408
404
409
// If we found an obstacle after the first pixel, report the current segment as the starting one and that there is free space here
405
410
if (result > 0 ) {
406
411
// Set accurate segment progress
407
412
// TODO: See if this is a good idea, or if we should just set it to 0 and set limbPos to the start of current segment
408
- m_SegProgress = g_SceneMan.ShortestDistance (GetProgressPos (), limbPos).GetMagnitude () / offsetSegment .GetMagnitude ();
413
+ m_SegProgress = g_SceneMan.ShortestDistance (GetProgressPos (), limbPos).GetMagnitude () / currentSegment .GetMagnitude ();
409
414
limbPos = GetProgressPos ();
410
415
// m_SegProgress = 0;
411
416
m_Ended = false ;
0 commit comments