(data B2SolverData)
| 212 | } |
| 213 | |
| 214 | func (joint *B2MouseJoint) SolveVelocityConstraints(data B2SolverData) { |
| 215 | |
| 216 | vB := data.Velocities[joint.M_indexB].V |
| 217 | wB := data.Velocities[joint.M_indexB].W |
| 218 | |
| 219 | // Cdot = v + cross(w, r) |
| 220 | Cdot := B2Vec2Add(vB, B2Vec2CrossScalarVector(wB, joint.M_rB)) |
| 221 | impulse := B2Vec2Mat22Mul(joint.M_mass, (B2Vec2Add(B2Vec2Add(Cdot, joint.M_C), B2Vec2MulScalar(joint.M_gamma, joint.M_impulse))).OperatorNegate()) |
| 222 | |
| 223 | oldImpulse := joint.M_impulse |
| 224 | joint.M_impulse.OperatorPlusInplace(impulse) |
| 225 | maxImpulse := data.Step.Dt * joint.M_maxForce |
| 226 | if joint.M_impulse.LengthSquared() > maxImpulse*maxImpulse { |
| 227 | joint.M_impulse.OperatorScalarMulInplace(maxImpulse / joint.M_impulse.Length()) |
| 228 | } |
| 229 | impulse = B2Vec2Sub(joint.M_impulse, oldImpulse) |
| 230 | |
| 231 | vB.OperatorPlusInplace(B2Vec2MulScalar(joint.M_invMassB, impulse)) |
| 232 | wB += joint.M_invIB * B2Vec2Cross(joint.M_rB, impulse) |
| 233 | |
| 234 | data.Velocities[joint.M_indexB].V = vB |
| 235 | data.Velocities[joint.M_indexB].W = wB |
| 236 | } |
| 237 | |
| 238 | func (joint *B2MouseJoint) SolvePositionConstraints(data B2SolverData) bool { |
| 239 | return true |
nothing calls this directly
no test coverage detected