+void ServerEnvironment::getSelectedActiveObjects(
+ const core::line3d<f32> &shootline_on_map,
+ std::vector<PointedThing> &objects)
+{
+ std::vector<u16> objectIds;
+ getObjectsInsideRadius(objectIds, shootline_on_map.start,
+ shootline_on_map.getLength() + 10.0f);
+ const v3f line_vector = shootline_on_map.getVector();
+
+ for (u16 objectId : objectIds) {
+ ServerActiveObject* obj = getActiveObject(objectId);
+
+ aabb3f selection_box;
+ if (!obj->getSelectionBox(&selection_box))
+ continue;
+
+ v3f pos = obj->getBasePosition();
+
+ aabb3f offsetted_box(selection_box.MinEdge + pos,
+ selection_box.MaxEdge + pos);
+
+ v3f current_intersection;
+ v3s16 current_normal;
+ if (boxLineCollision(offsetted_box, shootline_on_map.start, line_vector,
+ ¤t_intersection, ¤t_normal)) {
+ objects.emplace_back(
+ (s16) objectId, current_intersection, current_normal,
+ (current_intersection - shootline_on_map.start).getLengthSQ());
+ }
+ }
+}
+