Skip to content

Commit

Permalink
Fix short raycasts missing large objects (#14339)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
appgurueu committed Feb 4, 2024
1 parent e7dbd32 commit 1d9c971
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions doc/lua_api.md
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/serverenvironment.cpp
Expand Up @@ -1826,8 +1826,8 @@ void ServerEnvironment::getSelectedActiveObjects(
const std::optional<Pointabilities> &pointabilities)
{
std::vector<ServerActiveObject *> 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) {
Expand Down

0 comments on commit 1d9c971

Please sign in to comment.