Cache calculation of bounding boxes with transforms (#3287)

* Cache calculation of bounding boxes with transforms

* Reuse bounding boxes across for the same rotation

* Cleanup code and add documentation

* Add tests
This commit is contained in:
Dennis Kobert
2025-10-17 10:20:55 +00:00
committed by GitHub
parent 8d3a8c2c11
commit e8f18b0ac0
3 changed files with 307 additions and 9 deletions
@@ -154,10 +154,7 @@ impl DocumentMetadata {
pub fn bounding_box_with_transform(&self, layer: LayerNodeIdentifier, transform: DAffine2) -> Option<[DVec2; 2]> {
self.click_targets(layer)?
.iter()
.filter_map(|click_target| match click_target.target_type() {
ClickTargetType::Subpath(subpath) => subpath.bounding_box_with_transform(transform),
ClickTargetType::FreePoint(_) => click_target.bounding_box_with_transform(transform),
})
.filter_map(|click_target| click_target.bounding_box_with_transform(transform))
.reduce(Quad::combine_bounds)
}