|
SuperDex Physics C++ API
|
Represents a constraint that restricts the degrees of freedom of one or more actors. More...
#include <mochi_constraint.h>
Public Member Functions | |
| virtual void | CancelQuery (QueryHandle handle)=0 |
| Cancel a previously registered query. | |
| virtual Actor const * | GetActor (int actorIndex) const =0 |
| Get read-only access to one of the actors affected by this constraint. | |
| virtual Actor * | GetActor (int actorIndex)=0 |
| Get one of the actors affected by this constraint. | |
| virtual real | GetDamping () const =0 |
| Get the constraint's damping parameter. | |
| virtual DynamicArray< real > | GetDeviation () const =0 |
| Compute the constraint's current deviation from its target, limits, or coupling condition. | |
| virtual Span< int const > | GetDofIndicesForActor (int actorIndex) const =0 |
| Get the degrees of freedom (DoF) indices affected by this constraint on a specific actor. | |
| virtual Span< real const > | GetForce (Error &error) const =0 |
| Get the force/torque applied by the constraint. | |
| virtual ConstraintHandle | GetHandle () const =0 |
| Get the handle associated with this constraint. | |
| virtual Span< real const > | GetLimitMaxValues (Error &error) const =0 |
| Get the constraint's maximum limit values. | |
| virtual Span< real const > | GetLimitMinValues (Error &error) const =0 |
| Get the constraint's minimum limit values. | |
| virtual int | GetNumActors () const =0 |
| Get the number of actors affected by the constraint. | |
| virtual real | GetSaturation () const =0 |
| Get the constraint's saturation parameter. | |
| virtual real | GetStiffness () const =0 |
| Get the constraint's stiffness parameter. | |
| virtual ConstraintType | GetType () const =0 |
| Get the type of the constraint. | |
| virtual bool | IsQuerySupported (QueryType type) const =0 |
| Check whether a query type is supported for this constraint. | |
| virtual QueryHandle | RegisterQuery (QueryType type, Error &error)=0 |
| Register a query to compute data for this constraint. | |
| virtual void | SetDamping (real damping, Error &error)=0 |
| Set the constraint's damping parameter. | |
| virtual void | SetRefRelativeRotation (Quaternion const &rotationA, Quaternion const &rotationB, Error &error)=0 |
| Set a relative-rotation target from two rotations expressed in a common frame. | |
| virtual void | SetSaturation (real saturation, Error &error)=0 |
| Set the constraint's saturation parameter. | |
| virtual void | SetStiffness (real stiffness, Error &error)=0 |
| Set the constraint's stiffness parameter. | |
| virtual void | SetTargetDof (real target, Error &error)=0 |
| Set the constraint's target DoF. | |
| virtual void | SetTargetPosition (Real3 const &position, Error &error)=0 |
| Set the constraint's target position in world frame. | |
| virtual void | SetTargetRotation (Quaternion const &rotation, Error &error)=0 |
| Set the constraint's target rotation. | |
| virtual void | UpdateOldTarget (Error &error)=0 |
| Update the old target to match the current target. | |
Protected Member Functions | |
| virtual | ~Constraint ()=default |
Represents a constraint that restricts the degrees of freedom of one or more actors.
Constraints enforce relationships between actor degrees of freedom (DoFs), such as fixing positions, limiting joint angles, or tracking target poses. They apply forces to maintain desired configurations using spring-damper mechanics controlled by stiffness and damping parameters.
Definition at line 39 of file mochi_constraint.h.
|
protectedvirtualdefault |
|
pure virtual |
Cancel a previously registered query.
| [in] | handle | QueryHandle from a previous RegisterQuery call. |
|
nodiscardpure virtual |
Get read-only access to one of the actors affected by this constraint.
| [in] | actorIndex | Actor index in the range [0, GetNumActors). |
|
nodiscardpure virtual |
Get one of the actors affected by this constraint.
| [in] | actorIndex | Actor index in the range [0, GetNumActors). |
|
nodiscardpure virtual |
Get the constraint's damping parameter.
|
nodiscardpure virtual |
Compute the constraint's current deviation from its target, limits, or coupling condition.
|
nodiscardpure virtual |
Get the degrees of freedom (DoF) indices affected by this constraint on a specific actor.
| [in] | actorIndex | Actor index in the range [0, GetNumActors). |
|
nodiscardpure virtual |
Get the force/torque applied by the constraint.
Values are ordered first by actor (in the order returned by GetActor), then by DoF within each actor (in the order returned by GetDofIndicesForActor). Each entry has units conjugate to its DoF: [N] for translational DoFs and [N·m] for rotational DoFs (so a single returned vector may mix both, e.g. for ConstraintType::RigidPivotPosition the 6 entries are 3 force [N] followed by 3 torque [N·m] components on the rigid actor).
| [in,out] | error | Error status. Check Error::IsOK for success. |
|
nodiscardpure virtual |
Get the handle associated with this constraint.
|
nodiscardpure virtual |
Get the constraint's maximum limit values.
| [in,out] | error | Error status. Check Error::IsOK for success. |
|
nodiscardpure virtual |
Get the constraint's minimum limit values.
| [in,out] | error | Error status. Check Error::IsOK for success. |
|
nodiscardpure virtual |
Get the number of actors affected by the constraint.
|
nodiscardpure virtual |
Get the constraint's saturation parameter.
|
nodiscardpure virtual |
Get the constraint's stiffness parameter.
|
nodiscardpure virtual |
Get the type of the constraint.
|
nodiscardpure virtual |
Check whether a query type is supported for this constraint.
| [in] | type | Type of query to check. |
|
pure virtual |
Register a query to compute data for this constraint.
| [in] | type | Type of query to register. |
| [in,out] | error | Error status. Check Error::IsOK for success. |
Set the constraint's damping parameter.
| [in] | damping | Damping value. [N·s/m] for translation constraints, [N·m·s/rad] for rotation constraints. Must be non-negative and finite. |
| [in,out] | error | Error status. Check Error::IsOK for success. |
|
pure virtual |
Set a relative-rotation target from two rotations expressed in a common frame.
Sets the target to inverse(rotationA) * rotationB.
| [in] | rotationA | First rotation. Represents JointRotationTrackingConstraintParams::actorA for ConstraintType::JointRotationTracking and the rigid actor for ConstraintType::RodElementRotationToRigid. Must be finite and non-zero. Normalized before use. |
| [in] | rotationB | Second rotation. Represents JointRotationTrackingConstraintParams::actorB for ConstraintType::JointRotationTracking and the selected rod element for ConstraintType::RodElementRotationToRigid. Must be finite and non-zero. Normalized before use. |
| [in,out] | error | Error status. Check Error::IsOK for success. |
Set the constraint's saturation parameter.
| [in] | saturation | Saturation distance [m] for translation constraints or angle [rad] for rotation constraints, or any negative value to disable saturation. Must be finite and non-zero. |
| [in,out] | error | Error status. Check Error::IsOK for success. |
Set the constraint's stiffness parameter.
| [in] | stiffness | Stiffness value. [N/m] for translation constraints, [N·m/rad] for rotation constraints. Must be non-negative and finite. |
| [in,out] | error | Error status. Check Error::IsOK for success. |
Set the constraint's target DoF.
| [in] | target | Target DoF value. Units: [m] for translation DoFs, [rad] for rotation DoFs. |
| [in,out] | error | Error status. Check Error::IsOK for success. |
|
pure virtual |
Set the constraint's target position in world frame.
| [in] | position | Target position [m] in world frame. Must be finite. |
| [in,out] | error | Error status. Check Error::IsOK for success. |
|
pure virtual |
Set the constraint's target rotation.
The target is interpreted according to the constraint type. For ConstraintType::RigidPivotRotation, it is the target pivot-frame rotation in world coordinates. For ConstraintType::RigidPivotToRigidTarget, it is the rotation of the target center-of-mass transform in world coordinates. For ConstraintType::Articulated3dRotationTarget, it is the target joint-local rotation. For ConstraintType::JointRotationTracking, it is the target rotation of JointRotationTrackingConstraintParams::actorB relative to JointRotationTrackingConstraintParams::actorA. For ConstraintType::RodElementRotationToRigid, it is the target rotation of the constrained rod element relative to the rigid actor.
| [in] | rotation | Target rotation quaternion [x, y, z, w]. Must be finite and non-zero. Normalized before use. |
| [in,out] | error | Error status. Check Error::IsOK for success. |
|
pure virtual |
Update the old target to match the current target.
Call this method after changing a target discontinuously, and before stepping the scene, to prevent that change from contributing to damping during the next simulation step.
| [in,out] | error | Error status. Check Error::IsOK for success. |