質問編集履歴
1
コードを追加しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -5,3 +5,37 @@
|
|
5
5
|
|
6
6
|
|
7
7
|
当たり判定はAABBでやっていますが、それで出来ない場合は別の当たり判定も教えてほしいです
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
bool box2box(BoxNode& nodeA, BoxNode& nodeB)
|
14
|
+
|
15
|
+
{
|
16
|
+
|
17
|
+
Vector3 minA = nodeA.getPosition() - Vector3(nodeA.getSizeX(), nodeA.getSizeY(), nodeA.getSizeZ());
|
18
|
+
|
19
|
+
Vector3 maxA = nodeA.getPosition() + Vector3(nodeA.getSizeX(), nodeA.getSizeY(), nodeA.getSizeZ());
|
20
|
+
|
21
|
+
Vector3 minB = nodeB.getPosition() - Vector3(nodeB.getSizeX(), nodeB.getSizeY(), nodeB.getSizeZ());
|
22
|
+
|
23
|
+
Vector3 maxB = nodeB.getPosition() + Vector3(nodeB.getSizeX(), nodeB.getSizeY(), nodeB.getSizeZ());
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
if (minA.x < maxB.x && maxA.x > minB.x &&
|
28
|
+
|
29
|
+
minA.y < maxB.y && maxA.y > minB.y &&
|
30
|
+
|
31
|
+
minA.z < maxB.z && maxA.z > minB.z)
|
32
|
+
|
33
|
+
{
|
34
|
+
|
35
|
+
return true;
|
36
|
+
|
37
|
+
}
|
38
|
+
|
39
|
+
return false;
|
40
|
+
|
41
|
+
}
|