Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use more compact keys, prefer Map to Object #4

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

perliedman
Copy link

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!

@wwwtyro
Copy link
Owner

wwwtyro commented May 29, 2021

@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.

@perliedman
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants