-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcollider.h
60 lines (47 loc) · 1.48 KB
/
collider.h
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
#pragma once
#include <glm/glm.hpp>
#include "aabb.h"
#include "transform.h"
enum class ColliderType {
NOCLIP, // collides with nothing, movement influenced purely by velocity and gravity
BASIC, // collides with statics, invisible to other types
TRIGGER, // collides with statics, checks TRIGGERs and FULLs without colliding
FULL // collides with statics, checks TRIGGERs and FULLs, collides against FULLs
};
// to be used in collision callbacks
// maybe just make collision callback except a simplified collider struct
// with a enum tag and position and stuff maybe
enum class Tag {
NONE,
PLAYER,
PLAYER_PROJECTILE,
ENEMY_PROJECTILE,
ENEMY,
EXPLOSION,
TERRAIN,
ITEM,
HEALER,
SWITCH,
BOSSBOY,
};
// Colliders represent dynamic physics objects
class Collider {
public:
Transform* transform; // id of transform this collider is changing position of
Tag tag;
ColliderType type;
glm::vec3 vel;
float gravityMultiplier = 1.0f;
bool grounded = false; // true if is standing on something flat
bool onTerrain = false; // true if standing on terrain
bool enabled = true; // true if should be apart of physics simulation
bool awake = true; // true if inside physics simulation area
Collider();
void setExtents(glm::vec3 min, glm::vec3 max);
AABB getAABB() const;
private:
glm::vec3 extmin;
glm::vec3 extmax;
glm::vec3 pos;
friend class Physics;
};