fn in_cave(&self, world_manager: &super::WorldManager) -> bool {
        let mut height = 0.0;
        let mut above = 0.0;

        let world = world_manager.get_world();
        let relevant_pos = Point2f::new(self.position.x, self.position.y);
        let pillar_index = PillarIndex(AxialPoint::from_real(relevant_pos));

        let vec_len = world
            .pillar_at(pillar_index)
            .map(|pillar| pillar.sections().len())
            .unwrap_or(0);

        let pillar_vec = world
            .pillar_at(pillar_index)
            .map(|pillar| pillar.sections());

        if pillar_vec.is_some() {
            let new_pillar_vec = pillar_vec.unwrap();

            if vec_len == 1 {
                height = new_pillar_vec[0].top.to_real();
                above = f32::INFINITY;
            } else {
                for i in 0..vec_len {
                    if i != vec_len - 1 {
                        if new_pillar_vec[i].top.to_real() < self.position.z
                            && self.position.z < new_pillar_vec[i + 1].bottom.to_real()
                        {
                            height = new_pillar_vec[i].top.to_real();
                            above = new_pillar_vec[i + 1].bottom.to_real();
                            break;
                        } else {
                            continue;
                        }
                    } else {
                        height = new_pillar_vec[i].top.to_real();
                        above = f32::INFINITY;
                        break;
                    }
                }
            }
        }

        !(self.position.z > height && above == f32::INFINITY)
    }
/// returns true iff particle is inside a cave
returns true iff particle is inside a cave
returns true iff particle is inside a cave
fn in_cave(&self, world_manager: &super::WorldManager) -> bool {
        let mut height = 0.0;
        let mut above = 0.0;
        let world = world_manager.get_world();
        let relevant_pos = Point2f::new(self.position.x, self.position.y);
        let pillar_index = PillarIndex(AxialPoint::from_real(relevant_pos));
        let vec_len = world
            .pillar_at(pillar_index)
            .map(|pillar| pillar.sections().len())
            .unwrap_or(0);
        let pillar_vec = world
            .pillar_at(pillar_index)
            .map(|pillar| pillar.sections());
        if pillar_vec.is_some() {
            let new_pillar_vec = pillar_vec.unwrap();
            if vec_len == 1 {
                height = new_pillar_vec[0].top.to_real();
                above = f32::INFINITY;
            } else {
                for i in 0..vec_len {
                    if i != vec_len - 1 {
                        if new_pillar_vec[i].top.to_real() < self.position.z
                            && self.position.z < new_pillar_vec[i + 1].bottom.to_real()
                        {
                            height = new_pillar_vec[i].top.to_real();
                            above = new_pillar_vec[i + 1].bottom.to_real();
                            break;
                        } else {
                            continue;
                        }
                    } else {
                        height = new_pillar_vec[i].top.to_real();
                        above = f32::INFINITY;
                        break;
                    }
                }
            }
        }
        !(self.position.z > height && above == f32::INFINITY)
    }
fn in_cave ( & self , world_manager : & super :: WorldManager ) -> bool { let mut height = 0.0 ; let mut above = 0.0 ; let world = world_manager . get_world ( ) ; let relevant_pos = Point2f :: new ( self . position . x , self . position . y ) ; let pillar_index = PillarIndex ( AxialPoint :: from_real ( relevant_pos ) ) ; let vec_len = world . pillar_at ( pillar_index ) . map ( | pillar | pillar . sections ( ) . len ( ) ) . unwrap_or ( 0 ) ; let pillar_vec = world . pillar_at ( pillar_index ) . map ( | pillar | pillar . sections ( ) ) ; if pillar_vec . is_some ( ) { let new_pillar_vec = pillar_vec . unwrap ( ) ; if vec_len == 1 { height = new_pillar_vec [ 0 ] . top . to_real ( ) ; above = f32 :: INFINITY ; } else { for i in 0 .. vec_len { if i != vec_len - 1 { if new_pillar_vec [ i ] . top . to_real ( ) < self . position . z && self . position . z < new_pillar_vec [ i + 1 ] . bottom . to_real ( ) { height = new_pillar_vec [ i ] . top . to_real ( ) ; above = new_pillar_vec [ i + 1 ] . bottom . to_real ( ) ; break ; } else { continue ; } } else { height = new_pillar_vec [ i ] . top . to_real ( ) ; above = f32 :: INFINITY ; break ; } } } } ! ( self . position . z > height && above == f32 :: INFINITY ) }
returns true iff particle is inside a cave
returns true iff particle is inside a cave
&self
world_manager
&super::WorldManager