MCPcopy Create free account
hub / github.com/defold/defold / b2CreateShape

Function b2CreateShape

external/box2d/Box2D/src/shape.c:163–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161}
162
163static 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
194b2ShapeId b2CreateCircleShape( b2BodyId bodyId, const b2ShapeDef* def, const b2Circle* circle )
195{

Callers 4

b2CreateCircleShapeFunction · 0.85
b2CreateCapsuleShapeFunction · 0.85
b2CreatePolygonShapeFunction · 0.85
b2CreateSegmentShapeFunction · 0.85

Calls 7

b2IsValidFloatFunction · 0.85
b2GetWorldLockedFunction · 0.85
b2GetBodyFullIdFunction · 0.85
b2GetBodyTransformQuickFunction · 0.85
b2CreateShapeInternalFunction · 0.85
b2UpdateBodyMassDataFunction · 0.85
b2ValidateSolverSetsFunction · 0.85

Tested by

no test coverage detected