aboutsummaryrefslogtreecommitdiff
path: root/src_testbed/harness
diff options
context:
space:
mode:
authorSébastien Crozet <developer@crozet.re>2022-02-20 12:55:00 +0100
committerSébastien Crozet <sebastien@crozet.re>2022-03-20 21:49:16 +0100
commitfb20d72ee29de9311a81aec6eb9f02fd2aa35fc4 (patch)
tree45827ac4c754c3670d1ddb2f91fc498515d6b3b8 /src_testbed/harness
parente740493b980dc9856864ead3206a4fa02aff965f (diff)
downloadrapier-fb20d72ee29de9311a81aec6eb9f02fd2aa35fc4.tar.gz
rapier-fb20d72ee29de9311a81aec6eb9f02fd2aa35fc4.tar.bz2
rapier-fb20d72ee29de9311a81aec6eb9f02fd2aa35fc4.zip
Joint API and joint motors improvements
Diffstat (limited to 'src_testbed/harness')
-rw-r--r--src_testbed/harness/mod.rs38
1 files changed, 32 insertions, 6 deletions
diff --git a/src_testbed/harness/mod.rs b/src_testbed/harness/mod.rs
index beebe80..59cccc3 100644
--- a/src_testbed/harness/mod.rs
+++ b/src_testbed/harness/mod.rs
@@ -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 {