18 float gap = -FxInfinityf;
40 std::size_t
size()
const {
return vx.size(); }
45 const std::size_t i =
static_cast<std::size_t
>(body);
56 float ra_n[2] = {0.0f, 0.0f},
rb_n[2] = {0.0f, 0.0f};
57 float ra_t[2] = {0.0f, 0.0f},
rb_t[2] = {0.0f, 0.0f};
58 float K_n[2] = {0.0f, 0.0f},
K_t[2] = {0.0f, 0.0f};
59 float wA = 0.0f,
wB = 0.0f,
IA = 0.0f,
IB = 0.0f;
76 bool m_is_valid =
false;
158 if (k <= 0.0)
return;
164 bool& active)
const = 0;
190 const std::shared_ptr<FxEntity>& e2);
192 bool& active)
const override;
203 bool& active)
const override;
214 const FxVec2f& anchor,
bool anchor_is_local =
true);
216 bool& active)
const override;
224 bool m_axis_is_local;
225 float m_initial_projection;
233 const FxVec2f& axis,
bool axis_is_local =
true);
235 bool& active)
const override;
259 bool& active)
const override;
266 bool m_axis_is_local;
267 float m_initial_projection;
271 const std::shared_ptr<FxEntity>& e2,
const FxVec2f& axis,
272 bool axis_is_local =
true);
274 bool& active)
const override;
289 void color_pairs(
const std::vector<std::pair<size_t, size_t>>& pairs,
290 const std::vector<std::shared_ptr<FxEntity>>& entities);
298 void group_contacts(
const std::vector<uint32_t>& contact_colors, std::vector<uint32_t>& order);
301 size_t group_count()
const {
return m_group_starts.empty() ? 0 : m_group_starts.size() - 1; }
302 uint32_t
group_start(
size_t g)
const {
return m_group_starts[g]; }
313 std::vector<uint32_t> m_group_starts;
314 std::vector<uint32_t> m_color_of;
315 std::vector<uint64_t> m_used;
316 std::vector<uint32_t> m_counts;
317 std::vector<uint8_t> m_movable;
318 std::vector<uint32_t> m_group_of_color;
319 std::vector<uint32_t> m_group_counts;
320 size_t m_overflow_group =
static_cast<size_t>(-1);
321 size_t m_colored_count = 0;
322 size_t m_overflow_count = 0;
323 bool m_has_overflow =
false;
346 std::vector<float>
jn[2],
jt[2];
348 std::size_t
size()
const {
return ia.size(); }
352 template<
typename Fn>
375 for (
int s = 0; s < 2; ++s) {
398 vax.resize(
ia.size());
399 vay.resize(
ia.size());
400 wav.resize(
ia.size());
401 vbx.resize(
ia.size());
402 vby.resize(
ia.size());
403 wbv.resize(
ia.size());
415 return contact.
body1 >= 0 && contact.
body2 >= 0;
428 const std::shared_ptr<FxEntity>& entity2);
433 const std::shared_ptr<FxEntity>& entity2);
438 const std::shared_ptr<FxEntity>& entity2,
float substep_dt);
457 uint32_t contact_index);
FxVec< float, 2 > FxVec2f
void evaluate(float &C, FxVec2f &g1, FxVec2f &g2, float >h1, float >h2, bool &active) const override
FxAnchorConstraint(const std::shared_ptr< FxEntity > &e1, const std::shared_ptr< FxEntity > &e2, const FxVec2f &anchor, bool anchor_is_local=true)
FxAngleLockConstraint(const std::shared_ptr< FxEntity > &e1, const std::shared_ptr< FxEntity > &e2, float tgt=0.0f)
void evaluate(float &C, FxVec2f &g1, FxVec2f &g2, float >h1, float >h2, bool &active) const override
void evaluate(float &C, FxVec2f &g1, FxVec2f &g2, float >h1, float >h2, bool &active) const override
FxAngularLimitConstraint(const std::shared_ptr< FxEntity > &e1, const std::shared_ptr< FxEntity > &e2)
Base type for solver constraints.
const std::shared_ptr< FxEntity > & get_entity2() const
void set_stiffness(double k)
const std::shared_ptr< FxEntity > & get_entity1() const
std::shared_ptr< FxEntity > entity1
std::string get_entity2_name() const
const std::string & get_name() const
void setCompliance(double c)
virtual void evaluate(float &C, FxVec2f &g1, FxVec2f &g2, float >h1, float >h2, bool &active) const =0
std::shared_ptr< FxEntity > entity2
virtual ~FxConstraint()=default
std::string get_entity1_name() const
FxDistanceConstraint(const std::shared_ptr< FxEntity > &e1, const std::shared_ptr< FxEntity > &e2, const FxVec2f &anchor1, const FxVec2f &anchor2)
FxVec2f anchor2_world() const
FxVec2f anchor1_world() const
void evaluate(float &C, FxVec2f &g1, FxVec2f &g2, float >h1, float >h2, bool &active) const override
A named rigid body with state, material properties, geometry, and forces.
FxMotionAlongAxisConstraint(const std::shared_ptr< FxEntity > &e1, const std::shared_ptr< FxEntity > &e2, const FxVec2f &axis, bool axis_is_local=true)
void evaluate(float &C, FxVec2f &g1, FxVec2f &g2, float >h1, float >h2, bool &active) const override
FxSeparationConstraint(const std::shared_ptr< FxEntity > &e1, const std::shared_ptr< FxEntity > &e2, const FxVec2f &axis, bool axis_is_local=true)
void evaluate(float &C, FxVec2f &g1, FxVec2f &g2, float >h1, float >h2, bool &active) const override
Single-precision 2D vector.
const FxContact collision_check(const FxEntity &entity1, const FxEntity &entity2)
void warm_start(FxContact &contact, const FxContactSolverData &data, FxSolverBodies &bodies)
void hold_contact(FxHeldContact &held, const FxContact &contact)
bool contact_point_touches(const FxContact &contact, size_t i)
void resolve_penetration(const FxContact &contact, double dt=0.016f)
void batch_append(FxContactBatch &batch, const FxContact &contact, const FxContactSolverData &data, uint32_t contact_index)
bool aabb_overlap_check(const FxEntity &entity1, const FxEntity &entity2)
void resolve_velocities_batched(FxContactBatch &batch, std::size_t begin, std::size_t end, FxSolverBodies &bodies, int slots)
FxContact speculative_contact_check(const std::shared_ptr< FxEntity > &entity1, const std::shared_ptr< FxEntity > &entity2, float substep_dt)
constexpr float kContactPointApart
bool contact_is_solvable(const FxContact &contact)
void batch_write_back(const FxContactBatch &batch, std::vector< FxContact > &contacts)
void init_velocity_pass(FxContact &contact, FxContactSolverData &data, const FxSolverBodies &bodies)
bool remeasure_contact(FxHeldContact &held)
std::vector< float > inv_i
std::vector< float > inv_m
FxVec2f velocity_at(int32_t body, const FxVec2f &r) const
void resize(std::size_t n)