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

#include <PointConstraint.hpp>

Public Member Functions

bool IsWorldConstraint () const
 Check if this is a world constraint.

Static Public Member Functions

static PointConstraint Create (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 point constraint between two bodies.
static PointConstraint CreateToWorld (Engine::EntityId body, const glm::vec3 &worldPoint, const ConstraintSettings &constraintSettings=ConstraintSettings::Rigid())
 Create a point constraint from body to world (pendulum, anchor).
static PointConstraint CreateToWorldWithOffset (Engine::EntityId body, const glm::vec3 &worldPoint, const glm::vec3 &localPoint, const ConstraintSettings &constraintSettings=ConstraintSettings::Rigid())
 Create a point constraint from body to world with local attachment.

Public Attributes

Engine::EntityId bodyA = Engine::EntityId::Null()
 First body entity (the entity this component is attached to).
Engine::EntityId bodyB = Engine::EntityId::Null()
 Second body entity (the entity to connect to).
glm::vec3 localPointA = glm::vec3(0.0f)
 Attachment point on bodyA in local body space.
glm::vec3 localPointB = glm::vec3(0.0f)
 Attachment point on bodyB in local body space (or world space if world constraint).
ConstraintSettings settings
 Constraint settings (stiffness, damping, breaking thresholds).
bool broken = false
 Whether this constraint has been broken.

Detailed Description

Examples
Pendulum.

Member Function Documentation

◆ Create()

PointConstraint Physics::Component::PointConstraint::Create ( 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() )
inlinestaticnodiscard

Create a point constraint between two bodies.

Parameters
aFirst body entity (owner of this component)
bSecond body entity
pointALocal attachment point on bodyA
pointBLocal attachment point on bodyB
constraintSettingsConstraint behavior settings
Returns
Configured PointConstraint component
Examples
Elbow, and Ragdoll.

◆ CreateToWorld()

PointConstraint Physics::Component::PointConstraint::CreateToWorld ( Engine::EntityId body,
const glm::vec3 & worldPoint,
const ConstraintSettings & constraintSettings = ConstraintSettings::Rigid() )
inlinestaticnodiscard

Create a point constraint from body to world (pendulum, anchor).

Creates a ball-and-socket joint connecting a body to a fixed point in world space. The body can rotate freely around this point.

Parameters
bodyThe body entity to constrain
worldPointFixed anchor point in world space
constraintSettingsConstraint behavior settings
Returns
Configured PointConstraint component
Examples
Pendulum.

◆ CreateToWorldWithOffset()

PointConstraint Physics::Component::PointConstraint::CreateToWorldWithOffset ( Engine::EntityId body,
const glm::vec3 & worldPoint,
const glm::vec3 & localPoint,
const ConstraintSettings & constraintSettings = ConstraintSettings::Rigid() )
inlinestaticnodiscard

Create a point constraint from body to world with local attachment.

Same as CreateToWorld, but allows specifying an offset on the body.

Parameters
bodyThe body entity to constrain
worldPointFixed anchor point in world space
localPointAttachment point on the body in local space
constraintSettingsConstraint behavior settings
Returns
Configured PointConstraint component

◆ IsWorldConstraint()

bool Physics::Component::PointConstraint::IsWorldConstraint ( ) const
inlinenodiscard

Check if this is a world constraint.

Returns
true if bodyB is invalid (world constraint)

Member Data Documentation

◆ bodyA

Engine::EntityId Physics::Component::PointConstraint::bodyA = Engine::EntityId::Null()

First body entity (the entity this component is attached to).

◆ bodyB

Engine::EntityId Physics::Component::PointConstraint::bodyB = Engine::EntityId::Null()

Second body entity (the entity to connect to).

If invalid (default constructed), this becomes a world constraint.

◆ broken

bool Physics::Component::PointConstraint::broken = false

Whether this constraint has been broken.

◆ localPointA

glm::vec3 Physics::Component::PointConstraint::localPointA = glm::vec3(0.0f)

Attachment point on bodyA in local body space.

The point on the first body where the joint is located. Coordinates are relative to the body's center of mass.

◆ localPointB

glm::vec3 Physics::Component::PointConstraint::localPointB = glm::vec3(0.0f)

Attachment point on bodyB in local body space (or world space if world constraint).

For body-to-body constraints: local coordinates on bodyB For world constraints: world space coordinates of the anchor point

◆ settings

ConstraintSettings Physics::Component::PointConstraint::settings

Constraint settings (stiffness, damping, breaking thresholds).


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