Joint API and joint motors improvements
This commit is contained in:
committed by
Sébastien Crozet
parent
e740493b98
commit
fb20d72ee2
@@ -16,32 +16,58 @@ pub mod plugin;
|
||||
pub struct RunState {
|
||||
#[cfg(feature = "parallel")]
|
||||
pub thread_pool: rapier::rayon::ThreadPool,
|
||||
pub num_threads: usize,
|
||||
#[cfg(feature = "parallel")]
|
||||
num_threads: usize,
|
||||
pub timestep_id: usize,
|
||||
pub time: f32,
|
||||
}
|
||||
|
||||
impl RunState {
|
||||
#[cfg(feature = "parallel")]
|
||||
pub fn new() -> Self {
|
||||
#[cfg(feature = "parallel")]
|
||||
let num_threads = num_cpus::get_physical();
|
||||
#[cfg(not(feature = "parallel"))]
|
||||
let num_threads = 1;
|
||||
|
||||
#[cfg(feature = "parallel")]
|
||||
let thread_pool = rapier::rayon::ThreadPoolBuilder::new()
|
||||
.num_threads(num_threads)
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
Self {
|
||||
#[cfg(feature = "parallel")]
|
||||
thread_pool: thread_pool,
|
||||
num_threads,
|
||||
timestep_id: 0,
|
||||
time: 0.0,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "parallel"))]
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
timestep_id: 0,
|
||||
time: 0.0,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "parallel")]
|
||||
pub fn num_threads(&self) -> usize {
|
||||
self.num_threads
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "parallel"))]
|
||||
pub fn num_threads(&self) -> usize {
|
||||
1
|
||||
}
|
||||
|
||||
#[cfg(feature = "parallel")]
|
||||
pub fn set_num_threads(&mut self, num_threads: usize) {
|
||||
if self.num_threads != num_threads {
|
||||
self.thread_pool = rapier::rayon::ThreadPoolBuilder::new()
|
||||
.num_threads(num_threads)
|
||||
.build()
|
||||
.unwrap();
|
||||
self.num_threads = num_threads;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Harness {
|
||||
|
||||
@@ -535,7 +535,7 @@ impl<'a, 'b, 'c, 'd, 'e, 'f> Testbed<'a, 'b, 'c, 'd, 'e, 'f> {
|
||||
&self.harness.physics.impulse_joints,
|
||||
&self.harness.physics.multibody_joints,
|
||||
self.state.selected_backend == PHYSX_BACKEND_TWO_FRICTION_DIR,
|
||||
self.harness.state.num_threads,
|
||||
self.harness.state.num_threads(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,32 +101,32 @@ pub fn update_ui(ui_context: &EguiContext, state: &mut TestbedState, harness: &m
|
||||
|| state.selected_backend == PHYSX_BACKEND_TWO_FRICTION_DIR
|
||||
{
|
||||
ui.add(
|
||||
Slider::new(&mut integration_parameters.max_velocity_iterations, 0..=200)
|
||||
Slider::new(&mut integration_parameters.max_velocity_iterations, 1..=200)
|
||||
.text("pos. iters."),
|
||||
);
|
||||
ui.add(
|
||||
Slider::new(
|
||||
&mut integration_parameters.max_stabilization_iterations,
|
||||
0..=200,
|
||||
1..=200,
|
||||
)
|
||||
.text("vel. iters."),
|
||||
);
|
||||
} else {
|
||||
ui.add(
|
||||
Slider::new(&mut integration_parameters.max_velocity_iterations, 0..=200)
|
||||
Slider::new(&mut integration_parameters.max_velocity_iterations, 1..=200)
|
||||
.text("vel. rest. iters."),
|
||||
);
|
||||
ui.add(
|
||||
Slider::new(
|
||||
&mut integration_parameters.max_velocity_friction_iterations,
|
||||
0..=200,
|
||||
1..=200,
|
||||
)
|
||||
.text("vel. frict. iters."),
|
||||
);
|
||||
ui.add(
|
||||
Slider::new(
|
||||
&mut integration_parameters.max_stabilization_iterations,
|
||||
0..=200,
|
||||
1..=200,
|
||||
)
|
||||
.text("vel. stab. iters."),
|
||||
);
|
||||
@@ -134,10 +134,11 @@ pub fn update_ui(ui_context: &EguiContext, state: &mut TestbedState, harness: &m
|
||||
|
||||
#[cfg(feature = "parallel")]
|
||||
{
|
||||
let mut num_threads = harness.state.num_threads();
|
||||
ui.add(
|
||||
Slider::new(&mut harness.state.num_threads, 1..=num_cpus::get_physical())
|
||||
.text("num. threads"),
|
||||
Slider::new(&mut num_threads, 1..=num_cpus::get_physical()).text("num. threads"),
|
||||
);
|
||||
harness.state.set_num_threads(num_threads);
|
||||
}
|
||||
ui.add(
|
||||
Slider::new(&mut integration_parameters.max_ccd_substeps, 0..=10).text("CCD substeps"),
|
||||
|
||||
Reference in New Issue
Block a user