From 2402fe7b0360f74e361bde105d01a0f0821c4197 Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 16 Apr 2024 04:10:43 +0200 Subject: [PATCH] add "mesh handcrafted" command --- src/commands.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index fc9c168..f305d66 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -53,6 +53,7 @@ struct ParserState { wants_maxrotation: Option, wants_maxvelocity: Option, collider_is_mesh: bool, + collider_is_one_mesh_of_scene: bool, thrust_forward: f32, thrust_sideways: f32, thrust_back: f32, @@ -96,6 +97,7 @@ impl Default for ParserState { wants_maxrotation: None, wants_maxvelocity: None, collider_is_mesh: false, + collider_is_one_mesh_of_scene: false, thrust_forward: default_engine.thrust_forward, thrust_sideways: default_engine.thrust_forward, thrust_back: default_engine.thrust_back, @@ -362,6 +364,9 @@ pub fn load_defs( ["collider", "mesh"] => { state.collider_is_mesh = true; } + ["collider", "handcrafted"] => { + state.collider_is_one_mesh_of_scene = true; + } ["player", "yes"] => { state.is_player = true; state.is_alive = true; @@ -482,17 +487,21 @@ fn spawn_entities( actor.insert(AngularVelocity(state.angular_momentum)); actor.insert(ColliderDensity(state.density)); if state.collider_is_mesh { + actor.insert(MassPropertiesBundle::new_computed( + &Collider::sphere(0.5 * state.model_scale as f64), state.density)); + actor.insert(AsyncSceneCollider::new(Some( + ComputedCollider::TriMesh + //ComputedCollider::ConvexDecomposition(VHACDParameters::default()) + ))); + } + else if state.collider_is_one_mesh_of_scene { + actor.insert(MassPropertiesBundle::new_computed( + &Collider::sphere(0.5 * state.model_scale as f64), state.density)); actor.insert(AsyncSceneCollider::new(None) .with_shape_for_name("Collider", ComputedCollider::TriMesh) .with_layers_for_name("Collider", CollisionLayers::ALL) //.with_density_for_name("Collider", state.density) ); - actor.insert(MassPropertiesBundle::new_computed( - &Collider::sphere(0.5 * state.model_scale as f64), state.density)); - //actor.insert(AsyncSceneCollider::new(Some( - //ComputedCollider::TriMesh - //ComputedCollider::ConvexDecomposition(VHACDParameters::default()) - //))); } else { actor.insert(state.collider.clone());