void cpSpaceRemoveStaticShape(cpSpace *space, cpShape *shape) { cpAssertHard(cpSpaceContainsShape(space, shape), "Cannot remove a static or sleeping shape that was not added to the space. (Removed twice maybe?)"); cpAssertSpaceUnlocked(space); cpBody *body = shape->body; if(cpBodyIsStatic(body)) cpBodyActivateStatic(body, shape); cpBodyRemoveShape(body, shape); cpSpaceFilterArbiters(space, body, shape); cpSpatialIndexRemove(space->staticShapes, shape, shape->hashid); shape->space = NULL; }
void cpSpaceRemoveShape(cpSpace *space, cpShape *shape) { cpBody *body = shape->body; cpAssertHard(cpSpaceContainsShape(space, shape), "Cannot remove a shape that was not added to the space. (Removed twice maybe?)"); cpAssertSpaceUnlocked(space); cpBool isStatic = (cpBodyGetType(body) == CP_BODY_TYPE_STATIC); if(isStatic){ cpBodyActivateStatic(body, shape); } else { cpBodyActivate(body); } cpBodyRemoveShape(body, shape); cpSpaceFilterArbiters(space, body, shape); cpSpatialIndexRemove(isStatic ? space->staticShapes : space->dynamicShapes, shape, shape->hashid); shape->space = NULL; shape->hashid = 0; }
void cpSpaceRemoveShape(cpSpace *space, cpShape *shape) { cpBody *body = shape->body; if(cpBodyIsStatic(body)){ cpSpaceRemoveStaticShape(space, shape); return; } cpBodyActivate(body); cpAssertSpaceUnlocked(space); cpAssertWarn(cpHashSetFind(space->activeShapes->handleSet, shape->hashid, shape), "Cannot remove a shape that was not added to the space. (Removed twice maybe?)"); cpBodyRemoveShape(body, shape); removalContext context = {space, shape}; cpHashSetFilter(space->contactSet, (cpHashSetFilterFunc)contactSetFilterRemovedShape, &context); cpSpaceHashRemove(space->activeShapes, shape, shape->hashid); }