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,9 +6,9 @@ fn create_wall(
testbed: &mut Testbed,
bodies: &mut RigidBodySet,
colliders: &mut ColliderSet,
offset: Vector<f32>,
offset: Vector,
stack_height: usize,
half_extents: Vector<f32>,
half_extents: Vector,
) {
let shift = half_extents * 2.0;
let mut k = 0;
@@ -21,15 +22,17 @@ fn create_wall(
- stack_height as f32 * half_extents.z;
// Build the rigid body.
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y, z]);
let rigid_body = RigidBodyBuilder::dynamic().translation(Vector::new(x, y, z));
let handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(half_extents.x, half_extents.y, half_extents.z);
colliders.insert_with_parent(collider, handle, bodies);
k += 1;
if k % 2 == 0 {
testbed.set_initial_body_color(handle, [1., 131. / 255., 244.0 / 255.]);
testbed
.set_initial_body_color(handle, Color::new(1., 131. / 255., 244.0 / 255., 1.0));
} else {
testbed.set_initial_body_color(handle, [131. / 255., 1., 244.0 / 255.]);
testbed
.set_initial_body_color(handle, Color::new(131. / 255., 1., 244.0 / 255., 1.0));
}
}
}
@@ -50,7 +53,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 ground_handle = bodies.insert(rigid_body);
let collider = ColliderBuilder::cuboid(ground_size, ground_height, ground_size);
colliders.insert_with_parent(collider, ground_handle, &mut bodies);
@@ -69,18 +72,18 @@ pub fn init_world(testbed: &mut Testbed) {
testbed,
&mut bodies,
&mut colliders,
vector![x, shift_y, 0.0],
Vector::new(x, shift_y, 0.0),
num_z,
vector![0.5, 0.5, 1.0],
Vector::new(0.5, 0.5, 1.0),
);
create_wall(
testbed,
&mut bodies,
&mut colliders,
vector![x, shift_y, shift_z],
Vector::new(x, shift_y, shift_z),
num_z,
vector![0.5, 0.5, 1.0],
Vector::new(0.5, 0.5, 1.0),
);
}
@@ -94,8 +97,8 @@ pub fn init_world(testbed: &mut Testbed) {
.sensor(true)
.active_events(ActiveEvents::COLLISION_EVENTS);
let rigid_body = RigidBodyBuilder::dynamic()
.linvel(vector![1000.0, 0.0, 0.0])
.translation(vector![-20.0, shift_y + 2.0, 0.0])
.linvel(Vector::new(1000.0, 0.0, 0.0))
.translation(Vector::new(-20.0, shift_y + 2.0, 0.0))
.ccd_enabled(true);
let sensor_handle = bodies.insert(rigid_body);
colliders.insert_with_parent(collider, sensor_handle, &mut bodies);
@@ -103,20 +106,20 @@ pub fn init_world(testbed: &mut Testbed) {
// Second rigid-body with CCD enabled.
let collider = ColliderBuilder::ball(1.0).density(10.0);
let rigid_body = RigidBodyBuilder::dynamic()
.linvel(vector![1000.0, 0.0, 0.0])
.translation(vector![-20.0, shift_y + 2.0, shift_z])
.linvel(Vector::new(1000.0, 0.0, 0.0))
.translation(Vector::new(-20.0, shift_y + 2.0, shift_z))
.ccd_enabled(true);
let handle = bodies.insert(rigid_body);
colliders.insert_with_parent(collider.clone(), handle, &mut bodies);
testbed.set_initial_body_color(handle, [0.2, 0.2, 1.0]);
testbed.set_initial_body_color(handle, Color::new(0.2, 0.2, 1.0, 1.0));
// Callback that will be executed on the main loop to handle proximities.
testbed.add_callback(move |mut graphics, physics, events, _| {
while let Ok(prox) = events.collision_events.try_recv() {
let color = if prox.started() {
[1.0, 1.0, 0.0]
Color::new(1.0, 1.0, 0.0, 1.0)
} else {
[0.5, 0.5, 1.0]
Color::new(0.5, 0.5, 1.0, 1.0)
};
let parent_handle1 = physics
@@ -134,10 +137,10 @@ pub fn init_world(testbed: &mut Testbed) {
if let Some(graphics) = &mut graphics {
if parent_handle1 != ground_handle && parent_handle1 != sensor_handle {
graphics.set_body_color(parent_handle1, color);
graphics.set_body_color(parent_handle1, color, false);
}
if parent_handle2 != ground_handle && parent_handle2 != sensor_handle {
graphics.set_body_color(parent_handle2, color);
graphics.set_body_color(parent_handle2, color, false);
}
}
}
@@ -147,5 +150,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);
}