Engine²
Open-source game engine written in C++.
Loading...
Searching...
No Matches
Physics::Component::ConstraintSettings Struct Reference

#include <ConstraintSettings.hpp>

Public Member Functions

bool IsBreakable () const
 Check if this constraint is breakable.
bool IsRigid () const
 Check if this constraint is rigid (no spring behavior).

Static Public Member Functions

static ConstraintSettings Rigid ()
 Create settings for a perfectly rigid constraint.
static ConstraintSettings Breakable (float force, float torque=0.0f)
 Create settings for a breakable constraint.
static ConstraintSettings Soft (float stiff=0.5f, float damp=0.1f)
 Create settings for a soft spring-like constraint.

Public Attributes

float stiffness = 1.0f
 Constraint stiffness [0.0, 1.0].
float damping = 0.0f
 Constraint damping [0.0, 1.0].
float breakForce = 0.0f
 Maximum force before constraint breaks (Newtons).
float breakTorque = 0.0f
 Maximum torque before constraint breaks (Newton-meters).
bool enableCollision = false
 Enable collision between constrained bodies.

Member Function Documentation

◆ Breakable()

ConstraintSettings Physics::Component::ConstraintSettings::Breakable ( float force,
float torque = 0.0f )
inlinestaticnodiscard

Create settings for a breakable constraint.

Breakable constraints are rigid until the force/torque exceeds the specified thresholds, then they snap and are disabled.

Parameters
forceMaximum force before breaking (Newtons)
torqueMaximum torque before breaking (Newton-meters), defaults to 0 (force only)
Returns
ConstraintSettings configured for breakable behavior
Examples
Breakable.

◆ IsBreakable()

bool Physics::Component::ConstraintSettings::IsBreakable ( ) const
inlinenodiscard

Check if this constraint is breakable.

Returns
true if either breakForce or breakTorque is greater than 0

◆ IsRigid()

bool Physics::Component::ConstraintSettings::IsRigid ( ) const
inlinenodiscard

Check if this constraint is rigid (no spring behavior).

Returns
true if stiffness is 1.0 and damping is 0.0

◆ Rigid()

ConstraintSettings Physics::Component::ConstraintSettings::Rigid ( )
inlinestaticnodiscard

Create settings for a perfectly rigid constraint.

Rigid constraints have no spring behavior and cannot break. Use for fixed attachments, welding, etc.

Returns
ConstraintSettings configured for rigid behavior
Examples
Pendulum, Simple, and Two-body.

◆ Soft()

ConstraintSettings Physics::Component::ConstraintSettings::Soft ( float stiff = 0.5f,
float damp = 0.1f )
inlinestaticnodiscard

Create settings for a soft spring-like constraint.

Soft constraints have spring behavior and gradually enforce the constraint over time. Use for ropes, springs, etc.

Parameters
stiffStiffness coefficient [0.0, 1.0]
dampDamping coefficient [0.0, 1.0]
Returns
ConstraintSettings configured for soft behavior
Examples
Chain, Elbow, Ragdoll, and Spring.

Member Data Documentation

◆ breakForce

float Physics::Component::ConstraintSettings::breakForce = 0.0f

Maximum force before constraint breaks (Newtons).

When the constraint force exceeds this threshold, the constraint is marked as broken and disabled.

  • 0.0 = Unbreakable (default)
  • >0.0 = Breaks when force exceeds threshold
Note
Use infinity for truly unbreakable constraints

◆ breakTorque

float Physics::Component::ConstraintSettings::breakTorque = 0.0f

Maximum torque before constraint breaks (Newton-meters).

When the constraint torque exceeds this threshold, the constraint is marked as broken and disabled.

  • 0.0 = Unbreakable (default)
  • >0.0 = Breaks when torque exceeds threshold
Note
Use infinity for truly unbreakable constraints

◆ damping

float Physics::Component::ConstraintSettings::damping = 0.0f

Constraint damping [0.0, 1.0].

Controls how much energy is absorbed to prevent oscillation:

  • 0.0 = No damping (bouncy, oscillates)
  • 0.5 = Medium damping (some oscillation)
  • 1.0 = Critical damping (no oscillation)

Internally mapped to Jolt's SpringSettings::mDamping

◆ enableCollision

bool Physics::Component::ConstraintSettings::enableCollision = false

Enable collision between constrained bodies.

When true, the two bodies connected by this constraint can still collide with each other. When false (default), collisions between the constrained bodies are disabled.

◆ stiffness

float Physics::Component::ConstraintSettings::stiffness = 1.0f

Constraint stiffness [0.0, 1.0].

Controls how rigid the constraint is:

  • 1.0 = Perfectly rigid (no spring behavior)
  • 0.5 = Medium stiffness (some flexibility)
  • 0.0 = Very soft (minimal constraint force)

Internally mapped to Jolt's SpringSettings::mStiffness


The documentation for this struct was generated from the following file: