Skip to content

Commit dbb48cf

Browse files
committed
Further fixes to limbpath
1 parent 95798d4 commit dbb48cf

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

Source/Entities/LimbPath.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ void LimbPath::Restart() {
373373
bool LimbPath::RestartFree(Vector& limbPos, MOID MOIDToIgnore, int ignoreTeam) {
374374
std::deque<Vector>::iterator prevSeg = m_CurrentSegment;
375375
float prevProg = m_SegProgress;
376-
m_SegProgress = 0;
376+
m_SegProgress = 0.0F;
377377
bool found = false;
378378
float result = 0;
379379

@@ -387,8 +387,9 @@ bool LimbPath::RestartFree(Vector& limbPos, MOID MOIDToIgnore, int ignoreTeam) {
387387
result = g_SceneMan.CastObstacleRay(beginPos, targetPos - beginPos, notUsed, limbPos, MOIDToIgnore, ignoreTeam, g_MaterialGrass);
388388

389389
// 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) {
391391
found = true;
392+
}
392393
} else {
393394
Vector notUsed;
394395

@@ -398,14 +399,18 @@ bool LimbPath::RestartFree(Vector& limbPos, MOID MOIDToIgnore, int ignoreTeam) {
398399
// Find the first start segment that has an obstacle on it
399400
int i = 0;
400401
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);
403408

404409
// If we found an obstacle after the first pixel, report the current segment as the starting one and that there is free space here
405410
if (result > 0) {
406411
// Set accurate segment progress
407412
// 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();
409414
limbPos = GetProgressPos();
410415
// m_SegProgress = 0;
411416
m_Ended = false;

0 commit comments

Comments
 (0)