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

Function b2CreateShapeInternal

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

Source from the content-addressed store, hash-verified

57}
58
59static b2Shape* b2CreateShapeInternal( b2World* world, b2Body* body, b2Transform transform, const b2ShapeDef* def,
60 const void* geometry, b2ShapeType shapeType )
61{
62 int shapeId = b2AllocId( &world->shapeIdPool );
63
64 if ( shapeId == world->shapes.count )
65 {
66 b2ShapeArray_Push( &world->shapes, ( b2Shape ){ 0 } );
67 }
68 else
69 {
70 B2_ASSERT( world->shapes.data[shapeId].id == B2_NULL_INDEX );
71 }
72
73 b2Shape* shape = b2ShapeArray_Get( &world->shapes, shapeId );
74
75 switch ( shapeType )
76 {
77 case b2_capsuleShape:
78 shape->capsule = *(const b2Capsule*)geometry;
79 break;
80
81 case b2_circleShape:
82 shape->circle = *(const b2Circle*)geometry;
83 break;
84
85 case b2_polygonShape:
86 shape->polygon = *(const b2Polygon*)geometry;
87 break;
88
89 case b2_segmentShape:
90 shape->segment = *(const b2Segment*)geometry;
91 break;
92
93 case b2_chainSegmentShape:
94 shape->chainSegment = *(const b2ChainSegment*)geometry;
95 break;
96
97 default:
98 B2_ASSERT( false );
99 break;
100 }
101
102 shape->id = shapeId;
103 shape->bodyId = body->id;
104 shape->type = shapeType;
105 shape->density = def->density;
106 shape->friction = def->material.friction;
107 shape->restitution = def->material.restitution;
108 shape->rollingResistance = def->material.rollingResistance;
109 shape->tangentSpeed = def->material.tangentSpeed;
110 shape->userMaterialId = def->material.userMaterialId;
111 shape->filter = def->filter;
112 shape->userData = def->userData;
113 shape->customColor = def->material.customColor;
114 shape->enlargedAABB = false;
115 shape->enableSensorEvents = def->enableSensorEvents;
116 shape->enableContactEvents = def->enableContactEvents;

Callers 2

b2CreateShapeFunction · 0.85
b2CreateChainFunction · 0.85

Calls 4

b2AllocIdFunction · 0.85
b2GetShapeCentroidFunction · 0.85
b2CreateShapeProxyFunction · 0.85
b2ValidateSolverSetsFunction · 0.85

Tested by

no test coverage detected