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

Method CreateFixtureFromDef

DynamicsB2Body.go:611–642  ·  view source on GitHub ↗
(def *B2FixtureDef)

Source from the content-addressed store, hash-verified

609}
610
611func (body *B2Body) CreateFixtureFromDef(def *B2FixtureDef) *B2Fixture {
612
613 B2Assert(body.M_world.IsLocked() == false)
614 if body.M_world.IsLocked() == true {
615 return nil
616 }
617
618 fixture := NewB2Fixture()
619 fixture.Create(body, def)
620
621 if (body.M_flags & B2Body_Flags.E_activeFlag) != 0x0000 {
622 broadPhase := &body.M_world.M_contactManager.M_broadPhase
623 fixture.CreateProxies(broadPhase, body.M_xf)
624 }
625
626 fixture.M_next = body.M_fixtureList
627 body.M_fixtureList = fixture
628 body.M_fixtureCount++
629
630 fixture.M_body = body
631
632 // Adjust mass properties if needed.
633 if fixture.M_density > 0.0 {
634 body.ResetMassData()
635 }
636
637 // Let the world know we have a new fixture. This will cause new contacts
638 // to be created at the beginning of the next time step.
639 body.M_world.M_flags |= B2World_Flags.E_newFixture
640
641 return fixture
642}
643
644func (body *B2Body) CreateFixture(shape B2ShapeInterface, density float64) *B2Fixture {
645

Callers 2

CreateFixtureMethod · 0.95
TestCPPComplianceFunction · 0.80

Calls 6

CreateMethod · 0.95
CreateProxiesMethod · 0.95
ResetMassDataMethod · 0.95
B2AssertFunction · 0.85
NewB2FixtureFunction · 0.85
IsLockedMethod · 0.80

Tested by 1

TestCPPComplianceFunction · 0.64