aboutsummaryrefslogtreecommitdiff
path: root/src/client/clientenvironment.cpp
diff options
context:
space:
mode:
authorLars Müller <34514239+appgurueu@users.noreply.github.com>2022-10-30 16:53:14 +0100
committerGitHub <noreply@github.com>2022-10-30 16:53:14 +0100
commit077627181ee2eac3c0dacc3d8dc49825837e474c (patch)
treea8a6298198738f2edb30bd7e733a7a0d2005affa /src/client/clientenvironment.cpp
parentb8292319924994352d56d6111faa73fe315d149a (diff)
downloadminetest-077627181ee2eac3c0dacc3d8dc49825837e474c.tar.xz
Allow rotating entity selectionboxes (#12379)
Diffstat (limited to 'src/client/clientenvironment.cpp')
-rw-r--r--src/client/clientenvironment.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/client/clientenvironment.cpp b/src/client/clientenvironment.cpp
index 0b6f1a325..1ce443bcc 100644
--- a/src/client/clientenvironment.cpp
+++ b/src/client/clientenvironment.cpp
@@ -505,15 +505,24 @@ void ClientEnvironment::getSelectedActiveObjects(
if (!obj->getSelectionBox(&selection_box))
continue;
- const v3f &pos = obj->getPosition();
- 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,
- &current_intersection, &current_normal)) {
- objects.emplace_back((s16) obj->getId(), current_intersection, current_normal,
+ v3f current_normal, current_raw_normal;
+ const v3f rel_pos = shootline_on_map.start - obj->getPosition();
+ bool collision;
+ GenericCAO* gcao = dynamic_cast<GenericCAO*>(obj);
+ if (gcao != nullptr && gcao->getProperties().rotate_selectionbox) {
+ gcao->getSceneNode()->updateAbsolutePosition();
+ const v3f deg = obj->getSceneNode()->getAbsoluteTransformation().getRotationDegrees();
+ collision = boxLineCollision(selection_box, deg,
+ rel_pos, line_vector, &current_intersection, &current_normal, &current_raw_normal);
+ } else {
+ collision = boxLineCollision(selection_box, rel_pos, line_vector,
+ &current_intersection, &current_normal);
+ current_raw_normal = current_normal;
+ }
+ if (collision) {
+ current_intersection += obj->getPosition();
+ objects.emplace_back(obj->getId(), current_intersection, current_normal, current_raw_normal,
(current_intersection - shootline_on_map.start).getLengthSQ());
}
}