| 477 | } |
| 478 | |
| 479 | void ScaleRegionProjections(std::vector<RegionProjection>& projections, |
| 480 | const double scale) { |
| 481 | const float sf = static_cast<float>(scale); |
| 482 | for (auto& rp : projections) { |
| 483 | for (auto& fp : rp.face_projections) { |
| 484 | for (auto& p : fp) { |
| 485 | p *= sf; |
| 486 | } |
| 487 | } |
| 488 | // Recompute bounding box from scaled projections. |
| 489 | float min_x = std::numeric_limits<float>::max(); |
| 490 | float min_y = std::numeric_limits<float>::max(); |
| 491 | float max_x = std::numeric_limits<float>::lowest(); |
| 492 | float max_y = std::numeric_limits<float>::lowest(); |
| 493 | for (const auto& fp : rp.face_projections) { |
| 494 | for (const auto& p : fp) { |
| 495 | min_x = std::min(min_x, p.x()); |
| 496 | min_y = std::min(min_y, p.y()); |
| 497 | max_x = std::max(max_x, p.x()); |
| 498 | max_y = std::max(max_y, p.y()); |
| 499 | } |
| 500 | } |
| 501 | rp.bbox_x = static_cast<int>(std::floor(min_x)); |
| 502 | rp.bbox_y = static_cast<int>(std::floor(min_y)); |
| 503 | rp.bbox_width = static_cast<int>(std::ceil(max_x)) - rp.bbox_x + 1; |
| 504 | rp.bbox_height = static_cast<int>(std::ceil(max_y)) - rp.bbox_y + 1; |
| 505 | } |
| 506 | } |
| 507 | |
| 508 | AtlasLayout PackAtlas(const std::vector<RegionProjection>& projections, |
| 509 | const std::vector<FaceRegion>& regions, |
no outgoing calls
no test coverage detected