Quark Physics  1.0
2D Rigid and Soft Body Physics Engine
qmanifold.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 #ifndef QMANIFOLD_H
29 #define QMANIFOLD_H
30 #include "qbody.h"
31 #include "qcollision.h"
35 class QManifold
36 {
37  QVector GetRelativeVelocity(QParticle *contactParticle,vector<QParticle*> referenceParticles, QVector rRef,QVector rInc);
38  QVector linearRelativeVelocity=QVector::Zero();
39 
40  //One time calculate properties
41  float restitution=0.0f;
42  float invMass;
43  bool isCollisionOneSide=false;
44 public:
45 
46 
52  QManifold(QBody *bodyA,QBody *bodyB);
53 
54  QBody *bodyA;
55  QBody *bodyB;
56 
58  vector<QCollision::Contact*> contacts;
59 
61  void Solve();
62 
65 
66 
67 };
68 
69 struct QManifoldKey{
70 public:
71  QManifoldKey(QBody *bA,QBody *bB){
72  if(bA<bB){
73  bodyA=bA;
74  bodyB=bB;
75  }else{
76  bodyA=bB;
77  bodyB=bA;
78  }
79  }
80  QBody *bodyA;
81  QBody *bodyB;
82 };
83 
84 inline bool operator <(const QManifoldKey& mk1,const QManifoldKey& mk2){
85  if(mk1.bodyA<mk2.bodyA){
86  return true;
87  }
88  if(mk1.bodyA==mk2.bodyA && mk1.bodyB<mk2.bodyB){
89  return true;
90  }
91  return false;
92 }
93 
94 #endif // QMANIFOLD_H
QBody objects are the base class for all types of bodies. Any class derived from QBody shares these m...
Definition: qbody.h:43
QManifold retrieves collision data from collision tests between two QBody objects using QCollision me...
Definition: qmanifold.h:36
void Solve()
Definition: qmanifold.cpp:108
void SolveFrictionAndVelocities()
Definition: qmanifold.cpp:274
vector< QCollision::Contact * > contacts
Definition: qmanifold.h:58
QManifold(QBody *bodyA, QBody *bodyB)
Definition: qmanifold.cpp:39
QParticle objects form the network structures of QMesh objects defined for all body object types....
Definition: qparticle.h:37
Definition: qmanifold.h:69
Definition: qvector.h:44