18class ConstraintManager;
38 static constexpr auto type = ConstraintType::FixedConstraint;
51 static constexpr auto type = ConstraintType::PointConstraint;
60 static constexpr auto type = ConstraintType::DistanceConstraint;
72 static constexpr auto type = ConstraintType::HingeConstraint;
89 static constexpr auto type = ConstraintType::SliderConstraint;
106 static constexpr auto type = ConstraintType::SwingTwistConstraint;
139 m_otherBody{otherBody},
159 auto GetConstraintTarget() const ->
Entity {
return m_otherBody; }
163 auto IsEnabled() const ->
bool {
return m_enabled; }
169 friend class physics::ConstraintManager;
170 inline static physics::ConstraintManager* s_manager =
nullptr;
175 bool m_enabled =
true;
uint32_t ConstraintId
Unique value identifying internal Constraint state.
Definition: Constraints.h:129
std::variant< FixedConstraintInfo, PointConstraintInfo, DistanceConstraintInfo, HingeConstraintInfo, SliderConstraintInfo, SwingTwistConstraintInfo > ConstraintInfo
Generalized constraint initialization information.
Definition: Constraints.h:126
ConstraintType
Type of a Constraint.
Definition: Constraints.h:26
A physics constraint attaching the owning RigidBody to another.
Definition: Constraints.h:133
auto GetInfo() -> ConstraintInfo &
Get the ConstraintInfo.
Definition: Constraints.h:148
void Enable(bool enabled)
Toggle the Constraint on or off.
void NotifyUpdateInfo()
Update internal state based on the current ConstraintInfo values.
auto GetType() const -> ConstraintType
Get the type of constraint.
void SetConstraintTarget(RigidBody *otherBody=nullptr)
Update the body that the Constraint owner is attached to (use nullptr to attach to the world).
auto GetId() const -> ConstraintId
Get the Constraint's unique identifier.
Definition: Constraints.h:166
Identifies an object in the registry.
Definition: Entity.h:18
Component managing physics simulation properties.
Definition: RigidBody.h:92
Constraint settings to keep two bodies within a specified distance range.
Definition: Constraints.h:59
float minLimit
how close together bodies are allowed to be [0, maxDistance]
Definition: Constraints.h:64
Vector3 targetPosition
local attach position
Definition: Constraints.h:63
Vector3 ownerPosition
local attach position
Definition: Constraints.h:62
SpringSettings springSettings
settings to soften the limits
Definition: Constraints.h:66
float maxLimit
how far apart bodies are allowed to be [minDistance, infinity]
Definition: Constraints.h:65
Constraint settings to rigidly fix two bodies together, limiting all relative motion.
Definition: Constraints.h:37
Vector3 targetUp
local up axis
Definition: Constraints.h:45
Vector3 targetRight
local right axis
Definition: Constraints.h:44
Vector3 targetPosition
local attach position
Definition: Constraints.h:43
Vector3 ownerUp
local up axis
Definition: Constraints.h:42
Vector3 ownerRight
local right axis
Definition: Constraints.h:41
Vector3 ownerPosition
local attach position
Definition: Constraints.h:40
Constraint settings to attach two bodies with a hinge, limiting relative motion to rotation about a s...
Definition: Constraints.h:71
Vector3 ownerNormalAxis
local reference axis perpendicular to ownerHingeAxis
Definition: Constraints.h:76
SpringSettings springSettings
settings to soften the limits
Definition: Constraints.h:83
Vector3 targetPosition
local attach position
Definition: Constraints.h:77
Vector3 ownerPosition
local attach position
Definition: Constraints.h:74
Vector3 targetNormalAxis
local reference axis perpendicular to targetHingeAxis
Definition: Constraints.h:79
Vector3 ownerHingeAxis
local axis of rotation
Definition: Constraints.h:75
float maxLimit
max rotation about hinge axis [0, pi]
Definition: Constraints.h:81
Vector3 targetHingeAxis
local axis of rotation
Definition: Constraints.h:78
float minLimit
min rotation about hinge axis [-pi, 0] ( |minLimit| + maxLimit > 0 )
Definition: Constraints.h:80
float maxFrictionTorque
max torque to apply as friction (Nm) [0, inf]
Definition: Constraints.h:82
Constraint settings to attach two bodies at a point, limiting relative motion to rotation only.
Definition: Constraints.h:50
Vector3 ownerPosition
local attach position
Definition: Constraints.h:53
Vector3 targetPosition
local attach position
Definition: Constraints.h:54
Constraint settings to attach two bodies with a slider, limiting relative motion to a single axis of ...
Definition: Constraints.h:88
Vector3 ownerSliderAxis
local axis of translation
Definition: Constraints.h:92
float maxLimit
slider length in positive direction [0, inf]
Definition: Constraints.h:98
float minLimit
slider length in negative direction [-inf, 0] ( |minLimit| + maxLimit > 0 )
Definition: Constraints.h:97
Vector3 targetNormalAxis
local reference axis perpendicular to targetSliderAxis
Definition: Constraints.h:96
Vector3 targetSliderAxis
local axis of translation
Definition: Constraints.h:95
float maxFrictionForce
max friction force that can be applied (N) [0, inf]
Definition: Constraints.h:99
Vector3 targetPosition
local attach position
Definition: Constraints.h:94
Vector3 ownerNormalAxis
local reference axis perpendicular to ownerSliderAxis
Definition: Constraints.h:93
Vector3 ownerPosition
local attach position
Definition: Constraints.h:91
SpringSettings springSettings
settings to soften the limits
Definition: Constraints.h:100
Settings for softening constraints with a spring-damper.
Definition: SpringSettings.h:11
Constraint settings to attach two bodies with a shoulder-like joint, limiting relative motion to rota...
Definition: Constraints.h:105
Vector3 ownerPosition
local attach position
Definition: Constraints.h:108
Vector3 targetPosition
local attach position
Definition: Constraints.h:110
float swingLimit
rotation limit from twist axis (cone angle) [0, pi]
Definition: Constraints.h:112
float maxFrictionTorque
max torque to apply as friction (Nm) [0, inf]
Definition: Constraints.h:114
Vector3 targetTwistAxis
local twist axis (cone axis)
Definition: Constraints.h:111
Vector3 ownerTwistAxis
local twist axis (cone axis)
Definition: Constraints.h:109
float twistLimit
rotation limit about twist axis [0, pi]
Definition: Constraints.h:113
A three component vector.
Definition: Vector.h:29