summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvdyotte <vdyotte@gmail.com>2021-10-28 23:08:48 -0400
committervdyotte <vdyotte@gmail.com>2021-10-28 23:08:48 -0400
commit02b6bbc5df079131eaa98925d299b7a328800583 (patch)
tree32ec079b7a6f3edcfb8e2f49ddc3c056d1f05e03
parentd3547be9ae8ae8bfbbece4757fc0759b712354a7 (diff)
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
-rw-r--r--scene/main/viewport.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 5f8e66e337..f0dd9cb7f4 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -715,10 +715,11 @@ void Viewport::_process_picking() {
if (camera_3d) {
Vector3 from = camera_3d->project_ray_origin(pos);
Vector3 dir = camera_3d->project_ray_normal(pos);
+ real_t far = camera_3d->far;
PhysicsDirectSpaceState3D *space = PhysicsServer3D::get_singleton()->space_get_direct_state(find_world_3d()->get_space());
if (space) {
- bool col = space->intersect_ray(from, from + dir * 10000, result, Set<RID>(), 0xFFFFFFFF, true, true, true);
+ bool col = space->intersect_ray(from, from + dir * far, result, Set<RID>(), 0xFFFFFFFF, true, true, true);
ObjectID new_collider;
if (col) {
CollisionObject3D *co = Object::cast_to<CollisionObject3D>(result.collider);