From 1d9c9710d70c8d48de362f13ab97de5a6215a5c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20M=C3=BCller?= <34514239+appgurueu@users.noreply.github.com> Date: Sun, 4 Feb 2024 14:04:05 +0100 Subject: [PATCH] Fix short raycasts missing large objects (#14339) Increases the tolerance from one node to five nodes. Also optimizes the "sphere" used for pre-filtering entities to start in the middle of the line segment rather than at the start. --- doc/lua_api.md | 2 ++ src/serverenvironment.cpp | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/lua_api.md b/doc/lua_api.md index b4ce001dd..469292a72 100644 --- a/doc/lua_api.md +++ b/doc/lua_api.md @@ -8403,6 +8403,8 @@ Player properties need to be saved manually. -- If `rotate = false`, the selection box will not rotate with the object itself, remaining fixed to the axes. -- If `rotate = true`, it will match the object's rotation and any attachment rotations. -- Raycasts use the selection box and object's rotation, but do *not* obey attachment rotations. + -- For server-side raycasts to work correctly, + -- the selection box should extend at most 5 units in each direction. pointable = true, diff --git a/src/serverenvironment.cpp b/src/serverenvironment.cpp index 0d003e078..7b188f60f 100644 --- a/src/serverenvironment.cpp +++ b/src/serverenvironment.cpp @@ -1826,8 +1826,8 @@ void ServerEnvironment::getSelectedActiveObjects( const std::optional &pointabilities) { std::vector objs; - getObjectsInsideRadius(objs, shootline_on_map.start, - shootline_on_map.getLength() + 10.0f, nullptr); + getObjectsInsideRadius(objs, shootline_on_map.getMiddle(), + 0.5 * shootline_on_map.getLength() + 5 * BS, nullptr); const v3f line_vector = shootline_on_map.getVector(); for (auto obj : objs) {