public void ReIndex() { float num = 1E-05f; float length = spline.GetLength(num); int capacity = Mathf.FloorToInt(length * 2f); List <Vector3> list = new List <Vector3>(capacity); float num2 = 0f; float f = length / 1024f; float num3 = Mathf.Pow(f, 2f); Vector3 vector = spline.GetNonUniformPoint(0f); list.Add(vector); while (num2 <= 1f) { Vector3 nonUniformPoint = spline.GetNonUniformPoint(num2); while ((nonUniformPoint - vector).sqrMagnitude <= num3) { num2 += num; nonUniformPoint = spline.GetNonUniformPoint(num2); } vector = nonUniformPoint; list.Add(nonUniformPoint); } linearPoints = list.ToArray(); }
public void ReIndex() { var searchStepSize = 0.00001f; var length = spline.GetLength(searchStepSize); var indexSize = Mathf.FloorToInt(length * 2); var _linearPoints = new List <Vector3>(indexSize); var t = 0f; var linearDistanceStep = length / 1024; var linearDistanceStep2 = Mathf.Pow(linearDistanceStep, 2); var start = spline.GetNonUniformPoint(0); _linearPoints.Add(start); while (t <= 1f) { var current = spline.GetNonUniformPoint(t); while ((current - start).sqrMagnitude <= linearDistanceStep2) { t += searchStepSize; current = spline.GetNonUniformPoint(t); } start = current; _linearPoints.Add(current); } linearPoints = _linearPoints.ToArray(); }
public void ReIndex() { float searchStepSize = 0.00001f; float length = spline.GetLength(searchStepSize); int indexSize = Mathf.FloorToInt(length * 2); List <Vector3> linearPoints = new List <Vector3>(indexSize); //...what does the "_" @ the front mean? (Removed it because it bothered me) float t = 0f; //meaningless variable name leads me to believe I'm missing some math background info. float linearDistanceStep = length / 1024; float linearDistanceStep2 = Mathf.Pow(linearDistanceStep, 2); Vector3 start = spline.GetNonUniformPoint(0); linearPoints.Add(start); while (t <= 1f) { Vector3 current = spline.GetNonUniformPoint(t); while ((current - start).sqrMagnitude <= linearDistanceStep2) { t += searchStepSize; current = spline.GetNonUniformPoint(t); } start = current; linearPoints.Add(current); } this.linearPoints = linearPoints.ToArray(); }