summaryrefslogtreecommitdiff
path: root/scene/2d
diff options
context:
space:
mode:
Diffstat (limited to 'scene/2d')
-rw-r--r--scene/2d/navigation_region_2d.cpp2
-rw-r--r--scene/2d/navigation_region_2d.h2
-rw-r--r--scene/2d/node_2d.cpp42
-rw-r--r--scene/2d/node_2d.h5
-rw-r--r--scene/2d/tile_map.cpp7
5 files changed, 49 insertions, 9 deletions
diff --git a/scene/2d/navigation_region_2d.cpp b/scene/2d/navigation_region_2d.cpp
index 19484442b1..abbfbf83b7 100644
--- a/scene/2d/navigation_region_2d.cpp
+++ b/scene/2d/navigation_region_2d.cpp
@@ -118,7 +118,7 @@ Array NavigationPolygon::_get_polygons() const {
return ret;
}
-void NavigationPolygon::_set_outlines(const TypedArray<Vector<int32_t>> &p_array) {
+void NavigationPolygon::_set_outlines(const TypedArray<Vector<Vector2>> &p_array) {
outlines.resize(p_array.size());
for (int i = 0; i < p_array.size(); i++) {
diff --git a/scene/2d/navigation_region_2d.h b/scene/2d/navigation_region_2d.h
index cbfe4299fb..e730df6373 100644
--- a/scene/2d/navigation_region_2d.h
+++ b/scene/2d/navigation_region_2d.h
@@ -58,7 +58,7 @@ protected:
void _set_polygons(const TypedArray<Vector<int32_t>> &p_array);
Array _get_polygons() const;
- void _set_outlines(const TypedArray<Vector<int32_t>> &p_array);
+ void _set_outlines(const TypedArray<Vector<Vector2>> &p_array);
Array _get_outlines() const;
public:
diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp
index ac8a77b6cb..1ea51be148 100644
--- a/scene/2d/node_2d.cpp
+++ b/scene/2d/node_2d.cpp
@@ -42,6 +42,7 @@ Dictionary Node2D::_edit_get_state() const {
state["position"] = get_position();
state["rotation"] = get_rotation();
state["scale"] = get_scale();
+ state["skew"] = get_skew();
return state;
}
@@ -51,11 +52,14 @@ void Node2D::_edit_set_state(const Dictionary &p_state) {
pos = p_state["position"];
angle = p_state["rotation"];
_scale = p_state["scale"];
+ skew = p_state["skew"];
_update_transform();
_change_notify("rotation");
_change_notify("rotation_degrees");
_change_notify("scale");
+ _change_notify("skew");
+ _change_notify("skew_degrees");
_change_notify("position");
}
@@ -111,7 +115,7 @@ void Node2D::_edit_set_rect(const Rect2 &p_edit_rect) {
Point2 new_pos = p_edit_rect.position + p_edit_rect.size * zero_offset;
Transform2D postxf;
- postxf.set_rotation_and_scale(angle, _scale);
+ postxf.set_rotation_scale_and_skew(angle, _scale, skew);
new_pos = postxf.xform(new_pos);
pos += new_pos;
@@ -128,12 +132,13 @@ void Node2D::_update_xform_values() {
pos = _mat.elements[2];
angle = _mat.get_rotation();
_scale = _mat.get_scale();
+ skew = _mat.get_skew();
_xform_dirty = false;
}
void Node2D::_update_transform() {
- _mat.set_rotation_and_scale(angle, _scale);
+ _mat.set_rotation_scale_and_skew(angle, _scale, skew);
_mat.elements[2] = pos;
RenderingServer::get_singleton()->canvas_item_set_transform(get_canvas_item(), _mat);
@@ -163,11 +168,26 @@ void Node2D::set_rotation(float p_radians) {
_change_notify("rotation_degrees");
}
+void Node2D::set_skew(float p_radians) {
+
+ if (_xform_dirty)
+ ((Node2D *)this)->_update_xform_values();
+ skew = p_radians;
+ _update_transform();
+ _change_notify("skew");
+ _change_notify("skew_degrees");
+}
+
void Node2D::set_rotation_degrees(float p_degrees) {
set_rotation(Math::deg2rad(p_degrees));
}
+void Node2D::set_skew_degrees(float p_degrees) {
+
+ set_skew(Math::deg2rad(p_degrees));
+}
+
void Node2D::set_scale(const Size2 &p_scale) {
if (_xform_dirty)
@@ -196,11 +216,22 @@ float Node2D::get_rotation() const {
return angle;
}
+float Node2D::get_skew() const {
+ if (_xform_dirty)
+ ((Node2D *)this)->_update_xform_values();
+
+ return skew;
+}
+
float Node2D::get_rotation_degrees() const {
return Math::rad2deg(get_rotation());
}
+float Node2D::get_skew_degrees() const {
+
+ return Math::rad2deg(get_skew());
+}
Size2 Node2D::get_scale() const {
if (_xform_dirty)
((Node2D *)this)->_update_xform_values();
@@ -398,11 +429,15 @@ void Node2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_position", "position"), &Node2D::set_position);
ClassDB::bind_method(D_METHOD("set_rotation", "radians"), &Node2D::set_rotation);
ClassDB::bind_method(D_METHOD("set_rotation_degrees", "degrees"), &Node2D::set_rotation_degrees);
+ ClassDB::bind_method(D_METHOD("set_skew", "radians"), &Node2D::set_skew);
+ ClassDB::bind_method(D_METHOD("set_skew_degrees", "degrees"), &Node2D::set_skew_degrees);
ClassDB::bind_method(D_METHOD("set_scale", "scale"), &Node2D::set_scale);
ClassDB::bind_method(D_METHOD("get_position"), &Node2D::get_position);
ClassDB::bind_method(D_METHOD("get_rotation"), &Node2D::get_rotation);
ClassDB::bind_method(D_METHOD("get_rotation_degrees"), &Node2D::get_rotation_degrees);
+ ClassDB::bind_method(D_METHOD("get_skew"), &Node2D::get_skew);
+ ClassDB::bind_method(D_METHOD("get_skew_degrees"), &Node2D::get_skew_degrees);
ClassDB::bind_method(D_METHOD("get_scale"), &Node2D::get_scale);
ClassDB::bind_method(D_METHOD("rotate", "radians"), &Node2D::rotate);
@@ -443,6 +478,8 @@ void Node2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rotation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_rotation", "get_rotation");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rotation_degrees", PROPERTY_HINT_RANGE, "-360,360,0.1,or_lesser,or_greater", PROPERTY_USAGE_EDITOR), "set_rotation_degrees", "get_rotation_degrees");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scale"), "set_scale", "get_scale");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "skew", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_skew", "get_skew");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "skew_degrees", PROPERTY_HINT_RANGE, "-89.9,89.9,0.1", PROPERTY_USAGE_EDITOR), "set_skew_degrees", "get_skew_degrees");
ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "transform", PROPERTY_HINT_NONE, "", 0), "set_transform", "get_transform");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "global_position", PROPERTY_HINT_NONE, "", 0), "set_global_position", "get_global_position");
@@ -460,6 +497,7 @@ Node2D::Node2D() {
angle = 0;
_scale = Vector2(1, 1);
+ skew = 0;
_xform_dirty = false;
z_index = 0;
z_relative = true;
diff --git a/scene/2d/node_2d.h b/scene/2d/node_2d.h
index abed05ed0c..0afec36254 100644
--- a/scene/2d/node_2d.h
+++ b/scene/2d/node_2d.h
@@ -40,6 +40,7 @@ class Node2D : public CanvasItem {
Point2 pos;
float angle;
Size2 _scale;
+ float skew;
int z_index;
bool z_relative;
@@ -75,6 +76,8 @@ public:
void set_position(const Point2 &p_pos);
void set_rotation(float p_radians);
void set_rotation_degrees(float p_degrees);
+ void set_skew(float p_radians);
+ void set_skew_degrees(float p_radians);
void set_scale(const Size2 &p_scale);
void rotate(float p_radians);
@@ -86,7 +89,9 @@ public:
Point2 get_position() const;
float get_rotation() const;
+ float get_skew() const;
float get_rotation_degrees() const;
+ float get_skew_degrees() const;
Size2 get_scale() const;
Point2 get_global_position() const;
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index 9628c01718..86e61fe878 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -940,13 +940,10 @@ void TileMap::update_bitmask_area(const Vector2 &p_pos) {
void TileMap::update_bitmask_region(const Vector2 &p_start, const Vector2 &p_end) {
if ((p_end.x < p_start.x || p_end.y < p_start.y) || (p_end.x == p_start.x && p_end.y == p_start.y)) {
- int i;
Array a = get_used_cells();
- for (i = 0; i < a.size(); i++) {
- // update_bitmask_area() in order to update cells adjacent to the
- // current cell, since ordering in array may not be reliable
+ for (int i = 0; i < a.size(); i++) {
Vector2 vector = (Vector2)a[i];
- update_bitmask_area(Vector2(vector.x, vector.y));
+ update_cell_bitmask(vector.x, vector.y);
}
return;
}