Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.

building-blocks v0.7.0

Latest
Compare
Choose a tag to compare
@bonsairobo bonsairobo released this 14 Jun 15:25
· 356 commits to main since this release

Development Status Update

v0.7.0 is a modest release, but it does have some major API changes that I wanted to get out before taking a deep dive into any new features.

Release Highlights

Removal of ChunkPyramid

You might remember that a ChunkPyramid was added in v0.6.0 for supporting chunk downsampling. Well, it's gone now! Instead, you can just use a ChunkMap for everything that the ChunkPyramid used to do. This just means that now chunk storages are keyed on ChunkKey, which contains a level of detail.

As a result, now many of the ChunkMap methods have changed to require an lod: u8 parameter. And the access trait impls have moved onto a wrapper called the ChunkMapLodView. This means you can do all of the normal access trait stuff on a single LOD at a time.

map.lod_view(0).for_each(...);

Along with this change, I made it so that the ChunkDownsampler can support multichannel Src and Dst chunk types. There aren't currently any users of this feature, but it should be as simple as combining some existing ChunkDownsamplers and applying one to each channel.

borrow_channels

After using the new multichannel arrays for some time, it became apparent that we need a more convenient way of interacting with just a subset of channels. Technically, you could use the TransformMap for this, but it wasn't the most ergonomic option. Now, Array has two new methods: borrow_channels and borrow_channels_mut. They can be used like so:

let mut a = Array3x3::fill(extent, (0.0, 0, 'a'));
// Type annotation not required, just used for educational purpose.
let mut borrow: Array3x2<char, f32, &mut [char], &mut [f32]> = a.borrow_channels_mut(|(f, _, c)| (f, c));

And then borrow is a single channel array that can be used like any other. It implements all of the access traits.

Lockstep array iteration and downsampling perf improvements

Some improvements have been made to the Array iteration code. Now, via the ArrayForEach and LockStepArrayForEach types, you can iterate over the strides for two arrays in lockstep. They also support a step parameter which allows for stepping through arrays at different intervals, which is useful when sampling from arrays at different resolutions. These new types have been used to rewrite the PointDownsampler and SdfMeanDownsampler, giving a 2x perf improvement in the bechmarks.

lod_terrain example works with blocky and smooth voxels

Now you can run the lod_terrain example with either blocky or smooth voxels. You just need to provide a CLI argument of "blocky" or "smooth".

Also, all of the examples have moved into their own crate outside of the root workspace, so you need to cd examples before running them. This was done to avoid pulling in bevy as a dev-dependency when building tests and benchmarks.

Other Changes

Additions

  • FillExtent trait
  • delete and pop methods for ChunkWriteStorage

Modifications

  • bug fixes in the clipmap module; several unit tests added
  • collision module of the building_blocks_search crate had some API renames
  • OctreeSet now respects VisitStatus::Stop in post-order traversals
  • OctreeSet method names have a new "fat" vs "thin" leaf concept
  • renamed OctreeDBVT to OctreeDbvt

Benchmark Results

These results come from running cargo bench --all on my PC with an Intel i5-4590 3.3 GHz CPU, using the stable rust v1.52 toolchain and thin LTO enabled. All benchmarks are single-threaded.

SHOW RESULTS

greedy_quads_terrace/8  time:   [9.4202 us 9.4465 us 9.4744 us]                                    
greedy_quads_terrace/16 time:   [53.374 us 53.545 us 53.735 us]                                    
greedy_quads_terrace/32 time:   [388.80 us 389.58 us 390.43 us]                                    
greedy_quads_terrace/64 time:   [3.0510 ms 3.0583 ms 3.0667 ms]                                    

height_map_plane/8      time:   [725.52 ns 726.56 ns 727.64 ns]                                
height_map_plane/16     time:   [2.8329 us 2.8407 us 2.8496 us]                                 
height_map_plane/32     time:   [11.822 us 11.853 us 11.890 us]                                 
height_map_plane/64     time:   [49.684 us 49.964 us 50.270 us]                                

