diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_inspector.cpp | 2 | ||||
-rw-r--r-- | editor/editor_inspector.h | 2 | ||||
-rw-r--r-- | editor/editor_node.cpp | 5 | ||||
-rw-r--r-- | editor/editor_properties.cpp | 14 | ||||
-rw-r--r-- | editor/editor_resource_preview.cpp | 1 | ||||
-rw-r--r-- | editor/import/editor_import_collada.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/asset_library_editor_plugin.cpp | 1 | ||||
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 24 | ||||
-rw-r--r-- | editor/plugins/editor_preview_plugins.cpp | 10 | ||||
-rw-r--r-- | editor/plugins/spatial_editor_plugin.cpp | 13 | ||||
-rw-r--r-- | editor/plugins/spatial_editor_plugin.h | 4 | ||||
-rw-r--r-- | editor/spatial_editor_gizmos.cpp | 44 | ||||
-rw-r--r-- | editor/spatial_editor_gizmos.h | 2 |
13 files changed, 101 insertions, 23 deletions
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index d7e0302478..1078fabc2e 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -2010,7 +2010,7 @@ void EditorInspector::_property_changed(const String &p_path, const Variant &p_v } } -void EditorInspector::_property_changed_update_all(const String &p_path, const Variant &p_value) { +void EditorInspector::_property_changed_update_all(const String &p_path, const Variant &p_value, const String &p_name, bool p_changing) { update_tree(); } diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h index 4fb3198e87..3d22cdb9a3 100644 --- a/editor/editor_inspector.h +++ b/editor/editor_inspector.h @@ -302,7 +302,7 @@ class EditorInspector : public ScrollContainer { void _edit_set(const String &p_name, const Variant &p_value, bool p_refresh_all, const String &p_changed_field); void _property_changed(const String &p_path, const Variant &p_value, const String &p_name = "", bool changing = false); - void _property_changed_update_all(const String &p_path, const Variant &p_value); + void _property_changed_update_all(const String &p_path, const Variant &p_value, const String &p_name = "", bool p_changing = false); void _multiple_properties_changed(Vector<String> p_paths, Array p_values); void _property_keyed(const String &p_path, bool p_advance); void _property_keyed_with_value(const String &p_path, const Variant &p_value, bool p_advance); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 0ff0bca7ee..c8e00b0586 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -952,6 +952,9 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) { } if (img.is_valid()) { + + img = img->duplicate(); + save.step(TTR("Creating Thumbnail"), 2); save.step(TTR("Creating Thumbnail"), 3); @@ -5635,7 +5638,7 @@ EditorNode::EditorNode() { bottom_panel->add_child(bottom_panel_vb); bottom_panel_hb = memnew(HBoxContainer); - bottom_panel_hb->set_custom_minimum_size(Size2(0, 24)); // Adjust for the height of the "Expand Bottom Dock" icon. + bottom_panel_hb->set_custom_minimum_size(Size2(0, 24 * EDSCALE)); // Adjust for the height of the "Expand Bottom Dock" icon. bottom_panel_vb->add_child(bottom_panel_hb); bottom_panel_hb_editors = memnew(HBoxContainer); diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index f19eac6878..56bab440c9 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -2187,7 +2187,19 @@ void EditorPropertyResource::_menu_option(int p_which) { return; } - Object *obj = ClassDB::instance(intype); + Object *obj = NULL; + + if (ScriptServer::is_global_class(intype)) { + obj = ClassDB::instance(ScriptServer::get_global_class_base(intype)); + if (obj) { + Ref<Script> script = ResourceLoader::load(ScriptServer::get_global_class_path(intype)); + if (script.is_valid()) { + obj->set_script(Variant(script)); + } + } + } else { + obj = ClassDB::instance(intype); + } if (!obj) { obj = EditorNode::get_editor_data().instance_custom_type(intype, "Resource"); diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index 368efbc48f..f77f31db80 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -159,6 +159,7 @@ void EditorResourcePreview::_generate_preview(Ref<ImageTexture> &r_texture, Ref< small_thumbnail_size *= EDSCALE; Ref<Image> small_image = r_texture->get_data(); + small_image = small_image->duplicate(); small_image->resize(small_thumbnail_size, small_thumbnail_size, Image::INTERPOLATE_CUBIC); r_small_texture.instance(); r_small_texture->create_from_image(small_image); diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index cd5df14f1b..dbf63102cf 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -44,8 +44,6 @@ #include "scene/resources/packed_scene.h" #include "scene/resources/surface_tool.h" -#include <iostream> - struct ColladaImport { Collada collada; diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index a42765df6b..c68023ee9b 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -174,6 +174,7 @@ void EditorAssetLibraryItemDescription::set_image(int p_type, int p_index, const if (preview_images[i].is_video) { Ref<Image> overlay = get_icon("PlayOverlay", "EditorIcons")->get_data(); Ref<Image> thumbnail = p_image->get_data(); + thumbnail = thumbnail->duplicate(); Point2 overlay_pos = Point2((thumbnail->get_width() - overlay->get_width()) / 2, (thumbnail->get_height() - overlay->get_height()) / 2); thumbnail->lock(); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 2913c4ce56..b2d2704f07 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -2741,10 +2741,11 @@ void CanvasItemEditor::_draw_selection() { if (canvas_item->_edit_use_pivot()) { // Draw the node's pivot - Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * Transform2D(canvas_item->_edit_get_rotation(), canvas_item->_edit_get_position())).orthonormalized(); + Transform2D unscaled_transform = (xform * canvas_item->get_transform().affine_inverse() * Transform2D(canvas_item->_edit_get_rotation(), canvas_item->_edit_get_position() + canvas_item->_edit_get_pivot())).orthonormalized(); Transform2D simple_xform = viewport->get_transform() * unscaled_transform; + viewport->draw_set_transform_matrix(simple_xform); - viewport->draw_texture(pivot_icon, canvas_item->_edit_get_pivot() - (pivot_icon->get_size() / 2).floor()); + viewport->draw_texture(pivot_icon, -(pivot_icon->get_size() / 2).floor()); viewport->draw_set_transform_matrix(viewport->get_transform()); } @@ -3277,7 +3278,24 @@ void CanvasItemEditor::_notification(int p_what) { pivot_button->set_disabled(nb_having_pivot == 0); // Show / Hide the layout button - presets_menu->set_visible(nb_control > 0 && nb_control == selection.size()); + if (nb_control > 0 && nb_control == selection.size()) { + presets_menu->set_visible(true); + presets_menu->set_tooltip(TTR("Presets for the anchors and margins values of a Control node.")); + + // Disable if the selected node is child of a container + presets_menu->set_disabled(false); + for (List<CanvasItem *>::Element *E = selection.front(); E; E = E->next()) { + Control *control = Object::cast_to<Control>(E->get()); + if (!control || Object::cast_to<Container>(control->get_parent())) { + presets_menu->set_disabled(true); + presets_menu->set_tooltip(TTR("A child of a container gets its anchors and margins values overriden by its parent.")); + break; + } + } + + } else { + presets_menu->set_visible(false); + } // Update the viewport if bones changes for (Map<BoneKey, BoneList>::Element *E = bone_list.front(); E; E = E->next()) { diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index 8464dfd0aa..0c0cc9d635 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -99,12 +99,14 @@ Ref<Texture> EditorTexturePreviewPlugin::generate(const RES &p_from, const Size2 } else { Ref<Texture> tex = p_from; img = tex->get_data(); + if (img.is_valid()) { + img = img->duplicate(); + } } if (img.is_null() || img->empty()) return Ref<Texture>(); - img = img->duplicate(); img->clear_mipmaps(); if (img->is_compressed()) { @@ -332,7 +334,7 @@ Ref<Texture> EditorMaterialPreviewPlugin::generate(const RES &p_from, const Size OS::get_singleton()->delay_usec(10); } - Ref<Image> img = VS::get_singleton()->VS::get_singleton()->texture_get_data(viewport_texture); + Ref<Image> img = VS::get_singleton()->texture_get_data(viewport_texture); VS::get_singleton()->mesh_surface_set_material(sphere, 0, RID()); ERR_FAIL_COND_V(!img.is_valid(), Ref<ImageTexture>()); @@ -732,7 +734,7 @@ Ref<Texture> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 p_ OS::get_singleton()->delay_usec(10); } - Ref<Image> img = VS::get_singleton()->VS::get_singleton()->texture_get_data(viewport_texture); + Ref<Image> img = VS::get_singleton()->texture_get_data(viewport_texture); ERR_FAIL_COND_V(img.is_null(), Ref<ImageTexture>()); VS::get_singleton()->instance_set_base(mesh_instance, RID()); @@ -852,7 +854,7 @@ Ref<Texture> EditorFontPreviewPlugin::generate_from_path(const String &p_path, c OS::get_singleton()->delay_usec(10); } - Ref<Image> img = VS::get_singleton()->VS::get_singleton()->texture_get_data(viewport_texture); + Ref<Image> img = VS::get_singleton()->texture_get_data(viewport_texture); ERR_FAIL_COND_V(img.is_null(), Ref<ImageTexture>()); img->convert(Image::FORMAT_RGBA8); diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 276ca2e451..78bc989c5f 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -5732,6 +5732,7 @@ void SpatialEditorPlugin::snap_cursor_to_plane(const Plane &p_plane) { } void SpatialEditor::add_gizmo_plugin(Ref<EditorSpatialGizmoPlugin> p_plugin) { + ERR_FAIL_NULL(p_plugin.ptr()); gizmo_plugins.push_back(p_plugin); _update_gizmos_menu(); SpatialEditor::get_singleton()->update_all_gizmos(); @@ -5869,7 +5870,7 @@ Ref<SpatialMaterial> EditorSpatialGizmoPlugin::get_material(const String &p_name ERR_FAIL_COND_V(!materials.has(p_name), Ref<SpatialMaterial>()); ERR_FAIL_COND_V(materials[p_name].size() == 0, Ref<SpatialMaterial>()); - if (p_gizmo.is_null()) return materials[p_name][0]; + if (p_gizmo.is_null() || materials[p_name].size() == 1) return materials[p_name][0]; int index = (p_gizmo->is_selected() ? 1 : 0) + (p_gizmo->is_editable() ? 2 : 0); @@ -5888,7 +5889,7 @@ String EditorSpatialGizmoPlugin::get_name() const { if (get_script_instance() && get_script_instance()->has_method("get_name")) { return get_script_instance()->call("get_name"); } - return TTR("Name-less gizmo"); + return TTR("Nameless gizmo"); } Ref<EditorSpatialGizmo> EditorSpatialGizmoPlugin::get_gizmo(Spatial *p_spatial) { @@ -5938,7 +5939,7 @@ void EditorSpatialGizmoPlugin::_bind_methods() { cm.default_arguments.push_back(false); BIND_VMETHOD(cm); - BIND_VMETHOD(MethodInfo(Variant::BOOL, "is_gizmo_handle_highlighted", GIZMO_REF, PropertyInfo(Variant::INT, "index"))); + BIND_VMETHOD(MethodInfo(Variant::BOOL, "is_handle_highlighted", GIZMO_REF, PropertyInfo(Variant::INT, "index"))); #undef GIZMO_REF } @@ -6008,9 +6009,9 @@ void EditorSpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int p_ } } -bool EditorSpatialGizmoPlugin::is_gizmo_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int p_idx) const { - if (get_script_instance() && get_script_instance()->has_method("is_gizmo_handle_highlighted")) { - return get_script_instance()->call("is_gizmo_handle_highlighted", p_gizmo, p_idx); +bool EditorSpatialGizmoPlugin::is_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int p_idx) const { + if (get_script_instance() && get_script_instance()->has_method("is_handle_highlighted")) { + return get_script_instance()->call("is_handle_highlighted", p_gizmo, p_idx); } return false; } diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h index 87cd089428..2dc627cb27 100644 --- a/editor/plugins/spatial_editor_plugin.h +++ b/editor/plugins/spatial_editor_plugin.h @@ -110,6 +110,7 @@ public: void add_handles(const Vector<Vector3> &p_handles, const Ref<Material> &p_material, bool p_billboard = false, bool p_secondary = false); void add_solid_box(Ref<Material> &p_material, Vector3 p_size, Vector3 p_position = Vector3()); + virtual bool is_handle_highlighted(int p_idx) const; virtual String get_handle_name(int p_idx) const; virtual Variant get_handle_value(int p_idx); virtual void set_handle(int p_idx, Camera *p_camera, const Point2 &p_point); @@ -117,6 +118,7 @@ public: void set_spatial_node(Spatial *p_node); Spatial *get_spatial_node() const { return spatial_node; } + EditorSpatialGizmoPlugin *get_plugin() const { return gizmo_plugin; } Vector3 get_handle_pos(int p_idx) const; bool intersect_frustum(const Camera *p_camera, const Vector<Plane> &p_frustum); bool intersect_ray(Camera *p_camera, const Point2 &p_point, Vector3 &r_pos, Vector3 &r_normal, int *r_gizmo_handle = NULL, bool p_sec_first = false); @@ -786,7 +788,7 @@ public: virtual Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const; virtual void set_handle(EditorSpatialGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point); virtual void commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false); - virtual bool is_gizmo_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int p_idx) const; + virtual bool is_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int p_idx) const; Ref<EditorSpatialGizmo> get_gizmo(Spatial *p_spatial); void set_state(int p_state); diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index 9f3a0e78f6..f62391e436 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -99,26 +99,63 @@ void EditorSpatialGizmo::clear() { void EditorSpatialGizmo::redraw() { + if (get_script_instance() && get_script_instance()->has_method("redraw")) { + get_script_instance()->call("redraw"); + return; + } + ERR_FAIL_COND(!gizmo_plugin); gizmo_plugin->redraw(this); } String EditorSpatialGizmo::get_handle_name(int p_idx) const { + + if (get_script_instance() && get_script_instance()->has_method("get_handle_name")) { + return get_script_instance()->call("get_handle_name", p_idx); + } + ERR_FAIL_COND_V(!gizmo_plugin, ""); return gizmo_plugin->get_handle_name(this, p_idx); } +bool EditorSpatialGizmo::is_handle_highlighted(int p_idx) const { + + if (get_script_instance() && get_script_instance()->has_method("is_handle_highlighted")) { + return get_script_instance()->call("is_handle_highlighted", p_idx); + } + + ERR_FAIL_COND_V(!gizmo_plugin, false); + return gizmo_plugin->is_handle_highlighted(this, p_idx); +} + Variant EditorSpatialGizmo::get_handle_value(int p_idx) { + + if (get_script_instance() && get_script_instance()->has_method("get_handle_value")) { + return get_script_instance()->call("get_handle_value", p_idx); + } + ERR_FAIL_COND_V(!gizmo_plugin, Variant()); return gizmo_plugin->get_handle_value(this, p_idx); } void EditorSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_point) { + + if (get_script_instance() && get_script_instance()->has_method("set_handle")) { + get_script_instance()->call("set_handle", p_idx, p_camera, p_point); + return; + } + ERR_FAIL_COND(!gizmo_plugin); return gizmo_plugin->set_handle(this, p_idx, p_camera, p_point); } void EditorSpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) { + + if (get_script_instance() && get_script_instance()->has_method("commit_handle")) { + get_script_instance()->call("commit_handle", p_idx, p_restore, p_cancel); + return; + } + ERR_FAIL_COND(!gizmo_plugin); return gizmo_plugin->commit_handle(this, p_idx, p_restore, p_cancel); } @@ -298,7 +335,7 @@ void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, const Ref for (int i = 0; i < p_handles.size(); i++) { Color col(1, 1, 1, 1); - if (gizmo_plugin->is_gizmo_handle_highlighted(this, i)) + if (is_handle_highlighted(i)) col = Color(0, 0, 1, 0.9); if (SpatialEditor::get_singleton()->get_over_gizmo_handle() != i) @@ -690,11 +727,14 @@ void EditorSpatialGizmo::_bind_methods() { ClassDB::bind_method(D_METHOD("add_unscaled_billboard", "material", "default_scale"), &EditorSpatialGizmo::add_unscaled_billboard, DEFVAL(1)); ClassDB::bind_method(D_METHOD("add_handles", "handles", "material", "billboard", "secondary"), &EditorSpatialGizmo::add_handles, DEFVAL(false), DEFVAL(false)); ClassDB::bind_method(D_METHOD("set_spatial_node", "node"), &EditorSpatialGizmo::_set_spatial_node); + ClassDB::bind_method(D_METHOD("get_spatial_node"), &EditorSpatialGizmo::get_spatial_node); + ClassDB::bind_method(D_METHOD("get_plugin"), &EditorSpatialGizmo::get_plugin); ClassDB::bind_method(D_METHOD("clear"), &EditorSpatialGizmo::clear); ClassDB::bind_method(D_METHOD("set_hidden", "hidden"), &EditorSpatialGizmo::set_hidden); BIND_VMETHOD(MethodInfo("redraw")); BIND_VMETHOD(MethodInfo(Variant::STRING, "get_handle_name", PropertyInfo(Variant::INT, "index"))); + BIND_VMETHOD(MethodInfo(Variant::BOOL, "is_handle_highlighted", PropertyInfo(Variant::INT, "index"))); MethodInfo hvget(Variant::NIL, "get_handle_value", PropertyInfo(Variant::INT, "index")); hvget.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT; @@ -2117,7 +2157,7 @@ void SoftBodySpatialGizmoPlugin::commit_handle(EditorSpatialGizmo *p_gizmo, int soft_body->pin_point_toggle(p_idx); } -bool SoftBodySpatialGizmoPlugin::is_gizmo_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int idx) const { +bool SoftBodySpatialGizmoPlugin::is_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int idx) const { SoftBody *soft_body = Object::cast_to<SoftBody>(p_gizmo->get_spatial_node()); return soft_body->is_point_pinned(idx); } diff --git a/editor/spatial_editor_gizmos.h b/editor/spatial_editor_gizmos.h index 40e137cded..0d89fb0f03 100644 --- a/editor/spatial_editor_gizmos.h +++ b/editor/spatial_editor_gizmos.h @@ -214,7 +214,7 @@ public: String get_handle_name(const EditorSpatialGizmo *p_gizmo, int p_idx) const; Variant get_handle_value(EditorSpatialGizmo *p_gizmo, int p_idx) const; void commit_handle(EditorSpatialGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel); - bool is_gizmo_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int idx) const; + bool is_handle_highlighted(const EditorSpatialGizmo *p_gizmo, int idx) const; SoftBodySpatialGizmoPlugin(); }; |