de257b6366
Original patch by Cody Winchester (@CodyWinch), several fixes and cleanup by Bastien Montagne (@mont29). Differential revision: https://developer.blender.org/D7656