A joint-like constraint on one or more bodies. More...
#include <playrho/d2/Joint.hpp>
Public Member Functions | |
Joint () noexcept=default | |
Default constructor. More... | |
Joint (const Joint &other) | |
Copy constructor. More... | |
Joint (Joint &&other) noexcept | |
Move constructor. More... | |
template<typename T , typename Tp = DecayedTypeIfNotSame<T, Joint>, typename = std::enable_if_t<std::is_constructible_v<Tp, T>>> | |
Joint (T &&arg) | |
Initializing constructor. More... | |
bool | has_value () const noexcept |
Checks whether this instance contains a value. | |
Joint & | operator= (const Joint &other) |
Copy assignment. More... | |
Joint & | operator= (Joint &&other) noexcept |
Move assignment. More... | |
template<typename T , typename Tp = DecayedTypeIfNotSame<T, Joint>, typename = std::enable_if_t<std::is_constructible_v<Tp, T>>> | |
Joint & | operator= (T &&arg) |
Move assignment support for any valid underlying configuration. More... | |
void | swap (Joint &other) noexcept |
Swap function. | |
Friends | |
BodyID | GetBodyA (const Joint &object) noexcept |
Gets the first body attached to this joint. | |
BodyID | GetBodyB (const Joint &object) noexcept |
Gets the second body attached to this joint. | |
bool | GetCollideConnected (const Joint &object) noexcept |
Gets collide connected. More... | |
TypeID | GetType (const Joint &object) noexcept |
Gets the identifier of the type of data this can be casted to. | |
void | InitVelocity (Joint &object, const Span< BodyConstraint > &bodies, const playrho::StepConf &step, const ConstraintSolverConf &conf) |
Initializes velocity constraint data based on the given solver data. More... | |
bool | operator!= (const Joint &lhs, const Joint &rhs) noexcept |
Inequality operator for joint comparisons. | |
bool | operator== (const Joint &lhs, const Joint &rhs) noexcept |
Equality operator for joint comparisons. | |
bool | ShiftOrigin (Joint &object, const Length2 &value) noexcept |
Shifts the origin for any points stored in world coordinates. More... | |
bool | SolvePosition (const Joint &object, const Span< BodyConstraint > &bodies, const ConstraintSolverConf &conf) |
Solves the position constraint. More... | |
bool | SolveVelocity (Joint &object, const Span< BodyConstraint > &bodies, const playrho::StepConf &step) |
Solves velocity constraint. More... | |
template<typename T > | |
std::add_pointer_t< std::add_const_t< T > > | TypeCast (const Joint *value) noexcept |
Converts the given joint into its current configuration value. More... | |
template<typename T > | |
std::add_pointer_t< T > | TypeCast (Joint *value) noexcept |
Converts the given joint into its current configuration value. More... | |
Related Functions | |
(Note that these are not member functions.) | |
void | EnableLimit (Joint &object, bool value) |
Enables the specified joint's limit property if it supports one. More... | |
void | EnableMotor (Joint &object, bool value) |
Enables the specified joint's motor property if it supports one. More... | |
Angle | GetAngularLowerLimit (const Joint &object) |
RotInertia | GetAngularMass (const Joint &object) |
Gets the given joint's angular mass. More... | |
AngularMomentum | GetAngularMotorImpulse (const Joint &object) |
Gets the angular motor impulse of the joint if it has this property. More... | |
Angle | GetAngularOffset (const Joint &object) |
Gets the angular offset property of the specified joint if its type has one. More... | |
AngularMomentum | GetAngularReaction (const Joint &object) |
Angle | GetAngularUpperLimit (const Joint &object) |
Gets the upper joint limit. More... | |
Real | GetDampingRatio (const Joint &object) |
Gets the given joint's damping ratio property if it has one. More... | |
DistanceJointConf | GetDistanceJointConf (const Joint &joint) |
Gets the definition data for the given joint. More... | |
Frequency | GetFrequency (const Joint &object) |
Gets the frequency of the joint if it has this property. More... | |
FrictionJointConf | GetFrictionJointConf (const Joint &joint) |
Gets the definition data for the given joint. More... | |
GearJointConf | GetGearJointConf (const Joint &joint) |
Gets the definition data for the given joint. More... | |
Length2 | GetGroundAnchorA (const Joint &object) |
Length2 | GetGroundAnchorB (const Joint &object) |
Length | GetLength (const Joint &object) |
Gets the length property of the specified joint if its type has one. More... | |
LimitState | GetLimitState (const Joint &object) |
Length | GetLinearLowerLimit (const Joint &object) |
Momentum | GetLinearMotorImpulse (const Joint &object) |
Length2 | GetLinearOffset (const Joint &object) |
Gets the linear offset property of the specified joint if its type has one. More... | |
Momentum2 | GetLinearReaction (const Joint &object) |
Length | GetLinearUpperLimit (const Joint &object) |
Length2 | GetLocalAnchorA (const Joint &object) |
Length2 | GetLocalAnchorB (const Joint &object) |
UnitVec | GetLocalXAxisA (const Joint &object) |
Gets the given joint's local X axis A if its type supports that. More... | |
UnitVec | GetLocalYAxisA (const Joint &object) |
Gets the given joint's local Y axis A if its type supports that. More... | |
Force | GetMaxForce (const Joint &object) |
Gets the given joint's max force if its type supports that. More... | |
Force | GetMaxMotorForce (const Joint &object) |
Gets the given joint's max motor force if its type supports that. More... | |
Torque | GetMaxMotorTorque (const Joint &object) |
Gets the given joint's max motor torque if its type supports that. More... | |
Torque | GetMaxTorque (const Joint &object) |
Gets the given joint's max torque if its type supports that. More... | |
MotorJointConf | GetMotorJointConf (const Joint &joint) |
Gets the definition data for the given joint. More... | |
AngularVelocity | GetMotorSpeed (const Joint &object) |
Gets the given joint's motor speed if its type supports that. More... | |
Torque | GetMotorTorque (const Joint &joint, Frequency inv_dt) |
Gets the current motor torque for the given joint given the inverse time step. More... | |
PrismaticJointConf | GetPrismaticJointConf (const Joint &joint) |
Gets the definition data for the given joint. More... | |
PulleyJointConf | GetPulleyJointConf (const Joint &joint) |
Gets the definition data for the given joint. More... | |
Real | GetRatio (const Joint &object) |
Gets the given joint's ratio property if it has one. More... | |
Angle | GetReferenceAngle (const Joint &object) |
Gets the reference angle of the joint if it has one. More... | |
RevoluteJointConf | GetRevoluteJointConf (const Joint &joint) |
Gets the definition data for the given joint. More... | |
RopeJointConf | GetRopeJointConf (const Joint &joint) |
Gets the definition data for the given joint. More... | |
Length2 | GetTarget (const Joint &object) |
Gets the given joint's target property if it has one. More... | |
TargetJointConf | GetTargetJointConf (const Joint &joint) |
Gets the definition data for the given joint. More... | |
WeldJointConf | GetWeldJointConf (const Joint &joint) |
Gets the definition data for the given joint. More... | |
WheelJointConf | GetWheelJointConf (const Joint &joint) |
Gets the definition data for the given joint. More... | |
auto | IsDestroyed (const Joint &object) noexcept -> bool |
Gets whether the given entity is in the is-destroyed state. | |
bool | IsLimitEnabled (const Joint &object) |
Gets the specified joint's limit property if it supports one. More... | |
bool | IsMotorEnabled (const Joint &object) |
Gets the specified joint's motor property value if it supports one. More... | |
void | SetAngularLimits (Joint &object, Angle lower, Angle upper) |
Sets the joint limits. More... | |
void | SetAngularOffset (Joint &object, Angle value) |
Sets the angular offset property of the specified joint if its type has one. More... | |
void | SetFrequency (Joint &object, Frequency value) |
Sets the frequency of the joint if it has this property. More... | |
void | SetLinearLimits (Joint &object, Length lower, Length upper) |
void | SetLinearOffset (Joint &object, const Length2 &value) |
Sets the linear offset property of the specified joint if its type has one. More... | |
void | SetMaxMotorForce (Joint &object, Force value) |
Sets the given joint's max motor force if its type supports that. More... | |
void | SetMaxMotorTorque (Joint &object, Torque value) |
Sets the given joint's max motor torque if its type supports that. More... | |
void | SetMotorSpeed (Joint &object, AngularVelocity value) |
Sets the given joint's motor speed if its type supports that. More... | |
void | SetTarget (Joint &object, const Length2 &value) |
Sets the given joint's target property if it has one. More... | |
template<typename T > | |
T | TypeCast (const Joint &value) |
Converts the given joint into its current configuration value. More... | |
template<typename T > | |
T | TypeCast (Joint &&value) |
Converts the given joint into its current configuration value. More... | |
template<typename T > | |
T | TypeCast (Joint &value) |
Converts the given joint into its current configuration value. More... | |
A joint-like constraint on one or more bodies.
This is a concrete manifestation of the joint concept. Joints are constraints that are used to constrain one or more bodies in various fashions. Some joints also feature limits and motors.
T
has at least the following function definitions available for it:bool operator==(const T& lhs, const T& rhs) noexcept;
BodyID GetBodyA(const T& object) noexcept;
BodyID GetBodyB(const T& object) noexcept;
bool GetCollideConnected(const T& object) noexcept;
bool ShiftOrigin(T& object, Length2 value) noexcept;
void InitVelocity(T& object, const Span<BodyConstraint>& bodies, const StepConf& step, const ConstraintSolverConf& conf);
bool SolveVelocity(T& object, const Span<BodyConstraint>& bodies, const StepConf& step);
bool SolvePosition(const T& object, const Span<BodyConstraint>& bodies, const ConstraintSolverConf& conf);
|
defaultnoexcept |
Default constructor.
Constructs a joint that contains no value.
has_value()
returns false. GetType(const Joint&)
returns GetTypeID<void>()
. Referenced by operator=().
|
inline |
Copy constructor.
This constructor copies all the details of other.
|
inlinenoexcept |
Move constructor.
This constructor moves all the details of other into *this
and leaves other in the default constructed state.
|
inlineexplicit |
Initializing constructor.
arg | Value to construct a joint instance for. |
T
for its values to be valid candidates for this function. explicit
to prevent implicit conversions and to provide preferable error messages from the compiler with less to-do when a type doesn't support one or more of the required functions. For instance, if there exists no function GetBodyA(const T&)
for the type T
, then clang issues the error: No matching function for call to 'GetBodyA'. explicit
and nothing else is done, then GetBodyA(const Joint&)
becomes eligible to satisfy that requirement (because of implicit conversion from T
to Joint
). This results in an exhaustive loop which is decidely less desirable than a compile time error. explicit
and const
rvalue reference taking versions of the required functions are deleted with definitions like BodyID GetBodyA(const Joint&&) noexcept = delete
, then clang issues an error of: Call to deleted function 'GetBodyA'. The idea for these deleted functions came from the article Controlling overload resolution #1: Preventing implicit conversions. While this would be preferable to discovering the issue at runtime, that's not as preferable as the error clang generates when this constructor is marked explicit
since this message points to the deleted function as the problem rather than directly to there being "no
matching function". std::any
, dealing with overload resolution of the required functions is less appealing than marking this constuctor explicit
as explained above. has_value()
returns true. std::bad_alloc | if there's a failure allocating storage. |
Copy assignment.
This operator copies all the details of other into *this
.
Move assignment.
This operator moves all the details of other into *this
and leaves other in the default constructed state.
|
inline |
Move assignment support for any valid underlying configuration.
T
for its values to be valid candidates for this function. has_value()
returns true.
|
related |
Enables the specified joint's limit property if it supports one.
std::invalid_argument | If not supported for the given joint's type. |
|
related |
Enables the specified joint's motor property if it supports one.
std::invalid_argument | If not supported for the given joint's type. |
Gets the lower joint limit.
std::invalid_argument | If not supported for the given joint's type. |
|
related |
Gets the given joint's angular mass.
std::invalid_argument | If not supported for the given joint's type. |
|
related |
Gets the angular motor impulse of the joint if it has this property.
std::invalid_argument | If not supported for the given joint's type. |
Gets the angular offset property of the specified joint if its type has one.
std::invalid_argument | If not supported for the given joint's type. |
|
related |
Get the angular reaction on body-B.
Gets the upper joint limit.
std::invalid_argument | If not supported for the given joint's type. |
|
friend |
Gets collide connected.
Gets the given joint's damping ratio property if it has one.
std::invalid_argument | If not supported for the given joint's type. |
|
related |
Gets the definition data for the given joint.
joint | The joint to get the configuration for. |
std::bad_cast | If the given joint's type is inappropriate for getting this value. |
Gets the frequency of the joint if it has this property.
std::invalid_argument | If not supported for the given joint's type. |
|
related |
Gets the definition data for the given joint.
std::bad_cast | If the given joint's type is inappropriate for getting this value. |
|
related |
Gets the definition data for the given joint.
std::bad_cast | If the given joint's type is inappropriate for getting this value. |
std::invalid_argument | If not supported for the given joint's type. |
std::invalid_argument | If not supported for the given joint's type. |
Gets the length property of the specified joint if its type has one.
std::invalid_argument | If not supported for the given joint's type. |
|
related |
std::invalid_argument | If not supported for the given joint's type. |
Gets the lower linear joint limit.
std::invalid_argument | If not supported for the given joint's type. |
std::invalid_argument | If not supported for the given joint's type. |
Gets the linear offset property of the specified joint if its type has one.
std::invalid_argument | If not supported for the given joint's type. |
Get the linear reaction on body-B at the joint anchor.
Gets the upper linear joint limit.
std::invalid_argument | If not supported for the given joint's type. |
Get the anchor point on body-A in local coordinates.
Get the anchor point on body-B in local coordinates.
Gets the given joint's local X axis A if its type supports that.
std::invalid_argument | If not supported for the given joint's type. |
Gets the given joint's local Y axis A if its type supports that.
std::invalid_argument | If not supported for the given joint's type. |
Gets the given joint's max force if its type supports that.
std::invalid_argument | If not supported for the given joint's type. |
Gets the given joint's max motor force if its type supports that.
std::invalid_argument | If not supported for the given joint's type. |
Gets the given joint's max motor torque if its type supports that.
std::invalid_argument | If not supported for the given joint's type. |
Gets the given joint's max torque if its type supports that.
std::invalid_argument | If not supported for the given joint's type. |
|
related |
Gets the definition data for the given joint.
std::bad_cast | If the given joint's type is inappropriate for getting this value. |
|
related |
Gets the given joint's motor speed if its type supports that.
std::invalid_argument | If not supported for the given joint's type. |
Gets the current motor torque for the given joint given the inverse time step.
std::invalid_argument | If not supported for the given joint's type. |
|
related |
Gets the definition data for the given joint.
std::bad_cast | If the given joint's type is inappropriate for getting this value. |
|
related |
Gets the definition data for the given joint.
std::bad_cast | If the given joint's type is inappropriate for getting this value. |
Gets the given joint's ratio property if it has one.
std::invalid_argument | If not supported for the given joint's type. |
Gets the reference angle of the joint if it has one.
std::invalid_argument | If not supported for the given joint's type. |
|
related |
Gets the definition data for the given joint.
std::bad_cast | If the given joint's type is inappropriate for getting this value. |
|
related |
Gets the definition data for the given joint.
std::bad_cast | If the given joint's type is inappropriate for getting this value. |
Gets the given joint's target property if it has one.
std::invalid_argument | If not supported for the given joint's type. |
|
related |
Gets the definition data for the given joint.
std::bad_cast | If the given joint's type is inappropriate for getting this value. |
|
related |
Gets the definition data for the given joint.
std::bad_cast | If the given joint's type is inappropriate for getting this value. |
|
related |
Gets the definition data for the given joint.
std::bad_cast | If the given joint's type is inappropriate for getting this value. |
|
friend |
Initializes velocity constraint data based on the given solver data.
SolveVelocity
.
|
related |
Gets the specified joint's limit property if it supports one.
std::invalid_argument | If not supported for the given joint's type. |
|
related |
Gets the specified joint's motor property value if it supports one.
std::invalid_argument | If not supported for the given joint's type. |
Sets the joint limits.
std::invalid_argument | If not supported for the given joint's type. |
Sets the angular offset property of the specified joint if its type has one.
std::invalid_argument | If not supported for the given joint's type. |
Sets the frequency of the joint if it has this property.
std::invalid_argument | If not supported for the given joint's type. |
Sets the joint limits.
std::invalid_argument | If not supported for the given joint's type. |
Sets the linear offset property of the specified joint if its type has one.
std::invalid_argument | If not supported for the given joint's type. |
Sets the given joint's max motor force if its type supports that.
std::invalid_argument | If not supported for the given joint's type. |
Sets the given joint's max motor torque if its type supports that.
std::invalid_argument | If not supported for the given joint's type. |
|
related |
Sets the given joint's motor speed if its type supports that.
std::invalid_argument | If not supported for the given joint's type. |
Sets the given joint's target property if it has one.
std::invalid_argument | If not supported for the given joint's type. |
Shifts the origin for any points stored in world coordinates.
true
if shift done, false
otherwise.
|
friend |
Solves the position constraint.
true
if the position errors are within tolerance.
|
friend |
Solves velocity constraint.
InitVelocity
has been called. true
if velocity is "solved", false
otherwise.
|
related |
Converts the given joint into its current configuration value.
std::any
class and its associated std::any_cast
function. The code for this is based off of the std::any
implementation from the LLVM Project. std::bad_cast | If the given template parameter type isn't the type of this joint's configuration value. |
|
friend |
Converts the given joint into its current configuration value.
std::any
class and its associated std::any_cast
function. The code for this is based off of the std::any
code from the LLVM Project.
|
related |
Converts the given joint into its current configuration value.
std::any
class and its associated std::any_cast
function. The code for this is based off of the std::any
implementation from the LLVM Project.
|
related |
Converts the given joint into its current configuration value.
std::any
class and its associated std::any_cast
function. The code for this is based off of the std::any
implementation from the LLVM Project.
|
friend |
Converts the given joint into its current configuration value.
std::any
class and its associated std::any_cast
function. The code for this is based off of the std::any
implementation from the LLVM Project.