neighbor linkage for oct trees complete
This commit is contained in:
parent
4e50b1a12e
commit
d65a38200c
2 changed files with 18 additions and 8 deletions
src/scene
|
@ -111,9 +111,9 @@ pub fn generate_test_scene(scene: &mut Scene, data: &mut AppData) -> Result<()>
|
|||
let index = scene.sized_vertices.len();
|
||||
cube.draw(&data.topology, index, scene);
|
||||
|
||||
let tree_ref_one = Rc::new(RefCell::new(oct_tree1));
|
||||
let tree_ref_two = Rc::new(RefCell::new(oct_tree2));
|
||||
scene.oct_trees = vec![vec![vec![tree_ref_one.clone(), tree_ref_two.clone()]]];
|
||||
let tree_ref_one = Rc::new(RefCell::new(oct_tree1.clone()));
|
||||
let tree_ref_two = Rc::new(RefCell::new(oct_tree2.clone()));
|
||||
scene.oct_trees = vec![vec![vec![tree_ref_one.clone(), tree_ref_two.clone()], vec![tree_ref_two.clone(), tree_ref_two.clone()]], vec![vec![tree_ref_one.clone(), tree_ref_two.clone()], vec![tree_ref_two.clone(), tree_ref_two.clone()]]];
|
||||
|
||||
Ok(())
|
||||
}
|
|
@ -71,13 +71,15 @@ impl Scene {
|
|||
|
||||
let mut neighbor_trees: Vec<Vec<Vec<Rc<OctTree<Rc<RefCell<EmptyVolume>>>>>>> = vec![];
|
||||
|
||||
let mut x_index = 0;
|
||||
let mut y_index = 0;
|
||||
|
||||
|
||||
let mut z_index = 0;
|
||||
for oct_tree_plane_xy in &self.oct_trees {
|
||||
neighbor_trees.push(vec![]);
|
||||
let mut y_index = 0;
|
||||
for oct_tree_line_y in oct_tree_plane_xy {
|
||||
neighbor_trees[z_index].push(vec![]);
|
||||
let mut x_index = 0;
|
||||
for oct_tree in oct_tree_line_y {
|
||||
let mut new_volumes: Vec<Rc<RefCell<EmptyVolume>>>;
|
||||
let new_neighbors;
|
||||
|
@ -92,18 +94,26 @@ impl Scene {
|
|||
}
|
||||
z_index += 1;
|
||||
}
|
||||
let mut x_index = 0;
|
||||
let mut y_index = 0;
|
||||
|
||||
let mut z_index = 0;
|
||||
for oct_tree_plane_xy in &self.oct_trees {
|
||||
let mut y_index = 0;
|
||||
for oct_tree_line_x in oct_tree_plane_xy {
|
||||
let mut x_index = 0;
|
||||
for oct_tree in oct_tree_line_x {
|
||||
|
||||
if oct_tree_line_x.len() > x_index + 1 {
|
||||
EmptyVolume::combine_results(oct_tree, &neighbor_trees[z_index][y_index][x_index], &oct_tree_line_x[x_index + 1], &neighbor_trees[z_index][y_index][x_index + 1], vertex::Facing::Right);
|
||||
EmptyVolume::combine_results(&oct_tree_line_x[x_index + 1], &neighbor_trees[z_index][y_index][x_index + 1], oct_tree, &neighbor_trees[z_index][y_index][x_index], vertex::Facing::Left);
|
||||
}
|
||||
|
||||
if oct_tree_plane_xy.len() > y_index + 1 {
|
||||
EmptyVolume::combine_results(oct_tree, &neighbor_trees[z_index][y_index][x_index], &oct_tree_plane_xy[y_index + 1][x_index], &neighbor_trees[z_index][y_index + 1][x_index], vertex::Facing::Back);
|
||||
EmptyVolume::combine_results(&oct_tree_plane_xy[y_index + 1][x_index], &neighbor_trees[z_index][y_index + 1][x_index], oct_tree, &neighbor_trees[z_index][y_index][x_index], vertex::Facing::Front);
|
||||
}
|
||||
if self.oct_trees.len() > z_index + 1 {
|
||||
EmptyVolume::combine_results(oct_tree, &neighbor_trees[z_index][y_index][x_index], &self.oct_trees[z_index + 1][y_index][x_index], &neighbor_trees[z_index + 1][y_index][x_index], vertex::Facing::Top);
|
||||
EmptyVolume::combine_results(&self.oct_trees[z_index + 1][y_index][x_index], &neighbor_trees[z_index + 1][y_index][x_index], oct_tree, &neighbor_trees[z_index][y_index][x_index], vertex::Facing::Bottom);
|
||||
}
|
||||
x_index += 1;
|
||||
}
|
||||
y_index += 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue