Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
魔术师Dix
Unity几何库:木蝴蝶
提交
d285a243
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 搜索 >>
提交
d285a243
编写于
11月 10, 2022
作者:
魔术师Dix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加数据结构,AABB的Box;
上级
39af8309
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
254 addition
and
0 deletion
+254
-0
Intersection/IntrLine2dBox2dAABB.cs
Intersection/IntrLine2dBox2dAABB.cs
+21
-0
Intersection/IntrLine2dBox2dAABB.cs.meta
Intersection/IntrLine2dBox2dAABB.cs.meta
+11
-0
Intersection/IntrLine3dBox3dAABB.cs
Intersection/IntrLine3dBox3dAABB.cs
+123
-0
Intersection/IntrLine3dBox3dAABB.cs.meta
Intersection/IntrLine3dBox3dAABB.cs.meta
+11
-0
Math/Box2d.cs
Math/Box2d.cs
+1
-0
Math/Box2dAABB.cs
Math/Box2dAABB.cs
+23
-0
Math/Box2dAABB.cs.meta
Math/Box2dAABB.cs.meta
+11
-0
Math/Box3d.cs
Math/Box3d.cs
+1
-0
Math/Box3dAABB.cs
Math/Box3dAABB.cs
+41
-0
Math/Box3dAABB.cs.meta
Math/Box3dAABB.cs.meta
+11
-0
未找到文件。
Intersection/IntrLine2dBox2dAABB.cs
0 → 100644
浏览文件 @
d285a243
/*
*Copyright(C) 2020 by Cyf All rights reserved.
*Unity版本:2021.3.11f1c2
*作者:程一峰
*创建日期: 2022-11-10
*模块说明:
*版本: 1.0
*/
namespace
Oroxylum
{
/// <summary>
///
/// </summary>
public
struct
IntrLine2dBox2dAABB
{
}
}
Intersection/IntrLine2dBox2dAABB.cs.meta
0 → 100644
浏览文件 @
d285a243
fileFormatVersion: 2
guid: 8effaf9bdb01f13428af8b8d62da04e3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Intersection/IntrLine3dBox3dAABB.cs
0 → 100644
浏览文件 @
d285a243
/*
*Copyright(C) 2020 by Cyf All rights reserved.
*Unity版本:2021.3.11f1c2
*作者:程一峰
*创建日期: 2022-11-10
*模块说明:
*版本: 1.0
*/
using
Unity.Mathematics
;
namespace
Oroxylum
{
/// <summary>
/// 相交计算结果:3d直线与3dBoxAABB
/// </summary>
public
struct
IntrLine3dBox3dAABB
{
public
int
Quantity
;
public
E_IntersectionResult
Result
;
public
E_IntersectionType
Type
;
public
float
LineParam0
,
LineParam1
;
public
float3
Point0
;
public
float3
Point1
;
public
IntrLine3dBox3dAABB
(
Line3d
line
,
Box3dAABB
box
)
{
Result
=
E_IntersectionResult
.
NotComputed
;
Type
=
E_IntersectionType
.
Empty
;
LineParam0
=
-
float
.
MaxValue
;
LineParam1
=
float
.
MaxValue
;
Point0
=
0
;
Point1
=
1
;
Quantity
=
0
;
DoClipping
(
ref
LineParam0
,
ref
LineParam1
,
ref
line
.
Origin
,
ref
line
.
Direction
,
ref
box
,
true
,
ref
Quantity
,
ref
Point0
,
ref
Point1
,
ref
Type
);
Result
=
(
Type
!=
E_IntersectionType
.
Empty
)
?
E_IntersectionResult
.
Intersects
:
E_IntersectionResult
.
NoIntersection
;
}
static
bool
DoClipping
(
ref
float
t0
,
ref
float
t1
,
ref
float3
origin
,
ref
float3
direction
,
ref
Box3dAABB
box
,
bool
solid
,
ref
int
quantity
,
ref
float3
point0
,
ref
float3
point1
,
ref
E_IntersectionType
intrType
)
{
float3
BOrigin
=
origin
-
box
.
Center
;
float3
extent
=
box
.
Extents
;
double
saveT0
=
t0
,
saveT1
=
t1
;
bool
notAllClipped
=
Clip
(+
direction
.
x
,
-
BOrigin
.
x
-
extent
.
x
,
ref
t0
,
ref
t1
)
&&
Clip
(-
direction
.
x
,
+
BOrigin
.
x
-
extent
.
x
,
ref
t0
,
ref
t1
)
&&
Clip
(+
direction
.
y
,
-
BOrigin
.
y
-
extent
.
y
,
ref
t0
,
ref
t1
)
&&
Clip
(-
direction
.
y
,
+
BOrigin
.
y
-
extent
.
y
,
ref
t0
,
ref
t1
)
&&
Clip
(+
direction
.
z
,
-
BOrigin
.
z
-
extent
.
z
,
ref
t0
,
ref
t1
)
&&
Clip
(-
direction
.
z
,
+
BOrigin
.
z
-
extent
.
z
,
ref
t0
,
ref
t1
);
if
(
notAllClipped
&&
(
solid
||
t0
!=
saveT0
||
t1
!=
saveT1
))
{
if
(
t1
>
t0
)
{
intrType
=
E_IntersectionType
.
LineSegment
;
quantity
=
2
;
point0
=
origin
+
t0
*
direction
;
point1
=
origin
+
t1
*
direction
;
}
else
{
intrType
=
E_IntersectionType
.
Point
;
quantity
=
1
;
point0
=
origin
+
t0
*
direction
;
}
}
else
{
quantity
=
0
;
intrType
=
E_IntersectionType
.
Empty
;
}
return
intrType
!=
E_IntersectionType
.
Empty
;
}
static
bool
Clip
(
float
denom
,
float
numer
,
ref
float
t0
,
ref
float
t1
)
{
// Return value is 'true' if line segment intersects the current test
// plane. Otherwise 'false' is returned in which case the line segment
// is entirely clipped.
if
(
denom
>
0
)
{
if
(
numer
-
denom
*
t1
>
OMath
.
ZeroTolerance
)
{
return
false
;
}
if
(
numer
>
denom
*
t0
)
{
t0
=
numer
/
denom
;
}
return
true
;
}
else
if
(
denom
<
0
)
{
if
(
numer
-
denom
*
t0
>
OMath
.
ZeroTolerance
)
{
return
false
;
}
if
(
numer
>
denom
*
t1
)
{
t1
=
numer
/
denom
;
}
return
true
;
}
else
{
return
numer
<=
0
;
}
}
}
}
Intersection/IntrLine3dBox3dAABB.cs.meta
0 → 100644
浏览文件 @
d285a243
fileFormatVersion: 2
guid: 4066e991336213544ad3e5a186e244cf
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Math/Box2d.cs
浏览文件 @
d285a243
...
...
@@ -13,6 +13,7 @@ namespace Oroxylum
{
/// <summary>
/// 2d Box
/// 平行四边形
/// </summary>
public
struct
Box2d
{
...
...
Math/Box2dAABB.cs
0 → 100644
浏览文件 @
d285a243
/*
*Copyright(C) 2020 by Cyf All rights reserved.
*Unity版本:2021.3.11f1c2
*作者:程一峰
*创建日期: 2022-11-10
*模块说明:木蝴蝶数学库:数据格式
*版本: 1.0
*/
using
Unity.Mathematics
;
namespace
Oroxylum
{
/// <summary>
/// AxisAlignedBox2d
/// 规整的AABB盒子
/// </summary>
public
struct
Box2dAABB
{
}
}
Math/Box2dAABB.cs.meta
0 → 100644
浏览文件 @
d285a243
fileFormatVersion: 2
guid: 89ec9118f87a18f4898945385f27ce54
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Math/Box3d.cs
浏览文件 @
d285a243
...
...
@@ -14,6 +14,7 @@ namespace Oroxylum
{
/// <summary>
/// 3d Box
/// 平行立方体
/// </summary>
public
struct
Box3d
{
...
...
Math/Box3dAABB.cs
0 → 100644
浏览文件 @
d285a243
/*
*Copyright(C) 2020 by Cyf All rights reserved.
*Unity版本:2021.3.11f1c2
*作者:程一峰
*创建日期: 2022-11-10
*模块说明:木蝴蝶数学库:数据格式
*版本: 1.0
*/
using
System
;
using
Unity.Mathematics
;
namespace
Oroxylum
{
/// <summary>
/// AxisAlignedBox3d
/// AABB 规整的立方体
/// </summary>
public
struct
Box3dAABB
{
public
float3
Min
;
public
float3
Max
;
public
Box3dAABB
(
float3
vMin
,
float3
vMax
)
{
Min
=
new
float3
(
math
.
min
(
vMin
.
x
,
vMax
.
x
),
math
.
min
(
vMin
.
y
,
vMax
.
y
),
math
.
min
(
vMin
.
z
,
vMax
.
z
));
Max
=
new
float3
(
math
.
max
(
vMin
.
x
,
vMax
.
x
),
math
.
max
(
vMin
.
y
,
vMax
.
y
),
math
.
max
(
vMin
.
z
,
vMax
.
z
));
}
public
float
Width
=>
math
.
max
(
Max
.
x
-
Min
.
x
,
0
);
public
float
Height
=>
math
.
max
(
Max
.
y
-
Min
.
y
,
0
);
public
float
Depth
=>
math
.
max
(
Max
.
z
-
Min
.
z
,
0
);
public
float
Volume
=>
Width
*
Height
*
Depth
;
public
float3
Diagonal
=>
new
float3
(
Max
.
x
-
Min
.
x
,
Max
.
y
-
Min
.
y
,
Max
.
z
-
Min
.
z
);
public
float3
Extents
=>
new
float3
((
Max
.
x
-
Min
.
x
)
*
0.5f
,
(
Max
.
y
-
Min
.
y
)
*
0.5f
,
(
Max
.
z
-
Min
.
z
)
*
0.5f
);
public
float3
Center
=>
new
float3
(
0.5f
*
(
Min
.
x
+
Max
.
x
),
0.5f
*
(
Min
.
y
+
Max
.
y
),
0.5f
*
(
Min
.
z
+
Max
.
z
));
}
}
\ No newline at end of file
Math/Box3dAABB.cs.meta
0 → 100644
浏览文件 @
d285a243
fileFormatVersion: 2
guid: eb75c217b50948b42bee1926eb47c716
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录