1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
use crate::{UnorientedQuad, UnorientedUnitQuad};
#[derive(Default)]
pub struct QuadBuffer {
/// A group of quads for each block face. We rely on [`OrientedBlockFace`]
/// metadata to interpret them.
pub groups: [Vec<UnorientedQuad>; 6],
}
impl QuadBuffer {
pub fn new() -> Self {
const EMPTY: Vec<UnorientedQuad> = Vec::new();
Self { groups: [EMPTY; 6] }
}
pub fn reset(&mut self) {
for group in self.groups.iter_mut() {
group.clear();
}
}
/// Returns the total count of quads across all groups.
pub fn num_quads(&self) -> usize {
let mut sum = 0;
for group in self.groups.iter() {
sum += group.len();
}
sum
}
}
#[derive(Default)]
pub struct UnitQuadBuffer {
/// A group of quads for each block face. We rely on [`OrientedBlockFace`]
/// metadata to interpret them.
///
/// When using these values for materials and lighting, you can access them
/// using either the quad's minimum voxel coordinates or the vertex
/// coordinates given by [`OrientedBlockFace::quad_corners`].
pub groups: [Vec<UnorientedUnitQuad>; 6],
}
impl UnitQuadBuffer {
pub fn new() -> Self {
const EMPTY: Vec<UnorientedUnitQuad> = Vec::new();
Self { groups: [EMPTY; 6] }
}
/// Clears the buffer.
pub fn reset(&mut self) {
for group in self.groups.iter_mut() {
group.clear();
}
}
/// Returns the total count of quads across all groups.
pub fn num_quads(&self) -> usize {
let mut sum = 0;
for group in self.groups.iter() {
sum += group.len();
}
sum
}
}