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

Update mesh-loader & CI fixes #234

Merged
merged 4 commits into from
Jan 15, 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
1 change: 0 additions & 1 deletion .github/.cspell/project-dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ rospack
rosrun
rustdocflags
rustflags
rustfmt
rustlib
RUSTSEC
rusttype
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:
branches: [main]
schedule:
- cron: '0 15 * * *'
- cron: '0 15 * * 0,4' # Every Monday and Friday at 00:00 JST

env:
CARGO_INCREMENTAL: 0
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ assimp = ["assimp-crate", "assimp-sys", "tempfile"]
crossbeam-queue = "0.3.5"
k = "0.31"
kiss3d = "0.35"
mesh-loader = "0.0.2"
mesh-loader = "0.1"
rand = "0.8"
serde = { version = "1.0", features = ["derive"] }
structopt = "0.3"
Expand Down
63 changes: 33 additions & 30 deletions src/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ fn load_mesh_assimp(
let mut importer = assimp::Importer::new();
importer.pre_transform_vertices(|x| x.enable = true);
importer.collada_ignore_up_direction(true);
importer.triangulate(true);
let (meshes, textures, colors) =
convert_assimp_scene_to_kiss3d_mesh(&importer.read_file(file_string)?);
info!(
Expand Down Expand Up @@ -276,7 +277,7 @@ fn load_stl(
opt_color: &Option<na::Point3<f32>>,
group: &mut SceneNode,
) -> Result<SceneNode> {
let stl = mesh_loader::stl::from_slice(bytes)?;
let stl = mesh_loader::Mesh::merge(mesh_loader::stl::from_slice(bytes)?.meshes);
let mesh = Rc::new(RefCell::new(kiss3d::resource::Mesh::new(
stl.vertices.into_iter().map(Into::into).collect(),
stl.faces
Expand Down Expand Up @@ -307,35 +308,37 @@ fn load_collada(
group: &mut SceneNode,
) -> Result<SceneNode> {
let mut base = group.add_group();
let collada =
mesh_loader::collada::from_str(s).map_err(|e| crate::Error::Other(e.to_string()))?;
for mesh in collada.meshes {
debug!(
"name={},vertices={},normals={},texcoords0={},texcoords1={},faces={}",
mesh.name,
mesh.vertices.len(),
mesh.normals.len(),
mesh.texcoords[0].len(),
mesh.texcoords[1].len(),
mesh.faces.len()
);
let positions = mesh.vertices.iter().map(|&v| na::Point3::from(v)).collect();
let faces = mesh
.faces
.iter()
.map(|v| na::Point3::new(v[0] as u16, v[1] as u16, v[2] as u16))
.collect();
let mut scene = base.add_mesh(
Rc::new(RefCell::new(kiss3d::resource::Mesh::new(
positions, faces, None, None, false,
))),
scale,
);
if let Some(color) = *opt_color {
scene.set_color(color[0], color[1], color[2]);
}

// TODO: material
let collada = mesh_loader::Mesh::merge(mesh_loader::collada::from_str(s)?.meshes);
debug!(
"name={},vertices={},normals={},texcoords0={},texcoords1={},faces={}",
collada.name,
collada.vertices.len(),
collada.normals.len(),
collada.texcoords[0].len(),
collada.texcoords[1].len(),
collada.faces.len()
);
let positions = collada.vertices.into_iter().map(Into::into).collect();
let faces = collada
.faces
.into_iter()
.map(|f| {
na::Point3::new(
f[0].try_into().unwrap(),
f[1].try_into().unwrap(),
f[2].try_into().unwrap(),
)
})
.collect();
let mut scene = base.add_mesh(
Rc::new(RefCell::new(kiss3d::resource::Mesh::new(
positions, faces, None, None, false,
))),
scale,
);
if let Some(color) = *opt_color {
scene.set_color(color[0], color[1], color[2]);
}
// TODO: material
Ok(base)
}
2 changes: 1 addition & 1 deletion tools/spell-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ if [[ -n "$(git ls-files '*Cargo.toml')" ]]; then
dependencies=$(sed <<<"${dependencies}" 's/[0-9_-]/\n/g' | LC_ALL=C sort -f -u)
fi
config_old=$(<.cspell.json)
config_new=$(grep <<<"${config_old}" -v ' *//' | jq 'del(.dictionaries[])' | jq 'del(.dictionaryDefinitions[])')
config_new=$(grep <<<"${config_old}" -v '^ *//' | jq 'del(.dictionaries[])' | jq 'del(.dictionaryDefinitions[])')
trap -- 'echo "${config_old}" >.cspell.json; echo >&2 "$0: trapped SIGINT"; exit 1' SIGINT
echo "${config_new}" >.cspell.json
if [[ -n "${has_rust}" ]]; then
Expand Down