QSoftBody is a body type that defines deformable, soft objects in the physics world. Mass-spring model is used for simulation dynamics in soft bodies. In the mass-spring model, there are particles with mass that can move individually and interact with the physics world, and these particles can be connected to each other with spring constraints. Additionally, with some user-configurable options specific to the simulation, particles can be subjected to constraints obtained from some calculations. For example, you can add a constraint that ensures particles remain faithful to their initially defined local positions using the "shape matching" option. You can apply a constraint that gives the feeling that the polygon are filled with gas and maintains their area using the "area preserving" option. You can use options that allow particles to collide with each other with a specific radius, and create objects called PBD (Position Based Dynamics). QSoftBody objects inherently require a more flexible configuration than other body types and contain many options.
More...
#include <qsoftbody.h>
|
Public Types inherited from QBody |
enum | Modes { DYNAMIC
, STATIC
} |
|
enum | BodyTypes { RIGID
, AREA
, SOFT
} |
|
enum | SimulationModels { MASS_SPRING
, RIGID_BODY
} |
|
Public Attributes inherited from QBody |
std::function< void(QBody *body)> | PreStepEventListener |
|
std::function< void(QBody *body)> | StepEventListener |
|
std::function< bool(QBody *body, CollisionInfo)> | CollisionEventListener |
|
Protected Member Functions inherited from QBody |
void | UpdateAABB () |
|
void | UpdateMeshTransforms () |
|
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 |
QWorld * | world |
|
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 |
|
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 |
|
QSoftBody is a body type that defines deformable, soft objects in the physics world. Mass-spring model is used for simulation dynamics in soft bodies. In the mass-spring model, there are particles with mass that can move individually and interact with the physics world, and these particles can be connected to each other with spring constraints. Additionally, with some user-configurable options specific to the simulation, particles can be subjected to constraints obtained from some calculations. For example, you can add a constraint that ensures particles remain faithful to their initially defined local positions using the "shape matching" option. You can apply a constraint that gives the feeling that the polygon are filled with gas and maintains their area using the "area preserving" option. You can use options that allow particles to collide with each other with a specific radius, and create objects called PBD (Position Based Dynamics). QSoftBody objects inherently require a more flexible configuration than other body types and contain many options.
◆ ApplyShapeMatching()
void QSoftBody::ApplyShapeMatching |
( |
| ) |
|
Applies the shape matching operation to the body.
◆ GetAreaPreservingEnabled()
bool QSoftBody::GetAreaPreservingEnabled |
( |
| ) |
|
|
inline |
Returns whether the area preserving option is enabled of the body. If the area preserving option is enabled, the total area of the polygon are calculated at each physics step, and forces are applied to the particles that define the boundaries of the polygon to achieve a total area that can be determined by the user. If the user does not specify, when this option is enabled, the target area is calculated based on the original positions of the polygon particles, in other words, the total area of undeformed polygons are set as the target area.
◆ GetAreaPreservingRate()
float QSoftBody::GetAreaPreservingRate |
( |
| ) |
|
|
inline |
Returns the rate to apply area preserving to the body if the area preserving is enabled. Determines the rate of the target area to apply preserve constraints.
◆ GetAreaPreservingRigidity()
float QSoftBody::GetAreaPreservingRigidity |
( |
| ) |
|
|
inline |
Returns the rigidity to apply area preserving to the body if the area preserving is enabled. Determines the hardness of the restrictions to be applied to particles for the application of the target area.
◆ GetMass()
float QSoftBody::GetMass |
( |
| ) |
|
|
inlinevirtual |
Returns mass value of the body.
Reimplemented from QBody.
◆ GetParticleSpesificMass()
float QSoftBody::GetParticleSpesificMass |
( |
| ) |
|
|
inline |
Returns the particle-specific mass value of the body. This value is used if the particle-specific mass option is enabled.
◆ GetParticleSpesificMassEnabled()
bool QSoftBody::GetParticleSpesificMassEnabled |
( |
| ) |
|
|
inline |
Sets whether the particle-spesific mass option is enabled for the body. If this option is set to true, particles will continue to move with the mass defined for the body, but a specific mass value provided by you will be used for collision and constraint calculations. In most case, you don't want the mass value defined for the entire soft body object to be used for individual particle collision and constraint responses. Instead, you can define a specific particle mass value by dividing the mass value of the body by the number of particles, for example.
◆ GetPassivationOfInternalSpringsEnabled()
bool QSoftBody::GetPassivationOfInternalSpringsEnabled |
( |
| ) |
|
|
inline |
Returns whether to passivate the internal spring connections of the soft body. If this option is enabled, the internal springs are more passive in the simulation, which can be useful for soft bodies where the internal springs and particle connections only provide UV and other data based on the movement of the soft body.
◆ GetRigidity()
float QSoftBody::GetRigidity |
( |
| ) |
|
|
inline |
Returns the rigidity of the body. It determines the rigidity of the spring joints of the body.
◆ GetSelfCollisionsEnabled()
bool QSoftBody::GetSelfCollisionsEnabled |
( |
| ) |
|
|
inline |
Gets whether self collisions are enabled for the body. If set to true, all mesh parts within the body will collide with each other.
◆ GetSelfCollisionsSpecifiedRadius()
float QSoftBody::GetSelfCollisionsSpecifiedRadius |
( |
| ) |
|
|
inline |
Returns the specified particle radius value for self particle collisions. If the value is 0.0, particles will collide with their radius. Default value is 0.0.
◆ GetShapeMatchingEnabled()
bool QSoftBody::GetShapeMatchingEnabled |
( |
| ) |
|
|
inline |
Returns whether the shape matcing option is enabled for the body. If set to true, during the simulation process, all particles are forced to stay true to their undeformed positions.
◆ GetShapeMatchingFixedPosition()
QVector QSoftBody::GetShapeMatchingFixedPosition |
( |
| ) |
|
|
inline |
Sets the position of the target shape during shape matching if the fixed transform feature is active.
◆ GetShapeMatchingFixedRotation()
float QSoftBody::GetShapeMatchingFixedRotation |
( |
| ) |
|
|
inline |
Sets the rotation of the target shape during shape matching if the fixed transform feature is active.
◆ GetShapeMatchingFixedTransformEnabled()
bool QSoftBody::GetShapeMatchingFixedTransformEnabled |
( |
| ) |
|
|
inline |
Returns whether you will be able to determine the position and rotation of the target shape when the shape matching feature is active. If set to true, you will be able to adjust the position and rotation values of the target shape yourself.
◆ GetShapeMatchingRate()
float QSoftBody::GetShapeMatchingRate |
( |
| ) |
|
|
inline |
Returns the rate value to apply the shape matching to the body.
◆ GetTargetPreservationArea()
float QSoftBody::GetTargetPreservationArea |
( |
| ) |
|
|
inline |
Returns the total target area to apply area preserving if the area preserving is enabled.
◆ PostUpdate()
void QSoftBody::PostUpdate |
( |
| ) |
|
|
virtual |
Called after all bodies have completed their Update step to perform post-update operations.
Reimplemented from QBody.
◆ PreserveAreas()
void QSoftBody::PreserveAreas |
( |
| ) |
|
Applies the preserve area operation to the body.
◆ SetAreaPreservingEnabled()
QSoftBody* QSoftBody::SetAreaPreservingEnabled |
( |
bool |
value | ) |
|
|
inline |
Sets whether the area preserving option is enabled of the body. If the area preserving option is enabled, the total area of the polygon are calculated at each physics step, and forces are applied to the particles that define the boundaries of the polygon to achieve a total area that can be determined by the user. If the user does not specify, when this option is enabled, the target area is calculated based on the original positions of the polygon particles, in other words, the total area of undeformed polygons are set as the target area.
- Parameters
-
- Returns
- A pointer to the body itself.
◆ SetAreaPreservingRate()
QSoftBody* QSoftBody::SetAreaPreservingRate |
( |
float |
value | ) |
|
|
inline |
Sets the rate to apply area preserving to the body if the area preserving is enabled. Determines the rate of the target area to apply preserve constraints.
- Parameters
-
value | A value to set, it must be a value between 0.0 and 1.0. |
- Returns
- A pointer to the body itself.
◆ SetAreaPreservingRigidity()
QSoftBody* QSoftBody::SetAreaPreservingRigidity |
( |
float |
value | ) |
|
|
inline |
Sets the rigidity to apply area preserving to the body if the area preserving is enabled. Determines the hardness of the restrictions to be applied to particles for the application of the target area.
- Parameters
-
- Returns
- A pointer to the body itself.
◆ SetParticleSpesificMass()
QSoftBody* QSoftBody::SetParticleSpesificMass |
( |
float |
value | ) |
|
|
inline |
Sets the particle-specific mass value of the body. This value is used if the particle-specific mass option is enabled.
- Parameters
-
- Returns
- A pointer to the body itself.
◆ SetParticleSpesificMassEnabled()
QSoftBody* QSoftBody::SetParticleSpesificMassEnabled |
( |
bool |
value | ) |
|
|
inline |
Sets whether the particle-spesific mass option is enabled for the body. If this option is set to true, particles will continue to move with the mass defined for the body, but a specific mass value provided by you will be used for collision and constraint calculations. In most case, you don't want the mass value defined for the entire soft body object to be used for individual particle collision and constraint responses. Instead, you can define a specific particle mass value by dividing the mass value of the body by the number of particles, for example.
- Parameters
-
- Returns
- A pointer to the body itself.
◆ SetPassivationOfInternalSpringsEnabled()
QSoftBody* QSoftBody::SetPassivationOfInternalSpringsEnabled |
( |
bool |
value | ) |
|
|
inline |
Sets whether to passivate the internal spring connections of the soft body. If this option is enabled, the internal springs are more passive in the simulation, which can be useful for soft bodies where the internal springs and particle connections only provide UV and other data based on the movement of the soft body.
- Parameters
-
- Returns
- A pointer to the body itself.
◆ SetRigidity()
QSoftBody* QSoftBody::SetRigidity |
( |
float |
value | ) |
|
|
inline |
Sets the rigidity of the body. It determines the rigidity of the spring joints of the body.
- Parameters
-
- Returns
- A pointer to the body itself.
◆ SetSelfCollisionsEnabled()
QSoftBody* QSoftBody::SetSelfCollisionsEnabled |
( |
bool |
value | ) |
|
|
inline |
Sets whether self particle collisions are enabled for the body. If set to true, all mesh parts within the body will collide with each other.
- Parameters
-
- Returns
- A pointer to the body itself.
◆ SetSelfCollisionsSpecifiedRadius()
QSoftBody* QSoftBody::SetSelfCollisionsSpecifiedRadius |
( |
float |
value | ) |
|
|
inline |
Sets a specified particle radius value for self particle collisions. If set to 0, particles will collide with their radius. Default value is 0.
- Parameters
-
- Returns
- A pointer to the body itself.
◆ SetShapeMatchingEnabled()
QSoftBody* QSoftBody::SetShapeMatchingEnabled |
( |
bool |
value, |
|
|
bool |
withoutInternals = false |
|
) |
| |
|
inline |
Sets whether the shape matcing option is enabled for the body. If set to true, during the simulation process, all particles are forced to stay true to their undeformed positions.
- Parameters
-
value | A value to set. |
withoutInternals | Applies method without internal particles. |
- Returns
- A pointer to the body itself.
◆ SetShapeMatchingFixedPosition()
Sets the position of the target shape during shape matching if the fixed transform feature is active.
- Parameters
-
- Returns
- A pointer to the body itself.
◆ SetShapeMatchingFixedRotation()
QSoftBody* QSoftBody::SetShapeMatchingFixedRotation |
( |
float |
value | ) |
|
|
inline |
Sets the rotation value of the target shape during shape matching if the fixed transform feature is active.
- Parameters
-
- Returns
- A pointer to the body itself.
◆ SetShapeMatchingFixedTransformEnabled()
QSoftBody* QSoftBody::SetShapeMatchingFixedTransformEnabled |
( |
bool |
value | ) |
|
|
inline |
Sets whether you will be able to determine the position and rotation of the target shape when the shape matching feature is active. If set to true, you will be able to adjust the position and rotation values of the target shape yourself.
- Parameters
-
- Returns
- A pointer to the body itself.
◆ SetShapeMatchingRate()
QSoftBody* QSoftBody::SetShapeMatchingRate |
( |
float |
value | ) |
|
|
inline |
Sets the rate value to apply the shape matching to the body.
- Parameters
-
value | A value to set, it must be a value between 0.0 and 1.0. |
- Returns
- A pointer to the body itself.
◆ SetTargetPreservationArea()
QSoftBody* QSoftBody::SetTargetPreservationArea |
( |
float |
value | ) |
|
|
inline |
Sets the total target area to apply area preserving if the area preserving is enabled.
- Parameters
-
- Returns
- A pointer to the body itself.
◆ Update()
void QSoftBody::Update |
( |
| ) |
|
|
virtual |
Updates properties of the soft body and applies needed physical dynamics.
Reimplemented from QBody.
The documentation for this class was generated from the following files: