summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/object/object.cpp14
-rw-r--r--core/object/object.h12
-rw-r--r--doc/classes/Object.xml8
-rw-r--r--editor/plugins/asset_library_editor_plugin.cpp3
-rw-r--r--editor/plugins/collision_shape_2d_editor_plugin.cpp57
-rw-r--r--editor/plugins/collision_shape_2d_editor_plugin.h13
-rw-r--r--editor/plugins/texture_editor_plugin.cpp6
-rw-r--r--editor/plugins/texture_editor_plugin.h6
-rw-r--r--modules/gltf/gltf_document.cpp2
-rw-r--r--scene/main/scene_tree.cpp15
-rw-r--r--scene/main/scene_tree.h4
-rw-r--r--scene/main/viewport.cpp26
-rw-r--r--scene/main/viewport.h3
-rw-r--r--tests/test_object.h4
14 files changed, 113 insertions, 60 deletions
diff --git a/core/object/object.cpp b/core/object/object.cpp
index 0644012318..66a4d17b7b 100644
--- a/core/object/object.cpp
+++ b/core/object/object.cpp
@@ -922,11 +922,11 @@ Variant Object::get_script() const {
return script;
}
-bool Object::has_meta(const String &p_name) const {
+bool Object::has_meta(const StringName &p_name) const {
return metadata.has(p_name);
}
-void Object::set_meta(const String &p_name, const Variant &p_value) {
+void Object::set_meta(const StringName &p_name, const Variant &p_value) {
if (p_value.get_type() == Variant::NIL) {
metadata.erase(p_name);
return;
@@ -935,12 +935,12 @@ void Object::set_meta(const String &p_name, const Variant &p_value) {
metadata[p_name] = p_value;
}
-Variant Object::get_meta(const String &p_name) const {
+Variant Object::get_meta(const StringName &p_name) const {
ERR_FAIL_COND_V_MSG(!metadata.has(p_name), Variant(), "The object does not have any 'meta' values with the key '" + p_name + "'.");
return metadata[p_name];
}
-void Object::remove_meta(const String &p_name) {
+void Object::remove_meta(const StringName &p_name) {
metadata.erase(p_name);
}
@@ -964,8 +964,8 @@ Array Object::_get_method_list_bind() const {
return ret;
}
-Vector<String> Object::_get_meta_list_bind() const {
- Vector<String> _metaret;
+Vector<StringName> Object::_get_meta_list_bind() const {
+ Vector<StringName> _metaret;
List<Variant> keys;
metadata.get_key_list(&keys);
@@ -976,7 +976,7 @@ Vector<String> Object::_get_meta_list_bind() const {
return _metaret;
}
-void Object::get_meta_list(List<String> *p_list) const {
+void Object::get_meta_list(List<StringName> *p_list) const {
List<Variant> keys;
metadata.get_key_list(&keys);
for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
diff --git a/core/object/object.h b/core/object/object.h
index 296e07983d..b7d0916a54 100644
--- a/core/object/object.h
+++ b/core/object/object.h
@@ -615,7 +615,7 @@ protected:
return &_class_name;
}
- Vector<String> _get_meta_list_bind() const;
+ Vector<StringName> _get_meta_list_bind() const;
Array _get_property_list_bind() const;
Array _get_method_list_bind() const;
@@ -743,11 +743,11 @@ public:
/* SCRIPT */
- bool has_meta(const String &p_name) const;
- void set_meta(const String &p_name, const Variant &p_value);
- void remove_meta(const String &p_name);
- Variant get_meta(const String &p_name) const;
- void get_meta_list(List<String> *p_list) const;
+ bool has_meta(const StringName &p_name) const;
+ void set_meta(const StringName &p_name, const Variant &p_value);
+ void remove_meta(const StringName &p_name);
+ Variant get_meta(const StringName &p_name) const;
+ void get_meta_list(List<StringName> *p_list) const;
#ifdef TOOLS_ENABLED
void set_edited(bool p_edited);
diff --git a/doc/classes/Object.xml b/doc/classes/Object.xml
index cdf76a3a59..fe7529bceb 100644
--- a/doc/classes/Object.xml
+++ b/doc/classes/Object.xml
@@ -400,7 +400,7 @@
<method name="get_meta" qualifiers="const">
<return type="Variant">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<description>
Returns the object's metadata entry for the given [code]name[/code].
@@ -454,7 +454,7 @@
<method name="has_meta" qualifiers="const">
<return type="bool">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<description>
Returns [code]true[/code] if a metadata entry is found with the given [code]name[/code].
@@ -543,7 +543,7 @@
<method name="remove_meta">
<return type="void">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<description>
Removes a given entry from the object's metadata. See also [method set_meta].
@@ -619,7 +619,7 @@
<method name="set_meta">
<return type="void">
</return>
- <argument index="0" name="name" type="String">
+ <argument index="0" name="name" type="StringName">
</argument>
<argument index="1" name="value" type="Variant">
</argument>
diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp
index bbc8107cf6..556f35d4b0 100644
--- a/editor/plugins/asset_library_editor_plugin.cpp
+++ b/editor/plugins/asset_library_editor_plugin.cpp
@@ -603,8 +603,7 @@ void EditorAssetLibrary::_notification(int p_what) {
void EditorAssetLibrary::_update_repository_options() {
Dictionary default_urls;
- default_urls["godotengine.org"] = "https://godotengine.org/asset-library/api";
- default_urls["localhost"] = "http://127.0.0.1/asset-library/api";
+ default_urls["godotengine.org (Official)"] = "https://godotengine.org/asset-library/api";
Dictionary available_urls = _EDITOR_DEF("asset_library/available_urls", default_urls, true);
repository->clear();
Array keys = available_urls.keys();
diff --git a/editor/plugins/collision_shape_2d_editor_plugin.cpp b/editor/plugins/collision_shape_2d_editor_plugin.cpp
index 45adbe29de..2c2adc2672 100644
--- a/editor/plugins/collision_shape_2d_editor_plugin.cpp
+++ b/editor/plugins/collision_shape_2d_editor_plugin.cpp
@@ -31,6 +31,7 @@
#include "collision_shape_2d_editor_plugin.h"
#include "canvas_item_editor_plugin.h"
+#include "core/os/keyboard.h"
#include "scene/resources/capsule_shape_2d.h"
#include "scene/resources/circle_shape_2d.h"
#include "scene/resources/concave_polygon_shape_2d.h"
@@ -97,7 +98,7 @@ Variant CollisionShape2DEditor::get_handle_value(int idx) const {
case RECTANGLE_SHAPE: {
Ref<RectangleShape2D> rect = node->get_shape();
- if (idx < 3) {
+ if (idx < 8) {
return rect->get_size().abs();
}
@@ -176,16 +177,26 @@ void CollisionShape2DEditor::set_handle(int idx, Point2 &p_point) {
} break;
case RECTANGLE_SHAPE: {
- if (idx < 3) {
+ if (idx < 8) {
Ref<RectangleShape2D> rect = node->get_shape();
+ Vector2 size = (Point2)original;
- Vector2 size = rect->get_size();
- if (idx == 2) {
- size = p_point * 2;
+ if (RECT_HANDLES[idx].x != 0) {
+ size.x = p_point.x * RECT_HANDLES[idx].x * 2;
+ }
+ if (RECT_HANDLES[idx].y != 0) {
+ size.y = p_point.y * RECT_HANDLES[idx].y * 2;
+ }
+
+ if (Input::get_singleton()->is_key_pressed(KEY_ALT)) {
+ rect->set_size(size.abs());
+ node->set_global_position(original_transform.get_origin());
} else {
- size[idx] = p_point[idx] * 2;
+ rect->set_size(((Point2)original + (size - (Point2)original) * 0.5).abs());
+ Point2 pos = original_transform.affine_inverse().xform(original_transform.get_origin());
+ pos += (size - (Point2)original) * 0.5 * RECT_HANDLES[idx] * 0.5;
+ node->set_global_position(original_transform.xform(pos));
}
- rect->set_size(size.abs());
canvas_item_editor->update_viewport();
}
@@ -280,8 +291,10 @@ void CollisionShape2DEditor::commit_handle(int idx, Variant &p_org) {
Ref<RectangleShape2D> rect = node->get_shape();
undo_redo->add_do_method(rect.ptr(), "set_size", rect->get_size());
+ undo_redo->add_do_method(node, "set_global_transform", node->get_global_transform());
undo_redo->add_do_method(canvas_item_editor, "update_viewport");
undo_redo->add_undo_method(rect.ptr(), "set_size", p_org);
+ undo_redo->add_undo_method(node, "set_global_transform", original_transform);
undo_redo->add_undo_method(canvas_item_editor, "update_viewport");
} break;
@@ -342,6 +355,8 @@ bool CollisionShape2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_e
}
original = get_handle_value(edit_handle);
+ original_transform = node->get_global_transform();
+ last_point = original;
pressed = true;
return true;
@@ -369,13 +384,26 @@ bool CollisionShape2DEditor::forward_canvas_gui_input(const Ref<InputEvent> &p_e
}
Vector2 cpoint = canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(mm->get_position()));
- cpoint = node->get_global_transform().affine_inverse().xform(cpoint);
+ cpoint = original_transform.affine_inverse().xform(cpoint);
+ last_point = cpoint;
set_handle(edit_handle, cpoint);
return true;
}
+ Ref<InputEventKey> k = p_event;
+
+ if (k.is_valid()) {
+ if (edit_handle == -1 || !pressed || k->is_echo()) {
+ return false;
+ }
+
+ if (shape_type == RECTANGLE_SHAPE && k->get_keycode() == KEY_ALT) {
+ set_handle(edit_handle, last_point); // Update handle when Alt key is toggled.
+ }
+ }
+
return false;
}
@@ -492,15 +520,12 @@ void CollisionShape2DEditor::forward_canvas_draw_over_viewport(Control *p_overla
case RECTANGLE_SHAPE: {
Ref<RectangleShape2D> shape = node->get_shape();
- handles.resize(3);
+ handles.resize(8);
Vector2 ext = shape->get_size() / 2;
- handles.write[0] = Point2(ext.x, 0);
- handles.write[1] = Point2(0, ext.y);
- handles.write[2] = Point2(ext.x, ext.y);
-
- p_overlay->draw_texture(h, gt.xform(handles[0]) - size);
- p_overlay->draw_texture(h, gt.xform(handles[1]) - size);
- p_overlay->draw_texture(h, gt.xform(handles[2]) - size);
+ for (int i = 0; i < handles.size(); i++) {
+ handles.write[i] = RECT_HANDLES[i] * ext;
+ p_overlay->draw_texture(h, gt.xform(handles[i]) - size);
+ }
} break;
diff --git a/editor/plugins/collision_shape_2d_editor_plugin.h b/editor/plugins/collision_shape_2d_editor_plugin.h
index 054db1a61b..7db6bd22aa 100644
--- a/editor/plugins/collision_shape_2d_editor_plugin.h
+++ b/editor/plugins/collision_shape_2d_editor_plugin.h
@@ -52,6 +52,17 @@ class CollisionShape2DEditor : public Control {
SEGMENT_SHAPE
};
+ const Point2 RECT_HANDLES[8] = {
+ Point2(1, 0),
+ Point2(1, 1),
+ Point2(0, 1),
+ Point2(-1, 1),
+ Point2(-1, 0),
+ Point2(-1, -1),
+ Point2(0, -1),
+ Point2(1, -1),
+ };
+
EditorNode *editor;
UndoRedo *undo_redo;
CanvasItemEditor *canvas_item_editor;
@@ -63,6 +74,8 @@ class CollisionShape2DEditor : public Control {
int edit_handle;
bool pressed;
Variant original;
+ Transform2D original_transform;
+ Point2 last_point;
Variant get_handle_value(int idx) const;
void set_handle(int idx, Point2 &p_point);
diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp
index 2eee9b8de3..44db06bcfd 100644
--- a/editor/plugins/texture_editor_plugin.cpp
+++ b/editor/plugins/texture_editor_plugin.cpp
@@ -48,8 +48,10 @@ void TexturePreview::_notification(int p_what) {
break;
}
- Ref<Font> metadata_label_font = get_theme_font(SNAME("expression"), SNAME("EditorFonts"));
- metadata_label->add_theme_font_override("font", metadata_label_font);
+ if (metadata_label) {
+ Ref<Font> metadata_label_font = get_theme_font(SNAME("expression"), SNAME("EditorFonts"));
+ metadata_label->add_theme_font_override("font", metadata_label_font);
+ }
checkerboard->set_texture(get_theme_icon(SNAME("Checkerboard"), SNAME("EditorIcons")));
} break;
diff --git a/editor/plugins/texture_editor_plugin.h b/editor/plugins/texture_editor_plugin.h
index c7272c83bc..36a5513ea6 100644
--- a/editor/plugins/texture_editor_plugin.h
+++ b/editor/plugins/texture_editor_plugin.h
@@ -39,10 +39,10 @@ class TexturePreview : public MarginContainer {
GDCLASS(TexturePreview, MarginContainer);
private:
- TextureRect *texture_display;
+ TextureRect *texture_display = nullptr;
- TextureRect *checkerboard;
- Label *metadata_label;
+ TextureRect *checkerboard = nullptr;
+ Label *metadata_label = nullptr;
protected:
void _notification(int p_what);
diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp
index 09bae884b9..30d023606f 100644
--- a/modules/gltf/gltf_document.cpp
+++ b/modules/gltf/gltf_document.cpp
@@ -2796,7 +2796,7 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> state) {
mat = mat3d;
}
- import_mesh->add_surface(primitive, array, morphs, Dictionary(), mat, mat->get_name());
+ import_mesh->add_surface(primitive, array, morphs, Dictionary(), mat, mat.is_valid() ? mat->get_name() : String());
}
Vector<float> blend_weights;
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index 2fe5d7aa78..644ce92018 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -82,6 +82,14 @@ bool SceneTreeTimer::is_process_always() {
return process_always;
}
+void SceneTreeTimer::set_ignore_time_scale(bool p_ignore) {
+ ignore_time_scale = p_ignore;
+}
+
+bool SceneTreeTimer::is_ignore_time_scale() {
+ return ignore_time_scale;
+}
+
void SceneTreeTimer::release_connections() {
List<Connection> connections;
get_all_signal_connections(&connections);
@@ -466,8 +474,13 @@ bool SceneTree::process(float p_time) {
E = N;
continue;
}
+
float time_left = E->get()->get_time_left();
- time_left -= p_time;
+ if (E->get()->is_ignore_time_scale()) {
+ time_left -= Engine::get_singleton()->get_process_step();
+ } else {
+ time_left -= p_time;
+ }
E->get()->set_time_left(time_left);
if (time_left < 0) {
diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h
index 0be0e185a5..c3d59663d6 100644
--- a/scene/main/scene_tree.h
+++ b/scene/main/scene_tree.h
@@ -54,6 +54,7 @@ class SceneTreeTimer : public RefCounted {
float time_left = 0.0;
bool process_always = true;
+ bool ignore_time_scale = false;
protected:
static void _bind_methods();
@@ -65,6 +66,9 @@ public:
void set_process_always(bool p_process_always);
bool is_process_always();
+ void set_ignore_time_scale(bool p_ignore);
+ bool is_ignore_time_scale();
+
void release_connections();
SceneTreeTimer();
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index f81b512b0c..34a871b993 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -502,17 +502,6 @@ void Viewport::_notification(int p_what) {
RS::get_singleton()->viewport_set_active(viewport, false);
RenderingServer::get_singleton()->viewport_set_parent_viewport(viewport, RID());
-
- } break;
- case NOTIFICATION_INTERNAL_PROCESS: {
- if (gui.tooltip_timer >= 0) {
- gui.tooltip_timer -= get_process_delta_time();
- if (gui.tooltip_timer < 0) {
- _gui_show_tooltip();
- set_process_internal(false);
- }
- }
-
} break;
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
if (get_tree()->is_debugging_collisions_hint() && contact_2d_debug.is_valid()) {
@@ -1489,8 +1478,10 @@ void Viewport::_gui_sort_roots() {
void Viewport::_gui_cancel_tooltip() {
gui.tooltip_control = nullptr;
- gui.tooltip_timer = -1;
- set_process_internal(false);
+ if (gui.tooltip_timer.is_valid()) {
+ gui.tooltip_timer->release_connections();
+ gui.tooltip_timer = Ref<SceneTreeTimer>();
+ }
if (gui.tooltip_popup) {
gui.tooltip_popup->queue_delete();
gui.tooltip_popup = nullptr;
@@ -2139,10 +2130,15 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
}
if (can_tooltip && !is_tooltip_shown) {
+ if (gui.tooltip_timer.is_valid()) {
+ gui.tooltip_timer->release_connections();
+ gui.tooltip_timer = Ref<SceneTreeTimer>();
+ }
gui.tooltip_control = over;
gui.tooltip_pos = over->get_screen_transform().xform(pos);
- gui.tooltip_timer = gui.tooltip_delay;
- set_process_internal(true);
+ gui.tooltip_timer = get_tree()->create_timer(gui.tooltip_delay);
+ gui.tooltip_timer->set_ignore_time_scale(true);
+ gui.tooltip_timer->connect("timeout", callable_mp(this, &Viewport::_gui_show_tooltip));
}
}
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index 9c3df4c770..b5c49a8a97 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -50,6 +50,7 @@ class Label;
class Timer;
class Viewport;
class CollisionObject3D;
+class SceneTreeTimer;
class ViewportTexture : public Texture2D {
GDCLASS(ViewportTexture, Texture2D);
@@ -373,7 +374,7 @@ private:
bool drag_attempted = false;
Variant drag_data;
ObjectID drag_preview_id;
- float tooltip_timer = -1.0;
+ Ref<SceneTreeTimer> tooltip_timer;
float tooltip_delay = 0.0;
Transform2D focus_inv_xform;
bool roots_order_dirty = false;
diff --git a/tests/test_object.h b/tests/test_object.h
index 36f9ef2a51..a18adf31b6 100644
--- a/tests/test_object.h
+++ b/tests/test_object.h
@@ -139,7 +139,7 @@ TEST_CASE("[Object] Metadata") {
Color(object.get_meta(meta_path)).is_equal_approx(Color(0, 1, 0)),
"The returned object metadata after setting should match the expected value.");
- List<String> meta_list;
+ List<StringName> meta_list;
object.get_meta_list(&meta_list);
CHECK_MESSAGE(
meta_list.size() == 1,
@@ -154,7 +154,7 @@ TEST_CASE("[Object] Metadata") {
"The returned object metadata after removing should match the expected value.");
ERR_PRINT_ON;
- List<String> meta_list2;
+ List<StringName> meta_list2;
object.get_meta_list(&meta_list2);
CHECK_MESSAGE(
meta_list2.size() == 0,