Fx2D
A C++20 2D rigid-body physics engine
Loading...
Searching...
No Matches
FxJoint Class Referenceabstract

Base type shared by engine joints. More...

#include <Joints.h>

+ Inheritance diagram for FxJoint:
+ Collaboration diagram for FxJoint:

Public Member Functions

 FxJoint (const std::string &name, const std::shared_ptr< FxEntity > &e1, const std::shared_ptr< FxEntity > &e2)
 
virtual ~FxJoint ()=default
 
const std::string & get_name () const
 
void reset ()
 
const std::shared_ptr< FxEntity > & get_entity1 () const
 
const std::shared_ptr< FxEntity > & get_entity2 () const
 
std::string get_entity1_name () const
 
std::string get_entity2_name () const
 
const std::vector< std::shared_ptr< FxConstraint > > & get_constraints () const
 
void set_pid (const FxVec3f &pid)
 
FxVec3f get_pid () const
 
void set_p (float p)
 
void set_i (float i)
 
void set_d (float d)
 
float get_p () const
 
float get_i () const
 
float get_d () const
 
void set_instant (bool instant)
 
bool get_instant () const
 
void set_effort (float effort)
 
float get_effort () const
 
void set_max_effort (float max_effort)
 
float get_max_effort () const
 
void set_control_mode (ControlMode mode)
 
ControlMode get_control_mode () const
 
virtual bool is_revolute () const
 
virtual bool is_prismatic () const
 
virtual void apply_controls (double dt)=0
 

Public Attributes

bool enabled = true
 
bool entities_collide = false
 

Protected Member Functions

void namespace_constraints ()
 
void reset_pid_state ()
 
void wake_entities ()
 
float eval_pid (float error, double dt)
 
float clamp_effort (float effort) const
 

Protected Attributes

std::shared_ptr< FxEntity > entity1
 
std::shared_ptr< FxEntity > entity2
 
std::string m_name
 
std::vector< std::shared_ptr< FxConstraint > > m_constraints
 
FxVec3f m_pid {1.0f, 0.0f, 0.0f}
 
float m_integral = 0.0f
 
float m_previous_error = 0.0f
 
float m_target_effort = 0.0f
 
bool m_instant = true
 

Detailed Description

Base type shared by engine joints.

Definition at line 13 of file Joints.h.

Constructor & Destructor Documentation

◆ FxJoint()

FxJoint::FxJoint ( const std::string &  name,
const std::shared_ptr< FxEntity > &  e1,
const std::shared_ptr< FxEntity > &  e2 
)

◆ ~FxJoint()

virtual FxJoint::~FxJoint ( )
virtualdefault

Member Function Documentation

◆ apply_controls()

virtual void FxJoint::apply_controls ( double  dt)
pure virtual

Implemented in FxRevoluteJoint, and FxPrismaticJoint.

◆ clamp_effort()

float FxJoint::clamp_effort ( float  effort) const
protected

◆ eval_pid()

float FxJoint::eval_pid ( float  error,
double  dt 
)
protected

◆ get_constraints()

const std::vector< std::shared_ptr< FxConstraint > > & FxJoint::get_constraints ( ) const
inline

Definition at line 58 of file Joints.h.

◆ get_control_mode()

ControlMode FxJoint::get_control_mode ( ) const
inline

Definition at line 78 of file Joints.h.

◆ get_d()

float FxJoint::get_d ( ) const
inline

Definition at line 70 of file Joints.h.

◆ get_effort()

float FxJoint::get_effort ( ) const
inline

Definition at line 74 of file Joints.h.

◆ get_entity1()

const std::shared_ptr< FxEntity > & FxJoint::get_entity1 ( ) const
inline

Definition at line 50 of file Joints.h.

◆ get_entity1_name()

std::string FxJoint::get_entity1_name ( ) const

◆ get_entity2()

const std::shared_ptr< FxEntity > & FxJoint::get_entity2 ( ) const
inline

Definition at line 51 of file Joints.h.

◆ get_entity2_name()

std::string FxJoint::get_entity2_name ( ) const

◆ get_i()

float FxJoint::get_i ( ) const
inline

Definition at line 69 of file Joints.h.

◆ get_instant()

bool FxJoint::get_instant ( ) const
inline

Definition at line 72 of file Joints.h.

◆ get_max_effort()

float FxJoint::get_max_effort ( ) const
inline

Definition at line 76 of file Joints.h.

◆ get_name()

const std::string & FxJoint::get_name ( ) const
inline

Definition at line 45 of file Joints.h.

◆ get_p()

float FxJoint::get_p ( ) const
inline

Definition at line 68 of file Joints.h.

◆ get_pid()

FxVec3f FxJoint::get_pid ( ) const
inline

Definition at line 64 of file Joints.h.

◆ is_prismatic()

virtual bool FxJoint::is_prismatic ( ) const
inlinevirtual

Reimplemented in FxPrismaticJoint.

Definition at line 82 of file Joints.h.

◆ is_revolute()

virtual bool FxJoint::is_revolute ( ) const
inlinevirtual

Reimplemented in FxRevoluteJoint.

Definition at line 81 of file Joints.h.

◆ namespace_constraints()

void FxJoint::namespace_constraints ( )
protected

◆ reset()

void FxJoint::reset ( )
inline

Definition at line 47 of file Joints.h.

◆ reset_pid_state()

void FxJoint::reset_pid_state ( )
protected

◆ set_control_mode()

void FxJoint::set_control_mode ( ControlMode  mode)

◆ set_d()

void FxJoint::set_d ( float  d)
inline

Definition at line 67 of file Joints.h.

◆ set_effort()

void FxJoint::set_effort ( float  effort)

◆ set_i()

void FxJoint::set_i ( float  i)
inline

Definition at line 66 of file Joints.h.

◆ set_instant()

void FxJoint::set_instant ( bool  instant)
inline

Definition at line 71 of file Joints.h.

◆ set_max_effort()

void FxJoint::set_max_effort ( float  max_effort)

◆ set_p()

void FxJoint::set_p ( float  p)
inline

Definition at line 65 of file Joints.h.

◆ set_pid()

void FxJoint::set_pid ( const FxVec3f &  pid)

◆ wake_entities()

void FxJoint::wake_entities ( )
protected

Member Data Documentation

◆ enabled

bool FxJoint::enabled = true

Definition at line 37 of file Joints.h.

◆ entities_collide

bool FxJoint::entities_collide = false

Definition at line 38 of file Joints.h.

◆ entity1

std::shared_ptr<FxEntity> FxJoint::entity1
protected

Definition at line 15 of file Joints.h.

◆ entity2

std::shared_ptr<FxEntity> FxJoint::entity2
protected

Definition at line 16 of file Joints.h.

◆ m_constraints

std::vector<std::shared_ptr<FxConstraint> > FxJoint::m_constraints
protected

Definition at line 18 of file Joints.h.

◆ m_instant

bool FxJoint::m_instant = true
protected

Definition at line 25 of file Joints.h.

◆ m_integral

float FxJoint::m_integral = 0.0f
protected

Definition at line 22 of file Joints.h.

◆ m_name

std::string FxJoint::m_name
protected

Definition at line 17 of file Joints.h.

◆ m_pid

FxVec3f FxJoint::m_pid {1.0f, 0.0f, 0.0f}
protected

Definition at line 21 of file Joints.h.

◆ m_previous_error

float FxJoint::m_previous_error = 0.0f
protected

Definition at line 23 of file Joints.h.

◆ m_target_effort

float FxJoint::m_target_effort = 0.0f
protected

Definition at line 24 of file Joints.h.


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