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
10class d2Draw;
11
12typedef std::pair<d2Body*, d2Body*> ColliderPair;
13typedef std::list<ColliderPair> ColliderPairList;
14
16{
17public:
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
A class representing a 2D rigid body.
Definition d2Body.h:28
Definition d2Broadphase.h:16
virtual void Draw(const d2Draw &draw) const =0
virtual void Add(d2Body *body)=0
virtual ~d2Broadphase()=default
virtual d2Body * Pick(const d2Vec2 &point) const =0
virtual void Query(const d2AABB &aabb, ColliderList &output) const =0
virtual const ColliderPairList & ComputePairs(void)=0
virtual void Update(void)=0
std::vector< d2Body * > ColliderList
Definition d2Broadphase.h:39
virtual void Remove(d2Body *body)=0
Definition d2Draw.h:67
std::list< ColliderPair > ColliderPairList
Definition d2Broadphase.h:13
std::pair< d2Body *, d2Body * > ColliderPair
Definition d2Broadphase.h:12
Definition d2AABB.h:10
Represents a 2D vector.
Definition d2Math.h:22