Skip to content

Commit 28adacf

Browse files
authored
Fix default chain def (erincatto#878)
Fixes some sample crashes and should make using the new surface material easier. Fix body destruction handling of chain data.
1 parent 73324a7 commit 28adacf

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/body.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,7 @@ void b2DestroyBody( b2BodyId bodyId )
396396
{
397397
b2ChainShape* chain = b2ChainShapeArray_Get( &world->chainShapes, chainId );
398398

399-
b2Free( chain->shapeIndices, chain->count * sizeof( int ) );
400-
chain->shapeIndices = NULL;
399+
b2FreeChainData( chain );
401400

402401
// Return chain to free list.
403402
b2FreeId( &world->chainIdPool, chainId );

src/types.c

+6
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,13 @@ b2SurfaceMaterial b2DefaultSurfaceMaterial( void )
7474

7575
b2ChainDef b2DefaultChainDef( void )
7676
{
77+
static b2SurfaceMaterial defaultMaterial = {
78+
.friction = 0.6f,
79+
};
80+
7781
b2ChainDef def = { 0 };
82+
def.materials = &defaultMaterial;
83+
def.materialCount = 1;
7884
def.filter = b2DefaultFilter();
7985
def.internalValue = B2_SECRET_COOKIE;
8086
return def;

0 commit comments

Comments
 (0)