summaryrefslogtreecommitdiff
path: root/servers/physics_2d/joints_2d_sw.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'servers/physics_2d/joints_2d_sw.cpp')
-rw-r--r--servers/physics_2d/joints_2d_sw.cpp28
1 files changed, 0 insertions, 28 deletions
diff --git a/servers/physics_2d/joints_2d_sw.cpp b/servers/physics_2d/joints_2d_sw.cpp
index 4524629d50..73d916138b 100644
--- a/servers/physics_2d/joints_2d_sw.cpp
+++ b/servers/physics_2d/joints_2d_sw.cpp
@@ -56,7 +56,6 @@
*/
static inline real_t k_scalar(Body2DSW *a, Body2DSW *b, const Vector2 &rA, const Vector2 &rB, const Vector2 &n) {
-
real_t value = 0;
{
@@ -66,7 +65,6 @@ static inline real_t k_scalar(Body2DSW *a, Body2DSW *b, const Vector2 &rA, const
}
if (b) {
-
value += b->get_inv_mass();
real_t rcn = rB.cross(n);
value += b->get_inv_inertia() * rcn * rcn;
@@ -90,7 +88,6 @@ normal_relative_velocity(Body2DSW *a, Body2DSW *b, Vector2 rA, Vector2 rB, Vecto
}
bool PinJoint2DSW::setup(real_t p_step) {
-
Space2DSW *space = A->get_space();
ERR_FAIL_COND_V(!space, false);
rA = A->get_transform().basis_xform(anchor_A);
@@ -115,7 +112,6 @@ bool PinJoint2DSW::setup(real_t p_step) {
K[1] = K1[1] + K2[1];
if (B) {
-
Transform2D K3;
K3[0].x = B->get_inv_inertia() * rB.y * rB.y;
K3[1].x = -B->get_inv_inertia() * rB.x * rB.y;
@@ -147,12 +143,10 @@ bool PinJoint2DSW::setup(real_t p_step) {
}
inline Vector2 custom_cross(const Vector2 &p_vec, real_t p_other) {
-
return Vector2(p_other * p_vec.y, -p_other * p_vec.x);
}
void PinJoint2DSW::solve(real_t p_step) {
-
// compute relative velocity
Vector2 vA = A->get_linear_velocity() - custom_cross(rA, A->get_angular_velocity());
@@ -172,13 +166,11 @@ void PinJoint2DSW::solve(real_t p_step) {
}
void PinJoint2DSW::set_param(PhysicsServer2D::PinJointParam p_param, real_t p_value) {
-
if (p_param == PhysicsServer2D::PIN_JOINT_SOFTNESS)
softness = p_value;
}
real_t PinJoint2DSW::get_param(PhysicsServer2D::PinJointParam p_param) const {
-
if (p_param == PhysicsServer2D::PIN_JOINT_SOFTNESS)
return softness;
ERR_FAIL_V(0);
@@ -186,7 +178,6 @@ real_t PinJoint2DSW::get_param(PhysicsServer2D::PinJointParam p_param) const {
PinJoint2DSW::PinJoint2DSW(const Vector2 &p_pos, Body2DSW *p_body_a, Body2DSW *p_body_b) :
Joint2DSW(_arr, p_body_b ? 2 : 1) {
-
A = p_body_a;
B = p_body_b;
anchor_A = p_body_a->get_inv_transform().xform(p_pos);
@@ -200,7 +191,6 @@ PinJoint2DSW::PinJoint2DSW(const Vector2 &p_pos, Body2DSW *p_body_a, Body2DSW *p
}
PinJoint2DSW::~PinJoint2DSW() {
-
if (A)
A->remove_constraint(this);
if (B)
@@ -259,7 +249,6 @@ mult_k(const Vector2 &vr, const Vector2 &k1, const Vector2 &k2) {
}
bool GrooveJoint2DSW::setup(real_t p_step) {
-
// calculate endpoints in worldspace
Vector2 ta = A->get_transform().xform(A_groove_1);
Vector2 tb = A->get_transform().xform(A_groove_2);
@@ -311,7 +300,6 @@ bool GrooveJoint2DSW::setup(real_t p_step) {
}
void GrooveJoint2DSW::solve(real_t p_step) {
-
// compute impulse
Vector2 vr = relative_velocity(A, B, rA, rB);
@@ -329,7 +317,6 @@ void GrooveJoint2DSW::solve(real_t p_step) {
GrooveJoint2DSW::GrooveJoint2DSW(const Vector2 &p_a_groove1, const Vector2 &p_a_groove2, const Vector2 &p_b_anchor, Body2DSW *p_body_a, Body2DSW *p_body_b) :
Joint2DSW(_arr, 2) {
-
A = p_body_a;
B = p_body_b;
@@ -343,7 +330,6 @@ GrooveJoint2DSW::GrooveJoint2DSW(const Vector2 &p_a_groove1, const Vector2 &p_a_
}
GrooveJoint2DSW::~GrooveJoint2DSW() {
-
A->remove_constraint(this);
B->remove_constraint(this);
}
@@ -353,7 +339,6 @@ GrooveJoint2DSW::~GrooveJoint2DSW() {
//////////////////////////////////////////////
bool DampedSpringJoint2DSW::setup(real_t p_step) {
-
rA = A->get_transform().basis_xform(anchor_A);
rB = B->get_transform().basis_xform(anchor_B);
@@ -382,7 +367,6 @@ bool DampedSpringJoint2DSW::setup(real_t p_step) {
}
void DampedSpringJoint2DSW::solve(real_t p_step) {
-
// compute relative velocity
real_t vrn = normal_relative_velocity(A, B, rA, rB, n) - target_vrn;
@@ -397,38 +381,28 @@ void DampedSpringJoint2DSW::solve(real_t p_step) {
}
void DampedSpringJoint2DSW::set_param(PhysicsServer2D::DampedStringParam p_param, real_t p_value) {
-
switch (p_param) {
-
case PhysicsServer2D::DAMPED_STRING_REST_LENGTH: {
-
rest_length = p_value;
} break;
case PhysicsServer2D::DAMPED_STRING_DAMPING: {
-
damping = p_value;
} break;
case PhysicsServer2D::DAMPED_STRING_STIFFNESS: {
-
stiffness = p_value;
} break;
}
}
real_t DampedSpringJoint2DSW::get_param(PhysicsServer2D::DampedStringParam p_param) const {
-
switch (p_param) {
-
case PhysicsServer2D::DAMPED_STRING_REST_LENGTH: {
-
return rest_length;
} break;
case PhysicsServer2D::DAMPED_STRING_DAMPING: {
-
return damping;
} break;
case PhysicsServer2D::DAMPED_STRING_STIFFNESS: {
-
return stiffness;
} break;
}
@@ -438,7 +412,6 @@ real_t DampedSpringJoint2DSW::get_param(PhysicsServer2D::DampedStringParam p_par
DampedSpringJoint2DSW::DampedSpringJoint2DSW(const Vector2 &p_anchor_a, const Vector2 &p_anchor_b, Body2DSW *p_body_a, Body2DSW *p_body_b) :
Joint2DSW(_arr, 2) {
-
A = p_body_a;
B = p_body_b;
anchor_A = A->get_inv_transform().xform(p_anchor_a);
@@ -453,7 +426,6 @@ DampedSpringJoint2DSW::DampedSpringJoint2DSW(const Vector2 &p_anchor_a, const Ve
}
DampedSpringJoint2DSW::~DampedSpringJoint2DSW() {
-
A->remove_constraint(this);
B->remove_constraint(this);
}