예제 #1
0
        void DoInterpolate()
        {
            if (!mSpline.IsInitialized)
            {
                return;
            }
            System.Type metaType = System.Type.GetType(MetaDataType.Value);
            bool        calc     = !Input.IsNone;

            if (calc)
            {
                float f = (UseWorldUnits.Value) ? mSpline.DistanceToTF(Input.Value) : Input.Value;

                if (StorePosition.UseVariable)
                {
                    StorePosition.Value = (UseCache.Value) ? mSpline.InterpolateFast(f) : mSpline.Interpolate(f);
                }

                if (StoreTangent.UseVariable)
                {
                    StoreTangent.Value = mSpline.GetTangent(f);
                }

                if (StoreUpVector.UseVariable)
                {
                    StoreUpVector.Value = mSpline.GetOrientationUpFast(f);
                }

                if (StoreRotation.UseVariable)
                {
                    StoreRotation.Value = (StoreUpVector.IsNone) ? mSpline.GetOrientationFast(f) : Quaternion.LookRotation(mSpline.GetTangent(f), StoreUpVector.Value);
                }

                if (StoreScale.UseVariable)
                {
                    StoreScale.Value = mSpline.InterpolateScale(f);
                }

                if (StoreTF.UseVariable)
                {
                    StoreTF.Value = f;
                }

                if (StoreDistance.UseVariable)
                {
                    StoreDistance.Value = (UseWorldUnits.Value) ? Input.Value : mSpline.TFToDistance(f);
                }
                if (metaType != null)
                {
                    if (StoreMetadata.UseVariable)
                    {
                        StoreMetadata.Value = mSpline.GetMetadata(metaType, f);
                    }
                    if (StoreInterpolatedMetadata.useVariable)
                    {
                        StoreInterpolatedMetadata.SetValue(mSpline.InterpolateMetadata(metaType, f));
                    }
                }


                CurvySplineSegment seg = null;
                float segF             = 0;
                if (StoreSegment.UseVariable)
                {
                    seg = getSegment(f, out segF);
                    StoreSegment.Value = seg.gameObject;
                }

                if (StoreSegmentF.UseVariable)
                {
                    if (!seg)
                    {
                        seg = getSegment(f, out segF);
                    }
                    StoreSegmentF.Value = segF;
                }

                if (StoreSegmentDistance.UseVariable)
                {
                    if (!seg)
                    {
                        seg = getSegment(f, out segF);
                    }
                    StoreSegmentDistance.Value = seg.LocalFToDistance(segF);
                }
            }
            // General
            if (StoreLength.UseVariable)
            {
                StoreLength.Value = mSpline.Length;
            }

            if (StoreCount.UseVariable)
            {
                StoreCount.Value = (mSpline is CurvySplineGroup) ? ((CurvySplineGroup)mSpline).Count : ((CurvySpline)mSpline).Count;
            }
        }