Jolt Physics
A multi core friendly Game Physics Engine
|
Base class for all physics constraints. A constraint removes one or more degrees of freedom for a rigid body. More...
#include <Constraint.h>
Protected Member Functions | |
void | ToConstraintSettings (ConstraintSettings &outSettings) const |
Helper function to copy settings back to constraint settings for this base class. | |
Protected Attributes | |
float | mDrawConstraintSize |
Size of constraint when drawing it through the debug renderer. | |
Protected Attributes inherited from RefTarget< Constraint > | |
atomic< uint32 > | mRefCount |
Current reference count. | |
Friends | |
class | ConstraintManager |
Additional Inherited Members | |
Static Public Member Functions inherited from RefTarget< Constraint > | |
static int | sInternalGetRefCountOffset () |
INTERNAL HELPER FUNCTION USED BY SERIALIZATION. | |
Static Protected Attributes inherited from RefTarget< Constraint > | |
static constexpr uint32 | cEmbedded |
A large value that gets added to the refcount to mark the object as embedded. | |
Base class for all physics constraints. A constraint removes one or more degrees of freedom for a rigid body.
|
inlineexplicit |
Constructor.
|
virtualdefault |
Virtual destructor.
|
pure virtual |
Link bodies that are connected by this constraint in the island builder.
Implemented in TwoBodyConstraint, and VehicleConstraint.
|
pure virtual |
Link bodies that are connected by this constraint in the same split. Returns the split index.
Implemented in TwoBodyConstraint, and VehicleConstraint.
|
pure virtual |
|
inlinevirtual |
Reimplemented in ConeConstraint, HingeConstraint, SixDOFConstraint, SliderConstraint, SwingTwistConstraint, and VehicleConstraint.
|
inlinevirtual |
Reimplemented in TwoBodyConstraint.
|
inline |
Priority of the constraint when solving. Higher numbers have are more likely to be solved correctly. Note that if you want a deterministic simulation and you cannot guarantee the order in which constraints are added/removed, you can make the priority for all constraints unique to get a deterministic ordering.
|
pure virtual |
Debug function to convert a constraint to its settings, note that this will not save to which bodies the constraint is connected to.
Implemented in ConeConstraint, DistanceConstraint, FixedConstraint, GearConstraint, HingeConstraint, PathConstraint, PointConstraint, PulleyConstraint, RackAndPinionConstraint, SixDOFConstraint, SliderConstraint, SwingTwistConstraint, and VehicleConstraint.
|
inline |
Size of constraint when drawing it through the debug renderer.
|
inline |
Test if a constraint is enabled.
|
inline |
|
inline |
|
pure virtual |
Get the sub type of a constraint.
Implemented in ConeConstraint, DistanceConstraint, FixedConstraint, GearConstraint, HingeConstraint, PathConstraint, PointConstraint, PulleyConstraint, RackAndPinionConstraint, SixDOFConstraint, SliderConstraint, SwingTwistConstraint, and VehicleConstraint.
|
inlinevirtual |
Get the type of a constraint.
Reimplemented in TwoBodyConstraint.
|
inline |
Access to the user data, can be used for anything by the application.
Reimplemented in PathConstraint, TwoBodyConstraint, and VehicleConstraint.
|
pure virtual |
Notify the constraint that the shape of a body has changed and that its center of mass has moved by inDeltaCOM. Bodies don't know which constraints are connected to them so the user is responsible for notifying the relevant constraints when a body changes.
inBodyID | ID of the body that has changed |
inDeltaCOM | The delta of the center of mass of the body (shape->GetCenterOfMass() - shape_before_change->GetCenterOfMass()) |
Implemented in ConeConstraint, DistanceConstraint, FixedConstraint, GearConstraint, HingeConstraint, PathConstraint, PointConstraint, PulleyConstraint, RackAndPinionConstraint, SixDOFConstraint, SliderConstraint, SwingTwistConstraint, and VehicleConstraint.
Notify the system that the configuration of the bodies and/or constraint has changed enough so that the warm start impulses should not be applied the next frame. You can use this function for example when repositioning a ragdoll through Ragdoll::SetPose in such a way that the orientation of the bodies completely changes so that the previous frame impulses are no longer a good approximation of what the impulses will be in the next frame. Calling this function when there are no big changes will result in the constraints being much 'softer' than usual so they are more easily violated (e.g. a long chain of bodies might sag a bit if you call this every frame).
Implemented in ConeConstraint, DistanceConstraint, FixedConstraint, GearConstraint, HingeConstraint, PathConstraint, PointConstraint, PulleyConstraint, RackAndPinionConstraint, SixDOFConstraint, SliderConstraint, SwingTwistConstraint, and VehicleConstraint.
|
virtual |
Restoring state for replay.
Reimplemented in ConeConstraint, DistanceConstraint, FixedConstraint, GearConstraint, HingeConstraint, PathConstraint, PointConstraint, PulleyConstraint, RackAndPinionConstraint, SixDOFConstraint, SliderConstraint, SwingTwistConstraint, and VehicleConstraint.
|
virtual |
Saving state for replay.
Reimplemented in ConeConstraint, DistanceConstraint, FixedConstraint, GearConstraint, HingeConstraint, PathConstraint, PointConstraint, PulleyConstraint, RackAndPinionConstraint, SixDOFConstraint, SliderConstraint, SwingTwistConstraint, and VehicleConstraint.
Enable / disable this constraint. This can e.g. be used to implement a breakable constraint by detecting that the constraint impulse (see e.g. PointConstraint::GetTotalLambdaPosition) went over a certain limit and then disabling the constraint. Note that although a disabled constraint will not affect the simulation in any way anymore, it does incur some processing overhead. Alternatively you can remove a constraint from the constraint manager (which may be more costly if you want to disable the constraint for a short while).
Used only when the constraint is active. Override for the number of solver position iterations to run, 0 means use the default in PhysicsSettings::mNumPositionSteps. The number of iterations to use is the max of all contacts and constraints in the island.
Used only when the constraint is active. Override for the number of solver velocity iterations to run, 0 means use the default in PhysicsSettings::mNumVelocitySteps. The number of iterations to use is the max of all contacts and constraints in the island.
|
protected |
Helper function to copy settings back to constraint settings for this base class.
|
friend |
|
protected |
Size of constraint when drawing it through the debug renderer.