Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
魔术师Dix
Unity几何库:木蝴蝶
提交
6cec9dd8
Unity几何库:木蝴蝶
项目概览
魔术师Dix
/
Unity几何库:木蝴蝶
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Unity几何库:木蝴蝶
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
6cec9dd8
编写于
10月 19, 2023
作者:
魔术师Dix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
更新通用方法结构;
上级
668e1c06
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
39 addition
and
28 deletion
+39
-28
Common/Oroxylum.asmdef
Common/Oroxylum.asmdef
+1
-3
Common/Utils.cs
Common/Utils.cs
+3
-25
Math/Extensions.Math.cs
Math/Extensions.Math.cs
+35
-0
未找到文件。
Common/Oroxylum.asmdef
浏览文件 @
6cec9dd8
{
"name": "Oroxylum",
"rootNamespace": "",
"references": [
"Unity.Mathematics"
],
"references": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
...
...
Common/Utils.cs
浏览文件 @
6cec9dd8
...
...
@@ -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
字符串操作
...
...
Math/Extensions.Math.cs
浏览文件 @
6cec9dd8
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录