2019-05-17 17:54:56 +00:00
|
|
|
use super::{block::Block, TerrainChunkMeta, TerrainChunkSize};
|
2019-05-17 17:44:30 +00:00
|
|
|
use crate::{
|
common: Rework volume API
See the doc comments in `common/src/vol.rs` for more information on
the API itself.
The changes include:
* Consistent `Err`/`Error` naming.
* Types are named `...Error`.
* `enum` variants are named `...Err`.
* Rename `VolMap{2d, 3d}` -> `VolGrid{2d, 3d}`. This is in preparation
to an upcoming change where a “map” in the game related sense will
be added.
* Add volume iterators. There are two types of them:
* _Position_ iterators obtained from the trait `IntoPosIterator`
using the method
`fn pos_iter(self, lower_bound: Vec3<i32>, upper_bound: Vec3<i32>) -> ...`
which returns an iterator over `Vec3<i32>`.
* _Volume_ iterators obtained from the trait `IntoVolIterator`
using the method
`fn vol_iter(self, lower_bound: Vec3<i32>, upper_bound: Vec3<i32>) -> ...`
which returns an iterator over `(Vec3<i32>, &Self::Vox)`.
Those traits will usually be implemented by references to volume
types (i.e. `impl IntoVolIterator<'a> for &'a T` where `T` is some
type which usually implements several volume traits, such as `Chunk`).
* _Position_ iterators iterate over the positions valid for that
volume.
* _Volume_ iterators do the same but return not only the position
but also the voxel at that position, in each iteration.
* Introduce trait `RectSizedVol` for the use case which we have with
`Chonk`: A `Chonk` is sized only in x and y direction.
* Introduce traits `RasterableVol`, `RectRasterableVol`
* `RasterableVol` represents a volume that is compile-time sized and has
its lower bound at `(0, 0, 0)`. The name `RasterableVol` was chosen
because such a volume can be used with `VolGrid3d`.
* `RectRasterableVol` represents a volume that is compile-time sized at
least in x and y direction and has its lower bound at `(0, 0, z)`.
There's no requirement on he lower bound or size in z direction.
The name `RectRasterableVol` was chosen because such a volume can be
used with `VolGrid2d`.
2019-09-03 22:23:29 +00:00
|
|
|
vol::{BaseVol, ReadVol, RectRasterableVol, RectVolSize, VolSize, WriteVol},
|
|
|
|
volumes::chunk::{Chunk, ChunkError},
|
2019-05-17 17:44:30 +00:00
|
|
|
};
|
2019-08-11 20:38:28 +00:00
|
|
|
use hashbrown::HashMap;
|
2019-05-17 17:54:56 +00:00
|
|
|
use serde_derive::{Deserialize, Serialize};
|
2019-06-06 14:48:41 +00:00
|
|
|
use std::ops::Add;
|
2019-05-25 05:54:47 +00:00
|
|
|
use vek::*;
|
2019-05-17 17:44:30 +00:00
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum ChonkError {
|
common: Rework volume API
See the doc comments in `common/src/vol.rs` for more information on
the API itself.
The changes include:
* Consistent `Err`/`Error` naming.
* Types are named `...Error`.
* `enum` variants are named `...Err`.
* Rename `VolMap{2d, 3d}` -> `VolGrid{2d, 3d}`. This is in preparation
to an upcoming change where a “map” in the game related sense will
be added.
* Add volume iterators. There are two types of them:
* _Position_ iterators obtained from the trait `IntoPosIterator`
using the method
`fn pos_iter(self, lower_bound: Vec3<i32>, upper_bound: Vec3<i32>) -> ...`
which returns an iterator over `Vec3<i32>`.
* _Volume_ iterators obtained from the trait `IntoVolIterator`
using the method
`fn vol_iter(self, lower_bound: Vec3<i32>, upper_bound: Vec3<i32>) -> ...`
which returns an iterator over `(Vec3<i32>, &Self::Vox)`.
Those traits will usually be implemented by references to volume
types (i.e. `impl IntoVolIterator<'a> for &'a T` where `T` is some
type which usually implements several volume traits, such as `Chunk`).
* _Position_ iterators iterate over the positions valid for that
volume.
* _Volume_ iterators do the same but return not only the position
but also the voxel at that position, in each iteration.
* Introduce trait `RectSizedVol` for the use case which we have with
`Chonk`: A `Chonk` is sized only in x and y direction.
* Introduce traits `RasterableVol`, `RectRasterableVol`
* `RasterableVol` represents a volume that is compile-time sized and has
its lower bound at `(0, 0, 0)`. The name `RasterableVol` was chosen
because such a volume can be used with `VolGrid3d`.
* `RectRasterableVol` represents a volume that is compile-time sized at
least in x and y direction and has its lower bound at `(0, 0, z)`.
There's no requirement on he lower bound or size in z direction.
The name `RectRasterableVol` was chosen because such a volume can be
used with `VolGrid2d`.
2019-09-03 22:23:29 +00:00
|
|
|
ChunkError(ChunkError),
|
2019-05-17 17:44:30 +00:00
|
|
|
OutOfBounds,
|
|
|
|
}
|
|
|
|
|
2019-05-21 22:04:39 +00:00
|
|
|
const SUB_CHUNK_HEIGHT: u32 = 16;
|
2019-05-20 02:53:04 +00:00
|
|
|
|
2019-08-15 00:10:56 +00:00
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
|
|
pub struct SubChunkSize;
|
|
|
|
|
|
|
|
impl VolSize for SubChunkSize {
|
|
|
|
const SIZE: Vec3<u32> = Vec3 {
|
common: Rework volume API
See the doc comments in `common/src/vol.rs` for more information on
the API itself.
The changes include:
* Consistent `Err`/`Error` naming.
* Types are named `...Error`.
* `enum` variants are named `...Err`.
* Rename `VolMap{2d, 3d}` -> `VolGrid{2d, 3d}`. This is in preparation
to an upcoming change where a “map” in the game related sense will
be added.
* Add volume iterators. There are two types of them:
* _Position_ iterators obtained from the trait `IntoPosIterator`
using the method
`fn pos_iter(self, lower_bound: Vec3<i32>, upper_bound: Vec3<i32>) -> ...`
which returns an iterator over `Vec3<i32>`.
* _Volume_ iterators obtained from the trait `IntoVolIterator`
using the method
`fn vol_iter(self, lower_bound: Vec3<i32>, upper_bound: Vec3<i32>) -> ...`
which returns an iterator over `(Vec3<i32>, &Self::Vox)`.
Those traits will usually be implemented by references to volume
types (i.e. `impl IntoVolIterator<'a> for &'a T` where `T` is some
type which usually implements several volume traits, such as `Chunk`).
* _Position_ iterators iterate over the positions valid for that
volume.
* _Volume_ iterators do the same but return not only the position
but also the voxel at that position, in each iteration.
* Introduce trait `RectSizedVol` for the use case which we have with
`Chonk`: A `Chonk` is sized only in x and y direction.
* Introduce traits `RasterableVol`, `RectRasterableVol`
* `RasterableVol` represents a volume that is compile-time sized and has
its lower bound at `(0, 0, 0)`. The name `RasterableVol` was chosen
because such a volume can be used with `VolGrid3d`.
* `RectRasterableVol` represents a volume that is compile-time sized at
least in x and y direction and has its lower bound at `(0, 0, z)`.
There's no requirement on he lower bound or size in z direction.
The name `RectRasterableVol` was chosen because such a volume can be
used with `VolGrid2d`.
2019-09-03 22:23:29 +00:00
|
|
|
x: TerrainChunkSize::RECT_SIZE.x,
|
|
|
|
y: TerrainChunkSize::RECT_SIZE.y,
|
2019-08-15 00:10:56 +00:00
|
|
|
z: SUB_CHUNK_HEIGHT,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
const SUB_CHUNK_HASH_LIMIT: usize =
|
|
|
|
(SubChunkSize::SIZE.x * SubChunkSize::SIZE.y * SubChunkSize::SIZE.z) as usize / 4;
|
|
|
|
|
2019-05-17 17:44:30 +00:00
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
|
|
pub struct Chonk {
|
|
|
|
z_offset: i32,
|
|
|
|
sub_chunks: Vec<SubChunk>,
|
|
|
|
below: Block,
|
|
|
|
above: Block,
|
|
|
|
meta: TerrainChunkMeta,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Chonk {
|
|
|
|
pub fn new(z_offset: i32, below: Block, above: Block, meta: TerrainChunkMeta) -> Self {
|
|
|
|
Self {
|
|
|
|
z_offset,
|
|
|
|
sub_chunks: Vec::new(),
|
|
|
|
below,
|
|
|
|
above,
|
|
|
|
meta,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-11 18:39:25 +00:00
|
|
|
pub fn meta(&self) -> &TerrainChunkMeta {
|
|
|
|
&self.meta
|
|
|
|
}
|
|
|
|
|
2019-06-04 17:19:40 +00:00
|
|
|
pub fn get_min_z(&self) -> i32 {
|
2019-05-17 21:19:32 +00:00
|
|
|
self.z_offset
|
|
|
|
}
|
|
|
|
|
2019-06-04 17:19:40 +00:00
|
|
|
pub fn get_max_z(&self) -> i32 {
|
2019-05-20 02:53:04 +00:00
|
|
|
self.z_offset + (self.sub_chunks.len() as u32 * SUB_CHUNK_HEIGHT) as i32
|
2019-05-17 21:19:32 +00:00
|
|
|
}
|
|
|
|
|
2019-06-04 12:45:41 +00:00
|
|
|
pub fn get_metrics(&self) -> ChonkMetrics {
|
|
|
|
ChonkMetrics {
|
|
|
|
chonks: 1,
|
2019-06-04 12:49:57 +00:00
|
|
|
homogeneous: self
|
|
|
|
.sub_chunks
|
2019-06-04 12:45:41 +00:00
|
|
|
.iter()
|
2019-06-04 12:49:57 +00:00
|
|
|
.filter(|s| match s {
|
|
|
|
SubChunk::Homogeneous(_) => true,
|
|
|
|
_ => false,
|
|
|
|
})
|
2019-06-04 12:45:41 +00:00
|
|
|
.count(),
|
2019-06-04 12:49:57 +00:00
|
|
|
hash: self
|
|
|
|
.sub_chunks
|
2019-06-04 12:45:41 +00:00
|
|
|
.iter()
|
2019-06-04 12:49:57 +00:00
|
|
|
.filter(|s| match s {
|
|
|
|
SubChunk::Hash(_, _) => true,
|
|
|
|
_ => false,
|
|
|
|
})
|
2019-06-04 12:45:41 +00:00
|
|
|
.count(),
|
2019-06-04 12:49:57 +00:00
|
|
|
heterogeneous: self
|
|
|
|
.sub_chunks
|
2019-06-04 12:45:41 +00:00
|
|
|
.iter()
|
2019-06-04 12:49:57 +00:00
|
|
|
.filter(|s| match s {
|
|
|
|
SubChunk::Heterogeneous(_) => true,
|
|
|
|
_ => false,
|
|
|
|
})
|
2019-06-04 12:45:41 +00:00
|
|
|
.count(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-15 02:18:51 +00:00
|
|
|
// Returns the index (in self.sub_chunks) of the SubChunk that contains
|
|
|
|
// layer z; note that this index changes when more SubChunks are prepended
|
2019-05-17 17:44:30 +00:00
|
|
|
fn sub_chunk_idx(&self, z: i32) -> usize {
|
2019-08-15 02:18:51 +00:00
|
|
|
((z - self.z_offset) / SUB_CHUNK_HEIGHT as i32) as usize
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns the z_offset of the sub_chunk that contains layer z
|
|
|
|
fn sub_chunk_z_offset(&self, z: i32) -> i32 {
|
|
|
|
let rem = (z - self.z_offset) % SUB_CHUNK_HEIGHT as i32;
|
|
|
|
if rem < 0 {
|
|
|
|
z - (rem + SUB_CHUNK_HEIGHT as i32)
|
|
|
|
} else {
|
|
|
|
z - rem
|
|
|
|
}
|
2019-05-17 17:44:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl BaseVol for Chonk {
|
|
|
|
type Vox = Block;
|
common: Rework volume API
See the doc comments in `common/src/vol.rs` for more information on
the API itself.
The changes include:
* Consistent `Err`/`Error` naming.
* Types are named `...Error`.
* `enum` variants are named `...Err`.
* Rename `VolMap{2d, 3d}` -> `VolGrid{2d, 3d}`. This is in preparation
to an upcoming change where a “map” in the game related sense will
be added.
* Add volume iterators. There are two types of them:
* _Position_ iterators obtained from the trait `IntoPosIterator`
using the method
`fn pos_iter(self, lower_bound: Vec3<i32>, upper_bound: Vec3<i32>) -> ...`
which returns an iterator over `Vec3<i32>`.
* _Volume_ iterators obtained from the trait `IntoVolIterator`
using the method
`fn vol_iter(self, lower_bound: Vec3<i32>, upper_bound: Vec3<i32>) -> ...`
which returns an iterator over `(Vec3<i32>, &Self::Vox)`.
Those traits will usually be implemented by references to volume
types (i.e. `impl IntoVolIterator<'a> for &'a T` where `T` is some
type which usually implements several volume traits, such as `Chunk`).
* _Position_ iterators iterate over the positions valid for that
volume.
* _Volume_ iterators do the same but return not only the position
but also the voxel at that position, in each iteration.
* Introduce trait `RectSizedVol` for the use case which we have with
`Chonk`: A `Chonk` is sized only in x and y direction.
* Introduce traits `RasterableVol`, `RectRasterableVol`
* `RasterableVol` represents a volume that is compile-time sized and has
its lower bound at `(0, 0, 0)`. The name `RasterableVol` was chosen
because such a volume can be used with `VolGrid3d`.
* `RectRasterableVol` represents a volume that is compile-time sized at
least in x and y direction and has its lower bound at `(0, 0, z)`.
There's no requirement on he lower bound or size in z direction.
The name `RectRasterableVol` was chosen because such a volume can be
used with `VolGrid2d`.
2019-09-03 22:23:29 +00:00
|
|
|
type Error = ChonkError;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl RectRasterableVol for Chonk {
|
|
|
|
const RECT_SIZE: Vec2<u32> = TerrainChunkSize::RECT_SIZE;
|
2019-05-17 17:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl ReadVol for Chonk {
|
|
|
|
#[inline(always)]
|
|
|
|
fn get(&self, pos: Vec3<i32>) -> Result<&Block, ChonkError> {
|
2019-08-14 20:12:01 +00:00
|
|
|
if pos.z < self.get_min_z() {
|
2019-05-17 17:44:30 +00:00
|
|
|
// Below the terrain
|
|
|
|
Ok(&self.below)
|
2019-08-14 20:12:01 +00:00
|
|
|
} else if pos.z >= self.get_max_z() {
|
2019-05-17 17:44:30 +00:00
|
|
|
// Above the terrain
|
|
|
|
Ok(&self.above)
|
|
|
|
} else {
|
|
|
|
// Within the terrain
|
|
|
|
|
|
|
|
let sub_chunk_idx = self.sub_chunk_idx(pos.z);
|
|
|
|
|
2019-05-17 17:54:56 +00:00
|
|
|
match &self.sub_chunks[sub_chunk_idx] {
|
|
|
|
// Can't fail
|
2019-05-17 17:44:30 +00:00
|
|
|
SubChunk::Homogeneous(block) => Ok(block),
|
2019-05-22 13:22:54 +00:00
|
|
|
SubChunk::Hash(cblock, map) => {
|
|
|
|
let rpos = pos
|
|
|
|
- Vec3::unit_z()
|
|
|
|
* (self.z_offset + sub_chunk_idx as i32 * SUB_CHUNK_HEIGHT as i32);
|
|
|
|
|
2019-06-04 12:45:41 +00:00
|
|
|
Ok(map.get(&rpos.map(|e| e as u8)).unwrap_or(cblock))
|
2019-05-25 05:54:47 +00:00
|
|
|
}
|
2019-05-17 17:44:30 +00:00
|
|
|
SubChunk::Heterogeneous(chunk) => {
|
2019-05-17 17:54:56 +00:00
|
|
|
let rpos = pos
|
|
|
|
- Vec3::unit_z()
|
2019-05-21 22:31:38 +00:00
|
|
|
* (self.z_offset + sub_chunk_idx as i32 * SUB_CHUNK_HEIGHT as i32);
|
2019-05-22 13:22:54 +00:00
|
|
|
|
2019-07-01 20:42:43 +00:00
|
|
|
chunk.get(rpos).map_err(ChonkError::ChunkError)
|
2019-05-17 17:54:56 +00:00
|
|
|
}
|
2019-05-17 17:44:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl WriteVol for Chonk {
|
|
|
|
#[inline(always)]
|
|
|
|
fn set(&mut self, pos: Vec3<i32>, block: Block) -> Result<(), ChonkError> {
|
2019-08-15 02:18:51 +00:00
|
|
|
if pos.z < self.get_min_z() {
|
|
|
|
// Prepend exactly sufficiently many SubChunks via Vec::splice
|
|
|
|
let target_z_offset = self.sub_chunk_z_offset(pos.z);
|
|
|
|
let c = SubChunk::Homogeneous(self.below);
|
|
|
|
let n = (self.get_min_z() - target_z_offset) / SUB_CHUNK_HEIGHT as i32;
|
|
|
|
self.sub_chunks
|
|
|
|
.splice(0..0, std::iter::repeat(c).take(n as usize));
|
|
|
|
self.z_offset = target_z_offset;
|
|
|
|
} else if pos.z >= self.get_max_z() {
|
|
|
|
// Append exactly sufficiently many SubChunks via Vec::extend
|
|
|
|
let target_z_offset = self.sub_chunk_z_offset(pos.z);
|
|
|
|
let c = SubChunk::Homogeneous(self.above);
|
|
|
|
let n = (target_z_offset - self.get_max_z()) / SUB_CHUNK_HEIGHT as i32 + 1;
|
|
|
|
self.sub_chunks
|
|
|
|
.extend(std::iter::repeat(c).take(n as usize));
|
2019-06-04 12:45:41 +00:00
|
|
|
}
|
2019-05-17 17:44:30 +00:00
|
|
|
|
2019-06-04 12:45:41 +00:00
|
|
|
let sub_chunk_idx = self.sub_chunk_idx(pos.z);
|
2019-05-17 17:44:30 +00:00
|
|
|
|
2019-06-04 12:49:57 +00:00
|
|
|
let rpos =
|
|
|
|
pos - Vec3::unit_z() * (self.z_offset + sub_chunk_idx as i32 * SUB_CHUNK_HEIGHT as i32);
|
2019-06-04 12:45:41 +00:00
|
|
|
|
|
|
|
match &mut self.sub_chunks[sub_chunk_idx] {
|
|
|
|
// Can't fail
|
|
|
|
SubChunk::Homogeneous(cblock) if block == *cblock => Ok(()),
|
|
|
|
SubChunk::Homogeneous(cblock) => {
|
2019-08-11 20:38:28 +00:00
|
|
|
let mut map = HashMap::default();
|
2019-06-04 12:45:41 +00:00
|
|
|
map.insert(rpos.map(|e| e as u8), block);
|
|
|
|
|
|
|
|
self.sub_chunks[sub_chunk_idx] = SubChunk::Hash(*cblock, map);
|
|
|
|
Ok(())
|
2019-06-04 12:49:57 +00:00
|
|
|
}
|
2019-07-01 13:36:45 +00:00
|
|
|
SubChunk::Hash(cblock, map) if block == *cblock => {
|
|
|
|
map.remove(&rpos.map(|e| e as u8));
|
|
|
|
Ok(())
|
2019-07-01 13:38:45 +00:00
|
|
|
}
|
2019-08-15 00:10:56 +00:00
|
|
|
SubChunk::Hash(_cblock, map) if map.len() < SUB_CHUNK_HASH_LIMIT => {
|
2019-06-04 12:45:41 +00:00
|
|
|
map.insert(rpos.map(|e| e as u8), block);
|
|
|
|
Ok(())
|
2019-06-04 12:49:57 +00:00
|
|
|
}
|
2019-06-04 12:45:41 +00:00
|
|
|
SubChunk::Hash(cblock, map) => {
|
|
|
|
let mut new_chunk = Chunk::filled(*cblock, ());
|
|
|
|
for (map_pos, map_block) in map {
|
2019-06-04 12:49:57 +00:00
|
|
|
new_chunk
|
2019-07-01 20:42:43 +00:00
|
|
|
.set(map_pos.map(|e| i32::from(e)), *map_block)
|
2019-06-04 12:49:57 +00:00
|
|
|
.unwrap(); // Can't fail (I hope!)
|
2019-05-25 05:54:47 +00:00
|
|
|
}
|
2019-05-22 13:22:54 +00:00
|
|
|
|
2019-07-01 13:36:45 +00:00
|
|
|
new_chunk.set(rpos, block).unwrap(); // Can't fail (I hope)
|
|
|
|
|
2019-06-04 12:45:41 +00:00
|
|
|
self.sub_chunks[sub_chunk_idx] = SubChunk::Heterogeneous(new_chunk);
|
|
|
|
Ok(())
|
2019-06-04 12:49:57 +00:00
|
|
|
}
|
2019-05-22 13:22:54 +00:00
|
|
|
|
2019-06-04 12:45:41 +00:00
|
|
|
/*
|
|
|
|
SubChunk::Homogeneous(cblock) => {
|
|
|
|
let mut new_chunk = Chunk::filled(*cblock, ());
|
2019-05-22 16:24:08 +00:00
|
|
|
|
2019-06-04 12:45:41 +00:00
|
|
|
new_chunk.set(rpos, block).unwrap(); // Can't fail (I hope!)
|
2019-05-22 16:24:08 +00:00
|
|
|
|
2019-06-04 12:45:41 +00:00
|
|
|
self.sub_chunks[sub_chunk_idx] = SubChunk::Heterogeneous(new_chunk);
|
|
|
|
Ok(())
|
2019-05-17 17:44:30 +00:00
|
|
|
}
|
2019-06-04 12:45:41 +00:00
|
|
|
*/
|
2019-07-01 20:42:43 +00:00
|
|
|
SubChunk::Heterogeneous(chunk) => {
|
|
|
|
chunk.set(rpos, block).map_err(ChonkError::ChunkError)
|
2019-07-02 21:25:07 +00:00
|
|
|
} //_ => unimplemented!(),
|
2019-05-17 17:44:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
|
|
pub enum SubChunk {
|
|
|
|
Homogeneous(Block),
|
2019-08-11 20:38:28 +00:00
|
|
|
Hash(Block, HashMap<Vec3<u8>, Block>),
|
2019-07-01 13:36:45 +00:00
|
|
|
Heterogeneous(Chunk<Block, SubChunkSize, ()>),
|
2019-05-17 17:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl SubChunk {
|
|
|
|
pub fn filled(block: Block) -> Self {
|
|
|
|
SubChunk::Homogeneous(block)
|
|
|
|
}
|
|
|
|
}
|
2019-06-04 12:45:41 +00:00
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct ChonkMetrics {
|
|
|
|
chonks: usize,
|
|
|
|
homogeneous: usize,
|
|
|
|
hash: usize,
|
|
|
|
heterogeneous: usize,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for ChonkMetrics {
|
|
|
|
fn default() -> Self {
|
|
|
|
ChonkMetrics {
|
|
|
|
chonks: 0,
|
|
|
|
homogeneous: 0,
|
|
|
|
hash: 0,
|
|
|
|
heterogeneous: 0,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Add for ChonkMetrics {
|
|
|
|
type Output = Self;
|
|
|
|
|
|
|
|
fn add(self, other: Self::Output) -> Self {
|
|
|
|
Self::Output {
|
|
|
|
chonks: self.chonks + other.chonks,
|
|
|
|
homogeneous: self.homogeneous + other.homogeneous,
|
|
|
|
hash: self.hash + other.hash,
|
|
|
|
heterogeneous: self.heterogeneous + other.heterogeneous,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|