20 #ifndef ANTKEEPER_PHYSICS_SPRING_CONSTRAINT_HPP
21 #define ANTKEEPER_PHYSICS_SPRING_CONSTRAINT_HPP
35 void solve(
float dt)
override;
80 inline constexpr
void detach() noexcept
103 m_stiffness = stiffness;
143 return m_resting_length;
163 rigid_body* m_body_b{};
172 float m_resting_length{};
175 float m_stiffness{1.0f};
178 float m_damping{1.0f};
Abstract base class for rigid body constraints.
constexpr void set_damping(float damping) noexcept
Sets the damping constant of the spring.
constexpr void attach_a(rigid_body &body_a, const math::fvec3 &point_a) noexcept
Attaches the spring to body a.
void solve(float dt) override
Solves the constraint.
constexpr const math::fvec3 & get_point_b() const noexcept
Returns the point at which the spring is attached to body b, in body-space.
constexpr void set_resting_length(float length) noexcept
Sets the resting length of the spring.
constexpr void attach_b(rigid_body &body_b, const math::fvec3 &point_b) noexcept
Attaches the spring to body b.
constexpr float get_stiffness() const noexcept
Returns the stiffness constant of the spring.
constexpr rigid_body * get_body_a() const noexcept
Returns the body to which the spring is attached at point a.
constexpr void detach_a() noexcept
Detaches the spring from body a.
constexpr rigid_body * get_body_b() const noexcept
Returns the body to which the spring is attached at point b.
constexpr const math::fvec3 & get_point_a() const noexcept
Returns the point at which the spring is attached to body a, in body-space.
constexpr float get_damping() const noexcept
Returns the damping constant of the spring.
constexpr void set_stiffness(float stiffness) noexcept
Sets the stiffness constant of the spring.
constexpr void detach() noexcept
Detaches the spring from bodies a and b.
constexpr float get_resting_length() const noexcept
Returns the resting length of the spring, in meters.
constexpr void detach_b() noexcept
Detaches the spring from body b.
T length(const quaternion< T > &q)
Calculates the length of a quaternion.