diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/3d/arvr_nodes.cpp | 10 | ||||
-rw-r--r-- | scene/3d/camera.cpp | 10 | ||||
-rw-r--r-- | scene/animation/tween.cpp | 1 | ||||
-rw-r--r-- | scene/gui/control.cpp | 6 |
4 files changed, 12 insertions, 15 deletions
diff --git a/scene/3d/arvr_nodes.cpp b/scene/3d/arvr_nodes.cpp index f0aaba1065..8d1556ef1c 100644 --- a/scene/3d/arvr_nodes.cpp +++ b/scene/3d/arvr_nodes.cpp @@ -85,9 +85,8 @@ Vector3 ARVRCamera::project_local_ray_normal(const Point2 &p_pos) const { Vector3 ray; CameraMatrix cm = arvr_interface->get_projection_for_eye(ARVRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar()); - float screen_w, screen_h; - cm.get_viewport_size(screen_w, screen_h); - ray = Vector3(((cpos.x / viewport_size.width) * 2.0 - 1.0) * screen_w, ((1.0 - (cpos.y / viewport_size.height)) * 2.0 - 1.0) * screen_h, -get_znear()).normalized(); + Vector2 screen_he = cm.get_viewport_half_extents(); + ray = Vector3(((cpos.x / viewport_size.width) * 2.0 - 1.0) * screen_he.x, ((1.0 - (cpos.y / viewport_size.height)) * 2.0 - 1.0) * screen_he.y, -get_znear()).normalized(); return ray; }; @@ -138,13 +137,12 @@ Vector3 ARVRCamera::project_position(const Point2 &p_point, float p_z_depth) con CameraMatrix cm = arvr_interface->get_projection_for_eye(ARVRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar()); - Size2 vp_size; - cm.get_viewport_size(vp_size.x, vp_size.y); + Vector2 vp_he = cm.get_viewport_half_extents(); Vector2 point; point.x = (p_point.x / viewport_size.x) * 2.0 - 1.0; point.y = (1.0 - (p_point.y / viewport_size.y)) * 2.0 - 1.0; - point *= vp_size; + point *= vp_he; Vector3 p(point.x, point.y, -p_z_depth); diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp index 3a30755f7f..640189a26e 100644 --- a/scene/3d/camera.cpp +++ b/scene/3d/camera.cpp @@ -291,9 +291,8 @@ Vector3 Camera::project_local_ray_normal(const Point2 &p_pos) const { } else { CameraMatrix cm; cm.set_perspective(fov, viewport_size.aspect(), near, far, keep_aspect == KEEP_WIDTH); - float screen_w, screen_h; - cm.get_viewport_size(screen_w, screen_h); - ray = Vector3(((cpos.x / viewport_size.width) * 2.0 - 1.0) * screen_w, ((1.0 - (cpos.y / viewport_size.height)) * 2.0 - 1.0) * screen_h, -near).normalized(); + Vector2 screen_he = cm.get_viewport_half_extents(); + ray = Vector3(((cpos.x / viewport_size.width) * 2.0 - 1.0) * screen_he.x, ((1.0 - (cpos.y / viewport_size.height)) * 2.0 - 1.0) * screen_he.y, -near).normalized(); } return ray; @@ -402,13 +401,12 @@ Vector3 Camera::project_position(const Point2 &p_point, float p_z_depth) const { else cm.set_perspective(fov, viewport_size.aspect(), p_z_depth, far, keep_aspect == KEEP_WIDTH); - Size2 vp_size; - cm.get_viewport_size(vp_size.x, vp_size.y); + Vector2 vp_he = cm.get_viewport_half_extents(); Vector2 point; point.x = (p_point.x / viewport_size.x) * 2.0 - 1.0; point.y = (1.0 - (p_point.y / viewport_size.y)) * 2.0 - 1.0; - point *= vp_size; + point *= vp_he; Vector3 p(point.x, point.y, -p_z_depth); diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index 58212335c2..331a6c769c 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -827,6 +827,7 @@ bool Tween::start() { // Are there any pending updates? if (pending_update != 0) { // Start the tweens after deferring + call_deferred("start"); return true; } diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 4f499af186..ae48a1356e 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -2475,9 +2475,9 @@ void Control::_window_find_focus_neighbour(const Vector2 &p_dir, Node *p_at, con Transform2D xform = c->get_global_transform(); points[0] = xform.xform(Point2()); - points[1] = xform.xform(Point2(get_size().x, 0)); - points[2] = xform.xform(get_size()); - points[3] = xform.xform(Point2(0, get_size().y)); + points[1] = xform.xform(Point2(c->get_size().x, 0)); + points[2] = xform.xform(c->get_size()); + points[3] = xform.xform(Point2(0, c->get_size().y)); float min = 1e7; |