Skip to content

Commit

Permalink
Fix default chain def (#878)
Browse files Browse the repository at this point in the history
Fixes some sample crashes and should make using the new surface material
easier.

Fix body destruction handling of chain data.
  • Loading branch information
erincatto authored Jan 27, 2025
1 parent 73324a7 commit 28adacf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/body.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,7 @@ void b2DestroyBody( b2BodyId bodyId )
{
b2ChainShape* chain = b2ChainShapeArray_Get( &world->chainShapes, chainId );

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

// Return chain to free list.
b2FreeId( &world->chainIdPool, chainId );
Expand Down
6 changes: 6 additions & 0 deletions src/types.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,13 @@ b2SurfaceMaterial b2DefaultSurfaceMaterial( void )

b2ChainDef b2DefaultChainDef( void )
{
static b2SurfaceMaterial defaultMaterial = {
.friction = 0.6f,
};

b2ChainDef def = { 0 };
def.materials = &defaultMaterial;
def.materialCount = 1;
def.filter = b2DefaultFilter();
def.internalValue = B2_SECRET_COOKIE;
return def;
Expand Down

0 comments on commit 28adacf

Please sign in to comment.