From b38b6b659dffc7248927c16f28a19754abf4e6c0 Mon Sep 17 00:00:00 2001 From: Benjamin Date: Tue, 8 Apr 2025 11:55:10 -0700 Subject: [PATCH] common: fix incorrect aabb of scenes --- src/renderer/tvgScene.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/renderer/tvgScene.h b/src/renderer/tvgScene.h index 3c213141..62fe6a85 100644 --- a/src/renderer/tvgScene.h +++ b/src/renderer/tvgScene.h @@ -194,7 +194,7 @@ struct Scene::Impl : Paint::Impl return ret; } - Result bounds(Point* pt4, Matrix& m, TVG_UNUSED bool obb, bool stroking) + Result bounds(Point* pt4, Matrix& m, bool obb, bool stroking) { if (paints.empty()) return Result::InsufficientCondition; @@ -203,7 +203,7 @@ struct Scene::Impl : Paint::Impl for (auto paint : paints) { Point tmp[4]; - if (PAINT(paint)->bounds(tmp, nullptr, false, stroking) != Result::Success) continue; + if (PAINT(paint)->bounds(tmp, obb ? nullptr : &m, false, stroking) != Result::Success) continue; //Merge regions for (int i = 0; i < 4; ++i) { if (tmp[i].x < min.x) min.x = tmp[i].x; @@ -212,10 +212,17 @@ struct Scene::Impl : Paint::Impl if (tmp[i].y > max.y) max.y = tmp[i].y; } } - pt4[0] = min * m; - pt4[1] = Point{max.x, min.y} * m; - pt4[2] = max * m; - pt4[3] = Point{min.x, max.y} * m; + pt4[0] = min; + pt4[1] = Point{max.x, min.y}; + pt4[2] = max; + pt4[3] = Point{min.x, max.y}; + + if (obb) { + pt4[0] *= m; + pt4[1] *= m; + pt4[2] *= m; + pt4[3] *= m; + } return Result::Success; }