public void RemoveFirstCurve(ref float val) { BezierAccesser oldFirst = splines[0]; List <BezierAccesser> newList = new List <BezierAccesser>(splines.Count - 1); for (int i = 1; i < splines.Count; i++) { newList.Add(splines[i]); } splines = newList; Destroy(oldFirst.gameObject.GetComponentInParent <GenerationTileController>().gameObject); float differenceInStep = (1f / splines.Count) - (1f / (splines.Count + 1)); bool isInverse = false; float n = val; if (n <= (1f / (splines.Count + 1))) { isInverse = true; n = 1f - n; } float v = Mathf.Lerp((float)splines.Count + 1, 0, n); float s = val; float newN = Mathf.InverseLerp((float)splines.Count, 0, v); val = (isInverse)? 1 - newN : newN; if (splines.Count < 2) { val = s; } }
// The val is the value on the old curve that should be mapped to the new. public void AddCurve(ref float val, BezierAccesser c) { float v = Mathf.Lerp(0, (float)splines.Count, val); float s = val; val = Mathf.InverseLerp(0, (float)splines.Count + 1f, v); if (splines.Count < 2) { val = s; } splines.Add(c); }