diff options
Diffstat (limited to 'src/serverenvironment.cpp')
-rw-r--r-- | src/serverenvironment.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/serverenvironment.cpp b/src/serverenvironment.cpp index 4cdb21a4b..f893064de 100644 --- a/src/serverenvironment.cpp +++ b/src/serverenvironment.cpp @@ -1771,16 +1771,27 @@ void ServerEnvironment::getSelectedActiveObjects( continue; v3f pos = obj->getBasePosition(); - - aabb3f offsetted_box(selection_box.MinEdge + pos, - selection_box.MaxEdge + pos); + v3f rel_pos = shootline_on_map.start - pos; v3f current_intersection; - v3s16 current_normal; - if (boxLineCollision(offsetted_box, shootline_on_map.start, line_vector, - ¤t_intersection, ¤t_normal)) { + v3f current_normal; + v3f current_raw_normal; + + ObjectProperties *props = obj->accessObjectProperties(); + bool collision; + UnitSAO* usao = dynamic_cast<UnitSAO*>(obj); + if (props->rotate_selectionbox && usao != nullptr) { + collision = boxLineCollision(selection_box, usao->getTotalRotation(), + rel_pos, line_vector, ¤t_intersection, ¤t_normal, ¤t_raw_normal); + } else { + collision = boxLineCollision(selection_box, rel_pos, line_vector, + ¤t_intersection, ¤t_normal); + current_raw_normal = current_normal; + } + if (collision) { + current_intersection += pos; objects.emplace_back( - (s16) obj->getId(), current_intersection, current_normal, + (s16) obj->getId(), current_intersection, current_normal, current_raw_normal, (current_intersection - shootline_on_map.start).getLengthSQ()); } } |