diff --git a/src/client/activeobjectmgr.cpp b/src/client/activeobjectmgr.cpp index 7b7fab033..af2d6fe63 100644 --- a/src/client/activeobjectmgr.cpp +++ b/src/client/activeobjectmgr.cpp @@ -107,9 +107,9 @@ void ActiveObjectMgr::getActiveObjects(const v3f &origin, f32 max_d, } } -void ActiveObjectMgr::getActiveSelectableObjects(const core::line3d &shootline, - std::vector &dest) +std::vector ActiveObjectMgr::getActiveSelectableObjects(const core::line3d &shootline) { + std::vector dest; // Imagine a not-axis-aligned cuboid oriented into the direction of the shootline, // with the width of the object's selection box radius * 2 and with length of the // shootline (+selection box radius forwards and backwards). We check whether @@ -147,6 +147,7 @@ void ActiveObjectMgr::getActiveSelectableObjects(const core::line3d &shootl dest.emplace_back(obj, d); } + return dest; } } // namespace client diff --git a/src/client/activeobjectmgr.h b/src/client/activeobjectmgr.h index 78147abd4..a4243c644 100644 --- a/src/client/activeobjectmgr.h +++ b/src/client/activeobjectmgr.h @@ -37,12 +37,10 @@ public: void getActiveObjects(const v3f &origin, f32 max_d, std::vector &dest); - // Similar to above, but takes selection box sizes, and line direction into - // account. - // Objects without selectionbox are not returned. - // Returned distances are in direction of shootline. - // Distance check is coarse. - void getActiveSelectableObjects(const core::line3d &shootline, - std::vector &dest); + + /// Gets all CAOs whose selection boxes may intersect the @p shootline. + /// @note CAOs without a selection box are not returned. + /// @note Distances are along the @p shootline. + std::vector getActiveSelectableObjects(const core::line3d &shootline); }; } // namespace client diff --git a/src/client/clientenvironment.cpp b/src/client/clientenvironment.cpp index 69c8ac00b..d71b0ec33 100644 --- a/src/client/clientenvironment.cpp +++ b/src/client/clientenvironment.cpp @@ -495,8 +495,7 @@ void ClientEnvironment::getSelectedActiveObjects( const core::line3d &shootline_on_map, std::vector &objects) { - std::vector allObjects; - m_ao_manager.getActiveSelectableObjects(shootline_on_map, allObjects); + auto allObjects = m_ao_manager.getActiveSelectableObjects(shootline_on_map); const v3f line_vector = shootline_on_map.getVector(); for (const auto &allObject : allObjects) {