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

Method SetType

DynamicsB2Body.go:563–609  ·  view source on GitHub ↗
(bodytype uint8)

Source from the content-addressed store, hash-verified

561}
562
563func (body *B2Body) SetType(bodytype uint8) {
564
565 B2Assert(body.M_world.IsLocked() == false)
566 if body.M_world.IsLocked() == true {
567 return
568 }
569
570 if body.M_type == bodytype {
571 return
572 }
573
574 body.M_type = bodytype
575
576 body.ResetMassData()
577
578 if body.M_type == B2BodyType.B2_staticBody {
579 body.M_linearVelocity.SetZero()
580 body.M_angularVelocity = 0.0
581 body.M_sweep.A0 = body.M_sweep.A
582 body.M_sweep.C0 = body.M_sweep.C
583 body.SynchronizeFixtures()
584 }
585
586 body.SetAwake(true)
587
588 body.M_force.SetZero()
589 body.M_torque = 0.0
590
591 // Delete the attached contacts.
592 ce := body.M_contactList
593 for ce != nil {
594 ce0 := ce
595 ce = ce.Next
596 body.M_world.M_contactManager.Destroy(ce0.Contact)
597 }
598
599 body.M_contactList = nil
600
601 // Touch the proxies so that new contacts will be created (when appropriate)
602 broadPhase := body.M_world.M_contactManager.M_broadPhase
603 for f := body.M_fixtureList; f != nil; f = f.M_next {
604 proxyCount := f.M_proxyCount
605 for i := 0; i < proxyCount; i++ {
606 broadPhase.TouchProxy(f.M_proxies[i].ProxyId)
607 }
608 }
609}
610
611func (body *B2Body) CreateFixtureFromDef(def *B2FixtureDef) *B2Fixture {
612

Callers

nothing calls this directly

Calls 8

ResetMassDataMethod · 0.95
SynchronizeFixturesMethod · 0.95
SetAwakeMethod · 0.95
B2AssertFunction · 0.85
IsLockedMethod · 0.80
TouchProxyMethod · 0.80
DestroyMethod · 0.65
SetZeroMethod · 0.45

Tested by

no test coverage detected