public SerializedCurvySpline(CurvySpline spline, CurvySerializationSpace space = CurvySerializationSpace.WorldSpline) { if (spline) { Name = spline.name; P = (space == CurvySerializationSpace.Self) ? spline.transform.localPosition : spline.transform.position; R = (space == CurvySerializationSpace.Self) ? spline.transform.localRotation.eulerAngles : spline.transform.rotation.eulerAngles; Interpolation = spline.Interpolation; Keep2D = spline.RestrictTo2D; Closed = spline.Closed; AutoEndTangents = spline.AutoEndTangents; Orientation = spline.Orientation; BzAutoDist = spline.AutoHandleDistance; CacheDensity = spline.CacheDensity; Pooling = spline.UsePooling; Threading = spline.UseThreading; CheckTForm = spline.CheckTransform; UpdateIn = spline.UpdateIn; ControlPoints = new SerializedCurvySplineSegment[spline.ControlPointCount]; for (int i = 0; i < spline.ControlPointCount; i++) { ControlPoints[i] = new SerializedCurvySplineSegment(spline.ControlPoints[i]); } } }
public override void Reset() { base.Reset(); CloseSpline = true; AutoEndTangents = true; CacheDensity = 25; Orientation = CurvyOrientation.Dynamic; AutoRefresh = true; storeObject = null; }
/// <summary> /// Sets basic spline parameters /// </summary> protected void PrepareSpline(CurvyInterpolation interpolation, CurvyOrientation orientation = CurvyOrientation.Dynamic, int cachedensity = 50, bool closed = true) { #if UNITY_EDITOR if (!Application.isPlaying) { Undo.RecordObject(Spline, "Apply Shape"); } #endif Spline.Interpolation = interpolation; Spline.Orientation = orientation; Spline.CacheDensity = cachedensity; Spline.Closed = closed; Spline.RestrictTo2D = this is CurvyShape2D; }
void OnGUI() { GUILayout.BeginVertical(GUI.skin.box); GUILayout.Label("Curvy offers various options to fine-tune performance vs. precision balance:"); // Interpolation GUILayout.BeginHorizontal(); GUILayout.Label("Interpolation: "); if (GUILayout.Toggle(mInterpolation == CurvyInterpolation.Linear, "Linear", GUI.skin.button)) mInterpolation=CurvyInterpolation.Linear; if (GUILayout.Toggle(mInterpolation == CurvyInterpolation.Bezier, "Bezier", GUI.skin.button)) mInterpolation=CurvyInterpolation.Bezier; if (GUILayout.Toggle(mInterpolation == CurvyInterpolation.CatmullRom, "CatmullRom", GUI.skin.button)) mInterpolation = CurvyInterpolation.CatmullRom; if (GUILayout.Toggle(mInterpolation == CurvyInterpolation.TCB, "TCB", GUI.skin.button)) mInterpolation = CurvyInterpolation.TCB; GUILayout.EndHorizontal(); // Orientation GUILayout.BeginHorizontal(); GUILayout.Label("Orientation: "); if (GUILayout.Toggle(mOrientation == CurvyOrientation.None, "None", GUI.skin.button)) mOrientation = CurvyOrientation.None; if (GUILayout.Toggle(mOrientation == CurvyOrientation.Static, "Static", GUI.skin.button)) mOrientation = CurvyOrientation.Static; if (GUILayout.Toggle(mOrientation == CurvyOrientation.Dynamic, "Dynamic", GUI.skin.button)) mOrientation = CurvyOrientation.Dynamic; GUILayout.EndHorizontal(); // CP-Count GUILayout.BeginHorizontal(); GUILayout.Label("Control Points (max): " + mControlPointCount.ToString()); mControlPointCount = (int)GUILayout.HorizontalSlider(mControlPointCount, 2, 1000); GUILayout.EndHorizontal(); // Length GUILayout.BeginHorizontal(); GUILayout.Label("Total spline length: " + mTotalSplineLength.ToString()); mTotalSplineLength = (int)GUILayout.HorizontalSlider(mTotalSplineLength, 5, 10000); GUILayout.EndHorizontal(); // Cache GUILayout.BeginHorizontal(); GUILayout.Label("Cache Density: "+mCacheSize.ToString()); mCacheSize=(int)GUILayout.HorizontalSlider(mCacheSize, 1, 100); GUILayout.EndHorizontal(); mUseCache=GUILayout.Toggle(mUseCache, "Use Cache (where applicable)"); mUseMultiThreads = GUILayout.Toggle(mUseMultiThreads, "Use Multiple Threads (where applicable)"); GUILayout.Label("Select Test:"); int sel=GUILayout.SelectionGrid(Mathf.Max(0,mCurrentTest), mTests.ToArray(),4); if (sel != mCurrentTest) { mCurrentTest = sel; Timer.Clear(); mTestResults.Clear(); mGUIMethod = GetType().GetMethod("GUI_"+mTests[mCurrentTest], BindingFlags.NonPublic | BindingFlags.Instance); mRunMethod = GetType().GetMethod("Test_"+mTests[mCurrentTest], BindingFlags.NonPublic | BindingFlags.Instance); } GUILayout.Space(5); if (mGUIMethod != null) mGUIMethod.Invoke(this, null); GUI.enabled = !mExecuting && mRunMethod!=null; string label = (mExecuting) ? "Please wait..." : "Run (" + LOOPS + " times)"; if (GUILayout.Button(label)) { mExecuting = true; Timer.Clear(); mTestResults.Clear(); Invoke("runTest", .5f); } GUI.enabled = true; if (Timer.Count > 0) { foreach (var s in mTestResults) GUILayout.Label(s); GUILayout.Label(string.Format("Average (ms): {0:0.0000}", Timer.AverageMS)); GUILayout.Label(string.Format("Minimum (ms): {0:0.0000}", Timer.MinimumMS)); GUILayout.Label(string.Format("Maximum (ms): {0:0.0000}", Timer.MaximumMS)); } GUILayout.EndVertical(); }
void OnGUI() { GUILayout.BeginVertical(GUI.skin.box); GUILayout.Label("Curvy offers various options to fine-tune performance vs. precision balance:"); // Interpolation GUILayout.BeginHorizontal(); GUILayout.Label("Interpolation: "); if (GUILayout.Toggle(mInterpolation == CurvyInterpolation.Linear, "Linear", GUI.skin.button)) { mInterpolation = CurvyInterpolation.Linear; } if (GUILayout.Toggle(mInterpolation == CurvyInterpolation.Bezier, "Bezier", GUI.skin.button)) { mInterpolation = CurvyInterpolation.Bezier; } if (GUILayout.Toggle(mInterpolation == CurvyInterpolation.CatmullRom, "CatmullRom", GUI.skin.button)) { mInterpolation = CurvyInterpolation.CatmullRom; } if (GUILayout.Toggle(mInterpolation == CurvyInterpolation.TCB, "TCB", GUI.skin.button)) { mInterpolation = CurvyInterpolation.TCB; } GUILayout.EndHorizontal(); // Orientation GUILayout.BeginHorizontal(); GUILayout.Label("Orientation: "); if (GUILayout.Toggle(mOrientation == CurvyOrientation.None, "None", GUI.skin.button)) { mOrientation = CurvyOrientation.None; } if (GUILayout.Toggle(mOrientation == CurvyOrientation.Static, "Static", GUI.skin.button)) { mOrientation = CurvyOrientation.Static; } if (GUILayout.Toggle(mOrientation == CurvyOrientation.Dynamic, "Dynamic", GUI.skin.button)) { mOrientation = CurvyOrientation.Dynamic; } GUILayout.EndHorizontal(); // CP-Count GUILayout.BeginHorizontal(); GUILayout.Label("Control Points (max): " + mControlPointCount.ToString()); mControlPointCount = (int)GUILayout.HorizontalSlider(mControlPointCount, 2, 1000); GUILayout.EndHorizontal(); // Length GUILayout.BeginHorizontal(); GUILayout.Label("Total spline length: " + mTotalSplineLength.ToString()); mTotalSplineLength = (int)GUILayout.HorizontalSlider(mTotalSplineLength, 5, 10000); GUILayout.EndHorizontal(); // Cache GUILayout.BeginHorizontal(); GUILayout.Label("Cache Density: " + mCacheSize.ToString()); mCacheSize = (int)GUILayout.HorizontalSlider(mCacheSize, 1, 100); GUILayout.EndHorizontal(); mUseCache = GUILayout.Toggle(mUseCache, "Use Cache (where applicable)"); mUseMultiThreads = GUILayout.Toggle(mUseMultiThreads, "Use Multiple Threads (where applicable)"); GUILayout.Label("Select Test:"); int sel = GUILayout.SelectionGrid(Mathf.Max(0, mCurrentTest), mTests.ToArray(), 4); if (sel != mCurrentTest) { mCurrentTest = sel; Timer.Clear(); mTestResults.Clear(); mGUIMethod = GetType().GetMethod("GUI_" + mTests[mCurrentTest], BindingFlags.NonPublic | BindingFlags.Instance); mRunMethod = GetType().GetMethod("Test_" + mTests[mCurrentTest], BindingFlags.NonPublic | BindingFlags.Instance); } GUILayout.Space(5); if (mGUIMethod != null) { mGUIMethod.Invoke(this, null); } GUI.enabled = !mExecuting && mRunMethod != null; string label = (mExecuting) ? "Please wait..." : "Run (" + LOOPS + " times)"; if (GUILayout.Button(label)) { mExecuting = true; Timer.Clear(); mTestResults.Clear(); Invoke("runTest", .5f); } GUI.enabled = true; if (Timer.Count > 0) { foreach (var s in mTestResults) { GUILayout.Label(s); } GUILayout.Label(string.Format("Average (ms): {0:0.0000}", Timer.AverageMS)); GUILayout.Label(string.Format("Minimum (ms): {0:0.0000}", Timer.MinimumMS)); GUILayout.Label(string.Format("Maximum (ms): {0:0.0000}", Timer.MaximumMS)); } GUILayout.EndVertical(); }
/// <summary> /// Sets basic spline parameters /// </summary> protected void PrepareSpline(CurvyInterpolation interpolation, CurvyOrientation orientation = CurvyOrientation.Dynamic, int cachedensity = 50, bool closed = true) { #if UNITY_EDITOR if (!Application.isPlaying) Undo.RecordObject(Spline, "Apply Shape"); #endif Spline.Interpolation = interpolation; Spline.Orientation = orientation; Spline.CacheDensity = cachedensity; Spline.Closed = closed; Spline.RestrictTo2D = this is CurvyShape2D; }