// This example is pulled from the Plink demo.
if(ChipmunkDemoRightDown){
// Find the shape under the mouse.
cpShape *nearest = cpSpaceNearestPointQueryNearest(space, ChipmunkDemoMouse, 0.0, GRABABLE_MASK_BIT, CP_NO_GROUP, NULL);
if(nearest){
cpBody *body = cpShapeGetBody(nearest);
if(cpBodyIsStatic(body)){
// If the body is static, convert it to dynamic and add it to the space.
cpSpaceConvertBodyToDynamic(space, body, pentagon_mass, pentagon_moment);
cpSpaceAddBody(space, body);
} else {
// If the body is dynamic, remove it from the space and convert it to static.
cpSpaceRemoveBody(space, body);
cpSpaceConvertBodyToStatic(space, body);
}
}
}