Skip to content

Commit

Permalink
decompose rabbit + add warning against running in debug
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrixyz committed Dec 2, 2024
1 parent 5e1b244 commit e425dca
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions crates/parry3d/examples/convex_decomposition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
Expand All @@ -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()
});

Expand All @@ -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),
Expand All @@ -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
}
}

0 comments on commit e425dca

Please sign in to comment.