Exemplo n.º 1
0
void Camera::_notification(int p_what) {

	switch(p_what) {
	
		case NOTIFICATION_ENTER_WORLD: {


			bool first_camera = get_viewport()->_camera_add(this);
			if (!get_tree()->is_node_being_edited(this) && (current || first_camera))
				make_current();


		} break;			
		case NOTIFICATION_TRANSFORM_CHANGED: {
		
			_request_camera_update();
		} break;
		case NOTIFICATION_EXIT_WORLD: {
		
			if (!get_tree()->is_node_being_edited(this)) {
				if (is_current()) {
					clear_current();
					current=true; //keep it true

				} else {
					current=false;
				}
			}

			get_viewport()->_camera_remove(this);


		} break;
		case NOTIFICATION_BECAME_CURRENT: {
			if (get_world().is_valid()) {
				get_world()->_register_camera(this);
			}
		} break;
		case NOTIFICATION_LOST_CURRENT: {
			if (get_world().is_valid()) {
				get_world()->_remove_camera(this);
			}
		} break;

	
	}

}
Exemplo n.º 2
0
void Camera::_notification(int p_what) {

	switch(p_what) {
	
		case NOTIFICATION_ENTER_WORLD: {

			viewport_ptr=NULL;

			{ //find viewport stuff
				Node *parent=get_parent();

				while(parent) {

					Viewport* viewport = parent->cast_to<Viewport>();

					if (viewport) {
						viewport_ptr=viewport;
						break;
					}
					parent=parent->get_parent();
				}

			}

			if (viewport_ptr)
				viewport_ptr->cameras.insert(this);
			if (current)
				make_current();

		} break;			
		case NOTIFICATION_TRANSFORM_CHANGED: {
		
			_request_camera_update();
		} break;
		case NOTIFICATION_EXIT_WORLD: {
		
			if (is_current()) {
				clear_current();
				current=true; //keep it true

			} else {
				current=false;
			}
			if (viewport_ptr)
				viewport_ptr->cameras.erase(this);
			viewport_ptr=NULL;

		} break;
		case NOTIFICATION_BECAME_CURRENT: {
			if (get_world().is_valid()) {
				get_world()->_register_camera(this);
			}
		} break;
		case NOTIFICATION_LOST_CURRENT: {
			if (get_world().is_valid()) {
				get_world()->_remove_camera(this);
			}
		} break;

	
	}

}