static inline void mergeBodies(cpSpace *space, cpArray *components, cpArray *rogueBodies, cpBody *a, cpBody *b) { // Ignore connections to static bodies if(cpBodyIsStatic(a) || cpBodyIsStatic(b)) return; cpBody *a_root = componentNodeRoot(a); cpBody *b_root = componentNodeRoot(b); cpBool a_sleep = cpBodyIsSleeping(a_root); cpBool b_sleep = cpBodyIsSleeping(b_root); if(a_sleep && b_sleep){ return; } else if(a_sleep || b_sleep){ componentActivate(a_root); componentActivate(b_root); } // Add any rogue bodies found to the list and reset the idle time of anything they touch. if(cpBodyIsRogue(a)){ cpArrayPush(rogueBodies, a); b->node.idleTime = 0.0f; } if(cpBodyIsRogue(b)){ cpArrayPush(rogueBodies, b); a->node.idleTime = 0.0f; } componentNodeMerge(a_root, b_root); }
static inline void mergeBodies(cpSpace *space, cpArray *components, cpArray *rogueBodies, cpBody *a, cpBody *b) { // Don't merge with the static body if(cpBodyIsStatic(a) || cpBodyIsStatic(b)) return; cpBody *a_root = componentNodeRoot(a); cpBody *b_root = componentNodeRoot(b); cpBool a_sleep = cpBodyIsSleeping(a_root); cpBool b_sleep = cpBodyIsSleeping(b_root); if(a_sleep && b_sleep){ return; } else if(a_sleep || b_sleep){ componentActivate(a_root); componentActivate(b_root); } // Add any rogue bodies (bodies not added to the space) if(!a->space) cpArrayPush(rogueBodies, a); if(!b->space) cpArrayPush(rogueBodies, b); componentNodeMerge(a_root, b_root); }
void cpBodyActivate(cpBody *body) { if(!cpBodyIsRogue(body)){ body->node.idleTime = 0.0f; componentActivate(componentNodeRoot(body)); } }
void cpBodyActivate(cpBody *body) { // Force the body to wake up even if it's not in a currently sleeping component // Like a body resting on or jointed to a rogue body. body->node.idleTime = 0.0f; cpBody *root = componentNodeRoot(body); if(root) componentActivate(root); }
void cpBodyActivate(cpBody *body) { componentActivate(componentNodeRoot(body)); }