vixel icon indicating copy to clipboard operation
vixel copied to clipboard

Use more compact keys, prefer Map to Object

Open perliedman opened this issue 5 years ago • 2 comments

Hi, first off let me just thank you for an amazing project! I've had so much fun rendering voxel landscapes, a breeze to get started with this. Of course I more or less immediately started to push this to its limits, and encountered some problems when generating large maps.

I think I found some potential improvements:

  • Most importantly, using ES6 Map instead of Object to store the voxels and their index appears to be much faster
  • I also made some changes regarding how keys are generated, preferring integers (as much as they exist in JavaScript...) or at least shorter strings as keys to the maps
  • Material information was duplicated in the Stage as well as in the VoxelIndex, so I replaced this with a reference from the Stage to the VoxelIndex, which saves memory

Using this, I have shaved off something like 40% of the heap size when I generate a 512x32x512 Vixel, and time to initialize the map is down from 8 seconds to 6.7, which is not as significant but at least better.

Hope you can find some use for these changes!

perliedman avatar Dec 10 '19 20:12 perliedman

@perliedman Thank you for these. Sorry it's taken me a year and a half to take a look. I'll see about integrating them.

wwwtyro avatar May 29 '21 18:05 wwwtyro

No worries, I'm more than familiar with the feeling :sweat_smile:

perliedman avatar Jun 11 '21 11:06 perliedman