Jolt Physics
A multi core friendly Game Physics Engine
|
#include <ConeConstraint.h>
Public Member Functions | |
JPH_OVERRIDE_NEW_DELETE | ConeConstraint (Body &inBody1, Body &inBody2, const ConeConstraintSettings &inSettings) |
Construct cone constraint. | |
virtual EConstraintSubType | GetSubType () const override |
Get the sub type of a constraint. | |
virtual void | NotifyShapeChanged (const BodyID &inBodyID, Vec3Arg inDeltaCOM) override |
virtual void | SetupVelocityConstraint (float inDeltaTime) override |
virtual void | ResetWarmStart () override |
virtual void | WarmStartVelocityConstraint (float inWarmStartImpulseRatio) override |
virtual bool | SolveVelocityConstraint (float inDeltaTime) override |
virtual bool | SolvePositionConstraint (float inDeltaTime, float inBaumgarte) override |
virtual void | DrawConstraint (DebugRenderer *inRenderer) const override |
virtual void | DrawConstraintLimits (DebugRenderer *inRenderer) const override |
virtual void | SaveState (StateRecorder &inStream) const override |
Saving state for replay. | |
virtual void | RestoreState (StateRecorder &inStream) override |
Restoring state for replay. | |
virtual Ref< ConstraintSettings > | GetConstraintSettings () const override |
Debug function to convert a constraint to its settings, note that this will not save to which bodies the constraint is connected to. | |
virtual Mat44 | GetConstraintToBody1Matrix () const override |
Calculates the transform that transforms from constraint space to body 1 space. The first column of the matrix is the primary constraint axis (e.g. the hinge axis / slider direction), second column the secondary etc. | |
virtual Mat44 | GetConstraintToBody2Matrix () const override |
Calculates the transform that transforms from constraint space to body 2 space. The first column of the matrix is the primary constraint axis (e.g. the hinge axis / slider direction), second column the secondary etc. | |
void | SetHalfConeAngle (float inHalfConeAngle) |
Update maximum angle between body 1 and 2 (see ConeConstraintSettings) | |
float | GetCosHalfConeAngle () const |
Public Member Functions inherited from TwoBodyConstraint | |
JPH_OVERRIDE_NEW_DELETE | TwoBodyConstraint (Body &inBody1, Body &inBody2, const TwoBodyConstraintSettings &inSettings) |
Constructor. | |
virtual EConstraintType | GetType () const override |
Get the type of a constraint. | |
virtual bool | IsActive () const override |
Solver interface. | |
virtual void | DrawConstraintReferenceFrame (DebugRenderer *inRenderer) const override |
Body * | GetBody1 () const |
Access to the connected bodies. | |
Body * | GetBody2 () const |
virtual void | BuildIslands (uint32 inConstraintIndex, IslandBuilder &ioBuilder, BodyManager &inBodyManager) override |
Link bodies that are connected by this constraint in the island builder. | |
virtual uint | BuildIslandSplits (LargeIslandSplitter &ioSplitter) const override |
Link bodies that are connected by this constraint in the same split. Returns the split index. | |
Public Member Functions inherited from Constraint | |
JPH_OVERRIDE_NEW_DELETE | Constraint (const ConstraintSettings &inSettings) |
Constructor. | |
virtual | ~Constraint ()=default |
Virtual destructor. | |
uint32 | GetConstraintPriority () const |
void | SetConstraintPriority (uint32 inPriority) |
void | SetNumVelocityStepsOverride (uint inN) |
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. | |
uint | GetNumVelocityStepsOverride () const |
void | SetNumPositionStepsOverride (uint inN) |
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. | |
uint | GetNumPositionStepsOverride () const |
void | SetEnabled (bool inEnabled) |
bool | GetEnabled () const |
Test if a constraint is enabled. | |
uint64 | GetUserData () const |
Access to the user data, can be used for anything by the application. | |
void | SetUserData (uint64 inUserData) |
float | GetDrawConstraintSize () const |
Size of constraint when drawing it through the debug renderer. | |
void | SetDrawConstraintSize (float inSize) |
Public Member Functions inherited from RefTarget< Constraint > | |
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 Member Functions inherited from NonCopyable | |
NonCopyable ()=default | |
NonCopyable (const NonCopyable &)=delete | |
void | operator= (const NonCopyable &)=delete |
Get Lagrange multiplier from last physics update (the linear/angular impulse applied to satisfy the constraint) | |
Vec3 | GetTotalLambdaPosition () const |
float | GetTotalLambdaRotation () const |
Additional Inherited Members | |
Static Public Member Functions inherited from RefTarget< Constraint > | |
static int | sInternalGetRefCountOffset () |
INTERNAL HELPER FUNCTION USED BY SERIALIZATION. | |
Protected Member Functions inherited from Constraint | |
void | ToConstraintSettings (ConstraintSettings &outSettings) const |
Helper function to copy settings back to constraint settings for this base class. | |
Protected Attributes inherited from TwoBodyConstraint | |
Body * | mBody1 |
The two bodies involved. | |
Body * | mBody2 |
Protected Attributes inherited from Constraint | |
float | mDrawConstraintSize |
Size of constraint when drawing it through the debug renderer. | |
Protected Attributes inherited from RefTarget< Constraint > | |
atomic< uint32 > | mRefCount |
Current reference count. | |
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. | |
A cone constraint constraints 2 bodies to a single point and limits the swing between the twist axis within a cone:
t1 . t2 <= cos(theta)
Where:
t1 = twist axis of body 1. t2 = twist axis of body 2. theta = half cone angle (angle from the principal axis of the cone to the edge).
Calculating the Jacobian:
Constraint equation:
C = t1 . t2 - cos(theta)
Derivative:
d/dt C = d/dt (t1 . t2) = (d/dt t1) . t2 + t1 . (d/dt t2) = (w1 x t1) . t2 + t1 . (w2 x t2) = (t1 x t2) . w1 + (t2 x t1) . w2
d/dt C = J v = [0, -t2 x t1, 0, t2 x t1] [v1, w1, v2, w2]
Where J is the Jacobian.
Note that this is the exact same equation as used in AngleConstraintPart if we use t2 x t1 as the world space axis
ConeConstraint::ConeConstraint | ( | Body & | inBody1, |
Body & | inBody2, | ||
const ConeConstraintSettings & | inSettings ) |
Construct cone constraint.
|
overridevirtual |
Implements Constraint.
|
overridevirtual |
Reimplemented from Constraint.
|
overridevirtual |
Debug function to convert a constraint to its settings, note that this will not save to which bodies the constraint is connected to.
Implements Constraint.
|
overridevirtual |
Calculates the transform that transforms from constraint space to body 1 space. The first column of the matrix is the primary constraint axis (e.g. the hinge axis / slider direction), second column the secondary etc.
Implements TwoBodyConstraint.
|
overridevirtual |
Calculates the transform that transforms from constraint space to body 2 space. The first column of the matrix is the primary constraint axis (e.g. the hinge axis / slider direction), second column the secondary etc.
Implements TwoBodyConstraint.
|
inline |
|
inlineoverridevirtual |
Get the sub type of a constraint.
Implements Constraint.
|
inline |
|
inline |
|
overridevirtual |
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()) |
Implements Constraint.
|
overridevirtual |
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).
Implements Constraint.
|
overridevirtual |
Restoring state for replay.
Reimplemented from Constraint.
|
overridevirtual |
Saving state for replay.
Reimplemented from Constraint.
Update maximum angle between body 1 and 2 (see ConeConstraintSettings)
Implements Constraint.
|
overridevirtual |
Implements Constraint.
Implements Constraint.
Implements Constraint.