linux shader building, complete side renaming, esc to quit

This commit is contained in:
steffen 2024-12-22 11:13:05 +01:00
parent c733c0519f
commit 57e862832a
5 changed files with 160 additions and 122 deletions

View file

@ -39,6 +39,28 @@ fn main() {
io::stderr().write_all(&output.stderr).unwrap(); io::stderr().write_all(&output.stderr).unwrap();
assert!(output.status.success()); assert!(output.status.success());
} else if std::env::consts::OS == "linux" {
#[allow(unused_must_use)]
std::fs::remove_file("shaders/geo_cube.spv");
#[allow(unused_must_use)]
std::fs::remove_file("shaders/frag_cube.spv");
#[allow(unused_must_use)]
std::fs::remove_file("shaders/vert_cube.spv");
#[allow(unused_must_use)]
std::fs::remove_file("shaders/geo_cuboid.spv");
#[allow(unused_must_use)]
std::fs::remove_file("shaders/frag_cuboid.spv");
#[allow(unused_must_use)]
std::fs::remove_file("shaders/vert_cuboid.spv");
#[warn(unused_must_use)]
// probably need to check the os and have different versions
let mut command = Command::new("./shaders/compile.sh");
let output = command.output().expect("Failed to execute command");
println!("status: {}", output.status);
io::stdout().write_all(&output.stdout).unwrap();
io::stderr().write_all(&output.stderr).unwrap();
assert!(output.status.success());
} }
assert!(Path::new("shaders/geo_cube.spv").exists()); assert!(Path::new("shaders/geo_cube.spv").exists());

11
shaders/compile.sh Executable file
View file

@ -0,0 +1,11 @@
#!/bin/sh
glslc shaders/cube.vert -o shaders/vert_cube.spv
glslc shaders/cube.frag -o shaders/frag_cube.spv
glslc shaders/cube.geom -o shaders/geo_cube.spv
glslc shaders/cuboid.vert -o shaders/vert_cuboid.spv
glslc shaders/cuboid.frag -o shaders/frag_cuboid.spv
glslc shaders/cuboid.geom -o shaders/geo_cuboid.spv
glslc shaders/rt_quad.vert -o shaders/vert_rt_quad.spv
glslc shaders/rt_quad.frag -o shaders/frag_rt_quad.spv

View file

@ -10,6 +10,7 @@ use log::*;
use winit::dpi::{LogicalSize, LogicalPosition}; use winit::dpi::{LogicalSize, LogicalPosition};
use winit::event::{Event, WindowEvent}; use winit::event::{Event, WindowEvent};
use winit::event_loop::EventLoop; use winit::event_loop::EventLoop;
use winit::keyboard::NamedKey;
use winit::window::{Window, WindowBuilder}; use winit::window::{Window, WindowBuilder};
use vulkanalia::loader::{LibloadingLoader, LIBRARY}; use vulkanalia::loader::{LibloadingLoader, LIBRARY};
@ -131,6 +132,11 @@ fn main() -> Result<()> {
if event.logical_key == "d" { if event.logical_key == "d" {
app.cur_pos += app.view_direction.cross(vertex::Vec3::new(0.0, 0.0, 1.0)) * 0.1; app.cur_pos += app.view_direction.cross(vertex::Vec3::new(0.0, 0.0, 1.0)) * 0.1;
} }
if event.logical_key == NamedKey::Escape {
elwt.exit();
unsafe { app.device.device_wait_idle().unwrap(); }
unsafe { app.destroy(); }
}
}, },
_ => {} _ => {}
} }

View file

