summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorArjen van Staalduinen <arst@knowlogy.nl>2018-12-18 08:11:13 +0100
committerArjen van Staalduinen <arst@knowlogy.nl>2018-12-19 13:35:41 +0100
commitef9313f415a2994138a9d36a66cf9658c3198bab (patch)
tree2de6b2cb2febed084f665d90dc56ed365ad05210 /scene
parent4b6e7b50b9a0f4f7496b2d01cd07e6c386679abe (diff)
fix near infinite loop when no previous mouse position
Added physics_has_last_mousepos to better deal with situations where there is no last_mousepos
Diffstat (limited to 'scene')
-rw-r--r--scene/main/viewport.cpp8
-rw-r--r--scene/main/viewport.h1
2 files changed, 6 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++) {
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index 6b6ca3b7db..b75ebeeec5 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -209,6 +209,7 @@ private:
Transform physics_last_object_transform;
Transform physics_last_camera_transform;
ObjectID physics_last_id;
+ bool physics_has_last_mousepos;
Vector2 physics_last_mousepos;
struct {