(massData *B2MassData)
| 779 | } |
| 780 | |
| 781 | func (body *B2Body) SetMassData(massData *B2MassData) { |
| 782 | |
| 783 | B2Assert(body.M_world.IsLocked() == false) |
| 784 | if body.M_world.IsLocked() == true { |
| 785 | return |
| 786 | } |
| 787 | |
| 788 | if body.M_type != B2BodyType.B2_dynamicBody { |
| 789 | return |
| 790 | } |
| 791 | |
| 792 | body.M_invMass = 0.0 |
| 793 | body.M_I = 0.0 |
| 794 | body.M_invI = 0.0 |
| 795 | |
| 796 | body.M_mass = massData.Mass |
| 797 | if body.M_mass <= 0.0 { |
| 798 | body.M_mass = 1.0 |
| 799 | } |
| 800 | |
| 801 | body.M_invMass = 1.0 / body.M_mass |
| 802 | |
| 803 | if massData.I > 0.0 && (body.M_flags&B2Body_Flags.E_fixedRotationFlag) == 0 { |
| 804 | body.M_I = massData.I - body.M_mass*B2Vec2Dot(massData.Center, massData.Center) |
| 805 | B2Assert(body.M_I > 0.0) |
| 806 | body.M_invI = 1.0 / body.M_I |
| 807 | } |
| 808 | |
| 809 | // Move center of mass. |
| 810 | oldCenter := body.M_sweep.C |
| 811 | body.M_sweep.LocalCenter = massData.Center |
| 812 | body.M_sweep.C0 = B2TransformVec2Mul(body.M_xf, body.M_sweep.LocalCenter) |
| 813 | body.M_sweep.C = B2TransformVec2Mul(body.M_xf, body.M_sweep.LocalCenter) |
| 814 | |
| 815 | // Update center of mass velocity. |
| 816 | body.M_linearVelocity.OperatorPlusInplace( |
| 817 | B2Vec2CrossScalarVector( |
| 818 | body.M_angularVelocity, |
| 819 | B2Vec2Sub(body.M_sweep.C, oldCenter), |
| 820 | ), |
| 821 | ) |
| 822 | } |
| 823 | |
| 824 | func (body B2Body) ShouldCollide(other *B2Body) bool { |
| 825 |
nothing calls this directly
no test coverage detected