summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/canvas_item.cpp23
-rw-r--r--scene/2d/canvas_item.h2
-rw-r--r--scene/2d/collision_object_2d.cpp6
-rw-r--r--scene/2d/collision_object_2d.h2
-rw-r--r--scene/2d/tile_map.cpp8
-rw-r--r--scene/3d/mesh_instance.cpp3
-rw-r--r--scene/gui/graph_edit.cpp20
-rw-r--r--scene/gui/graph_edit.h2
-rw-r--r--scene/gui/split_container.cpp22
-rw-r--r--scene/resources/primitive_meshes.cpp24
-rw-r--r--scene/resources/primitive_meshes.h3
-rw-r--r--scene/resources/tile_set.cpp46
-rw-r--r--scene/resources/tile_set.h8
13 files changed, 116 insertions, 53 deletions
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index 4a80aba355..68a3166aa7 100644
--- a/scene/2d/canvas_item.cpp
+++ b/scene/2d/canvas_item.cpp
@@ -609,6 +609,27 @@ void CanvasItem::draw_line(const Point2 &p_from, const Point2 &p_to, const Color
VisualServer::get_singleton()->canvas_item_add_line(canvas_item, p_from, p_to, p_color, p_width, p_antialiased);
}
+void CanvasItem::draw_polyline(const Vector<Point2> &p_points, const Color &p_color, float p_width, bool p_antialiased) {
+
+ if (!drawing) {
+ ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
+ ERR_FAIL();
+ }
+
+ Vector<Color> colors;
+ colors.push_back(p_color);
+ VisualServer::get_singleton()->canvas_item_add_polyline(canvas_item, p_points, colors, p_width, p_antialiased);
+}
+
+void CanvasItem::draw_polyline_colors(const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width, bool p_antialiased) {
+
+ if (!drawing) {
+ ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
+ ERR_FAIL();
+ }
+
+ VisualServer::get_singleton()->canvas_item_add_polyline(canvas_item, p_points, p_colors, p_width, p_antialiased);
+}
void CanvasItem::draw_rect(const Rect2 &p_rect, const Color &p_color, bool p_filled) {
if (!drawing) {
@@ -955,6 +976,8 @@ void CanvasItem::_bind_methods() {
//ClassDB::bind_method(D_METHOD("get_transform"),&CanvasItem::get_transform);
ClassDB::bind_method(D_METHOD("draw_line", "from", "to", "color", "width", "antialiased"), &CanvasItem::draw_line, DEFVAL(1.0), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("draw_polyline", "points", "color", "width", "antialiased"), &CanvasItem::draw_polyline, DEFVAL(1.0), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("draw_polyline_colors", "points", "colors", "width", "antialiased"), &CanvasItem::draw_polyline_colors, DEFVAL(1.0), DEFVAL(false));
ClassDB::bind_method(D_METHOD("draw_rect", "rect", "color", "filled"), &CanvasItem::draw_rect, DEFVAL(true));
ClassDB::bind_method(D_METHOD("draw_circle", "pos", "radius", "color"), &CanvasItem::draw_circle);
ClassDB::bind_method(D_METHOD("draw_texture", "texture:Texture", "pos", "modulate", "normal_map:Texture"), &CanvasItem::draw_texture, DEFVAL(Color(1, 1, 1, 1)), DEFVAL(Variant()));
diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h
index 06130e3252..27842727ac 100644
--- a/scene/2d/canvas_item.h
+++ b/scene/2d/canvas_item.h
@@ -242,6 +242,8 @@ public:
/* DRAWING API */
void draw_line(const Point2 &p_from, const Point2 &p_to, const Color &p_color, float p_width = 1.0, bool p_antialiased = false);
+ void draw_polyline(const Vector<Point2> &p_points, const Color &p_color, float p_width = 1.0, bool p_antialiased = false);
+ void draw_polyline_colors(const Vector<Point2> &p_points, const Vector<Color> &p_colors, float p_width = 1.0, bool p_antialiased = false);
void draw_rect(const Rect2 &p_rect, const Color &p_color, bool p_filled = true);
void draw_circle(const Point2 &p_pos, float p_radius, const Color &p_color);
void draw_texture(const Ref<Texture> &p_texture, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1, 1), const Ref<Texture> &p_normal_map = Ref<Texture>());
diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp
index c5c274e225..0821b00dd9 100644
--- a/scene/2d/collision_object_2d.cpp
+++ b/scene/2d/collision_object_2d.cpp
@@ -204,10 +204,10 @@ int CollisionObject2D::shape_owner_get_shape_count(uint32_t p_owner) const {
return shapes[p_owner].shapes.size();
}
-Ref<Shape> CollisionObject2D::shape_owner_get_shape(uint32_t p_owner, int p_shape) const {
+Ref<Shape2D> CollisionObject2D::shape_owner_get_shape(uint32_t p_owner, int p_shape) const {
- ERR_FAIL_COND_V(!shapes.has(p_owner), Ref<Shape>());
- ERR_FAIL_INDEX_V(p_shape, shapes[p_owner].shapes.size(), Ref<Shape>());
+ ERR_FAIL_COND_V(!shapes.has(p_owner), Ref<Shape2D>());
+ ERR_FAIL_INDEX_V(p_shape, shapes[p_owner].shapes.size(), Ref<Shape2D>());
return shapes[p_owner].shapes[p_shape].shape;
}
diff --git a/scene/2d/collision_object_2d.h b/scene/2d/collision_object_2d.h
index deffe8a002..3580d3d942 100644
--- a/scene/2d/collision_object_2d.h
+++ b/scene/2d/collision_object_2d.h
@@ -94,7 +94,7 @@ public:
void shape_owner_add_shape(uint32_t p_owner, const Ref<Shape2D> &p_shape);
int shape_owner_get_shape_count(uint32_t p_owner) const;
- Ref<Shape> shape_owner_get_shape(uint32_t p_owner, int p_shape) const;
+ Ref<Shape2D> shape_owner_get_shape(uint32_t p_owner, int p_shape) const;
int shape_owner_get_shape_index(uint32_t p_owner, int p_shape) const;
void shape_owner_remove_shape(uint32_t p_owner, int p_shape);
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index 57e25ec609..9d70b75027 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -461,16 +461,18 @@ void TileMap::_update_dirty_quadrants() {
Transform2D xform;
xform.set_origin(offset.floor());
- _fix_cell_transform(xform, c, shapes[i].shape_offset + center_ofs, s);
+ _fix_cell_transform(xform, c, center_ofs, s);
+
+ xform *= shapes[i].shape_transform;
if (debug_canvas_item.is_valid()) {
vs->canvas_item_add_set_transform(debug_canvas_item, xform);
shape->draw(debug_canvas_item, debug_collision_color);
}
ps->body_add_shape(q.body, shape->get_rid(), xform);
- shape_idx++;
- ps->body_set_shape_as_one_way_collision(q.body, shape_idx, shapes[i].one_way_collision);
ps->body_set_shape_metadata(q.body, shape_idx, Vector2(E->key().x, E->key().y));
+ ps->body_set_shape_as_one_way_collision(q.body, shape_idx, shapes[i].one_way_collision);
+ shape_idx++;
}
}
diff --git a/scene/3d/mesh_instance.cpp b/scene/3d/mesh_instance.cpp
index e755b1480b..a0d9c26430 100644
--- a/scene/3d/mesh_instance.cpp
+++ b/scene/3d/mesh_instance.cpp
@@ -281,6 +281,9 @@ void MeshInstance::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_skeleton_path", "skeleton_path:NodePath"), &MeshInstance::set_skeleton_path);
ClassDB::bind_method(D_METHOD("get_skeleton_path:NodePath"), &MeshInstance::get_skeleton_path);
+ ClassDB::bind_method(D_METHOD("set_surface_material", "surface", "material:Material"), &MeshInstance::set_surface_material);
+ ClassDB::bind_method(D_METHOD("get_surface_material:Material", "surface"), &MeshInstance::get_surface_material);
+
ClassDB::bind_method(D_METHOD("create_trimesh_collision"), &MeshInstance::create_trimesh_collision);
ClassDB::set_method_flags("MeshInstance", "create_trimesh_collision", METHOD_FLAGS_DEFAULT);
ClassDB::bind_method(D_METHOD("create_convex_collision"), &MeshInstance::create_convex_collision);
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index 8d085d5399..9d45b6e70a 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -568,7 +568,7 @@ static _FORCE_INLINE_ Vector2 _bezier_interp(real_t t, Vector2 start, Vector2 co
return start * omt3 + control_1 * omt2 * t * 3.0 + control_2 * omt * t2 * 3.0 + end * t3;
}
-void GraphEdit::_bake_segment2d(CanvasItem *p_where, float p_begin, float p_end, const Vector2 &p_a, const Vector2 &p_out, const Vector2 &p_b, const Vector2 &p_in, int p_depth, int p_min_depth, int p_max_depth, float p_tol, const Color &p_color, const Color &p_to_color, int &lines) const {
+void GraphEdit::_bake_segment2d(Vector<Vector2> &points, Vector<Color> &colors, float p_begin, float p_end, const Vector2 &p_a, const Vector2 &p_out, const Vector2 &p_b, const Vector2 &p_in, int p_depth, int p_min_depth, int p_max_depth, float p_tol, const Color &p_color, const Color &p_to_color, int &lines) const {
float mp = p_begin + (p_end - p_begin) * 0.5;
Vector2 beg = _bezier_interp(p_begin, p_a, p_a + p_out, p_b + p_in, p_b);
@@ -581,11 +581,12 @@ void GraphEdit::_bake_segment2d(CanvasItem *p_where, float p_begin, float p_end,
if (p_depth >= p_min_depth && (dp < p_tol || p_depth >= p_max_depth)) {
- p_where->draw_line(beg, end, p_color.linear_interpolate(p_to_color, mp), 2, true);
+ points.push_back((beg + end) * 0.5);
+ colors.push_back(p_color.linear_interpolate(p_to_color, mp));
lines++;
} else {
- _bake_segment2d(p_where, p_begin, mp, p_a, p_out, p_b, p_in, p_depth + 1, p_min_depth, p_max_depth, p_tol, p_color, p_to_color, lines);
- _bake_segment2d(p_where, mp, p_end, p_a, p_out, p_b, p_in, p_depth + 1, p_min_depth, p_max_depth, p_tol, p_color, p_to_color, lines);
+ _bake_segment2d(points, colors, p_begin, mp, p_a, p_out, p_b, p_in, p_depth + 1, p_min_depth, p_max_depth, p_tol, p_color, p_to_color, lines);
+ _bake_segment2d(points, colors, mp, p_end, p_a, p_out, p_b, p_in, p_depth + 1, p_min_depth, p_max_depth, p_tol, p_color, p_to_color, lines);
}
}
@@ -609,7 +610,16 @@ void GraphEdit::_draw_cos_line(CanvasItem *p_where, const Vector2 &p_from, const
Vector2 c2 = Vector2(-cp_offset * zoom, 0);
int lines = 0;
- _bake_segment2d(p_where, 0, 1, p_from, c1, p_to, c2, 0, 3, 9, 8, p_color, p_to_color, lines);
+
+ Vector<Point2> points;
+ Vector<Color> colors;
+ points.push_back(p_from);
+ colors.push_back(p_color);
+ _bake_segment2d(points, colors, 0, 1, p_from, c1, p_to, c2, 0, 3, 9, 8, p_color, p_to_color, lines);
+ points.push_back(p_to);
+ colors.push_back(p_to_color);
+
+ p_where->draw_polyline_colors(points, colors, 2, true);
#else
diff --git a/scene/gui/graph_edit.h b/scene/gui/graph_edit.h
index 22d053d312..e908829d5f 100644
--- a/scene/gui/graph_edit.h
+++ b/scene/gui/graph_edit.h
@@ -110,7 +110,7 @@ private:
bool awaiting_scroll_offset_update;
List<Connection> connections;
- void _bake_segment2d(CanvasItem *p_where, float p_begin, float p_end, const Vector2 &p_a, const Vector2 &p_out, const Vector2 &p_b, const Vector2 &p_in, int p_depth, int p_min_depth, int p_max_depth, float p_tol, const Color &p_color, const Color &p_to_color, int &lines) const;
+ void _bake_segment2d(Vector<Vector2> &points, Vector<Color> &colors, float p_begin, float p_end, const Vector2 &p_a, const Vector2 &p_out, const Vector2 &p_b, const Vector2 &p_in, int p_depth, int p_min_depth, int p_max_depth, float p_tol, const Color &p_color, const Color &p_to_color, int &lines) const;
void _draw_cos_line(CanvasItem *p_where, const Vector2 &p_from, const Vector2 &p_to, const Color &p_color, const Color &p_to_color);
diff --git a/scene/gui/split_container.cpp b/scene/gui/split_container.cpp
index 31236fa277..e3dad08809 100644
--- a/scene/gui/split_container.cpp
+++ b/scene/gui/split_container.cpp
@@ -131,7 +131,12 @@ void SplitContainer::_resort() {
if (ratiomode) {
- middle_sep = ms_first[axis] + available / 2;
+ int first_ratio = first->get_stretch_ratio();
+ int second_ratio = second->get_stretch_ratio();
+
+ float ratio = float(first_ratio) / (first_ratio + second_ratio);
+
+ middle_sep = ms_first[axis] + available * ratio;
} else if (expand_first_mode) {
@@ -144,12 +149,17 @@ void SplitContainer::_resort() {
} else if (ratiomode) {
- if (expand_ofs < -(available / 2))
- expand_ofs = -(available / 2);
- else if (expand_ofs > (available / 2))
- expand_ofs = (available / 2);
+ int first_ratio = first->get_stretch_ratio();
+ int second_ratio = second->get_stretch_ratio();
+
+ float ratio = float(first_ratio) / (first_ratio + second_ratio);
+
+ if (expand_ofs < -(available * ratio))
+ expand_ofs = -(available * ratio);
+ else if (expand_ofs > (available * (1.0 - ratio)))
+ expand_ofs = (available * (1.0 - ratio));
- middle_sep = ms_first[axis] + available / 2 + expand_ofs;
+ middle_sep = ms_first[axis] + available * ratio + expand_ofs;
} else if (expand_first_mode) {
diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp
index 8d058377db..6e41cef4a0 100644
--- a/scene/resources/primitive_meshes.cpp
+++ b/scene/resources/primitive_meshes.cpp
@@ -53,7 +53,15 @@ void PrimitiveMesh::_update() {
emit_changed();
}
-void PrimitiveMesh::_queue_update() {
+void PrimitiveMesh::_queue_update(bool p_first_mesh) {
+
+ if (first_mesh && p_first_mesh) {
+ first_mesh = false;
+ cache_is_dirty = true;
+ _update();
+ return;
+ }
+
if (!cache_is_dirty) {
cache_is_dirty = true;
call_deferred("_update");
@@ -145,6 +153,7 @@ PrimitiveMesh::PrimitiveMesh() {
// make sure we do an update after we've finished constructing our object
cache_is_dirty = false;
+ first_mesh = true;
_queue_update();
}
@@ -350,7 +359,7 @@ int CapsuleMesh::get_radial_segments() const {
void CapsuleMesh::set_rings(const int p_rings) {
rings = p_rings > 1 ? p_rings : 1;
- _queue_update();
+ _queue_update(true); //last property set, force update mesh
}
int CapsuleMesh::get_rings() const {
@@ -608,7 +617,7 @@ int CubeMesh::get_subdivide_height() const {
void CubeMesh::set_subdivide_depth(const int p_subdivide) {
subdivide_d = p_subdivide > 0 ? p_subdivide : 0;
- _queue_update();
+ _queue_update(true); //last property set, force update mesh
}
int CubeMesh::get_subdivide_depth() const {
@@ -825,7 +834,7 @@ int CylinderMesh::get_radial_segments() const {
void CylinderMesh::set_rings(const int p_rings) {
rings = p_rings > 0 ? p_rings : 0;
- _queue_update();
+ _queue_update(true); //last property set, force update mesh
}
int CylinderMesh::get_rings() const {
@@ -942,7 +951,7 @@ int PlaneMesh::get_subdivide_width() const {
void PlaneMesh::set_subdivide_depth(const int p_subdivide) {
subdivide_d = p_subdivide > 0 ? p_subdivide : 0;
- _queue_update();
+ _queue_update(true); //last property set, force update mesh
}
int PlaneMesh::get_subdivide_depth() const {
@@ -1232,7 +1241,7 @@ int PrismMesh::get_subdivide_height() const {
void PrismMesh::set_subdivide_depth(const int p_divisions) {
subdivide_d = p_divisions > 0 ? p_divisions : 0;
- _queue_update();
+ _queue_update(true); //last property set, force update mesh
}
int PrismMesh::get_subdivide_depth() const {
@@ -1301,6 +1310,7 @@ void QuadMesh::_bind_methods() {
QuadMesh::QuadMesh() {
primitive_type = PRIMITIVE_TRIANGLE_FAN;
+ _queue_update(true);
}
/**
@@ -1437,7 +1447,7 @@ int SphereMesh::get_rings() const {
void SphereMesh::set_is_hemisphere(const bool p_is_hemisphere) {
is_hemisphere = p_is_hemisphere;
- _queue_update();
+ _queue_update(true); //last property set, force update mesh
}
bool SphereMesh::get_is_hemisphere() const {
diff --git a/scene/resources/primitive_meshes.h b/scene/resources/primitive_meshes.h
index 91d1af2ee1..5e1387e864 100644
--- a/scene/resources/primitive_meshes.h
+++ b/scene/resources/primitive_meshes.h
@@ -51,6 +51,7 @@ private:
Ref<Material> material;
+ bool first_mesh;
bool cache_is_dirty;
void _update();
@@ -60,7 +61,7 @@ protected:
static void _bind_methods();
virtual void _create_mesh_array(Array &p_arr) = 0;
- void _queue_update();
+ void _queue_update(bool p_first_mesh = false); //pretty bad hack to have the mesh built firt time parameters are set without delay
void set_aabb(Rect3 p_aabb);
diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp
index b9d2c503e1..d00d2d96c4 100644
--- a/scene/resources/tile_set.cpp
+++ b/scene/resources/tile_set.cpp
@@ -57,8 +57,8 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
tile_set_region(id, p_value);
else if (what == "shape")
tile_set_shape(id, 0, p_value);
- else if (what == "shape_offset")
- tile_set_shape_offset(id, 0, p_value);
+ else if (what == "shape_transform")
+ tile_set_shape_transform(id, 0, p_value);
else if (what == "shape_one_way")
tile_set_shape_one_way(id, 0, p_value);
else if (what == "shapes")
@@ -105,8 +105,8 @@ bool TileSet::_get(const StringName &p_name, Variant &r_ret) const {
r_ret = tile_get_region(id);
else if (what == "shape")
r_ret = tile_get_shape(id, 0);
- else if (what == "shape_offset")
- r_ret = tile_get_shape_offset(id, 0);
+ else if (what == "shape_transform")
+ r_ret = tile_get_shape_transform(id, 0);
else if (what == "shape_one_way")
r_ret = tile_get_shape_one_way(id, 0);
else if (what == "shapes")
@@ -142,7 +142,7 @@ void TileSet::_get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::OBJECT, pre + "occluder", PROPERTY_HINT_RESOURCE_TYPE, "OccluderPolygon2D"));
p_list->push_back(PropertyInfo(Variant::VECTOR2, pre + "navigation_offset"));
p_list->push_back(PropertyInfo(Variant::OBJECT, pre + "navigation", PROPERTY_HINT_RESOURCE_TYPE, "NavigationPolygon"));
- p_list->push_back(PropertyInfo(Variant::VECTOR2, pre + "shape_offset", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR));
+ p_list->push_back(PropertyInfo(Variant::VECTOR2, pre + "shape_transform", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR));
p_list->push_back(PropertyInfo(Variant::OBJECT, pre + "shape", PROPERTY_HINT_RESOURCE_TYPE, "Shape2D", PROPERTY_USAGE_EDITOR));
p_list->push_back(PropertyInfo(Variant::BOOL, pre + "shape_one_way", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR));
p_list->push_back(PropertyInfo(Variant::ARRAY, pre + "shapes", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
@@ -252,13 +252,13 @@ void TileSet::tile_clear_shapes(int p_id) {
tile_map[p_id].shapes_data.clear();
}
-void TileSet::tile_add_shape(int p_id, const Ref<Shape2D> &p_shape, const Vector2 &p_offset, bool p_one_way) {
+void TileSet::tile_add_shape(int p_id, const Ref<Shape2D> &p_shape, const Transform2D &p_transform, bool p_one_way) {
ERR_FAIL_COND(!tile_map.has(p_id));
ShapeData new_data = ShapeData();
new_data.shape = p_shape;
- new_data.shape_offset = p_offset;
+ new_data.shape_transform = p_transform;
new_data.one_way_collision = p_one_way;
tile_map[p_id].shapes_data.push_back(new_data);
@@ -288,22 +288,22 @@ Ref<Shape2D> TileSet::tile_get_shape(int p_id, int p_shape_id) const {
return Ref<Shape2D>();
}
-void TileSet::tile_set_shape_offset(int p_id, int p_shape_id, const Vector2 &p_offset) {
+void TileSet::tile_set_shape_transform(int p_id, int p_shape_id, const Transform2D &p_offset) {
ERR_FAIL_COND(!tile_map.has(p_id));
if (tile_map[p_id].shapes_data.size() <= p_shape_id)
tile_map[p_id].shapes_data.resize(p_shape_id + 1);
- tile_map[p_id].shapes_data[p_shape_id].shape_offset = p_offset;
+ tile_map[p_id].shapes_data[p_shape_id].shape_transform = p_offset;
emit_changed();
}
-Vector2 TileSet::tile_get_shape_offset(int p_id, int p_shape_id) const {
+Transform2D TileSet::tile_get_shape_transform(int p_id, int p_shape_id) const {
- ERR_FAIL_COND_V(!tile_map.has(p_id), Vector2());
+ ERR_FAIL_COND_V(!tile_map.has(p_id), Transform2D());
if (tile_map[p_id].shapes_data.size() > p_shape_id)
- return tile_map[p_id].shapes_data[p_shape_id].shape_offset;
+ return tile_map[p_id].shapes_data[p_shape_id].shape_transform;
- return Vector2();
+ return Transform2D();
}
void TileSet::tile_set_shape_one_way(int p_id, int p_shape_id, const bool p_one_way) {
@@ -388,7 +388,7 @@ void TileSet::_tile_set_shapes(int p_id, const Array &p_shapes) {
ERR_FAIL_COND(!tile_map.has(p_id));
Vector<ShapeData> shapes_data;
- Vector2 default_offset = tile_get_shape_offset(p_id, 0);
+ Transform2D default_transform = tile_get_shape_transform(p_id, 0);
bool default_one_way = tile_get_shape_one_way(p_id, 0);
for (int i = 0; i < p_shapes.size(); i++) {
ShapeData s = ShapeData();
@@ -398,7 +398,7 @@ void TileSet::_tile_set_shapes(int p_id, const Array &p_shapes) {
if (shape.is_null()) continue;
s.shape = shape;
- s.shape_offset = default_offset;
+ s.shape_transform = default_transform;
s.one_way_collision = default_one_way;
} else if (p_shapes[i].get_type() == Variant::DICTIONARY) {
Dictionary d = p_shapes[i];
@@ -408,10 +408,12 @@ void TileSet::_tile_set_shapes(int p_id, const Array &p_shapes) {
else
continue;
- if (d.has("shape_offset") && d["shape_offset"].get_type() == Variant::VECTOR2)
- s.shape_offset = d["shape_offset"];
+ if (d.has("shape_transform") && d["shape_transform"].get_type() == Variant::TRANSFORM2D)
+ s.shape_transform = d["shape_transform"];
+ else if (d.has("shape_offset") && d["shape_offset"].get_type() == Variant::VECTOR2)
+ s.shape_transform = Transform2D(0, (Vector2)d["shape_offset"]);
else
- s.shape_offset = default_offset;
+ s.shape_transform = default_transform;
if (d.has("one_way") && d["one_way"].get_type() == Variant::BOOL)
s.one_way_collision = d["one_way"];
@@ -438,7 +440,7 @@ Array TileSet::_tile_get_shapes(int p_id) const {
for (int i = 0; i < data.size(); i++) {
Dictionary shape_data;
shape_data["shape"] = data[i].shape;
- shape_data["shape_offset"] = data[i].shape_offset;
+ shape_data["shape_transform"] = data[i].shape_transform;
shape_data["one_way"] = data[i].one_way_collision;
arr.push_back(shape_data);
}
@@ -520,11 +522,11 @@ void TileSet::_bind_methods() {
ClassDB::bind_method(D_METHOD("tile_get_region", "id"), &TileSet::tile_get_region);
ClassDB::bind_method(D_METHOD("tile_set_shape", "id", "shape_id", "shape:Shape2D"), &TileSet::tile_set_shape);
ClassDB::bind_method(D_METHOD("tile_get_shape:Shape2D", "id", "shape_id"), &TileSet::tile_get_shape);
- ClassDB::bind_method(D_METHOD("tile_set_shape_offset", "id", "shape_id", "shape_offset"), &TileSet::tile_set_shape_offset);
- ClassDB::bind_method(D_METHOD("tile_get_shape_offset", "id", "shape_id"), &TileSet::tile_get_shape_offset);
+ ClassDB::bind_method(D_METHOD("tile_set_shape_transform", "id", "shape_id", "shape_transform"), &TileSet::tile_set_shape_transform);
+ ClassDB::bind_method(D_METHOD("tile_get_shape_transform", "id", "shape_id"), &TileSet::tile_get_shape_transform);
ClassDB::bind_method(D_METHOD("tile_set_shape_one_way", "id", "shape_id", "one_way"), &TileSet::tile_set_shape_one_way);
ClassDB::bind_method(D_METHOD("tile_get_shape_one_way", "id", "shape_id"), &TileSet::tile_get_shape_one_way);
- ClassDB::bind_method(D_METHOD("tile_add_shape", "id", "shape:Shape2D", "shape_offset", "one_way"), &TileSet::tile_add_shape, DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("tile_add_shape", "id", "shape:Shape2D", "shape_transform", "one_way"), &TileSet::tile_add_shape, DEFVAL(false));
ClassDB::bind_method(D_METHOD("tile_get_shape_count", "id"), &TileSet::tile_get_shape_count);
ClassDB::bind_method(D_METHOD("tile_set_shapes", "id", "shapes"), &TileSet::_tile_set_shapes);
ClassDB::bind_method(D_METHOD("tile_get_shapes", "id"), &TileSet::_tile_get_shapes);
diff --git a/scene/resources/tile_set.h b/scene/resources/tile_set.h
index c07d82c75a..99c506390c 100644
--- a/scene/resources/tile_set.h
+++ b/scene/resources/tile_set.h
@@ -43,7 +43,7 @@ class TileSet : public Resource {
public:
struct ShapeData {
Ref<Shape2D> shape;
- Vector2 shape_offset;
+ Transform2D shape_transform;
bool one_way_collision;
ShapeData() {
@@ -105,14 +105,14 @@ public:
void tile_set_shape(int p_id, int p_shape_id, const Ref<Shape2D> &p_shape);
Ref<Shape2D> tile_get_shape(int p_id, int p_shape_id) const;
- void tile_set_shape_offset(int p_id, int p_shape_id, const Vector2 &p_offset);
- Vector2 tile_get_shape_offset(int p_id, int p_shape_id) const;
+ void tile_set_shape_transform(int p_id, int p_shape_id, const Transform2D &p_transform);
+ Transform2D tile_get_shape_transform(int p_id, int p_shape_id) const;
void tile_set_shape_one_way(int p_id, int p_shape_id, bool p_one_way);
bool tile_get_shape_one_way(int p_id, int p_shape_id) const;
void tile_clear_shapes(int p_id);
- void tile_add_shape(int p_id, const Ref<Shape2D> &p_shape, const Vector2 &p_offset, bool p_one_way = false);
+ void tile_add_shape(int p_id, const Ref<Shape2D> &p_shape, const Transform2D &p_transform, bool p_one_way = false);
int tile_get_shape_count(int p_id) const;
void tile_set_shapes(int p_id, const Vector<ShapeData> &p_shapes);