diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_properties.cpp | 70 | ||||
-rw-r--r-- | editor/import/editor_scene_importer_gltf.cpp | 8 | ||||
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 14 | ||||
-rw-r--r-- | editor/plugins/tile_set_editor_plugin.cpp | 22 |
4 files changed, 74 insertions, 40 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index c3f0d1b712..2d50d25ff5 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -2980,7 +2980,16 @@ Variant EditorPropertyResource::get_drag_data_fw(const Point2 &p_point, Control } bool EditorPropertyResource::_is_drop_valid(const Dictionary &p_drag_data) const { - String allowed_type = base_type; + Vector<String> allowed_types = base_type.split(","); + int size = allowed_types.size(); + for (int i = 0; i < size; i++) { + String at = allowed_types[i].strip_edges(); + if (at == "StandardMaterial3D") { + allowed_types.append("Texture2D"); + } else if (at == "ShaderMaterial") { + allowed_types.append("Shader"); + } + } Dictionary drag_data = p_drag_data; @@ -2993,9 +3002,9 @@ bool EditorPropertyResource::_is_drop_valid(const Dictionary &p_drag_data) const } if (res.is_valid()) { - for (int i = 0; i < allowed_type.get_slice_count(","); i++) { - String at = allowed_type.get_slice(",", i).strip_edges(); - if (res.is_valid() && ClassDB::is_parent_class(res->get_class(), at)) { + for (int i = 0; i < allowed_types.size(); i++) { + String at = allowed_types[i].strip_edges(); + if (ClassDB::is_parent_class(res->get_class(), at)) { return true; } } @@ -3009,8 +3018,8 @@ bool EditorPropertyResource::_is_drop_valid(const Dictionary &p_drag_data) const String ftype = EditorFileSystem::get_singleton()->get_file_type(file); if (ftype != "") { - for (int i = 0; i < allowed_type.get_slice_count(","); i++) { - String at = allowed_type.get_slice(",", i).strip_edges(); + for (int i = 0; i < allowed_types.size(); i++) { + String at = allowed_types[i].strip_edges(); if (ClassDB::is_parent_class(ftype, at)) { return true; } @@ -3039,24 +3048,49 @@ void EditorPropertyResource::drop_data_fw(const Point2 &p_point, const Variant & res = drag_data["resource"]; } - if (res.is_valid()) { - emit_changed(get_edited_property(), res); - update_property(); - return; - } - - if (drag_data.has("type") && String(drag_data["type"]) == "files") { + if (!res.is_valid() && drag_data.has("type") && String(drag_data["type"]) == "files") { Vector<String> files = drag_data["files"]; if (files.size() == 1) { String file = files[0]; - RES file_res = ResourceLoader::load(file); - if (file_res.is_valid()) { - emit_changed(get_edited_property(), file_res); - update_property(); - return; + res = ResourceLoader::load(file); + } + } + + if (res.is_valid()) { + bool need_convert = true; + + Vector<String> allowed_types = base_type.split(","); + for (int i = 0; i < allowed_types.size(); i++) { + String at = allowed_types[i].strip_edges(); + if (ClassDB::is_parent_class(res->get_class(), at)) { + need_convert = false; + break; + } + } + + if (need_convert) { + for (int i = 0; i < allowed_types.size(); i++) { + String at = allowed_types[i].strip_edges(); + if (at == "StandardMaterial3D" && ClassDB::is_parent_class(res->get_class(), "Texture2D")) { + Ref<StandardMaterial3D> mat = memnew(StandardMaterial3D); + mat->set_texture(StandardMaterial3D::TextureParam::TEXTURE_ALBEDO, res); + res = mat; + break; + } + + if (at == "ShaderMaterial" && ClassDB::is_parent_class(res->get_class(), "Shader")) { + Ref<ShaderMaterial> mat = memnew(ShaderMaterial); + mat->set_shader(res); + res = mat; + break; + } } } + + emit_changed(get_edited_property(), res); + update_property(); + return; } } diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index 683db0e31d..bb144d2ed6 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -1229,10 +1229,14 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) { } } + mesh.blend_weights.resize(mesh.mesh->get_blend_shape_count()); + for (int32_t weight_i = 0; weight_i < mesh.blend_weights.size(); weight_i++) { + mesh.blend_weights.write[weight_i] = 0.0f; + } + if (d.has("weights")) { const Array &weights = d["weights"]; - ERR_FAIL_COND_V(mesh.mesh->get_blend_shape_count() != weights.size(), ERR_PARSE_ERROR); - mesh.blend_weights.resize(weights.size()); + ERR_FAIL_COND_V(mesh.blend_weights.size() != weights.size(), ERR_PARSE_ERROR); for (int j = 0; j < weights.size(); j++) { mesh.blend_weights.write[j] = weights[j]; } diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 44913abe8b..3c6556a310 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -2045,10 +2045,10 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { if ((b->get_alt() && !b->get_control()) || tool == TOOL_MOVE) { List<CanvasItem *> selection = _get_edited_canvas_items(); - // Remove not movable nodes + drag_selection.clear(); for (int i = 0; i < selection.size(); i++) { - if (!_is_node_movable(selection[i], true)) { - selection.erase(selection[i]); + if (_is_node_movable(selection[i], true)) { + drag_selection.push_back(selection[i]); } } @@ -2073,7 +2073,6 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { } drag_from = transform.affine_inverse().xform(b->get_position()); - drag_selection = selection; _save_canvas_item_state(drag_selection); } return true; @@ -2395,16 +2394,15 @@ bool CanvasItemEditor::_gui_input_select(const Ref<InputEvent> &p_event) { // Drag the node(s) if requested List<CanvasItem *> selection2 = _get_edited_canvas_items(); - // Remove not movable nodes + drag_selection.clear(); for (int i = 0; i < selection2.size(); i++) { - if (!_is_node_movable(selection2[i], true)) { - selection2.erase(selection2[i]); + if (_is_node_movable(selection2[i], true)) { + drag_selection.push_back(selection2[i]); } } if (selection2.size() > 0) { drag_type = DRAG_MOVE; - drag_selection = selection2; drag_from = click; _save_canvas_item_state(drag_selection); } diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp index b121a7ae3e..7fb751e3ed 100644 --- a/editor/plugins/tile_set_editor_plugin.cpp +++ b/editor/plugins/tile_set_editor_plugin.cpp @@ -1977,7 +1977,7 @@ void TileSetEditor::_set_edited_shape_points(const Vector<Vector2> &points) { if (convex.is_valid()) { undo_redo->add_do_method(convex.ptr(), "set_points", points); undo_redo->add_undo_method(convex.ptr(), "set_points", _get_edited_shape_points()); - } else if (concave.is_valid()) { + } else if (concave.is_valid() && points.size() > 1) { PackedVector2Array segments; for (int i = 0; i < points.size() - 1; i++) { segments.push_back(points[i]); @@ -2669,7 +2669,7 @@ void TileSetEditor::draw_polygon_shapes() { workspace->draw_polygon(polygon, colors); if (coord == edited_shape_coord || tileset->tile_get_tile_mode(get_current_tile()) == TileSet::SINGLE_TILE) { - if (!creating_shape) { + if (!creating_shape && polygon.size() > 1) { for (int j = 0; j < polygon.size() - 1; j++) { workspace->draw_line(polygon[j], polygon[j + 1], c_border, 1); } @@ -2706,13 +2706,11 @@ void TileSetEditor::draw_polygon_shapes() { } workspace->draw_polygon(polygon, colors); - if (!creating_shape) { - if (polygon.size() > 1) { - for (int j = 0; j < polygon.size() - 1; j++) { - workspace->draw_line(polygon[j], polygon[j + 1], c_border, 1); - } - workspace->draw_line(polygon[polygon.size() - 1], polygon[0], c_border, 1); + if (!creating_shape && polygon.size() > 1) { + for (int j = 0; j < polygon.size() - 1; j++) { + workspace->draw_line(polygon[j], polygon[j + 1], c_border, 1); } + workspace->draw_line(polygon[polygon.size() - 1], polygon[0], c_border, 1); } if (shape == edited_occlusion_shape) { draw_handles = true; @@ -2756,7 +2754,7 @@ void TileSetEditor::draw_polygon_shapes() { workspace->draw_polygon(polygon, colors); if (coord == edited_shape_coord) { - if (!creating_shape) { + if (!creating_shape && polygon.size() > 1) { for (int j = 0; j < polygon.size() - 1; j++) { workspace->draw_line(polygon[j], polygon[j + 1], c_border, 1); } @@ -2796,7 +2794,7 @@ void TileSetEditor::draw_polygon_shapes() { } workspace->draw_polygon(polygon, colors); - if (!creating_shape) { + if (!creating_shape && polygon.size() > 1) { for (int j = 0; j < polygon.size() - 1; j++) { workspace->draw_line(polygon[j], polygon[j + 1], c_border, 1); } @@ -2845,7 +2843,7 @@ void TileSetEditor::draw_polygon_shapes() { workspace->draw_polygon(polygon, colors); if (coord == edited_shape_coord) { - if (!creating_shape) { + if (!creating_shape && polygon.size() > 1) { for (int j = 0; j < polygon.size() - 1; j++) { workspace->draw_line(polygon[j], polygon[j + 1], c_border, 1); } @@ -2863,7 +2861,7 @@ void TileSetEditor::draw_polygon_shapes() { } } - if (creating_shape) { + if (creating_shape && current_shape.size() > 1) { for (int j = 0; j < current_shape.size() - 1; j++) { workspace->draw_line(current_shape[j], current_shape[j + 1], Color(0, 1, 1), 1); } |