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

Make the Magicavoxel parser load voxels lazily #7

Merged
merged 1 commit into from
Mar 23, 2024

Conversation

DouglasDwyer
Copy link
Contributor

In my engine, I use gvox as follows. I identify chunks of the world (256³ regions) to be loaded, and forward them to background threads. These background threads instantiate a gvox context and adapters, and then do a parser-driven blit for that chunk.

The Magicavoxel adapter, upon instantiation, reads and loads the entire Magicavoxel file into memory as flat arrays. This is very wasteful and leads to computer lag for my use case (the system allocator is heavily burdened), since a bunch of extra models are loaded that fall outside of the 256³ region about which I care.

To fix this, this PR adds lazy loading of Magicavoxel model chunks. The voxels for a model from a Magicavoxel file are not decompressed until that model is read for the first time. This improves performance and eliminates lag spikes for me.

@GabeRundlett
Copy link
Owner

Ignore the checks. This looks good

@GabeRundlett GabeRundlett merged commit 4776a57 into GabeRundlett:master Mar 23, 2024
1 of 3 checks passed
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.

2 participants