提交 6cec9dd8 编写于 作者: 魔术师Dix's avatar 魔术师Dix

更新通用方法结构;

上级 668e1c06
{
"name": "Oroxylum",
"rootNamespace": "",
"references": [
"Unity.Mathematics"
],
"references": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
......
......@@ -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);
}
/// <summary>
......@@ -331,20 +330,6 @@ namespace Oroxylum
return point;
}
/// <summary>
/// 将 float4x4 转换为 Matrix4x4;
/// </summary>
/// <param name="value">float4x4</param>
/// <returns>Matrix4x4</returns>
public static Matrix4x4 ToMatrix4X4(this float4x4 value) { return new Matrix4x4(value.c0, value.c1, value.c2, value.c3); }
/// <summary>
/// 将 Matrix4x4 转换为 float4x4
/// </summary>
/// <param name="value">Matrix4x4</param>
/// <returns>float4x4</returns>
public static float4x4 ToFloat4X4(this Matrix4x4 value) { return new float4x4(value[0], value[1], value[2], value[3]); }
/// <summary>
/// 将值限制在两个Vector3之间
/// </summary>
......@@ -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 字符串操作
......
......@@ -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);
}
/// <summary>
/// 将 float4x4 转换为 Matrix4x4;
/// </summary>
/// <param name="value">float4x4</param>
/// <returns>Matrix4x4</returns>
public static Matrix4x4 ToMatrix4X4(this float4x4 value) { return new Matrix4x4(value.c0, value.c1, value.c2, value.c3); }
/// <summary>
/// 将 Matrix4x4 转换为 float4x4
/// </summary>
/// <param name="value">Matrix4x4</param>
/// <returns>float4x4</returns>
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); }
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册