Skip to content

Commit

Permalink
pedestrian bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
EricBoiseLGSVL committed Mar 6, 2019
1 parent 755ebd3 commit 5dc8c64
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions Assets/Scripts/Driving/PedestrianManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ public void OptimizePedestrians()

// get ped per seg count
segInView.Clear();
foreach (var seg in pedSegments)
for (int i = 0; i < pedSegments.Count; i++)
{
for (var i = 0; i < seg.segment.targetWorldPositions.Count; i++)
for (var j = 0; j < pedSegments[i].segment.targetWorldPositions.Count; j++)
{
if (CheckPositionInView(seg.segment.targetWorldPositions[i]))
if (CheckPositionInView(pedSegments[i].segment.targetWorldPositions[j]))
{
segInView.Add(seg);
segInView.Add(pedSegments[i]);
break; // found a seg within threshold so add to segInView list
}
}
Expand All @@ -106,17 +106,17 @@ public void OptimizePedestrians()
pedPerSegmentCount = Mathf.FloorToInt(pedTotalCount / segInView.Count);

// check if ped can be made active
foreach (var seg in segInView)
for (int i = 0; i < segInView.Count; i++)
{
for (var i = 0; i < seg.segment.targetWorldPositions.Count; i++)
for (var j = 0; j < segInView[i].segment.targetWorldPositions.Count; j++)
{
if (CheckPositionInView(seg.segment.targetWorldPositions[i]))
if (CheckPositionInView(segInView[i].segment.targetWorldPositions[j]))
{
int addCount = pedPerSegmentCount - seg.transform.childCount;
int addCount = pedPerSegmentCount - segInView[i].transform.childCount;
if (addCount > 0)
{
for (int j = 0; j < addCount; j++)
SpawnPedestrian(seg);
for (int k = 0; k < addCount; k++)
SpawnPedestrian(segInView[i]);
}
break; // found a waypoint within threshold so spawn at this seg
}
Expand Down

0 comments on commit 5dc8c64

Please sign in to comment.