Copperfield Engine 0.1
C++ Game Engine
Loading...
Searching...
No Matches
collisions.h
Go to the documentation of this file.
1
3#ifndef __COLLISIONS_H__
4#define __COLLISIONS_H__ 1
5
6#include "math/vector_2.h"
7#include "math/vector_3.h"
8#include "math/vector_4.h"
9
11enum Face { NONE,
12 FRONT,
13 BACK,
14 LEFT,
15 RIGHT,
16 TOP,
17 BOTTOM
18};
19
20struct BoxCmp;
21
22namespace coma {
24namespace cols {
30 const BoxCmp& other);
31
36bool collidesWith(const BoxCmp& me, const BoxCmp& other);
37
38class Circle {
39 public:
40 Circle();
41 Circle(float x, float y, float r);
42 Circle(Vec2 pos, float r);
43 Circle(float v[3]);
44 Circle(const Circle& o);
45 ~Circle();
46
47 void operator=(const Circle& o);
48
49 float radius;
50 Vec2 pos;
51};
52
53class Sphere {
54 public:
55 Sphere();
56 Sphere(float x, float y, float z, float r);
57 Sphere(Vec3 pos, float r);
58 Sphere(float v[4]);
59 Sphere(const Sphere& o);
60 ~Sphere();
61
62 void operator=(const Sphere& o);
63
64 float radius;
65 Vec3 pos;
66};
67
68class Rect2 {
69 Rect2();
70 Rect2(float x, float y, float w, float h);
71 Rect2(float a[4]);
72 Rect2(const Vec4& a);
73 Rect2(const Vec2& pos, const Vec2& size);
74 Rect2(const Rect2& o);
75 ~Rect2();
76
77 float r[4];
78};
79
80class Rect3 {
81 Rect3();
82 Rect3(float x, float y, float z, float w, float h, float d);
83 Rect3(float a[6]);
84 Rect3(const Vec3& pos, const Vec3& size);
85 Rect3(const Rect3& o);
86 ~Rect3();
87
88 float r[6];
89};
90
91class Obb2 {};
92class Obb3 {};
93
94// 2d
95bool Check(Circle c, Vec2 p);
96bool Check(Rect2 r, Vec2 p);
97bool Check(Obb2 o, Vec2 p);
98
99bool Check(Circle c1, Circle c2);
100bool Check(Rect2 r, Circle c);
101bool Check(Obb2 o, Circle c);
102
103bool Check(Rect2 r1, Rect2 r2);
104bool Check(Obb2 o, Rect2 r);
105
106bool Check(Obb2 o1, Obb2 o2);
107
108// 3d
109bool Check(Sphere s, Vec3 p);
110bool Check(Rect3 r, Vec3 p);
111bool Check(Obb3 o, Vec3 p);
112
113bool Check(Sphere s1, Sphere s2);
114bool Check(Rect3 r, Sphere s);
115bool Check(Obb3 o, Sphere s);
116
117bool Check(Rect3 r1, Rect3 r2);
118bool Check(Obb3 o, Rect3 r);
119
120bool Check(Obb3 o1, Obb3 o2);
121
122} // namespace cols
123} // namespace coma
124
125#endif
represents mathematical vector with 2 components
Definition: vector_2.h:7
represents mathematical vector with 3 components
Definition: vector_3.h:12
Face
The faces of a cube colision.
Definition: collisions.h:11
Face detectFaceCollision(const BoxCmp &me, const BoxCmp &other)
If two objects are colliding return the face of the box with which it collides.
bool collidesWith(const BoxCmp &me, const BoxCmp &other)
Detect if the BoxCmp are colliding.
copperdielf Math Library
Definition: buffer.hpp:5
Component used to detect collisions.
Definition: default_components.hpp:337