summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
authorBojidar Marinov <bojidar.marinov.bg@gmail.com>2017-06-30 19:01:20 +0300
committerBojidar Marinov <bojidar.marinov.bg@gmail.com>2017-06-30 19:01:20 +0300
commit80356f925c515ae04bd694a6ddb25c15c3ca6555 (patch)
tree6327ea28fa964fc86f68b2b3ccd33464fa953385 /editor/plugins
parent198bd9db02950d261c83b0c383fe737df3c5f152 (diff)
Fix #9409, fixup #9370; tileset now has shape transform instead of offset
Fix bad return type in CollisionObject2D, Shape -> Shape2D. Was causing unintended null when casting. (9409) Fix a misplaced ++ operator. (9370) Fix merging with exiting tileset duplicating shapes. (9370)
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/tile_set_editor_plugin.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp
index 70b6257bb2..3563f70d0b 100644
--- a/editor/plugins/tile_set_editor_plugin.cpp
+++ b/editor/plugins/tile_set_editor_plugin.cpp
@@ -90,9 +90,10 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) {
phys_offset += -s / 2;
}
- Vector<Ref<Shape2D> > collisions;
+ Vector<TileSet::ShapeData> collisions;
Ref<NavigationPolygon> nav_poly;
Ref<OccluderPolygon2D> occluder;
+ bool found_collisions = false;
for (int j = 0; j < mi->get_child_count(); j++) {
@@ -106,24 +107,38 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) {
if (!child2->cast_to<StaticBody2D>())
continue;
+
+ found_collisions = true;
+
StaticBody2D *sb = child2->cast_to<StaticBody2D>();
List<uint32_t> shapes;
sb->get_shape_owners(&shapes);
for (List<uint32_t>::Element *E = shapes.front(); E; E = E->next()) {
+ if (sb->is_shape_owner_disabled(E->get())) continue;
- Vector2 shape_offset = sb->shape_owner_get_transform(E->get()).get_origin();
+ Transform2D shape_transform = sb->shape_owner_get_transform(E->get());
bool one_way = sb->is_shape_owner_one_way_collision_enabled(E->get());
+ shape_transform.set_origin(shape_transform.get_origin() - phys_offset);
+
for (int k = 0; k < sb->shape_owner_get_shape_count(E->get()); k++) {
- Ref<Shape> shape = sb->shape_owner_get_shape(E->get(), k);
- p_library->tile_add_shape(id, shape, shape_offset, one_way);
+ Ref<Shape2D> shape = sb->shape_owner_get_shape(E->get(), k);
+ TileSet::ShapeData shape_data;
+ shape_data.shape = shape;
+ shape_data.shape_transform = shape_transform;
+ shape_data.one_way_collision = one_way;
+ collisions.push_back(shape_data);
}
}
}
+ if (found_collisions) {
+ p_library->tile_set_shapes(id, collisions);
+ }
+
p_library->tile_set_texture_offset(id, mi->get_offset());
p_library->tile_set_navigation_polygon(id, nav_poly);
p_library->tile_set_light_occluder(id, occluder);