SabreCSG icon indicating copy to clipboard operation
SabreCSG copied to clipboard

Save Meshes as Assets will fail with multiple CSGModels in the scene

Open damagefilter opened this issue 6 years ago • 1 comments

Basically what the title says.

It will write out the meshes next to the scene, labelled "VisualMesh" + materialMeshDictionary.MeshCount + ".asset". While perfectly fine with one single CSG model in the scene, it breaks with multiple CSGModels. Each one has its own materialMeshDictionary (makes perfect sense too) and each one is counting from zero upward, overriding meshes from another CSGModel.

The same happens for the collision mesh of course.

I went there and looked if the names can be made unique somewhat. Certainly, there are many ways to make it so. Add a GUID to the file name. Add a timestamp to the file name. Add some form of Hash value. Whatever. Those are, perhaps, not exactly pretty solutions though, hence I didn't jump straight in and PR the thing.

Anyone fancy dropping some input on this? The places in question are MeshGroupManager.FinalizeVisualMesh and MeshGroupManager.FinalizeCollisionMesh

damagefilter avatar Jan 21 '19 10:01 damagefilter

If the assets are not discovered by their path a AssetDatabase.GenerateUniqueAssetPath or two should do it, but I'll let someone who knows better than me to make the changes :)

vertxxyz avatar Jan 21 '19 11:01 vertxxyz