commit "0ae071f" cause "Make all bone posable" and "Morph armature" to throw errors.

Issue #751 resolved
Suttisak Denduangchai created an issue

The error is also appeared on blank .blend file with newly import figure. I dont know why some bones don’t have DazExtraBone property. So, I add if hasattr(pb.bone, 'DazExtraBone'):` to fix it.

I also move for pb in rig.pose.bones: block to the bottom of method to fix "Morph armature" function because in your version, it runs for pb in rig.pose.bones: before for pb in rig.pose.bones: causing offsets[parent.name] to have old value. I also change if parent: because using only offsets[pb.name] = offsets[parent.name] will break the ERC morphs on geograft.

morph_armature.py line 65-82

    for pb in rig.pose.bones:
        if pb.name[-5:] == "(drv)":
            bname = pb.name[:-5]
            finname = "%s(fin)" % bname
            heads[bname] = heads[finname] = heads[pb.name]
            tails[bname] = tails[finname] = tails[pb.name]
            offsets[bname] = offsets[finname] = offsets[pb.name]
    for pb in rig.pose.bones:
        if hasattr(pb.bone, 'DazExtraBone'):
            print(pb.bone.name,pb.bone.DazExtraBone)
            if pb.bone.DazExtraBone:
                parent = pb.parent
                while parent and parent.bone.DazExtraBone:
                    parent = parent.parent
                if parent:
                    offsets[pb.name] = offsets[pb.name]+offsets[parent.name]
    return heads, tails, offsets

figure.py line 692-703

        for bname in self.bnames:
            if (bname not in rig.pose.bones.keys() or
                drvBone(bname) not in rig.pose.bones.keys()):
                del self.bnames[bname]
            else:
                bone = rig.data.bones[bname]
                db = rig.data.bones[drvBone(bname)]
                fb = rig.data.bones[finBone(bname)]
                if hasattr(db, 'DazExtraBone'):
                    bone.DazExtraBone = fb.DazExtraBone = db.DazExtraBone

Comments (7)

  1. Thomas Larsson repo owner

    The DazExtraBone property is defined when the plugin registers (in daz.py line 467), so the only way this could happen is if you have an old version of that file. Maybe you didn’t reload.

    However, this would be a problem if the plugin is disabled and you run morph_armature.py in a script window, which you may want to do at a render farm. Other bone properties are needed too, like DazScale and DazHeadLocal. They are now registered locally. Note that this register function is not invoked when the plugin is registered, so the definition is not overwritten. It is only used in stand-alone mode.

    It is better to handle the extra bones before the driven bones. I tried the opposite order first, but the transforms were double counted somehow.

  2. Suttisak Denduangchai reporter

    Thanks for your reply. The reason I change the code to handle the driven bones before extra bones because your original code works with original merged bones (before applying “Make all bones posable”) but after “Make all bones posable” applied, the bones in main mesh are correctly morphed but geograft bones are not.

    I’ve check Futalicious bones after “Make all bones posable”, it will be Pelvis(drv) > Pelvis > ShaftRoot(drv) > ShaftRoot > ….

    The problem is Pelvis(drv) has PdOffset non-zero value, but Pelvis has zero value (0,0,0) (before being replaced by Pelvis(drv) PdOffset value). Your code recursively finds parent bone by checking DazExtraBone boolean flag, but it stops at Pelvis (beause Pelvis DazExtraBone is false, somehow). So offset[parent.name] of ShaftRoot(drv), ShaftRoot is zero.

    That’s why I switch the code to let Pelvis(drv) PdOffset to be copy to Pelvis PdOffset first.

    Maybe Pelvis DazExtraBone which should be TRUE in geograft is getting overwritten by Pelvis DazExtraBone from main mesh.

  3. Thomas Larsson repo owner

    Fixed in last commit, although it is very weird. The line

    offsets[pb.name] += offsets[parent.name]

    double-counted the transformation, but

    offsets[pb.name] = offsets[pb.name] + offsets[parent.name]

    works.

  4. Log in to comment