46 lines
918 B
C#
46 lines
918 B
C#
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;
|
|
}
|
|
}
|
|
}
|
|
}
|