From 6626748fa699b82e40008d84c56a6fe5d61ed3ee Mon Sep 17 00:00:00 2001 From: Sergei Surovtsev Date: Tue, 2 Apr 2024 17:36:39 +0300 Subject: [PATCH] upd to recent bevy --- Cargo.toml | 6 +++--- src/adapters.rs | 9 ++++++--- src/mujoco_shape.rs | 8 ++++++-- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0da7a7b..d91e331 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" } diff --git a/src/adapters.rs b/src/adapters.rs index ab96339..86e5be5 100644 --- a/src/adapters.rs +++ b/src/adapters.rs @@ -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}; @@ -47,8 +47,11 @@ pub(crate) fn body_tree(bodies: &[Body]) -> Vec { /// 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 diff --git a/src/mujoco_shape.rs b/src/mujoco_shape.rs index 63ddc53..a871935 100644 --- a/src/mujoco_shape.rs +++ b/src/mujoco_shape.rs @@ -4,6 +4,7 @@ use bevy::{ prelude::*, render::{ mesh::{Indices, Mesh}, + render_asset::RenderAssetUsages, render_resource::PrimitiveTopology, }, }; @@ -114,8 +115,11 @@ impl From 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);