Example #1
0
void Listener::_notification(int p_what) {

	switch (p_what) {

		case NOTIFICATION_ENTER_WORLD: {
			bool first_listener = get_viewport()->_listener_add(this);
			if (!get_tree()->is_node_being_edited(this) && (current || first_listener))
				make_current();
		} break;
		case NOTIFICATION_TRANSFORM_CHANGED: {
			_request_listener_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()->_listener_remove(this);

		} break;
	}
}
Example #2
0
static void test_addNodeInTree_NullIn() {
    before();

    GNode *tree = NULL;
    add_node_in_tree(tree, NULL);
    assert_tree_is_null("Add node in tree ─ Tree is null", tree);

// THIS IS THE STRUCTURE:
//
// test-dir (3 children)
//├─ bepa.png
//├─ cepa.jpg
//└─ epa.png

    GNode *expected = get_tree(SINGLE_FILE, FALSE, FALSE);

    add_node_in_tree(tree, expected);
    assert_tree_is_null("Add node in tree ─ Tree is null", tree);

    tree = get_tree(SINGLE_FILE, FALSE, FALSE);
    add_node_in_tree(tree, NULL);
    assert_trees_equal("Add node in tree ─ Node is null", tree, expected);


    GNode *node_without_data = g_node_new(NULL);
    add_node_in_tree(tree, node_without_data);
    assert_trees_equal("Add node in tree ─ Node is null", tree, expected);


    free_whole_tree(tree);
    free_whole_tree(expected);
    free_whole_tree(node_without_data);
    after();
}
Example #3
0
void NavigationPolygonInstance::set_enabled(bool p_enabled) {

	if (enabled==p_enabled)
		return;
	enabled=p_enabled;

	if (!is_inside_tree())
		return;

	if (!enabled) {

		if (nav_id!=-1) {
			navigation->navpoly_remove(nav_id);
			nav_id=-1;
		}
	} else {

		if (navigation) {

			if (navpoly.is_valid()) {

				nav_id = navigation->navpoly_create(navpoly,get_relative_transform_to_parent(navigation),this);
			}
		}

	}

	if (get_tree()->is_editor_hint() || get_tree()->is_debugging_navigation_hint())
		update();

	//update_gizmo();
}
Example #4
0
void NavigationMeshInstance::_notification(int p_what) {

	switch (p_what) {
		case NOTIFICATION_ENTER_TREE: {

			Spatial *c = this;
			while (c) {

				navigation = c->cast_to<Navigation>();
				if (navigation) {

					if (enabled && navmesh.is_valid()) {

						nav_id = navigation->navmesh_create(navmesh, get_relative_transform(navigation), this);
					}
					break;
				}

				c = c->get_parent_spatial();
			}

			if (navmesh.is_valid() && get_tree()->is_debugging_navigation_hint()) {

				MeshInstance *dm = memnew(MeshInstance);
				dm->set_mesh(navmesh->get_debug_mesh());
				if (is_enabled()) {
					dm->set_material_override(get_tree()->get_debug_navigation_material());
				} else {
					dm->set_material_override(get_tree()->get_debug_navigation_disabled_material());
				}
				add_child(dm);
				debug_view = dm;
			}

		} break;
		case NOTIFICATION_TRANSFORM_CHANGED: {

			if (navigation && nav_id != -1) {
				navigation->navmesh_set_transform(nav_id, get_relative_transform(navigation));
			}

		} break;
		case NOTIFICATION_EXIT_TREE: {

			if (navigation) {

				if (nav_id != -1) {
					navigation->navmesh_remove(nav_id);
					nav_id = -1;
				}
			}

			if (debug_view) {
				debug_view->queue_delete();
				debug_view = NULL;
			}
			navigation = NULL;
		} break;
	}
}
Example #5
0
void Camera2D::_update_scroll() {

	if (!is_inside_tree())
		return;

	if (get_tree()->is_editor_hint()) {
		update(); //will just be drawn
		return;
	}

	if (current) {

		ERR_FAIL_COND(custom_viewport && !ObjectDB::get_instance(custom_viewport_id));

		Matrix32 xform = get_camera_transform();

		if (viewport) {
			viewport->set_canvas_transform(xform);
		}

		Size2 screen_size = viewport->get_visible_rect().size;
		Point2 screen_offset = (anchor_mode == ANCHOR_MODE_DRAG_CENTER ? (screen_size * 0.5) : Point2());

		get_tree()->call_group(SceneTree::GROUP_CALL_REALTIME, group_name, "_camera_moved", xform, screen_offset);
	};
}
Example #6
0
void RayCast::set_cast_to(const Vector3& p_point) {

	cast_to=p_point;
	if (is_inside_tree() && (get_tree()->is_editor_hint() || get_tree()->is_debugging_collisions_hint()))
		update_gizmo();

}
void ConnectDialog::popup_dialog(const String &p_for_signal, bool p_advanced) {

	advanced->set_pressed(p_advanced);
	from_signal->set_text(p_for_signal);
	error_label->add_color_override("font_color", get_color("error_color", "Editor"));
	vbc_right->set_visible(p_advanced);

	if (p_advanced) {

		popup_centered(Size2(900, 500) * EDSCALE);
		connect_to_label->set_text("Connect to Node:");
		tree->set_connect_to_script_mode(false);
		error_label->hide();
	} else {
		popup_centered(Size2(700, 500) * EDSCALE);
		connect_to_label->set_text("Connect to Script:");
		tree->set_connect_to_script_mode(true);

		if (!_find_first_script(get_tree()->get_edited_scene_root(), get_tree()->get_edited_scene_root())) {
			error_label->show();
		} else {
			error_label->hide();
		}
	}
}
Example #8
0
void RayCast2D::_notification(int p_what) {

	switch (p_what) {

		case NOTIFICATION_ENTER_TREE: {

			if (enabled && !get_tree()->is_editor_hint())
				set_fixed_process(true);
			else
				set_fixed_process(false);

			if (get_parent()->cast_to<PhysicsBody2D>()) {
				if (exclude_parent_body)
					exclude.insert(get_parent()->cast_to<PhysicsBody2D>()->get_rid());
				else
					exclude.erase(get_parent()->cast_to<PhysicsBody2D>()->get_rid());
			}
		} break;
		case NOTIFICATION_EXIT_TREE: {

			if (enabled)
				set_fixed_process(false);

		} break;

		case NOTIFICATION_DRAW: {

			if (!get_tree()->is_editor_hint() && !get_tree()->is_debugging_collisions_hint())
				break;
			Transform2D xf;
			xf.rotate(cast_to.angle());
			xf.translate(Vector2(cast_to.length(), 0));

			//Vector2 tip = Vector2(0,s->get_length());
			Color dcol = get_tree()->get_debug_collisions_color(); //0.9,0.2,0.2,0.4);
			draw_line(Vector2(), cast_to, dcol, 3);
			Vector<Vector2> pts;
			float tsize = 4;
			pts.push_back(xf.xform(Vector2(tsize, 0)));
			pts.push_back(xf.xform(Vector2(0, 0.707 * tsize)));
			pts.push_back(xf.xform(Vector2(0, -0.707 * tsize)));
			Vector<Color> cols;
			for (int i = 0; i < 3; i++)
				cols.push_back(dcol);

			draw_primitive(pts, cols, Vector<Vector2>()); //small arrow

		} break;

		case NOTIFICATION_FIXED_PROCESS: {

			if (!enabled)
				break;

			_update_raycast_state();

		} break;
	}
}
Example #9
0
void CollisionShape::_notification(int p_what) {

	switch(p_what) {

		case NOTIFICATION_ENTER_TREE: {
			unparenting=false;
			can_update_body=get_tree()->is_editor_hint();
			set_notify_local_transform(!can_update_body);

			if (get_tree()->is_debugging_collisions_hint()) {
				_create_debug_shape();
			}

			//indicator_instance = VisualServer::get_singleton()->instance_create2(indicator,get_world()->get_scenario());
		} break;
		case NOTIFICATION_TRANSFORM_CHANGED: {
		//	VisualServer::get_singleton()->instance_set_transform(indicator_instance,get_global_transform());
			if (can_update_body && updating_body) {
				_update_body();
			}
		} break;
		case NOTIFICATION_EXIT_TREE: {
		/*	if (indicator_instance.is_valid()) {
				VisualServer::get_singleton()->free(indicator_instance);
				indicator_instance=RID();
			}*/
			can_update_body=false;
			set_notify_local_transform(false);
			if (debug_shape) {
				debug_shape->queue_delete();
				debug_shape=NULL;
			}
		} break;
		case NOTIFICATION_UNPARENTED: {
			unparenting=true;
			if (can_update_body && updating_body)
				_update_body();
		} break;
		case NOTIFICATION_PARENTED: {
			if (can_update_body && updating_body)
				_update_body();
		} break;
		case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {

			if (!can_update_body && update_shape_index>=0) {

				CollisionObject *co = get_parent()->cast_to<CollisionObject>();
				if (co) {
					co->set_shape_transform(update_shape_index,get_transform());
				}
			}

		} break;

	}
}
Example #10
0
void CanvasItem::_notification(int p_what) {


	switch(p_what) {
		case NOTIFICATION_ENTER_TREE: {

			first_draw=true;
			pending_children_sort=false;
			if (get_parent()) {
				CanvasItem *ci = get_parent()->cast_to<CanvasItem>();
				if (ci)
					C=ci->children_items.push_back(this);
			}
			_enter_canvas();
			if (!block_transform_notify && !xform_change.in_list()) {
				get_tree()->xform_change_list.add(&xform_change);
			}
		} break;
		case NOTIFICATION_MOVED_IN_PARENT: {


			if (group!="") {
				get_tree()->call_group(SceneTree::GROUP_CALL_UNIQUE,group,"_raise_self");
			} else {
				CanvasItem *p = get_parent_item();
				ERR_FAIL_COND(!p);
				p->_queue_sort_children();
			}


		} break;
		case NOTIFICATION_EXIT_TREE: {
			if (xform_change.in_list())
				get_tree()->xform_change_list.remove(&xform_change);
			_exit_canvas();
			if (C) {
				get_parent()->cast_to<CanvasItem>()->children_items.erase(C);
				C=NULL;
			}
			global_invalid=true;
		} break;
		case NOTIFICATION_DRAW: {

		} break;
		case NOTIFICATION_TRANSFORM_CHANGED: {


		} break;
		case NOTIFICATION_VISIBILITY_CHANGED: {

			emit_signal(SceneStringNames::get_singleton()->visibility_changed);
		} break;

	}
}
Example #11
0
void Node::update_configuration_warning() {

#ifdef TOOLS_ENABLED
	if (!is_inside_tree())
		return;
	if (get_tree()->get_edited_scene_root() && (get_tree()->get_edited_scene_root()==this || get_tree()->get_edited_scene_root()->is_a_parent_of(this))) {
		get_tree()->emit_signal(SceneStringNames::get_singleton()->node_configuration_warning_changed,this);
	}
#endif

}
Example #12
0
void Timer::_notification(int p_what) {

	switch(p_what) {


		case NOTIFICATION_READY: {

			if (autostart) {
#ifdef TOOLS_ENABLED
				if (get_tree()->is_editor_hint() && get_tree()->get_edited_scene_root() && (get_tree()->get_edited_scene_root()==this || get_tree()->get_edited_scene_root()->is_a_parent_of(this)))
					break;
#endif
				start();
				autostart=false;
			}
		} break;
		case NOTIFICATION_PROCESS: {
			if (timer_process_mode == TIMER_PROCESS_FIXED || !is_processing())
				return;
			time_left -= get_process_delta_time();

			if (time_left<0) {
				if (!one_shot)
					//time_left=wait_time+time_left;
					time_left = wait_time;
				else
					stop();

				emit_signal("timeout");
			}

		} break;
		case NOTIFICATION_FIXED_PROCESS: {
			if (timer_process_mode == TIMER_PROCESS_IDLE || !is_fixed_processing())
				return;
			time_left -= get_fixed_process_delta_time();

			if (time_left<0) {
				if (!one_shot)
					//time_left = wait_time + time_left;
					time_left = wait_time;
				else
					stop();
				emit_signal("timeout");
			}

		} break;
	}
}
Example #13
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;

	
	}

}
Example #14
0
void CollisionShape::_notification(int p_what) {

	switch (p_what) {

		case NOTIFICATION_PARENTED: {
			parent = Object::cast_to<CollisionObject>(get_parent());
			if (parent) {
				owner_id = parent->create_shape_owner(this);
				if (shape.is_valid()) {
					parent->shape_owner_add_shape(owner_id, shape);
				}
				parent->shape_owner_set_transform(owner_id, get_transform());
				parent->shape_owner_set_disabled(owner_id, disabled);
			}
		} break;
		case NOTIFICATION_ENTER_TREE: {
			if (get_tree()->is_debugging_collisions_hint()) {
				_create_debug_shape();
			}

		} break;
		case NOTIFICATION_LOCAL_TRANSFORM_CHANGED: {
			if (parent) {
				parent->shape_owner_set_transform(owner_id, get_transform());
			}
		} break;
		case NOTIFICATION_UNPARENTED: {
			if (parent) {
				parent->remove_shape_owner(owner_id);
			}
			owner_id = 0;
			parent = NULL;
		} break;
	}
}
Example #15
0
void ColorPicker::_screen_input(const Ref<InputEvent> &ev) {

	Ref<InputEventMouseButton> bev = ev;

	if (bev.is_valid()) {

		if (bev->get_button_index() == BUTTON_LEFT && !bev->is_pressed()) {
			emit_signal("color_changed", color);
			screen->hide();
		}
	}

	Ref<InputEventMouseMotion> mev = ev;

	if (mev.is_valid()) {
		Viewport *r = get_tree()->get_root();
		if (!r->get_visible_rect().has_point(Point2(mev->get_global_position().x, mev->get_global_position().y)))
			return;
		Ref<Image> img = r->get_screen_capture();
		if (!img.is_null()) {
			last_capture = img;
			r->queue_screen_capture();
		}
		if (last_capture.is_valid() && !last_capture->empty()) {
			int pw = last_capture->get_format() == Image::FORMAT_RGBA8 ? 4 : 3;
			int ofs = (mev->get_global_position().y * last_capture->get_width() + mev->get_global_position().x) * pw;

			PoolVector<uint8_t>::Read r = last_capture->get_data().read();

			Color c(r[ofs + 0] / 255.0, r[ofs + 1] / 255.0, r[ofs + 2] / 255.0);

			set_pick_color(c);
		}
	}
}
Example #16
0
void Particles2D::_notification(int p_what) {

	if (p_what == NOTIFICATION_DRAW) {

		RID texture_rid;
		if (texture.is_valid())
			texture_rid = texture->get_rid();
		RID normal_rid;
		if (normal_map.is_valid())
			normal_rid = texture->get_rid();

		VS::get_singleton()->canvas_item_add_particles(get_canvas_item(), particles, texture_rid, normal_rid, h_frames, v_frames);

#ifdef TOOLS_ENABLED
		if (Engine::get_singleton()->is_editor_hint() && (this == get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->is_a_parent_of(this))) {

			draw_rect(visibility_rect, Color(0, 0.7, 0.9, 0.4), false);
		}
#endif
	}

	if (p_what == NOTIFICATION_PAUSED || p_what == NOTIFICATION_UNPAUSED) {
		if (can_process()) {
			VS::get_singleton()->particles_set_speed_scale(particles, speed_scale);
		} else {

			VS::get_singleton()->particles_set_speed_scale(particles, 0);
		}
	}

	if (p_what == NOTIFICATION_TRANSFORM_CHANGED) {
		_update_particle_emission_transform();
	}
}
Example #17
0
void Spatial::_propagate_transform_changed(Spatial *p_origin) {

	if (!is_inside_tree()) {
		return;
	}

	//	if (data.dirty&DIRTY_GLOBAL)
	//		return; //already dirty

	data.children_lock++;

	for (List<Spatial *>::Element *E = data.children.front(); E; E = E->next()) {

		if (E->get()->data.toplevel_active)
			continue; //don't propagate to a toplevel
		E->get()->_propagate_transform_changed(p_origin);
	}

	if (!data.ignore_notification && !xform_change.in_list()) {

		get_tree()->xform_change_list.add(&xform_change);
	}
	data.dirty |= DIRTY_GLOBAL;

	data.children_lock--;
}
Example #18
0
void Spatial::_notify_dirty() {

	if (!data.ignore_notification && !xform_change.in_list()) {

		get_tree()->xform_change_list.add(&xform_change);
	}
}
void Polygon2DEditor::_notification(int p_what) {

	switch(p_what) {

		case NOTIFICATION_READY: {

			button_create->set_icon( get_icon("Edit","EditorIcons"));
			button_edit->set_icon( get_icon("MovePoint","EditorIcons"));
			button_edit->set_pressed(true);
			button_uv->set_icon( get_icon("Uv","EditorIcons"));

			uv_button[UV_MODE_EDIT_POINT]->set_icon(get_icon("ToolSelect","EditorIcons"));
			uv_button[UV_MODE_MOVE]->set_icon(get_icon("ToolMove","EditorIcons"));
			uv_button[UV_MODE_ROTATE]->set_icon(get_icon("ToolRotate","EditorIcons"));
			uv_button[UV_MODE_SCALE]->set_icon(get_icon("ToolScale","EditorIcons"));

			b_snap_grid->set_icon( get_icon("Grid", "EditorIcons"));
			b_snap_enable->set_icon( get_icon("Snap", "EditorIcons"));
			uv_icon_zoom->set_texture( get_icon("Zoom", "EditorIcons"));

			get_tree()->connect("node_removed", this, "_node_removed");

		} break;
		case NOTIFICATION_FIXED_PROCESS: {


		} break;
	}

}
Example #20
0
void RayCast2D::set_cast_to(const Vector2& p_point) {

	cast_to=p_point;
	if (is_inside_tree() && get_tree()->is_editor_hint())
		update();

}
Example #21
0
void StreamPlayer::_notification(int p_what) {

	switch(p_what) {

		case NOTIFICATION_ENTER_TREE: {

			//set_idle_process(false); //don't annoy
			if (stream.is_valid() && !get_tree()->is_editor_hint()) {
				if (resume_pos>=0) {
					play(resume_pos);
					resume_pos=-1;
				} else if (autoplay) {
					play();
					autoplay = false; //this line fix autoplay issues
				}
			}

		} break;
		case NOTIFICATION_EXIT_TREE: {

			if (is_playing()) {
				resume_pos=get_pos();
			}
			stop(); //wathever it may be doing, stop
		} break;
	}
}
void MeshInstanceEditor::_create_outline_mesh() {

    Ref<Mesh> mesh = node->get_mesh();
    if (mesh.is_null()) {
        err_dialog->set_text(TTR("MeshInstance lacks a Mesh!"));
        err_dialog->popup_centered_minsize();
        return;
    }

    Ref<Mesh> mesho = mesh->create_outline(outline_size->get_val());

    if (mesho.is_null()) {
        err_dialog->set_text(TTR("Could not create outline!"));
        err_dialog->popup_centered_minsize();
        return;
    }

    MeshInstance *mi = memnew( MeshInstance );
    mi->set_mesh(mesho);
    Node *owner=node->get_owner();
    if (get_tree()->get_edited_scene_root()==node) {
        owner=node;
    }

    UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();

    ur->create_action(TTR("Create Outline"));

    ur->add_do_method(node,"add_child",mi);
    ur->add_do_method(mi,"set_owner",owner);

    ur->add_do_reference(mi);
    ur->add_undo_method(node,"remove_child",mi);
    ur->commit_action();
}
void Polygon3DEditor::_notification(int p_what) {

	switch (p_what) {

		case NOTIFICATION_READY: {

			button_create->set_icon(get_icon("Edit", "EditorIcons"));
			button_edit->set_icon(get_icon("MovePoint", "EditorIcons"));
			button_edit->set_pressed(true);
			get_tree()->connect("node_removed", this, "_node_removed");

		} break;
		case NOTIFICATION_PROCESS: {
			if (!node) {
				return;
			}

			if (_get_depth() != prev_depth) {
				_polygon_draw();
				prev_depth = _get_depth();
			}

		} break;
	}
}
Example #24
0
void ProjectManager::_notification(int p_what) {

	if (p_what==NOTIFICATION_ENTER_TREE) {

		get_tree()->set_editor_hint(true);
	}
}
Example #25
0
void Path2D::_curve_changed() {


	if (is_inside_tree() && get_tree()->is_editor_hint())
		update();

}
Example #26
0
	void input_system::load_bindings()
	{
		auto config = config_system();
		const auto tree = config.get_tree(config::type::input);

		for (auto const & device_node : tree)
		{
			const string & device = device_node.first;
			const auto & input_types = device_node.second;

			for (auto const & input_node : input_types)
			{
				const string & type = input_node.first;
				const auto & codes_tree = input_node.second;

				for (auto const & code_node : codes_tree)
				{
					const string & code = code_node.first;
					const string & name = code_node.second.get_value<string>();

					if (device == "keyboard")
					{
						keyboard_binds.push_back(binding(code, type, name));
					}
					else if (device == "mouse")
					{
						mouse_binds.push_back(binding(code, type, name));
					}
				}
			}
		}
	}
