Migrated to bevy 0.11
This commit is contained in:
parent
9184bef570
commit
c9f877a4b1
@ -11,3 +11,6 @@
|
|||||||
|
|
||||||
# Version 0.3.0
|
# Version 0.3.0
|
||||||
- Migrated to bevy 0.10
|
- Migrated to bevy 0.10
|
||||||
|
|
||||||
|
# Version 0.4.0
|
||||||
|
- Migrated to bevy 0.11
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "bevy_mod_inverse_kinematics"
|
name = "bevy_mod_inverse_kinematics"
|
||||||
version = "0.3.0"
|
version = "0.4.0"
|
||||||
authors = ["Bram Buurlage <brambuurlage@gmail.com>"]
|
authors = ["Bram Buurlage <brambuurlage@gmail.com>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
categories = ["game-engines", "graphics", "rendering"]
|
categories = ["game-engines", "graphics", "rendering"]
|
||||||
@ -10,8 +10,4 @@ keywords = ["gamedev", "graphics", "bevy", "animation"]
|
|||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = "0.10"
|
bevy = "0.11"
|
||||||
#bevy_prototype_debug_lines = { version = "0.9.1", features = ["3d"], optional = true }
|
|
||||||
|
|
||||||
[features]
|
|
||||||
#debug_lines = ["bevy_prototype_debug_lines"]
|
|
||||||
|
@ -13,10 +13,9 @@ fn main() {
|
|||||||
}),
|
}),
|
||||||
..default()
|
..default()
|
||||||
}))
|
}))
|
||||||
.add_plugin(InverseKinematicsPlugin)
|
.add_plugins(InverseKinematicsPlugin)
|
||||||
.add_startup_system(setup)
|
.add_systems(Startup, setup)
|
||||||
.add_system(setup_ik)
|
.add_systems(Update, (setup_ik, manually_target))
|
||||||
.add_system(manually_target)
|
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,16 +187,15 @@ fn manually_target(
|
|||||||
|
|
||||||
if let Some(event) = cursor.iter().last() {
|
if let Some(event) = cursor.iter().last() {
|
||||||
let view = transform.compute_matrix();
|
let view = transform.compute_matrix();
|
||||||
let (viewport_min, viewport_max) = camera.logical_viewport_rect().unwrap();
|
let viewport_rect = camera.logical_viewport_rect().unwrap();
|
||||||
let screen_size = camera.logical_target_size().unwrap();
|
let viewport_size = viewport_rect.size();
|
||||||
let viewport_size = viewport_max - viewport_min;
|
let adj_cursor_pos = event.position - Vec2::new(viewport_rect.min.x, viewport_rect.min.y);
|
||||||
let adj_cursor_pos =
|
|
||||||
event.position - Vec2::new(viewport_min.x, screen_size.y - viewport_max.y);
|
|
||||||
|
|
||||||
let projection = camera.projection_matrix();
|
let projection = camera.projection_matrix();
|
||||||
let far_ndc = projection.project_point3(Vec3::NEG_Z).z;
|
let far_ndc = projection.project_point3(Vec3::NEG_Z).z;
|
||||||
let near_ndc = projection.project_point3(Vec3::Z).z;
|
let near_ndc = projection.project_point3(Vec3::Z).z;
|
||||||
let cursor_ndc = (adj_cursor_pos / viewport_size) * 2.0 - Vec2::ONE;
|
let cursor_ndc =
|
||||||
|
((adj_cursor_pos / viewport_size) * 2.0 - Vec2::ONE) * Vec2::new(1.0, -1.0);
|
||||||
let ndc_to_world: Mat4 = view * projection.inverse();
|
let ndc_to_world: Mat4 = view * projection.inverse();
|
||||||
let near = ndc_to_world.project_point3(cursor_ndc.extend(near_ndc));
|
let near = ndc_to_world.project_point3(cursor_ndc.extend(near_ndc));
|
||||||
let far = ndc_to_world.project_point3(cursor_ndc.extend(far_ndc));
|
let far = ndc_to_world.project_point3(cursor_ndc.extend(far_ndc));
|
||||||
|
@ -30,9 +30,6 @@ pub struct IkConstraint {
|
|||||||
|
|
||||||
impl Plugin for InverseKinematicsPlugin {
|
impl Plugin for InverseKinematicsPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.add_system(
|
app.add_systems(Update, solver::inverse_kinematics_system);
|
||||||
solver::inverse_kinematics_system
|
|
||||||
//.after(bevy::transform::TransformSystem::TransformPropagate),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user