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

#include <FixedConstraint.hpp>

Public Member Functions

bool IsWorldConstraint () const
 Check if this is a world constraint (body to world, not body to body).

Static Public Member Functions

static FixedConstraint 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 fixed constraint between two bodies.
static FixedConstraint CreateToWorld (Engine::EntityId body, const glm::vec3 &worldPoint, const ConstraintSettings &constraintSettings=ConstraintSettings::Rigid())
 Create a fixed constraint from one body to the world.

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.
ConstraintSettings settings
 Constraint settings (stiffness, damping, breaking thresholds).
bool broken = false
 Whether this constraint has been broken.

Detailed Description

Examples
Two-body.

Member Function Documentation

◆ Create()

FixedConstraint Physics::Component::FixedConstraint::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 fixed 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 FixedConstraint component
Examples
Breakable, and Two-body.

◆ CreateToWorld()

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

Create a fixed constraint from one body to the world.

Attaches a body to a fixed point in world space.

Parameters
bodyThe body entity to constrain
worldPointPoint in world space to attach to
constraintSettingsConstraint behavior settings
Returns
Configured FixedConstraint component

◆ IsWorldConstraint()

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

Check if this is a world constraint (body to world, not body to body).

Returns
true if bodyB is invalid (world constraint)

Member Data Documentation

◆ bodyA

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

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

This should be the entity that owns this constraint component. World constraints are encoded by setting bodyB invalid (see CreateToWorld()).

◆ bodyB

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

Second body entity (the entity to connect to).

The other entity involved in the constraint.

◆ broken

bool Physics::Component::FixedConstraint::broken = false

Whether this constraint has been broken.

When a breakable constraint exceeds its force/torque threshold, this flag is set to true and the Jolt constraint is disabled. The component remains attached to allow user code to react.

◆ localPointA

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

Attachment point on bodyA in local body space.

The point on the first body where the constraint attaches. Coordinates are relative to the body's center of mass.

◆ localPointB

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

Attachment point on bodyB in local body space.

The point on the second body where the constraint attaches. Coordinates are relative to the body's center of mass.

◆ settings

ConstraintSettings Physics::Component::FixedConstraint::settings

Constraint settings (stiffness, damping, breaking thresholds).


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