Fix for an occasional crash in Freestyle stroke rendering.

Materials were freed before releasing meshes that may have references to the materials.
Indentation fix.
De-duplicated #includes.
Freestyle: Stroke rendering optimization.

Previously mesh objects were created for individual visible stroke segments (recalling that
a stroke may consist of alternate visible and invisible segments).  This could result in an
excessive memory consumption in stroke rendering when strokes are composed of many
short visible segments (for instance by means of dashed lines and/or blueprint geometry
modifiers).

Now mesh objects represent individual strokes instead of stroke segments, which tends to
reduce the number of generated mesh objects by an order of magnitude.
DopeSheet: View Selected recenters the view vertically to display the active channel
Code cleanup: Define a dedicated "channel_role" field for animchannel types

This makes it easier for finding the active or first selected channel
(where actual data channels need to be favoured over expanders - which come
first), as previously, long switch statements were needed everytime.
NLA Editor: View selected also recenters the view now (as in the DopeSheet Editor)
NLA Editor Bugfix: Select NLA tracks too when selecting strips
Tweaking tooltip for NLA tweakmode enter to be a bit more descriptive
Fix T40094 Faulty resizing behavior of frame node.

Frame nodes still have the "hidden" flag like all other nodes, but this
has to be ignored during resizing. width/height range for the frame
nodes must be unlimited for this to work correctly.
Fix T36973: Active snapping fails for edges/faces

also add snap-active support for armatures, pose & metas
Code cleanup: style
Metaball transform, support active-only option
Freestyle: Fix for a wrong interpolation of stroke segment visibility.
Freestyle: Fix for dashed lines when applied to invisible stroke segments.

Dashed lines were resetting stroke segment visibility by mistake (making invisible segments
visible, for example when applied to the results of square blueprint geometry modifier).
Fix for random crashes when grabbing (rmb-drag) NLA strips

Although these crashes were quite sporadic, they seemed to happen most when
rmb-dragging strips randomly in quick succession. The most likely cause seems
to be a null check I accidentally took out during one of my commits yesterday.
Fix T40108: Copying materials leaves a shared Action datablock in nested
bNodeTree blocks.

This was broken by rB6e99fb0 (own commit). I expected the `do_action`
argument to be of no importance in this case due to node trees using
material animation, but this is not the case.

Anyway, this patch adds back a do_action to the BKE_libblock_copy_nolib
function as well to restore the previous behavior.
Fix cycles motion pass for hair curves showing a bit of motion when there isn't any.
Fix T39585: cycles motion vector pass problem with curves.
Fix wrong job type used in cycles bake operator, could cause crashes.

Ref T40077.