Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix: earcut-rs utils3d API changes #286

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions nusamai-geometry/examples/citygml_polygons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ end_header
// comment crs: GEOGCRS["JGD2011",DATUM["Japanese Geodetic Datum 2011",ELLIPSOID["GRS 1980",6378137,298.257222101,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",0,ANGLEUNIT["degree",0.0174532925199433]],CS[ellipsoidal,2],AXIS["geodetic latitude (Lat)",north,ORDER[1],ANGLEUNIT["degree",0.0174532925199433]],AXIS["geodetic longitude (Lon)",east,ORDER[2],ANGLEUNIT["degree",0.0174532925199433]],USAGE[SCOPE["Horizontal component of 3D system."],AREA["Japan - onshore and offshore."],BBOX[17.09,122.38,46.05,157.65]],ID["EPSG",6668]]

fn write_features(mpolys: &[MultiPolygon3], mu_lng: f64, mu_lat: f64) {
use earcut_rs::{utils_3d::project3d_to_2d, Earcut};
use earcut_rs::{utils3d::project3d_to_2d, Earcut};
let mut earcutter = Earcut::new();
let mut buf3d: Vec<f64> = Vec::new();
let mut buf2d: Vec<f64> = Vec::new();
Expand All @@ -240,7 +240,7 @@ fn write_features(mpolys: &[MultiPolygon3], mu_lng: f64, mu_lat: f64) {
]
}));

if project3d_to_2d(&buf3d, num_outer, &mut buf2d) {
if project3d_to_2d(&buf3d, num_outer, 3, &mut buf2d) {
// earcut
earcutter.earcut(&buf2d, poly.hole_indices(), 2, &mut triangles_out);
// indices and vertices
Expand Down
4 changes: 2 additions & 2 deletions nusamai-gltf/examples/geometry_to_gltf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

use byteorder::{LittleEndian, WriteBytesExt};
use clap::Parser;
use earcut_rs::{utils_3d::project3d_to_2d, Earcut};
use earcut_rs::{utils3d::project3d_to_2d, Earcut};
use indexmap::IndexSet;
use nusamai_geometry::MultiPolygon3;
use nusamai_gltf_json::*;
Expand Down Expand Up @@ -252,7 +252,7 @@ fn tessellate(
]
}));

if project3d_to_2d(&buf3d, num_outer, &mut buf2d) {
if project3d_to_2d(&buf3d, num_outer, 3, &mut buf2d) {
// earcut
earcutter.earcut(&buf2d, poly.hole_indices(), 2, &mut triangles_out);
// indices and vertices
Expand Down
4 changes: 2 additions & 2 deletions nusamai/src/sink/cesiumtiles/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::path::{Path, PathBuf};
use std::sync::{mpsc, Arc, Mutex};

use ahash::RandomState;
use earcut_rs::utils_3d::project3d_to_2d;
use earcut_rs::utils3d::project3d_to_2d;
use earcut_rs::Earcut;
use ext_sort::{buffer::mem::MemoryLimitedBufferBuilder, ExternalSorter, ExternalSorterBuilder};
use indexmap::IndexSet;
Expand Down Expand Up @@ -267,7 +267,7 @@ fn tile_writing_stage(
buf3d.clear();
buf3d.extend(poly.coords());

if project3d_to_2d(&buf3d, num_outer, &mut buf2d) {
if project3d_to_2d(&buf3d, num_outer, 3, &mut buf2d) {
// earcut
earcutter.earcut(&buf2d, poly.hole_indices(), 2, &mut triangles_buf);
triangles.extend(triangles_buf.iter().map(|idx| {
Expand Down
4 changes: 2 additions & 2 deletions nusamai/src/sink/gltf_poc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::path::{Path, PathBuf};

use ahash::RandomState;
use byteorder::{ByteOrder, LittleEndian};
use earcut_rs::utils_3d::project3d_to_2d;
use earcut_rs::utils3d::project3d_to_2d;
use earcut_rs::Earcut;
use indexmap::IndexSet;
use nusamai_gltf_json::extensions::mesh::ext_mesh_features::FeatureId;
Expand Down Expand Up @@ -178,7 +178,7 @@ impl DataSink for GltfPocSink {
buf3d.clear();
buf3d.extend(poly.coords());

if project3d_to_2d(&buf3d, num_outer, &mut buf2d) {
if project3d_to_2d(&buf3d, num_outer, 3, &mut buf2d) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

project3d_to_2d関数呼び出しに追加された引数3は、earcut-rsライブラリのAPI変更に対応するためのものです。この変更は、関数の新しいシグネチャに適合していますが、この追加引数の意味や目的についてのコメントがコード内にないため、将来のメンテナンス性が懸念されます。この引数が何を表しているのか、なぜ3が選ばれたのかについての説明をコメントとして追加することをお勧めします。

// earcut
earcutter.earcut(
&buf2d,
Expand Down
4 changes: 2 additions & 2 deletions nusamai/src/sink/ply/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::path::PathBuf;

use ahash::RandomState;
use byteorder::{ByteOrder, LittleEndian, WriteBytesExt};
use earcut_rs::{utils_3d::project3d_to_2d, Earcut};
use earcut_rs::{utils3d::project3d_to_2d, Earcut};
use indexmap::IndexSet;
use nusamai_citygml::{schema::Schema, GeometryType};

Expand Down Expand Up @@ -136,7 +136,7 @@ impl DataSink for StanfordPlySink {
buf3d.clear();
buf3d.extend(poly.coords());

if project3d_to_2d(&buf3d, num_outer, &mut buf2d) {
if project3d_to_2d(&buf3d, num_outer, 3, &mut buf2d) {
// earcut
earcutter.earcut(
&buf2d,
Expand Down
Loading