KisaragiLibrary
 
読��り中…
検索中…
一致�る文字列を見��られ��ん
Collision.hpp
[詳解]
1#pragma once
2
3#include "ComponentBase.hpp"
4#include "Const.h"
5#include <array>
6#include <vector>
7#include "Matrix2D.hpp"
8#include "Kisaragi_Math.hpp"
9#include "Primitive.hpp"
10#include "GameObj.hpp"
12#include "CollisionQueue.hpp"
13
14using std::vector;
15
16
17
18//TODO ‘ŠŽè‘¤‚É‚àhit‚ð’Ê’m
19
20//TODO SAT‚·‚é‘O‚ÉŽlŠp‚Æ‚©‚ÅŽG‚ȉ‰ŽZ‚µ‚½•û‚ª‚¢‚¢‚¯‚Ç�A4•ª–Ø‚·‚é‹C‚È‚ñ‚Å�È—ª
21
22namespace Kisaragi_Lib
23{
25 {
26 public:
27 bool hit;
28
30 {
31
32 }
33
35 {
36
37 }
38
39
40 //“–‚½‚è”»’è�ˆ—�‚ð�s‚Á‚Ä‚¢‚È‚¢‚È‚çExit�ˆ—�‚ð�s‚¤
41
42
43 //AABB‚Ƃ̓–‚½‚è”»’è‚ð�s‚¤
44
45 };
46
48 {
49 public:
51
53
54
55 //bool CollidesWith(AABBCollision2D* _other)
56 //{
57 // bool result = false;
58
59 // //ƒ��[ƒ‹ƒh�À•W‚ð‹�‚ß‚é
60 // Point2D<double> thisLehtTop = gameObj->transform.position + aabb.LeftTopPoint();
61 // Point2D<double> thisRightBottom = gameObj->transform.position + aabb.RightBottomPoint();
62
63 // Point2D<double> otherLeftTop = _other->gameObj->transform.position + _other->aabb.LeftTopPoint();
64 // Point2D<double> otherRightBottom = _other->gameObj->transform.position + _other->aabb.RightBottomPoint();
65
66
67 // //_other‚̉E’[‚ª�¶’[‚æ‚è‰E‚É‚ ‚é‚©?
68 // if (thisLehtTop.x <= otherRightBottom.x
69 // //_other‚Ì�¶’[‚ª‰E’[‚æ‚è�¶‚É‚ ‚é‚©?
70 // && thisRightBottom.x >= otherLeftTop.x)
71 // {
72 //
73 // //_other‚̉º’[‚ª�ã’[‚æ‚艺‚É‚ ‚é‚©?
74 // if (thisLehtTop.y <= otherRightBottom.y
75 // //_other‚Ì�ã’[‚ª‰º’[‚æ‚è�ã‚É‚ ‚é‚©?
76 // && thisRightBottom.y >= otherLeftTop.y)
77 // {
78 // result = true;
79 // Hit(_other);
80 // }
81 // }
82
83 // return result;
84 //}
85
86 };
87
88
89
90
91
92
93
94 //class CollisionCheck
95 //{
96 //public:
97 // static bool Collision(BoxCollision2D _obj1, BoxCollision2D _obj2)
98 // {
99 // // OBB vs OBB
100 // //bool CollisionTest_OBB_OBB(Vector2[] vertsA, Vector2[] vertsB)
101 //
102 // //ŽQ�l https://www.eproph527tw.com/i3dprg/ch02/sec221.html
103 // //4ŠpŒ`‚̕ӂ̃xƒNƒgƒ‹‚ð‹�‚ß‚é(�¡‰ñ‚Í•À�sŽl•ÓŒ`‚̂ݑΉž.‘¼‚É‚à‘Ήž‚³‚¹‚½‚¯‚ê‚Εӂ̗ʂð‘�‚₵‚Ä‚Ë)
104 // std::vector<Vector2<double>> sideDirs;
105
106 //
107 //
108 // //ŽQ�lŒ³‚Å‚Í�³‹K‰»‚µ‚Ă邯‚ÇŒ‹‰Ê‚͕ςí‚ç‚È‚¢‚̂łµ‚È‚­‚Ä—Ç‚¢
109 //
110 // //•À�sŽl•ÓŒ`A‚̕ӃxƒNƒgƒ‹‚ð‹�‚ß‚é
111 // sideDirs.push_back(_obj1.boxVertex[0] - _obj1.boxVertex[1]);
112 // sideDirs.push_back(_obj1.boxVertex[1] - _obj1.boxVertex[2]);
113 // //•À�sŽl•ÓŒ`B‚̕ӃxƒNƒgƒ‹‚ð‹�‚ß‚é
114 // sideDirs.push_back(_obj2.boxVertex[0] - _obj2.boxVertex[1]);
115 // sideDirs.push_back(_obj2.boxVertex[1] - _obj2.boxVertex[2]);
116 //
117
118 // for(auto& u : sideDirs)
119 // {
120 // float minA = _obj1.boxVertex[0].x * u.x + _obj1.boxVertex[0].y * u.y;
121 // float maxA = minA;
122 // float minB = _obj2.boxVertex[0].x * u.x + _obj2.boxVertex[0].y * u.y;
123 // float maxB = minB;
124
125 // //•ӂ̃xƒNƒgƒ‹‚ðŠî�€‚Æ‚µ‚Ä�AŽË‰e‹óŠÔ‚ð‹�‚ß‚é
126 // for (int i = 1; i < 4; i++)
127 // {
128 // float projA = _obj1.boxVertex[i].x * u.x + _obj1.boxVertex[i].y * u.y;
129 // if (projA < minA) { minA = projA; }
130 // else if (projA > maxA) { maxA = projA; }
131
132 // float projB = _obj2.boxVertex[i].x * u.x + _obj2.boxVertex[i].y * u.y;
133 // if (projB < minB) { minB = projB; }
134 // else if (projB > maxB) { maxB = projB; }
135 // }
136
137 // //‚à‚µŽË‰e‹æŠÔ‚ɃMƒƒƒbƒv‚ª‚ ‚ê‚Î�A�Փ˂͂Ȃ¢‚Æ”»’f‚µ�Afalse‚ð•Ô‚µ‚Ü‚·�B
138 // if (maxB < minA || maxA < minB)
139 // {
140 // return false;
141 // }
142 // }
143
144 // return true;
145 //
146 // }
147 //};
148
149
150
151
152
153
154
155}
図形�形状を表����クラスを�供�るヘッダ
AABBCollision2D(AABB< double > _aabb)
Definition Collision.hpp:52
AABB< double > aabb
Definition Collision.hpp:50
bool hit
Definition Collision.hpp:27
~Collision2DBase()
Definition Collision.hpp:34
Collision2DBase()
Definition Collision.hpp:29
Definition ComponentBase.hpp:24
Definition Accessor.hpp:110
軸平行境界ボックス
Definition Primitive.hpp:460