@@ -371,13 +371,15 @@ b2ChainId b2CreateChain( b2BodyId bodyId, const b2ChainDef* def )
371371 chainShape -> generation += 1 ;
372372 chainShape -> friction = def -> friction ;
373373 chainShape -> restitution = def -> restitution ;
374+ chainShape -> material = def -> material ;
374375
375376 body -> headChainId = chainId ;
376377
377378 b2ShapeDef shapeDef = b2DefaultShapeDef ();
378379 shapeDef .userData = def -> userData ;
379- shapeDef .restitution = def -> restitution ;
380380 shapeDef .friction = def -> friction ;
381+ shapeDef .restitution = def -> restitution ;
382+ shapeDef .material = def -> material ;
381383 shapeDef .filter = def -> filter ;
382384 shapeDef .customColor = def -> customColor ;
383385 shapeDef .enableContactEvents = false;
@@ -1417,6 +1419,34 @@ float b2Chain_GetRestitution( b2ChainId chainId )
14171419 return chainShape -> restitution ;
14181420}
14191421
1422+ void b2Chain_SetMaterial ( b2ChainId chainId , int material )
1423+ {
1424+ b2World * world = b2GetWorldLocked ( chainId .world0 );
1425+ if ( world == NULL )
1426+ {
1427+ return ;
1428+ }
1429+
1430+ b2ChainShape * chainShape = b2GetChainShape ( world , chainId );
1431+ chainShape -> material = material ;
1432+
1433+ int count = chainShape -> count ;
1434+
1435+ for ( int i = 0 ; i < count ; ++ i )
1436+ {
1437+ int shapeId = chainShape -> shapeIndices [i ];
1438+ b2Shape * shape = b2ShapeArray_Get ( & world -> shapes , shapeId );
1439+ shape -> material = material ;
1440+ }
1441+ }
1442+
1443+ int b2Chain_GetMaterial ( b2ChainId chainId )
1444+ {
1445+ b2World * world = b2GetWorld ( chainId .world0 );
1446+ b2ChainShape * chainShape = b2GetChainShape ( world , chainId );
1447+ return chainShape -> material ;
1448+ }
1449+
14201450int b2Shape_GetContactCapacity ( b2ShapeId shapeId )
14211451{
14221452 b2World * world = b2GetWorldLocked ( shapeId .world0 );
0 commit comments