Example #27
0
bool Camera::_get(const StringName& p_name,Variant &r_ret) const {

	if (p_name=="projection") {
		r_ret= mode;
	} else if (p_name=="fov" || p_name=="fovy" || p_name=="fovx")
		r_ret= fov;
	else if (p_name=="size" || p_name=="sizex" || p_name=="sizey")
		r_ret= size;
	else if (p_name=="near")
		r_ret= near;
	else if (p_name=="far")
		r_ret= far;
	else if (p_name=="keep_aspect")
		r_ret= int(keep_aspect);
	else if (p_name=="current") {

		if (is_inside_tree() && get_tree()->is_node_being_edited(this)) {
			r_ret=current;
		} else {
			r_ret=is_current();
		}
	} else if (p_name=="visible_layers") {
		r_ret=get_visible_layers();
	} else if (p_name=="h_offset") {
		r_ret=get_h_offset();
	} else if (p_name=="v_offset") {
		r_ret=get_v_offset();
	} else if (p_name=="environment") {
		r_ret=get_environment();
	} else
		return false;

	return true;
}
Example #28
0
void VisibilityNotifier2D::_notification(int p_what) {


	switch(p_what) {
		case NOTIFICATION_ENTER_TREE: {

			//get_world_2d()->
			get_world_2d()->_register_notifier(this,get_global_transform().xform(rect));
		} break;
		case NOTIFICATION_TRANSFORM_CHANGED: {

			//get_world_2d()->
			get_world_2d()->_update_notifier(this,get_global_transform().xform(rect));
		} break;
		case NOTIFICATION_DRAW: {

			if (get_tree()->is_editor_hint()) {

				draw_rect(rect,Color(1,0.5,1,0.2));
			}
		} break;
		case NOTIFICATION_EXIT_TREE: {

			get_world_2d()->_remove_notifier(this);
		} break;
	}
}
Example #29
0
void ColorPicker::_screen_input(const Ref<InputEvent> &p_event) {

	Ref<InputEventMouseButton> bev = p_event;

	if (bev.is_valid()) {

		if (bev->get_button_index() == BUTTON_LEFT && !bev->is_pressed()) {
			emit_signal("color_changed", color);
			screen->hide();
		}
	}

	Ref<InputEventMouseMotion> mev = p_event;

	if (mev.is_valid()) {
		Viewport *r = get_tree()->get_root();
		if (!r->get_visible_rect().has_point(Point2(mev->get_global_position().x, mev->get_global_position().y)))
			return;
		Ref<Image> img = r->get_texture()->get_data();
		if (img.is_valid() && !img->empty()) {
			img->lock();
			Vector2 ofs = mev->get_global_position() - r->get_visible_rect().get_position();
			Color c = img->get_pixel(ofs.x, r->get_visible_rect().size.height - ofs.y);
			img->unlock();
			set_pick_color(c);
		}
	}
}
Example #30
0
bool Node::can_process() const {

	ERR_FAIL_COND_V( !is_inside_tree(), false );

	if (get_tree()->is_paused()) {

		if (data.pause_mode==PAUSE_MODE_STOP)
			return false;
		if (data.pause_mode==PAUSE_MODE_PROCESS)
			return true;
		if (data.pause_mode==PAUSE_MODE_INHERIT) {

			if (!data.pause_owner)
				return false; //clearly no pause owner by default

			if (data.pause_owner->data.pause_mode==PAUSE_MODE_PROCESS)
				return true;

			if (data.pause_owner->data.pause_mode==PAUSE_MODE_STOP)
				return false;
		}

	}

	return true;
}