Browse Source

simplify child index calculations

opt
Björn Steinbrink 8 months ago
parent
commit
ce0c3be895
1 changed files with 7 additions and 9 deletions
  1. +7
    -9
      src/barnes_hut.rs

+ 7
- 9
src/barnes_hut.rs View File

@ -80,12 +80,11 @@ impl Octree {
else {
//println!("A{}", self.nodes[cur_node].num_particles);
//Divide and conquer
let (base, mask) = self.children[cur_node];
let mut off = 0;
let (mut child, mask) = self.children[cur_node];
for c in 0..8 {
if mask & (1 << c) != 0 {
self.barnes_hut_specific_node(particle, base as usize + off, delta);
off += 1;
self.barnes_hut_specific_node(particle, child as usize, delta);
child += 1;
}
}
}
@ -151,12 +150,11 @@ impl Octree {
}
}
let mut off = 0;
for (i, particle_oct) in particle_octs.iter().enumerate() {
let mut c = idx as usize;
for particle_oct in &particle_octs {
if !particle_oct.is_empty() {
self.add_particles_to_specific_node(&particle_oct,
self.children[cur_node].0 as usize + off);
off += 1;
self.add_particles_to_specific_node(&particle_oct, c);
c += 1;
}
}
}


Loading…
Cancel
Save