diff options
-rw-r--r-- | core/bind/core_bind.cpp | 2 | ||||
-rw-r--r-- | doc/classes/BaseButton.xml | 2 | ||||
-rw-r--r-- | editor/plugins/animation_blend_space_2d_editor.cpp | 9 | ||||
-rw-r--r-- | editor/plugins/animation_blend_space_2d_editor.h | 2 | ||||
-rw-r--r-- | editor/plugins/polygon_2d_editor_plugin.cpp | 21 | ||||
-rw-r--r-- | platform/osx/os_osx.mm | 4 | ||||
-rw-r--r-- | scene/animation/animation_blend_space_2d.cpp | 40 | ||||
-rw-r--r-- | scene/animation/animation_blend_space_2d.h | 1 |
8 files changed, 59 insertions, 22 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 7a253ed85c..e81468e888 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -2423,7 +2423,7 @@ void _Thread::_start_func(void *ud) { } break; case Variant::CallError::CALL_ERROR_TOO_FEW_ARGUMENTS: { - reason = "Too Many Arguments"; + reason = "Too Few Arguments"; } break; case Variant::CallError::CALL_ERROR_INVALID_METHOD: { diff --git a/doc/classes/BaseButton.xml b/doc/classes/BaseButton.xml index 05ffe6cc11..ff3e22ba26 100644 --- a/doc/classes/BaseButton.xml +++ b/doc/classes/BaseButton.xml @@ -92,7 +92,7 @@ <argument index="0" name="button_pressed" type="bool"> </argument> <description> - This signal is emitted when the button was just toggled between pressed and normal states (only if toggle_mode is active). The new state is contained in the [i]pressed[/i] argument. + This signal is emitted when the button was just toggled between pressed and normal states (only if toggle_mode is active). The new state is contained in the [i]button_pressed[/i] argument. </description> </signal> </signals> diff --git a/editor/plugins/animation_blend_space_2d_editor.cpp b/editor/plugins/animation_blend_space_2d_editor.cpp index 664e3e8b7f..038e2d0b3e 100644 --- a/editor/plugins/animation_blend_space_2d_editor.cpp +++ b/editor/plugins/animation_blend_space_2d_editor.cpp @@ -47,11 +47,19 @@ bool AnimationNodeBlendSpace2DEditor::can_edit(const Ref<AnimationNode> &p_node) return bs2d.is_valid(); } +void AnimationNodeBlendSpace2DEditor::_blend_space_changed() { + blend_space_draw->update(); +} + void AnimationNodeBlendSpace2DEditor::edit(const Ref<AnimationNode> &p_node) { + if (blend_space.is_valid()) { + blend_space->disconnect("triangles_updated", this, "_blend_space_changed"); + } blend_space = p_node; if (!blend_space.is_null()) { + blend_space->connect("triangles_updated", this, "_blend_space_changed"); _update_space(); } } @@ -837,6 +845,7 @@ void AnimationNodeBlendSpace2DEditor::_bind_methods() { ClassDB::bind_method("_removed_from_graph", &AnimationNodeBlendSpace2DEditor::_removed_from_graph); ClassDB::bind_method("_auto_triangles_toggled", &AnimationNodeBlendSpace2DEditor::_auto_triangles_toggled); + ClassDB::bind_method("_blend_space_changed", &AnimationNodeBlendSpace2DEditor::_blend_space_changed); ClassDB::bind_method("_file_opened", &AnimationNodeBlendSpace2DEditor::_file_opened); } diff --git a/editor/plugins/animation_blend_space_2d_editor.h b/editor/plugins/animation_blend_space_2d_editor.h index 3c128a6ef9..74186791e1 100644 --- a/editor/plugins/animation_blend_space_2d_editor.h +++ b/editor/plugins/animation_blend_space_2d_editor.h @@ -138,6 +138,8 @@ class AnimationNodeBlendSpace2DEditor : public AnimationTreeNodeEditorPlugin { MENU_LOAD_FILE_CONFIRM = 1002 }; + void _blend_space_changed(); + protected: void _notification(int p_what); static void _bind_methods(); diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index a2873fe7d7..93d262f874 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -665,9 +665,9 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { //todo, could check whether it already exists? polygons.push_back(polygon_create); - undo_redo->create_action(TTR("Add Polygon")); + undo_redo->create_action(TTR("Add Custom Polygon")); undo_redo->add_do_method(node, "set_polygons", polygons); - undo_redo->add_undo_method(node, "set_polygons", polygons_prev); + undo_redo->add_undo_method(node, "set_polygons", node->get_polygons()); undo_redo->add_do_method(uv_edit_draw, "update"); undo_redo->add_undo_method(uv_edit_draw, "update"); undo_redo->commit_action(); @@ -705,9 +705,9 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { if (erase_index != -1) { polygons.remove(erase_index); - undo_redo->create_action(TTR("Remove Polygon")); + undo_redo->create_action(TTR("Remove Custom Polygon")); undo_redo->add_do_method(node, "set_polygons", polygons); - undo_redo->add_undo_method(node, "set_polygons", polygons_prev); + undo_redo->add_undo_method(node, "set_polygons", node->get_polygons()); undo_redo->add_do_method(uv_edit_draw, "update"); undo_redo->add_undo_method(uv_edit_draw, "update"); undo_redo->commit_action(); @@ -735,18 +735,21 @@ void Polygon2DEditor::_uv_input(const Ref<InputEvent> &p_input) { } else if (uv_drag && !uv_create) { - if (uv_edit_mode[0]->is_pressed()) { //edit uv + if (uv_edit_mode[0]->is_pressed()) { // Edit UV. undo_redo->create_action(TTR("Transform UV Map")); undo_redo->add_do_method(node, "set_uv", node->get_uv()); undo_redo->add_undo_method(node, "set_uv", points_prev); - } else if (uv_edit_mode[1]->is_pressed()) { //edit polygon + undo_redo->add_do_method(uv_edit_draw, "update"); + undo_redo->add_undo_method(uv_edit_draw, "update"); + undo_redo->commit_action(); + } else if (uv_edit_mode[1]->is_pressed() && uv_move_current == UV_MODE_EDIT_POINT) { // Edit polygon. undo_redo->create_action(TTR("Transform Polygon")); undo_redo->add_do_method(node, "set_polygon", node->get_polygon()); undo_redo->add_undo_method(node, "set_polygon", points_prev); + undo_redo->add_do_method(uv_edit_draw, "update"); + undo_redo->add_undo_method(uv_edit_draw, "update"); + undo_redo->commit_action(); } - undo_redo->add_do_method(uv_edit_draw, "update"); - undo_redo->add_undo_method(uv_edit_draw, "update"); - undo_redo->commit_action(); uv_drag = false; } else if (bone_painting) { diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 5880a0e0bd..ddd98ab88c 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -629,6 +629,7 @@ static void _mouseDownEvent(NSEvent *event, int index, int mask, bool pressed) { const Vector2 pos = get_mouse_pos([event locationInWindow], backingScaleFactor); mm->set_position(pos); mm->set_global_position(pos); + mm->set_speed(OS_OSX::singleton->input->get_last_mouse_speed()); Vector2 relativeMotion = Vector2(); relativeMotion.x = [event deltaX] * OS_OSX::singleton -> _mouse_scale(backingScaleFactor); relativeMotion.y = [event deltaY] * OS_OSX::singleton -> _mouse_scale(backingScaleFactor); @@ -1615,7 +1616,8 @@ void OS_OSX::set_cursor_shape(CursorShape p_shape) { case CURSOR_VSPLIT: [[NSCursor resizeUpDownCursor] set]; break; case CURSOR_HSPLIT: [[NSCursor resizeLeftRightCursor] set]; break; case CURSOR_HELP: [[NSCursor arrowCursor] set]; break; - default: {}; + default: { + }; } } diff --git a/scene/animation/animation_blend_space_2d.cpp b/scene/animation/animation_blend_space_2d.cpp index 8b26044805..d744d6cc8e 100644 --- a/scene/animation/animation_blend_space_2d.cpp +++ b/scene/animation/animation_blend_space_2d.cpp @@ -80,18 +80,15 @@ void AnimationNodeBlendSpace2D::add_blend_point(const Ref<AnimationRootNode> &p_ blend_points[p_at_index].node->connect("tree_changed", this, "_tree_changed", varray(), CONNECT_REFERENCE_COUNTED); blend_points_used++; - if (auto_triangles) { - trianges_dirty = true; - } + _queue_auto_triangles(); + emit_signal("tree_changed"); } void AnimationNodeBlendSpace2D::set_blend_point_position(int p_point, const Vector2 &p_position) { ERR_FAIL_INDEX(p_point, blend_points_used); blend_points[p_point].position = p_position; - if (auto_triangles) { - trianges_dirty = true; - } + _queue_auto_triangles(); } void AnimationNodeBlendSpace2D::set_blend_point_node(int p_point, const Ref<AnimationRootNode> &p_node) { ERR_FAIL_INDEX(p_point, blend_points_used); @@ -309,15 +306,27 @@ Vector<int> AnimationNodeBlendSpace2D::_get_triangles() const { return t; } +void AnimationNodeBlendSpace2D::_queue_auto_triangles() { + if (!auto_triangles || trianges_dirty) { + return; + } + + trianges_dirty = true; + call_deferred("_update_triangles"); +} + void AnimationNodeBlendSpace2D::_update_triangles() { if (!auto_triangles || !trianges_dirty) return; + print_line("updating triangles"); trianges_dirty = false; triangles.clear(); - if (blend_points_used < 3) + if (blend_points_used < 3) { + emit_signal("triangles_updated"); return; + } Vector<Vector2> points; points.resize(blend_points_used); @@ -327,9 +336,12 @@ void AnimationNodeBlendSpace2D::_update_triangles() { Vector<Delaunay2D::Triangle> triangles = Delaunay2D::triangulate(points); + print_line("triangles generated: " + itos(triangles.size())); + for (int i = 0; i < triangles.size(); i++) { add_triangle(triangles[i].points[0], triangles[i].points[1], triangles[i].points[2]); } + emit_signal("triangles_updated"); } Vector2 AnimationNodeBlendSpace2D::get_closest_point(const Vector2 &p_point) { @@ -546,6 +558,10 @@ String AnimationNodeBlendSpace2D::get_caption() const { } void AnimationNodeBlendSpace2D::_validate_property(PropertyInfo &property) const { + + if (auto_triangles && property.name == "triangles") { + property.usage = 0; + } if (property.name.begins_with("blend_point_")) { String left = property.name.get_slicec('/', 0); int idx = left.get_slicec('_', 2).to_int(); @@ -557,10 +573,12 @@ void AnimationNodeBlendSpace2D::_validate_property(PropertyInfo &property) const } void AnimationNodeBlendSpace2D::set_auto_triangles(bool p_enable) { - auto_triangles = p_enable; - if (auto_triangles) { - trianges_dirty = true; + if (auto_triangles == p_enable) { + return; } + + auto_triangles = p_enable; + _queue_auto_triangles(); } bool AnimationNodeBlendSpace2D::get_auto_triangles() const { @@ -625,6 +643,7 @@ void AnimationNodeBlendSpace2D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_blend_mode"), &AnimationNodeBlendSpace2D::get_blend_mode); ClassDB::bind_method(D_METHOD("_tree_changed"), &AnimationNodeBlendSpace2D::_tree_changed); + ClassDB::bind_method(D_METHOD("_update_triangles"), &AnimationNodeBlendSpace2D::_update_triangles); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "auto_triangles", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_auto_triangles", "get_auto_triangles"); @@ -642,6 +661,7 @@ void AnimationNodeBlendSpace2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::STRING, "y_label", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_y_label", "get_y_label"); ADD_PROPERTY(PropertyInfo(Variant::INT, "blend_mode", PROPERTY_HINT_ENUM, "Interpolated,Discrete,Carry", PROPERTY_USAGE_NOEDITOR), "set_blend_mode", "get_blend_mode"); + ADD_SIGNAL(MethodInfo("triangles_updated")); BIND_ENUM_CONSTANT(BLEND_MODE_INTERPOLATED); BIND_ENUM_CONSTANT(BLEND_MODE_DISCRETE); BIND_ENUM_CONSTANT(BLEND_MODE_DISCRETE_CARRY); diff --git a/scene/animation/animation_blend_space_2d.h b/scene/animation/animation_blend_space_2d.h index 53885d4ad2..c21360beb9 100644 --- a/scene/animation/animation_blend_space_2d.h +++ b/scene/animation/animation_blend_space_2d.h @@ -82,6 +82,7 @@ protected: bool trianges_dirty; void _update_triangles(); + void _queue_auto_triangles(); void _tree_changed(); |