public virtual void Recompute() { if (waypoints.Count < 2) { return; } for (int i = 0; i < waypoints.Count; i++) { waypoints[i].index = i; } totalLength = 0; for (int i = 0; i < waypoints.Count; i++) { var length = (Position(Next(waypoints[i])) - Position(waypoints[i])).magnitude; waypoints[i].start = totalLength; waypoints[i].end = totalLength + length; totalLength += length; } // some checks for (int i = 0; i < waypoints.Count; i++) { if (waypoints[i].length <= 0) { Debug.LogError("Degenerate waypoints: " + i); } } broadphase1d = null; }
public void InitialiseBroadphase() { if (broadphase1d == null) { broadphase1d = ScriptableObject.CreateInstance(typeof(WaypointsBroadphase1D)) as WaypointsBroadphase1D; broadphase1d.Initialise(waypoints, totalLength); } }