public void RemovePoint(int index) { if (m_Points.Count <= 3) { Debug.LogWarning("Can't remove any more points."); return; } //TODO:finish removing, remove also tangents and times m_Hermite.RemovePosition(index); }
public void ValidateData() { var posFail = points.Count != m_Hermite.Positions.Count; var outTangFail = outTangents.Count != m_Hermite.OutTangents.Count; var inTangFail = inTangents.Count != m_Hermite.InTangents.Count; var timesFail = times.Count != m_Hermite.Times.Count; if (posFail) { /////////////////// /// ADDITION /////////////////// if (points.Count == m_Hermite.Positions.Count + 1) { // we assume addition from editor via SerializedProperty has happened var differentIndex = CheckForDifference <Vector3>(points, m_Hermite.Positions); m_Hermite.AddPositionToIndexNatural(points[differentIndex], differentIndex); inTangents.Clear(); inTangents.AddRange(m_Hermite.InTangents); outTangents.Clear(); outTangents.AddRange(m_Hermite.OutTangents); times.Clear(); times.AddRange(m_Hermite.Times); } // if (inTangents.Count + 1 == m_Hermite.InTangents.Count) // { // we assume another tangent has been generated because we've added another point // var differentIndex = CheckForDifference<Vector3>(inTangents, m_Hermite.InTangents); // inTangents.Insert(differentIndex, m_Hermite.InTangents[differentIndex]); // } // if (outTangents.Count + 1 == m_Hermite.OutTangents.Count) // { // we assume another tangent has been generated because we've added another point // var differentIndex = CheckForDifference<Vector3>(outTangents, m_Hermite.OutTangents); // outTangents.Insert(differentIndex, m_Hermite.OutTangents[differentIndex]); // } // if (times.Count + 1 == m_Hermite.Times.Count) // { // we assume another time has been generated because we've added another point // var differentIndex = CheckForDifference<float>(times, m_Hermite.Times); // times.Insert(differentIndex, m_Hermite.Times[differentIndex]); // } /////////////////// /// REMOVAL /////////////////// if (points.Count == m_Hermite.Positions.Count - 1) { // we assume it's removal var differentIndex = CheckForDifference <Vector3>(points, m_Hermite.Positions); m_Hermite.RemovePosition(differentIndex); } if (inTangents.Count - 1 == m_Hermite.InTangents.Count) { // we assume tangent has been removed internally because of point removal var differentIndex = CheckForDifference <Vector3>(inTangents, m_Hermite.InTangents); inTangents.RemoveAt(differentIndex); } if (outTangents.Count - 1 == m_Hermite.OutTangents.Count) { // we assume tangent has been removed internally because of point removal var differentIndex = CheckForDifference <Vector3>(outTangents, m_Hermite.OutTangents); outTangents.RemoveAt(differentIndex); } if (times.Count - 1 == m_Hermite.Times.Count) { // we assume time has been removed because we've remove a point var differentIndex = CheckForDifference <float>(times, m_Hermite.Times); times.RemoveAt(differentIndex); } } // EVALUATE THE CHANGES - they can happen by manipulating the field via editor SerializedProperty writing GetTheDifferences <Vector3>(m_Hermite.Positions, points, m_DifferencesVect); if (m_DifferencesVect.Count > 0) { foreach (var difVect in m_DifferencesVect) { m_Hermite.SetPosition(difVect.Key, difVect.Value); } } GetTheDifferences <Vector3>(m_Hermite.InTangents, inTangents, m_DifferencesVect); if (m_DifferencesVect.Count > 0) { foreach (var difVect in m_DifferencesVect) { m_Hermite.SetInTangent(difVect.Key, difVect.Value); } } GetTheDifferences <Vector3>(m_Hermite.OutTangents, outTangents, m_DifferencesVect); if (m_DifferencesVect.Count > 0) { foreach (var difVect in m_DifferencesVect) { m_Hermite.SetOutTangent(difVect.Key, difVect.Value); } } GetTheDifferences <float>(m_Hermite.Times, times, m_DifferencesFloat); if (m_DifferencesFloat.Count > 0) { foreach (var difFloat in m_DifferencesFloat) { m_Hermite.SetTime(difFloat.Key, difFloat.Value); } } }