diff --git a/Common/Oroxylum.asmdef b/Common/Oroxylum.asmdef index 4b96acf670793162efbd028b0a89d084fd77b63b..8b7ffa32279d2a62ff353761ae14760842b1b853 100644 --- a/Common/Oroxylum.asmdef +++ b/Common/Oroxylum.asmdef @@ -1,9 +1,7 @@ { "name": "Oroxylum", "rootNamespace": "", - "references": [ - "Unity.Mathematics" - ], + "references": [], "includePlatforms": [], "excludePlatforms": [], "allowUnsafeCode": false, diff --git a/Common/Utils.cs b/Common/Utils.cs index 4ebab348969314f019ae32aa4f96d127499a22e9..2d13342a0d28b0e70eec0f5642335bf4258eb459 100644 --- a/Common/Utils.cs +++ b/Common/Utils.cs @@ -9,7 +9,6 @@ using System.Collections.Generic; using Unity.Collections; -using Unity.Mathematics; using UnityEngine; namespace Oroxylum @@ -222,7 +221,7 @@ namespace Oroxylum return ret; } - public static long Int2ToLong(int2 v) + public static long Int2ToLong(Vector2Int v) { int q = v.x, r = v.y; long rt = (long)q << 32; @@ -230,11 +229,11 @@ namespace Oroxylum return rt; } - public static int2 LongToInt2(long id) + public static Vector2Int LongToInt2(long id) { int x = (int)(id >> 32); int y = (int)id; - return new int2(x, y); + return new Vector2Int(x, y); } /// @@ -331,20 +330,6 @@ namespace Oroxylum return point; } - /// - /// 将 float4x4 转换为 Matrix4x4; - /// - /// float4x4 - /// Matrix4x4 - public static Matrix4x4 ToMatrix4X4(this float4x4 value) { return new Matrix4x4(value.c0, value.c1, value.c2, value.c3); } - - /// - /// 将 Matrix4x4 转换为 float4x4 - /// - /// Matrix4x4 - /// float4x4 - public static float4x4 ToFloat4X4(this Matrix4x4 value) { return new float4x4(value[0], value[1], value[2], value[3]); } - /// /// 将值限制在两个Vector3之间 /// @@ -406,13 +391,6 @@ namespace Oroxylum return x + z; } - - public static float2 XZ_float(this Vector3 p) { return new float2(p.x, p.z); } - - public static Vector3 ToVec3ByXZ(this float2 xz, float y = 0) { return new Vector3(xz.x, y, xz.y); } - - public static float2 Vec2ToFloat2(this Vector2 p) { return new float2(p.x, p.y); } - #endregion #region 字符串操作 diff --git a/Math/Extensions.Math.cs b/Math/Extensions.Math.cs index 3eb2cf85aff144d98b4e6eb7da4b08bbda86251e..919164ab7d011c1d720ed0bfe75452e39007ad50 100644 --- a/Math/Extensions.Math.cs +++ b/Math/Extensions.Math.cs @@ -90,5 +90,40 @@ namespace Oroxylum float z = a.z * b.z; return new Vector3(x, y, z); } + + public static long Int2ToLong(int2 v) + { + int q = v.x, r = v.y; + long rt = (long)q << 32; + rt = rt | (r & 0xffffffff); + return rt; + } + + public static int2 LongToInt2(long id) + { + int x = (int)(id >> 32); + int y = (int)id; + return new int2(x, y); + } + + /// + /// 将 float4x4 转换为 Matrix4x4; + /// + /// float4x4 + /// Matrix4x4 + public static Matrix4x4 ToMatrix4X4(this float4x4 value) { return new Matrix4x4(value.c0, value.c1, value.c2, value.c3); } + + /// + /// 将 Matrix4x4 转换为 float4x4 + /// + /// Matrix4x4 + /// float4x4 + public static float4x4 ToFloat4X4(this Matrix4x4 value) { return new float4x4(value[0], value[1], value[2], value[3]); } + + public static float2 XZ_float(this Vector3 p) { return new float2(p.x, p.z); } + + public static Vector3 ToVec3ByXZ(this float2 xz, float y = 0) { return new Vector3(xz.x, y, xz.y); } + + public static float2 Vec2ToFloat2(this Vector2 p) { return new float2(p.x, p.y); } } }