-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColliders.h
More file actions
64 lines (52 loc) · 1.38 KB
/
Colliders.h
File metadata and controls
64 lines (52 loc) · 1.38 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
#pragma once
#include<glm/glm.hpp>
#include "glm/ext.hpp"
#include <iostream>
typedef struct Line {
glm::vec3 start;
glm::vec3 end;
inline Line() {}
inline Line(const glm::vec3& s, const glm::vec3& e) : start(s), end(e) { }
} Line;
class Plane
{
public:
Plane():m_normal(glm::vec3(0.0f,1.0f,0.0f)), m_distance(0.0f) { }
Plane(const glm::vec3 normal, float distance) :
m_normal(normal),
m_distance(distance)
{ }
Plane normalized() { return Plane(m_normal / glm::length(m_normal), m_distance / glm::length(m_normal)); }
inline const glm::vec3& getNormal() { return m_normal; }
inline float getDistance() { return m_distance; }
private:
glm::vec3 m_normal;
float m_distance;
};
class OBB
{
public:
OBB(const glm::vec3& position, const glm::mat3& orientation, const glm::vec3& size) :
m_position(position), m_orientation(orientation), m_size(size)
{}
const glm::vec3& getPosition() { return m_position; }
const glm::mat3& getOrientation() { return m_orientation; }
const glm::vec3& getSize() { return m_size; }
private:
glm::vec3 m_position;
glm::mat3 m_orientation;
glm::vec3 m_size;
};
class BoundingSphere
{
public:
BoundingSphere(const glm::vec3& center, float radius) :
m_center(center),
m_radius(radius)
{}
inline const glm::vec3& getCenter() { return m_center; }
inline float getRadius() { return m_radius; }
private:
glm::vec3 m_center;
float m_radius;
};