// generates densities for the first vertices
generates densities for the first vertices
generates densities for the first vertices
fn label_initial_vertices(&mut self) {
        // temp perlin sampler
        let perlin = Worley::new();
        // calculates an offset for the perlin based on the chunk
        // spacing and the space between vertices
        // (ugly f64 conversion, not sure if dirty code?)
        let perlin_offset = Vector3::new(
            self.offset.x as f64 * self.chunk_bounds as f64 - self.offset.x as f64,
            self.offset.y as f64 * self.chunk_bounds as f64 - self.offset.y as f64,
            self.offset.z as f64 * self.chunk_bounds as f64 - self.offset.z as f64,
        );
        // iterates over the data to assign noise values
        for x in 0..CHUNK_BOUNDS {
            for y in 0..CHUNK_BOUNDS {
                for z in 0..CHUNK_BOUNDS {
                    // gets the perlin value for the point
                    let perlin_value = perlin.get([
                        (perlin_offset.x + x as f64)/CHUNK_BOUNDS as f64,
                        (perlin_offset.y + y as f64)/CHUNK_BOUNDS as f64,
                        (perlin_offset.z + z as f64)/CHUNK_BOUNDS as f64
                    ]);
                    // sets the weighted grid
                    self.grid_weights[[x, y, z]] = perlin_value as f32;
                    // if the perlin value is over the isovalue, set the mask
                    // to PLUS, else to minus
                    if perlin_value as f32 >= self.isovalue {
                        self.grid[[x, y, z]] = Mask::PLUS;
                    }
                    else {
                        self.grid[[x, y, z]] = Mask::MINUS;
                    }
                }
            }
        }
    }
fn label_initial_vertices ( & mut self ) { // temp perlin sampler let perlin = Worley :: new ( ) ; // calculates an offset for the perlin based on the chunk // spacing and the space between vertices // (ugly f64 conversion, not sure if dirty code?) let perlin_offset = Vector3 :: new ( self . offset . x as f64 * self . chunk_bounds as f64 - self . offset . x as f64 , self . offset . y as f64 * self . chunk_bounds as f64 - self . offset . y as f64 , self . offset . z as f64 * self . chunk_bounds as f64 - self . offset . z as f64 , ) ; // iterates over the data to assign noise values for x in 0 .. CHUNK_BOUNDS { for y in 0 .. CHUNK_BOUNDS { for z in 0 .. CHUNK_BOUNDS { // gets the perlin value for the point let perlin_value = perlin . get ( [ ( perlin_offset . x + x as f64 ) / CHUNK_BOUNDS as f64 , ( perlin_offset . y + y as f64 ) / CHUNK_BOUNDS as f64 , ( perlin_offset . z + z as f64 ) / CHUNK_BOUNDS as f64 ] ) ; // sets the weighted grid self . grid_weights [ [ x , y , z ] ] = perlin_value as f32 ; // if the perlin value is over the isovalue, set the mask // to PLUS, else to minus if perlin_value as f32 >= self . isovalue { self . grid [ [ x , y , z ] ] = Mask :: PLUS ; } else { self . grid [ [ x , y , z ] ] = Mask :: MINUS ; } } } } }
generates densities for the first vertices
generates densities for the first vertices
&mut self