From 78f90be13c727f6a48f7c507a15e4acc24880912 Mon Sep 17 00:00:00 2001 From: osaka-yu Date: Thu, 7 Nov 2024 13:04:47 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=B9=E3=83=8A=E3=83=83=E3=83=97=E5=87=A6?= =?UTF-8?q?=E7=90=86=E5=BE=8C=E3=81=AE=E9=A0=82=E7=82=B9=E3=81=8Cpoly=5Fbu?= =?UTF-8?q?f=E3=81=AB=E5=8F=8D=E6=98=A0=E3=81=95=E3=82=8C=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nusamai/src/sink/cesiumtiles/slice.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/nusamai/src/sink/cesiumtiles/slice.rs b/nusamai/src/sink/cesiumtiles/slice.rs index 87468268..d78dae62 100644 --- a/nusamai/src/sink/cesiumtiles/slice.rs +++ b/nusamai/src/sink/cesiumtiles/slice.rs @@ -263,7 +263,7 @@ fn slice_polygon( // todo?: check interior bbox to optimize for (ri, (ring, uv_ring)) in poly.rings().zip_eq(poly_uv.rings()).enumerate() { - if ring.raw_coords().is_empty() { + if ring.is_empty() { continue; } @@ -350,7 +350,7 @@ fn slice_polygon( poly_buf.clear(); for ring in y_sliced_poly.rings() { - if ring.raw_coords().is_empty() { + if ring.is_empty() { continue; } @@ -410,19 +410,21 @@ fn slice_polygon( max_y: 1.0, }; - let rings: Vec<_> = poly_buf.rings().collect(); + let rings: Vec<_> = poly_buf.rings().map(|r| r.raw_coords().to_vec()).collect(); - for ring in rings { - if ring.raw_coords().is_empty() { + for ring in rings.iter() { + if ring.is_empty() { continue; } ring_buffer.clear(); - for vertex in &ring { - let snapped_vertex = snap_to_tile_boundary(vertex, &tile_bounds); + for vertex in ring { + let snapped_vertex = snap_to_tile_boundary(*vertex, &tile_bounds); ring_buffer.push(snapped_vertex); } + let drained_ring: Vec<_> = ring_buffer.drain(..).collect(); + poly_buf.add_ring(drained_ring); } send_polygon(key, &poly_buf);