diff --git a/Assets/Scripts/Monolith.cs b/Assets/Scripts/Monolith.cs index 5168e29..069f0e3 100644 --- a/Assets/Scripts/Monolith.cs +++ b/Assets/Scripts/Monolith.cs @@ -43,8 +43,8 @@ public class Monolith : MonoBehaviour break; case Scene.Pixelgon: - // toolNewQuad.Frame(input, pixelgon); - // render.ToolNewQuad(toolNewQuad); + // toolNewQuad.Frame(input, pixelgon); + // render.ToolNewQuad(toolNewQuad); if (input.offCon.two.down) { toolNewVector.Reset(); @@ -125,6 +125,30 @@ public static class StaticMethods } } + static Vector3[] snappingDir = new Vector3[] { Vector3.right, Vector3.up, Vector3.forward }; + public static Vector3 DirSnap(Vector3 a, Vector3 c) + { + for (int i = 0; i < snappingDir.Length; i++) + { + for (int j = 0; j < 2; j++) + { + Vector3 snapDir = snappingDir[i]; + if (j == 1) + { + snapDir = snappingDir[i] * -1f; // right -> left etc. + } + + Vector3 dir = (c - a).normalized; + if (Vector3.Angle(snapDir, dir) < 8f) // dir snapping margin + { + return a + snapDir * Vector3.Distance(a, c); + } + } + } + + return c; + } + public static Vector3 EdgeSnap(Vector3 a, Vector3 b, Vector3 c) { Quaternion perspective = Quaternion.LookRotation(b - a); @@ -144,6 +168,8 @@ public static class StaticMethods // snapping margin, where is this variable? // idk becuase this snapping system will be reused in tools and quads // scalable 0-1 * design (0 == no snapping) set parameter in ORIEL UI + + // min distance to handle 2+ conflicting snaps if (dist < 0.02f) { pC.x = pA.x; diff --git a/Assets/Scripts/Pixelgon.cs b/Assets/Scripts/Pixelgon.cs index d3d9280..07cfdfd 100644 --- a/Assets/Scripts/Pixelgon.cs +++ b/Assets/Scripts/Pixelgon.cs @@ -6,6 +6,7 @@ using UnityEngine; [Serializable] public class Pixelgon { + // Just Data // public List quads = new List(); // one material, one texture, map uv accordingly public List vectors = new List(); // mapped to one List with null break vectors } \ No newline at end of file diff --git a/Assets/Scripts/Stretch Silo/StretchSilo.cs b/Assets/Scripts/Stretch Silo/StretchSilo.cs index f5a77d9..1c80c16 100644 --- a/Assets/Scripts/Stretch Silo/StretchSilo.cs +++ b/Assets/Scripts/Stretch Silo/StretchSilo.cs @@ -6,5 +6,6 @@ using System.Collections.Generic; [Serializable] public class StretchSilo { + // Just Data public Vector3 structure; } \ No newline at end of file diff --git a/Assets/Scripts/Tools/ToolNewVector.cs b/Assets/Scripts/Tools/ToolNewVector.cs index 41a4419..4ecdc81 100644 --- a/Assets/Scripts/Tools/ToolNewVector.cs +++ b/Assets/Scripts/Tools/ToolNewVector.cs @@ -19,6 +19,7 @@ public class ToolNewVector public void Frame(Input input, Pixelgon pixelgon) { + bool snapped = false; cursorPos = input.twistCursor; int length = 0; @@ -32,9 +33,6 @@ public class ToolNewVector { if (length > 0) { - // how to switch between edge snap and direction snap - // can you have them both happening at the same time? - // is it a priority based system? cursorPos = StaticMethods.EdgeSnap( pixelgon.vectors[i - 1], pixelgon.vectors[i], @@ -42,6 +40,10 @@ public class ToolNewVector ); if (cursorPos != input.twistCursor) { + // how to switch between edge snap and direction snap + // can you have them both happening at the same time? + // is it a priority based system? + snapped = true; break; } } @@ -50,6 +52,18 @@ public class ToolNewVector } } + if (!snapped && vector.Count > 1) + { + cursorPos = StaticMethods.DirSnap(vector[vector.Count - 2], cursorPos); + if (cursorPos != input.twistCursor) + { + // how to switch between edge snap and direction snap + // can you have them both happening at the same time? + // is it a priority based system? + snapped = true; + } + } + if (input.mainCon.trigger.down) { vector.Add(cursorPos); diff --git a/Assets/Source.meta b/Assets/Source.meta deleted file mode 100644 index 458b388..0000000 --- a/Assets/Source.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: a5b4216e803c33a4fb96579e8f0d4bef -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: