Skip to content

Commit

Permalink
upd to recent bevy
Browse files Browse the repository at this point in the history
  • Loading branch information
stillonearth committed Apr 2, 2024
1 parent 1b7ac13 commit 6626748
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ repository = "https://github.com/stillonearth/bevy_mujoco"
[dependencies]
mujoco-rust = { version = "0.0.6" }
arrayvec = "0.7.2"
bevy = "0.12"
bevy = "0.13"
trees = "0.4.1"
serde = { version = "1", features = ["derive"] }
itertools = "0.11.0"
itertools = "0.12"
nalgebra = "0.32.2"

[dev-dependencies]
rand = "0.8.5"
bevy_flycam = { git = "https://github.com/stillonearth/bevy_flycam.git", rev = "9508f35" }
bevy_flycam = { git = "https://github.com/stillonearth/bevy_flycam.git", rev = "baffe50" }
9 changes: 6 additions & 3 deletions src/adapters.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use bevy::{
prelude::*,
render::{mesh::Indices, render_resource::PrimitiveTopology},
render::{mesh::Indices, render_asset::RenderAssetUsages, render_resource::PrimitiveTopology},
};
use mujoco_rust::{Body, Geom, GeomType};
use nalgebra::{ArrayStorage, Const, Matrix, Quaternion};
Expand Down Expand Up @@ -47,8 +47,11 @@ pub(crate) fn body_tree(bodies: &[Body]) -> Vec<BodyTree> {

/// Make a bevy mesh from exported MuJoCo mesh
pub(crate) fn mesh_mujoco_2_bevy(mj_mesh: mujoco_rust::Mesh) -> Mesh {
let mut mesh = Mesh::new(PrimitiveTopology::TriangleList);
mesh.set_indices(Some(Indices::U32(mj_mesh.indices)));
let mut mesh = Mesh::new(
PrimitiveTopology::TriangleList,
RenderAssetUsages::MAIN_WORLD | RenderAssetUsages::RENDER_WORLD,
);
mesh.insert_indices(Indices::U32(mj_mesh.indices));
mesh.insert_attribute(Mesh::ATTRIBUTE_POSITION, mj_mesh.vertices);
mesh.insert_attribute(Mesh::ATTRIBUTE_NORMAL, mj_mesh.normals);
mesh
Expand Down
8 changes: 6 additions & 2 deletions src/mujoco_shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use bevy::{
prelude::*,
render::{
mesh::{Indices, Mesh},

Check failure on line 6 in src/mujoco_shape.rs

View workflow job for this annotation

GitHub Actions / clippy

the item `Mesh` is imported redundantly

error: the item `Mesh` is imported redundantly --> src/mujoco_shape.rs:6:25 | 4 | prelude::*, | ---------- the item `Mesh` is already imported here 5 | render::{ 6 | mesh::{Indices, Mesh}, | ^^^^ | = note: `-D unused-imports` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(unused_imports)]`
render_asset::RenderAssetUsages,
render_resource::PrimitiveTopology,
},
};
Expand Down Expand Up @@ -114,8 +115,11 @@ impl From<Cylinder> for Mesh {
.map(|&p| [p[0] / c.radius, (p[1] + c.height) / (c.height * 2.0)])
.collect();

let mut mesh = Mesh::new(PrimitiveTopology::TriangleList);
mesh.set_indices(Some(Indices::U32(indices)));
let mut mesh = Mesh::new(
PrimitiveTopology::TriangleList,
RenderAssetUsages::MAIN_WORLD | RenderAssetUsages::RENDER_WORLD,
);
mesh.insert_indices(Indices::U32(indices));
mesh.insert_attribute(Mesh::ATTRIBUTE_POSITION, positions);
mesh.insert_attribute(Mesh::ATTRIBUTE_NORMAL, normals);
mesh.insert_attribute(Mesh::ATTRIBUTE_UV_0, uvs);
Expand Down

0 comments on commit 6626748

Please sign in to comment.