Code cleanup: use typedefs for ui handler functions
Correct last commit: workaround for BGE
Fix T39053: Replace mesh actuator does not replace material (only mesh)

The replace mesh actuator was reconverting the mesh data which causes
conflicts with the LoD code. Instead, we just look for an already
converted mesh, which should already be in the scene.
View3d Toolbar: project-paint tools were in options, move into own panel
Bake-API prevent baking for engines that dont support the baking API

In the future we can fallback to the Blender Internal baking.

Review/Suggestions by Campbell Barton
Fix T40476 - Baking multiple selected objects in Cycles final result
depends on last selected object

Reviewers: campbellbarton

Differential Revision: https://developer.blender.org/D577
Bake-API small cleanup
Code cleanup: replace macro with function to reduce binary size
Change to key modifier should trigger re-evaluation of drag-and-drop

This change is part of a fix for T40435, but will postpone for now.

Original patch by Sergey Sharybin
Tweaks to bevel and crease transform

They were using INPUT_SPRING in a way which didn't allow
it to easily redo the operator because INPUT_SPRING internally
is stored as a ration between old value and new one and crease
and bevel were converting this to value delta.

Now made it special input type INPUT_SPRING_DELTA which is
storing delta of the spring, meaning now values in the redo
panel kind of makes sense -- they mean how much to add/remove
to the crease/bevel weight.

Expect to be no functional changes from interactive transform
POV, just a bit more convenient to use redo panel.
Fix T40489: Curve drawing skipped loose-wire when mixed with solid faces
Fix for dupli's ignoring color in set-scenes

also skip setting wire color drawing depth
Freestyle: Fix for a potential infinite loop in stroke resampling by vertex count.

Changes were made in Stroke::Resample(int) in C++ to prevent a potential infinite loop
caused by an inconsistency between Stroke::_Length and the stroke length computed
based on stroke vertices.  Such a stroke length inconsistency is usually caused by missing
calls of Stroke::UpdateLength() (i.e., API implementation bugs), but also may occur due
to scripting errors in user-defined style modules.  This commit is meant to help script
writters to identify the latter error cases.  Now Stroke.resample(int) may raise a runtime
error to signal an error condition.
OSX 10.10: fix for Blender crashing on fsmenu due icloud in the favorite list but pointer is NULL when not activated
This does not break other OSX versions, just add a check for pathString
Optimize editmode drawing edgees

Was interpolating and setting the color twice per edge.
Now only set the color when needed (can be once per draw),
~2x speedup for edge drawing.
Fix T40456: cycles bug with branched path + sss + no sample all direct lights.
Fix issues when ungrouping meta changes the final sequencer render

Seems to be caused by the way how the most bottom strip in the stack
used to apply effect. Just rendering strip in this cases will not give
proper results.

Made it so effect is applying between empty imbuf and actual strip.
Seems to work by tests, but more intense testing is required.
Fix T40478: wrong cycles fresnel with GLSL materials in the viewport.
Fix T40482: Cycles matlib file crashes

it's possible that runtime optimizer would call get_attribute
with NULL renderstate. As per documentation, it's valid to
return false in that cases and in worst case we'll just miss
some possible optimization.

Supporting such cases would require some bigger changes to
Cycles since attributes are only set to up for the kernel
after shader compilation.

Thanks Brecht for review!
BMesh: avoid using OpenMP when nothing to do

Gave slowdown drawing on high poly meshes