void DoInterpolate() { if (!mSegment.Spline.IsInitialized) { return; } bool calc = !Input.IsNone; if (calc) { System.Type metaType = System.Type.GetType(MetaDataType.Value); float inputF = (UseWorldUnits.Value) ? mSegment.DistanceToLocalF(Input.Value) : Input.Value; if (StorePosition.IsNone == false) { StorePosition.Value = (UseCache.Value) ? mSegment.InterpolateFast(inputF) : mSegment.Interpolate(inputF); } if (StoreTangent.IsNone == false) { StoreTangent.Value = mSegment.GetTangent(inputF); } if (StoreUpVector.IsNone == false) { StoreUpVector.Value = mSegment.GetOrientationUpFast(inputF); } if (StoreRotation.IsNone == false) { StoreRotation.Value = (StoreUpVector.IsNone) ? mSegment.GetOrientationFast(inputF) : Quaternion.LookRotation(mSegment.GetTangent(inputF), StoreUpVector.Value); } if (StoreScale.IsNone == false) { CurvySplineSegment nextControlPoint = mSegment.Spline.GetNextControlPoint(mSegment); StoreScale.Value = nextControlPoint ? Vector3.Lerp(mSegment.transform.lossyScale, nextControlPoint.transform.lossyScale, inputF) : mSegment.transform.lossyScale; } if (StoreTF.IsNone == false) { StoreTF.Value = mSegment.LocalFToTF(inputF); } if (StoreSegmentDistance.IsNone == false) { StoreSegmentDistance.Value = mSegment.LocalFToDistance(inputF); } if (StoreDistance.IsNone == false) { StoreDistance.Value = (StoreSegmentDistance.IsNone == false) ? StoreSegmentDistance.Value + mSegment.Distance : mSegment.LocalFToDistance(inputF) + mSegment.Distance; } if (StoreSegmentF.IsNone == false) { StoreSegmentF.Value = inputF; } if (metaType != null) { if (metaType.IsSubclassOf(typeof(CurvyMetadataBase)) == false) { //this if statement's branch does not exclude classes inheriting from CurvyMetadataBase but not from CurvyInterpolatableMetadataBase, but that's ok, those classes are handled below Debug.LogError("Meta data type " + metaType.FullName + " should be a subclass of CurvyInterpolatableMetadataBase<T>"); } else { if (StoreMetadata.IsNone == false) { MethodInfo genericMethodInfo = mSegment.GetType().GetMethod("GetMetadata").MakeGenericMethod(metaType); StoreMetadata.Value = (Object)genericMethodInfo.Invoke(mSegment, new System.Object[] { false }); } if (StoreInterpolatedMetadata.IsNone == false) { Type argumentType = CurvyGetValue.GetInterpolatableMetadataGenericType(metaType); if (argumentType == null) { Debug.LogError("Meta data type " + metaType.FullName + " should be a subclass of CurvyInterpolatableMetadataBase<T>"); } else { MethodInfo genericMethodInfo = mSegment.GetType().GetMethod("GetInterpolatedMetadata").MakeGenericMethod(metaType, argumentType); StoreInterpolatedMetadata.SetValue(genericMethodInfo.Invoke(mSegment, new System.Object[] { inputF })); } } } } } // General if (StoreLength.IsNone == false) { StoreLength.Value = mSegment.Length; } if (StoreSegmentIndex.IsNone == false) { StoreSegmentIndex.Value = mSegment.Spline.GetSegmentIndex(mSegment); } if (StoreControlPointIndex.IsNone == false) { StoreControlPointIndex.Value = mSegment.Spline.GetControlPointIndex(mSegment); } }