| 149 | } |
| 150 | |
| 151 | b2Fixture* b2Body::CreateFixture(const b2FixtureDef* def) |
| 152 | { |
| 153 | b2Assert(m_world->IsLocked() == false); |
| 154 | if (m_world->IsLocked() == true) |
| 155 | { |
| 156 | return NULL; |
| 157 | } |
| 158 | |
| 159 | b2BlockAllocator* allocator = &m_world->m_blockAllocator; |
| 160 | |
| 161 | void* memory = allocator->Allocate(sizeof(b2Fixture)); |
| 162 | b2Fixture* fixture = new (memory) b2Fixture; |
| 163 | fixture->Create(allocator, this, def); |
| 164 | |
| 165 | if (m_flags & e_activeFlag) |
| 166 | { |
| 167 | b2BroadPhase* broadPhase = &m_world->m_contactManager.m_broadPhase; |
| 168 | fixture->CreateProxies(broadPhase, m_xf); |
| 169 | } |
| 170 | |
| 171 | fixture->m_next = m_fixtureList; |
| 172 | m_fixtureList = fixture; |
| 173 | ++m_fixtureCount; |
| 174 | |
| 175 | fixture->m_body = this; |
| 176 | |
| 177 | // Adjust mass properties if needed. |
| 178 | if (fixture->m_density > 0.0f) |
| 179 | { |
| 180 | ResetMassData(); |
| 181 | } |
| 182 | |
| 183 | // Let the world know we have a new fixture. This will cause new contacts |
| 184 | // to be created at the beginning of the next time step. |
| 185 | m_world->m_flags |= b2World::e_newFixture; |
| 186 | |
| 187 | return fixture; |
| 188 | } |
| 189 | |
| 190 | b2Fixture* b2Body::CreateFixture(const b2Shape* shape, float32 density) |
| 191 | { |
no test coverage detected