Quark Physics  1.0
2D Rigid and Soft Body Physics Engine
QAreaBody Class Reference

QAreaBody objects are objects that don't respond to collisions or receive any response from them, but only report collisions. An operation is not applied for them to move during physics steps, they are stationary. Unlike other body types, they have two event listeners named OnCollisionEnter and OnCollisionExit. More...

#include <qareabody.h>

Inheritance diagram for QAreaBody:
Collaboration diagram for QAreaBody:

Public Member Functions

virtual void OnCollisionEnter (QBody *collidedBody)
 
virtual void OnCollisionExit (QBody *collidedBody)
 
bool GetGravityFreeEnabled ()
 
QVector GetLinearForceToApply ()
 
QAreaBodySetGravityFreeEnabled (bool value)
 
QAreaBodySetLinearForceToApply (QVector value)
 
- Public Member Functions inherited from QBody
virtual void OnPreStep ()
 
virtual void OnStep ()
 
virtual bool OnCollision (CollisionInfo)
 
BodyTypes GetBodyType ()
 
QWorldGetWorld ()
 
QVector GetPosition ()
 
QVector GetPreviousPosition ()
 
float GetRotation ()
 
float GetRotationDegree ()
 
float GetPreviousRotation ()
 
QAABB GetAABB () const
 
float GetTotalInitialArea ()
 
float GetTotalPolygonsInitialArea ()
 
float GetTotalArea ()
 
float GetTotalPolygonsArea ()
 
Modes GetMode ()
 
float GetInertia ()
 
int GetLayersBit ()
 
int GetCollidableLayersBit ()
 
bool GetOverlapWithCollidableLayersBit (int layersBit)
 
bool GetOverlapWithLayersBit (int layersBit)
 
bool GetIsSleeping ()
 
bool GetCanSleep ()
 
SimulationModels GetSimulationModel ()
 
float GetFriction ()
 
float GetStaticFriction ()
 
float GetAirFriction ()
 
virtual float GetMass ()
 
float GetRestitution ()
 
float GetCircumference ()
 
bool GetBodySpecificTimeScaleEnabled ()
 
float GetBodySpesificTimeScale ()
 
bool GetEnabled ()
 
float GetVelocityLimit ()
 
bool GetIntegratedVelocitiesEnabled ()
 
bool GetCustomGravityEnabled ()
 
QVector GetCustomGravity ()
 
QBodySetPosition (QVector value, bool withPreviousPosition=true)
 
QBodyAddPosition (QVector value, bool withPreviousPosition=true)
 
virtual QBodyApplyForce (QVector value)
 
QBodySetPreviousPosition (QVector value)
 
QBodyAddPreviousPosition (QVector value)
 
QBodySetRotation (float angleRadian, bool withPreviousRotation=true)
 
QBodySetRotationDegree (float degree, bool withPreviousRotation=true)
 
QBodyAddRotation (float angleRadian, bool withPreviousRotation=true)
 
QBodySetPreviousRotation (float angleRadian)
 
QBodyAddPreviousRotation (float angleRadian)
 
QBodySetLayersBit (int value)
 
QBodySetCollidableLayersBit (int value)
 
QBodySetCanSleep (bool value)
 
QBodySetMode (QBody::Modes bodyMode)
 
QBodySetSimulationModel (SimulationModels model)
 
QBodySetFriction (float value)
 
QBodySetStaticFriction (float value)
 
QBodySetAirFriction (float value)
 
QBodySetMass (float value)
 
QBodySetRestitution (float value)
 
QBodySetBodySpecificTimeScaleEnabled (bool value)
 
QBodySetBodySpecificTimeScale (float value)
 
QBodySetEnabled (bool value)
 
QBodySetIntegratedVelocitiesEnabled (bool value)
 
QBodySetCustomGravityEnabled (bool value)
 
QBodySetCustomGravity (QVector value)
 
QBodyAddMesh (QMesh *mesh)
 
QBodyRemoveMeshAt (int index)
 
QMeshGetMeshAt (int index)
 
int GetMeshCount ()
 
vector< QMesh * > * GetMeshes ()
 
QBodyAddMeshesFromFile (string filePath)
 
QBodyWakeUp ()
 
QBodySetVelocityLimit (float value)
 

Public Attributes

std::function< void(QAreaBody *areaBody, QBody *collidedBody)> CollisionEnterEventListener
 
std::function< void(QAreaBody *areaBody, QBody *collidedBody)> CollisionExitEventListener
 
- Public Attributes inherited from QBody
std::function< void(QBody *body)> PreStepEventListener
 
std::function< void(QBody *body)> StepEventListener
 
std::function< bool(QBody *body, CollisionInfo)> CollisionEventListener
 
bool manualDeletion =false
 

Friends

class QManifold
 
class QWorld
 

Additional Inherited Members

