AstrorEnales / blender_magicavoxel

Addon for the Blender 3D modeling software for loading MagicaVoxel VOX files
MIT License
39 stars 5 forks source link

Importing large models can crash Blender #8

Closed ZsoltHevesi closed 9 months ago

ZsoltHevesi commented 9 months ago

When importing large models, Blender can freeze and it either eventually loads, or never does and I have to close Blender, so I kind of have to guess the limit of the amount of cubes I can import at a time. I know I can split the voxels into separate objects and import them as separate files but that kinda works against Greedy Meshing. Is there is a way to circumvent this issue that I'm not aware of?

Either way, I just wanted to say that I have no idea why this isn't the most recommended Voxel add-on for Blender and I'm super thankful. Preserving Material IDs while using Greedy Meshing is something that's essential to my current project and I was almost convinced no one has made a tool that combined both. This is incredible!

AstrorEnales commented 9 months ago

Thank you very much for your kind words! When you say large models, can you tell me how large you mean? Blender is sadly somewhat slow in some parts, especially when importing individual cubes, but from your description i guess you use the greedy meshing mode. I will investigate what may be improved and also try to find a solution for blender not to freeze and maybe show a progress bar (the importer is still running in the background when blender freezes and will eventually finish). If you are willing, it would be easier to test if you could provide me with a vox file that caused the problem.

ZsoltHevesi commented 9 months ago

Yeah, my models are BIG. My current limit is 255 cubed. The project I'm currently using should feature Occlusion Culling, so for the moment I actually kind of benefit from splitting my models into parts. I also found even the huge models eventually load, unlike RichysHub's addon. Here is the file: Chateau.zip

AstrorEnales commented 9 months ago

I tested your file and did some research on the window freezing issue. Sadly this is a big issue with blender python addons that the window will freeze and be unresponsive for long tasks and there is currently no great way to provide feedback such as a progress bar to the user, sorry. However, i took the opportunity to replace the internal data structure of the voxels with a proper one (i had this on my todo list for quite some time). The greedy meshed loading time on my machine for your Chateau got reduced from 530 seconds to 158 seconds which i'm quite happy with :) I created a new release just now, feel free to download and test it for yourself. I tested it with a variety of models and all seems fine, but with such big changes you never know. So please let me know it there is something wrong!

ZsoltHevesi commented 9 months ago

That's great! I'm quite happy with that, thank you