public bool Step(EcsRoadData road) { if (Mathf.Approximately(sRoadLastComputed, road.ecsRoad.length)) { return(false); } if (GeometrySampling.IsApproximatelyLessThan(sRoadCurrent + sRoadStep, road.ecsRoad.length)) { sRoadCurrent += sRoadStep; } else { sRoadCurrent = road.ecsRoad.length; } CheckStateAndUpdate(road); return(true); }
private void CheckStateAndUpdate(EcsRoadData road) { if (!IsStale()) { return; } if (!GeometrySampling.IsApproximatelyLessThan(sRoadCurrent, geometryEndS)) { (geometryIdx, geometryEndS) = FindNextAlongLength(road.ecsGeometries, sRoadCurrent, geometryIdx, road.ecsRoad.length); geometryState = new SamplingStateGeometry(road.ecsGeometries[geometryIdx]); } if (!GeometrySampling.IsApproximatelyLessThan(sRoadCurrent, laneOffsetEndS)) { (laneOffsetIdx, laneOffsetEndS) = FindNextAlongLength(road.laneOffsets, sRoadCurrent, laneOffsetIdx, road.ecsRoad.length); } if (!GeometrySampling.IsApproximatelyLessThan(sRoadCurrent, laneSectionEndS)) { if (canMoveToNextLaneSection) { (laneSectionIdx, laneSectionEndS) = FindNextAlongLength(road.ecsLaneSections, sRoadCurrent, laneSectionIdx, road.ecsRoad.length); } else if (!Mathf.Approximately(sRoadCurrent, laneSectionEndS)) { throw new Exception("Attempted to traverse past end of lane section, but " + $"{nameof(canMoveToNextLaneSection)} is {canMoveToNextLaneSection}"); } } ComputeSamples(road); }