Skip to content

Commit

Permalink
Bone2D changes:
Browse files Browse the repository at this point in the history
* Fixed issue where Bone2D gizmos would incorrectly rotate when their parent node was rotated.
* Fixed RID leaks created via the Bone2D gizmos.

* Fixed clang format issue in CanvasItemEditor
  • Loading branch information
TwistedTwigleg committed Jul 24, 2020
1 parent 37720f3 commit 78fcf91
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion editor/plugins/canvas_item_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ class CanvasItemEditor : public VBoxContainer {
bool _is_node_movable(const Node *p_node, bool p_popup_warning = false);
void _find_canvas_items_at_pos(const Point2 &p_pos, Node *p_node, Vector<_SelectResult> &r_items, const Transform2D &p_parent_xform = Transform2D(), const Transform2D &p_canvas_xform = Transform2D());
void _get_canvas_items_at_pos(const Point2 &p_pos, Vector<_SelectResult> &r_items, bool p_allow_locked = false);

void _find_canvas_items_in_rect(const Rect2 &p_rect, Node *p_node, List<CanvasItem *> *r_items, const Transform2D &p_parent_xform = Transform2D(), const Transform2D &p_canvas_xform = Transform2D());
bool _select_click_on_item(CanvasItem *item, Point2 p_click_pos, bool p_append);

Expand Down
11 changes: 10 additions & 1 deletion scene/2d/skeleton_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,12 @@ bool Bone2D::_editor_get_bone_shape(Vector<Vector2> *shape, Vector<Vector2> *out
Vector2 rel;
if (other_bone) {
rel = (other_bone->get_global_transform().get_origin() - get_global_transform().get_origin());
rel = rel.rotated(-get_global_rotation()); // Undo Bone2D node's rotation so its drawn correctly regardless of the node's rotation
} else {
float angle_to_use = get_rotation() + bone_angle;
rel = Vector2(cos(angle_to_use), sin(angle_to_use)) * length;
rel = rel.rotated(-get_rotation()); // Undo Bone2D node's rotation so its drawn correctly regardless of the node's rotation
}
rel = rel.rotated(-get_rotation());

Vector2 relt = rel.tangent().normalized() * bone_width;
Vector2 reln = rel.normalized();
Expand Down Expand Up @@ -475,6 +476,14 @@ Bone2D::Bone2D() {
}
}

Bone2D::~Bone2D() {
#ifdef TOOLS_ENABLED
if (!editor_gizmo_rid.is_null()) {
RenderingServer::get_singleton()->free(editor_gizmo_rid);
}
#endif // TOOLS_ENABLED
}

//////////////////////////////////////

bool Skeleton2D::_set(const StringName &p_path, const Variant &p_value) {
Expand Down
1 change: 1 addition & 0 deletions scene/2d/skeleton_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class Bone2D : public Node2D {
#endif // TOOLS_ENABLED

Bone2D();
~Bone2D();
};

class SkeletonModificationStack2D;
Expand Down

0 comments on commit 78fcf91

Please sign in to comment.