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

Make assimp feature disabled by default #240

Merged
merged 2 commits into from
Feb 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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ jobs:
if: startsWith(matrix.os, 'windows')

- run: cargo fmt --all --check
- run: cargo clippy --all-targets
- run: cargo clippy --all-features --all-targets
- run: cargo hack build --feature-powerset
- run: cargo test
- run: cargo test --all-features

wasm:
runs-on: ubuntu-20.04
Expand All @@ -68,7 +68,7 @@ jobs:
targets: wasm32-unknown-unknown
- name: Install wasm-pack
uses: taiki-e/install-action@wasm-pack
- run: cargo build --target wasm32-unknown-unknown --no-default-features --lib
- run: cargo build --target wasm32-unknown-unknown --lib
- run: cargo build --target wasm32-unknown-unknown -p urdf-viz-wasm
- name: Build wasm example
run: npm install && npm run build
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ jobs:
with:
bin: urdf-viz
include: ${{ matrix.include-files }}
# TODO: Should we enable assimp feature for pre-built binary?
# all-features: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_PROFILE_RELEASE_LTO: true
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ exclude = [".github/*", "img/*"]
members = ["examples/wasm"]

[features]
default = ["assimp"]
default = []
assimp = ["dep:assimp", "assimp-sys", "tempfile"]

# Note: k, kiss3d, serde, structopt, tokio, urdf-rs, and wasm-bindgen are public dependencies.
Expand Down
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,18 @@ If you are using rust-lang already and `cargo` is installed, you can install by
cargo install urdf-viz
```

If you don't use mesh other than `.obj`, `.stl`, and `.dae` files, you can skip install
of assimp by disabling the `assimp` feature like below.
If you want to use mesh other than `.obj`, `.stl`, and `.dae` files, you need to install
with assimp like below.

```bash
cargo install urdf-viz --no-default-features
cargo install urdf-viz --features assimp
```

Note: When the `assimp` feature is disabled, materials are not fully supported yet.

### Pre-requirements for build

#### Common

You need [cmake](https://cmake.org/download/) to use assimp (mesh loader).
It can be skipped if you use `--no-default-features`, but it will make it
fail to show mesh files other than `.obj`, `.stl`, and `.dae`.
If you want to use `--features assimp` to use mesh other than `.obj`, `.stl`, and `.dae` files, you need [cmake](https://cmake.org/download/).

#### On Linux

Expand Down Expand Up @@ -241,7 +237,7 @@ curl http://127.0.0.1:7777/get_urdf_text
* [kiss3d](https://github.com/sebcrozet/kiss3d): `urdf-viz` is strongly depend on `kiss3d`, which is super easy to use, great 3D graphic engine.
* [nalgebra](https://github.com/sebcrozet/nalgebra): linear algebra library.
* [k](https://github.com/openrr/k): kinematics library which is based on [nalgebra](https://github.com/sebcrozet/nalgebra). It can load URDF files using `urdf-rs`.
* [assimp-rs](https://github.com/Eljay/assimp-rs): assimp rust interface. `kiss3d` supports `.obj` files natively, but urdf contains `dae` or `stl` files. These files are converted to kiss3d mesh model by `assimp-rs`
* [mesh-loader](https://github.com/openrr/mesh-loader): Mesh files (`.obj`, `.stl`, and `.dae`) loader.
* [urdf-rs](https://github.com/openrr/urdf-rs): URDF file loader.
* [structopt](https://github.com/TeXitoi/structopt): super easy command line arguments parser.

Expand Down
2 changes: 1 addition & 1 deletion examples/wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
crate-type = ["cdylib"]

[target.'cfg(target_family = "wasm")'.dependencies]
urdf-viz = { path = "../..", default-features = false }
urdf-viz = { path = "../.." }
console_error_panic_hook = "0.1"
tracing-wasm = "0.2"
wasm-bindgen = "0.2"
Expand Down
1 change: 1 addition & 0 deletions src/assimp_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ pub(crate) fn convert_assimp_scene_to_kiss3d_mesh(
vertices.extend(mesh.vertex_iter().map(|v| na::Point3::new(v.x, v.y, v.z)));
indices.extend(mesh.face_iter().filter_map(|f| {
if f.num_indices == 3 {
// TODO: https://github.com/openrr/urdf-viz/issues/22
Some(na::Point3::new(f[0] as u16, f[1] as u16, f[2] as u16))
} else {
debug!("invalid mesh!");
Expand Down
9 changes: 2 additions & 7 deletions src/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,8 @@ fn load_with_mesh_loader(
let faces = mesh
.faces
.into_iter()
.map(|f| {
na::Point3::new(
f[0].try_into().unwrap(),
f[1].try_into().unwrap(),
f[2].try_into().unwrap(),
)
})
// TODO: https://github.com/openrr/urdf-viz/issues/22
.map(|f| na::Point3::new(f[0] as u16, f[1] as u16, f[2] as u16))
.collect();

let kiss3d_mesh = Rc::new(RefCell::new(kiss3d::resource::Mesh::new(
Expand Down