add "collider mesh" command, generating the collider from the scene
This commit is contained in:
parent
7b04a41177
commit
ac3b17badf
|
@ -12,7 +12,7 @@ rust-version = "1.76.0"
|
|||
[dependencies]
|
||||
regex = "1"
|
||||
bevy = { version = "0.13.1", default-features = false, features = ["jpeg", "bevy_asset", "bevy_audio", "bevy_scene", "bevy_winit", "bevy_core_pipeline", "bevy_pbr", "bevy_gltf", "bevy_render", "bevy_text", "bevy_ui", "multi-threaded", "png", "vorbis", "x11", "tonemapping_luts"]}
|
||||
bevy_xpbd_3d = { version = "0.4", default-features = false, features = ["3d", "f32", "parry-f32", "parallel"] }
|
||||
bevy_xpbd_3d = { version = "0.4", default-features = false, features = ["3d", "f32", "parry-f32", "parallel", "async-collider"] }
|
||||
bevy_embedded_assets = "0.10.2"
|
||||
|
||||
[features]
|
||||
|
|
|
@ -5,7 +5,7 @@ actor 0 0 0 suit
|
|||
oxygen 0.008
|
||||
health 0.3
|
||||
angularmomentum 0 0 0
|
||||
collider capsule 2 1
|
||||
collider mesh
|
||||
thrust 1.2 1 1 1 1.5
|
||||
rotationy 0.65
|
||||
engine monopropellant
|
||||
|
@ -50,18 +50,21 @@ actor 3000 0 0 moonlet
|
|||
actor 1000 20 300 monolith
|
||||
scale 2
|
||||
mass 1000
|
||||
collider mesh
|
||||
rotationx 0.5
|
||||
angularmomentum 0.0 0.0 0.01
|
||||
|
||||
actor 10000 2000 -3500 monolith
|
||||
scale 2
|
||||
mass 1000
|
||||
collider mesh
|
||||
rotationx 0.5
|
||||
angularmomentum 0.0 0.0 0.01
|
||||
|
||||
actor -8000 -1000 -100 monolith
|
||||
scale 2
|
||||
mass 1000
|
||||
collider mesh
|
||||
rotationx 0.5
|
||||
angularmomentum 0.0 0.0 0.01
|
||||
|
||||
|
@ -143,6 +146,7 @@ actor 10 0 70 suit
|
|||
chatid hi_icarus
|
||||
alive yes
|
||||
mass 200.0
|
||||
collider capsule 2 1
|
||||
pronoun it
|
||||
chat hi_icarus
|
||||
name Icarus
|
||||
|
@ -184,6 +188,7 @@ actor -300 0 40 suit
|
|||
chatid drifter
|
||||
oxygen 0.08
|
||||
mass 200.0
|
||||
collider capsule 2 1
|
||||
chat drifter
|
||||
name "Drifter"
|
||||
msg 5 INIT noresponse "Requesting permission to communicate..."
|
||||
|
|
15
src/world.rs
15
src/world.rs
|
@ -216,6 +216,7 @@ struct ParserState {
|
|||
is_suited: bool,
|
||||
is_vehicle: bool,
|
||||
has_physics: bool,
|
||||
collider_is_mesh: bool,
|
||||
thrust_forward: f32,
|
||||
thrust_sideways: f32,
|
||||
thrust_back: f32,
|
||||
|
@ -263,6 +264,7 @@ impl Default for ParserState {
|
|||
is_suited: false,
|
||||
is_vehicle: false,
|
||||
has_physics: true,
|
||||
collider_is_mesh: false,
|
||||
thrust_forward: default_engine.thrust_forward,
|
||||
thrust_sideways: default_engine.thrust_forward,
|
||||
thrust_back: default_engine.thrust_back,
|
||||
|
@ -511,6 +513,9 @@ pub fn load_defs(
|
|||
continue;
|
||||
}
|
||||
}
|
||||
["collider", "mesh"] => {
|
||||
state.collider_is_mesh = true;
|
||||
}
|
||||
["player", "yes"] => {
|
||||
state.is_player = true;
|
||||
state.is_alive = true;
|
||||
|
@ -683,8 +688,16 @@ fn spawn_entities(
|
|||
let fix_scale = 1.0 / state.model_scale.powf(3.0);
|
||||
actor.insert(RigidBody::Dynamic);
|
||||
actor.insert(AngularVelocity(state.angular_momentum));
|
||||
actor.insert(state.collider.clone());
|
||||
actor.insert(ColliderDensity(state.mass * fix_scale));
|
||||
if state.collider_is_mesh {
|
||||
actor.insert(AsyncSceneCollider::new(Some(
|
||||
ComputedCollider::TriMesh
|
||||
//ComputedCollider::ConvexDecomposition(VHACDParameters::default())
|
||||
)));
|
||||
}
|
||||
else {
|
||||
actor.insert(state.collider.clone());
|
||||
}
|
||||
}
|
||||
// TODO: angular velocity for objects without collisions, static objects
|
||||
|
||||
|
|
Loading…
Reference in a new issue