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

You can apply angle constraints between 3 particles using the QAngleConstraint. The physics engine uses QAngleConstraint to impose angle constraints between particles in objects already simulated using mass-spring models (e.g. QSoftBody objects). However, if the user wants, they can apply specific angle constraints between any 3 particles using QAngleConstraint. QWorld also provides methods to manage QAngleConstraint objects. More...

#include <qangleconstraint.h>

Public Member Functions

 QAngleConstraint (QParticle *particleA, QParticle *particleB, QParticle *particleC, float angleRange=0.1f)
 
 QAngleConstraint (QParticle *particleA, QParticle *particleB, QParticle *particleC, float minimumAngle, float maximumAngle)
 
virtual void Update (float specifiedRigidity=-1.0f, bool addToAccumulatedForces=false)
 
QParticleGetParticleA ()
 
QParticleGetParticleB ()
 
QParticleGetParticleC ()
 
float GetMinAngle ()
 
float GetMaxAngle ()
 
float GetRigidity ()
 
bool GetEnabled ()
 
float GetCurrentAngle ()
 
QAngleConstraintSetParticleA (QParticle *particle)
 
QAngleConstraintSetParticleB (QParticle *particle)
 
QAngleConstraintSetParticleC (QParticle *particle)
 
QAngleConstraintSetMinAngle (float value)
 
QAngleConstraintSetMaxAngle (float value)
 
QAngleConstraintSetRigidity (float rigidity)
 
QAngleConstraintSetEnabled (bool value)
 

Static Public Member Functions

static float GetAngleOfParticlesWithLocalPositions (QParticle *particleA, QParticle *particleB, QParticle *particleC)
 

Public Attributes

bool manualDeletion =false
 

Detailed Description

You can apply angle constraints between 3 particles using the QAngleConstraint. The physics engine uses QAngleConstraint to impose angle constraints between particles in objects already simulated using mass-spring models (e.g. QSoftBody objects). However, if the user wants, they can apply specific angle constraints between any 3 particles using QAngleConstraint. QWorld also provides methods to manage QAngleConstraint objects.

Warning
QAngleConstraint will not work correctly on objects that are not simulated with particle dynamics, such as rigid bodies whose positions are fixed by transformations. QAngleConstraint relies on the ability to change the positions of particles with freedom of movement to apply constraints correctly.

Constructor & Destructor Documentation

◆ QAngleConstraint() [1/2]

QAngleConstraint::QAngleConstraint ( QParticle particleA,
QParticle particleB,
QParticle particleC,
float  angleRange = 0.1f 
)

Creates an angle constraint between three particles. But auto calculates min-max angle with the local positions of the particles.

Parameters
particleAA particle in the world.
particleBAnother particle in the world.
particleCAnother particle in the world.

◆ QAngleConstraint() [2/2]

QAngleConstraint::QAngleConstraint ( QParticle particleA,
QParticle particleB,
QParticle particleC,
float  minimumAngle,
float  maximumAngle 
)

Creates an angle constraint between three particles.

Parameters
particleAA particle in the world.
particleBAnother particle in the world.
particleCAnother particle in the world.
minimumAngleThe min-angle between three particles.
maximumAngleThe max-angle between the three particles.

Member Function Documentation

◆ GetEnabled()

bool QAngleConstraint::GetEnabled ( )
inline

Returns whether the spring is enabled.

◆ GetMaxAngle()

float QAngleConstraint::GetMaxAngle ( )
inline

Returns the max-angle of the constraint

◆ GetMinAngle()

float QAngleConstraint::GetMinAngle ( )
inline

Returns the min-angle of the constraint.

◆ GetParticleA()

QParticle* QAngleConstraint::GetParticleA ( )
inline

Returns particleA of the angle constraint

◆ GetParticleB()

QParticle* QAngleConstraint::GetParticleB ( )
inline

Returns particleB of the angle constraint

◆ GetParticleC()

QParticle* QAngleConstraint::GetParticleC ( )
inline

Returns particleC of the angle constraint

◆ GetRigidity()

float QAngleConstraint::GetRigidity ( )
inline

Returns the rigidity of the angle constraint

◆ SetEnabled()

QAngleConstraint* QAngleConstraint::SetEnabled ( bool  value)
inline

Sets whether the angle constraint is enabled.

Parameters
valueTrue or false.
Returns
A pointer to the spring itself.

◆ SetMaxAngle()

QAngleConstraint* QAngleConstraint::SetMaxAngle ( float  value)
inline

Sets the max-angle of the constraint.

Parameters
valueThe angle to set.
Returns
A pointer to the spring itself.

◆ SetMinAngle()

QAngleConstraint* QAngleConstraint::SetMinAngle ( float  value)
inline

Sets the min-angle of the constraint.

Parameters
valueThe angle to set.
Returns
A pointer to the spring itself.

◆ SetParticleA()

QAngleConstraint* QAngleConstraint::SetParticleA ( QParticle particle)
inline

Sets particleA of the angle constraint.

Parameters
particleA pointer to the particle.
Returns
A pointer to the spring itself.

◆ SetParticleB()

QAngleConstraint* QAngleConstraint::SetParticleB ( QParticle particle)
inline

Sets particleB of the angle constraint.

Parameters
particleA pointer to the particle.
Returns
A pointer to the spring itself.

◆ SetParticleC()

QAngleConstraint* QAngleConstraint::SetParticleC ( QParticle particle)
inline

Sets particleC of the angle constraint.

Parameters
particleA pointer to the particle.
Returns
A pointer to the spring itself.

◆ SetRigidity()

QAngleConstraint* QAngleConstraint::SetRigidity ( float  rigidity)
inline

Sets the rigidity of the constraint.

Parameters
rigidityThe rigidity value to set.It must be a value between 0.0 and 1.0.
Returns
A pointer to the spring itself.

◆ Update()

void QAngleConstraint::Update ( float  specifiedRigidity = -1.0f,
bool  addToAccumulatedForces = false 
)
virtual

Applies angle constraints and updates particle positions.

Parameters
specifiedRigidityThis is the specific rigidity value that will be used instead of the current rigidity value of the constraint. By default, it is set to -1.0, which means it is disabled. It must be a value between 0.0 and 1.0. Otherwise, the original rigidity value defined for the constraint will be applied.
addToAccumulatedForcesThis property allows forces to be accumulated on particles for advanced purposes and then applies the average of these forces to the particle. If set to true, the necessary force for the constraint is not applied directly but is instead added to the particle's accumulated force collection. These properties are defined in the QParticle class and should only be used if you truly understand what you are doing."

Member Data Documentation

◆ manualDeletion

bool QAngleConstraint::manualDeletion =false

By default, objects included in the physics engine are deleted by the destructors of the objects they belong to. When this flag is enabled, it indicates that this object should never be deleted by this engine. It is disabled by default, and it is recommended to keep it disabled. However, it can be used if needed for advanced purposes and integrations.


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