From 9f85b0358fdd12a7eb1e483829bfb085d6970a2f Mon Sep 17 00:00:00 2001 From: Adam <46227443+Adamkob12@users.noreply.github.com> Date: Wed, 15 Nov 2023 14:24:14 -0800 Subject: [PATCH] Added variant TriMeshWithFlags to ComputedCollider (#251) fixes #248 adds a variant `ComputedCollider::TriMeshWithFlags` that allows for generation of Colliders with flags using AsyncCollider. --- src/components/collider.rs | 4 +++- src/plugins/prepare.rs | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/components/collider.rs b/src/components/collider.rs index 0f94b2bd..18cf7076 100644 --- a/src/components/collider.rs +++ b/src/components/collider.rs @@ -892,7 +892,7 @@ pub struct AsyncCollider(pub ComputedCollider); /// // Generate colliders for everything except specific meshes by name /// commands.spawn(( /// scene, -/// AsyncSceneCollider::new(ComputedCollider::TriMesh) +/// AsyncSceneCollider::new(ComputedCollider::TriMeshWithFlags(TriMeshFlags::MERGE_DUPLICATE_VERTICES)) /// .without_shape_for_name("Tree"), /// )); /// } @@ -1016,6 +1016,8 @@ pub enum ComputedCollider { /// A triangle mesh. #[default] TriMesh, + /// A triangle mesh with a custom configuration. + TriMeshWithFlags(TriMeshFlags), /// A convex hull. ConvexHull, /// A compound shape obtained from a decomposition into convex parts using the specified diff --git a/src/plugins/prepare.rs b/src/plugins/prepare.rs index ccfada19..4b00c841 100644 --- a/src/plugins/prepare.rs +++ b/src/plugins/prepare.rs @@ -419,6 +419,9 @@ pub fn init_async_colliders( if let Some(mesh) = meshes.get(mesh_handle) { let collider = match &async_collider.0 { ComputedCollider::TriMesh => Collider::trimesh_from_mesh(mesh), + ComputedCollider::TriMeshWithFlags(flags) => { + Collider::trimesh_from_mesh_with_config(mesh, *flags) + } ComputedCollider::ConvexHull => Collider::convex_hull_from_mesh(mesh), ComputedCollider::ConvexDecomposition(params) => { Collider::convex_decomposition_from_mesh_with_config(mesh, params) @@ -468,6 +471,9 @@ pub fn init_async_scene_colliders( let collider = match collider_data.shape { ComputedCollider::TriMesh => Collider::trimesh_from_mesh(mesh), + ComputedCollider::TriMeshWithFlags(flags) => { + Collider::trimesh_from_mesh_with_config(mesh, flags) + } ComputedCollider::ConvexHull => Collider::convex_hull_from_mesh(mesh), ComputedCollider::ConvexDecomposition(params) => { Collider::convex_decomposition_from_mesh_with_config(mesh, ¶ms)