🎉 Avoid rendering too small shapes

This commit is contained in:
Alejandro Alonso 2025-03-24 11:49:38 +01:00
parent d1d30e7eb5
commit a80f114d66
2 changed files with 9 additions and 1 deletions

View file

@ -586,7 +586,7 @@ impl RenderState {
if !self.render_in_progress {
return Ok(());
}
let scale = self.get_scale();
let mut should_stop = false;
while !should_stop {
if let Some(current_tile) = self.current_tile {
@ -663,6 +663,7 @@ impl RenderState {
}
if !transformed_element.extrect().intersects(self.render_area)
|| transformed_element.hidden()
|| transformed_element.visually_insignificant(scale)
{
debug::render_debug_shape(self, &transformed_element, false);
continue;

View file

@ -42,6 +42,8 @@ pub use transform::*;
use crate::math;
use crate::math::{Bounds, Matrix, Point};
const MIN_VISIBLE_SIZE: f32 = 2.0;
#[derive(Debug, Clone, PartialEq)]
pub enum Type {
Frame(Frame),
@ -505,6 +507,11 @@ impl Shape {
self.hidden
}
pub fn visually_insignificant(&self, scale: f32) -> bool {
self.selrect.width() * scale < MIN_VISIBLE_SIZE
|| self.selrect.height() * scale < MIN_VISIBLE_SIZE
}
// TODO: Maybe store this inside the shape
pub fn bounds(&self) -> Bounds {
let mut bounds = Bounds::new(