#include <DistanceConstraint.hpp>
|
| bool | IsWorldConstraint () const |
| | Check if this is a world constraint.
|
| bool | IsAutoDistance () const |
| | Check if distances should be auto-detected.
|
| bool | IsFixedDistance () const |
| | Check if this is a fixed distance (rope) or range (spring).
|
|
| static DistanceConstraint | Create (Engine::EntityId a, Engine::EntityId b, float distance, const glm::vec3 &pointA=glm::vec3(0.0f), const glm::vec3 &pointB=glm::vec3(0.0f), const ConstraintSettings &constraintSettings=ConstraintSettings::Rigid()) |
| | Create a fixed-distance constraint (rope).
|
| static DistanceConstraint | CreateWithRange (Engine::EntityId a, Engine::EntityId b, float min, float max, const glm::vec3 &pointA=glm::vec3(0.0f), const glm::vec3 &pointB=glm::vec3(0.0f), const ConstraintSettings &constraintSettings=ConstraintSettings::Soft()) |
| | Create a distance constraint with min/max range (spring).
|
| static DistanceConstraint | CreateToWorld (Engine::EntityId body, const glm::vec3 &worldPoint, float distance, const glm::vec3 &localPoint=glm::vec3(0.0f), const ConstraintSettings &constraintSettings=ConstraintSettings::Rigid()) |
| | Create a distance constraint from body to world.
|
| static DistanceConstraint | CreateAutoDistance (Engine::EntityId a, Engine::EntityId b, const glm::vec3 &pointA=glm::vec3(0.0f), const glm::vec3 &pointB=glm::vec3(0.0f), const ConstraintSettings &constraintSettings=ConstraintSettings::Rigid()) |
| | Create a distance constraint with auto-detected distance.
|
◆ Create()
Create a fixed-distance constraint (rope).
Creates a constraint that maintains an exact distance between two bodies.
- Parameters
-
| a | First body entity |
| b | Second body entity |
| distance | The fixed distance to maintain |
| pointA | Local attachment point on bodyA |
| pointB | Local attachment point on bodyB |
| constraintSettings | Constraint behavior settings |
- Returns
- Configured DistanceConstraint component
- Examples
- Chain, and Simple.
◆ CreateAutoDistance()
Create a distance constraint with auto-detected distance.
The distance is automatically calculated from the initial body positions.
- Parameters
-
| a | First body entity |
| b | Second body entity |
| pointA | Local attachment point on bodyA |
| pointB | Local attachment point on bodyB |
| constraintSettings | Constraint behavior settings |
- Returns
- Configured DistanceConstraint component
◆ CreateToWorld()
Create a distance constraint from body to world.
Attaches a body to a fixed point in world space with a distance constraint.
- Parameters
-
| body | The body entity to constrain |
| worldPoint | Point in world space |
| distance | The distance to maintain from worldPoint |
| localPoint | Attachment point on the body in local space |
| constraintSettings | Constraint behavior settings |
- Returns
- Configured DistanceConstraint component
◆ CreateWithRange()
Create a distance constraint with min/max range (spring).
Creates a constraint that allows distance to vary within a range.
- Parameters
-
| a | First body entity |
| b | Second body entity |
| min | Minimum distance (compressed state) |
| max | Maximum distance (extended state) |
| pointA | Local attachment point on bodyA |
| pointB | Local attachment point on bodyB |
| constraintSettings | Constraint behavior settings |
- Returns
- Configured DistanceConstraint component
- Examples
- Spring.
◆ IsAutoDistance()
| bool Physics::Component::DistanceConstraint::IsAutoDistance |
( |
| ) |
const |
|
inlinenodiscard |
Check if distances should be auto-detected.
- Returns
- true if either min or max distance is -1.0f
◆ IsFixedDistance()
| bool Physics::Component::DistanceConstraint::IsFixedDistance |
( |
| ) |
const |
|
inlinenodiscard |
Check if this is a fixed distance (rope) or range (spring).
- Returns
- true if minDistance equals maxDistance
◆ IsWorldConstraint()
| bool Physics::Component::DistanceConstraint::IsWorldConstraint |
( |
| ) |
const |
|
inlinenodiscard |
Check if this is a world constraint.
- Returns
- true if bodyB is invalid (world constraint)
◆ bodyA
First body entity (the entity this component is attached to).
◆ bodyB
Second body entity (the entity to connect to).
◆ broken
| bool Physics::Component::DistanceConstraint::broken = false |
Whether this constraint has been broken.
◆ localPointA
| glm::vec3 Physics::Component::DistanceConstraint::localPointA = glm::vec3(0.0f) |
Attachment point on bodyA in local body space.
◆ localPointB
| glm::vec3 Physics::Component::DistanceConstraint::localPointB = glm::vec3(0.0f) |
Attachment point on bodyB in local body space (or world-space anchor for world constraints).
For body-to-body constraints: local coordinates on bodyB. For body-to-world constraints (when bodyB is invalid), this member stores a world-space anchor point and is interpreted as such. Use IsWorldConstraint() to detect this state.
◆ maxDistance
| float Physics::Component::DistanceConstraint::maxDistance = -1.0f |
Maximum allowed distance between attachment points.
When the bodies try to get further than this distance, the constraint pulls them together.
Special values:
- -1.0f = Auto-detect from initial body positions
◆ minDistance
| float Physics::Component::DistanceConstraint::minDistance = -1.0f |
Minimum allowed distance between attachment points.
When the bodies try to get closer than this distance, the constraint pushes them apart.
Special values:
- -1.0f = Auto-detect from initial body positions
- 0.0f = Bodies can touch (no minimum)
◆ settings
Constraint settings (stiffness, damping, breaking thresholds).
The documentation for this struct was generated from the following file: