45 lines
913 B
C#
45 lines
913 B
C#
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;
|
|
}
|
|
}
|
|
}
|
|
}
|