Page MenuHome

Experimental workaround for IK's used with non-uniform bone scaling
AbandonedPublic

Authored by Campbell Barton (campbellbarton) on Jul 7 2016, 6:04 AM.

Details

Summary

Patch that solves IK's with uniform scaled bones to allow bones with Y-only scale to be used in an IK chain.
(Requested by @Daniel Martinez Lara (pepeland), see )

This patch is quite simple.

  • Before calculating IK's, make the bones uniform scale (match X/Z size to the Y axis).
  • Calculate IK's with uniform scale.
  • Apply the scale back after the IK's are calculated.

This is admittedly a workaround for supporting non-uniform scales in the solver, I stated to look into this, but this is quite involved - I suspect having rotations calculated predictably with non-uniform scale may be more trouble then its worth.

Heres a test file, see before after results:

Details:

  • Tested with/without inherit scale option.
  • If you delete the empty target, auto-IK with transform glitches a bit (moves after finishing transform), however even without this patch the problem exists.
  • The patch could be modified to check for non-uniform scale per bone and only perform extra work when non-uniform scales exist, but this could cause issues with very small changes in scale causing jittering... so rather leave this as is for now.

This patch is just to get initial feedback.

Diff Detail

Repository
rB Blender
Branch
TEMP-IK_SOLVER-NON_UNIFORM-WORKAROUND

Event Timeline

Campbell Barton (campbellbarton) retitled this revision from to Experimental workaround for IK's used with non-uniform bone scaling.

I'm feeling a bit silly right now, haha! XD Why oh why didn't I think of doing this when I had a look earlier!

It's great to see that you've managed to figure out a workaround for this :)

As you said, from what i saw when I tried solving this earlier for Daniel, it does look like it gets quite a bit more involved as soon as you try to actually make the code handle the non-uniform case. From what I could tell, the only alternative to doing to would have been to fix the way that we apply the IK solver results back to the bone - i.e. how we calculate and apply the "ikmat" stuff - but figuring out how to do that looks like it could get pretty nasty. It also seemed that the IK solver itself seemed fine as it didn't seem to know (or be given) anything about the scaled nature of the bones (unless Brecht could confirm otherwise).

So, from my side, this will be fine :)

Campbell Barton (campbellbarton) edited edge metadata.

Move math functions into BLI_math. Created normalize_*_length, this is handy since its quite common to normalize then scale to set the length. (could also be called normalize_*_mul_fl... but that feels a bit awkward).

  • rename normalize_*_scale -> length

From what I can tell this change doesn't even affect what the IK solver does, it is already supposed to ignore such non-uniform scale. The IK solver itself only knows about rotations and translations.

If you change the non-uniform scale work around to only affect step 6 it still gives the same result, step 5 is not affected by it. It seems to affect how scale is inherited or something like that?

A problem with this patch is that it discards the scale on the X and Z axes of bones. In the example file they are all 1.0, and if you change them to something else you'll see it has no effect, while without an IK solver scale on those axes has an effect.