Quark Physics  1.0
2D Rigid and Soft Body Physics Engine
qbroadphase.h
1 
2 /************************************************************************************
3  * MIT License
4  *
5  * Copyright (c) 2023 Eray Zesen
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a copy
8  * of this software and associated documentation files (the "Software"), to deal
9  * in the Software without restriction, including without limitation the rights
10  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11  * copies of the Software, and to permit persons to whom the Software is
12  * furnished to do so, subject to the following conditions:
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  *
24  * https://github.com/erayzesen/QuarkPhysics
25  *
26 **************************************************************************************/
27 
28 
29 
30 
31 #ifndef QBROADPHASE_H
32 #define QBROADPHASE_H
33 
34 #include <unordered_map>
35 #include <unordered_set>
36 #include <vector>
37 #include "qaabb.h"
38 #include "qbody.h"
39 #include "qmanifold.h"
40 #include "qcollision.h"
41 
42 
43 
44 class QBroadPhase {
45 protected:
46  std::unordered_set<pair<QBody*, QBody*>,QBody::BodyPairHash,QBody::BodyPairEqual> pairs;
47  bool BodiesCanCollide(QBody * bodyA,QBody *bodyB){
48  return QBody::CanCollide(bodyA,bodyB);
49  }
50 
51 public:
52  vector<QBody*> &bodies;
53  QBroadPhase(vector<QBody*> &worldBodies): bodies(worldBodies){};
54  ~QBroadPhase(){};
55 
56 
57  virtual void Clear();
58 
59  virtual std::unordered_set<pair<QBody*, QBody*>,QBody::BodyPairHash,QBody::BodyPairEqual> &GetPairs();
60 
61  virtual void Insert(QBody* body);
62 
63  virtual void Remove(QBody* body);
64 
65 
66 };
67 
68 
69 #endif // QBROADPHASE_H
QBody objects are the base class for all types of bodies. Any class derived from QBody shares these m...
Definition: qbody.h:43
Definition: qbroadphase.h:44
Definition: qbody.h:76
Definition: qbody.h:68