void StepSW::_check_suspend(BodySW *p_island,float p_delta) { bool can_sleep=true; BodySW *b = p_island; while(b) { if (b->get_mode()==PhysicsServer::BODY_MODE_STATIC) continue; //ignore for static if (!b->sleep_test(p_delta)) can_sleep=false; b=b->get_island_next(); } //put all to sleep or wake up everyoen b = p_island; while(b) { if (b->get_mode()==PhysicsServer::BODY_MODE_STATIC) continue; //ignore for static bool active = b->is_active(); if (active==can_sleep) b->set_active(!can_sleep); b=b->get_island_next(); } }
PhysicsServer::BodyMode PhysicsServerSW::body_get_mode(RID p_body) const { BodySW *body = body_owner.get(p_body); ERR_FAIL_COND_V(!body,BODY_MODE_STATIC); return body->get_mode(); };
void StepSW::_populate_island(BodySW* p_body,BodySW** p_island,ConstraintSW **p_constraint_island) { p_body->set_island_step(_step); p_body->set_island_next(*p_island); *p_island=p_body; for(Map<ConstraintSW*,int>::Element *E=p_body->get_constraint_map().front();E;E=E->next()) { ConstraintSW *c=(ConstraintSW*)E->key(); if (c->get_island_step()==_step) continue; //already processed c->set_island_step(_step); c->set_island_next(*p_constraint_island); *p_constraint_island=c; for(int i=0;i<c->get_body_count();i++) { if (i==E->get()) continue; BodySW *b = c->get_body_ptr()[i]; if (b->get_island_step()==_step || b->get_mode()==PhysicsServer::BODY_MODE_STATIC) continue; //no go _populate_island(c->get_body_ptr()[i],p_island,p_constraint_island); } } }
_FORCE_INLINE_ static bool _match_object_type_query(CollisionObjectSW *p_object, uint32_t p_layer_mask, uint32_t p_type_mask) { if ((p_object->get_layer_mask()&p_layer_mask)==0) return false; if (p_object->get_type()==CollisionObjectSW::TYPE_AREA && !(p_type_mask&PhysicsDirectSpaceState::TYPE_MASK_AREA)) return false; BodySW *body = static_cast<BodySW*>(p_object); return (1<<body->get_mode())&p_type_mask; }