MHX Switch option to hide Forarm twist with hand (for perfect snap) constrain

Issue #511 resolved
engetudouiti created an issue

I approve the MHX way which constrain Forearm twist with Hand, as option. (when user twist Hand , Forearm follow the twist though I found same constrain for FK too)

At same time it cause snapping issue I do not argue about detail but, I may request add on add one more option which simply hide those 2 constrain with use check box .

On If user need the MHX function (forarm auto twist with hand) keep activate it (I do not consider it is default or not)

Off if user often use FK <> IK snap, un-activate it , then hide the 2 constrain. so all snapping issue gone away. Each option have pro and con, so user may decide which is better for each purpose.

Though as my private purpose, I may manually on and off those constrain, but I do not think user easy find which constrain need to edit and do not know how it will effect with snapping. Regard with recent snapping up-date, I think this option is useful. (so user can see real parfect snap without any issue, but can control twist for IK chain bones, as they need.

Comments (17)

  1. Thomas Larsson repo owner

    Fixed in recent commit. The option is called Forearms Follow Hands and is located in the properties panel.

    Unfortunately, it doesn’t seem to work correctly. IK snapping is perfect, but FK snapping moves the hands. The rotation is right but the location is slightly off sometimes. This happens even if I disconnect the FK hands from the FK forearms.

    In fact, FK snapping wasn’t perfect before neither, because the IK rig allows for stretching but the FK rig does not. But the problem is worse now.

  2. engetudouiti reporter

    I do not see issue with new commits, (which you add option for Auto twist forearms on and off)

    with Off it work perfectly for FK <> IK even though I twist Forearms with IK and FK as I like.

    if ON with snapping I see slightly forearms twist, which added by the constrain I suppose.

    About IK twist bones, I hope if you simply add them in usual IK layer.

    because if you use it as extra, those bone only need for IK mode, so it remain with FK mode too.

    I need to hide them every-time for FK mode.

    Those IK twist bone not harm but simply useful to adjust IK bone twist for each limb. even though user do not use often

    IK twist is for main IK limbs and used to pose those bone with IK mode only. when you snap FK <> IK if you hide those twist, user do not know those IK twist bone auto set value. so I think they better visible as default with IK mode.

  3. engetudouiti reporter

    I still not see issue = hand move,, for snap FK hand to IK. I hope to know when it happen.. can you show pose pic, which cause issue?

    Then if it is caused IK stretch, (only happen when you set IK pose which actually stretch bone) I think it is usual.

  4. Thomas Larsson repo owner

    The ik twist bones have been moved to the ik layers.

    The snapping problem occurs almost always for me, even if the ik arm is not stretched. As in the picture, the hands have the same rotation but the locations differ slightly.

  5. engetudouiti reporter

    I suppose actually your arm IK pose slightly streched IK arm bones . Untill snap FK to IK , if you move hand to the Forearms pivot (so strech stop) silighly,

    I think you mai not see snap issue.. what I means with IK pose (eventhough you do not think it stretch arms) when you stragith your arms with IK hands, hand IK bone easy get small distance from deform forearms.

    if you check pivot of IK hand with pose which cause snap issue (FK to IK) the IK hand pivot actually have distance from deform forearm bone tip (joint point) then snap FK to IK simply locate FK bone without stretch.

    This pic is no distance = non stretch between Forearms and IK hand. so FK snap to IK, I do not have issue

    but if I slightly move IK hand to get distance (stragit arms perfectly), (Though I can not easy find it, but usually I pose IK hand not move from the joint point. (if you carefully check mesh wire, when stretch you clear see mesh deform so)

    Now I can see snap issue.

    Then to avoid it,

    1. I set FK hand not connected with . (but keep parent as same as before)
    2. I use script after FK snap IK

    import bpy
    import mathutils
    
    pbs = bpy.context.active_object.pose.bones
    amt = bpy.context.active_object
    
    hand_fk = pbs["hand.fk.L"]
    hand_ik = pbs["hand.ik.L"]
    
    "correct snap FK to IK foot and toes after add on snap"
    
    def snap(src, trg):
        src.matrix = trg.matrix   
        bpy.context.view_layer.update() 
    
    snap(hand_fk, hand_ik)
    

    then when I change IK influecne, FK bone correctly snap and I do not see any issue.

    So I suppose, if you set FK hand = non connected with parent

    then if you change your script witch locate FK hand to IK hand, I do not think you see this issue any more.

    Actually if I do not use custom script, but if I set IK pose like those, even though I do not set FK hand not connected with parent,

    add on snap script not work correctly (I do not know reason,,though), but after all just set matrix same,, (run custom fool script)

    it now snap correctly. like this

    1 untill use custom script, but snap FK to IK, (FK hand is disconnected) )

    2 run above script

    Though I do not know if I happend to change other setting etc, but at least current snap FK to IK, not locate FK hand on to the IK hand postion

    (when IK hand have moved from connect point, even though FK hand are disconnected, (manually I set so))

  6. engetudouiti reporter

    I test again with recent commits , then If I do 2 things (disconnect FK hand from parent) and use the custom script, it correct FK hand position. Though I do not hope FK strech arms,, (so when return FK, I may need to remove local hand FK location )

    And as mentioned, it only happen for pose, when IK hand actually separate from Forearm tail position, so I do not think I actually need to disconnect FK hand though,, anyway I see issue, even though I set disconnect, current FK snap to IK not correctly locate FK hand. I suppose up-date issue. if FK bone is disconnected, it can move free, so at least FK snap to IK, you only need to locate FK hand position correctly on to IK hand I think (current add on snap script happend to not work so,,I do not know reason though.

  7. engetudouiti reporter

    Thomas may check these pic, at first I set FK hand parent as non connected (so FK hand can move free)

    1_ pose IK hand (it show some stretch) , then FK pose as free (but not FK mode so mesh not follow)

    2_ snap FK to IK without Swithc mode and layers, (so keep IK mode, and layer to check FK bone and IK bone easy) and without follow hand twist.

    3_ if I change IK influence value from 1.00 to 0.00 the hand shirink to FK position = FK hand not locate IK position correctly

    4_ just run the script which only locate FK hand to IK hand pos and rotation (matrix)

    5_ to confirm it correclty snapped (FK bone to IK bones), I change IK influence 0 to 1 or 1 to 0.

    as you know IK bone do not change at all. (FK bone only snap to iK, with add on and custom script)

    then with any IK influence value, I do not see any deform anymore = FK bone perfect fit correctly.

    Then if I check FK hand transform value, it now not keep as 0. (because FK bone try to locate stretch position)

    so I suppose add on work correctly but not locate hand position (if user change FK hand free move (not connected) but keep same parent) without your intention. if you add same thing in add on snap function, (Just locate FKhand to IK hand, current add on should work without hand shrink when FK snap to IK (and change mode as FK)

    I suspect it seems up-date issue, but do not know actually what cause difference (when use custom script and locate again or use add on snap only)

    Then basically I do not think this is bug (because I do not suppose snap FK to IK work when IK hand move from connected position. (it may often happen, without you check it carefully for straight arm pose. but if you bend slightly and locate hand carefully I suppose you can avoid not move IK hand from connected pos, but if it is not your usuall work flow,, I recommend,, add option (which need to change bone parent as non connected but keep same parent bone for FK hand) + some edit for add on snap function to confirm FK hand locate on IK hand place. with use matrix etc. (what my fool scirpt onlly did it without any deep insight ^^;)

    eg you can add option , FK hand not connected with forearm.FK (then snap FK to IK work as it should be though you need to edit current snap funciton still)

    ==

    Then basically,, I do not set IK stretch pose,, (I usually try to avoid hand stretch (even though it is almost 3 mm etc,,) if I snap FK to IK, and hand shrink, I confrim the IK pose was wrong for me (because IK hand have distance from forearm already)… I do not know others often use stretch for IK posing.. but for me not hope to stretch deform, (if I strech I use twk bones , that is purpose for twk bones, so I can avoid IK strech even though it is real small distance)

  8. engetudouiti reporter

    I reserch more for my purpose.

    Basically there is 2 different aploach for FK IK rig.

    1_ make IK chain not show stretch deform. even though IK controll bone free move, avoid it to effect stretch.

    2_ make IK chain show stretch deform with free move IK controll bones

    at current MHX rig use type 2 rig, so IK hand and IK foot free move, and actually deform hand and foot follow the movement (temporally forget about twk bone please = actuall deform bone)

    then If you hope perfect snap, you must need to set FK hand disconnected from FK forearm. at current it is connected.

    and add on snap FK to IK function, can not locate FK hand (even though it can free move) on to the IK hand correctly (though I do not know reason still, with see ikfk.py.. maybe you need to confirm matrix of FK hand IK hand, it must need to show same matrix. but I think it will be solved. (just set matrix correctly after current snap FK to IK function again)

    After all , there is no way, if you hope to keep IK hand free stretch and deform , but keep FK hand not stretch . it should cause snap issue if you use stretch pose.

    But I have interesting the type 1 (IK chain not show stretch deform, even though IK controll bone (IKhand) still free move)

    It can be done, if you connected deform hand bone to forearm bone. like this pic.

    we just need to connect Hand.L with parent Forearm.L .

    then Hand.L can nof follow IK hand when there is stretch = IK hand have distance with IK Forearm tail.

    if you change rig so, IK and FK forearm not show stretch deform any more. like this pic.

    Then if I snap FK to IK, FK bone try to locate on current IK hand position, but your script locate FK hand on to the deform bone. so it not show any deform when snap FK to IK.. (about this case, IK bone pos it not matter, because FK bone can not locate on the pos, then it restrict to the hand bone pos when snap FK to IK.

    because

    FK hand is connected with FK forearm <> and hand is connected with Forearm, so FK bone simply locate on current IK pose defrom postion.

    I suppose even though I run my custom script, FK hand can not change pos because it is connected already.

    Then when IK to FK still work without problem..

    I recommend Thomas simply test this. (just connect hand.L / R with the parent Forearm, and test IK pose and snap as you need FK <> IK.

    I think if add on offer option, (connect hand and Forearm) it is more good option, than un-connect FK bone from FK forearm

    because so user can avoid stretch pose for IK without check real IK hand position. (check small distance etc), then can snap work without problem.

    btw, then why you have not connected hand with Forearmes before? do you hope stretch pose for hands? and do not remember default for toot, how did you connect foot and shin? if not I think it is better offer option,, free stretch pose / non stretch pose for IK hand/ foot

    with non stretch pose add on snap function already work almost perfect I suppose.

  9. engetudouiti reporter

    So I add some new things in this topic, (as for me layer issue is already solved thoguh) as request.. I summarize.

    request A (relate with Pole target postion in strech pose)

    I hope to add new 4 bone targets to set IK xxxPoleA constrain to avoid pole target (knee and elbow) move with IK hand and IK foot on stretched position.

    (clean up requestA pics for some reasons (I reject this request))

    s for some reason.

    request B (for non stretch deform IK pose )

    new option for MHX properties, for foot.L / R and hand.L / R , connected with their parent. eg (name as strech IK foot and hand (on / off)

    with off, (check box) now those bone connected with their parent, then not show stretch deform for IK too.

    so user can avoid stretch IK pose. (but still can move IK bone free, without deform as stretch (auto limitted), then snap scirpt work without problem.

    set up those for left side IK, now it work like this

    request C

    (though I do not know it need, but it seems actually what Thomas hope about IK pose and snap FK <> IK , To keep stretch foot and hand with IK, then snap FK to IK work correctly,)

    1_ need new option whih will change FK hand and FK foot not connected with FK forearm and FK Shin.

    if use the option, FK hand and FK foot can stretch (free move and defrom) as same as IK hand Foot (though it may off with the above option which connect deform hand and foot bone with parent deform bones)

    then snap FK <> IK will work correctly (but as mentioned above, you may need to edit current snap script to up-date FK hand pos '(free move) correctly

    ====

    Those 3 request may related with each other, but request A work which option you choose.. (locate pole more reasnable, without consider IK controller pos)

  10. engetudouiti reporter

    I found why I need to snap IK to FK twice to snap correctly, it happen when I change pole target as new one which not follow IK hand and IK foot.

    handPoleTarget and anklePoleTarget (request A) , if I do not use new Target for xxxPoleA constrain it not happen. (to work it you need to change snap function I suppose)

    without Request A , even though I connect hand and foot (deform bone) for parent (request B ) I need not snap twice.

    I do not know which request (A , B, C) you may have interesting, so it may denpend on you. (how you change current snap functions)

    I think Request A offer more visual stablilty, when user often use stretch IK pose, with snapping FK<> IK, but to work it correctly you need to change current FK<>IK snap function for new added bone.

    Request B is for user who not hope stretch Foot and Hand with IK pose. (FK not stretch)

    Request C is for user who everytime hope to stretch Hand and Foot (include FK pose)

    about both case Snap may work perfect (IK <> FK)

    with Request B, (just connect deform arm and foot for their parent >> non IK stretch ) snap work without edit. I do not know reason.

    but Request C, at current I think you may need to edit some. (it work with my custom script just locate FK hand on to IK hand so)

    then now I remove all request A things ^^; (hope Thomas did not start to try add new target bones,,)

  11. engetudouiti reporter

    Then about pole things, I change mind about Request A which add new target bone which not follow foot and hand move far away.

    because it only happen, IK hand and foot stretch>> make distance from Shin or Forearms tail.

    with check cone and poleA move, user can check current IK pose stretch or not.

    Once snap FK to IK after all user do not use pole , then later IK to FK (IK pose), IK pole auto locate because Foot / hand can not stretch. untill you change FK hand/foot parent setting (non connected) , So I may not need Request A it not bad, but it need new bone and you need to change current function,

    I afraid, once you change function, it cause new issue.

    So my priority is Request B and Request C

    RequestB is on and off setting for IK stretch when user need . (just connect deform bone with parent or not (default they are not connected)

    Request C is to free strech arm and hand for FK posing. (so snap will work correctly even though you make stretch pose in IK)

    Request A (add new pole target bone, which restrict pole move) may only need after you confrim other things

  12. engetudouiti reporter

    To easy test those, hope Thomas test with this script. (I attach script file too)

    you simply comment out and choose option, and run to set MHX rig from 3 option.

    OptA is my recommend one. (so I hope you add option, in MHX option, which restrict stretch pose for IK, (IK hand and IK foot still move free but not deform as stretch, then user can avoid snap issue, and may correctly position IK foot and hand, with visual)

    OptB is maybe Thomas hope it work, it simply disconnedt FK hand from parent, though you still need to edit your snap function, but without it snap FK to IK always move hand (because FK bone can not locate when IK hand have distance from IK shin tail) with OptB then run above script, (it simply change FK hand matrix to locate on IK hand) now snape work perfect. Though I afraid, if you make snap script so OptA still work or not.. ^^; (I afraid it)

    OptC simply return default set-up, with stretch pose, (even though it is really slight stretch, when IK foot/hand have distance from IK Shin/Forearm, you should see snap issue for FK snap IK (shrink)

    and pose IK, FK, then use snap function and compare please. with all option setting, I keep not forearm twist with hand (I do not know way to make it work for snap perfect)

    """
    1. Change the last function setting option opt = ["optA", "optB", "OptC"]
       with remove comment-out mark 
    
    2. select MHX g3 /g8 rig then run script
    
    optA restrict foot and hand stretch for IK (FK), so snap work perfect (my recommend)
    
    optB free move foot and hand and stretch pose with IK and FK. so snap will work perfect 
    (but Thomas need to edit snap func which correclty locate IK hand/foot onto FK)
    
    optC return as default (free move and stretch for IK only = it should cause snap issue with IK strech pose)
    
    """    
    
    import bpy
    
    blist = ["foot.R", "foot.L", "hand.R", "hand.L"]
    fklist =  ["hand.fk.L", "hand.fk.R"]
    
    def setConnect (rig, bn, flag):
        rig.edit_bones[bn].use_connect = flag
    
    
    def setOpt(opt):
        ob = bpy.context.active_object
        rig = ob.data
        cmode = ob.mode
        bpy.ops.object.mode_set(mode = "EDIT")
    
        if opt == "optA":
            for bn in blist:
                setConnect(rig, bn, True)
            for bn in fklist:
                setConnect(rig, bn, True)
    
        elif opt == "optB":
            for bn in blist:
                setConnect(rig, bn, False)
                print(bn)
            for bn in fklist:
                setConnect(rig, bn, False)
                print(bn)
    
        elif opt == "optC":
            for bn in blist:
                setConnect(rig, bn, False)
            for bn in fklist:
                setConnect(rig, bn, True)
        else:
            print("no option")
    
        bpy.ops.object.mode_set(mode = cmode)
    
    "remove commeentout of each option then run script"    
    
    my_opt = "optA"
    #my_opt = "optB"
    #my_opt = "optC"
    
    setOpt(my_opt)
    

    As my taste

    optA is best for non stretch animation. (it can make easy straight hand foot pose without afraid snap issue, and even though I move hip with keep IK, it never show stretch defrom.. any more,, stop with the restrcit. (though IK hand and foot are locate far away,,untill user notice it)

  13. engetudouiti reporter

    For optB (free strech with FK pose too, so snap work, and it can Pin hand and Foot mesh strictly, so I think it is good option too)

    after snap FK to IK (with stretch pose), I run this script (I suppose same thing may need for foot ) to correct shrink.

    about Opt B, I suppose Thomas can easy fix snap function to work it.

  14. engetudouiti reporter

    As best of best, (if you will enhance more) OptA and OptB may better to choose for each hand, foot, whenever user hope it.

    I find actually these option is useful and hope to set for each Limb case by case. Stretch ON and off,, maybe current default setting is not good at least for snap, (with IK strech deform but with FK non strech = snap issue)

    Though it actually change edit bone setting, so do not know if I exchange it in timeline and key, how it work. but basically I can change with each animation segments and if user know correctly, how stretch work with each option, change setting of bone connection make no harm for current animation with exchange FK <> IK. (and about both case snap may work well)

    What I am afraid is, if you make these option for each limb, snap function may need to change for OptA and OptB setting. at current add on snap function, OptA (non strech for IK / FK) work no issue for snapping, but for OptB (strech for FK/IK), add on need to change snap script.

    anyway at first I may expect if Thomas will add these connect setting for each MHX limb first without change snap function.

    (because even though you do not add those option, with strech IK pose snap FK to IK actually show problem (though it seems usuall thing for me, and can not avoid, without you use same strech setting for FK/IK limbs) then at least if you limit strech for IK snap should work. without change function.

    (but it means, IK foot and hand can not stretch, so with some pose your IK foot and hand may move, without you check current IK foot and hand position (when it need to stretch, it is restriced then hand, or foot will follow hip or other bone move)

  15. engetudouiti reporter

    As my request, I think this issue can be closed. (though if Thomas not content with current status, as I said you need to choose, (FK/IK both stretch) or (FK / IK non strech) (and need some edit for FK strech version. )

    I may hope to close this (as usuall I add many things in topic) devide my request, MHX offer new option toggle button, for “stretch on off “ about each limb.. to make things clear. (I like clickable button, like IK / FK switch which you offer for each limb)

  16. Log in to comment