fn add_top_and_bottom_face(
    pos: AxialPoint,
    pillar: &HexPillar,
    vertices: &mut Vec<Vertex>,
    indices: &mut Vec<u32>,
) {
    for sec in pillar.sections() {
        let ground = sec.ground.get_id();

        // Add top and bottom face
        let face_props = [
            (sec.top, [0.0, 0.0, 1.0], false),
            (sec.bottom, [0.0, 0.0, -1.0], true),
        ];

        for &(height, normal, rev) in &face_props {
            let prev_len = vertices.len() as u32;

            // We completely skip all faces at height 0
            if height.units() == 0 {
                continue;
            }

            // Add center point
            vertices.push(Vertex {
                position: [pos.to_real().x, pos.to_real().y, height.to_real()],
                normal: normal,
                radius: 0.0,
                tex_coords: [0.5, 0.5],
                material_color: sec.ground.get_color(),
                ground: ground,
            });

            // Iterate over all corners with position and uv coordinates
            let iter = NORM_CORNERS
                .iter()
                .map(|c| c * HEX_OUTER_RADIUS)
                .zip(CORNER_UV)
                .enumerate();
            for (i, (corner, &uv)) in iter {
                let i = i as u32;
                let pos2d = pos.to_real() + corner;

                vertices.push(Vertex {
                    position: [pos2d.x, pos2d.y, height.to_real()],
                    normal: normal,
                    radius: 1.0,
                    tex_coords: uv,
                    material_color: sec.ground.get_color(),
                    ground: ground,
                });

                if rev {
                    indices.push(prev_len);
                    indices.push(prev_len + ((i + 1) % 6) + 1);
                    indices.push(prev_len + i + 1);
                } else {
                    indices.push(prev_len);
                    indices.push(prev_len + i + 1);
                    indices.push(prev_len + ((i + 1) % 6) + 1);
                }
            }
        }
    }
}
/// Adds the top and bottom face for every section in a pillar, but completely
/// ignores all faces at height 0.
Adds the top and bottom face for every section in a pillar, but completely
ignores all faces at height 0.
Adds the top and bottom face for every section in a pillar but completely ignores all faces at height 0 .
fn add_top_and_bottom_face(
    pos: AxialPoint,
    pillar: &HexPillar,
    vertices: &mut Vec<Vertex>,
    indices: &mut Vec<u32>,
) {
    for sec in pillar.sections() {
        let ground = sec.ground.get_id();
        // Add top and bottom face
        let face_props = [
            (sec.top, [0.0, 0.0, 1.0], false),
            (sec.bottom, [0.0, 0.0, -1.0], true),
        ];
        for &(height, normal, rev) in &face_props {
            let prev_len = vertices.len() as u32;
            // We completely skip all faces at height 0
            if height.units() == 0 {
                continue;
            }
            // Add center point
            vertices.push(Vertex {
                position: [pos.to_real().x, pos.to_real().y, height.to_real()],
                normal: normal,
                radius: 0.0,
                tex_coords: [0.5, 0.5],
                material_color: sec.ground.get_color(),
                ground: ground,
            });
            // Iterate over all corners with position and uv coordinates
            let iter = NORM_CORNERS
                .iter()
                .map(|c| c * HEX_OUTER_RADIUS)
                .zip(CORNER_UV)
                .enumerate();
            for (i, (corner, &uv)) in iter {
                let i = i as u32;
                let pos2d = pos.to_real() + corner;
                vertices.push(Vertex {
                    position: [pos2d.x, pos2d.y, height.to_real()],
                    normal: normal,
                    radius: 1.0,
                    tex_coords: uv,
                    material_color: sec.ground.get_color(),
                    ground: ground,
                });
                if rev {
                    indices.push(prev_len);
                    indices.push(prev_len + ((i + 1) % 6) + 1);
                    indices.push(prev_len + i + 1);
                } else {
                    indices.push(prev_len);
                    indices.push(prev_len + i + 1);
                    indices.push(prev_len + ((i + 1) % 6) + 1);
                }
            }
        }
    }
}
fn add_top_and_bottom_face ( pos : AxialPoint , pillar : & HexPillar , vertices : & mut Vec < Vertex > , indices : & mut Vec < u32 > , ) { for sec in pillar . sections ( ) { let ground = sec . ground . get_id ( ) ; // Add top and bottom face let face_props = [ ( sec . top , [ 0.0 , 0.0 , 1.0 ] , false ) , ( sec . bottom , [ 0.0 , 0.0 , - 1.0 ] , true ) , ] ; for & ( height , normal , rev ) in & face_props { let prev_len = vertices . len ( ) as u32 ; // We completely skip all faces at height 0 if height . units ( ) == 0 { continue ; } // Add center point vertices . push ( Vertex { position : [ pos . to_real ( ) . x , pos . to_real ( ) . y , height . to_real ( ) ] , normal : normal , radius : 0.0 , tex_coords : [ 0.5 , 0.5 ] , material_color : sec . ground . get_color ( ) , ground : ground , } ) ; // Iterate over all corners with position and uv coordinates let iter = NORM_CORNERS . iter ( ) . map ( | c | c * HEX_OUTER_RADIUS ) . zip ( CORNER_UV ) . enumerate ( ) ; for ( i , ( corner , & uv ) ) in iter { let i = i as u32 ; let pos2d = pos . to_real ( ) + corner ; vertices . push ( Vertex { position : [ pos2d . x , pos2d . y , height . to_real ( ) ] , normal : normal , radius : 1.0 , tex_coords : uv , material_color : sec . ground . get_color ( ) , ground : ground , } ) ; if rev { indices . push ( prev_len ) ; indices . push ( prev_len + ( ( i + 1 ) % 6 ) + 1 ) ; indices . push ( prev_len + i + 1 ) ; } else { indices . push ( prev_len ) ; indices . push ( prev_len + i + 1 ) ; indices . push ( prev_len + ( ( i + 1 ) % 6 ) + 1 ) ; } } } } }
Adds the top and bottom face for every section in a pillar, but completely
ignores all faces at height 0.
Adds the top and bottom face for every section in a pillar but completely ignores all faces at height 0 .
pos
AxialPoint
pillar
&HexPillar
vertices
&mut Vec<Vertex>
indices
&mut Vec<u32>