-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCollider.cpp
More file actions
35 lines (28 loc) · 718 Bytes
/
Collider.cpp
File metadata and controls
35 lines (28 loc) · 718 Bytes
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
#include "Collider.h"
#include "CollisionManager.h"
#include "CollidableObject.h"
Collider::Collider(ColliderShape *shape, Physicalbody *rigidbody, CollidableObject *obj)
: _physicalbody(rigidbody)
, _obj(obj)
{
if (shape == nullptr)
return;
SetShape(shape);
}
Collider::~Collider()
{
for (size_t i = 0; i < _shapes.size(); ++i)
{
COLLISION_MGR->RemoveObject(_shapes[i]);
if (_shapes[i] != nullptr)
delete _shapes[i];
if (_physicalbody != nullptr)
delete _physicalbody;
}
}
void Collider::SetShape(ColliderShape *shape)
{
_shapes.push_back(shape);
shape->SetCollider(this);
COLLISION_MGR->SetObjectToTree(shape);
}