feat: migrate to glam whenever relevant + migrate testbed to kiss3d instead of bevy + release v0.32.0 (#909)
* feat: migrate to glam whenever relevant + migrate testbed to kiss3d instead of bevy * chore: update changelog * Fix warnings and tests * Release v0.32.0
This commit is contained in:
@@ -16,7 +16,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
let ground_size = 0.2;
|
||||
let ground_height = 0.01;
|
||||
|
||||
let rigid_body = RigidBodyBuilder::fixed().translation(vector![0.0, -ground_height, 0.0]);
|
||||
let rigid_body = RigidBodyBuilder::fixed().translation(Vector::new(0.0, -ground_height, 0.0));
|
||||
let floor_handle = bodies.insert(rigid_body);
|
||||
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
|
||||
colliders.insert_with_parent(collider, floor_handle, &mut bodies);
|
||||
@@ -41,8 +41,8 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
colliders.insert_with_parent(collider, new_body, &mut bodies);
|
||||
|
||||
let link_ab = SphericalJointBuilder::new()
|
||||
.local_anchor1(point![0.0, size / 2.0 * (i != 0) as usize as f32, 0.0])
|
||||
.local_anchor2(point![0.0, -size / 2.0, 0.0])
|
||||
.local_anchor1(Vector::new(0.0, size / 2.0 * (i != 0) as usize as f32, 0.0))
|
||||
.local_anchor2(Vector::new(0.0, -size / 2.0, 0.0))
|
||||
.build()
|
||||
.data;
|
||||
|
||||
@@ -70,14 +70,18 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
};
|
||||
|
||||
// Cast a ray on a plane aligned with the camera passing through the origin.
|
||||
let halfspace = HalfSpace {
|
||||
normal: -UnitVector::new_normalize(graphics.camera_fwd_dir()),
|
||||
};
|
||||
let mouse_ray = Ray::new(mouse_ray.0, mouse_ray.1);
|
||||
let Some(hit) = halfspace.cast_local_ray(&mouse_ray, f32::MAX, false) else {
|
||||
let fwd = graphics.camera_fwd_dir();
|
||||
let fwd_glam = Vector::new(-fwd.x, -fwd.y, -fwd.z).normalize();
|
||||
let halfspace = HalfSpace { normal: fwd_glam };
|
||||
let (mouse_orig, mouse_dir) = mouse_ray;
|
||||
let ray = Ray::new(
|
||||
Vector::new(mouse_orig.x, mouse_orig.y, mouse_orig.z),
|
||||
Vector::new(mouse_dir.x, mouse_dir.y, mouse_dir.z),
|
||||
);
|
||||
let Some(hit) = halfspace.cast_local_ray(&ray, f32::MAX, false) else {
|
||||
return;
|
||||
};
|
||||
let target_point = mouse_ray.point_at(hit);
|
||||
let target_point = ray.point_at(hit);
|
||||
|
||||
let options = InverseKinematicsOption {
|
||||
constrained_axes: JointAxesMask::LIN_AXES,
|
||||
@@ -88,7 +92,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
&physics.bodies,
|
||||
link_id,
|
||||
&options,
|
||||
&Isometry::from(target_point),
|
||||
&Pose::from_translation(target_point),
|
||||
|_| true,
|
||||
&mut displacements,
|
||||
);
|
||||
@@ -100,5 +104,5 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
* Set up the testbed.
|
||||
*/
|
||||
testbed.set_world(bodies, colliders, impulse_joints, multibody_joints);
|
||||
testbed.look_at(point![0.0, 0.5, 2.5], point![0.0, 0.5, 0.0]);
|
||||
testbed.look_at(Vec3::new(0.0, 0.5, 2.5), Vec3::new(0.0, 0.5, 0.0));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user