- Public Types inherited from QBody
enum  Modes { DYNAMIC , STATIC }
 
enum  BodyTypes { RIGID , AREA , SOFT }
 
enum  SimulationModels { MASS_SPRING , RIGID_BODY }
 
- Protected Member Functions inherited from QBody
void UpdateAABB ()
 
void UpdateMeshTransforms ()
 
virtual void Update ()
 
virtual void PostUpdate ()
 
virtual bool CanGiveCollisionResponseTo (QBody *otherBody)
 
- Static Protected Member Functions inherited from QBody
static QVector ComputeFriction (QBody *bodyA, QBody *bodyB, QVector &normal, float penetration, QVector &relativeVelocity)
 
static bool CanCollide (QBody *bodyA, QBody *bodyB, bool checkBodiesAreEnabled=true)
 
- Protected Attributes inherited from QBody
QWorldworld
 
QVector position =QVector(0,0)
 
QVector prevPosition =QVector::Zero()
 
float rotation =0.0f
 
float prevRotation =0.0f
 
QAABB aabb
 
Modes mode =QBody::Modes::DYNAMIC
 
bool inertiaNeedsUpdate =true
 
bool circumferenceNeedsUpdate =true
 
bool enableBodySpecificTimeScale =false
 
float bodySpecificTimeScale =1.0f
 
BodyTypes bodyType =BodyTypes::RIGID
 
bool enabled =true
 
float velocityLimit =0.0f
 
bool enableIntegratedVelocities =true
 
bool enableCustomGravity =false
 
QVector customGravity =QVector::Zero()
 
float friction =0.2f
 
float staticFriction =0.5f
 
float airFriction =0.01f
 
float mass =1.0f
 
float restitution =0.0f
 
int layersBit =1
 
int collidableLayersBit =1
 
bool isKinematic =false
 
bool allowKinematicCollisions =false
 
bool isSleeping =false
 
int sleepTick =120
 
int fixedVelocityTick =0
 
int fixedAngularTick =0
 
bool canSleep =true
 
vector< QMesh * > _meshes =vector<QMesh*>()
 
SimulationModels simulationModel =SimulationModels::RIGID_BODY
 
bool ignoreGravity =false
 

Detailed Description

QAreaBody objects are objects that don't respond to collisions or receive any response from them, but only report collisions. An operation is not applied for them to move during physics steps, they are stationary. Unlike other body types, they have two event listeners named OnCollisionEnter and OnCollisionExit.

Member Function Documentation

◆ GetGravityFreeEnabled()

bool QAreaBody::GetGravityFreeEnabled ( )
inline

Returns whether the option to exempt objects entering the area from gravity is enabled. If enabled, it will disable both the globally defined gravity and the body-specific gravity applied to physics bodies entering the area.

◆ GetLinearForceToApply()

QVector QAreaBody::GetLinearForceToApply ( )
inline

Returns the amount of linear force to be applied to objects entering the area. If a force vector is defined, objects entering the area will be continuously subjected to this force.

◆ OnCollisionEnter()

virtual void QAreaBody::OnCollisionEnter ( QBody collidedBody)
inlinevirtual

This event listener is triggered when any object enters the collision list of a QAreaBody for the first time.

Parameters
collidedBodyThe body entered to the collision list.

◆ OnCollisionExit()

virtual void QAreaBody::OnCollisionExit ( QBody collidedBody)
inlinevirtual

This event listener is triggered when any object exits the collision list of a QAreaBody for the first time.

Parameters
collidedBodyThe body exited from the collision list.

◆ SetGravityFreeEnabled()

QAreaBody* QAreaBody::SetGravityFreeEnabled ( bool  value)
inline

Sets whether the option to exempt objects entering the area from gravity is enabled. If enabled, it will disable both the globally defined gravity and the body-specific gravity applied to physics bodies entering the area.

Parameters
valueA bool vector to set
Returns
A pointer to the body itself.

◆ SetLinearForceToApply()

QAreaBody* QAreaBody::SetLinearForceToApply ( QVector  value)
inline

Sets the amount of linear force to be applied to objects entering the area. If a force vector is defined, objects entering the area will be continuously subjected to this force.

Parameters
valueA force vector to set.
Returns
A pointer to the body itself.

Member Data Documentation

◆ CollisionEnterEventListener

std::function<void(QAreaBody *areaBody,QBody* collidedBody)> QAreaBody::CollisionEnterEventListener

This is the event listener callback function for the OnCollisionEnter event.

Parameters
areaBodyAn area body.
collidedBodyThe collided body.

◆ CollisionExitEventListener

std::function<void(QAreaBody *areaBody,QBody* collidedBody)> QAreaBody::CollisionExitEventListener

This is the event listener callback function for the OnCollisionExit event.

Parameters
areaBodyAn area body.
collidedBodyThe collided body.

The documentation for this class was generated from the following files: