7#include <unordered_map>
40 FxJoint(
const std::string& name,
const std::shared_ptr<FxEntity>& e1,
41 const std::shared_ptr<FxEntity>& e2);
88 float m_max_effort = FxInfinityf;
97 float m_target_theta = 0.0f;
98 float m_target_omega = 0.0f;
100 void apply_torque_effort(
float torque);
104 const std::shared_ptr<FxEntity>& e2,
const FxVec2f& anchor_point,
105 float angle_min = -3.14159f,
float angle_max = 3.14159f);
129 float m_initial_distance;
130 float m_position_min, m_position_max;
131 float m_target_position = 0.0f;
132 float m_target_velocity = 0.0f;
134 void apply_force_effort(
float force);
138 const std::shared_ptr<FxEntity>& e2,
const FxVec2f& local_axis,
139 float position_min = -1000.0f,
float position_max = 1000.0f);
167 std::shared_ptr<FxEntity> m_entity;
168 FxVec2f m_local_anchor{0.0f, 0.0f};
170 double m_compliance = 0.0;
172 float m_max_lambda = FxInfinityf;
190 bool attached()
const {
return m_entity !=
nullptr; }
191 const std::shared_ptr<FxEntity>&
entity()
const {
return m_entity; }
Base type shared by engine joints.
void namespace_constraints()
const std::shared_ptr< FxEntity > & get_entity1() const
void set_pid(const FxVec3f &pid)
void set_control_mode(ControlMode mode)
float clamp_effort(float effort) const
virtual bool is_revolute() const
const std::vector< std::shared_ptr< FxConstraint > > & get_constraints() const
void set_effort(float effort)
void set_instant(bool instant)
const std::shared_ptr< FxEntity > & get_entity2() const
std::shared_ptr< FxEntity > entity2
const std::string & get_name() const
std::vector< std::shared_ptr< FxConstraint > > m_constraints
virtual bool is_prismatic() const
std::shared_ptr< FxEntity > entity1
float get_max_effort() const
virtual void apply_controls(double dt)=0
virtual ~FxJoint()=default
std::string get_entity1_name() const
float eval_pid(float error, double dt)
FxJoint(const std::string &name, const std::shared_ptr< FxEntity > &e1, const std::shared_ptr< FxEntity > &e2)
ControlMode get_control_mode() const
void set_max_effort(float max_effort)
std::string get_entity2_name() const
const std::shared_ptr< FxEntity > & entity() const
bool attach(const std::shared_ptr< FxEntity > &entity, const FxVec2f &world_point)
FxVec2f anchor_world() const
void set_target(const FxVec2f &world_point)
const FxVec2f & local_anchor() const
const FxVec2f & target() const
A sliding joint with limits and motor control.
void set_max_force(float max_force)
float get_position() const
float get_velocity() const
void set_velocity(float velocity, bool instant=true)
bool is_prismatic() const override
FxPrismaticJoint(const std::string &name, const std::shared_ptr< FxEntity > &e1, const std::shared_ptr< FxEntity > &e2, const FxVec2f &local_axis, float position_min=-1000.0f, float position_max=1000.0f)
void set_force(float force)
float get_max_force() const
void set_position(float position, bool instant=true)
void apply_controls(double dt) override
A pivot joint with angular limits and motor control.
void set_omega(float omega, bool instant=true)
bool is_revolute() const override
void apply_controls(double dt) override
float get_max_torque() const
void set_max_torque(float max_torque)
void set_theta(float angle, bool instant=true)
FxRevoluteJoint(const std::string &name, const std::shared_ptr< FxEntity > &e1, const std::shared_ptr< FxEntity > &e2, const FxVec2f &anchor_point, float angle_min=-3.14159f, float angle_max=3.14159f)
void set_torque(float torque)
Single-precision 2D vector.
Single-precision three-component vector, including poses.