code cleanup: de-duplicate ~75 lines copied twice - tsk tsk.


git-svn-id: https://svn.blender.org/svnroot/bf-blender/trunk/blender@54986 954f8c5b-7b00-dc11-b283-0030488c597c