From 30f359ee3c850612afe08f96e6834d078e632ecb Mon Sep 17 00:00:00 2001 From: vdyotte Date: Thu, 28 Oct 2021 23:08:48 -0400 Subject: [PATCH] fix hardcoded raycast distance with viewport object picking having the raycast distance hardcoded to `10000` caused input events to not be registered in very large 3D scenes. This resolves the issue by using the cameras far distance instead. Creating the more predictable behavior of if an object is visible, it will be picked by the viewport. resolves: #49735 (cherry picked from commit 02b6bbc5df079131eaa98925d299b7a328800583) --- scene/main/viewport.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 70ab1231b30..ab429a3f894 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -647,10 +647,11 @@ void Viewport::_process_picking(bool p_ignore_paused) { if (camera) { Vector3 from = camera->project_ray_origin(pos); Vector3 dir = camera->project_ray_normal(pos); + float far = camera->far; PhysicsDirectSpaceState *space = PhysicsServer::get_singleton()->space_get_direct_state(find_world()->get_space()); if (space) { - bool col = space->intersect_ray(from, from + dir * 10000, result, Set(), 0xFFFFFFFF, true, true, true); + bool col = space->intersect_ray(from, from + dir * far, result, Set(), 0xFFFFFFFF, true, true, true); ObjectID new_collider = 0; if (col) { CollisionObject *co = Object::cast_to(result.collider);