I'm using Chipmunk 6.0.1 in C and my use case is in this particular order (forgive my short-hand syntax):
Code: Select all
{
shape[i] = cpPolyShapeNew(NULL, ...); // create multiple shapes without a body
}
body = cpSpaceAddBody(...); // create a body later
{
cpShapeSetBody(shape[i], body) // set them to be part of the same body
cpSpaceAddShape(shape[i]) // add them to the space
}
However, I got a SIGSEGV and tracked it down to cpSpaceAddBody() calling an assertion cpShapeActive() which in the private API reads like the following around line 105 (chipmunk_private.h, 6.0.3):
Code: Select all
static inline cpBool
cpShapeActive(cpShape *shape)
{
return shape->prev || shape->body->shapeList == shape;
}
Code: Select all
static inline cpBool
cpShapeActive(cpShape *shape)
{
return shape->prev || (shape->body && shape->body->shapeList == shape);
}
Best,
Nikhil