Replace Kiss3d by Bevy for the testbed renderer.
This commit is contained in:
@@ -10,7 +10,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
let rad = 0.5;
|
||||
|
||||
// Callback that will be executed on the main loop to handle proximities.
|
||||
testbed.add_callback(move |mut window, mut graphics, physics, _, _| {
|
||||
testbed.add_callback(move |mut graphics, physics, _, _| {
|
||||
let rigid_body = RigidBodyBuilder::new_dynamic()
|
||||
.translation(0.0, 10.0)
|
||||
.build();
|
||||
@@ -20,8 +20,8 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
.colliders
|
||||
.insert(collider, handle, &mut physics.bodies);
|
||||
|
||||
if let (Some(graphics), Some(window)) = (&mut graphics, &mut window) {
|
||||
graphics.add(*window, handle, &physics.bodies, &physics.colliders);
|
||||
if let Some(graphics) = &mut graphics {
|
||||
graphics.add_body(handle, &physics.bodies, &physics.colliders);
|
||||
}
|
||||
|
||||
let to_remove: Vec<_> = physics
|
||||
@@ -38,8 +38,8 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
&mut physics.joints,
|
||||
);
|
||||
|
||||
if let (Some(graphics), Some(window)) = (&mut graphics, &mut window) {
|
||||
graphics.remove_body_nodes(*window, handle);
|
||||
if let Some(graphics) = &mut graphics {
|
||||
graphics.remove_body(handle);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -50,8 +50,3 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.look_at(Point2::new(0.0, 0.0), 20.0);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let testbed = Testbed::from_builders(0, vec![("Add-remove", init_world)]);
|
||||
testbed.run()
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ use wasm_bindgen::prelude::*;
|
||||
|
||||
use inflector::Inflector;
|
||||
|
||||
use rapier_testbed2d::Testbed;
|
||||
use rapier_testbed2d::{Testbed, TestbedApp};
|
||||
use std::cmp::Ordering;
|
||||
|
||||
mod add_remove2;
|
||||
@@ -89,7 +89,7 @@ pub fn main() {
|
||||
.iter()
|
||||
.position(|builder| builder.0.to_camel_case().as_str() == demo.as_str())
|
||||
.unwrap_or(0);
|
||||
let testbed = Testbed::from_builders(i, builders);
|
||||
let testbed = TestbedApp::from_builders(i, builders);
|
||||
|
||||
testbed.run()
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
}
|
||||
|
||||
// Callback that will be executed on the main loop to handle proximities.
|
||||
testbed.add_callback(move |_, mut graphics, physics, events, _| {
|
||||
testbed.add_callback(move |mut graphics, physics, events, _| {
|
||||
while let Ok(prox) = events.intersection_events.try_recv() {
|
||||
let color = if prox.intersecting {
|
||||
Point3::new(1.0, 1.0, 0.0)
|
||||
@@ -117,8 +117,3 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.look_at(Point2::new(0.0, 2.5), 20.0);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let testbed = Testbed::from_builders(0, vec![("Balls", init_world)]);
|
||||
testbed.run()
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
.build();
|
||||
let green_collider_handle = colliders.insert(green_floor, floor_handle, &mut bodies);
|
||||
|
||||
testbed.set_collider_initial_color(green_collider_handle, Point3::new(0.0, 1.0, 0.0));
|
||||
testbed.set_initial_collider_color(green_collider_handle, Point3::new(0.0, 1.0, 0.0));
|
||||
|
||||
/*
|
||||
* A blue floor that will collide with the BLUE group only.
|
||||
@@ -50,7 +50,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
.build();
|
||||
let blue_collider_handle = colliders.insert(blue_floor, floor_handle, &mut bodies);
|
||||
|
||||
testbed.set_collider_initial_color(blue_collider_handle, Point3::new(0.0, 0.0, 1.0));
|
||||
testbed.set_initial_collider_color(blue_collider_handle, Point3::new(0.0, 0.0, 1.0));
|
||||
|
||||
/*
|
||||
* Create the cubes
|
||||
@@ -81,7 +81,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
.build();
|
||||
colliders.insert(collider, handle, &mut bodies);
|
||||
|
||||
testbed.set_body_color(handle, color);
|
||||
testbed.set_initial_body_color(handle, color);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,8 +91,3 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.look_at(Point2::new(0.0, 1.0), 100.0);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let testbed = Testbed::from_builders(0, vec![("Boxes", init_world)]);
|
||||
testbed.run()
|
||||
}
|
||||
|
||||
@@ -79,8 +79,3 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.look_at(Point2::new(0.0, 50.0), 10.0);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let testbed = Testbed::from_builders(0, vec![("Balls", init_world)]);
|
||||
testbed.run()
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use na::Point2;
|
||||
use rapier2d::dynamics::{JointSet, RigidBodyBuilder, RigidBodySet};
|
||||
use rapier2d::geometry::{ColliderBuilder, ColliderSet};
|
||||
use rapier_testbed2d::Testbed;
|
||||
@@ -35,10 +36,5 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
* Set up the testbed.
|
||||
*/
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
// testbed.look_at(Point2::new(10.0, 10.0, 10.0), Point2::origin());
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let testbed = Testbed::from_builders(0, vec![("Boxes", init_world)]);
|
||||
testbed.run()
|
||||
testbed.look_at(Point2::new(0.0, 0.0), 50.0);
|
||||
}
|
||||
|
||||
@@ -65,8 +65,3 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.look_at(Point2::new(0.0, 0.0), 10.0);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let testbed = Testbed::from_builders(0, vec![("Heightfield", init_world)]);
|
||||
testbed.run()
|
||||
}
|
||||
|
||||
@@ -68,8 +68,3 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.look_at(Point2::new(numk as f32 * rad, numi as f32 * -rad), 20.0);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let testbed = Testbed::from_builders(0, vec![("Joints", init_world)]);
|
||||
testbed.run()
|
||||
}
|
||||
|
||||
@@ -56,8 +56,3 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.look_at(Point2::new(0.0, 0.0), 40.0);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let testbed = Testbed::from_builders(0, vec![("Boxes", init_world)]);
|
||||
testbed.run()
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
* Spawn cubes at regular intervals and apply a custom gravity
|
||||
* depending on their position.
|
||||
*/
|
||||
testbed.add_callback(move |mut window, mut graphics, physics, _, run_state| {
|
||||
testbed.add_callback(move |graphics, physics, _, run_state| {
|
||||
if run_state.timestep_id % 50 == 0 && physics.bodies.len() <= 7 {
|
||||
// Spawn a new cube.
|
||||
let collider = ColliderBuilder::cuboid(1.5, 2.0).build();
|
||||
@@ -112,8 +112,8 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
.colliders
|
||||
.insert(collider, handle, &mut physics.bodies);
|
||||
|
||||
if let (Some(graphics), Some(window)) = (&mut graphics, &mut window) {
|
||||
graphics.add(window, handle, &physics.bodies, &physics.colliders);
|
||||
if let Some(graphics) = graphics {
|
||||
graphics.add_body(handle, &physics.bodies, &physics.colliders);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,8 +139,3 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
);
|
||||
testbed.look_at(Point2::new(0.0, 0.0), 20.0);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let testbed = Testbed::from_builders(0, vec![("Boxes", init_world)]);
|
||||
testbed.run()
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
/*
|
||||
* Setup a callback to control the platform.
|
||||
*/
|
||||
testbed.add_callback(move |_, _, physics, _, run_state| {
|
||||
testbed.add_callback(move |_, physics, _, run_state| {
|
||||
let platform = physics.bodies.get_mut(platform_handle).unwrap();
|
||||
let mut next_pos = *platform.position();
|
||||
|
||||
@@ -84,8 +84,3 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.look_at(Point2::new(0.0, 1.0), 40.0);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let testbed = Testbed::from_builders(0, vec![("Kinematic body", init_world)]);
|
||||
testbed.run()
|
||||
}
|
||||
|
||||
@@ -67,8 +67,3 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.look_at(Point2::new(0.0, 0.0), 10.0);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let testbed = Testbed::from_builders(0, vec![("Heightfield", init_world)]);
|
||||
testbed.run()
|
||||
}
|
||||
|
||||
@@ -53,8 +53,3 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.look_at(Point2::new(0.0, 2.5), 20.0);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let testbed = Testbed::from_builders(0, vec![("Balls", init_world)]);
|
||||
testbed.run()
|
||||
}
|
||||
|
||||
@@ -49,8 +49,3 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.look_at(Point2::new(0.0, 1.0), 25.0);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let testbed = Testbed::from_builders(0, vec![("Boxes", init_world)]);
|
||||
testbed.run()
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
let collider = ColliderBuilder::cuboid(rad, rad).build();
|
||||
colliders.insert(collider, handle, &mut bodies);
|
||||
|
||||
testbed.set_body_color(handle, Point3::new(0.5, 0.5, 1.0));
|
||||
testbed.set_initial_body_color(handle, Point3::new(0.5, 0.5, 1.0));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -66,10 +66,10 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
let sensor_collider = ColliderBuilder::ball(rad * 5.0).sensor(true).build();
|
||||
colliders.insert(sensor_collider, sensor_handle, &mut bodies);
|
||||
|
||||
testbed.set_body_color(sensor_handle, Point3::new(0.5, 1.0, 1.0));
|
||||
testbed.set_initial_body_color(sensor_handle, Point3::new(0.5, 1.0, 1.0));
|
||||
|
||||
// Callback that will be executed on the main loop to handle proximities.
|
||||
testbed.add_callback(move |_, mut graphics, physics, events, _| {
|
||||
testbed.add_callback(move |mut graphics, physics, events, _| {
|
||||
while let Ok(prox) = events.intersection_events.try_recv() {
|
||||
let color = if prox.intersecting {
|
||||
Point3::new(1.0, 1.0, 0.0)
|
||||
@@ -96,8 +96,3 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
testbed.set_world(bodies, colliders, joints);
|
||||
testbed.look_at(Point2::new(0.0, 1.0), 100.0);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let testbed = Testbed::from_builders(0, vec![("Sensor", init_world)]);
|
||||
testbed.run()
|
||||
}
|
||||
|
||||
@@ -109,11 +109,6 @@ pub fn init_world(testbed: &mut Testbed) {
|
||||
testbed.look_at(Point2::new(0.0, 20.0), 17.0);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let testbed = Testbed::from_builders(0, vec![("Balls", init_world)]);
|
||||
testbed.run()
|
||||
}
|
||||
|
||||
const RAPIER_SVG_STR: &'static str = r#"
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg width="100%" height="100%" viewBox="0 0 527 131" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;">
|
||||
|
||||
Reference in New Issue
Block a user