Rigging a humanoid problem: Parenting with automatic weights twists legs around This is what my humanoid mesh looks like:



As you can see, after parenting the mesh with the armature, the legs twist around while other parts of the body look correct. Is this related to the roll of the lower leg bone? Recalculating the rolls yields different, but incorrect results. 



There are pole targets in front of the lower leg bones, I have adjusted the pole angle visible in screenshot 3 to get a correct a bending of the knee, but the mesh is still deformed.



Actually, I did get the mesh to look correct by correcting the pole angles of the lower leg bones, but then the bending of the knee is incorrect



Could somebody guide me in the right direction?
I found a solution:

BEFORE applying the armature to the mesh, I moved the leg bones so they wouldn't be completely straight and would have a slight bend in the direction the knee should move after being applied. After that, it was a matter of adjusting the pole angles.