/// <summary>
        /// Adds a new control point to the curve.
        /// </summary>
        /// <param name="time">Time of the new control point.</param>
        /// <param name="value">Value of the new control point.</param>
        /// <returns>Newly created control point.</returns>
        public CurveControlPoint <TValue> Add(float time, TValue value)
        {
            var toAdd = new CurveControlPoint <TValue>(time, value, Curve);

            Add(toAdd);
            return(toAdd);
        }
        /// <summary>
        /// Removes the control point from the curve.
        /// </summary>
        /// <param name="index">Index to remove at.</param>
        public void RemoveAt(int index)
        {
            CurveControlPoint <TValue> removed = list[index];

            list.RemoveAt(index);
            Curve.ControlPointRemoved(removed, index);
        }
示例#3
0
        internal void InternalControlPointTimeChanged(CurveControlPoint <TValue> controlPoint)
        {
            int oldIndex = ControlPoints.list.IndexOf(controlPoint);

            ControlPoints.list.RemoveAt(oldIndex);
            int index = GetPreviousIndex(controlPoint.Time) + 1;

            ControlPoints.list.Insert(index, controlPoint);
            ControlPointTimeChanged(controlPoint, oldIndex, index);
        }
        /// <summary>
        /// Adds a control point to the curve.
        /// </summary>
        /// <param name="point">New control point to add to the curve.</param>
        public void Add(CurveControlPoint <TValue> point)
        {
            int index = Curve.GetPreviousIndex(point.Time) + 1;

            //TODO: Test for time-wise duplicate?
            //IndexA would be the one that's possibly duplicated.
            //Even with duplicate, this is still technically sorted.
            list.Insert(index, point);
            Curve.ControlPointAdded(point, index);
        }
示例#5
0
 /// <summary>
 /// Compares the two control points based on their time.
 /// </summary>
 /// <param name="other">Control point to compare.</param>
 /// <returns>-1 if the current instance has a smaller time, 0 if equal, and 1 if the current instance has a larger time.</returns>
 public int CompareTo(CurveControlPoint <TValue> other)
 {
     if (other.Time < Time)
     {
         return(1);
     }
     if (other.Time > Time)
     {
         return(-1);
     }
     return(0);
 }
示例#6
0
 /// <summary>
 /// Called when a control point belonging to the curve has its value changed.
 /// </summary>
 /// <param name="curveControlPoint">Changed control point.</param>
 protected internal override void ControlPointValueChanged(CurveControlPoint <Vector3f> curveControlPoint)
 {
     tangents.Clear();
     ComputeTangents();
 }
示例#7
0
 /// <summary>
 /// Called when a control point belonging to the curve has its time changed.
 /// </summary>
 /// <param name="curveControlPoint">Changed control point.</param>
 /// <param name="oldIndex">Old index of the control point.</param>
 /// <param name="newIndex">New index of the control point.</param>
 protected internal override void ControlPointTimeChanged(CurveControlPoint <Vector3f> curveControlPoint, int oldIndex, int newIndex)
 {
     tangents.Clear();
     ComputeTangents();
 }
示例#8
0
 /// <summary>
 /// Called when a control point is added.
 /// </summary>
 /// <param name="curveControlPoint">New control point.</param>
 /// <param name="index">Index of the control point.</param>
 protected internal override void ControlPointAdded(CurveControlPoint <Vector3f> curveControlPoint, int index)
 {
     tangents.Clear();
     ComputeTangents();
 }
示例#9
0
 /// <summary>
 /// Called when a control point belonging to the curve has its value changed.
 /// </summary>
 /// <param name="curveControlPoint">Changed control point.</param>
 protected internal abstract void ControlPointValueChanged(CurveControlPoint <TValue> curveControlPoint);
示例#10
0
 /// <summary>
 /// Called when a control point belonging to the curve has its time changed.
 /// </summary>
 /// <param name="curveControlPoint">Changed control point.</param>
 /// <param name="oldIndex">Old index of the control point.</param>
 /// <param name="newIndex">New index of the control point.</param>
 protected internal abstract void ControlPointTimeChanged(CurveControlPoint <TValue> curveControlPoint, int oldIndex, int newIndex);
示例#11
0
 /// <summary>
 /// Called when a control point is removed.
 /// </summary>
 /// <param name="curveControlPoint">Removed control point.</param>
 /// <param name="oldIndex">Index of the control point before it was removed.</param>
 protected internal abstract void ControlPointRemoved(CurveControlPoint <TValue> curveControlPoint, int oldIndex);
示例#12
0
 /// <summary>
 /// Called when a control point is added.
 /// </summary>
 /// <param name="curveControlPoint">New control point.</param>
 /// <param name="index">Index of the control point.</param>
 protected internal abstract void ControlPointAdded(CurveControlPoint <TValue> curveControlPoint, int index);
 /// <summary>
 /// Removes the control point from the curve.
 /// </summary>
 /// <param name="controlPoint">Control point to remove.</param>
 public void Remove(CurveControlPoint <TValue> controlPoint)
 {
     RemoveAt(list.IndexOf(controlPoint));
 }