(data B2SolverData)
| 396 | } |
| 397 | |
| 398 | func (joint *B2WheelJoint) SolvePositionConstraints(data B2SolverData) bool { |
| 399 | cA := data.Positions[joint.M_indexA].C |
| 400 | aA := data.Positions[joint.M_indexA].A |
| 401 | cB := data.Positions[joint.M_indexB].C |
| 402 | aB := data.Positions[joint.M_indexB].A |
| 403 | |
| 404 | qA := MakeB2RotFromAngle(aA) |
| 405 | qB := MakeB2RotFromAngle(aB) |
| 406 | |
| 407 | rA := B2RotVec2Mul(qA, B2Vec2Sub(joint.M_localAnchorA, joint.M_localCenterA)) |
| 408 | rB := B2RotVec2Mul(qB, B2Vec2Sub(joint.M_localAnchorB, joint.M_localCenterB)) |
| 409 | d := B2Vec2Sub(B2Vec2Add(B2Vec2Sub(cB, cA), rB), rA) |
| 410 | |
| 411 | ay := B2RotVec2Mul(qA, joint.M_localYAxisA) |
| 412 | |
| 413 | sAy := B2Vec2Cross(B2Vec2Add(d, rA), ay) |
| 414 | sBy := B2Vec2Cross(rB, ay) |
| 415 | |
| 416 | C := B2Vec2Dot(d, ay) |
| 417 | |
| 418 | k := joint.M_invMassA + joint.M_invMassB + joint.M_invIA*joint.M_sAy*joint.M_sAy + joint.M_invIB*joint.M_sBy*joint.M_sBy |
| 419 | |
| 420 | impulse := 0.0 |
| 421 | if k != 0.0 { |
| 422 | impulse = -C / k |
| 423 | } else { |
| 424 | impulse = 0.0 |
| 425 | } |
| 426 | |
| 427 | P := B2Vec2MulScalar(impulse, ay) |
| 428 | LA := impulse * sAy |
| 429 | LB := impulse * sBy |
| 430 | |
| 431 | cA.OperatorMinusInplace(B2Vec2MulScalar(joint.M_invMassA, P)) |
| 432 | aA -= joint.M_invIA * LA |
| 433 | cB.OperatorPlusInplace(B2Vec2MulScalar(joint.M_invMassB, P)) |
| 434 | aB += joint.M_invIB * LB |
| 435 | |
| 436 | data.Positions[joint.M_indexA].C = cA |
| 437 | data.Positions[joint.M_indexA].A = aA |
| 438 | data.Positions[joint.M_indexB].C = cB |
| 439 | data.Positions[joint.M_indexB].A = aB |
| 440 | |
| 441 | return math.Abs(C) <= B2_linearSlop |
| 442 | } |
| 443 | |
| 444 | func (joint B2WheelJoint) GetAnchorA() B2Vec2 { |
| 445 | return joint.M_bodyA.GetWorldPoint(joint.M_localAnchorA) |
nothing calls this directly
no test coverage detected