From e425dca65849cb85feb4febdc844c89e14387635 Mon Sep 17 00:00:00 2001 From: Thierry Berger Date: Mon, 2 Dec 2024 11:41:20 +0100 Subject: [PATCH] decompose rabbit + add warning against running in debug --- .../parry3d/examples/convex_decomposition.rs | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/crates/parry3d/examples/convex_decomposition.rs b/crates/parry3d/examples/convex_decomposition.rs index b536865d..0da8202a 100644 --- a/crates/parry3d/examples/convex_decomposition.rs +++ b/crates/parry3d/examples/convex_decomposition.rs @@ -21,7 +21,7 @@ async fn main() { position, objects, .. }, .. - } = Obj::load("assets/tests/stairs.obj").unwrap(); + } = Obj::load("assets/tests/low_poly_bunny.obj").unwrap(); let bunny_mesh = TriMesh::with_flags( position @@ -39,6 +39,16 @@ async fn main() { clear_background(BLACK); easy_draw_text("Please wait while convex decomposition is being computed..."); + #[cfg(debug_assertions)] + { + macroquad::text::draw_text( + "Running in debug mode is way slower than with `--release`.", + 10.0, + 48.0 + 48.0, + 30.0, + RED, + ); + } next_frame().await; let mesh_vertices = bunny_mesh.vertices(); let mesh_indices = bunny_mesh.indices(); @@ -49,15 +59,15 @@ async fn main() { clear_background(BLACK); let elapsed_time = get_time() as f32; let camera_pos = Vec3::new( - 19f32 * elapsed_time.sin(), - 12f32, - 19f32 * elapsed_time.cos(), + 5.5f32 * elapsed_time.sin(), + 3f32, + 5.5f32 * elapsed_time.cos(), ); // Initialize 3D camera. set_camera(&Camera3D { position: camera_pos, up: Vec3::new(0f32, 1f32, 0f32), - target: Vec3::new(0f32, 4.5f32, 0f32), + target: Vec3::new(0f32, 1f32, 0f32), ..Default::default() }); @@ -68,7 +78,7 @@ async fn main() { /* * Display the shapes. */ - let (r, g, b) = hue_to_rgb(i as f32 / shapes_count as f32); + let (r, g, b) = hue_to_rgb(i as f32 / 6 as f32); let mesh = mquad_mesh_from_points( &trimesh_convex, Vec3::new(1f32, 3f32, 3f32), @@ -81,6 +91,8 @@ async fn main() { ); draw_mesh(&mesh); } + set_default_camera(); + easy_draw_text(&format!("Number of shapes: {}", shapes_count)); next_frame().await } }