Mesh Store empty folders and other 1.4 things

Squize posted this 29 September 2015


I know there was a recent thread about this, but this is ever so slightly different. Whenever I stop testing the game a small progress bar window pops up ultra quickly and I can just about make out it saving "Saving chunks". This gets worse the more I test the game. Yesterday I cleared out all the empty folders, went from 2k+ to 420. Today Unity opened pointing to an empty folder by chance in the project view, so I checked again, back up to 2k. Deleted, ran the game, checked and another 10 empty folders.

Is this a throw back to the new reload vox option ? The old assets that were included in the game before I updated to 1.4, is it getting confused with the old ones ?

Also the PBR transparent shader compiles out at 1.8 meg ? I had a look at it, and there's nothing there code wise, is this just Unity being Unity ?

Sorry it's a bit of a wall of moans / questions. The new update is excellent, I had some weirdness updating some assets but took about an hour to sort everything out, and it was great that you added things like the hidden flag and rebuild options.

Last edited 29 September 2015

Order By: Standard | Newest | Votes
GarethIW posted this 01 October 2015

Hey, thanks for the bug reports.

I've noticed the issue with empty folders and saving chunks after runtime too, and I thought I had solved it - obviously not. I'll go back and take another look.

I've switched over to using ShaderForge for all of the new shaders. I'm no shader expert, so I have no idea why it would be so large. I'm assuming the old shaders weren't that big? To be honest, I don't even know where compiled shaders are output to - is this specific to a particular platform?

Squize posted this 03 October 2015

Cool, thanks for taking a look at it.

As to the shaders, yeah I think it's just a weird Unity thing, as the code itself is just normal, there's nothing that stands out there.

Build report

Yet it's stupidly large for some reason. It works great, so it's just going to be one of those things I think.


Squize posted this 14 October 2015

Just as a bit of a follow up to this, are vox files being refreshed from the original file ? It feels like they are at compile time and then when finishing playing.

Is there anyway to turn that off, a class I can look at please ?


GarethIW posted this 14 October 2015

The volumes definitely shouldn't be refreshed from the .vox files without you clicking the button. I think you're just seeing the current issue that you mentioned in the original post. If you wanted to be sure, just stick a breakpoint in MagicaVoxelImporter.cs/FromMagica()

Squize posted this 01 November 2015

Thanks for the reply ( And sorry for my late one ), I really am going to have to take a proper look at it as it's just killing my workflow atm. Every time I come back from the editor to the Unity IDE it takes a couple of seconds to compile the scripts, even if it's a tiny change ( To my own code, not touching yours and in classes that don't even refer to the PicaVoxel ones ) and then when I quit testing the game I'm getting the issue in my original post.

I'm tempted to revert back to the previous version, I'm really surprised no one else seems to be having this issue, I've only got around 20 vox objects in a scene at most.

GarethIW posted this 01 November 2015

I've just been testing this and I am unable to reproduce. Here is what I did:

  1. New Unity project (5.2.2f3)
  2. Import PV
  3. Import 10x .vox objects, some with a large number of chunks
  4. Save scene, load a different scene, reload scene
  5. Run the project and stop it again (several times throughout)
  6. Change some of the scripts to force a recompile
  7. Run the project again.
  8. Edit a couple of the volumes
  9. Quit Unity and reload

None of the above created extra folders in the mesh store. There were ten all the way through the test. At no point did I get the "Saving Chunks" progress bar.

Can you see if you can reproduce with an empty project and PV 1.4.0? Perhaps we can narrow down the cause.

I should also mention that I am on Windows, I haven't tested the above on a Mac yet (I can do if you're on a Mac though).

Squize posted this 02 November 2015

Thanks for testing it mate, stick with me a couple of days and I'll try and capture some sample output. I wonder if it's a throwback to originally using 1.3 of PV ? So some assets are new and have to option to reload the vox, others aren't.

