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;
142 if (k <= 0.0)
return;
148 bool& active)
const = 0;
174 const std::shared_ptr<FxEntity>& e2);
176 bool& active)
const override;
187 bool& active)
const override;
198 const FxVec2f& anchor,
bool anchor_is_local =
true);
200 bool& active)
const override;
208 bool m_axis_is_local;
209 float m_initial_projection;
217 const FxVec2f& axis,
bool axis_is_local =
true);
219 bool& active)
const override;
226 bool m_axis_is_local;
227 float m_initial_projection;
231 const std::shared_ptr<FxEntity>& e2,
const FxVec2f& axis,
232 bool axis_is_local =
true);
234 bool& active)
const override;
249 void color_pairs(
const std::vector<std::pair<size_t, size_t>>& pairs,
250 const std::vector<std::shared_ptr<FxEntity>>& entities);
258 void group_contacts(
const std::vector<uint32_t>& contact_colors, std::vector<uint32_t>& order);
261 size_t group_count()
const {
return m_group_starts.empty() ? 0 : m_group_starts.size() - 1; }
262 uint32_t
group_start(
size_t g)
const {
return m_group_starts[g]; }
273 std::vector<uint32_t> m_group_starts;
274 std::vector<uint32_t> m_color_of;
275 std::vector<uint64_t> m_used;
276 std::vector<uint32_t> m_counts;
277 std::vector<uint8_t> m_movable;
278 std::vector<uint32_t> m_group_of_color;
279 std::vector<uint32_t> m_group_counts;
280 size_t m_overflow_group =
static_cast<size_t>(-1);
281 size_t m_colored_count = 0;
282 size_t m_overflow_count = 0;
283 bool m_has_overflow =
false;
306 std::vector<float>
jn[2],
jt[2];
308 std::size_t
size()
const {
return ia.size(); }
312 template<
typename Fn>
335 for (
int s = 0; s < 2; ++s) {
358 vax.resize(
ia.size());
359 vay.resize(
ia.size());
360 wav.resize(
ia.size());
361 vbx.resize(
ia.size());
362 vby.resize(
ia.size());
363 wbv.resize(
ia.size());
375 return contact.
body1 >= 0 && contact.
body2 >= 0;
381 const std::shared_ptr<FxEntity>& entity2);
386 const std::shared_ptr<FxEntity>& entity2);
391 const std::shared_ptr<FxEntity>& entity2,
float substep_dt);
403 uint32_t contact_index);
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
A named rigid body with state, material properties, geometry, and forces.
Base type shared by engine joints.
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 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)
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)
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)