@ -11,7 +11,7 @@ pub struct Cube{
pub tex_coord: vertex::Vec2 pub tex_coord: vertex::Vec2
} }
const cube_size: f32 = 0.5; const cube_size: f32 = 0.48;
impl Drawable for Cube { impl Drawable for Cube {
fn draw(& self, topology: &vk::PrimitiveTopology, start_index: usize, scene: &mut Scene) { fn draw(& self, topology: &vk::PrimitiveTopology, start_index: usize, scene: &mut Scene) {

View file

@ -5,7 +5,6 @@ use anyhow::Result;
use cgmath::{vec2, vec3, Vector3}; use cgmath::{vec2, vec3, Vector3};
use std::cell::RefCell; use std::cell::RefCell;
use std::intrinsics::size_of;
use std::rc::Rc; use std::rc::Rc;
use std::time::Instant; use std::time::Instant;
@ -652,26 +651,26 @@ struct EmptyVolume {
pub position: Vector3<usize>, pub position: Vector3<usize>,
pub color_left_rn: Vec<Vector3<u8>>, pub color_left: Vec<Vector3<u8>>,
pub color_right_rn: Vec<Vector3<u8>>, pub color_right: Vec<Vector3<u8>>,
pub color_top: Vec<Vector3<u8>>, pub color_top: Vec<Vector3<u8>>,
pub color_bottom: Vec<Vector3<u8>>, pub color_bottom: Vec<Vector3<u8>>,
pub color_back_rn: Vec<Vector3<u8>>, pub color_back: Vec<Vector3<u8>>,
pub color_front_rn: Vec<Vector3<u8>>, pub color_front: Vec<Vector3<u8>>,
pub roughness_left_rn: Vec<Vector3<u8>>, pub roughness_left: Vec<Vector3<u8>>,
pub roughness_right_rn: Vec<Vector3<u8>>, pub roughness_right: Vec<Vector3<u8>>,
pub roughness_top: Vec<Vector3<u8>>, pub roughness_top: Vec<Vector3<u8>>,
pub roughness_bottom: Vec<Vector3<u8>>, pub roughness_bottom: Vec<Vector3<u8>>,
pub roughness_back_rn: Vec<Vector3<u8>>, pub roughness_back: Vec<Vector3<u8>>,
pub roughness_front_rn: Vec<Vector3<u8>>, pub roughness_front: Vec<Vector3<u8>>,
pub neighbor_left_rn: Vec<Option<Rc<RefCell<Self>>>>, pub neighbor_left: Vec<Option<Rc<RefCell<Self>>>>,
pub neighbor_right_rn: Vec<Option<Rc<RefCell<Self>>>>, pub neighbor_right: Vec<Option<Rc<RefCell<Self>>>>,
pub neighbor_top: Vec<Option<Rc<RefCell<Self>>>>, pub neighbor_top: Vec<Option<Rc<RefCell<Self>>>>,
pub neighbor_bottom: Vec<Option<Rc<RefCell<Self>>>>, pub neighbor_bottom: Vec<Option<Rc<RefCell<Self>>>>,
pub neighbor_back_rn: Vec<Option<Rc<RefCell<Self>>>>, pub neighbor_back: Vec<Option<Rc<RefCell<Self>>>>,
pub neighbor_front_rn: Vec<Option<Rc<RefCell<Self>>>>, pub neighbor_front: Vec<Option<Rc<RefCell<Self>>>>,
} }
impl EmptyVolume { impl EmptyVolume {
@ -773,24 +772,24 @@ impl EmptyVolume {
size_y: y_size + 1, size_y: y_size + 1,
size_z: z_size + 1, size_z: z_size + 1,
position: Vector3{x: x_index, y: y_index, z: z_index}, position: Vector3{x: x_index, y: y_index, z: z_index},
color_left_rn: vec![], color_left: vec![],
color_right_rn: vec![], color_right: vec![],
color_top: vec![], color_top: vec![],
color_bottom: vec![], color_bottom: vec![],
color_back_rn: vec![], color_back: vec![],
color_front_rn: vec![], color_front: vec![],
roughness_left_rn: vec![], roughness_left: vec![],
roughness_right_rn: vec![], roughness_right: vec![],
roughness_top: vec![], roughness_top: vec![],
roughness_bottom: vec![], roughness_bottom: vec![],
roughness_back_rn: vec![], roughness_back: vec![],
roughness_front_rn: vec![], roughness_front: vec![],
neighbor_left_rn: vec![], neighbor_left: vec![],
neighbor_right_rn: vec![], neighbor_right: vec![],
neighbor_top: vec![], neighbor_top: vec![],
neighbor_bottom: vec![], neighbor_bottom: vec![],
neighbor_back_rn: vec![], neighbor_back: vec![],
neighbor_front_rn: vec![], neighbor_front: vec![],
}; };
println!("adding neighbor references"); println!("adding neighbor references");
//fill in info in the neighbor octtree //fill in info in the neighbor octtree
@ -887,111 +886,111 @@ impl EmptyVolume {
} }
// back face of the volume // back face of the volume
let mut back_colors_rn = vec![]; let mut back_colors = vec![];
let mut back_roughness_rn = vec![]; let mut back_roughness = vec![];
let mut back_elements_num_rn = 0; let mut back_elements_num = 0;
for x in 0..x_size+1 { for x in 0..x_size+1 {
for z in 0..z_size+1 { for z in 0..z_size+1 {
if let Some(c) = tree.get_element(reference.borrow().position.x + x, y_max_pos, reference.borrow().position.z + z) { if let Some(c) = tree.get_element(reference.borrow().position.x + x, y_max_pos, reference.borrow().position.z + z) {
back_elements_num_rn += 1; back_elements_num += 1;
let u8_color = Vector3 {x: (c.color * 255.0).x.min(255.0).max(0.0) as u8, y: (c.color * 255.0).y.min(255.0).max(0.0) as u8, z: (c.color * 255.0).z.min(255.0).max(0.0) as u8}; let u8_color = Vector3 {x: (c.color * 255.0).x.min(255.0).max(0.0) as u8, y: (c.color * 255.0).y.min(255.0).max(0.0) as u8, z: (c.color * 255.0).z.min(255.0).max(0.0) as u8};
back_colors_rn.push(u8_color); back_colors.push(u8_color);
back_roughness_rn.push(Vector3 {x: 128, y: 128, z: 128}); back_roughness.push(Vector3 {x: 128, y: 128, z: 128});
} }
else { else {
back_colors_rn.push(Vector3 { x: 255, y: 255, z: 255 }); back_colors.push(Vector3 { x: 255, y: 255, z: 255 });
back_roughness_rn.push(Vector3 {x: 255, y: 255, z: 255}); back_roughness.push(Vector3 {x: 255, y: 255, z: 255});
} }
} }
} }
if back_elements_num_rn > 0 { if back_elements_num > 0 {
reference.borrow_mut().color_back_rn = back_colors_rn; reference.borrow_mut().color_back = back_colors;
reference.borrow_mut().roughness_back_rn = back_roughness_rn; reference.borrow_mut().roughness_back = back_roughness;
} }
else { else {
reference.borrow_mut().color_back_rn= vec![]; reference.borrow_mut().color_back= vec![];
reference.borrow_mut().roughness_back_rn= vec![]; reference.borrow_mut().roughness_back= vec![];
} }
// front face of the volume // front face of the volume
let mut front_colors_rn = vec![]; let mut front_colors = vec![];
let mut front_roughness_rn = vec![]; let mut front_roughness = vec![];
let mut front_elements_num_rn = 0; let mut front_elements_num = 0;
for x in 0..x_size+1 { for x in 0..x_size+1 {
for z in 0..z_size+1 { for z in 0..z_size+1 {
if let Some(c) = tree.get_element(reference.borrow().position.x + x, y_min_pos, reference.borrow().position.z + z) { if let Some(c) = tree.get_element(reference.borrow().position.x + x, y_min_pos, reference.borrow().position.z + z) {
front_elements_num_rn += 1; front_elements_num += 1;
let u8_color = Vector3 {x: (c.color * 255.0).x.min(255.0).max(0.0) as u8, y: (c.color * 255.0).y.min(255.0).max(0.0) as u8, z: (c.color * 255.0).z.min(255.0).max(0.0) as u8}; let u8_color = Vector3 {x: (c.color * 255.0).x.min(255.0).max(0.0) as u8, y: (c.color * 255.0).y.min(255.0).max(0.0) as u8, z: (c.color * 255.0).z.min(255.0).max(0.0) as u8};
front_colors_rn.push(u8_color); front_colors.push(u8_color);
front_roughness_rn.push(Vector3 {x: 128, y: 128, z: 128}); front_roughness.push(Vector3 {x: 128, y: 128, z: 128});
} }
else { else {
front_colors_rn.push(Vector3 { x: 255, y: 255, z: 255 }); front_colors.push(Vector3 { x: 255, y: 255, z: 255 });
front_roughness_rn.push(Vector3 {x: 255, y: 255, z: 255}); front_roughness.push(Vector3 {x: 255, y: 255, z: 255});
} }
} }
} }
if front_elements_num_rn > 0 { if front_elements_num > 0 {
reference.borrow_mut().color_front_rn = front_colors_rn; reference.borrow_mut().color_front = front_colors;
reference.borrow_mut().roughness_front_rn = front_roughness_rn; reference.borrow_mut().roughness_front = front_roughness;
} }
else { else {
reference.borrow_mut().color_front_rn= vec![]; reference.borrow_mut().color_front= vec![];
reference.borrow_mut().roughness_front_rn= vec![]; reference.borrow_mut().roughness_front= vec![];
} }
// front face of the volume // front face of the volume
let mut left_colors_rn = vec![]; let mut left_colors = vec![];
let mut left_roughness_rn = vec![]; let mut left_roughness = vec![];
let mut left_elements_num_rn = 0; let mut left_elements_num = 0;
for y in 0..y_size+1 { for y in 0..y_size+1 {
for z in 0..z_size+1 { for z in 0..z_size+1 {
if let Some(c) = tree.get_element(x_min_pos, reference.borrow().position.y + y, reference.borrow().position.z + z) { if let Some(c) = tree.get_element(x_min_pos, reference.borrow().position.y + y, reference.borrow().position.z + z) {
left_elements_num_rn += 1; left_elements_num += 1;
let u8_color = Vector3 {x: (c.color * 255.0).x.min(255.0).max(0.0) as u8, y: (c.color * 255.0).y.min(255.0).max(0.0) as u8, z: (c.color * 255.0).z.min(255.0).max(0.0) as u8}; let u8_color = Vector3 {x: (c.color * 255.0).x.min(255.0).max(0.0) as u8, y: (c.color * 255.0).y.min(255.0).max(0.0) as u8, z: (c.color * 255.0).z.min(255.0).max(0.0) as u8};
left_colors_rn.push(u8_color); left_colors.push(u8_color);
left_roughness_rn.push(Vector3 {x: 128, y: 128, z: 128}); left_roughness.push(Vector3 {x: 128, y: 128, z: 128});
} }
else { else {
left_colors_rn.push(Vector3 { x: 255, y: 255, z: 255 }); left_colors.push(Vector3 { x: 255, y: 255, z: 255 });
left_roughness_rn.push(Vector3 {x: 255, y: 255, z: 255}); left_roughness.push(Vector3 {x: 255, y: 255, z: 255});
} }
} }
} }
if left_elements_num_rn > 0 { if left_elements_num > 0 {
reference.borrow_mut().color_left_rn = left_colors_rn; reference.borrow_mut().color_left = left_colors;
reference.borrow_mut().roughness_left_rn = left_roughness_rn; reference.borrow_mut().roughness_left = left_roughness;
} }
else { else {
reference.borrow_mut().color_left_rn= vec![]; reference.borrow_mut().color_left= vec![];
reference.borrow_mut().roughness_left_rn= vec![]; reference.borrow_mut().roughness_left= vec![];
} }
// back face of the volume // back face of the volume
let mut right_colors_rn = vec![]; let mut right_colors = vec![];
let mut right_roughness_rn = vec![]; let mut right_roughness = vec![];
let mut right_elements_num_rn = 0; let mut right_elements_num = 0;
for y in 0..y_size+1 { for y in 0..y_size+1 {
for z in 0..z_size+1 { for z in 0..z_size+1 {
if let Some(c) = tree.get_element(x_max_pos, reference.borrow().position.y + y, reference.borrow().position.z + z) { if let Some(c) = tree.get_element(x_max_pos, reference.borrow().position.y + y, reference.borrow().position.z + z) {
right_elements_num_rn += 1; right_elements_num += 1;
let u8_color = Vector3 {x: (c.color * 255.0).x.min(255.0).max(0.0) as u8, y: (c.color * 255.0).y.min(255.0).max(0.0) as u8, z: (c.color * 255.0).z.min(255.0).max(0.0) as u8}; let u8_color = Vector3 {x: (c.color * 255.0).x.min(255.0).max(0.0) as u8, y: (c.color * 255.0).y.min(255.0).max(0.0) as u8, z: (c.color * 255.0).z.min(255.0).max(0.0) as u8};
right_colors_rn.push(u8_color); right_colors.push(u8_color);
right_roughness_rn.push(Vector3 {x: 128, y: 128, z: 128}); right_roughness.push(Vector3 {x: 128, y: 128, z: 128});
} }
else { else {
right_colors_rn.push(Vector3 { x: 255, y: 255, z: 255 }); right_colors.push(Vector3 { x: 255, y: 255, z: 255 });
right_roughness_rn.push(Vector3 {x: 255, y: 255, z: 255}); right_roughness.push(Vector3 {x: 255, y: 255, z: 255});
} }
} }
} }
if right_elements_num_rn > 0 { if right_elements_num > 0 {
reference.borrow_mut().color_right_rn = right_colors_rn; reference.borrow_mut().color_right = right_colors;
reference.borrow_mut().roughness_right_rn = right_roughness_rn; reference.borrow_mut().roughness_right = right_roughness;
} }
else { else {
reference.borrow_mut().color_right_rn= vec![]; reference.borrow_mut().color_right= vec![];
reference.borrow_mut().roughness_right_rn= vec![]; reference.borrow_mut().roughness_right= vec![];
} }
println!("new volume done"); println!("new volume done");
@ -1075,91 +1074,91 @@ impl EmptyVolume {
} }
// back face of the volume // back face of the volume
let mut back_neighbors_rn = vec![]; let mut back_neighbors = vec![];
let mut back_elements_num_rn = 0; let mut back_elements_num = 0;
for x in 0..reference.borrow().size_x { for x in 0..reference.borrow().size_x {
for z in 0..reference.borrow().size_z { for z in 0..reference.borrow().size_z {
if let Some(c) = neighbors.get_element(reference.borrow().position.x + x, y_max_pos, reference.borrow().position.z + z) { if let Some(c) = neighbors.get_element(reference.borrow().position.x + x, y_max_pos, reference.borrow().position.z + z) {
back_elements_num_rn += 1; back_elements_num += 1;
back_neighbors_rn.push(Some(c.clone())); back_neighbors.push(Some(c.clone()));
} }
else { else {
back_neighbors_rn.push(None); back_neighbors.push(None);
} }
} }
} }
if back_elements_num_rn > 0 { if back_elements_num > 0 {
reference.borrow_mut().neighbor_back_rn = back_neighbors_rn; reference.borrow_mut().neighbor_back = back_neighbors;
} }
else { else {
reference.borrow_mut().neighbor_back_rn = vec![None]; reference.borrow_mut().neighbor_back = vec![None];
} }
// front face of the volume // front face of the volume
let mut front_neighbors_rn = vec![]; let mut front_neighbors = vec![];
let mut front_elements_num_rn = 0; let mut front_elements_num = 0;
if y_min_pos != 0{ if y_min_pos != 0{
for x in 0..reference.borrow().size_x { for x in 0..reference.borrow().size_x {
for z in 0..reference.borrow().size_z { for z in 0..reference.borrow().size_z {
if let Some(c) = neighbors.get_element(reference.borrow().position.x + x, y_min_pos, reference.borrow().position.z + z) { if let Some(c) = neighbors.get_element(reference.borrow().position.x + x, y_min_pos, reference.borrow().position.z + z) {
front_elements_num_rn += 1; front_elements_num += 1;
front_neighbors_rn.push(Some(c.clone())); front_neighbors.push(Some(c.clone()));
} }
else { else {
front_neighbors_rn.push(None); front_neighbors.push(None);
} }
} }
} }
} }
if front_elements_num_rn > 0 { if front_elements_num > 0 {
reference.borrow_mut().neighbor_front_rn = front_neighbors_rn; reference.borrow_mut().neighbor_front = front_neighbors;
} }
else { else {
reference.borrow_mut().neighbor_front_rn = vec![None]; reference.borrow_mut().neighbor_front = vec![None];
} }
// left face of the volume // left face of the volume
let mut left_neighbors_rn = vec![]; let mut left_neighbors = vec![];
let mut left_elements_num_rn = 0; let mut left_elements_num = 0;
if x_min_pos != 0 { if x_min_pos != 0 {
for y in 0..reference.borrow().size_y { for y in 0..reference.borrow().size_y {
for z in 0..reference.borrow().size_z { for z in 0..reference.borrow().size_z {
if let Some(c) = neighbors.get_element(x_min_pos, reference.borrow().position.y + y, reference.borrow().position.z + z) { if let Some(c) = neighbors.get_element(x_min_pos, reference.borrow().position.y + y, reference.borrow().position.z + z) {
left_elements_num_rn += 1; left_elements_num += 1;
left_neighbors_rn.push(Some(c.clone())); left_neighbors.push(Some(c.clone()));
} }
else { else {
left_neighbors_rn.push(None); left_neighbors.push(None);
} }
} }
} }
} }
if left_elements_num_rn > 0 { if left_elements_num > 0 {
reference.borrow_mut().neighbor_left_rn = left_neighbors_rn; reference.borrow_mut().neighbor_left = left_neighbors;
} }
else { else {
reference.borrow_mut().neighbor_left_rn = vec![None]; reference.borrow_mut().neighbor_left = vec![None];
} }
// right face of the volume // right face of the volume
let mut right_neighbors_rn = vec![]; let mut right_neighbors = vec![];
let mut right_elements_num_rn = 0; let mut right_elements_num = 0;
for y in 0..reference.borrow().size_y { for y in 0..reference.borrow().size_y {
for z in 0..reference.borrow().size_z { for z in 0..reference.borrow().size_z {
if let Some(c) = neighbors.get_element(x_max_pos, reference.borrow().position.y + y, reference.borrow().position.z + z) { if let Some(c) = neighbors.get_element(x_max_pos, reference.borrow().position.y + y, reference.borrow().position.z + z) {
right_elements_num_rn += 1; right_elements_num += 1;
right_neighbors_rn.push(Some(c.clone())); right_neighbors.push(Some(c.clone()));
} }
else { else {
right_neighbors_rn.push(None); right_neighbors.push(None);
} }
} }
} }
if right_elements_num_rn > 0 { if right_elements_num > 0 {
reference.borrow_mut().neighbor_right_rn = right_neighbors_rn; reference.borrow_mut().neighbor_right = right_neighbors;
} }
else { else {
reference.borrow_mut().neighbor_right_rn = vec![None]; reference.borrow_mut().neighbor_right = vec![None];
} }
} }
println!("volume creation took {} s", start_time.elapsed().as_millis() as f32 / 1000.0); println!("volume creation took {} s", start_time.elapsed().as_millis() as f32 / 1000.0);
@ -1220,11 +1219,11 @@ impl EmptyVolume {
for x in 0..self.size_x { for x in 0..self.size_x {
for z in 0..self.size_z { for z in 0..self.size_z {
let index = x * self.size_z + z; let index = x * self.size_z + z;
if self.color_front_rn.len() == 0 { if self.color_front.len() == 0 {
continue; continue;
} }
if self.neighbor_front_rn.len() > index { if self.neighbor_front.len() > index {
if let Some(_) = self.neighbor_front_rn[index] { if let Some(_) = self.neighbor_front[index] {
continue; continue;
} }
} }
@ -1244,11 +1243,11 @@ impl EmptyVolume {
for x in 0..self.size_x { for x in 0..self.size_x {
for z in 0..self.size_z { for z in 0..self.size_z {
let index = x * self.size_z + z; let index = x * self.size_z + z;
if self.color_back_rn.len() == 0 { if self.color_back.len() == 0 {
continue; continue;
} }
if self.neighbor_back_rn.len() > index { if self.neighbor_back.len() > index {
if let Some(_) = self.neighbor_back_rn[index] { if let Some(_) = self.neighbor_back[index] {
continue; continue;
} }
} }
@ -1268,11 +1267,11 @@ impl EmptyVolume {
for y in 0..self.size_y { for y in 0..self.size_y {
for z in 0..self.size_z { for z in 0..self.size_z {
let index = y * self.size_z + z; let index = y * self.size_z + z;
if self.color_left_rn.len() == 0 { if self.color_left.len() == 0 {
continue; continue;
} }
if self.neighbor_left_rn.len() > index { if self.neighbor_left.len() > index {
if let Some(_) = self.neighbor_left_rn[index] { if let Some(_) = self.neighbor_left[index] {
continue; continue;
} }
} }
@ -1292,11 +1291,11 @@ impl EmptyVolume {
for y in 0..self.size_y { for y in 0..self.size_y {
for z in 0..self.size_z { for z in 0..self.size_z {
let index = y * self.size_z + z; let index = y * self.size_z + z;
if self.color_right_rn.len() == 0 { if self.color_right.len() == 0 {
continue; continue;
} }
if self.neighbor_right_rn.len() > index { if self.neighbor_right.len() > index {
if let Some(_) = self.neighbor_right_rn[index] { if let Some(_) = self.neighbor_right[index] {
continue; continue;
} }
} }