surface_nets_sine_sdf/8 time:   [15.828 us 15.952 us 16.082 us]                                     
surface_nets_sine_sdf/16                                                                            
                        time:   [166.98 us 167.42 us 167.92 us]
surface_nets_sine_sdf/32                        
                        time:   [1.1799 ms 1.1831 ms 1.1866 ms]
surface_nets_sine_sdf/64                                                                            
                        time:   [9.9171 ms 9.9553 ms 9.9949 ms]

sphere_surface/8        time:   [1.2471 us 1.2492 us 1.2514 us]                              
sphere_surface/16       time:   [11.169 us 11.185 us 11.202 us]                               
sphere_surface/32       time:   [98.618 us 98.776 us 98.944 us]                              

flood_fill_sphere/16    time:   [32.166 us 32.220 us 32.280 us]                                  
flood_fill_sphere/32    time:   [268.58 us 269.05 us 269.52 us]                                 
flood_fill_sphere/64    time:   [1.9838 ms 1.9876 ms 1.9916 ms]                                  

array_for_each/16       time:   [1.7152 us 1.7187 us 1.7226 us]                               
array_for_each/32       time:   [17.812 us 17.880 us 17.947 us]                               
array_for_each/64       time:   [150.12 us 150.82 us 151.61 us]                              

array_for_each_point/16 time:   [2.4739 us 2.4797 us 2.4858 us]                                     
array_for_each_point/32 time:   [22.124 us 22.171 us 22.220 us]                                     
array_for_each_point/64 time:   [192.28 us 192.86 us 193.58 us]                                    

array_for_each_point_and_stride/16                        
                        time:   [3.9797 us 3.9892 us 4.0013 us]
array_for_each_point_and_stride/32                        
                        time:   [35.803 us 35.887 us 35.981 us]
array_for_each_point_and_stride/64                        
                        time:   [304.04 us 304.63 us 305.24 us]

array_point_indexing/16 time:   [10.691 us 10.707 us 10.724 us]                                     
array_point_indexing/32 time:   [100.41 us 100.87 us 101.30 us]                                    
array_point_indexing/64 time:   [835.65 us 837.50 us 839.67 us]                                    

array_copy/16           time:   [1.6250 us 1.6285 us 1.6321 us]                           
array_copy/32           time:   [16.360 us 16.400 us 16.447 us]                           
array_copy/64           time:   [419.59 us 420.45 us 421.35 us]                          

chunk_hash_map_for_each_point/16                        
                        time:   [4.3827 us 4.3922 us 4.4024 us]
chunk_hash_map_for_each_point/32                        
                        time:   [34.692 us 34.820 us 34.960 us]
chunk_hash_map_for_each_point/64                        
                        time:   [278.21 us 279.76 us 281.59 us]

chunk_hash_map_point_indexing/16                        
                        time:   [62.184 us 62.364 us 62.560 us]
chunk_hash_map_point_indexing/32                        
                        time:   [481.83 us 482.77 us 483.86 us]
chunk_hash_map_point_indexing/64                        
                        time:   [3.8085 ms 3.8159 ms 3.8236 ms]

chunk_hash_map_visit_chunks_sparse/128                        
                        time:   [8.4282 us 8.4485 us 8.4701 us]
chunk_hash_map_visit_chunks_sparse/256                        
                        time:   [179.92 us 183.50 us 187.06 us]
chunk_hash_map_visit_chunks_sparse/512                        
                        time:   [1.5100 ms 1.5337 ms 1.5576 ms]

chunk_hash_map_copy/16  time:   [973.24 ns 975.79 ns 978.56 ns]                                    
chunk_hash_map_copy/32  time:   [9.6658 us 9.7510 us 9.8324 us]                                    
chunk_hash_map_copy/64  time:   [82.749 us 83.486 us 84.364 us]                                   

compressible_chunk_map_point_indexing/16                        
                        time:   [72.292 us 72.756 us 73.223 us]
compressible_chunk_map_point_indexing/32                        
                        time:   [547.20 us 548.71 us 550.51 us]
compressible_chunk_map_point_indexing/64                        
                        time:   [4.3927 ms 4.4007 ms 4.4087 ms]


