Skip to content

Commit

Permalink
Merge pull request #54369 from S0yKaf/fix-hardcoded-ray-distance
Browse files Browse the repository at this point in the history
Fix hardcoded raycast distance in viewport object picking
  • Loading branch information
akien-mga authored Nov 1, 2021
2 parents a57de3b + 02b6bbc commit 96ce806
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion scene/main/viewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 96ce806

Please sign in to comment.