Dura2D
v0.1.0
An educational 2D game physics library
Loading...
Searching...
No Matches
d2Broadphase.h
Go to the documentation of this file.
1
#ifndef DURA2D_D2BROADPHASE_H
2
#define DURA2D_D2BROADPHASE_H
3
4
#include <memory>
5
#include <utility>
6
#include <list>
7
8
#include "
dura2d/d2Body.h
"
9
10
class
d2Draw
;
11
12
typedef
std::pair<d2Body*, d2Body*>
ColliderPair
;
13
typedef
std::list<ColliderPair>
ColliderPairList
;
14
15
class
d2Broadphase
16
{
17
public
:
18
19
virtual
~d2Broadphase
() =
default
;
20
21
// adds a new d2AABB to the broadphase
22
virtual
void
Add
(
d2Body
* body) = 0;
23
24
// removes a d2AABB from the broadphase
25
virtual
void
Remove
(
d2Body
* body) = 0;
26
27
// updates broadphase to react to changes to d2AABB
28
virtual
void
Update
(
void
) = 0;
29
30
// returns a list of possibly colliding colliders
31
virtual
const
ColliderPairList
&
ComputePairs
(
void
) = 0;
32
33
// returns a collider that collides with a point
34
// returns null if no such collider exists
35
virtual
d2Body
*
Pick
(
const
d2Vec2
&point)
const
= 0;
36
37
// returns a list of colliders whose AABBs collide
38
// with a query d2AABB
39
typedef
std::vector<d2Body *>
ColliderList
;
40
virtual
void
Query
(
const
d2AABB
&aabb,
ColliderList
&output)
const
= 0;
41
42
virtual
void
Draw
(
const
d2Draw
&draw)
const
= 0;
43
};
44
45
46
#endif
//DURA2D_D2BROADPHASE_H
d2Body
A class representing a 2D rigid body.
Definition
d2Body.h:28
d2Broadphase
Definition
d2Broadphase.h:16
d2Broadphase::Draw
virtual void Draw(const d2Draw &draw) const =0
d2Broadphase::Add
virtual void Add(d2Body *body)=0
d2Broadphase::~d2Broadphase
virtual ~d2Broadphase()=default
d2Broadphase::Pick
virtual d2Body * Pick(const d2Vec2 &point) const =0
d2Broadphase::Query
virtual void Query(const d2AABB &aabb, ColliderList &output) const =0
d2Broadphase::ComputePairs
virtual const ColliderPairList & ComputePairs(void)=0
d2Broadphase::Update
virtual void Update(void)=0
d2Broadphase::ColliderList
std::vector< d2Body * > ColliderList
Definition
d2Broadphase.h:39
d2Broadphase::Remove
virtual void Remove(d2Body *body)=0
d2Draw
Definition
d2Draw.h:67
d2Body.h
ColliderPairList
std::list< ColliderPair > ColliderPairList
Definition
d2Broadphase.h:13
ColliderPair
std::pair< d2Body *, d2Body * > ColliderPair
Definition
d2Broadphase.h:12
d2AABB
Definition
d2AABB.h:10
d2Vec2
Represents a 2D vector.
Definition
d2Math.h:22
dura2d
d2Broadphase.h
Generated by
1.12.0