mirror of
https://github.com/emilk/egui.git
synced 2026-06-27 07:03:14 -04:00
Tesselator: ignore non-positive clip rectangles
Closes https://github.com/emilk/egui/issues/328
This commit is contained in:
@@ -304,16 +304,19 @@ impl Rect {
|
||||
}
|
||||
|
||||
/// `min.x <= max.x && min.y <= max.y`.
|
||||
#[inline(always)]
|
||||
pub fn is_non_negative(&self) -> bool {
|
||||
self.min.x <= self.max.x && self.min.y <= self.max.y
|
||||
}
|
||||
|
||||
/// True if all members are also finite.
|
||||
#[inline(always)]
|
||||
pub fn is_finite(&self) -> bool {
|
||||
self.min.is_finite() && self.max.is_finite()
|
||||
}
|
||||
|
||||
/// True if any member is NaN.
|
||||
#[inline(always)]
|
||||
pub fn any_nan(self) -> bool {
|
||||
self.min.any_nan() || self.max.any_nan()
|
||||
}
|
||||
|
||||
@@ -742,6 +742,10 @@ pub fn tessellate_shapes(
|
||||
let mut clipped_meshes: Vec<ClippedMesh> = Vec::default();
|
||||
|
||||
for ClippedShape(clip_rect, shape) in shapes {
|
||||
if !clip_rect.is_non_negative() {
|
||||
continue; // skip empty clip rectangles
|
||||
}
|
||||
|
||||
let start_new_mesh = match clipped_meshes.last() {
|
||||
None => true,
|
||||
Some(cm) => cm.0 != clip_rect || cm.1.texture_id != shape.texture_id(),
|
||||
|
||||
Reference in New Issue
Block a user