From db4350f4f62bc126e92dff2ee92c1b420ce424c0 Mon Sep 17 00:00:00 2001 From: Kevin Reid Date: Mon, 5 Aug 2024 12:39:45 -0700 Subject: [PATCH] Update `size_hint` for `Evoxels`. Should have been in 57c383da4147d8d19b19368274fdac5195e1d607. --- all-is-cubes/src/block/eval/voxel_storage.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/all-is-cubes/src/block/eval/voxel_storage.rs b/all-is-cubes/src/block/eval/voxel_storage.rs index 586264850..b446959fe 100644 --- a/all-is-cubes/src/block/eval/voxel_storage.rs +++ b/all-is-cubes/src/block/eval/voxel_storage.rs @@ -313,13 +313,21 @@ impl<'a> arbitrary::Arbitrary<'a> for Evoxels { } fn size_hint(depth: usize) -> (usize, Option) { - arbitrary::size_hint::and_all(&[ + use crate::math::GridCoordinate; + + let max_data_size = GridAab::for_block(Resolution::MAX).volume().unwrap() + * Evoxel::size_hint(depth).1.unwrap(); + + arbitrary::size_hint::and( Resolution::size_hint(depth), arbitrary::size_hint::or( - Evoxel::size_hint(depth), - Vol::>::size_hint(depth), + Evoxel::size_hint(depth), // single-voxel case + arbitrary::size_hint::and( + (3, Some(size_of::() * 6)), // variable size of bounds choice + (0, Some(max_data_size)), // data + ), ), - ]) + ) } }