Readd missing import files
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using Wing.Utils;
|
||||
|
||||
namespace Wing.Gizmos
|
||||
{
|
||||
public class AngleSnap : SnapBase
|
||||
{
|
||||
public Vector3 Center = Vector3.zero;
|
||||
|
||||
private float mAngle = 0;
|
||||
public float CurrentAngle
|
||||
{
|
||||
get
|
||||
{
|
||||
return mAngle;
|
||||
}
|
||||
}
|
||||
public AngleSnap()
|
||||
{
|
||||
Precision = 15;
|
||||
}
|
||||
|
||||
protected override void CalcTolerance()
|
||||
{
|
||||
mTolerance = 0.2f * Precision;
|
||||
}
|
||||
|
||||
public override bool Snap(Vector3 inVal, ref Vector3 outVal, bool force = false)
|
||||
{
|
||||
if (!Enable)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector3 dir = inVal.normalized;
|
||||
float angle = GemetryHelper.VectorAngle(Vector3.right, dir);
|
||||
|
||||
mAngle = GemetryHelper.ValueMod(angle, Precision);
|
||||
|
||||
if (force || Mathf.Abs(angle - mAngle) <= Precision)
|
||||
{
|
||||
outVal = Quaternion.Euler(0, mAngle, 0) * Vector3.right;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9b0fd1b1ffcafb6498735f6aa8404058
|
||||
timeCreated: 1478770278
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using Wing.Utils;
|
||||
|
||||
namespace Wing.Gizmos
|
||||
{
|
||||
public class GridSnap : SnapBase
|
||||
{
|
||||
public Vector3 Center = Vector3.zero;
|
||||
|
||||
public GridSnap()
|
||||
{
|
||||
Precision = 1;
|
||||
}
|
||||
|
||||
protected override void CalcTolerance()
|
||||
{
|
||||
mTolerance = 0.2f * Precision;
|
||||
}
|
||||
|
||||
public override bool Snap(Vector3 inVal, ref Vector3 outVal, bool force = false)
|
||||
{
|
||||
if (!Enable)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Vector3 position = inVal;
|
||||
Vector3 offset = position - Center;
|
||||
Vector3 dp = GemetryHelper.Vector3Mod(offset, Precision);
|
||||
|
||||
Vector3 df = position - dp;
|
||||
df.x = Mathf.Abs(df.x);
|
||||
df.y = Mathf.Abs(df.y);
|
||||
df.z = Mathf.Abs(df.z);
|
||||
|
||||
float max = Mathf.Max(df.x, df.y, df.z);
|
||||
|
||||
if (force || max <= mTolerance)
|
||||
{
|
||||
outVal = dp;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e3fb8ef001ee43f4e862b612c2ba3ecf
|
||||
timeCreated: 1478770278
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Wing.Gizmos
|
||||
{
|
||||
public interface ISnap
|
||||
{
|
||||
bool Enable { get; set; }
|
||||
float Precision { get; set; }
|
||||
bool Snap(Vector3 inVal, ref Vector3 outVal, bool force = false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa4a06a87e47d294a80687a70ef6a733
|
||||
timeCreated: 1478766622
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using Wing.Utils;
|
||||
|
||||
namespace Wing.Gizmos
|
||||
{
|
||||
public class MoveSnap : SnapBase
|
||||
{
|
||||
public Vector3 Center = Vector3.zero;
|
||||
|
||||
public MoveSnap()
|
||||
{
|
||||
Precision = 1;
|
||||
}
|
||||
|
||||
protected override void CalcTolerance()
|
||||
{
|
||||
mTolerance = 0.05f * Precision;
|
||||
}
|
||||
|
||||
public override bool Snap(Vector3 inVal, ref Vector3 outVal, bool force = false)
|
||||
{
|
||||
if (!Enable)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector3 position = inVal;
|
||||
Vector3 offset = position - Center;
|
||||
Vector3 dp = GemetryHelper.Vector3Mod(offset, Precision);
|
||||
|
||||
if (force || (position - dp).magnitude <= mTolerance)
|
||||
{
|
||||
outVal = dp;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b21fc2f114b61e418e637a0ab7754f7
|
||||
timeCreated: 1478766622
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using Wing.Utils;
|
||||
|
||||
namespace Wing.Gizmos
|
||||
{
|
||||
public class RotateSnap : SnapBase
|
||||
{
|
||||
|
||||
public RotateSnap()
|
||||
{
|
||||
Precision = 5;
|
||||
}
|
||||
|
||||
protected override void CalcTolerance()
|
||||
{
|
||||
mTolerance = 0.2f * Precision;
|
||||
}
|
||||
|
||||
public override bool Snap(Vector3 inVal, ref Vector3 outVal, bool force = false)
|
||||
{
|
||||
if (!Enable)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector3 angle = inVal;
|
||||
outVal = GemetryHelper.Vector3Mod(angle, Precision);
|
||||
|
||||
Vector3 offset = angle - outVal;
|
||||
|
||||
if (force || offset.magnitude <= Precision)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 40c4b4487bab18344af53c665aff49d8
|
||||
timeCreated: 1478768767
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using Wing.Utils;
|
||||
|
||||
namespace Wing.Gizmos
|
||||
{
|
||||
public class ScaleSnap : SnapBase
|
||||
{
|
||||
public ScaleSnap()
|
||||
{
|
||||
Precision = 0.2f;
|
||||
}
|
||||
|
||||
protected override void CalcTolerance()
|
||||
{
|
||||
mTolerance = 0.5f * Precision;
|
||||
}
|
||||
|
||||
public override bool Snap(Vector3 inVal, ref Vector3 outVal, bool force = false)
|
||||
{
|
||||
if (!Enable)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector3 scale = inVal;
|
||||
Vector3 dp = GemetryHelper.Vector3Mod(scale, Precision);
|
||||
|
||||
if (force || (scale - dp).magnitude <= mTolerance)
|
||||
{
|
||||
outVal = dp;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f0ef511f98bffe44ba2edc3a3d045d1
|
||||
timeCreated: 1478768767
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Wing.Gizmos
|
||||
{
|
||||
public class SnapBase : ISnap
|
||||
{
|
||||
protected bool mEnable = false;
|
||||
protected float mPrecision = 0;
|
||||
protected float mTolerance = 0;
|
||||
|
||||
public bool Enable
|
||||
{
|
||||
get
|
||||
{
|
||||
return mEnable;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
mEnable = value;
|
||||
}
|
||||
}
|
||||
|
||||
public float Precision
|
||||
{
|
||||
get
|
||||
{
|
||||
return mPrecision;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
mPrecision = value;
|
||||
CalcTolerance();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void CalcTolerance()
|
||||
{
|
||||
mTolerance = Precision * 0.2f;
|
||||
}
|
||||
|
||||
public virtual bool Snap(Vector3 inVal, ref Vector3 outVal, bool force = false)
|
||||
{
|
||||
outVal = Vector3.zero;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3dbb40102de5ba442a384fd3d31ae70d
|
||||
timeCreated: 1478766622
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Wing.Utils;
|
||||
|
||||
namespace Wing.Gizmos
|
||||
{
|
||||
public enum ESnapType
|
||||
{
|
||||
Move,
|
||||
Rotate,
|
||||
Scale,
|
||||
Grid,
|
||||
Angle,
|
||||
}
|
||||
|
||||
public class SnapFactory : NormalSingleton<SnapFactory>
|
||||
{
|
||||
private Dictionary<ESnapType, ISnap> mSnaps = new Dictionary<ESnapType, ISnap>();
|
||||
|
||||
public SnapFactory()
|
||||
{
|
||||
mSnaps.Add(ESnapType.Move, new MoveSnap());
|
||||
mSnaps.Add(ESnapType.Rotate, new RotateSnap());
|
||||
mSnaps.Add(ESnapType.Scale, new ScaleSnap());
|
||||
mSnaps.Add(ESnapType.Grid, new GridSnap());
|
||||
mSnaps.Add(ESnapType.Angle, new AngleSnap());
|
||||
}
|
||||
|
||||
public ISnap Get(ESnapType type)
|
||||
{
|
||||
return mSnaps[type];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d9793fa7f0cf6134cb2c00fdab230811
|
||||
timeCreated: 1478770278
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user