From f06fc1fdf4126f1053218351def6f7e0c75d9d2f Mon Sep 17 00:00:00 2001 From: Adam Reichold Date: Fri, 26 Jun 2020 16:52:02 +0200 Subject: [PATCH] Call Spatial::get_global_transform and Vector3::dot only once within Camera::is_position_behind to avoid redundant work. (cherry picked from commit b2a204799adb290cd63c9c0346574448336d8f02) --- scene/3d/camera.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp index 71a868053b8..1cbb07a4ddc 100644 --- a/scene/3d/camera.cpp +++ b/scene/3d/camera.cpp @@ -333,8 +333,8 @@ Vector3 Camera::project_ray_origin(const Point2 &p_pos) const { bool Camera::is_position_behind(const Vector3 &p_pos) const { Transform t = get_global_transform(); - Vector3 eyedir = -get_global_transform().basis.get_axis(2).normalized(); - return eyedir.dot(p_pos) < (eyedir.dot(t.origin) + near); + Vector3 eyedir = -t.basis.get_axis(2).normalized(); + return eyedir.dot(p_pos - t.origin) < near; } Vector Camera::get_near_plane_points() const {