Jolt Physics
A multi core friendly Game Physics Engine
|
Distance constraint settings, used to create a distance constraint. More...
#include <DistanceConstraint.h>
Public Member Functions | |
virtual void | SaveBinaryState (StreamOut &inStream) const override |
Saves the contents of the constraint settings in binary form to inStream. | |
virtual TwoBodyConstraint * | Create (Body &inBody1, Body &inBody2) const override |
Create an an instance of this constraint. | |
Public Member Functions inherited from SerializableObject | |
virtual | ~SerializableObject ()=default |
Constructor. | |
Public Member Functions inherited from RefTarget< ConstraintSettings > | |
RefTarget ()=default | |
Constructor. | |
RefTarget (const RefTarget &) | |
~RefTarget () | |
assert no one is referencing us | |
void | SetEmbedded () const |
RefTarget & | operator= (const RefTarget &) |
Assignment operator. | |
uint32 | GetRefCount () const |
Get current refcount of this object. | |
void | AddRef () const |
Add or release a reference to this object. | |
void | Release () const |
Public Attributes | |
EConstraintSpace | mSpace = EConstraintSpace::WorldSpace |
This determines in which space the constraint is setup, all properties below should be in the specified space. | |
RVec3 | mPoint1 = RVec3::sZero() |
RVec3 | mPoint2 = RVec3::sZero() |
Body 2 constraint reference frame (space determined by mSpace) | |
float | mMinDistance = -1.0f |
Ability to override the distance range at which the two points are kept apart. If the value is negative, it will be replaced by the distance between mPoint1 and mPoint2 (works only if mSpace is world space). | |
float | mMaxDistance = -1.0f |
float | mFrequency = 0.0f |
float | mDamping = 0.0f |
Public Attributes inherited from ConstraintSettings | |
bool | mEnabled = true |
If this constraint is enabled initially. Use Constraint::SetEnabled to toggle after creation. | |
int | mNumVelocityStepsOverride = 0 |
Override for the number of solver velocity iterations to run, the total amount of iterations is the max of PhysicsSettings::mNumVelocitySteps and this for all constraints in the island. | |
int | mNumPositionStepsOverride = 0 |
Override for the number of position velocity iterations to run, the total amount of iterations is the max of PhysicsSettings::mNumPositionSteps and this for all constraints in the island. | |
float | mDrawConstraintSize = 1.0f |
Size of constraint when drawing it through the debug renderer. | |
uint64 | mUserData = 0 |
User data value (can be used by application) | |
Protected Member Functions | |
virtual void | RestoreBinaryState (StreamIn &inStream) override |
This function should not be called directly, it is used by sRestoreFromBinaryState. | |
Additional Inherited Members | |
Public Types inherited from ConstraintSettings | |
using | ConstraintResult = Result<Ref<ConstraintSettings>> |
Static Public Member Functions inherited from ConstraintSettings | |
static ConstraintResult | sRestoreFromBinaryState (StreamIn &inStream) |
Creates a constraint of the correct type and restores its contents from the binary stream inStream. | |
Static Public Member Functions inherited from RefTarget< ConstraintSettings > | |
static int | sInternalGetRefCountOffset () |
INTERNAL HELPER FUNCTION USED BY SERIALIZATION. | |
Protected Attributes inherited from RefTarget< ConstraintSettings > | |
atomic< uint32 > | mRefCount |
Current reference count. | |
Static Protected Attributes inherited from RefTarget< ConstraintSettings > | |
static constexpr uint32 | cEmbedded |
A large value that gets added to the refcount to mark the object as embedded. | |
Distance constraint settings, used to create a distance constraint.
|
overridevirtual |
Create an an instance of this constraint.
Implements TwoBodyConstraintSettings.
|
overrideprotectedvirtual |
This function should not be called directly, it is used by sRestoreFromBinaryState.
Reimplemented from ConstraintSettings.
|
overridevirtual |
Saves the contents of the constraint settings in binary form to inStream.
Reimplemented from ConstraintSettings.
float DistanceConstraintSettings::mDamping = 0.0f |
float DistanceConstraintSettings::mFrequency = 0.0f |
If mFrequency > 0 the constraint will be soft and mFrequency specifies the oscillation frequency in Hz and mDamping the damping ratio (0 = no damping, 1 = critical damping). If mFrequency <= 0, mDamping is ignored and the distance constraint will have hard limits (as hard as the time step / the number of velocity / position solver steps allows). Note that if you set mDamping = 0, you will not get an infinite oscillation. Because we integrate physics using an explicit Euler scheme, there is always energy loss. This is done to keep the simulation from exploding, because with a damping of 0 and even the slightest rounding error, the oscillation could become bigger and bigger until the simluation explodes.
float DistanceConstraintSettings::mMaxDistance = -1.0f |
float DistanceConstraintSettings::mMinDistance = -1.0f |
Ability to override the distance range at which the two points are kept apart. If the value is negative, it will be replaced by the distance between mPoint1 and mPoint2 (works only if mSpace is world space).
RVec3 DistanceConstraintSettings::mPoint1 = RVec3::sZero() |
Body 1 constraint reference frame (space determined by mSpace). Constraint will keep mPoint1 (a point on body 1) and mPoint2 (a point on body 2) at the same distance. Note that this constraint can be used as a cheap PointConstraint by setting mPoint1 = mPoint2 (but this removes only 1 degree of freedom instead of 3).
RVec3 DistanceConstraintSettings::mPoint2 = RVec3::sZero() |
Body 2 constraint reference frame (space determined by mSpace)
EConstraintSpace DistanceConstraintSettings::mSpace = EConstraintSpace::WorldSpace |
This determines in which space the constraint is setup, all properties below should be in the specified space.