OliverJPost / HumGen3D

Main code of the Human Generator 3D add-on for Blender
GNU General Public License v3.0
81 stars 14 forks source link

Armature is corrupted after re-opening a blend file containing a linked armature #110

Open io7m opened 7 months ago

io7m commented 7 months ago

Describe the bug

After linking a generated human into a blend file, creating some keyframes for the pose, saving, and then reopening the file, the skeleton is completely corrupted.

To Reproduce

I've attached a video humgen_bug.mkv that demonstrates the problem.

Steps to reproduce the behavior:

  1. Create a new human of any kind. Save the blend file.
  2. Create a new blend file.
  3. Go to File -> Link... and open the original blend file. Link in the 4-5 objects that make up the generated human.
  4. Select the armature, and "make library override". This is necessary in order to be able to move/pose the armature.
  5. Pose the armature and create some location/rotation keyframes.
  6. Save the file.
  7. Reopen the file.
  8. Note that the armature and model is now crushed into a horrifying shape.

Screenshots See attached video.

Desktop (please complete the following information):

io7m commented 7 months ago

The video attachment went missing. Here it is:

humgen_bug.zip

alicerunsonfedora commented 4 months ago

A workaround I've found for this is to make an export of the human and then use that instead, or appending the armature instead of linking it.

R4zerw4rs commented 3 months ago

The issue seems to be the Stretch To contraint on the bones of the armature. I don't know why, but not every armature is affected in my case/file.

You can fix this issue on the "corrupted" armature by following these steps:

  1. Select the "corrupted" armature in Object Mode
  2. Switch to Pose Mode
  3. Select any bone like for instance spine.001
  4. Press A to select all bones
  5. Switch to the bone constraint tab in the properties panel
  6. Deactivate all Stretch To constraints on the armature by holding Alt and Left click on the eye of the contraint to disable it This is the constraint you are looking for to deactivate: Deactivate_Stretch_To_Constraint

This should resolve the issue and all of your poses and action strips should work as expected even after you reopen the file.

I have not done any further testing deactivating the Stretch To contraint, but posing and using actions strips with animation data looks fine without issues as of right now.

io7m commented 3 months ago

Thanks for the workaround(s). Is this a bug in Blender, or a bug in HumGen?

R4zerw4rs commented 3 months ago

I think it's a bug in blender and not HumGens fault:

The armature get's "corrupted" in files opened with a blender installation without HumGen installed aswell. So the addon can't interfere with anything as it's not installed and yet the problem occurs.

This suggests that this may be a bug in blender concerning the Stretch To bone constraint in conjunction with library overrides.

As the armature still looks good after disabling the Stretch To bone constraints - as of right now without further testing - I guess that the Stretch To bone constraint is only needed during the creation of a human. This guess has to be confirmed or denied by the author of the add-on.

A possible fix in the add-on:

If the Stretch To bone constraint on all bones of the HumGen armature is not needed after creating and finishing a human, a possible fix for this issue in the HumGen add-on could be making the deletion of the bone constraints a part of the final step for creating the human. This should bypass the issue of the "corrupted" armature as the cause - the constraints on the bones - is removed.

io7m commented 3 months ago

Thanks, I'll try reporting this upstream!

alicerunsonfedora commented 2 months ago

I've also written the following script to effectively turn off the constraints:

import bpy

def uncrumple(obj):
    """Effectively mutes the Stretch To contstraints on all bones"""
    for bone in obj.pose.bones:
        for con in bone.constraints:
            if con.name != "Stretch To":
                 continue
            con.influence = 0

# For example (IDK if this call would work here...)
uncrumple(bpy.context.object)
io7m commented 2 months ago

Eventually got around to filing upstream:

https://projects.blender.org/blender/blender/issues/127017