ssbucarlos / smash-ultimate-blender

Blender Plugin containing utilities for Smash Ultimate Models and Animations.
45 stars 9 forks source link

same-name meshes have issues on export #82

Closed ssbucarlos closed 2 years ago

ssbucarlos commented 2 years ago

Users are reporting issues with exporting of same name meshes, such as mesh wieghts being incorrect. The issue seems to dissapear when the user renames the meshes to be uniquely named. The issue seems to not exist on the anim_test branch.

ScanMountGoat commented 2 years ago

I'm not able to reproduce this on the latest commit from main with Mario. Was there a specific character/file they were having trouble with?

ssbucarlos commented 2 years ago

Sorry i havent sat down to try and figure it out yet. Im contacting a user now to see if they have a backup of the blend with the issue somewhere. Alternatively, im going to try to find a file with the issue now. Sorry for the vagueness. The consequences vary from weights of other meshes of the same name ending up on another mesh, to meshes disappearing, to crossmod/ssb crashing. If i had to guess, the numshb order logic i added a while back is an issue and the users renaming or duplicating the mesh, the numshb order property no longer makes sense and is causing issues since i dont account for that.

ssbucarlos commented 2 years ago

It doesnt seem like its an issue on vanilla IO at least, which is probably why neither of us have ran into it.

ScanMountGoat commented 2 years ago

We could use the existing order for mesh object groups by using a vanilla mesh as reference. This ensures that all the "c00BodyShape" mesh objects come before the "Mario_hathead_VIS_O_OBJShape" mesh objects. The tricky part is that this doesn't work for correctly setting the sub index for each mesh object within a group. I'm not sure if the order of the mesh objects within a group matters other than affecting the render order slightly.

Regardless of how we order the mesh objects, the output shouldn't ever break in Cross Mod because the ordering should be consistent across all the exported files. Hopefully this isn't too hard to fix once we can reproduce it.

ScanMountGoat commented 2 years ago

I'm guessing this line is the problem. https://github.com/ssbucarlos/smash-ultimate-blender/blob/5c3c6e549462abd1570c27d013dd4f9b2ce4305c/panels/export_model.py#L142

ssbucarlos commented 2 years ago

yeah that would be the problem line. I think ur right and using the vanilla .numshb as a reference would be better

ssbucarlos commented 2 years ago

Rex_Armor_Mystery_2.zip in this blend file, seems like the weights are already messed up, and it looks like the mesh order doesn't make sense for the meshes. After telling the user to make the mesh names unique, and fixing the weights for the problematic vertices, they were then able to export without issue. Ill look into making the reference .numshb similar to how the reference .nusktb is prompted for. As for how to handle sub-indexes, im honestly not sure how much it matters either.

ScanMountGoat commented 2 years ago

There was bug causing the addon to export meshes with the same name and sub index, leading to incorrect weight assignments in game. Blender doesn't preserve the order of objects, so using groupby doesn't work. This was fixed recently to use a dictionary of lists instead.