7#include <unordered_map>
40 FxJoint(
const std::string& name,
const std::shared_ptr<FxEntity>& e1,
41 const std::shared_ptr<FxEntity>& e2);
89 float m_max_effort = FxInfinityf;
98 float m_target_theta = 0.0f;
99 float m_target_omega = 0.0f;
101 void apply_torque_effort(
float torque);
105 const std::shared_ptr<FxEntity>& e2,
const FxVec2f& anchor_point,
106 float angle_min = -3.14159f,
float angle_max = 3.14159f);
131 std::shared_ptr<FxDistanceConstraint> m_link;
132 float m_target_length = 0.0f;
133 float m_target_rate = 0.0f;
135 void apply_force_effort(
float force);
141 const std::shared_ptr<FxEntity>& e2,
const FxVec2f& anchor1 = {0.0f, 0.0f},
142 const FxVec2f& anchor2 = {0.0f, 0.0f},
float min_length = -1.0f,
143 float max_length = -1.0f);
177 float m_initial_distance;
178 float m_position_min, m_position_max;
179 float m_target_position = 0.0f;
180 float m_target_velocity = 0.0f;
182 void apply_force_effort(
float force);
186 const std::shared_ptr<FxEntity>& e2,
const FxVec2f& local_axis,
187 float position_min = -1000.0f,
float position_max = 1000.0f);
215 std::shared_ptr<FxEntity> m_entity;
216 FxVec2f m_local_anchor{0.0f, 0.0f};
218 double m_compliance = 0.0;
220 float m_max_lambda = FxInfinityf;
238 bool attached()
const {
return m_entity !=
nullptr; }
239 const std::shared_ptr<FxEntity>&
entity()
const {
return m_entity; }
void set_compliance(double compliance)
void set_max_force(float max_force)
void set_rate(float rate, bool instant=true)
float get_max_force() const
bool is_distance() const override
void set_force(float force)
float get_max_length() const
void set_link_stiffness(double stiffness)
FxDistanceJoint(const std::string &name, const std::shared_ptr< FxEntity > &e1, const std::shared_ptr< FxEntity > &e2, const FxVec2f &anchor1={0.0f, 0.0f}, const FxVec2f &anchor2={0.0f, 0.0f}, float min_length=-1.0f, float max_length=-1.0f)
void set_length(float length, bool instant=true)
void set_limits(float min_length, float max_length)
float get_min_length() const
void apply_controls(double dt) override
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)
virtual bool is_distance() const
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
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
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.