@Override public boolean solvePositionConstraints(final SolverData data) { final Rot qA = pool.popRot(); final Rot qB = pool.popRot(); final Vec2 rA = pool.popVec2(); final Vec2 rB = pool.popVec2(); final Vec2 uA = pool.popVec2(); final Vec2 uB = pool.popVec2(); final Vec2 temp = pool.popVec2(); final Vec2 PA = pool.popVec2(); final Vec2 PB = pool.popVec2(); Vec2 cA = data.positions[m_indexA].c; float aA = data.positions[m_indexA].a; Vec2 cB = data.positions[m_indexB].c; float aB = data.positions[m_indexB].a; qA.set(aA); qB.set(aB); Rot.mulToOutUnsafe(qA, temp.set(m_localAnchorA).subLocal(m_localCenterA), rA); Rot.mulToOutUnsafe(qB, temp.set(m_localAnchorB).subLocal(m_localCenterB), rB); uA.set(cA).addLocal(rA).subLocal(m_groundAnchorA); uB.set(cB).addLocal(rB).subLocal(m_groundAnchorB); float lengthA = uA.length(); float lengthB = uB.length(); if (lengthA > 10.0f * Settings.linearSlop) { uA.mulLocal(1.0f / lengthA); } else { uA.setZero(); } if (lengthB > 10.0f * Settings.linearSlop) { uB.mulLocal(1.0f / lengthB); } else { uB.setZero(); } // Compute effective mass. float ruA = Vec2.cross(rA, uA); float ruB = Vec2.cross(rB, uB); float mA = m_invMassA + m_invIA * ruA * ruA; float mB = m_invMassB + m_invIB * ruB * ruB; float mass = mA + m_ratio * m_ratio * mB; if (mass > 0.0f) { mass = 1.0f / mass; } float C = m_constant - lengthA - m_ratio * lengthB; float linearError = MathUtils.abs(C); float impulse = -mass * C; PA.set(uA).mulLocal(-impulse); PB.set(uB).mulLocal(-m_ratio * impulse); cA.x += m_invMassA * PA.x; cA.y += m_invMassA * PA.y; aA += m_invIA * Vec2.cross(rA, PA); cB.x += m_invMassB * PB.x; cB.y += m_invMassB * PB.y; aB += m_invIB * Vec2.cross(rB, PB); // data.positions[m_indexA].c.set(cA); data.positions[m_indexA].a = aA; // data.positions[m_indexB].c.set(cB); data.positions[m_indexB].a = aB; pool.pushRot(2); pool.pushVec2(7); return linearError < Settings.linearSlop; }