EdyJ / blender-to-unity3d-importer

Advanced Blender to Unity 3D model importer
MIT License
141 stars 34 forks source link

Occasionally applies unnecessary rotations #5

Open twilson90 opened 7 years ago

twilson90 commented 7 years ago

I've just tried importing some more complex models and found it's doing some unnecessary rotating.

Here's the model in question: https://drive.google.com/file/d/0B9DFPZBPKp6AdGU5czR4RDQteDQ/view?usp=sharing

When it's imported into unity with your script and the default settings, you'll notice the bike pedals incorrectly rotate 90 degrees.

If you have time could you please look into this? I can't work it out.

twilson90 commented 7 years ago

I worked out why this was happening soon after my original post. Surprisingly there is no check in place to determine if RotateMesh has already been applied to a mesh, so if you have objects that reference the same mesh in 2 or more objects, the rotation will be applied 2 or more times. This can be simply fixed by storing references to the MeshFilter.sharedMesh and ignoring those which have already been applied.

EdyJ commented 7 years ago

Thank you for reporting the issue! At the last versions I checked the script with Mesh instances were being imported as duplicated meshes. This is why the script includes an additional feature "Optimize Mesh Instances". This feature looks for identical meshes and restore the instance references. It looks like the Blender imported in Unity is now respecting mesh instances.

Can you submit your workaround as pull request? Alternatively, feel free to send me the modified script and I'll update the repo with it.

twilson90 commented 7 years ago

Sorry, I didn't see this message until now. Pull request has been made.