Migrated to bevy 0.10
This commit is contained in:
parent
927910bf63
commit
9184bef570
@ -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
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "bevy_mod_inverse_kinematics"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
authors = ["Bram Buurlage <brambuurlage@gmail.com>"]
|
||||
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]
|
||||
|
@ -12,9 +12,10 @@ 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 |
|
||||
| 0.10.0 | 0.3 |
|
||||
|
||||
## Examples
|
||||
|
||||
|
@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user