diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 696caa3..87a1ecb 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -8,3 +8,6 @@ # Version 0.2.0 - Migrated to bevy 0.9 - Removed debug_lines feature, to not have a third party bevy dependency. + +# Version 0.3.0 +- Migrated to bevy 0.10 diff --git a/Cargo.toml b/Cargo.toml index 780ac5a..b2f6ed7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_mod_inverse_kinematics" -version = "0.2.0" +version = "0.3.0" authors = ["Bram Buurlage "] edition = "2021" categories = ["game-engines", "graphics", "rendering"] @@ -10,7 +10,7 @@ keywords = ["gamedev", "graphics", "bevy", "animation"] license = "MIT OR Apache-2.0" [dependencies] -bevy = "0.9.0" +bevy = "0.10" #bevy_prototype_debug_lines = { version = "0.9.1", features = ["3d"], optional = true } [features] diff --git a/README.MD b/README.MD index aac48d5..da6b93f 100644 --- a/README.MD +++ b/README.MD @@ -11,10 +11,11 @@ A [Bevy](https://github.com/bevyengine/bevy) plugin for inverse kinematics. Supp I intend to track the latest releases of Bevy. -| bevy | bevy_mod_inverse_kinematics | -| ----- | --------------------------- | -| 0.8.1 | 0.1 | -| 0.9.0 | 0.2 | +| bevy | bevy_mod_inverse_kinematics | +| ------ | --------------------------- | +| 0.8.1 | 0.1 | +| 0.9.0 | 0.2 | +| 0.10.0 | 0.3 | ## Examples diff --git a/examples/skin_mesh.rs b/examples/skin_mesh.rs index 12b68e8..2edbe3b 100644 --- a/examples/skin_mesh.rs +++ b/examples/skin_mesh.rs @@ -1,4 +1,4 @@ -use bevy::prelude::*; +use bevy::{prelude::*, window::WindowResolution}; use bevy_mod_inverse_kinematics::*; #[derive(Component)] @@ -7,11 +7,10 @@ pub struct ManuallyTarget(Vec4); fn main() { App::new() .add_plugins(DefaultPlugins.set(WindowPlugin { - window: WindowDescriptor { - width: 800.0, - height: 600.0, + primary_window: Some(Window { + resolution: WindowResolution::new(800.0, 600.0), ..default() - }, + }), ..default() })) .add_plugin(InverseKinematicsPlugin) @@ -43,21 +42,11 @@ fn setup( }); }); - let size = 30.0; commands.spawn(DirectionalLightBundle { directional_light: DirectionalLight { color: Color::WHITE, illuminance: 10000.0, shadows_enabled: true, - shadow_projection: OrthographicProjection { - left: -size, - right: size, - bottom: -size, - top: size, - near: -size, - far: size, - ..default() - }, ..default() }, transform: Transform::from_xyz(-8.0, 8.0, 8.0).looking_at(Vec3::ZERO, Vec3::Y), @@ -65,7 +54,10 @@ fn setup( }); commands.spawn(PbrBundle { - mesh: meshes.add(Mesh::from(shape::Plane { size: 5.0 })), + mesh: meshes.add(Mesh::from(shape::Plane { + size: 5.0, + subdivisions: 0, + })), material: materials.add(StandardMaterial { base_color: Color::WHITE, ..default() @@ -113,9 +105,10 @@ fn setup_ik( .spawn(( PbrBundle { transform: Transform::from_xyz(0.3, 0.8, 0.2), - mesh: meshes.add(Mesh::from(shape::Icosphere { + mesh: meshes.add(Mesh::from(shape::UVSphere { radius: 0.05, - subdivisions: 1, + sectors: 7, + stacks: 7, })), material: materials.add(StandardMaterial { base_color: Color::RED, @@ -130,9 +123,10 @@ fn setup_ik( let pole_target = commands .spawn(PbrBundle { transform: Transform::from_xyz(-1.0, 0.4, -0.2), - mesh: meshes.add(Mesh::from(shape::Icosphere { + mesh: meshes.add(Mesh::from(shape::UVSphere { radius: 0.05, - subdivisions: 1, + sectors: 7, + stacks: 7, })), material: materials.add(StandardMaterial { base_color: Color::GREEN, @@ -149,6 +143,7 @@ fn setup_ik( target, pole_target: Some(pole_target), pole_angle: -std::f32::consts::FRAC_PI_2, + enabled: true, }); } } diff --git a/src/lib.rs b/src/lib.rs index 3f0229a..befbc3d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,14 +24,15 @@ pub struct IkConstraint { /// If a pole target is set, the bone will roll toward the pole target. /// This angle is the offset to apply to the roll. pub pole_angle: f32, + /// Whether this constraint is enabled. Disabled constraints will be skipped. + pub enabled: bool, } impl Plugin for InverseKinematicsPlugin { fn build(&self, app: &mut App) { - app.add_system_to_stage( - CoreStage::PostUpdate, + app.add_system( solver::inverse_kinematics_system - .after(bevy::transform::TransformSystem::TransformPropagate), + //.after(bevy::transform::TransformSystem::TransformPropagate), ); } } diff --git a/src/solver.rs b/src/solver.rs index 3939a0a..fdb3d21 100644 --- a/src/solver.rs +++ b/src/solver.rs @@ -16,6 +16,10 @@ pub fn inverse_kinematics_system( mut transforms: Query<(&mut Transform, &mut GlobalTransform)>, ) { for (entity, constraint) in query.iter() { + if !constraint.enabled { + continue; + } + if let Err(e) = constraint.solve( entity, &parents,