Now the world position of the bounding box return the right rotation (it was applied twice)

This commit is contained in:
bernatx 2022-07-26 22:06:54 +02:00 committed by bernat
parent 27b93905bf
commit 91430a3f1a
1 changed files with 18 additions and 1 deletions

View File

@ -84,12 +84,29 @@ namespace geom {
}};
}
/**
* Returns the positions of the 8 vertices of this BoundingBox in local space without its own rotation.
*/
std::array<Location, 8> GetLocalVerticesNoRotation() const {
return {{
location + Location({-extent.x,-extent.y,-extent.z}),
location + Location({-extent.x,-extent.y, extent.z}),
location + Location({-extent.x, extent.y,-extent.z}),
location + Location({-extent.x, extent.y, extent.z}),
location + Location({ extent.x,-extent.y,-extent.z}),
location + Location({ extent.x,-extent.y, extent.z}),
location + Location({ extent.x, extent.y,-extent.z}),
location + Location({ extent.x, extent.y, extent.z})
}};
}
/**
* Returns the positions of the 8 vertices of this BoundingBox in world space.
* @param in_bbox_to_world_transform The Transform from this BoundingBox space to world space.
*/
std::array<Location, 8> GetWorldVertices(const Transform &in_bbox_to_world_tr) const {
auto world_vertices = GetLocalVertices();
auto world_vertices = GetLocalVerticesNoRotation();
std::for_each(world_vertices.begin(), world_vertices.end(), [&in_bbox_to_world_tr](auto &world_vertex) {
in_bbox_to_world_tr.TransformPoint(world_vertex);
});