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:
Sébastien Crozet
2026-01-09 17:26:36 +01:00
committed by GitHub
parent 48de83817e
commit 0b7c3b34ec
265 changed files with 8501 additions and 8575 deletions

View File

@@ -1,3 +1,4 @@
use kiss3d::color::Color;
use rapier_testbed3d::Testbed;
use rapier3d::prelude::*;
@@ -5,16 +6,19 @@ pub fn build_block(
testbed: &mut Testbed,
bodies: &mut RigidBodySet,
colliders: &mut ColliderSet,
half_extents: Vector<f32>,
shift: Vector<f32>,
half_extents: Vector,
shift: Vector,
(mut numx, numy, mut numz): (usize, usize, usize),
) {
let dimensions = [half_extents.xyz(), half_extents.zyx()];
let dimensions = [
half_extents,
Vector::new(half_extents.z, half_extents.y, half_extents.x),
];
let block_width = 2.0 * half_extents.z * numx as f32;
let block_height = 2.0 * half_extents.y * numy as f32;
let spacing = (half_extents.z * numx as f32 - half_extents.x) / (numz as f32 - 1.0);
let mut color0 = [0.7, 0.5, 0.9];
let mut color1 = [0.6, 1.0, 0.6];
let mut color0 = Color::new(0.7, 0.5, 0.9, 1.0);
let mut color1 = Color::new(0.6, 1.0, 0.6, 1.0);
for i in 0..numy {
std::mem::swap(&mut numx, &mut numz);
@@ -36,11 +40,11 @@ pub fn build_block(
};
// Build the rigid body.
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![
let rigid_body = RigidBodyBuilder::dynamic().translation(Vector::new(
x + dim.x + shift.x,
y + dim.y + shift.y,
z + dim.z + shift.z
]);
z + dim.z + shift.z,
));
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(dim.x, dim.y, dim.z);
colliders.insert_with_parent(collider, handle, bodies);
@@ -52,16 +56,16 @@ pub fn build_block(
}
// Close the top.
let dim = half_extents.zxy();
let dim = Vector::new(half_extents.z, half_extents.x, half_extents.y);
for i in 0..(block_width / (dim.x * 2.0)) as usize {
for j in 0..(block_width / (dim.z * 2.0)) as usize {
// Build the rigid body.
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![
let rigid_body = RigidBodyBuilder::dynamic().translation(Vector::new(
i as f32 * dim.x * 2.0 + dim.x + shift.x,
dim.y + shift.y + block_height,
j as f32 * dim.z * 2.0 + dim.z + shift.z
]);
j as f32 * dim.z * 2.0 + dim.z + shift.z,
));
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(dim.x, dim.y, dim.z);
colliders.insert_with_parent(collider, handle, bodies);
@@ -86,7 +90,7 @@ pub fn init_world(testbed: &mut Testbed) {
let ground_size = 50.0;
let ground_height = 0.1;
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 handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
colliders.insert_with_parent(collider, handle, &mut bodies);
@@ -94,7 +98,7 @@ pub fn init_world(testbed: &mut Testbed) {
/*
* Create the cubes
*/
let half_extents = vector![0.02, 0.1, 0.4] / 2.0 * 10.0;
let half_extents = Vector::new(0.02, 0.1, 0.4) / 2.0 * 10.0;
let mut block_height = 0.0;
// These should only be set to odd values otherwise
// the blocks won't align in the nicest way.
@@ -111,7 +115,7 @@ pub fn init_world(testbed: &mut Testbed) {
&mut bodies,
&mut colliders,
half_extents,
vector![-block_width / 2.0, block_height, -block_width / 2.0],
Vector::new(-block_width / 2.0, block_height, -block_width / 2.0),
(numx, numy, numz),
);
block_height += numy as f32 * half_extents.y * 2.0 + half_extents.x * 2.0;
@@ -124,5 +128,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![100.0, 100.0, 100.0], Point::origin());
testbed.look_at(Vec3::new(100.0, 100.0, 100.0), Vec3::ZERO);
}