rework some threading code with the ui
This commit is contained in:
@@ -10,6 +10,8 @@ pub mod plugin;
|
||||
pub struct RunState {
|
||||
#[cfg(feature = "parallel")]
|
||||
pub thread_pool: rapier::rayon::ThreadPool,
|
||||
#[cfg(feature = "parallel")]
|
||||
pub num_threads: usize,
|
||||
pub timestep_id: usize,
|
||||
pub time: f32,
|
||||
}
|
||||
@@ -28,6 +30,8 @@ impl RunState {
|
||||
Self {
|
||||
#[cfg(feature = "parallel")]
|
||||
thread_pool: thread_pool,
|
||||
#[cfg(feature = "parallel")]
|
||||
num_threads,
|
||||
timestep_id: 0,
|
||||
time: 0.0,
|
||||
}
|
||||
|
||||
@@ -115,7 +115,6 @@ pub struct TestbedState {
|
||||
pub selected_example: usize,
|
||||
pub selected_backend: usize,
|
||||
pub physx_use_two_friction_directions: bool,
|
||||
pub num_threads: usize,
|
||||
pub snapshot: Option<PhysicsSnapshot>,
|
||||
}
|
||||
|
||||
@@ -180,7 +179,6 @@ impl Testbed {
|
||||
selected_example: 0,
|
||||
selected_backend: RAPIER_BACKEND,
|
||||
physx_use_two_friction_directions: true,
|
||||
num_threads,
|
||||
};
|
||||
|
||||
let harness = Harness::new_empty();
|
||||
@@ -1027,6 +1025,7 @@ impl State for Testbed {
|
||||
window,
|
||||
&mut self.harness.physics.integration_parameters,
|
||||
&mut self.state,
|
||||
&mut self.harness.state
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ use kiss3d::window::Window;
|
||||
use rapier::dynamics::IntegrationParameters;
|
||||
|
||||
use crate::testbed::{RunMode, TestbedActionFlags, TestbedState, TestbedStateFlags};
|
||||
use crate::harness::RunState;
|
||||
|
||||
const SIDEBAR_W: f64 = 200.0;
|
||||
const ELEMENT_W: f64 = SIDEBAR_W - 20.0;
|
||||
@@ -98,6 +99,7 @@ impl TestbedUi {
|
||||
window: &mut Window,
|
||||
integration_parameters: &mut IntegrationParameters,
|
||||
state: &mut TestbedState,
|
||||
run_state: &mut RunState,
|
||||
) {
|
||||
let ui_root = window.conrod_ui().window;
|
||||
let mut ui = window.conrod_ui_mut().set_widgets();
|
||||
@@ -254,7 +256,7 @@ impl TestbedUi {
|
||||
let curr_vel_iters = integration_parameters.max_velocity_iterations;
|
||||
let curr_pos_iters = integration_parameters.max_position_iterations;
|
||||
#[cfg(feature = "parallel")]
|
||||
let curr_num_threads = state.num_threads;
|
||||
let curr_num_threads = run_state.num_threads;
|
||||
let curr_max_ccd_substeps = integration_parameters.max_ccd_substeps;
|
||||
let curr_min_island_size = integration_parameters.min_island_size;
|
||||
let curr_warmstart_coeff = integration_parameters.warmstart_coeff;
|
||||
@@ -305,10 +307,10 @@ impl TestbedUi {
|
||||
.w_h(ELEMENT_W, ELEMENT_H)
|
||||
.set(self.ids.slider_num_threads, &mut ui)
|
||||
{
|
||||
if state.num_threads != val as usize {
|
||||
state.num_threads = val as usize;
|
||||
state.thread_pool = rapier::rayon::ThreadPoolBuilder::new()
|
||||
.num_threads(state.num_threads)
|
||||
if run_state.num_threads != val as usize {
|
||||
run_state.num_threads = val as usize;
|
||||
run_state.thread_pool = rapier::rayon::ThreadPoolBuilder::new()
|
||||
.num_threads(run_state.num_threads)
|
||||
.build()
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user