summaryrefslogtreecommitdiffstats
path: root/scene/3d/camera_3d.cpp
diff options
context:
space:
mode:
authorGeorge L. Albany <Megacake1234@gmail.com>2024-11-27 21:15:49 +0000
committerGitHub <noreply@github.com>2024-11-27 21:15:49 +0000
commit85d87116e184e7923b8d6804cab2681b61c62d83 (patch)
tree55ec5bfa061a5c27272b831e697b78ed1b756a70 /scene/3d/camera_3d.cpp
parentb06d20bf39d15ec736d08d4e4fcb32e0c3c1ce1e (diff)
parent721f53fde47c2727d99e3ecccdb789a67df36de0 (diff)
downloadredot-engine-master.tar.gz
Merge pull request #886 from Spartan322/merge/f128f38HEADmaster
Merge commit godotengine/godot@f128f38
Diffstat (limited to 'scene/3d/camera_3d.cpp')
-rw-r--r--scene/3d/camera_3d.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/scene/3d/camera_3d.cpp b/scene/3d/camera_3d.cpp
index 77665317a8..fb64bead13 100644
--- a/scene/3d/camera_3d.cpp
+++ b/scene/3d/camera_3d.cpp
@@ -531,9 +531,12 @@ Vector3 Camera3D::project_position(const Point2 &p_point, real_t p_z_depth) cons
}
Size2 viewport_size = get_viewport()->get_visible_rect().size;
- Projection cm = _get_camera_projection(p_z_depth);
+ Projection cm = _get_camera_projection(_near);
- Vector2 vp_he = cm.get_viewport_half_extents();
+ Plane z_slice(Vector3(0, 0, 1), -p_z_depth);
+ Vector3 res;
+ z_slice.intersect_3(cm.get_projection_plane(Projection::Planes::PLANE_RIGHT), cm.get_projection_plane(Projection::Planes::PLANE_TOP), &res);
+ Vector2 vp_he(res.x, res.y);
Vector2 point;
point.x = (p_point.x / viewport_size.x) * 2.0 - 1.0;