diff options
-rw-r--r-- | core/input/input.cpp | 30 | ||||
-rw-r--r-- | core/input/input.h | 12 | ||||
-rw-r--r-- | core/input/input_event.cpp | 55 | ||||
-rw-r--r-- | core/input/input_event.h | 12 | ||||
-rw-r--r-- | doc/classes/GraphEdit.xml | 2 | ||||
-rw-r--r-- | doc/classes/Input.xml | 4 | ||||
-rw-r--r-- | doc/classes/InputEventMouseMotion.xml | 8 | ||||
-rw-r--r-- | doc/classes/InputEventScreenDrag.xml | 4 | ||||
-rw-r--r-- | platform/javascript/display_server_javascript.cpp | 2 | ||||
-rw-r--r-- | platform/linuxbsd/display_server_x11.cpp | 4 | ||||
-rw-r--r-- | platform/osx/display_server_osx.mm | 2 | ||||
-rw-r--r-- | platform/windows/display_server_windows.cpp | 8 | ||||
-rw-r--r-- | scene/gui/rich_text_label.cpp | 3 | ||||
-rw-r--r-- | scene/gui/tree.cpp | 2 | ||||
-rw-r--r-- | scene/main/viewport.cpp | 8 | ||||
-rw-r--r-- | scene/resources/default_theme/default_theme.cpp | 2 | ||||
-rw-r--r-- | servers/rendering/renderer_viewport.cpp | 22 |
17 files changed, 93 insertions, 87 deletions
diff --git a/core/input/input.cpp b/core/input/input.cpp index 507a686cab..26df16792d 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -121,7 +121,7 @@ void Input::_bind_methods() { ClassDB::bind_method(D_METHOD("set_accelerometer", "value"), &Input::set_accelerometer); ClassDB::bind_method(D_METHOD("set_magnetometer", "value"), &Input::set_magnetometer); ClassDB::bind_method(D_METHOD("set_gyroscope", "value"), &Input::set_gyroscope); - ClassDB::bind_method(D_METHOD("get_last_mouse_speed"), &Input::get_last_mouse_speed); + ClassDB::bind_method(D_METHOD("get_last_mouse_velocity"), &Input::get_last_mouse_velocity); ClassDB::bind_method(D_METHOD("get_mouse_button_mask"), &Input::get_mouse_button_mask); ClassDB::bind_method(D_METHOD("set_mouse_mode", "mode"), &Input::set_mouse_mode); ClassDB::bind_method(D_METHOD("get_mouse_mode"), &Input::get_mouse_mode); @@ -183,7 +183,7 @@ void Input::get_argument_options(const StringName &p_function, int p_idx, List<S } } -void Input::SpeedTrack::update(const Vector2 &p_delta_p) { +void Input::VelocityTrack::update(const Vector2 &p_delta_p) { uint64_t tick = OS::get_singleton()->get_ticks_usec(); uint32_t tdiff = tick - last_tick; float delta_t = tdiff / 1000000.0; @@ -202,17 +202,17 @@ void Input::SpeedTrack::update(const Vector2 &p_delta_p) { accum = accum - slice; accum_t -= min_ref_frame; - speed = (slice / min_ref_frame).lerp(speed, min_ref_frame / max_ref_frame); + velocity = (slice / min_ref_frame).lerp(velocity, min_ref_frame / max_ref_frame); } } -void Input::SpeedTrack::reset() { +void Input::VelocityTrack::reset() { last_tick = OS::get_singleton()->get_ticks_usec(); - speed = Vector2(); + velocity = Vector2(); accum_t = 0; } -Input::SpeedTrack::SpeedTrack() { +Input::VelocityTrack::VelocityTrack() { min_ref_frame = 0.1; max_ref_frame = 0.3; reset(); @@ -515,7 +515,7 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em drag_event->set_position(mm->get_position()); drag_event->set_relative(mm->get_relative()); - drag_event->set_speed(mm->get_speed()); + drag_event->set_velocity(mm->get_velocity()); event_dispatch_function(drag_event); } @@ -525,12 +525,12 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em if (st.is_valid()) { if (st->is_pressed()) { - SpeedTrack &track = touch_speed_track[st->get_index()]; + VelocityTrack &track = touch_velocity_track[st->get_index()]; track.reset(); } else { // Since a pointer index may not occur again (OSs may or may not reuse them), // imperatively remove it from the map to keep no fossil entries in it - touch_speed_track.erase(st->get_index()); + touch_velocity_track.erase(st->get_index()); } if (emulate_mouse_from_touch) { @@ -570,9 +570,9 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em Ref<InputEventScreenDrag> sd = p_event; if (sd.is_valid()) { - SpeedTrack &track = touch_speed_track[sd->get_index()]; + VelocityTrack &track = touch_velocity_track[sd->get_index()]; track.update(sd->get_relative()); - sd->set_speed(track.speed); + sd->set_velocity(track.velocity); if (emulate_mouse_from_touch && sd->get_index() == mouse_from_touch_index) { Ref<InputEventMouseMotion> motion_event; @@ -582,7 +582,7 @@ void Input::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool p_is_em motion_event->set_position(sd->get_position()); motion_event->set_global_position(sd->get_position()); motion_event->set_relative(sd->get_relative()); - motion_event->set_speed(sd->get_speed()); + motion_event->set_velocity(sd->get_velocity()); motion_event->set_button_mask(mouse_button_mask); _parse_input_event_impl(motion_event, true); @@ -696,7 +696,7 @@ void Input::set_gyroscope(const Vector3 &p_gyroscope) { } void Input::set_mouse_position(const Point2 &p_posf) { - mouse_speed_track.update(p_posf - mouse_pos); + mouse_velocity_track.update(p_posf - mouse_pos); mouse_pos = p_posf; } @@ -704,8 +704,8 @@ Point2 Input::get_mouse_position() const { return mouse_pos; } -Point2 Input::get_last_mouse_speed() const { - return mouse_speed_track.speed; +Point2 Input::get_last_mouse_velocity() const { + return mouse_velocity_track.velocity; } MouseButton Input::get_mouse_button_mask() const { diff --git a/core/input/input.h b/core/input/input.h index b723fb563a..8b1d7d6161 100644 --- a/core/input/input.h +++ b/core/input/input.h @@ -117,9 +117,9 @@ private: int mouse_from_touch_index = -1; - struct SpeedTrack { + struct VelocityTrack { uint64_t last_tick; - Vector2 speed; + Vector2 velocity; Vector2 accum; float accum_t; float min_ref_frame; @@ -127,7 +127,7 @@ private: void update(const Vector2 &p_delta_p); void reset(); - SpeedTrack(); + VelocityTrack(); }; struct Joypad { @@ -141,8 +141,8 @@ private: int hat_current = 0; }; - SpeedTrack mouse_speed_track; - Map<int, SpeedTrack> touch_speed_track; + VelocityTrack mouse_velocity_track; + Map<int, VelocityTrack> touch_velocity_track; Map<int, Joypad> joy_names; int fallback_mapping = -1; @@ -274,7 +274,7 @@ public: Vector3 get_gyroscope() const; Point2 get_mouse_position() const; - Point2 get_last_mouse_speed() const; + Vector2 get_last_mouse_velocity() const; MouseButton get_mouse_button_mask() const; void warp_mouse_position(const Vector2 &p_to); diff --git a/core/input/input_event.cpp b/core/input/input_event.cpp index 794ed0275d..c608076a21 100644 --- a/core/input/input_event.cpp +++ b/core/input/input_event.cpp @@ -739,20 +739,15 @@ Vector2 InputEventMouseMotion::get_relative() const { return relative; } -void InputEventMouseMotion::set_speed(const Vector2 &p_speed) { - speed = p_speed; +void InputEventMouseMotion::set_velocity(const Vector2 &p_velocity) { + velocity = p_velocity; } -Vector2 InputEventMouseMotion::get_speed() const { - return speed; +Vector2 InputEventMouseMotion::get_velocity() const { + return velocity; } Ref<InputEvent> InputEventMouseMotion::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const { - Vector2 g = get_global_position(); - Vector2 l = p_xform.xform(get_position() + p_local_ofs); - Vector2 r = p_xform.basis_xform(get_relative()); - Vector2 s = p_xform.basis_xform(get_speed()); - Ref<InputEventMouseMotion> mm; mm.instantiate(); @@ -761,20 +756,20 @@ Ref<InputEvent> InputEventMouseMotion::xformed_by(const Transform2D &p_xform, co mm->set_modifiers_from_event(this); - mm->set_position(l); + mm->set_position(p_xform.xform(get_position() + p_local_ofs)); mm->set_pressure(get_pressure()); mm->set_tilt(get_tilt()); - mm->set_global_position(g); + mm->set_global_position(get_global_position()); mm->set_button_mask(get_button_mask()); - mm->set_relative(r); - mm->set_speed(s); + mm->set_relative(p_xform.basis_xform(get_relative())); + mm->set_velocity(p_xform.basis_xform(get_velocity())); return mm; } String InputEventMouseMotion::as_text() const { - return vformat(RTR("Mouse motion at position (%s) with speed (%s)"), String(get_position()), String(get_speed())); + return vformat(RTR("Mouse motion at position (%s) with velocity (%s)"), String(get_position()), String(get_velocity())); } String InputEventMouseMotion::to_string() { @@ -802,7 +797,7 @@ String InputEventMouseMotion::to_string() { // Work around the fact vformat can only take 5 substitutions but 6 need to be passed. String mask_and_position = vformat("button_mask=%s, position=(%s)", button_mask_string, String(get_position())); - return vformat("InputEventMouseMotion: %s, relative=(%s), speed=(%s), pressure=%.2f, tilt=(%s)", mask_and_position, String(get_relative()), String(get_speed()), get_pressure(), String(get_tilt())); + return vformat("InputEventMouseMotion: %s, relative=(%s), velocity=(%s), pressure=%.2f, tilt=(%s)", mask_and_position, String(get_relative()), String(get_velocity()), get_pressure(), String(get_tilt())); } bool InputEventMouseMotion::accumulate(const Ref<InputEvent> &p_event) { @@ -841,7 +836,7 @@ bool InputEventMouseMotion::accumulate(const Ref<InputEvent> &p_event) { set_position(motion->get_position()); set_global_position(motion->get_global_position()); - set_speed(motion->get_speed()); + set_velocity(motion->get_velocity()); relative += motion->get_relative(); return true; @@ -857,13 +852,13 @@ void InputEventMouseMotion::_bind_methods() { ClassDB::bind_method(D_METHOD("set_relative", "relative"), &InputEventMouseMotion::set_relative); ClassDB::bind_method(D_METHOD("get_relative"), &InputEventMouseMotion::get_relative); - ClassDB::bind_method(D_METHOD("set_speed", "speed"), &InputEventMouseMotion::set_speed); - ClassDB::bind_method(D_METHOD("get_speed"), &InputEventMouseMotion::get_speed); + ClassDB::bind_method(D_METHOD("set_velocity", "velocity"), &InputEventMouseMotion::set_velocity); + ClassDB::bind_method(D_METHOD("get_velocity"), &InputEventMouseMotion::get_velocity); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "tilt"), "set_tilt", "get_tilt"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "pressure"), "set_pressure", "get_pressure"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "relative"), "set_relative", "get_relative"); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "speed"), "set_speed", "get_speed"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "velocity"), "set_velocity", "get_velocity"); } /////////////////////////////////// @@ -1188,12 +1183,12 @@ Vector2 InputEventScreenDrag::get_relative() const { return relative; } -void InputEventScreenDrag::set_speed(const Vector2 &p_speed) { - speed = p_speed; +void InputEventScreenDrag::set_velocity(const Vector2 &p_velocity) { + velocity = p_velocity; } -Vector2 InputEventScreenDrag::get_speed() const { - return speed; +Vector2 InputEventScreenDrag::get_velocity() const { + return velocity; } Ref<InputEvent> InputEventScreenDrag::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const { @@ -1207,17 +1202,17 @@ Ref<InputEvent> InputEventScreenDrag::xformed_by(const Transform2D &p_xform, con sd->set_index(index); sd->set_position(p_xform.xform(pos + p_local_ofs)); sd->set_relative(p_xform.basis_xform(relative)); - sd->set_speed(p_xform.basis_xform(speed)); + sd->set_velocity(p_xform.basis_xform(velocity)); return sd; } String InputEventScreenDrag::as_text() const { - return vformat(RTR("Screen dragged with %s touch points at position (%s) with speed of (%s)"), itos(index), String(get_position()), String(get_speed())); + return vformat(RTR("Screen dragged with %s touch points at position (%s) with velocity of (%s)"), itos(index), String(get_position()), String(get_velocity())); } String InputEventScreenDrag::to_string() { - return vformat("InputEventScreenDrag: index=%d, position=(%s), relative=(%s), speed=(%s)", index, String(get_position()), String(get_relative()), String(get_speed())); + return vformat("InputEventScreenDrag: index=%d, position=(%s), relative=(%s), velocity=(%s)", index, String(get_position()), String(get_relative()), String(get_velocity())); } bool InputEventScreenDrag::accumulate(const Ref<InputEvent> &p_event) { @@ -1230,7 +1225,7 @@ bool InputEventScreenDrag::accumulate(const Ref<InputEvent> &p_event) { } set_position(drag->get_position()); - set_speed(drag->get_speed()); + set_velocity(drag->get_velocity()); relative += drag->get_relative(); return true; @@ -1246,13 +1241,13 @@ void InputEventScreenDrag::_bind_methods() { ClassDB::bind_method(D_METHOD("set_relative", "relative"), &InputEventScreenDrag::set_relative); ClassDB::bind_method(D_METHOD("get_relative"), &InputEventScreenDrag::get_relative); - ClassDB::bind_method(D_METHOD("set_speed", "speed"), &InputEventScreenDrag::set_speed); - ClassDB::bind_method(D_METHOD("get_speed"), &InputEventScreenDrag::get_speed); + ClassDB::bind_method(D_METHOD("set_velocity", "velocity"), &InputEventScreenDrag::set_velocity); + ClassDB::bind_method(D_METHOD("get_velocity"), &InputEventScreenDrag::get_velocity); ADD_PROPERTY(PropertyInfo(Variant::INT, "index"), "set_index", "get_index"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "position"), "set_position", "get_position"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "relative"), "set_relative", "get_relative"); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "speed"), "set_speed", "get_speed"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "velocity"), "set_velocity", "get_velocity"); } /////////////////////////////////// diff --git a/core/input/input_event.h b/core/input/input_event.h index 184d883af8..29450dfc52 100644 --- a/core/input/input_event.h +++ b/core/input/input_event.h @@ -271,7 +271,7 @@ class InputEventMouseMotion : public InputEventMouse { Vector2 tilt; float pressure = 0; Vector2 relative; - Vector2 speed; + Vector2 velocity; protected: static void _bind_methods(); @@ -286,8 +286,8 @@ public: void set_relative(const Vector2 &p_relative); Vector2 get_relative() const; - void set_speed(const Vector2 &p_speed); - Vector2 get_speed() const; + void set_velocity(const Vector2 &p_velocity); + Vector2 get_velocity() const; virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const override; virtual String as_text() const override; @@ -388,7 +388,7 @@ class InputEventScreenDrag : public InputEventFromWindow { int index = 0; Vector2 pos; Vector2 relative; - Vector2 speed; + Vector2 velocity; protected: static void _bind_methods(); @@ -403,8 +403,8 @@ public: void set_relative(const Vector2 &p_relative); Vector2 get_relative() const; - void set_speed(const Vector2 &p_speed); - Vector2 get_speed() const; + void set_velocity(const Vector2 &p_velocity); + Vector2 get_velocity() const; virtual Ref<InputEvent> xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs = Vector2()) const override; virtual String as_text() const override; diff --git a/doc/classes/GraphEdit.xml b/doc/classes/GraphEdit.xml index 46960d7cc4..9d16f64f3a 100644 --- a/doc/classes/GraphEdit.xml +++ b/doc/classes/GraphEdit.xml @@ -367,7 +367,7 @@ <theme_item name="port_grab_distance_horizontal" data_type="constant" type="int" default="24"> The horizontal range within which a port can be grabbed (on both sides). </theme_item> - <theme_item name="port_grab_distance_vertical" data_type="constant" type="int" default="6"> + <theme_item name="port_grab_distance_vertical" data_type="constant" type="int" default="26"> The vertical range within which a port can be grabbed (on both sides). </theme_item> <theme_item name="layout" data_type="icon" type="Texture2D"> diff --git a/doc/classes/Input.xml b/doc/classes/Input.xml index 4939e48e97..45b15331d2 100644 --- a/doc/classes/Input.xml +++ b/doc/classes/Input.xml @@ -141,10 +141,10 @@ Returns the strength of the joypad vibration: x is the strength of the weak motor, and y is the strength of the strong motor. </description> </method> - <method name="get_last_mouse_speed" qualifiers="const"> + <method name="get_last_mouse_velocity" qualifiers="const"> <return type="Vector2" /> <description> - Returns the mouse speed for the last time the cursor was moved, and this until the next frame where the mouse moves. This means that even if the mouse is not moving, this function will still return the value of the last motion. + Returns the mouse velocity for the last time the cursor was moved, and this until the next frame where the mouse moves. This means that even if the mouse is not moving, this function will still return the value of the last motion. </description> </method> <method name="get_magnetometer" qualifiers="const"> diff --git a/doc/classes/InputEventMouseMotion.xml b/doc/classes/InputEventMouseMotion.xml index bd1ae367c2..ae573f70f4 100644 --- a/doc/classes/InputEventMouseMotion.xml +++ b/doc/classes/InputEventMouseMotion.xml @@ -4,7 +4,7 @@ Input event type for mouse motion events. </brief_description> <description> - Contains mouse and pen motion information. Supports relative, absolute positions and speed. See [method Node._input]. + Contains mouse and pen motion information. Supports relative, absolute positions and velocity. See [method Node._input]. [b]Note:[/b] By default, this event is only emitted once per frame rendered at most. If you need more precise input reporting, call [method Input.set_use_accumulated_input] with [code]false[/code] to make events emitted as often as possible. If you use InputEventMouseMotion to draw lines, consider implementing [url=https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm]Bresenham's line algorithm[/url] as well to avoid visible gaps in lines if the user is moving the mouse quickly. </description> <tutorials> @@ -19,11 +19,11 @@ The mouse position relative to the previous position (position at the last frame). [b]Note:[/b] Since [InputEventMouseMotion] is only emitted when the mouse moves, the last event won't have a relative position of [code]Vector2(0, 0)[/code] when the user stops moving the mouse. </member> - <member name="speed" type="Vector2" setter="set_speed" getter="get_speed" default="Vector2(0, 0)"> - The mouse speed in pixels per second. - </member> <member name="tilt" type="Vector2" setter="set_tilt" getter="get_tilt" default="Vector2(0, 0)"> Represents the angles of tilt of the pen. Positive X-coordinate value indicates a tilt to the right. Positive Y-coordinate value indicates a tilt toward the user. Ranges from [code]-1.0[/code] to [code]1.0[/code] for both axes. </member> + <member name="velocity" type="Vector2" setter="set_velocity" getter="get_velocity" default="Vector2(0, 0)"> + The mouse velocity in pixels per second. + </member> </members> </class> diff --git a/doc/classes/InputEventScreenDrag.xml b/doc/classes/InputEventScreenDrag.xml index 19c26e3a98..0b0550fbdd 100644 --- a/doc/classes/InputEventScreenDrag.xml +++ b/doc/classes/InputEventScreenDrag.xml @@ -19,8 +19,8 @@ <member name="relative" type="Vector2" setter="set_relative" getter="get_relative" default="Vector2(0, 0)"> The drag position relative to the previous position (position at the last frame). </member> - <member name="speed" type="Vector2" setter="set_speed" getter="get_speed" default="Vector2(0, 0)"> - The drag speed. + <member name="velocity" type="Vector2" setter="set_velocity" getter="get_velocity" default="Vector2(0, 0)"> + The drag velocity. </member> </members> </class> diff --git a/platform/javascript/display_server_javascript.cpp b/platform/javascript/display_server_javascript.cpp index 5d960ef80c..f98e0c4c5f 100644 --- a/platform/javascript/display_server_javascript.cpp +++ b/platform/javascript/display_server_javascript.cpp @@ -230,7 +230,7 @@ void DisplayServerJavaScript::mouse_move_callback(double p_x, double p_y, double ev->set_relative(Vector2(p_rel_x, p_rel_y)); Input::get_singleton()->set_mouse_position(ev->get_position()); - ev->set_speed(Input::get_singleton()->get_last_mouse_speed()); + ev->set_velocity(Input::get_singleton()->get_last_mouse_velocity()); Input::get_singleton()->parse_input_event(ev); } diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp index 68bd5e8421..747b5beeda 100644 --- a/platform/linuxbsd/display_server_x11.cpp +++ b/platform/linuxbsd/display_server_x11.cpp @@ -3648,7 +3648,7 @@ void DisplayServerX11::process_events() { mm->set_position(pos); mm->set_global_position(pos); Input::get_singleton()->set_mouse_position(pos); - mm->set_speed(Input::get_singleton()->get_last_mouse_speed()); + mm->set_velocity(Input::get_singleton()->get_last_mouse_velocity()); mm->set_relative(rel); @@ -3678,7 +3678,7 @@ void DisplayServerX11::process_events() { mm->set_window_id(E.key); mm->set_position(pos_focused); mm->set_global_position(pos_focused); - mm->set_speed(Input::get_singleton()->get_last_mouse_speed()); + mm->set_velocity(Input::get_singleton()->get_last_mouse_velocity()); Input::get_singleton()->parse_input_event(mm); break; diff --git a/platform/osx/display_server_osx.mm b/platform/osx/display_server_osx.mm index e9cc79f149..2465334f84 100644 --- a/platform/osx/display_server_osx.mm +++ b/platform/osx/display_server_osx.mm @@ -787,7 +787,7 @@ static void _mouseDownEvent(DisplayServer::WindowID window_id, NSEvent *event, M mm->set_tilt(Vector2(p.x, p.y)); } mm->set_global_position(pos); - mm->set_speed(Input::get_singleton()->get_last_mouse_speed()); + mm->set_velocity(Input::get_singleton()->get_last_mouse_velocity()); const Vector2i relativeMotion = Vector2i(delta.x, delta.y) * DS_OSX->screen_get_max_scale(); mm->set_relative(relativeMotion); _get_key_modifier_state([event modifierFlags], mm); diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index ca2b68371c..091bed36ea 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -2079,7 +2079,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA mm->set_position(c); mm->set_global_position(c); Input::get_singleton()->set_mouse_position(c); - mm->set_speed(Vector2(0, 0)); + mm->set_velocity(Vector2(0, 0)); if (raw->data.mouse.usFlags == MOUSE_MOVE_RELATIVE) { mm->set_relative(Vector2(raw->data.mouse.lLastX, raw->data.mouse.lLastY)); @@ -2184,7 +2184,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA } Input::get_singleton()->set_mouse_position(mm->get_position()); - mm->set_speed(Input::get_singleton()->get_last_mouse_speed()); + mm->set_velocity(Input::get_singleton()->get_last_mouse_velocity()); if (old_invalid) { old_x = mm->get_position().x; @@ -2326,7 +2326,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA } Input::get_singleton()->set_mouse_position(mm->get_position()); - mm->set_speed(Input::get_singleton()->get_last_mouse_speed()); + mm->set_velocity(Input::get_singleton()->get_last_mouse_velocity()); if (old_invalid) { old_x = mm->get_position().x; @@ -2427,7 +2427,7 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA } Input::get_singleton()->set_mouse_position(mm->get_position()); - mm->set_speed(Input::get_singleton()->get_last_mouse_speed()); + mm->set_velocity(Input::get_singleton()->get_last_mouse_velocity()); if (old_invalid) { old_x = mm->get_position().x; diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 348a0324f4..653838b63b 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -1005,7 +1005,8 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o float y_off = TS->shaped_text_get_underline_position(rid); float underline_width = TS->shaped_text_get_underline_thickness(rid) * get_theme_default_base_scale(); draw_line(p_ofs + Vector2(off.x, off.y + y_off), p_ofs + Vector2(off.x + glyphs[i].advance * glyphs[i].repeat, off.y + y_off), uc, underline_width); - } else if (_find_strikethrough(it)) { + } + if (_find_strikethrough(it)) { Color uc = font_color; uc.a *= 0.5; float y_off = -TS->shaped_text_get_ascent(rid) + TS->shaped_text_get_size(rid).y / 2; diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 73d39aee8a..e46de43f1e 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -3171,7 +3171,7 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) { if (drag_touching && !drag_touching_deaccel) { drag_accum -= mm->get_relative().y; v_scroll->set_value(drag_from + drag_accum); - drag_speed = -mm->get_speed().y; + drag_speed = -mm->get_velocity().y; } } diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index abbd7ba5a0..a7534099e3 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1699,13 +1699,13 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { if (over) { Transform2D localizer = over->get_global_transform_with_canvas().affine_inverse(); Size2 pos = localizer.xform(mpos); - Vector2 speed = localizer.basis_xform(mm->get_speed()); + Vector2 velocity = localizer.basis_xform(mm->get_velocity()); Vector2 rel = localizer.basis_xform(mm->get_relative()); mm = mm->xformed_by(Transform2D()); // Make a copy. mm->set_global_position(mpos); - mm->set_speed(speed); + mm->set_velocity(velocity); mm->set_relative(rel); if (mm->get_button_mask() == MouseButton::NONE) { @@ -1955,12 +1955,12 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) { if (over->can_process()) { Transform2D localizer = over->get_global_transform_with_canvas().affine_inverse(); Size2 pos = localizer.xform(drag_event->get_position()); - Vector2 speed = localizer.basis_xform(drag_event->get_speed()); + Vector2 velocity = localizer.basis_xform(drag_event->get_velocity()); Vector2 rel = localizer.basis_xform(drag_event->get_relative()); drag_event = drag_event->xformed_by(Transform2D()); // Make a copy. - drag_event->set_speed(speed); + drag_event->set_velocity(velocity); drag_event->set_relative(rel); drag_event->set_position(pos); diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index 549bd3ba12..93c7eb43a1 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -994,7 +994,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const // Visual Node Ports theme->set_constant("port_grab_distance_horizontal", "GraphEdit", 24 * scale); - theme->set_constant("port_grab_distance_vertical", "GraphEdit", 6 * scale); + theme->set_constant("port_grab_distance_vertical", "GraphEdit", 26 * scale); theme->set_stylebox("bg", "GraphEditMinimap", make_flat_stylebox(Color(0.24, 0.24, 0.24), 0, 0, 0, 0)); Ref<StyleBoxFlat> style_minimap_camera = make_flat_stylebox(Color(0.65, 0.65, 0.65, 0.2), 0, 0, 0, 0); diff --git a/servers/rendering/renderer_viewport.cpp b/servers/rendering/renderer_viewport.cpp index 47934e7299..17a665922f 100644 --- a/servers/rendering/renderer_viewport.cpp +++ b/servers/rendering/renderer_viewport.cpp @@ -582,6 +582,21 @@ void RendererViewport::draw_viewports() { bool visible = vp->viewport_to_screen_rect != Rect2(); + if (vp->use_xr && xr_interface.is_valid()) { + visible = true; // XR viewport is always visible regardless of update mode, output is sent to HMD. + + // Override our size, make sure it matches our required size and is created as a stereo target + Size2 xr_size = xr_interface->get_render_target_size(); + + // Would have been nice if we could call viewport_set_size here, + // but alas that takes our RID and we now have our pointer, + // also we only check if view_count changes in render_target_set_size so we need to call that for this to reliably change + vp->occlusion_buffer_dirty = vp->occlusion_buffer_dirty || (vp->size != xr_size); + vp->size = xr_size; + uint32_t view_count = xr_interface->get_view_count(); + RSG::storage->render_target_set_size(vp->render_target, vp->size.x, vp->size.y, view_count); + } + if (vp->update_mode == RS::VIEWPORT_UPDATE_ALWAYS || vp->update_mode == RS::VIEWPORT_UPDATE_ONCE) { visible = true; } @@ -619,11 +634,6 @@ void RendererViewport::draw_viewports() { RSG::storage->render_target_set_as_unused(vp->render_target); if (vp->use_xr && xr_interface.is_valid()) { - // override our size, make sure it matches our required size and is created as a stereo target - vp->size = xr_interface->get_render_target_size(); - uint32_t view_count = xr_interface->get_view_count(); - RSG::storage->render_target_set_size(vp->render_target, vp->internal_size.x, vp->internal_size.y, view_count); - // check for an external texture destination (disabled for now, not yet supported) // RSG::storage->render_target_set_external_texture(vp->render_target, xr_interface->get_external_texture_for_eye(leftOrMono)); RSG::storage->render_target_set_external_texture(vp->render_target, 0); @@ -843,7 +853,7 @@ void RendererViewport::viewport_attach_to_screen(RID p_viewport, const Rect2 &p_ // if render_direct_to_screen was used, reset size and position if (RSG::rasterizer->is_low_end() && viewport->viewport_render_direct_to_screen) { RSG::storage->render_target_set_position(viewport->render_target, 0, 0); - RSG::storage->render_target_set_size(viewport->render_target, viewport->internal_size.x, viewport->internal_size.y, viewport->get_view_count()); + RSG::storage->render_target_set_size(viewport->render_target, viewport->size.x, viewport->size.y, viewport->get_view_count()); } viewport->viewport_to_screen_rect = Rect2(); |