| 161 | } |
| 162 | |
| 163 | static b2ShapeId b2CreateShape( b2BodyId bodyId, const b2ShapeDef* def, const void* geometry, b2ShapeType shapeType ) |
| 164 | { |
| 165 | B2_CHECK_DEF( def ); |
| 166 | B2_ASSERT( b2IsValidFloat( def->density ) && def->density >= 0.0f ); |
| 167 | B2_ASSERT( b2IsValidFloat( def->material.friction ) && def->material.friction >= 0.0f ); |
| 168 | B2_ASSERT( b2IsValidFloat( def->material.restitution ) && def->material.restitution >= 0.0f ); |
| 169 | B2_ASSERT( b2IsValidFloat( def->material.rollingResistance ) && def->material.rollingResistance >= 0.0f ); |
| 170 | B2_ASSERT( b2IsValidFloat( def->material.tangentSpeed ) ); |
| 171 | |
| 172 | b2World* world = b2GetWorldLocked( bodyId.world0 ); |
| 173 | if ( world == NULL ) |
| 174 | { |
| 175 | return ( b2ShapeId ){ 0 }; |
| 176 | } |
| 177 | |
| 178 | b2Body* body = b2GetBodyFullId( world, bodyId ); |
| 179 | b2Transform transform = b2GetBodyTransformQuick( world, body ); |
| 180 | |
| 181 | b2Shape* shape = b2CreateShapeInternal( world, body, transform, def, geometry, shapeType ); |
| 182 | |
| 183 | if ( def->updateBodyMass == true ) |
| 184 | { |
| 185 | b2UpdateBodyMassData( world, body ); |
| 186 | } |
| 187 | |
| 188 | b2ValidateSolverSets( world ); |
| 189 | |
| 190 | b2ShapeId id = { shape->id + 1, bodyId.world0, shape->generation }; |
| 191 | return id; |
| 192 | } |
| 193 | |
| 194 | b2ShapeId b2CreateCircleShape( b2BodyId bodyId, const b2ShapeDef* def, const b2Circle* circle ) |
| 195 | { |
no test coverage detected