diff --git a/examples/articulation.rs b/examples/articulation.rs index 0bc38df..cf1279a 100644 --- a/examples/articulation.rs +++ b/examples/articulation.rs @@ -8,13 +8,15 @@ use physx_sys::PxSolverType; fn main() { App::new() .add_plugins(DefaultPlugins) - .add_plugins(PhysicsPlugins.set(PhysicsCore { - scene: bpx::SceneDescriptor { - solver_type: PxSolverType::Tgs, + .add_plugins(PhysicsPlugins.set( + PhysicsCore { + scene: bpx::SceneDescriptor { + solver_type: PxSolverType::Tgs, + ..default() + }, ..default() - }, - ..default() - })) + }.with_pvd() + )) .add_plugins(common::DemoUtils) // optional .add_systems(Startup, ( spawn_long_chain, diff --git a/examples/cube_stacks.rs b/examples/cube_stacks.rs index 9a2f0fa..c545438 100644 --- a/examples/cube_stacks.rs +++ b/examples/cube_stacks.rs @@ -6,7 +6,9 @@ use bevy_mod_physx::prelude::{self as bpx, *}; fn main() { App::new() .add_plugins(DefaultPlugins) - .add_plugins(PhysicsPlugins) + .add_plugins(PhysicsPlugins.set( + PhysicsCore::new().with_pvd() + )) .add_plugins(common::DemoUtils) // optional .add_systems(Startup, ( spawn_plane, diff --git a/examples/detect_contacts.rs b/examples/detect_contacts.rs index 64852a1..c9b9273 100644 --- a/examples/detect_contacts.rs +++ b/examples/detect_contacts.rs @@ -101,18 +101,20 @@ fn main() { App::new() .add_plugins(DefaultPlugins) - .add_plugins(PhysicsPlugins.set(PhysicsCore { - scene: bpx::SceneDescriptor { - // simulation filter shader will filter details that we get in on_collision callback, - // by default on_collision callback doesn't do anything - simulation_filter_shader: FilterShaderDescriptor::CallDefaultFirst(simulation_filter_shader), - - // callback is a closure, where we pass Sender to - on_collision: Some(on_collision), + .add_plugins(PhysicsPlugins.set( + PhysicsCore { + scene: bpx::SceneDescriptor { + // simulation filter shader will filter details that we get in on_collision callback, + // by default on_collision callback doesn't do anything + simulation_filter_shader: FilterShaderDescriptor::CallDefaultFirst(simulation_filter_shader), + + // callback is a closure, where we pass Sender to + on_collision: Some(on_collision), + ..default() + }, ..default() - }, - ..default() - })) + }.with_pvd() + )) .add_plugins(common::DemoUtils) // optional .add_physics_event_channel(mpsc_receiver) .add_systems(Startup, ( diff --git a/examples/getting_started.rs b/examples/getting_started.rs index 6444515..96ccdc1 100644 --- a/examples/getting_started.rs +++ b/examples/getting_started.rs @@ -6,7 +6,9 @@ use bevy_mod_physx::prelude::{Material, Shape}; // bevy prelude conflicts fn main() { App::new() .add_plugins(DefaultPlugins) - .add_plugins(PhysicsPlugins) + .add_plugins(PhysicsPlugins.set( + PhysicsCore::new().with_pvd() + )) .add_systems(Startup, setup_graphics) .add_systems(Startup, setup_physics) .insert_resource(DebugRenderSettings::enable()) diff --git a/examples/kinematic.rs b/examples/kinematic.rs index 77e5182..c47a055 100644 --- a/examples/kinematic.rs +++ b/examples/kinematic.rs @@ -22,7 +22,9 @@ const CUE_SIZE: f32 = 0.5; fn main() { App::new() .add_plugins(DefaultPlugins) - .add_plugins(PhysicsPlugins) + .add_plugins(PhysicsPlugins.set( + PhysicsCore::new().with_pvd() + )) .add_plugins(common::DemoUtils) // optional .add_systems(Startup, ( spawn_table, diff --git a/examples/raycast.rs b/examples/raycast.rs index 2b82a39..f2b9e1b 100644 --- a/examples/raycast.rs +++ b/examples/raycast.rs @@ -21,7 +21,9 @@ fn main() { // ported from ray_casting3 example from bevy_rapier3d App::new() .add_plugins(DefaultPlugins) - .add_plugins(PhysicsPlugins) + .add_plugins(PhysicsPlugins.set( + PhysicsCore::new().with_pvd() + )) .add_plugins(common::DemoUtils) // optional .add_systems(Startup, ( init_materials, diff --git a/examples/test_articulation_drives.rs b/examples/test_articulation_drives.rs index b679f88..e0117b2 100644 --- a/examples/test_articulation_drives.rs +++ b/examples/test_articulation_drives.rs @@ -9,7 +9,9 @@ fn main() { // ported from https://github.com/MasterOfMarkets/bevy_mod_physx App::new() .add_plugins(DefaultPlugins) - .add_plugins(PhysicsPlugins) + .add_plugins(PhysicsPlugins.set( + PhysicsCore::new().with_pvd() + )) .add_plugins(common::DemoUtils) // optional .add_systems(Startup, ( spawn_scene, diff --git a/examples/test_convex_shapes.rs b/examples/test_convex_shapes.rs index 4970d9e..65cd29d 100644 --- a/examples/test_convex_shapes.rs +++ b/examples/test_convex_shapes.rs @@ -10,7 +10,9 @@ use bevy_mod_physx::prelude::{self as bpx, *}; fn main() { App::new() .add_plugins(DefaultPlugins) - .add_plugins(PhysicsPlugins) + .add_plugins(PhysicsPlugins.set( + PhysicsCore::new().with_pvd() + )) .add_plugins(common::DemoUtils) // optional .add_systems(Startup, ( spawn_scene, diff --git a/examples/test_damping.rs b/examples/test_damping.rs index 3bab06b..f01da3d 100644 --- a/examples/test_damping.rs +++ b/examples/test_damping.rs @@ -7,7 +7,9 @@ fn main() { // ported from https://github.com/MasterOfMarkets/bevy_mod_physx App::new() .add_plugins(DefaultPlugins) - .add_plugins(PhysicsPlugins) + .add_plugins(PhysicsPlugins.set( + PhysicsCore::new().with_pvd() + )) .add_plugins(common::DemoUtils) // optional .add_systems(Startup, ( spawn_scene, diff --git a/examples/test_fixed_timestep.rs b/examples/test_fixed_timestep.rs index 0b70fa3..33259b1 100644 --- a/examples/test_fixed_timestep.rs +++ b/examples/test_fixed_timestep.rs @@ -9,10 +9,11 @@ fn main() { App::new() .insert_resource(FixedTime::new_from_secs(0.05)) .add_plugins(DefaultPlugins) - .add_plugins(PhysicsPlugins.set(PhysicsCore { - timestep: TimestepMode::Custom, - ..default() - })) + .add_plugins(PhysicsPlugins.set( + PhysicsCore::new() + .with_timestep(TimestepMode::Custom) + .with_pvd() + )) .add_plugins(common::DemoUtils) // optional .add_systems(Startup, ( spawn_scene, diff --git a/examples/test_mass.rs b/examples/test_mass.rs index df9818c..9a99731 100644 --- a/examples/test_mass.rs +++ b/examples/test_mass.rs @@ -7,7 +7,9 @@ fn main() { // ported from https://github.com/MasterOfMarkets/bevy_mod_physx App::new() .add_plugins(DefaultPlugins) - .add_plugins(PhysicsPlugins) + .add_plugins(PhysicsPlugins.set( + PhysicsCore::new().with_pvd() + )) .add_plugins(common::DemoUtils) // optional .add_systems(Startup, ( spawn_scene, diff --git a/examples/test_restitution.rs b/examples/test_restitution.rs index 38b1f11..0a34e1d 100644 --- a/examples/test_restitution.rs +++ b/examples/test_restitution.rs @@ -7,7 +7,9 @@ fn main() { // ported from https://github.com/MasterOfMarkets/bevy_mod_physx App::new() .add_plugins(DefaultPlugins) - .add_plugins(PhysicsPlugins) + .add_plugins(PhysicsPlugins.set( + PhysicsCore::new().with_pvd() + )) .add_plugins(common::DemoUtils) // optional .add_systems(Startup, ( spawn_scene, diff --git a/src/lib.rs b/src/lib.rs index 69264bd..d56f772 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -77,7 +77,7 @@ pub struct FoundationDescriptor { pub tolerances: PxTolerancesScale, /// Enable visual debugger (PVD). /// - /// Default: true + /// Default: false pub visual_debugger: bool, /// IP port used for PVD, should same as the port setting /// in PVD application. @@ -95,7 +95,7 @@ impl Default for FoundationDescriptor { Self { extensions: true, tolerances: PxTolerancesScale { length: 1., speed: 10. }, - visual_debugger: true, + visual_debugger: false, visual_debugger_port: 5425, visual_debugger_host: None, } @@ -513,6 +513,27 @@ pub struct PhysicsCore { pub sync_first: bool, } +impl PhysicsCore { + pub fn new() -> Self { + Self::default() + } + + pub fn with_timestep(mut self, timestep: TimestepMode) -> Self { + self.timestep = timestep; + self + } + + pub fn with_gravity(mut self, gravity: Vec3) -> Self { + self.scene.gravity = gravity; + self + } + + pub fn with_pvd(mut self) -> Self { + self.foundation.visual_debugger = true; + self + } +} + impl Default for PhysicsCore { fn default() -> Self { Self {