Fix T39452: Meshes without materials causes a memory leak in the game engine

These types of meshes do not use material caching, and thus only the first created
material would be saved, but subsequent ones were not. Those subsequent materials
were then not being freed. Now we make sure to track all of the materials.

Note: Meshes that cannot make use of material caching (no materials or using face textures)
can still use up a large amount of RAM since a material is created per face.
Fix for curve smooth ignoring cyclic
RNA API: rename Sequence.elements.push() -> append()

also for SpaceNodeEditorPath
Code cleanup: use sqrtf when input and output are float
Code cleanup: use len_v2v2_int for view zoom-scale
BMesh: optimize quad_coord, avoid duplicate sqrt calls
View3D: replace RV3D_VIEW_PERSPORTHO with RV3D_VIEW_USER

This is hardly used, and may be removed later (looks like quad view used by accident).

It could cause the 2d grid to draw with the view at an angle.
BGE code cleanup: Removing OpenGL and bf_gpu code from KX_LightObject

The ultimate goal is to only allow the rasterizer to handle OpenGL and bf_gpu
calls. This commit creates a RAS_ILightObject interface and a RAS_OpenGLLight
implementation.
BGE code cleanup: Removing an unused include in KX_Light.cpp
Fix T39472: Changing Sequencer color space repeatedly changes movie strip's display gamma

Issue was caused by the old color space settings being lurking around
seq->anim after the changes in color space settings.
Unbreak carve build for clang

Based on D420
Fix T39455: Nodes scaled wrong when some in a frame, some not.

Transform operators for nodes were not taking parent nodes (frames) into
account. Now use the nodeToView/nodeFromView functions to apply
transforms in local node space.
Fix T39410: Crashes when Saving HiRes .tif
Fix for inset bug (edge rail had feedback loop with direction)

also disable edge-rail by default.
Fix T39288: Inset regression with extreme offset
Bevel Factor Mapping

Bevel Factor Mapping allows to control the relation between bevel factors
(number between 0 and 1) and the rendered start and end point of a beveled
spline.

There are three options: "Resolution", "Segments", "Spline". "Resolution"
option maps bevel factors as it was done < 2.71, "Spline" and "Segments"
are new.

* "Resolution“: Map the bevel factor to the number of subdivisions of a
  spline (U resolution).
* "Segments“: Map the bevel factor to the length of a segment and to the
  number of subdivisions of a segment.
* "Spline": Map the bevel factor to the length of a spline.

Reviewers: yakca, sergey, campbellbarton

CC: sanne

Differential Revision: https://developer.blender.org/D294
Fix T37599: Crash making linked objects local and undo

Root of the issues comes to the fact that it's possible to produce
a situation when library object data uses local object. This is
actually forbidden and not supported by .blend IO.

Made it so Make Local wouldn't produce such an unsupported states.

Reviewers: brecht

Differential Revision: https://developer.blender.org/D372
Implement asymmetric and free handles type for masks

Summary:
The title actually says it all, it's just possible to
have independent free handles for mask splines. Also
it's now possible to have aligned handles displayed
as independent handles.

Required changes in quite a few places, but they're
rather straightforward.

From user perspective there's one really visible change
which is removed Handle Type menu from the panel. With
asymmetric handles it's not clear which handle type to
display there. So now the only way to change handle type
is via V-key menu.

Rewrote normal evaluation function to make it deal
with new type of handles we support. Now it works in
the following way:

- Offset the original spline by maximal weight
- Calculate vector between corresponding U positions
  on offset and original spline
- Normalize this vector.

Seems to be giving more adequate results and doesn't
tend to self-intersect as much as old behavior used to,

There're still some changes which needed to be done, but
which are planned for further patch:

- Support colors and handle size via themes.
- Make handles color-coded, just the same as done for
  regular bezier splines in 3D viewport.

Additional changes to make roto workflow even better:
- Use circles to draw handles
- Support AA for handles
- Change click-create-drag to change curvature of the
  spline instead of adjusting point position.

Reviewers: campbellbarton

CC: sebastian_k, hype, cronk

Differential Revision: http://developer.blender.org/D121
Fix T39484: Time line: highlighted area for frame range one frame too short.

Just using same principle as the one already used for the 'cache bar': add -0.5/+0.5 offsets to start/end (also edited 'view all' op to match this).
Fix for mask vert add-slide dragging flipped direction