36 #include "qmanifold.h"
38 #include "qbroadphase.h"
39 #include "qcollision.h"
40 #include "qrigidbody.h"
41 #include "qsoftbody.h"
44 #include "qmath_utils.h"
59 vector <QJoint*> joints=vector<QJoint*>();
61 vector <QSpring*> springs=vector<QSpring*>();
63 vector<QRaycast*> raycasts=vector<QRaycast*>();
65 vector <QGizmo*> gizmos=vector<QGizmo*>();
67 vector<vector<QBody*> > sleepingIslands=vector<vector<QBody*> >();
71 vector<QManifold> manifolds;
82 bool enableSleeping=
true;
83 bool enableBroadphase=
true;
89 float sleepingPositionTolerance=0.1f;
90 float sleepingRotationTolerance=M_PI/180.0f;
93 int debugAABBTestCount=0;
94 int debugCollisionTestCount=0;
101 void CreateIslands(
int bodyIndex, vector<QBody*> &bodyList, vector<QBody*> &island, vector<bool> &visitedList);
102 void GenerateIslands(vector<QBody*> &bodyList, vector<vector<QBody*>> &islandList);
103 static bool SortBodiesHorizontal(
const QBody *bodyA,
const QBody *bodyB);
104 static bool SortBodiesVertical(
const QBody *bodyA,
const QBody *bodyB);
105 void GetCollisionPairs(vector<QBody *> &bodyList,vector<pair<QBody *, QBody *> > *resList);
107 void CreateIslands(
QBody &body, vector<QBody*> island);
108 vector<vector<QBody>> GenerateIslands(vector<QBody> bodyList );
111 void UpdateConstraints();
120 vector<QBody*> bodies=vector<QBody*>();
123 inline static float MAX_WORLD_SIZE=99999.0f;
136 return enableSleeping;
141 return sleepingPositionTolerance;
146 return sleepingRotationTolerance;
151 return enableBroadphase;
192 enableSleeping=value;
199 sleepingPositionTolerance=value;
206 sleepingRotationTolerance=value;
212 enableBroadphase=value;
221 broadPhase=externalBroadphase;
222 if (broadPhase!=
nullptr){
271 static vector<QCollision::Contact*> GetCollisions(
QBody *bodyA,
QBody *bodyB);
281 QWorld *AddBodyGroup(
const vector<QBody*> &bodyGroup);
290 QWorld *RemoveBodyAt(
int index);
294 return bodies.size();
300 return bodies[index];
308 for(
int i=0;i<bodies.size();i++){
320 vector<QBody*> GetBodiesHitByPoint(
QVector point,
int maxBodyCount=1,
bool onlyRigidBodies=
true,
int layersBit=-1);
328 vector<QParticle*> GetParticlesCloseToPoint(
QVector point,
float distance,
int maxParticleCount=1,
bool exceptRigidBodies=
true,
int layersBit=-1);
332 bool CollideWithWorld(
QBody *body);
337 vector<QManifold> TestCollisionWithWorld(
QBody *body);
352 QWorld *RemoveJointAt(
int index);
360 return joints.size();
366 return joints[index];
372 for(
int i=0;i<joints.size();i++)
391 QWorld *RemoveSpringAt(
int index);
403 return springs.size();
409 return springs[index];
415 for(
int i=0;i<springs.size();i++)
416 if(springs[i]==spring)
434 QWorld *RemoveRaycastAt(
int index);
438 return raycasts.size();
444 return raycasts[index];
450 for(
int i=0;i<raycasts.size();i++)
451 if(raycasts[i]==raycast)
477 QWorld *RemoveMatchingCollisionException(
QBody *body);
482 bool CheckCollisionException(
QBody *bodyA,
QBody *bodyB);
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
The QCollision class performs all collision detection operations. The relevant methods return contact...
Definition: qcollision.h:44
QJoint objects serves to apply various distance constraints between rigid bodies. Additionally,...
Definition: qjoint.h:37
QManifold retrieves collision data from collision tests between two QBody objects using QCollision me...
Definition: qmanifold.h:36
QParticle objects form the network structures of QMesh objects defined for all body object types....
Definition: qparticle.h:37
QRaycast objects send a ray into the world and return collision results with body objects....
Definition: qraycast.h:38
QSoftBody is a body type that defines deformable, soft objects in the physics world....
Definition: qsoftbody.h:35
You can apply distance constraints between 2 particles using the QSpring. The physics engine uses QSp...
Definition: qspring.h:39
A QWorld object is required to create a physics simulation. The QWorld class manages the entire physi...
Definition: qworld.h:51
bool GetEnabled()
Definition: qworld.h:175
QWorld * SetSleepingRotationTolerance(float value)
Definition: qworld.h:205
bool GetBroadphaseEnabled()
Definition: qworld.h:150
QWorld * SetSleepingPositionTolerance(float value)
Definition: qworld.h:198
QWorld * SetTimeScale(float value=1.0f)
Definition: qworld.h:242
QSpring * GetSpringAt(int index)
Definition: qworld.h:408
float GetTimeScale()
Definition: qworld.h:170
int GetBodyCount()
Definition: qworld.h:293
int GetBodyIndex(QBody *body)
Definition: qworld.h:305
int GetIterationCount()
Definition: qworld.h:165
int GetRaycastCount()
Definition: qworld.h:437
float GetSleepingPositionTolerance()
Definition: qworld.h:140
int GetJointCount()
Definition: qworld.h:359
bool GetSleepingEnabled()
Definition: qworld.h:135
QJoint * GetJointAt(int index)
Definition: qworld.h:365
QBody * GetBodyAt(int index)
Definition: qworld.h:299
int GetJointIndex(QJoint *joint)
Definition: qworld.h:371
QRaycast * GetRaycastAt(int index)
Definition: qworld.h:443
QWorld * SetBroadphaseEnabled(bool value)
Definition: qworld.h:211
QWorld * SetSleepingEnabled(bool value)
Definition: qworld.h:191
int GetSpringIndex(QSpring *spring)
Definition: qworld.h:414
QWorld * SetBroadphase(QBroadPhase *externalBroadphase)
Definition: qworld.h:220
QWorld * SetIterationCount(int value)
Definition: qworld.h:233
QWorld * SetGravity(QVector value)
Definition: qworld.h:184
vector< QGizmo * > * GetGizmos()
Definition: qworld.h:459
float GetSleepingRotationTolerance()
Definition: qworld.h:145
int GetRaycastIndex(QRaycast *raycast)
Definition: qworld.h:449
QWorld * SetEnabled(bool value)
Definition: qworld.h:250
QBroadPhase * GetBroadphase()
Definition: qworld.h:157
int GetSpringCount()
Definition: qworld.h:402