### Slight perf improvement

master
Stephen 5 months ago
parent
commit
519299a2bc
1 changed files with 7 additions and 6 deletions
1. +7
-6
src/barnes_hut.rs

#### + 7 - 6 src/barnes_hut.rsView File

 @ -46,10 +46,11 @@ impl Octree { particle: &mut RigidPoint, cur_node: usize, delta: f64) { if self.nodes[cur_node].num_particles == 0 { return; } let c_node = &self.nodes[cur_node]; if c_node.num_particles == 0 { return; } let min_coord = self.nodes[cur_node].min_coord; let max_coord = self.nodes[cur_node].max_coord; let min_coord = c_node.min_coord; let max_coord = c_node.max_coord; let width = max_coord.x - min_coord.x; let height = max_coord.y - min_coord.y; @ -63,8 +64,8 @@ impl Octree { let theta_squared = THETA * THETA; let ratio = s_squared / d_squared; if self.nodes[cur_node].num_particles == 1 || ratio < theta_squared { println!("s/d = {}", ratio.sqrt()); if c_node.num_particles == 1 || ratio < theta_squared { // println!("s/d = {}", ratio.sqrt()); //We can approximate if d_squared < 0.1 { return; } // Worse, but higher-performance, method of smoothing let other = &self.nodes[cur_node]; @ -77,7 +78,7 @@ impl Octree { //println!("A{}", self.nodes[cur_node].num_particles); //Divide and conquer for i in 0..8 { self.barnes_hut_specific_node(particle, self.nodes[cur_node].children[i] as usize, delta); self.barnes_hut_specific_node(particle, c_node.children[i] as usize, delta); } } }