Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
623f7b64
Commit
623f7b64
authored
Feb 16, 2019
by
Juan Linietsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updat polygons when skeleton setup changes, fixes #25949
parent
be9b9383
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
2 deletions
+32
-2
polygon_2d.cpp
scene/2d/polygon_2d.cpp
+26
-2
polygon_2d.h
scene/2d/polygon_2d.h
+3
-0
skeleton_2d.cpp
scene/2d/skeleton_2d.cpp
+3
-0
No files found.
scene/2d/polygon_2d.cpp
View file @
623f7b64
...
...
@@ -88,6 +88,10 @@ bool Polygon2D::_edit_is_selected_on_click(const Point2 &p_point, double p_toler
return
Geometry
::
is_point_in_polygon
(
p_point
-
get_offset
(),
polygon2d
);
}
void
Polygon2D
::
_skeleton_bone_setup_changed
()
{
update
();
}
void
Polygon2D
::
_notification
(
int
p_what
)
{
switch
(
p_what
)
{
...
...
@@ -102,10 +106,27 @@ void Polygon2D::_notification(int p_what) {
skeleton_node
=
Object
::
cast_to
<
Skeleton2D
>
(
get_node
(
skeleton
));
}
if
(
skeleton_node
)
ObjectID
new_skeleton_id
=
0
;
if
(
skeleton_node
)
{
VS
::
get_singleton
()
->
canvas_item_attach_skeleton
(
get_canvas_item
(),
skeleton_node
->
get_skeleton
());
else
new_skeleton_id
=
skeleton_node
->
get_instance_id
();
}
else
{
VS
::
get_singleton
()
->
canvas_item_attach_skeleton
(
get_canvas_item
(),
RID
());
}
if
(
new_skeleton_id
!=
current_skeleton_id
)
{
Object
*
old_skeleton
=
ObjectDB
::
get_instance
(
current_skeleton_id
);
if
(
old_skeleton
)
{
old_skeleton
->
disconnect
(
"bone_setup_changed"
,
this
,
"_skeleton_bone_setup_changed"
);
}
if
(
skeleton_node
)
{
skeleton_node
->
connect
(
"bone_setup_changed"
,
this
,
"_skeleton_bone_setup_changed"
);
}
current_skeleton_id
=
new_skeleton_id
;
}
Vector
<
Vector2
>
points
;
Vector
<
Vector2
>
uvs
;
...
...
@@ -809,6 +830,8 @@ void Polygon2D::_bind_methods() {
ClassDB
::
bind_method
(
D_METHOD
(
"_set_bones"
,
"bones"
),
&
Polygon2D
::
_set_bones
);
ClassDB
::
bind_method
(
D_METHOD
(
"_get_bones"
),
&
Polygon2D
::
_get_bones
);
ClassDB
::
bind_method
(
D_METHOD
(
"_skeleton_bone_setup_changed"
),
&
Polygon2D
::
_skeleton_bone_setup_changed
);
ADD_PROPERTY
(
PropertyInfo
(
Variant
::
COLOR
,
"color"
),
"set_color"
,
"get_color"
);
ADD_PROPERTY
(
PropertyInfo
(
Variant
::
VECTOR2
,
"offset"
),
"set_offset"
,
"get_offset"
);
ADD_PROPERTY
(
PropertyInfo
(
Variant
::
BOOL
,
"antialiased"
),
"set_antialiased"
,
"get_antialiased"
);
...
...
@@ -846,4 +869,5 @@ Polygon2D::Polygon2D() {
color
=
Color
(
1
,
1
,
1
);
rect_cache_dirty
=
true
;
internal_vertices
=
0
;
current_skeleton_id
=
0
;
}
scene/2d/polygon_2d.h
View file @
623f7b64
...
...
@@ -65,10 +65,13 @@ class Polygon2D : public Node2D {
mutable
Rect2
item_rect
;
NodePath
skeleton
;
ObjectID
current_skeleton_id
;
Array
_get_bones
()
const
;
void
_set_bones
(
const
Array
&
p_bones
);
void
_skeleton_bone_setup_changed
();
protected
:
void
_notification
(
int
p_what
);
static
void
_bind_methods
();
...
...
scene/2d/skeleton_2d.cpp
View file @
623f7b64
...
...
@@ -203,6 +203,7 @@ void Skeleton2D::_update_bone_setup() {
transform_dirty
=
true
;
_update_transform
();
emit_signal
(
"bone_setup_changed"
);
}
void
Skeleton2D
::
_make_transform_dirty
()
{
...
...
@@ -291,6 +292,8 @@ void Skeleton2D::_bind_methods() {
ClassDB
::
bind_method
(
D_METHOD
(
"get_bone"
,
"idx"
),
&
Skeleton2D
::
get_bone
);
ClassDB
::
bind_method
(
D_METHOD
(
"get_skeleton"
),
&
Skeleton2D
::
get_skeleton
);
ADD_SIGNAL
(
MethodInfo
(
"bone_setup_changed"
));
}
Skeleton2D
::
Skeleton2D
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment