void PhysicsServerSW::area_set_space_override_mode(RID p_area, AreaSpaceOverrideMode p_mode) { AreaSW *area = area_owner.get(p_area); ERR_FAIL_COND(!area); area->set_space_override_mode(p_mode); }
void PhysicsServerSW::area_set_area_monitor_callback(RID p_area, Object *p_receiver, const StringName &p_method) { AreaSW *area = area_owner.get(p_area); ERR_FAIL_COND(!area); area->set_area_monitor_callback(p_receiver ? p_receiver->get_instance_id() : 0, p_method); }
void PhysicsServerSW::area_set_monitorable(RID p_area,bool p_monitorable) { AreaSW *area = area_owner.get(p_area); ERR_FAIL_COND(!area); area->set_monitorable(p_monitorable); }
int PhysicsServerSW::area_get_shape_count(RID p_area) const { AreaSW *area = area_owner.get(p_area); ERR_FAIL_COND_V(!area, -1); return area->get_shape_count(); }
void PhysicsServerSW::area_set_collision_mask(RID p_area,uint32_t p_mask) { AreaSW *area = area_owner.get(p_area); ERR_FAIL_COND(!area); area->set_collision_mask(p_mask); }
void PhysicsServerSW::area_set_transform(RID p_area, const Transform& p_transform) { AreaSW *area = area_owner.get(p_area); ERR_FAIL_COND(!area); area->set_transform(p_transform); };
void PhysicsServerSW::area_remove_shape(RID p_area, int p_shape_idx) { AreaSW *area = area_owner.get(p_area); ERR_FAIL_COND(!area); area->remove_shape(p_shape_idx); }
RID PhysicsServerSW::area_create() { AreaSW *area = memnew( AreaSW ); RID rid = area_owner.make_rid(area); area->set_self(rid); return rid; };
Transform PhysicsServerSW::area_get_transform(RID p_area) const { AreaSW *area = area_owner.get(p_area); ERR_FAIL_COND_V(!area,Transform()); return area->get_transform(); };
bool PhysicsServerSW::area_is_ray_pickable(RID p_area) const { AreaSW *area = area_owner.get(p_area); ERR_FAIL_COND_V(!area, false); return area->is_ray_pickable(); }
void PhysicsServerSW::area_set_shape_disabled(RID p_area, int p_shape_idx, bool p_disabled) { AreaSW *area = area_owner.get(p_area); ERR_FAIL_COND(!area); ERR_FAIL_INDEX(p_shape_idx, area->get_shape_count()); area->set_shape_as_disabled(p_shape_idx, p_disabled); }
void PhysicsServerSW::area_clear_shapes(RID p_area) { AreaSW *area = area_owner.get(p_area); ERR_FAIL_COND(!area); while (area->get_shape_count()) area->remove_shape(0); }
void PhysicsServerSW::area_add_shape(RID p_area, RID p_shape, const Transform &p_transform) { AreaSW *area = area_owner.get(p_area); ERR_FAIL_COND(!area); ShapeSW *shape = shape_owner.get(p_shape); ERR_FAIL_COND(!shape); area->add_shape(shape, p_transform); }
RID PhysicsServerSW::area_get_shape(RID p_area, int p_shape_idx) const { AreaSW *area = area_owner.get(p_area); ERR_FAIL_COND_V(!area,RID()); ShapeSW *shape = area->get_shape(p_shape_idx); ERR_FAIL_COND_V(!shape,RID()); return shape->get_self(); }
RID PhysicsServerSW::area_get_space(RID p_area) const { AreaSW *area = area_owner.get(p_area); ERR_FAIL_COND_V(!area,RID()); SpaceSW *space = area->get_space(); if (!space) return RID(); return space->get_self(); };
void PhysicsServerSW::area_set_param(RID p_area, AreaParameter p_param, const Variant &p_value) { if (space_owner.owns(p_area)) { SpaceSW *space = space_owner.get(p_area); p_area = space->get_default_area()->get_self(); } AreaSW *area = area_owner.get(p_area); ERR_FAIL_COND(!area); area->set_param(p_param, p_value); };
ObjectID PhysicsServerSW::area_get_object_instance_id(RID p_area) const { if (space_owner.owns(p_area)) { SpaceSW *space = space_owner.get(p_area); p_area = space->get_default_area()->get_self(); } AreaSW *area = area_owner.get(p_area); ERR_FAIL_COND_V(!area, 0); return area->get_instance_id(); }
void PhysicsServerSW::area_attach_object_instance_id(RID p_area, ObjectID p_ID) { if (space_owner.owns(p_area)) { SpaceSW *space = space_owner.get(p_area); p_area = space->get_default_area()->get_self(); } AreaSW *area = area_owner.get(p_area); ERR_FAIL_COND(!area); area->set_instance_id(p_ID); }
void PhysicsServerSW::area_set_shape(RID p_area, int p_shape_idx, RID p_shape) { AreaSW *area = area_owner.get(p_area); ERR_FAIL_COND(!area); ShapeSW *shape = shape_owner.get(p_shape); ERR_FAIL_COND(!shape); ERR_FAIL_COND(!shape->is_configured()); area->set_shape(p_shape_idx, shape); }
Variant PhysicsServerSW::area_get_param(RID p_area,AreaParameter p_param) const { if (space_owner.owns(p_area)) { SpaceSW *space=space_owner.get(p_area); p_area=space->get_default_area()->get_self(); } AreaSW *area = area_owner.get(p_area); ERR_FAIL_COND_V(!area,Variant()); return area->get_param(p_param); };
void PhysicsServerSW::area_set_space(RID p_area, RID p_space) { AreaSW *area = area_owner.get(p_area); ERR_FAIL_COND(!area); SpaceSW *space=NULL; if (p_space.is_valid()) { space = space_owner.get(p_space); ERR_FAIL_COND(!space); } area->set_space(space); };
void SpaceSW::call_queries() { while (state_query_list.first()) { BodySW *b = state_query_list.first()->self(); state_query_list.remove(state_query_list.first()); b->call_queries(); } while (monitor_query_list.first()) { AreaSW *a = monitor_query_list.first()->self(); monitor_query_list.remove(monitor_query_list.first()); a->call_queries(); } }
void PhysicsServerSW::area_set_space(RID p_area, RID p_space) { AreaSW *area = area_owner.get(p_area); ERR_FAIL_COND(!area); SpaceSW *space = NULL; if (p_space.is_valid()) { space = space_owner.get(p_space); ERR_FAIL_COND(!space); } if (area->get_space() == space) return; //pointless area->clear_constraints(); area->set_space(space); };
RID PhysicsServerSW::space_create() { SpaceSW *space = memnew( SpaceSW ); RID id = space_owner.make_rid(space); space->set_self(id); RID area_id = area_create(); AreaSW *area = area_owner.get(area_id); ERR_FAIL_COND_V(!area,RID()); space->set_default_area(area); area->set_space(space); area->set_priority(-1); RID sgb = body_create(); body_set_space(sgb,id); body_set_mode(sgb,BODY_MODE_STATIC); space->set_static_global_body(sgb); return id; };
void PhysicsServerSW::free(RID p_rid) { if (shape_owner.owns(p_rid)) { ShapeSW *shape = shape_owner.get(p_rid); while(shape->get_owners().size()) { ShapeOwnerSW *so=shape->get_owners().front()->key(); so->remove_shape(shape); } shape_owner.free(p_rid); memdelete(shape); } else if (body_owner.owns(p_rid)) { BodySW *body = body_owner.get(p_rid); // if (body->get_state_query()) // _clear_query(body->get_state_query()); // if (body->get_direct_state_query()) // _clear_query(body->get_direct_state_query()); body->set_space(NULL); while( body->get_shape_count() ) { body->remove_shape(0); } while (body->get_constraint_map().size()) { RID self = body->get_constraint_map().front()->key()->get_self(); ERR_FAIL_COND(!self.is_valid()); free(self); } body_owner.free(p_rid); memdelete(body); } else if (area_owner.owns(p_rid)) { AreaSW *area = area_owner.get(p_rid); // if (area->get_monitor_query()) // _clear_query(area->get_monitor_query()); area->set_space(NULL); while( area->get_shape_count() ) { area->remove_shape(0); } area_owner.free(p_rid); memdelete(area); } else if (space_owner.owns(p_rid)) { SpaceSW *space = space_owner.get(p_rid); while(space->get_objects().size()) { CollisionObjectSW *co = (CollisionObjectSW *)space->get_objects().front()->get(); co->set_space(NULL); } active_spaces.erase(space); free(space->get_default_area()->get_self()); free(space->get_static_global_body()); space_owner.free(p_rid); memdelete(space); } else if (joint_owner.owns(p_rid)) { JointSW *joint = joint_owner.get(p_rid); for(int i=0;i<joint->get_body_count();i++) { joint->get_body_ptr()[i]->remove_constraint(joint); } joint_owner.free(p_rid); memdelete(joint); } else { ERR_EXPLAIN("Invalid ID"); ERR_FAIL(); } };