Files
XRLib/Assets/Scripts/Simulator/PropertyWindow/InitailizePopup/AsrsPositionUtil.cs
2026-01-16 16:45:34 +09:00

32 lines
998 B
C#

using UnityEngine;
using Simulator.Data;
public static class AsrsPositionUtil
{
// 서버/모델이 float로 주더라도 실제 그리드 좌표는 정수여야 하므로 RoundToInt를 사용합니다.
public static Vector3Int ToGridInt(Position p)
{
return new Vector3Int(
Mathf.RoundToInt(p.x),
Mathf.RoundToInt(p.y),
Mathf.RoundToInt(p.z)
);
}
public static Position ToPosition(Vector3Int v)
{
return new Position { x = v.x, y = v.y, z = v.z };
}
public static (Vector3Int from, Vector3Int to) Normalize(Vector3Int from, Vector3Int to)
{
int minX = Mathf.Min(from.x, to.x);
int maxX = Mathf.Max(from.x, to.x);
int minY = Mathf.Min(from.y, to.y);
int maxY = Mathf.Max(from.y, to.y);
int minZ = Mathf.Min(from.z, to.z);
int maxZ = Mathf.Max(from.z, to.z);
return (new Vector3Int(minX, minY, minZ), new Vector3Int(maxX, maxY, maxZ));
}
}