decompress_array_with_bincode_lz4/16                        
                        time:   [13.079 us 13.118 us 13.165 us]
decompress_array_with_bincode_lz4/32                        
                        time:   [98.359 us 98.610 us 98.864 us]
decompress_array_with_bincode_lz4/64                        
                        time:   [817.73 us 821.12 us 824.67 us]

decompress_array_with_fast_lz4/16                        
                        time:   [5.3044 us 5.3199 us 5.3369 us]
decompress_array_with_fast_lz4/32                        
                        time:   [32.948 us 33.013 us 33.082 us]
decompress_array_with_fast_lz4/64                        
                        time:   [261.91 us 263.90 us 265.97 us]

decompress_array_with_bincode_snappy/16                        
                        time:   [20.258 us 20.375 us 20.485 us]
decompress_array_with_bincode_snappy/32                        
                        time:   [100.17 us 100.45 us 100.80 us]
decompress_array_with_bincode_snappy/64                        
                        time:   [886.38 us 893.72 us 902.32 us]

decompress_array_with_fast_snappy/16                        
                        time:   [9.5126 us 9.5294 us 9.5463 us]
decompress_array_with_fast_snappy/32                        
                        time:   [39.019 us 39.109 us 39.216 us]
decompress_array_with_fast_snappy/64                        
                        time:   [289.97 us 290.53 us 291.16 us]


octree_from_array3_sphere/16                        
                        time:   [20.519 us 20.634 us 20.763 us]
octree_from_array3_sphere/32                        
                        time:   [152.69 us 153.64 us 154.54 us]
octree_from_array3_sphere/64                        
                        time:   [1.1479 ms 1.1534 ms 1.1589 ms]

ooctree_from_array3_full/16                                                                             
                        time:   [16.194 us 16.275 us 16.354 us]
octree_from_array3_full/32                                                                            
                        time:   [125.56 us 126.01 us 126.49 us]
octree_from_array3_full/64                                                                             
                        time:   [1.0397 ms 1.0480 ms 1.0567 ms]

octree_visit_branches_and_fat_leaves_of_sphere/16                                                                             
                        time:   [3.2587 us 3.2863 us 3.3133 us]
octree_visit_branches_and_fat_leaves_of_sphere/32                                                                            
                        time:   [31.885 us 32.161 us 32.443 us]
octree_visit_branches_and_fat_leaves_of_sphere/64                                                                             
                        time:   [168.96 us 170.09 us 171.30 us]

octree_visit_branch_and_leaf_nodes_of_sphere/16                                                                             
                        time:   [8.4103 us 8.4526 us 8.4923 us]
octree_visit_branch_and_leaf_nodes_of_sphere/32                                                                            
                        time:   [66.250 us 66.741 us 67.227 us]
octree_visit_branch_and_leaf_nodes_of_sphere/64                                                                             
                        time:   [301.55 us 303.59 us 305.69 us]


point_downsample3/16    time:   [334.91 ns 337.31 ns 339.58 ns]                                  
point_downsample3/32    time:   [2.3564 us 2.3721 us 2.3863 us]                                  
point_downsample3/64    time:   [147.84 us 148.10 us 148.41 us]                                 

sdf_mean_downsample3/16 time:   [6.1857 us 6.1956 us 6.2061 us]                                     
sdf_mean_downsample3/32 time:   [49.107 us 49.221 us 49.350 us]                                     
sdf_mean_downsample3/64 time:   [393.04 us 395.37 us 397.82 us]                                    

sdf_mean_downsample_chunk_map_with_index/1                                                                            
                        time:   [33.108 us 33.344 us 33.586 us]
sdf_mean_downsample_chunk_map_with_index/2                                                                            
                        time:   [77.578 us 78.137 us 78.707 us]
sdf_mean_downsample_chunk_map_with_index/4                                                                            
                        time:   [486.28 us 489.62 us 493.10 us]
sdf_mean_downsample_chunk_map_with_index/8                                                                             
                        time:   [3.7063 ms 3.7229 ms 3.7409 ms]