You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-15 13:51:40 +00:00
Merge pull request #97081 from aXu-AP/uv-editor-without-polygon
Open UV editor in point editing mode if no points
This commit is contained in:
@@ -275,7 +275,11 @@ void Polygon2DEditor::_uv_edit_mode_select(int p_mode) {
|
|||||||
uv_button[UV_MODE_REMOVE_POLYGON]->hide();
|
uv_button[UV_MODE_REMOVE_POLYGON]->hide();
|
||||||
uv_button[UV_MODE_PAINT_WEIGHT]->hide();
|
uv_button[UV_MODE_PAINT_WEIGHT]->hide();
|
||||||
uv_button[UV_MODE_CLEAR_WEIGHT]->hide();
|
uv_button[UV_MODE_CLEAR_WEIGHT]->hide();
|
||||||
_uv_mode(UV_MODE_EDIT_POINT);
|
if (node->get_polygon().is_empty()) {
|
||||||
|
_uv_mode(UV_MODE_CREATE);
|
||||||
|
} else {
|
||||||
|
_uv_mode(UV_MODE_EDIT_POINT);
|
||||||
|
}
|
||||||
|
|
||||||
bone_scroll_main_vb->hide();
|
bone_scroll_main_vb->hide();
|
||||||
bone_paint_strength->hide();
|
bone_paint_strength->hide();
|
||||||
@@ -317,9 +321,16 @@ void Polygon2DEditor::_uv_edit_mode_select(int p_mode) {
|
|||||||
uv_edit_draw->queue_redraw();
|
uv_edit_draw->queue_redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Polygon2DEditor::_uv_edit_popup_show() {
|
||||||
|
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||||
|
undo_redo->connect("version_changed", callable_mp(this, &Polygon2DEditor::_update_available_modes));
|
||||||
|
}
|
||||||
|
|
||||||
void Polygon2DEditor::_uv_edit_popup_hide() {
|
void Polygon2DEditor::_uv_edit_popup_hide() {
|
||||||
EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "uv_editor", Rect2(uv_edit->get_position(), uv_edit->get_size()));
|
EditorSettings::get_singleton()->set_project_metadata("dialog_bounds", "uv_editor", Rect2(uv_edit->get_position(), uv_edit->get_size()));
|
||||||
_cancel_editing();
|
_cancel_editing();
|
||||||
|
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||||
|
undo_redo->disconnect("version_changed", callable_mp(this, &Polygon2DEditor::_update_available_modes));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Polygon2DEditor::_menu_option(int p_option) {
|
void Polygon2DEditor::_menu_option(int p_option) {
|
||||||
@@ -346,6 +357,7 @@ void Polygon2DEditor::_menu_option(int p_option) {
|
|||||||
uv_edit->popup_centered_ratio(0.85);
|
uv_edit->popup_centered_ratio(0.85);
|
||||||
}
|
}
|
||||||
_update_bone_list();
|
_update_bone_list();
|
||||||
|
_update_available_modes();
|
||||||
get_tree()->connect("process_frame", callable_mp(this, &Polygon2DEditor::_center_view), CONNECT_ONE_SHOT);
|
get_tree()->connect("process_frame", callable_mp(this, &Polygon2DEditor::_center_view), CONNECT_ONE_SHOT);
|
||||||
} break;
|
} break;
|
||||||
case UVEDIT_POLYGON_TO_UV: {
|
case UVEDIT_POLYGON_TO_UV: {
|
||||||
@@ -408,6 +420,7 @@ void Polygon2DEditor::_cancel_editing() {
|
|||||||
node->set_polygons(polygons_prev);
|
node->set_polygons(polygons_prev);
|
||||||
|
|
||||||
_update_polygon_editing_state();
|
_update_polygon_editing_state();
|
||||||
|
_update_available_modes();
|
||||||
} else if (uv_drag) {
|
} else if (uv_drag) {
|
||||||
uv_drag = false;
|
uv_drag = false;
|
||||||
if (uv_edit_mode[0]->is_pressed()) { // Edit UV.
|
if (uv_edit_mode[0]->is_pressed()) { // Edit UV.
|
||||||
@@ -566,6 +579,7 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
|
|||||||
uv_drag = false;
|
uv_drag = false;
|
||||||
uv_create = false;
|
uv_create = false;
|
||||||
|
|
||||||
|
_update_available_modes();
|
||||||
_uv_mode(UV_MODE_EDIT_POINT);
|
_uv_mode(UV_MODE_EDIT_POINT);
|
||||||
_menu_option(MODE_EDIT);
|
_menu_option(MODE_EDIT);
|
||||||
} else {
|
} else {
|
||||||
@@ -973,6 +987,23 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Polygon2DEditor::_update_available_modes() {
|
||||||
|
// Force point editing mode if there's no polygon yet.
|
||||||
|
if (node->get_polygon().is_empty()) {
|
||||||
|
if (!uv_edit_mode[1]->is_pressed()) {
|
||||||
|
uv_edit_mode[1]->set_pressed(true);
|
||||||
|
_uv_edit_mode_select(1);
|
||||||
|
}
|
||||||
|
uv_edit_mode[0]->set_disabled(true);
|
||||||
|
uv_edit_mode[2]->set_disabled(true);
|
||||||
|
uv_edit_mode[3]->set_disabled(true);
|
||||||
|
} else {
|
||||||
|
uv_edit_mode[0]->set_disabled(false);
|
||||||
|
uv_edit_mode[2]->set_disabled(false);
|
||||||
|
uv_edit_mode[3]->set_disabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Polygon2DEditor::_center_view() {
|
void Polygon2DEditor::_center_view() {
|
||||||
Size2 texture_size;
|
Size2 texture_size;
|
||||||
if (node->get_texture().is_valid()) {
|
if (node->get_texture().is_valid()) {
|
||||||
@@ -1324,6 +1355,7 @@ Polygon2DEditor::Polygon2DEditor() {
|
|||||||
add_child(uv_edit);
|
add_child(uv_edit);
|
||||||
uv_edit->connect(SceneStringName(confirmed), callable_mp(this, &Polygon2DEditor::_uv_edit_popup_hide));
|
uv_edit->connect(SceneStringName(confirmed), callable_mp(this, &Polygon2DEditor::_uv_edit_popup_hide));
|
||||||
uv_edit->connect("canceled", callable_mp(this, &Polygon2DEditor::_uv_edit_popup_hide));
|
uv_edit->connect("canceled", callable_mp(this, &Polygon2DEditor::_uv_edit_popup_hide));
|
||||||
|
uv_edit->connect("about_to_popup", callable_mp(this, &Polygon2DEditor::_uv_edit_popup_show));
|
||||||
|
|
||||||
VBoxContainer *uv_main_vb = memnew(VBoxContainer);
|
VBoxContainer *uv_main_vb = memnew(VBoxContainer);
|
||||||
uv_edit->add_child(uv_main_vb);
|
uv_edit->add_child(uv_main_vb);
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ class Polygon2DEditor : public AbstractPolygon2DEditor {
|
|||||||
|
|
||||||
void _cancel_editing();
|
void _cancel_editing();
|
||||||
void _update_polygon_editing_state();
|
void _update_polygon_editing_state();
|
||||||
|
void _update_available_modes();
|
||||||
|
|
||||||
void _center_view();
|
void _center_view();
|
||||||
void _update_zoom_and_pan(bool p_zoom_at_center);
|
void _update_zoom_and_pan(bool p_zoom_at_center);
|
||||||
@@ -157,6 +158,7 @@ class Polygon2DEditor : public AbstractPolygon2DEditor {
|
|||||||
void _set_snap_step_y(real_t p_val);
|
void _set_snap_step_y(real_t p_val);
|
||||||
|
|
||||||
void _uv_edit_mode_select(int p_mode);
|
void _uv_edit_mode_select(int p_mode);
|
||||||
|
void _uv_edit_popup_show();
|
||||||
void _uv_edit_popup_hide();
|
void _uv_edit_popup_hide();
|
||||||
void _bone_paint_selected(int p_index);
|
void _bone_paint_selected(int p_index);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user