Skip to content

Commit

Permalink
スナップ処理後の頂点がpoly_bufに反映されるように修正
Browse files Browse the repository at this point in the history
  • Loading branch information
yud0uhu committed Nov 7, 2024
1 parent 8b4acae commit 78f90be
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions nusamai/src/sink/cesiumtiles/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;

Check warning on line 417 in nusamai/src/sink/cesiumtiles/slice.rs

View check run for this annotation

Codecov / codecov/patch

nusamai/src/sink/cesiumtiles/slice.rs#L417

Added line #L417 was not covered by tests
}

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);
Expand Down

0 comments on commit 78f90be

Please sign in to comment.