makehumancommunity / mpfb2

MPFB2 is a free and open source human generator for Blender
http://static.makehumancommunity.org/mpfb.html
Other
323 stars 39 forks source link

Delete Helpers error #166

Closed IvailoBurov closed 6 months ago

IvailoBurov commented 11 months ago

Describe the bug After importing models made with MakeHuman that work fine in MPFB2, deleting the helpers before exporting gives the following error:

Checklist Happens with Blender 3.67 and Blender 4.02

Screenshots / logs Python: Traceback (most recent call last): File "C:\Users\admin\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\mpfb\ui\basemeshops\operators\deletehelpers.py", line 88, in execute TargetService.reapply_all_details(obj) File "C:\Users\admin\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\mpfb\services\targetservice.py", line 825, in reapply_all_details TargetService.bulk_load_targets(basemesh, target_stack, encode_target_names=False) File "C:\Users\admin\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\mpfb\services\targetservice.py", line 520, in bulk_load_targets shape_key = TargetService.target_string_to_shape_key( File "C:\Users\admin\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\mpfb\services\targetservice.py", line 347, in target_string_to_shape_key TargetService._set_shape_key_coords_from_dict(blender_object, shape_key, shape_key_info) File "C:\Users\admin\AppData\Roaming\Blender Foundation\Blender\3.6\scripts\addons\mpfb\services\targetservice.py", line 276, in _set_shape_key_coords_from_dict buffer[base] += x * scale_factor IndexError: list index out of range

Platform and versions

joepal1976 commented 11 months ago

Thanks. I've pushed a fix to the blender4 branch now. It'll appear in tomorrow's nightly build.

Can you check if this solves the problem for you? Then I'll back-port it to the blender 3.6 branch.

IvailoBurov commented 11 months ago

Thanks for reply. mpfb2-blender4-20240101 build doesn't solve the problem. I have two Makehuman models imported, both have the same problem when removing the helpers in mpfb2. I'm attaching one here for testing: ivWoman.zip

joepal1976 commented 11 months ago

That's because the nightly builds are build at around five in the morning swedish time. You'll need a blender 4 build with a date from 20240102 or later for the fix to be in it.

IvailoBurov commented 11 months ago

This 20240102 build fixes the bug for Blender 4, but you need to bake the shapekeys first. Otherwise, the error occurs again. Is there a way to save shapekeys on export? With Blender 3.67 the error still persist.

joepal1976 commented 10 months ago

What I assume you are doing here is that you:

You're in a world of hurt if you do this, as results will often end up rather random. This especially if you try to modify a phenotype slider in MPFB. What you get from MakeHuman is a baked mesh without any shape keys, whereas everything in MPFB assumes you are working on a "live" basemesh with at least phenotype shape keys.

If you instead open exactly the same model from MakeHuman via "from presets" -> "import MHM" (ie, you open makehuman's save file for the model), you'll get an import which will work a lot better in MPFB. You will then also be able to remove helpers while keeping shape keys. For this to work with non-system assets, you'd need to configure the path to makehuman under the MPFB addon preferences in blender though.

I realize the distinction between these two import paths is impossible to understand for most users. I'll need to think up a way to at least warn about it within the scope of blender's rather limited UI.

At the very least, things should not crash when having picked the "wrong" import path.

IvailoBurov commented 10 months ago

Thanks for the detailed answer. What I do is:

  1. I'm importing a model from MakeHuman via MPFB's MHM import as a preset: изображение
  2. Then I try to remove the helpers without removing the key shapes: изображение And then I get the error described above. To avoid the error I have to delete the keyshapes first, but then I can't export the model with keyshapes.
joepal1976 commented 10 months ago

That's strange. I do exactly the same thing, but it works for me.

Can you paste the contents of your MHM file here? I don't think it can be attached.

IvailoBurov commented 10 months ago

For both models I get this error: ivWoman.zip Lydia.zip

joepal1976 commented 10 months ago

Ok, thanks. Yes, I can replicate the error with your MHM files.

I'm on it, but currently have no good theory on what the difference is.

joepal1976 commented 10 months ago

Ok, the difference between your test case and mine was that I had not used a modifier which affected the helper geometry. The core of the error is that after having deleted the helper geometry, the shape keys are rebuilt. The code did not take into account that the helper geometry might not exist when rebuilding and tried to modify the then no longer existing verts on the helpers.

I've pushed a fix to the blender4 branch. If you don't want to wait for the next nightly build, you can download the changed file and use it to overwrite to corresponding file in your addons directory: https://github.com/makehumancommunity/mpfb2/blob/blender4/src/mpfb/services/targetservice.py (click the three dots in the upper right corner to download the raw file). Otherwise it will be in the blender4 build tomorrow.

I have not updated the blender 3.6 branch yet. I'll want to see if this has unintended side effects before porting the fix.

IvailoBurov commented 10 months ago

Thanks, great job! Now the problem is fixed, and it was an obstacle even when importing Mixamo animations. I close the issue.

IvailoBurov commented 10 months ago

Just to remind you that the problem still exists in Blender 3.6 version.

joepal1976 commented 6 months ago

As the blender4 branch has been merged into master, this can be closed.