( btw I'm on mac and using 5.2.1f1 )

GarethIW posted this 02 November 2015

Hmmm, I'll put money on this being a Mac filesystem thing. I'll have to fire up the Mini to do some testing, but might not be until later this week.

If you attach the debugger to the editor and put a breakpoint in the mesh saving method, you should be able to follow the stack trace back to what's kicking off the saving. Let me know if you figure anything out in the meantime.

Rimevel posted this 18 February 2016

Was there any progress with this problem? I am having the same issue :( Some times when I press stop and go back to the editor a progress bar pops up. It lasts about 1 second and then all the mesh storage folders have doubled. I am on a mac as well.

Also sorry for reviving an old thread but it seemed the most relevant place to post this.

Last edited 18 February 2016

GarethIW posted this 19 February 2016

I now know what is causing the issue with generating chunks after exiting play, but I don't have a proper fix for it. I might have a fix for the empty folders though. First, I'll explain the issue:

The problem is caused by the code I use to detect when a volume has been duplicated (ctrl/cmd+d) in the editor.

In order to do duplicate a volume properly, we need to generate a new PicaVoxel ID for the volume so that it generates its own mesh. If we don't do this, the duplicated volume will share the same mesh as the original and any edits made to one duplicate will happen on all duplicates sharing the same mesh.

The trouble is (as with all things), there is no support for detecting a duplication event in editor script. The best you can do is look at the InstanceId of the volume GameObject. For some reason, just-duplicated objects are guaranteed to have a negative InstanceId, so if that is the case then we force the mesh to be saved with a new PicaVoxel ID.

The only trouble with that is we have to check for the negative InstanceId on Awake() of a volume, so the same code gets run when exiting Play mode or when recompiling scripts, or reloading the project.

This would all be fine if Unity did not change the InstanceIds of objects every time the project is reloaded. But it appears that at some point during a project's lifecycle, Unity starts to assign negative InstanceIds to objects that have not been duplicated when the project is reloaded. I've just never been able to reproduce this problem myself, and neither has anyone else - it does not happen with blank projects.

So that's the backstory to this issue. The only way to stop the unwanted chunk regeneration altogether is to disable the duplicate check by commenting out the else block starting at line 147 of Volume.cs

I think I've found a fix for just the empty folder issue, but as I can't reproduce the overarching issue I can't test it. Hopefully someone else can:

// Change line 614 of Frame.cs (in SaveChunkMeshes()) from:

if (string.IsNullOrEmpty(ParentVolume.AssetGuid) || forceNew) ParentVolume.AssetGuid = Guid.NewGuid().ToString();

// to:

if (string.IsNullOrEmpty(ParentVolume.AssetGuid)) ParentVolume.AssetGuid = Guid.NewGuid().ToString();

Last edited 19 February 2016

Rimevel posted this 02 March 2016

Kinda later reply but whatever :P I commented out the block at line 147 in Volume.cs like you said. So far it seem to have fixed the issue. Have not noticed any problems with doing so :D

GarethIW posted this 02 March 2016

So the issue with commenting out that block is that duplicating a PicaVoxel volume will no longer generate a new mesh instance to go with it. This means that if you edit a volume that has been duplicated, it will change the mesh on the original and the duplicate.

In the next release, I plan to put in a button to let you generate a new mesh instance on a volume, even though it doesn't really make any sense in any kind of workflow.

So yeah, all of this is because Unity doesn't provide an editor hook to check if an object has been duplicated. Sigh.

Rimevel posted this 02 March 2016

Well I have not had the need to duplicate any of my voxel models yet. I just have a single instance of my models saved as a prefabs. Anyways, thanks a lot for the help. Now I can work on my game without all the bloat :D

Erik posted this 20 April 2016

Just removed 22589 folders. :)

I like the idea of having a button to duplicate the mesh. Treating the mesh the same way you'd treat an imported 3d asset makes a lot of sense for workflows where you're using external tools like magicavoxel or qubicle.

Our 132 members have posted 493 times in 119 discussions