Refactor removal of constraints from bodies in 2D joints
This commit is contained in:
parent
aa42e8920b
commit
fb9d6fcc6d
|
@ -205,15 +205,6 @@ PinJoint2DSW::PinJoint2DSW(const Vector2 &p_pos, Body2DSW *p_body_a, Body2DSW *p
|
|||
}
|
||||
}
|
||||
|
||||
PinJoint2DSW::~PinJoint2DSW() {
|
||||
if (A) {
|
||||
A->remove_constraint(this, 0);
|
||||
}
|
||||
if (B) {
|
||||
B->remove_constraint(this, 1);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////
|
||||
//////////////////////////////////////////////
|
||||
//////////////////////////////////////////////
|
||||
|
@ -346,11 +337,6 @@ GrooveJoint2DSW::GrooveJoint2DSW(const Vector2 &p_a_groove1, const Vector2 &p_a_
|
|||
B->add_constraint(this, 1);
|
||||
}
|
||||
|
||||
GrooveJoint2DSW::~GrooveJoint2DSW() {
|
||||
A->remove_constraint(this, 0);
|
||||
B->remove_constraint(this, 1);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////
|
||||
//////////////////////////////////////////////
|
||||
//////////////////////////////////////////////
|
||||
|
@ -442,8 +428,3 @@ DampedSpringJoint2DSW::DampedSpringJoint2DSW(const Vector2 &p_anchor_a, const Ve
|
|||
A->add_constraint(this, 0);
|
||||
B->add_constraint(this, 1);
|
||||
}
|
||||
|
||||
DampedSpringJoint2DSW::~DampedSpringJoint2DSW() {
|
||||
A->remove_constraint(this, 0);
|
||||
B->remove_constraint(this, 1);
|
||||
}
|
||||
|
|
|
@ -60,6 +60,15 @@ public:
|
|||
bias = 0;
|
||||
max_force = max_bias = 3.40282e+38;
|
||||
};
|
||||
|
||||
virtual ~Joint2DSW() {
|
||||
for (int i = 0; i < get_body_count(); i++) {
|
||||
Body2DSW *body = get_body_ptr()[i];
|
||||
if (body) {
|
||||
body->remove_constraint(this, i);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
class PinJoint2DSW : public Joint2DSW {
|
||||
|
@ -90,7 +99,6 @@ public:
|
|||
real_t get_param(PhysicsServer2D::PinJointParam p_param) const;
|
||||
|
||||
PinJoint2DSW(const Vector2 &p_pos, Body2DSW *p_body_a, Body2DSW *p_body_b = nullptr);
|
||||
~PinJoint2DSW();
|
||||
};
|
||||
|
||||
class GrooveJoint2DSW : public Joint2DSW {
|
||||
|
@ -124,7 +132,6 @@ public:
|
|||
virtual void solve(real_t p_step);
|
||||
|
||||
GrooveJoint2DSW(const Vector2 &p_a_groove1, const Vector2 &p_a_groove2, const Vector2 &p_b_anchor, Body2DSW *p_body_a, Body2DSW *p_body_b);
|
||||
~GrooveJoint2DSW();
|
||||
};
|
||||
|
||||
class DampedSpringJoint2DSW : public Joint2DSW {
|
||||
|
@ -160,7 +167,6 @@ public:
|
|||
real_t get_param(PhysicsServer2D::DampedSpringParam p_param) const;
|
||||
|
||||
DampedSpringJoint2DSW(const Vector2 &p_anchor_a, const Vector2 &p_anchor_b, Body2DSW *p_body_a, Body2DSW *p_body_b);
|
||||
~DampedSpringJoint2DSW();
|
||||
};
|
||||
|
||||
#endif // JOINTS_2D_SW_H
|
||||
|
|
Loading…
Reference in New Issue