Saving Volume meshes edited at runtime

0
paulstraw posted this 07 April 2017

Hey again, this should be my last question for a bit. I'm currently implementing saving/loading of edited Volumes, and I've got the basic functionality working with Frame.ToCompressedByteArray() and Frame.FromCompressedByteArray(). However, for my use case, I'd really like to also save and load the chunk meshes, so I can get around calling Frame.UpdateAllChunks() when I load the Volume data back in. Does this seem sensible? If so, are there any methods I've missed that might help with that sort of thing? Seems like I'll just have to manually iterate over the chunks, correct?

Thanks for all your help!
-paul

Last edited 07 April 2017

2 Comments
Order By: Standard | Newest | Votes
0
GarethIW posted this 07 April 2017

I don't really have an answer for this one as I've never done mesh saving/loading at runtime. PicaVoxel saves edit-time meshes in the MeshStore as assets using AssetDatabase.CreateAsset(), which is an editor call and thus not available at runtime.

I'm curious about why you want to avoid Frame.UpdateAllChunks(). Is it a performance thing or because it destroys and recreates the chunks?

If it's the former, I would suggest testing performance in a build before you get concerned about optimization.

If it's the latter, there are ways around it as along as the size of the volume you're loading is the same size as the one you're loading into. For instance, using UpdateAllChunksNextFrame() will queue up the chunks for threaded regeneration without destroying and recreating the Chunk objects.

Last edited 07 April 2017

0
paulstraw posted this 07 April 2017

It's a performance thing. The volumes I'm saving and loading are quite large (384x160x384), so Frame.UpdateAllChunks() takes a good while.


Our 282 members have posted 390 times in 91 discussions