Skip to content

Commit

Permalink
disable PVD connection by default
Browse files Browse the repository at this point in the history
  • Loading branch information
rlidwka committed Aug 5, 2023
1 parent 635ace8 commit a152cb9
Show file tree
Hide file tree
Showing 13 changed files with 76 additions and 32 deletions.
14 changes: 8 additions & 6 deletions examples/articulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion examples/cube_stacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
24 changes: 13 additions & 11 deletions examples/detect_contacts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, (
Expand Down
4 changes: 3 additions & 1 deletion examples/getting_started.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
4 changes: 3 additions & 1 deletion examples/kinematic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion examples/raycast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion examples/test_articulation_drives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion examples/test_convex_shapes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion examples/test_damping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 5 additions & 4 deletions examples/test_fixed_timestep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion examples/test_mass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion examples/test_restitution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
25 changes: 23 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
}
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit a152cb9

Please sign in to comment.