diff options
-rw-r--r-- | main/input_default.cpp | 17 | ||||
-rw-r--r-- | modules/gdscript/gd_tokenizer.cpp | 1 | ||||
-rw-r--r-- | scene/2d/node_2d.cpp | 22 | ||||
-rw-r--r-- | scene/gui/control.cpp | 12 |
4 files changed, 36 insertions, 16 deletions
diff --git a/main/input_default.cpp b/main/input_default.cpp index 131e9e3b90..0a5d06c0d3 100644 --- a/main/input_default.cpp +++ b/main/input_default.cpp @@ -485,12 +485,27 @@ void InputDefault::warp_mouse_pos(const Vector2 &p_to) { Point2i InputDefault::warp_mouse_motion(const InputEventMouseMotion &p_motion, const Rect2 &p_rect) { - const Point2i rel_warped(Math::fmod(p_motion.relative_x, p_rect.size.x), Math::fmod(p_motion.relative_y, p_rect.size.y)); + // The relative distance reported for the next event after a warp is in the boundaries of the + // size of the rect on that axis, but it may be greater, in which case there's not problem as fmod() + // will warp it, but if the pointer has moved in the opposite direction between the pointer relocation + // and the subsequent event, the reported relative distance will be less than the size of the rect + // and thus fmod() will be disabled for handling the situation. + // And due to this mouse warping mechanism being stateless, we need to apply some heuristics to + // detect the warp: if the relative distance is greater than the half of the size of the relevant rect + // (checked per each axis), it will be considered as the consequence of a former pointer warp. + + const Point2i rel_sgn(p_motion.relative_x >= 0.0f ? 1 : -1, p_motion.relative_y >= 0.0 ? 1 : -1); + const Size2i warp_margin = p_rect.size * 0.5f; + const Point2i rel_warped( + Math::fmod(p_motion.relative_x + rel_sgn.x * warp_margin.x, p_rect.size.x) - rel_sgn.x * warp_margin.x, + Math::fmod(p_motion.relative_y + rel_sgn.y * warp_margin.y, p_rect.size.y) - rel_sgn.y * warp_margin.y); + const Point2i pos_local = Point2i(p_motion.global_x, p_motion.global_y) - p_rect.pos; const Point2i pos_warped(Math::fposmod(pos_local.x, p_rect.size.x), Math::fposmod(pos_local.y, p_rect.size.y)); if (pos_warped != pos_local) { OS::get_singleton()->warp_mouse_pos(pos_warped + p_rect.pos); } + return rel_warped; } diff --git a/modules/gdscript/gd_tokenizer.cpp b/modules/gdscript/gd_tokenizer.cpp index 981924191f..dca34f923e 100644 --- a/modules/gdscript/gd_tokenizer.cpp +++ b/modules/gdscript/gd_tokenizer.cpp @@ -117,6 +117,7 @@ const char *GDTokenizer::token_names[TK_MAX] = { "'.'", "'?'", "':'", + "'$'", "'\\n'", "PI", "_", diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp index 1ba6ec46cf..16b6342299 100644 --- a/scene/2d/node_2d.cpp +++ b/scene/2d/node_2d.cpp @@ -63,9 +63,10 @@ void Node2D::edit_set_state(const Variant &p_state) { angle = state[1]; _scale = state[2]; _update_transform(); - _change_notify("transform/rot"); - _change_notify("transform/scale"); - _change_notify("transform/pos"); + _change_notify("rotation"); + _change_notify("rotation_deg"); + _change_notify("scale"); + _change_notify("position"); } void Node2D::edit_set_rect(const Rect2 &p_edit_rect) { @@ -95,15 +96,16 @@ void Node2D::edit_set_rect(const Rect2 &p_edit_rect) { _scale *= new_scale; _update_transform(); - _change_notify("transform/scale"); - _change_notify("transform/pos"); + _change_notify("scale"); + _change_notify("position"); } void Node2D::edit_rotate(float p_rot) { angle += p_rot; _update_transform(); - _change_notify("transform/rot"); + _change_notify("rotation"); + _change_notify("rotation_deg"); } void Node2D::_update_xform_values() { @@ -134,7 +136,7 @@ void Node2D::set_position(const Point2 &p_pos) { ((Node2D *)this)->_update_xform_values(); pos = p_pos; _update_transform(); - _change_notify("transform/pos"); + _change_notify("position"); } void Node2D::set_rotation(float p_radians) { @@ -143,7 +145,8 @@ void Node2D::set_rotation(float p_radians) { ((Node2D *)this)->_update_xform_values(); angle = p_radians; _update_transform(); - _change_notify("transform/rot"); + _change_notify("rotation"); + _change_notify("rotation_deg"); } void Node2D::set_rotation_in_degrees(float p_degrees) { @@ -169,7 +172,7 @@ void Node2D::set_scale(const Size2 &p_scale) { if (_scale.y == 0) _scale.y = CMP_EPSILON; _update_transform(); - _change_notify("transform/scale"); + _change_notify("scale"); } Point2 Node2D::get_position() const { @@ -349,6 +352,7 @@ void Node2D::set_z(int p_z) { ERR_FAIL_COND(p_z > VS::CANVAS_ITEM_Z_MAX); z = p_z; VS::get_singleton()->canvas_item_set_z(get_canvas_item(), z); + _change_notify("z"); } void Node2D::set_z_as_relative(bool p_enabled) { diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index d2f3eea721..7f9944833a 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -1347,12 +1347,12 @@ Control::AnchorType Control::get_anchor(Margin p_margin) const { void Control::_change_notify_margins() { // this avoids sending the whole object data again on a change - _change_notify("margin/left"); - _change_notify("margin/top"); - _change_notify("margin/right"); - _change_notify("margin/bottom"); - _change_notify("rect/pos"); - _change_notify("rect/size"); + _change_notify("margin_left"); + _change_notify("margin_top"); + _change_notify("margin_right"); + _change_notify("margin_bottom"); + _change_notify("rect_pos"); + _change_notify("rect_size"); } void Control::set_margin(Margin p_margin, float p_value) { |