Tesselator: ignore zero-sized clip rects
Improves https://github.com/emilk/egui/issues/328
This commit is contained in:
parent
1681769329
commit
58ebb217dc
3 changed files with 12 additions and 7 deletions
|
@ -333,7 +333,7 @@ impl Layout {
|
||||||
impl Layout {
|
impl Layout {
|
||||||
pub fn align_size_within_rect(&self, size: Vec2, outer: Rect) -> Rect {
|
pub fn align_size_within_rect(&self, size: Vec2, outer: Rect) -> Rect {
|
||||||
debug_assert!(size.x >= 0.0 && size.y >= 0.0);
|
debug_assert!(size.x >= 0.0 && size.y >= 0.0);
|
||||||
debug_assert!(outer.is_non_negative());
|
debug_assert!(!outer.is_negative());
|
||||||
self.align2().align_size_within_rect(size, outer)
|
self.align2().align_size_within_rect(size, outer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -571,7 +571,7 @@ impl Layout {
|
||||||
/// Apply justify (fill width/height) and/or alignment after calling `next_space`.
|
/// Apply justify (fill width/height) and/or alignment after calling `next_space`.
|
||||||
pub(crate) fn justify_and_align(&self, frame: Rect, mut child_size: Vec2) -> Rect {
|
pub(crate) fn justify_and_align(&self, frame: Rect, mut child_size: Vec2) -> Rect {
|
||||||
debug_assert!(child_size.x >= 0.0 && child_size.y >= 0.0);
|
debug_assert!(child_size.x >= 0.0 && child_size.y >= 0.0);
|
||||||
debug_assert!(frame.is_non_negative());
|
debug_assert!(!frame.is_negative());
|
||||||
|
|
||||||
if self.horizontal_justify() {
|
if self.horizontal_justify() {
|
||||||
child_size.x = child_size.x.at_least(frame.width()); // fill full width
|
child_size.x = child_size.x.at_least(frame.width()); // fill full width
|
||||||
|
|
|
@ -297,16 +297,21 @@ impl Rect {
|
||||||
self.max.x < self.min.x || self.max.y < self.min.y
|
self.max.x < self.min.x || self.max.y < self.min.y
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `max.x < min.x` or `max.y < min.y`.
|
/// `width < 0 || height < 0`
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn is_negative(&self) -> bool {
|
pub fn is_negative(&self) -> bool {
|
||||||
self.max.x < self.min.x || self.max.y < self.min.y
|
self.max.x < self.min.x || self.max.y < self.min.y
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `min.x <= max.x && min.y <= max.y`.
|
#[deprecated = "Use !is_negative() instead"]
|
||||||
#[inline(always)]
|
|
||||||
pub fn is_non_negative(&self) -> bool {
|
pub fn is_non_negative(&self) -> bool {
|
||||||
self.min.x <= self.max.x && self.min.y <= self.max.y
|
!self.is_negative()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `width > 0 && height > 0`
|
||||||
|
#[inline(always)]
|
||||||
|
pub fn is_positive(&self) -> bool {
|
||||||
|
self.min.x < self.max.x && self.min.y < self.max.y
|
||||||
}
|
}
|
||||||
|
|
||||||
/// True if all members are also finite.
|
/// True if all members are also finite.
|
||||||
|
|
|
@ -742,7 +742,7 @@ pub fn tessellate_shapes(
|
||||||
let mut clipped_meshes: Vec<ClippedMesh> = Vec::default();
|
let mut clipped_meshes: Vec<ClippedMesh> = Vec::default();
|
||||||
|
|
||||||
for ClippedShape(clip_rect, shape) in shapes {
|
for ClippedShape(clip_rect, shape) in shapes {
|
||||||
if !clip_rect.is_non_negative() {
|
if !clip_rect.is_positive() {
|
||||||
continue; // skip empty clip rectangles
|
continue; // skip empty clip rectangles
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue