Dura2D  v0.1.0
An educational 2D game physics library
Loading...
Searching...
No Matches
d2NSquaredBroad.h
Go to the documentation of this file.
1#ifndef DURA2D_D2NSQUAREDBROAD_H
2#define DURA2D_D2NSQUAREDBROAD_H
3
5
7{
8public:
9 // adds a new d2AABB to the broadphase
10 void Add(d2Body* body) override;
11
12 // removes a d2AABB from the broadphase
13 void Remove(d2Body* body) override;
14
15 // updates broadphase to react to changes to d2AABB
16 void Update(void) override;
17
18 // returns a list of possibly colliding colliders
19 const ColliderPairList &ComputePairs(void) override;
20
21 // returns a collider that collides with a point
22 // returns null if no such collider exists
23 d2Body *Pick(const d2Vec2 &point) const override;
24
25 // returns a list of colliders whose AABBs collide
26 // with a query d2AABB
27 typedef std::vector<d2Body *> ColliderList;
28 void Query(const d2AABB &aabb, ColliderList &output) const override;
29
30private:
31 std::vector<d2Body *> bodies{};
32 ColliderPairList m_pairs{};
33};
34
35#endif //DURA2D_D2NSQUAREDBROAD_H
A class representing a 2D rigid body.
Definition d2Body.h:28
Definition d2Broadphase.h:16
Definition d2NSquaredBroad.h:7
d2Body * Pick(const d2Vec2 &point) const override
std::vector< d2Body * > ColliderList
Definition d2NSquaredBroad.h:27
void Remove(d2Body *body) override
void Update(void) override
const ColliderPairList & ComputePairs(void) override
void Query(const d2AABB &aabb, ColliderList &output) const override
void Add(d2Body *body) override
std::list< ColliderPair > ColliderPairList
Definition d2Broadphase.h:13
Definition d2AABB.h:10
Represents a 2D vector.
Definition d2Math.h:22