MCPcopy Create free account
hub / github.com/ByteArena/box2d / ApplyLinearImpulse

Method ApplyLinearImpulse

DynamicsB2Body.go:406–423  ·  view source on GitHub ↗
(impulse B2Vec2, point B2Vec2, wake bool)

Source from the content-addressed store, hash-verified

404}
405
406func (body *B2Body) ApplyLinearImpulse(impulse B2Vec2, point B2Vec2, wake bool) {
407 if body.M_type != B2BodyType.B2_dynamicBody {
408 return
409 }
410
411 if wake && (body.M_flags&B2Body_Flags.E_awakeFlag) == 0 {
412 body.SetAwake(true)
413 }
414
415 // Don't accumulate velocity if the body is sleeping
416 if (body.M_flags & B2Body_Flags.E_awakeFlag) != 0x0000 {
417 body.M_linearVelocity.OperatorPlusInplace(B2Vec2MulScalar(body.M_invMass, impulse))
418 body.M_angularVelocity += body.M_invI * B2Vec2Cross(
419 B2Vec2Sub(point, body.M_sweep.C),
420 impulse,
421 )
422 }
423}
424
425func (body *B2Body) ApplyLinearImpulseToCenter(impulse B2Vec2, wake bool) {
426 if body.M_type != B2BodyType.B2_dynamicBody {

Callers

nothing calls this directly

Calls 5

SetAwakeMethod · 0.95
B2Vec2MulScalarFunction · 0.85
B2Vec2CrossFunction · 0.85
B2Vec2SubFunction · 0.85
OperatorPlusInplaceMethod · 0.45

Tested by

no test coverage detected