summaryrefslogtreecommitdiff
path: root/scene/main/viewport.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-12-19 14:09:24 +0100
committerGitHub <noreply@github.com>2018-12-19 14:09:24 +0100
commita06f8ca6b9838c587841afc17d990646ac9997e4 (patch)
tree992631dbea28e774c6db173e86b70f26f4d27373 /scene/main/viewport.cpp
parent26058376aa180f70e152070b3b69272287a710a8 (diff)
parentef9313f415a2994138a9d36a66cf9658c3198bab (diff)
Merge pull request #24439 from staalduinen/mouse-motion-fix
fix near infinite loop when no previous mouse position
Diffstat (limited to 'scene/main/viewport.cpp')
-rw-r--r--scene/main/viewport.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index b220df6ce1..7f5dd39302 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -435,7 +435,7 @@ void Viewport::_notification(int p_what) {
}
}
- if (!has_mouse_motion) {
+ if (!has_mouse_motion && physics_has_last_mousepos) {
Ref<InputEventMouseMotion> mm;
mm.instance();
mm->set_global_position(physics_last_mousepos);
@@ -465,6 +465,7 @@ void Viewport::_notification(int p_what) {
pos = mm->get_position();
motion_tested = true;
+ physics_has_last_mousepos = true;
physics_last_mousepos = pos;
physics_last_mouse_state.alt = mm->get_alt();
physics_last_mouse_state.shift = mm->get_shift();
@@ -643,7 +644,7 @@ void Viewport::_notification(int p_what) {
}
}
- if (!motion_tested && camera && physics_last_mousepos != Vector2(1e20, 1e20)) {
+ if (!motion_tested && camera && physics_has_last_mousepos) {
//test anyway for mouseenter/exit because objects might move
Vector3 from = camera->project_ray_origin(physics_last_mousepos);
@@ -3105,7 +3106,8 @@ Viewport::Viewport() {
physics_object_picking = false;
physics_object_capture = 0;
physics_object_over = 0;
- physics_last_mousepos = Vector2(1e20, 1e20);
+ physics_has_last_mousepos = false;
+ physics_last_mousepos = Vector2(Math_INF, Math_INF);
shadow_atlas_size = 0;
for (int i = 0; i < 4; i++) {