MHX update / generate issues

Issue #1110 resolved
engetudouiti created an issue

I think new stretch option (can deform with stretchness value) is good enhancement.

but current status actually cause un-expected issue.

if user move IK foot then locate stretch position, then snap FK to IK >> IK to FK,

it easy break current rig. because it keep of-set value with stretch. like this image.

when strech = 0, the IK foot need to return pos. but not work any-more.

Main problem is, this un necessary off set not easy remove once it start. untill you reset all related bone I think

(maybe it need to reset hidden bone too)

To avoid this issue, need to change snap function I suppose.

(when there is un-necessary off-set, remove it )

Or need to add new button and function, which remove this off-set and locate IK foot chain on to the foot for strechness

I do not clear remember about old rig, but when I do not activate stretch, I suppose it did not happen before.

Now it seems happen even though I keep to stretch as zero. it is not matter. when there is off-set , then snap FK, snap IK,

this offset remain.

Comments (11)

  1. engetudouiti reporter

    Or maybe you need to change constrain way… I temporarry try to make remove_off_set function,

    it force to remove this off-set for IK bone.. once IK bone return correctly, snap FK to IK should work too… without it everytime, user remain small off-set, it wil lbe stored when snap …

  2. engetudouiti reporter

    At current, I may suggest these things

    1. Only strech activate for IK. when FK there should be no stretch.
    2. when FK snap IK, reset stretch value as 0 + run function which force to remove off-set.

    I make script, but it only work, untill you try to snap FK to IK. (though I hope if you can make it work for any case,,)

    then at current everytime I remove un-necessary off-set, when IK foot locate stretch poss.

    1, I locate foot IK stretch pos. it change bone pos like this.

    2 untill we change mode to FK, (use snap function), we need to set Stretchness as zero.

    then it show this off-set. it cause problem.

    3 you need to remove this off-set untill FK snap to IK.

    at current I run this script (now only work for Foot IK) for each foot

    import bpy
    import mathutils
    matrix = mathutils.Matrix
    rig = bpy.context.active_object
    pbones = rig.pose.bones
    
    def get_delta_trs(tbn, sbn):
    
    
        t_mtr = tbn.matrix
        s_mtr = sbn.matrix
        d_mtr = t_mtr-s_mtr
    
        return d_mtr
    
    def set_IKfoot(bname):
        tbn = None
        sbn = None
        if bname == "foot.ik.L":
            tbn = pbones['foot.L']
            sbn = pbones['foot.inv.ik.L']
    
        if bname == "foot.ik.R":
            tbn = pbones['foot.R']
            sbn = pbones['foot.inv.ik.R']
    
        pbones[bname].matrix = pbones[bname].matrix + get_delta_trs(tbn,sbn)
    
    set_IKfoot("foot.ik.L")
    set_IKfoot("foot.ik.R")
    

    It can remove un-necessary off-set for non stretchness like this

    Then we can safe snap FK to IK <> IK to FK.

    if you do not do these step, with locate IK foot on stretch pos, but try to snap FK to IK,, the off set remain, un-expected way, then it cause issue when you again snap IK to FK..

    Though I do not know it still work for library things.. (maybe no). I do not test with all option, eg change pole target etc,, so it still need to test. then I may hope you may add more reliable “remove off-set” function, and run untill snap FK to IK please...

  3. engetudouiti reporter

    For all limb IK bones.. (need to run untill snap FK to IK)

    import bpy
    import mathutils
    matrix = mathutils.Matrix
    rig = bpy.context.active_object
    
    
    def get_delta_trs(tbn, sbn): 
    
        t_mtr = tbn.matrix
        s_mtr = sbn.matrix
        d_mtr = t_mtr-s_mtr
    
        return d_mtr
    
    def set_IKbones(bname):
        tbn = None
        sbn = None
        if bname == "foot.ik.L":
            tbn = pbones['foot.L']
            sbn = pbones['foot.inv.ik.L']
    
        if bname == "foot.ik.R":
            tbn = pbones['foot.R']
            sbn = pbones['foot.inv.ik.R']
    
        if bname == "hand.ik.L":
            tbn = pbones['hand.L']
            sbn = pbones['hand.ik.L']
    
        if bname == "hand.ik.R":
            tbn = pbones['hand.R']
            sbn = pbones['hand.ik.R']
        print(tbn,sbn)
    
        pbones[bname].matrix = pbones[bname].matrix + get_delta_trs(tbn,sbn)
    
    rig.MhaArmStretch_L = 0.0
    rig.MhaArmStretch_R = 0.0
    rig.MhaLegStretch_L = 0.0
    rig.MhaLegStretch_R = 0.0
    
    rig.update_tag()
    pbones = rig.pose.bones
    ikbones = ["foot.ik.L", "foot.ik.R", "hand.ik.R", "hand.ik.L"]
    
    for bn in ikbones:
        set_IKbones(bn)
    

  4. engetudouiti reporter

    I notice, above script actually work but, it remain up-date issue^^;

    I do not remember how I up-date RNA prop correctly.

    so if you remain Stretch value,, you need to run this script twice.

    (1st time, it can set Stretch value as 0 >> I can confirm, it deform as non stretch

    2nd time, it can remove each IK controll bone…

    So if you do it for your function (each snap FK to IK button may need these step)

    consider please.. if you do not know when it happen clear, I offer more deital step,

    But I suppose, if you simply play with current MHX stretch, and often change IK <> FK

    after all you should see this issue, and may hope to remove this problem.

    (I suppose same thing may happen for G8 but I do not know.. if it only happen G3 and toe parent with tarsal option, then you do not hope to take time to correct it, I may set this topic as invalid.

    === But this problem should happen, because I see same problem for IK hands Stretch.>> snap FK to IK >> IK to FK

    Sorry It seems only happen for Foot. but G8 have same problem.

    The problem is not only about IK posing, because when we snap FK to IK with off set pos,, FK foe already change rig pos like this.

    I could correct it, with un-lock FK toe transform, and reset location only about FK toe, but after all if I use snap IK to FK

    it remain off-set issue. (your reset pose button only solve this issue, because I suppose it try to reset all bones which hidden usually)

  5. engetudouiti reporter

    OK I seems find reason. you may not need to add new function etc.

    Though I do not know detail, but anyway if I convert MHX, (I usually never merge toe)

    Daz importer seems not connect toe.FK.R and toe.FK.L bone for their parent. so they can move free.but I do not think toe bone need to move.. then it cause strange issue when user use stretch.

    Anyway I connect them to their parent. after that even though I snap with stretch pos, this problem seems removed.

    I suppose if you miss connect un-necessary one, but forget to connect necessary bone for stretch?

    (eg foot.FK , and Foot bone, should not be connected.. but as I said there seems case, it was connected)

    See (I Connect, toe.FK.R bones , but keep toe.FK.L (not connected) as add on set.)

    then set IK pos on stretch pose, snap FK >> snap IK.. now only left foot cause issue.

    I test with set stretch value. but if you connect toe.FK bones, problem not happen.

    and I suppose it is what you expected. 😀

    So what you need was,, check bone connected or not, then set it correctly, when convert to MHX,

    and MHX up-date function.

    toe.FK = Connect

    Foot and Foot.FK = Not connect

    hand and hand.FK Not Connect.

    Then finally stretch work well even though we snap IK <> FK with stretch pose with change stretch values.. (though if you add rotate with stretch FK pose, it may break, but we seldom do it I suppose)

    Same thing happen for G8 too, I confirmed now. I do not know if I merge toe first, how MHX convert though.

  6. engetudouiti reporter

    I add these code for props.py , class MHX_OT_UpdateMhx(MhxOperator):

    if you modify MHX update function, check this please..,

    https://bitbucket.org/Diffeomorphic/import_daz/issues/1105/mhx-up-date-fimction-still-remain-some

    both modify may need for update function work. (or some old MHX scene may return error/ cause issue with stretch snap)

            cmode = rig.mode
            bpy.ops.object.mode_set(mode='EDIT')
            ebns = rig.data.edit_bones
            setConnect(ebns)
            bpy.ops.object.mode_set(mode=cmode)
    
    def setConnect(ebns):
        ebns["hand.L"].use_connect = False
        ebns["hand.R"].use_connect = False
        ebns["hand.fk.L"].use_connect = False
        ebns["hand.fk.R"].use_connect = False
        ebns["foot.L"].use_connect = False
        ebns["foot.R"].use_connect = False
        ebns["foot.fk.L"].use_connect = False
        ebns["foot.fk.R"].use_connect = False
        ebns["toe.fk.L"].use_connect = True
        ebns["toe.fk.R"].use_connect = True
    

  7. Thomas Larsson repo owner

    There were two lines in the code that connected the toe and toe.fk bones to their parents, but those lines were commented out for some reason. So I removed the comments and now snapping and stretching seem to work together, at least for the quick tests that I made.

    You only mentioned toe.fk bones and not the toe bones themselves, but since the foot.rev bones are connected to toe.rev, I don’t think it matters; toes can never move away from the feet.

  8. engetudouiti reporter

    Yes I notice you comment out that line so it cause issue to convert as MHX. but I need it for up-date function too.

    though if up-date check it, it should work. (I do not hope to test it anymore untill I next up-date MHX, because I already edit some about MHX up-date code which include #1105 and rig fy meta-rig #1102 new issue. (when generate meta-rig and convert it)

    Then at least if you not merge Toe bone, I suppose I need to keep current setting for Toe bones maybe check later. anyway without you remove comment out., stretch and snap should cause issue.

    I may happy close this issue finally . but hope you check #1105 too.

    hm For me connect Toe or not Connect, show no difference. (so if it not cause issue it seems ok for me maybe connect get more stable? I do not know.

  9. Log in to comment