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

Method ApplyForce

DynamicsB2Body.go:357–374  ·  view source on GitHub ↗
(force B2Vec2, point B2Vec2, wake bool)

Source from the content-addressed store, hash-verified

355}
356
357func (body *B2Body) ApplyForce(force B2Vec2, point B2Vec2, wake bool) {
358 if body.M_type != B2BodyType.B2_dynamicBody {
359 return
360 }
361
362 if wake && (body.M_flags&B2Body_Flags.E_awakeFlag) == 0 {
363 body.SetAwake(true)
364 }
365
366 // Don't accumulate a force if the body is sleeping.
367 if (body.M_flags & B2Body_Flags.E_awakeFlag) != 0x0000 {
368 body.M_force.OperatorPlusInplace(force)
369 body.M_torque += B2Vec2Cross(
370 B2Vec2Sub(point, body.M_sweep.C),
371 force,
372 )
373 }
374}
375
376func (body *B2Body) ApplyForceToCenter(force B2Vec2, wake bool) {
377 if body.M_type != B2BodyType.B2_dynamicBody {

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected