-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCollisionList.cpp
More file actions
70 lines (55 loc) · 1.44 KB
/
Copy pathCollisionList.cpp
File metadata and controls
70 lines (55 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "CollisionList.h"
#include "CollidableObject.h"
CollList::CollList()
: index(0)
, collCapacity(1000)
{
colVec.reserve(1000);
}
CollList::~CollList()
{
Init();
}
void CollList::Init()
{
colVec.clear();
colVec.resize(0);
index = 0;
}
void CollList::Reflesh()
{
}
void CollList::ResetPos()
{
index = 0;
}
void CollList::Write(ColliderShape *shape1, ColliderShape *shape2)
{
auto objA = shape1->GetColliderPtr()->_obj;
auto objB = shape2->GetColliderPtr()->_obj;
//自分の衝突判定オブジェクトと判定しそうになっていたら終了
if (shape1->GetColliderPtr() == shape2->GetColliderPtr())
return;
//衝突しないタイプどうしだったら判定しない
if (!CollidableObject::IsCollidablePair(objA->GetType(), objB->GetType()))
return;
//ユーザー定義の条件で衝突しない設定なら判定しない
if (!objA->IsCollidable(*objB)
|| !objB->IsCollidable(*objA))
return;
colVec.push_back(std::move(std::make_pair(shape1, shape2)));
index++;
}
void CollList::Sort()
{
using namespace std;
sort(colVec.begin(), colVec.end(),
[](const pair<ColliderShape *, ColliderShape *> &lPair,
const pair<ColliderShape *, ColliderShape *> &rPair)
{
return (lPair.second->GetCenter()._y > rPair.second->GetCenter()._y);
});
}
void CollList::Debug()
{
}