From 057c5f8d1c9b075d3563e6cfd71f0b9e2e83a89a Mon Sep 17 00:00:00 2001 From: Brandon Reinhart Date: Mon, 4 Mar 2024 23:17:25 -0600 Subject: [PATCH 1/7] update to bevy-0.13 --- Cargo.toml | 8 ++++---- examples/custom_material.rs | 5 ++--- src/assets.rs | 14 +++++--------- src/lib.rs | 13 +++++++------ src/materials.rs | 5 ++--- 5 files changed, 20 insertions(+), 25 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index abdb30c..7284cd3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,13 +13,13 @@ exclude = [ [dependencies] rusty_spine = "0.7" -bevy = { version = "0.12", default-features = false, features = [ "bevy_render", "bevy_asset", "bevy_sprite" ] } -glam = { version = "0.24", features = [ "mint" ] } +bevy = { version = "0.13", default-features = false, features = [ "bevy_render", "bevy_asset", "bevy_sprite" ] } +glam = { version = "0.25", features = [ "mint" ] } thiserror = "1.0.50" [dev-dependencies] -lerp = "0.4" -bevy = { version = "0.12", default-features = true } +lerp = "0.5" +bevy = { version = "0.13", default-features = true } [workspace] resolver = "2" diff --git a/examples/custom_material.rs b/examples/custom_material.rs index 9c5252d..a1bdd21 100644 --- a/examples/custom_material.rs +++ b/examples/custom_material.rs @@ -1,7 +1,7 @@ use bevy::{ ecs::system::{StaticSystemParam, SystemParam}, prelude::*, - reflect::{TypePath, TypeUuid}, + reflect::TypePath, render::{ mesh::MeshVertexBufferLayout, render_resource::{ @@ -85,8 +85,7 @@ fn on_spawn( #[derive(Component)] pub struct MySpine; -#[derive(Asset, AsBindGroup, TypeUuid, TypePath, Clone, Default)] -#[uuid = "2e85f9ae-049a-4bb5-9f5d-ebaaa208df60"] +#[derive(Asset, AsBindGroup, TypePath, Clone, Default)] pub struct MyMaterial { #[texture(0)] #[sampler(1)] diff --git a/src/assets.rs b/src/assets.rs index 31c0590..c89ffb5 100644 --- a/src/assets.rs +++ b/src/assets.rs @@ -3,7 +3,7 @@ use std::{path::Path, sync::Arc}; use bevy::{ asset::{io::Reader, AssetLoader, AsyncReadExt, LoadContext}, prelude::*, - reflect::{TypePath, TypeUuid}, + reflect::TypePath, utils::BoxedFuture, }; use rusty_spine::SpineError; @@ -20,8 +20,7 @@ pub enum SpineLoaderError { /// Bevy asset for [`rusty_spine::Atlas`], loaded from `.atlas` files. /// /// For loading a complete skeleton, see [`SkeletonData`]. -#[derive(Asset, Debug, TypeUuid, TypePath)] -#[uuid = "e58e872a-9d35-41bf-b561-95f843686004"] +#[derive(Asset, Debug, TypePath)] pub struct Atlas { pub atlas: Arc, } @@ -63,8 +62,7 @@ impl AssetLoader for AtlasLoader { /// Bevy asset for [`rusty_spine::SkeletonJson`], loaded from `.json` files. /// /// For loading a complete skeleton, see [`SkeletonData`]. -#[derive(Asset, Debug, TypeUuid, TypePath)] -#[uuid = "8637cf16-90c4-4825-bdf2-277e38788365"] +#[derive(Asset, Debug, TypePath)] pub struct SkeletonJson { pub json: Vec, } @@ -100,8 +98,7 @@ impl AssetLoader for SkeletonJsonLoader { /// Bevy asset for [`rusty_spine::SkeletonBinary`], loaded from `.skel` files. /// /// For loading a complete skeleton, see [`SkeletonData`]. -#[derive(Asset, Debug, TypeUuid, TypePath)] -#[uuid = "2a2a342a-29ae-4417-adf5-06ea7f0732d0"] +#[derive(Asset, Debug, TypePath)] pub struct SkeletonBinary { pub binary: Vec, } @@ -138,8 +135,7 @@ impl AssetLoader for SkeletonBinaryLoader { /// skeleton (either [`SkeletonJson`] or [`SkeletonBinary`]). /// /// See [`SkeletonData::new_from_json`] or [`SkeletonData::new_from_binary`]. -#[derive(Asset, Debug, TypeUuid, TypePath)] -#[uuid = "7796a37b-37a4-49ea-bf4e-fb7344aa6015"] +#[derive(Asset, Debug, TypePath)] pub struct SkeletonData { pub atlas_handle: Handle, pub kind: SkeletonDataKind, diff --git a/src/lib.rs b/src/lib.rs index 4ac3be0..3715f9b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,6 +13,7 @@ use bevy::{ prelude::*, render::{ mesh::{Indices, MeshVertexAttribute}, + render_asset::RenderAssetUsages, render_resource::{PrimitiveTopology, VertexFormat}, texture::{ImageAddressMode, ImageFilterMode, ImageSampler, ImageSamplerDescriptor}, }, @@ -714,8 +715,10 @@ fn spine_spawn( .with_children(|parent| { let mut z = 0.; for (index, _) in controller.skeleton.slots().enumerate() { - let mut mesh = - Mesh::new(PrimitiveTopology::TriangleList); + let mut mesh = Mesh::new( + PrimitiveTopology::TriangleList, + RenderAssetUsages::MAIN_WORLD, + ); empty_mesh(&mut mesh); let mesh_handle = meshes.add(mesh); parent.spawn(( @@ -990,7 +993,7 @@ fn spine_update_meshes( for _ in 0..vertices.len() { normals.push([0., 0., 0.]); } - mesh.set_indices(Some(Indices::U16(indices))); + mesh.insert_indices(Indices::U16(indices)); mesh.insert_attribute( MeshVertexAttribute::new("Vertex_Position", 0, VertexFormat::Float32x2), vertices, @@ -1022,15 +1025,13 @@ fn spine_update_meshes( } fn empty_mesh(mesh: &mut Mesh) { - let indices = Indices::U32(vec![]); - let positions: Vec<[f32; 3]> = vec![]; let normals: Vec<[f32; 3]> = vec![]; let uvs: Vec<[f32; 2]> = vec![]; let colors: Vec<[f32; 4]> = vec![]; let dark_colors: Vec<[f32; 4]> = vec![]; - mesh.set_indices(Some(indices)); + mesh.remove_indices(); mesh.insert_attribute(Mesh::ATTRIBUTE_POSITION, positions); mesh.insert_attribute(Mesh::ATTRIBUTE_NORMAL, normals); mesh.insert_attribute(Mesh::ATTRIBUTE_UV_0, uvs); diff --git a/src/materials.rs b/src/materials.rs index f77d813..dcae8e0 100644 --- a/src/materials.rs +++ b/src/materials.rs @@ -8,7 +8,7 @@ use bevy::{ asset::Asset, ecs::system::{StaticSystemParam, SystemParam}, prelude::*, - reflect::{TypePath, TypeUuid}, + reflect::TypePath, render::{ mesh::{MeshVertexAttribute, MeshVertexBufferLayout}, render_resource::{ @@ -131,8 +131,7 @@ pub struct SpineSettingsQuery<'w, 's> { macro_rules! material { ($(#[$($attrss:tt)*])* $uuid:literal, $name:ident, $blend_mode:expr, $premultiplied_alpha:expr, $blend_state:expr) => { $(#[$($attrss)*])* - #[derive(Asset, Default, AsBindGroup, TypeUuid, TypePath, Clone)] - #[uuid = $uuid] + #[derive(Asset, Default, AsBindGroup, TypePath, Clone)] pub struct $name { #[texture(0)] #[sampler(1)] From 6b2556f6791e563e6e4522aecfbd7b747e1b6b73 Mon Sep 17 00:00:00 2001 From: Brandon Reinhart Date: Mon, 4 Mar 2024 23:29:03 -0600 Subject: [PATCH 2/7] fix more build issues nothing visible atm though --- examples/3d.rs | 17 ++++++++++------- examples/events.rs | 2 +- examples/spineboy/player.rs | 14 +++++++------- src/test.rs | 1 + 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/examples/3d.rs b/examples/3d.rs index e8560c7..2237953 100644 --- a/examples/3d.rs +++ b/examples/3d.rs @@ -45,11 +45,14 @@ fn setup( mut materials: ResMut>, ) { // plane - commands.spawn(PbrBundle { - mesh: meshes.add(shape::Plane::from_size(5.0).into()), - material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()), - ..default() - }); + // commands.spawn(PbrBundle { + // mesh: meshes.add(Plane3d::default().mesh().size(5.0, 5.0)), + // material: materials.add(ColorMaterial { + // color: Color::rgb(0.3, 0.5, 0.3), + // ..default() + // }), + // ..default() + // }); // light commands.spawn(PointLightBundle { @@ -107,8 +110,8 @@ fn controls( mut window_query: Query<&mut Window, With>, mut mouse_motion_events: EventReader, mut orbit_query: Query<(&mut Orbit, &mut Transform)>, - mouse_buttons: Res>, - keys: Res>, + mouse_buttons: Res>, + keys: Res>, ) { let mut window = window_query.single_mut(); if mouse_buttons.just_pressed(MouseButton::Left) { diff --git a/examples/events.rs b/examples/events.rs index 940c60c..84ecad1 100644 --- a/examples/events.rs +++ b/examples/events.rs @@ -70,7 +70,7 @@ fn on_spine_event( color: Color::WHITE, }, ) - .with_alignment(TextAlignment::Center), + .with_justify(JustifyText::Center), transform: Transform::from_xyz(0., -200., 1.), ..Default::default() }) diff --git a/examples/spineboy/player.rs b/examples/spineboy/player.rs index 35d354c..59c565e 100644 --- a/examples/spineboy/player.rs +++ b/examples/spineboy/player.rs @@ -1,6 +1,5 @@ use bevy::prelude::*; use bevy_spine::prelude::*; -use lerp::Lerp; use crate::bullet::{BulletSpawnEvent, BulletSystem}; @@ -225,7 +224,8 @@ fn player_aim( spine.animation_state.track_at_index_mut(PLAYER_TRACK_AIM) { let alpha = aim_track.alpha() * 2.5; - aim_track.set_alpha(alpha.lerp(1., time.delta_seconds()).clamp(0., 1.)); + aim_track + .set_alpha(lerp::Lerp::lerp(alpha, 1., time.delta_seconds()).clamp(0., 1.)); } } } @@ -237,7 +237,7 @@ fn player_shoot( mut spine_query: Query<(&mut Spine, &Transform)>, mut bullet_spawn_events: EventWriter, global_transform_query: Query<&GlobalTransform>, - mouse_buttons: Res>, + mouse_buttons: Res>, time: Res