Пример #1
0
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);
}
Пример #2
0
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();
}
Пример #3
0
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);
}
Пример #4
0
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();
	}


};