Fix bug in Mesh::split_to_u16
(#2459)
Co-authored-by: Vladislav Zhukov <vlad.zhukov@elektron.se>
This commit is contained in:
parent
37fd141dd1
commit
ea5c9483a2
2 changed files with 5 additions and 3 deletions
|
@ -5,6 +5,7 @@ All notable changes to the epaint crate will be documented in this file.
|
|||
## Unreleased
|
||||
* Improve the look of thin white lines ([#2437](https://github.com/emilk/egui/pull/2437)).
|
||||
* Don't render `\r` (Carriage Return) ([#2452](https://github.com/emilk/egui/pull/2452)).
|
||||
* Fix bug in `Mesh::split_to_u16` ([#2459](https://github.com/emilk/egui/pull/2459)).
|
||||
|
||||
|
||||
## 0.20.0 - 2022-12-08
|
||||
|
|
|
@ -191,9 +191,9 @@ impl Mesh {
|
|||
pub fn split_to_u16(self) -> Vec<Mesh16> {
|
||||
crate::epaint_assert!(self.is_valid());
|
||||
|
||||
const MAX_SIZE: u32 = 1 << 16;
|
||||
const MAX_SIZE: u32 = std::u16::MAX as u32;
|
||||
|
||||
if self.vertices.len() < MAX_SIZE as usize {
|
||||
if self.vertices.len() <= MAX_SIZE as usize {
|
||||
// Common-case optimization:
|
||||
return vec![Mesh16 {
|
||||
indices: self.indices.iter().map(|&i| i as u16).collect(),
|
||||
|
@ -218,7 +218,8 @@ impl Mesh {
|
|||
new_max = new_max.max(idx);
|
||||
}
|
||||
|
||||
if new_max - new_min < MAX_SIZE {
|
||||
let new_span_size = new_max - new_min + 1; // plus one, because it is an inclusive range
|
||||
if new_span_size <= MAX_SIZE {
|
||||
// Triangle fits
|
||||
min_vindex = new_min;
|
||||
max_vindex = new_max;
|
||||
|
|
Loading…
Reference in a new issue