Merge branch 'master' into blender2.8
authorCampbell Barton <ideasman42@gmail.com>
Fri, 1 Jun 2018 16:26:42 +0000 (18:26 +0200)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 1 Jun 2018 16:26:42 +0000 (18:26 +0200)
275 files changed:
1  2 
source/blender/blenfont/BLF_api.h
source/blender/blenfont/intern/blf_font.c
source/blender/blenfont/intern/blf_glyph.c
source/blender/blenfont/intern/blf_internal.h
source/blender/blenfont/intern/blf_internal_types.h
source/blender/blenkernel/BKE_DerivedMesh.h
source/blender/blenkernel/BKE_animsys.h
source/blender/blenkernel/BKE_multires.h
source/blender/blenkernel/BKE_node.h
source/blender/blenkernel/BKE_paint.h
source/blender/blenkernel/intern/action.c
source/blender/blenkernel/intern/anim_sys.c
source/blender/blenkernel/intern/appdir.c
source/blender/blenkernel/intern/constraint.c
source/blender/blenkernel/intern/ipo.c
source/blender/blenkernel/intern/mball.c
source/blender/blenkernel/intern/modifier.c
source/blender/blenkernel/intern/nla.c
source/blender/blenkernel/intern/node.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/particle_system.c
source/blender/blenkernel/intern/pointcache.c
source/blender/blenkernel/intern/scene.c
source/blender/blenkernel/intern/sequencer.c
source/blender/blenkernel/intern/writeffmpeg.c
source/blender/blenlib/intern/math_geom.c
source/blender/blenloader/intern/readfile.c
source/blender/blentranslation/BLT_translation.h
source/blender/collada/AnimationExporter.cpp
source/blender/collada/AnimationImporter.cpp
source/blender/collada/collada_utils.cpp
source/blender/compositor/operations/COM_RenderLayersProg.cpp
source/blender/depsgraph/DEG_depsgraph.h
source/blender/depsgraph/util/deg_util_function.h
source/blender/editors/animation/anim_channels_edit.c
source/blender/editors/animation/anim_deps.c
source/blender/editors/animation/anim_draw.c
source/blender/editors/animation/anim_filter.c
source/blender/editors/animation/anim_intern.h
source/blender/editors/animation/anim_markers.c
source/blender/editors/animation/anim_ops.c
source/blender/editors/animation/drivers.c
source/blender/editors/animation/keyframing.c
source/blender/editors/animation/keyingsets.c
source/blender/editors/armature/armature_add.c
source/blender/editors/armature/armature_intern.h
source/blender/editors/armature/armature_ops.c
source/blender/editors/armature/meshlaplacian.c
source/blender/editors/armature/pose_edit.c
source/blender/editors/armature/pose_group.c
source/blender/editors/armature/pose_lib.c
source/blender/editors/armature/pose_utils.c
source/blender/editors/include/ED_anim_api.h
source/blender/editors/include/ED_fileselect.h
source/blender/editors/include/ED_image.h
source/blender/editors/include/ED_keyframing.h
source/blender/editors/include/ED_mesh.h
source/blender/editors/include/ED_node.h
source/blender/editors/include/ED_object.h
source/blender/editors/include/ED_screen.h
source/blender/editors/include/ED_screen_types.h
source/blender/editors/include/ED_sculpt.h
source/blender/editors/include/ED_space_api.h
source/blender/editors/include/ED_undo.h
source/blender/editors/include/ED_util.h
source/blender/editors/include/ED_uvedit.h
source/blender/editors/include/ED_view3d.h
source/blender/editors/include/UI_icons.h
source/blender/editors/include/UI_interface.h
source/blender/editors/include/UI_interface_icons.h
source/blender/editors/include/UI_resources.h
source/blender/editors/include/UI_view2d.h
source/blender/editors/io/io_collada.c
source/blender/editors/mesh/editmesh_knife.c
source/blender/editors/mesh/editmesh_loopcut.c
source/blender/editors/mesh/mesh_data.c
source/blender/editors/mesh/mesh_intern.h
source/blender/editors/mesh/mesh_ops.c
source/blender/editors/object/object_edit.c
source/blender/editors/object/object_intern.h
source/blender/editors/object/object_modifier.c
source/blender/editors/object/object_ops.c
source/blender/editors/physics/dynamicpaint_ops.c
source/blender/editors/physics/particle_boids.c
source/blender/editors/physics/particle_object.c
source/blender/editors/physics/physics_ops.c
source/blender/editors/render/render_intern.h
source/blender/editors/render/render_ops.c
source/blender/editors/render/render_shading.c
source/blender/editors/render/render_update.c
source/blender/editors/screen/area.c
source/blender/editors/screen/glutil.c
source/blender/editors/screen/screen_context.c
source/blender/editors/screen/screen_edit.c
source/blender/editors/screen/screen_intern.h
source/blender/editors/screen/screen_ops.c
source/blender/editors/sculpt_paint/paint_intern.h
source/blender/editors/sound/sound_ops.c
source/blender/editors/space_action/action_buttons.c
source/blender/editors/space_action/action_intern.h
source/blender/editors/space_action/space_action.c
source/blender/editors/space_api/spacetypes.c
source/blender/editors/space_buttons/buttons_context.c
source/blender/editors/space_buttons/buttons_intern.h
source/blender/editors/space_buttons/buttons_texture.c
source/blender/editors/space_buttons/space_buttons.c
source/blender/editors/space_clip/clip_graph_ops.c
source/blender/editors/space_clip/clip_utils.c
source/blender/editors/space_console/space_console.c
source/blender/editors/space_file/file_draw.c
source/blender/editors/space_file/file_panels.c
source/blender/editors/space_file/filesel.c
source/blender/editors/space_file/space_file.c
source/blender/editors/space_graph/graph_buttons.c
source/blender/editors/space_graph/graph_draw.c
source/blender/editors/space_graph/space_graph.c
source/blender/editors/space_image/image_intern.h
source/blender/editors/space_image/space_image.c
source/blender/editors/space_info/info_stats.c
source/blender/editors/space_info/space_info.c
source/blender/editors/space_nla/nla_channels.c
source/blender/editors/space_nla/nla_draw.c
source/blender/editors/space_nla/space_nla.c
source/blender/editors/space_node/drawnode.c
source/blender/editors/space_node/node_draw.c
source/blender/editors/space_node/node_edit.c
source/blender/editors/space_node/node_intern.h
source/blender/editors/space_node/node_ops.c
source/blender/editors/space_outliner/outliner_draw.c
source/blender/editors/space_outliner/outliner_edit.c
source/blender/editors/space_outliner/outliner_intern.h
source/blender/editors/space_outliner/outliner_ops.c
source/blender/editors/space_outliner/outliner_select.c
source/blender/editors/space_outliner/outliner_tools.c
source/blender/editors/space_outliner/outliner_tree.c
source/blender/editors/space_outliner/space_outliner.c
source/blender/editors/space_script/space_script.c
source/blender/editors/space_sequencer/sequencer_edit.c
source/blender/editors/space_sequencer/sequencer_intern.h
source/blender/editors/space_sequencer/space_sequencer.c
source/blender/editors/space_text/space_text.c
source/blender/editors/space_text/text_draw.c
source/blender/editors/space_userpref/space_userpref.c
source/blender/editors/space_view3d/space_view3d.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/space_view3d/view3d_fly.c
source/blender/editors/space_view3d/view3d_header.c
source/blender/editors/space_view3d/view3d_intern.h
source/blender/editors/space_view3d/view3d_ops.c
source/blender/editors/space_view3d/view3d_project.c
source/blender/editors/space_view3d/view3d_select.c
source/blender/editors/space_view3d/view3d_toolbar.c
source/blender/editors/space_view3d/view3d_view.c
source/blender/editors/util/ed_util.c
source/blender/editors/uvedit/uvedit_intern.h
source/blender/gpu/intern/gpu_material.c
source/blender/ikplugin/BIK_api.h
source/blender/ikplugin/intern/ikplugin_api.c
source/blender/ikplugin/intern/ikplugin_api.h
source/blender/ikplugin/intern/iksolver_plugin.h
source/blender/ikplugin/intern/itasc_plugin.h
source/blender/imbuf/intern/thumbs.c
source/blender/imbuf/intern/thumbs_blend.c
source/blender/makesdna/DNA_action_types.h
source/blender/makesdna/DNA_anim_types.h
source/blender/makesdna/DNA_constraint_types.h
source/blender/makesdna/DNA_curve_types.h
source/blender/makesdna/DNA_freestyle_types.h
source/blender/makesdna/DNA_gpencil_types.h
source/blender/makesdna/DNA_node_types.h
source/blender/makesdna/DNA_windowmanager_types.h
source/blender/makesdna/intern/makesdna.c
source/blender/modifiers/intern/MOD_skin.c
source/blender/nodes/NOD_socket.h
source/blender/nodes/composite/node_composite_tree.c
source/blender/nodes/composite/nodes/node_composite_image.c
source/blender/nodes/intern/node_exec.c
source/blender/nodes/intern/node_socket.c
source/blender/nodes/shader/node_shader_tree.c
source/blender/nodes/shader/node_shader_util.c
source/blender/nodes/shader/node_shader_util.h
source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c
source/blender/nodes/shader/nodes/node_shader_blackbody.c
source/blender/nodes/shader/nodes/node_shader_brightness.c
source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c
source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c
source/blender/nodes/shader/nodes/node_shader_bsdf_hair.c
source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c
source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c
source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c
source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.c
source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c
source/blender/nodes/shader/nodes/node_shader_bump.c
source/blender/nodes/shader/nodes/node_shader_camera.c
source/blender/nodes/shader/nodes/node_shader_curves.c
source/blender/nodes/shader/nodes/node_shader_emission.c
source/blender/nodes/shader/nodes/node_shader_fresnel.c
source/blender/nodes/shader/nodes/node_shader_gamma.c
source/blender/nodes/shader/nodes/node_shader_geometry.c
source/blender/nodes/shader/nodes/node_shader_hueSatVal.c
source/blender/nodes/shader/nodes/node_shader_invert.c
source/blender/nodes/shader/nodes/node_shader_layer_weight.c
source/blender/nodes/shader/nodes/node_shader_light_falloff.c
source/blender/nodes/shader/nodes/node_shader_light_path.c
source/blender/nodes/shader/nodes/node_shader_mapping.c
source/blender/nodes/shader/nodes/node_shader_math.c
source/blender/nodes/shader/nodes/node_shader_mixRgb.c
source/blender/nodes/shader/nodes/node_shader_mix_shader.c
source/blender/nodes/shader/nodes/node_shader_normal.c
source/blender/nodes/shader/nodes/node_shader_object_info.c
source/blender/nodes/shader/nodes/node_shader_output_material.c
source/blender/nodes/shader/nodes/node_shader_output_world.c
source/blender/nodes/shader/nodes/node_shader_rgb.c
source/blender/nodes/shader/nodes/node_shader_sepcombHSV.c
source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c
source/blender/nodes/shader/nodes/node_shader_sepcombXYZ.c
source/blender/nodes/shader/nodes/node_shader_squeeze.c
source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c
source/blender/nodes/shader/nodes/node_shader_tex_brick.c
source/blender/nodes/shader/nodes/node_shader_tex_checker.c
source/blender/nodes/shader/nodes/node_shader_tex_coord.c
source/blender/nodes/shader/nodes/node_shader_tex_environment.c
source/blender/nodes/shader/nodes/node_shader_tex_gradient.c
source/blender/nodes/shader/nodes/node_shader_tex_image.c
source/blender/nodes/shader/nodes/node_shader_tex_magic.c
source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c
source/blender/nodes/shader/nodes/node_shader_tex_noise.c
source/blender/nodes/shader/nodes/node_shader_tex_sky.c
source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c
source/blender/nodes/shader/nodes/node_shader_tex_wave.c
source/blender/nodes/shader/nodes/node_shader_valToRgb.c
source/blender/nodes/shader/nodes/node_shader_value.c
source/blender/nodes/shader/nodes/node_shader_vectMath.c
source/blender/nodes/shader/nodes/node_shader_vectTransform.c
source/blender/nodes/shader/nodes/node_shader_volume_scatter.c
source/blender/nodes/texture/node_texture_util.h
source/blender/nodes/texture/nodes/node_texture_image.c
source/blender/nodes/texture/nodes/node_texture_proc.c
source/blender/nodes/texture/nodes/node_texture_texture.c
source/blender/physics/intern/hair_volume.cpp
source/blender/python/intern/gpu.c
source/blender/render/extern/include/RE_bake.h
source/blender/render/extern/include/RE_engine.h
source/blender/render/extern/include/RE_multires_bake.h
source/blender/render/extern/include/RE_pipeline.h
source/blender/render/extern/include/RE_render_ext.h
source/blender/render/extern/include/RE_shader_ext.h
source/blender/render/intern/include/render_result.h
source/blender/render/intern/include/renderpipeline.h
source/blender/render/intern/include/zbuf.h
source/blender/render/intern/source/imagetexture.c
source/blender/render/intern/source/pipeline.c
source/blender/render/intern/source/render_result.c
source/blender/windowmanager/WM_api.h
source/blender/windowmanager/WM_keymap.h
source/blender/windowmanager/WM_types.h
source/blender/windowmanager/intern/wm.c
source/blender/windowmanager/intern/wm_cursors.c
source/blender/windowmanager/intern/wm_dragdrop.c
source/blender/windowmanager/intern/wm_draw.c
source/blender/windowmanager/intern/wm_event_system.c
source/blender/windowmanager/intern/wm_files.c
source/blender/windowmanager/intern/wm_files_link.c
source/blender/windowmanager/intern/wm_init_exit.c
source/blender/windowmanager/intern/wm_keymap.c
source/blender/windowmanager/intern/wm_operators.c
source/blender/windowmanager/intern/wm_subwindow.c
source/blender/windowmanager/intern/wm_tooltip.c
source/blender/windowmanager/intern/wm_window.c
source/blender/windowmanager/wm.h
source/blender/windowmanager/wm_draw.h
source/blender/windowmanager/wm_event_system.h
source/blender/windowmanager/wm_event_types.h
source/blender/windowmanager/wm_files.h
source/blender/windowmanager/wm_window.h

Simple merge
Simple merge
Simple merge
@@@ -2660,10 -2622,21 +2660,10 @@@ static void animsys_evaluate_nla(Depsgr
  }
  
  /* NLA Evaluation function (mostly for use through do_animdata) 
-  *    - All channels that will be affected are not cleared anymore. Instead, we just evaluate into 
+  *    - All channels that will be affected are not cleared anymore. Instead, we just evaluate into
   *            some temp channels, where values can be accumulated in one go.
   */
 -static void animsys_calculate_nla(PointerRNA *ptr, AnimData *adt, float ctime)
 +static void animsys_calculate_nla(Depsgraph *depsgraph, PointerRNA *ptr, AnimData *adt, float ctime)
  {
        ListBase echannels = {NULL, NULL};
  
@@@ -2747,10 -2720,10 +2747,10 @@@ static void animsys_evaluate_overrides(
  /* Evaluation loop for evaluation animation data 
   *
   * This assumes that the animation-data provided belongs to the ID block in question,
-  * and that the flags for which parts of the anim-data settings need to be recalculated 
-  * have been set already by the depsgraph. Now, we use the recalc 
+  * and that the flags for which parts of the anim-data settings need to be recalculated
+  * have been set already by the depsgraph. Now, we use the recalc
   */
 -void BKE_animsys_evaluate_animdata(Scene *scene, ID *id, AnimData *adt, float ctime, short recalc)
 +void BKE_animsys_evaluate_animdata(Depsgraph *depsgraph, Scene *scene, ID *id, AnimData *adt, float ctime, short recalc)
  {
        PointerRNA id_ptr;
        
  /* Constraint Target Macros */
  #define VALID_CONS_TARGET(ct) ((ct) && (ct->tar))
  
 -/* Workaround for cyclic depenndnecy with curves.
 - * In such case curve_cache might not be ready yet,
 - */
 -#define CYCLIC_DEPENDENCY_WORKAROUND
 -
  /* ************************ Constraints - General Utilities *************************** */
  /* These functions here don't act on any specific constraints, and are therefore should/will
-  * not require any of the special function-pointers afforded by the relevant constraint 
+  * not require any of the special function-pointers afforded by the relevant constraint
   * type-info structs.
   */
  
@@@ -4910,10 -4966,10 +4910,10 @@@ void BKE_constraint_targets_for_solving
  /* This function is called whenever constraints need to be evaluated. Currently, all
   * constraints that can be evaluated are every time this gets run.
   *
-  * BKE_constraints_make_evalob and BKE_constraints_clear_evalob should be called before and 
+  * BKE_constraints_make_evalob and BKE_constraints_clear_evalob should be called before and
   * after running this function, to sort out cob
   */
 -void BKE_constraints_solve(ListBase *conlist, bConstraintOb *cob, float ctime)
 +void BKE_constraints_solve(struct Depsgraph *depsgraph, ListBase *conlist, bConstraintOb *cob, float ctime)
  {
        bConstraint *con;
        float oldmat[4][4];
@@@ -3391,13 -3293,13 +3391,13 @@@ static void obrel_list_add(LinkNode **l
  }
  
  /*
 - * Iterates over all objects of the given scene.
 + * Iterates over all objects of the given scene layer.
   * Depending on the eObjectSet flag:
   * collect either OB_SET_ALL, OB_SET_VISIBLE or OB_SET_SELECTED objects.
-  * If OB_SET_VISIBLE or OB_SET_SELECTED are collected, 
+  * If OB_SET_VISIBLE or OB_SET_SELECTED are collected,
   * then also add related objects according to the given includeFilters.
   */
 -LinkNode *BKE_object_relational_superset(struct Scene *scene, eObjectSet objectSet, eObRelationTypes includeFilter)
 +LinkNode *BKE_object_relational_superset(struct ViewLayer *view_layer, eObjectSet objectSet, eObRelationTypes includeFilter)
  {
        LinkNode *links = NULL;
  
@@@ -769,217 -765,9 +769,217 @@@ float dist_squared_ray_to_aabb_v3_simpl
  /** \} */
  
  
 +/* -------------------------------------------------------------------- */
 +/** \name dist_squared_to_projected_aabb and helpers
 +* \{ */
 +
 +/**
 + * \param projmat: Projection Matrix (usually perspective
 + * matrix multiplied by object matrix).
 + */
 +void dist_squared_to_projected_aabb_precalc(
 +        struct DistProjectedAABBPrecalc *precalc,
 +        const float projmat[4][4], const float winsize[2], const float mval[2])
 +{
 +      float win_half[2], relative_mval[2], px[4], py[4];
 +
 +      mul_v2_v2fl(win_half, winsize, 0.5f);
 +      sub_v2_v2v2(precalc->mval, mval, win_half);
 +
 +      relative_mval[0] = precalc->mval[0] / win_half[0];
 +      relative_mval[1] = precalc->mval[1] / win_half[1];
 +
 +      copy_m4_m4(precalc->pmat, projmat);
 +      for (int i = 0; i < 4; i++) {
 +              px[i] = precalc->pmat[i][0] - precalc->pmat[i][3] * relative_mval[0];
 +              py[i] = precalc->pmat[i][1] - precalc->pmat[i][3] * relative_mval[1];
 +
 +              precalc->pmat[i][0] *= win_half[0];
 +              precalc->pmat[i][1] *= win_half[1];
 +      }
 +#if 0
 +      float projmat_trans[4][4];
 +      transpose_m4_m4(projmat_trans, projmat);
 +      if (!isect_plane_plane_plane_v3(
 +              projmat_trans[0], projmat_trans[1], projmat_trans[3],
 +              precalc->ray_origin))
 +      {
 +              /* Orthographic projection. */
 +              isect_plane_plane_v3(
 +                      px, py,
 +                      precalc->ray_origin,
 +                      precalc->ray_direction);
 +      }
 +      else {
 +              /* Perspective projection. */
 +              cross_v3_v3v3(precalc->ray_direction, py, px);
 +              //normalize_v3(precalc->ray_direction);
 +      }
 +#else
 +      if (!isect_plane_plane_v3(
 +              px, py,
 +              precalc->ray_origin,
 +              precalc->ray_direction))
 +      {
 +              /* Matrix with weird coplanar planes. Undetermined origin.*/
 +              zero_v3(precalc->ray_origin);
 +              precalc->ray_direction[0] = precalc->pmat[0][3];
 +              precalc->ray_direction[1] = precalc->pmat[1][3];
 +              precalc->ray_direction[2] = precalc->pmat[2][3];
 +      }
 +#endif
 +
 +      for (int i = 0; i < 3; i++) {
 +              precalc->ray_inv_dir[i] =
 +                      (precalc->ray_direction[i] != 0.0f) ?
 +                      (1.0f / precalc->ray_direction[i]) : FLT_MAX;
 +      }
 +}
 +
 +/* Returns the distance from a 2d coordinate to a BoundBox (Projected) */
 +float dist_squared_to_projected_aabb(
 +        struct DistProjectedAABBPrecalc *data,
 +        const float bbmin[3], const float bbmax[3],
 +        bool r_axis_closest[3])
 +{
 +      float local_bvmin[3], local_bvmax[3];
 +      aabb_get_near_far_from_plane(
 +              data->ray_direction, bbmin, bbmax, local_bvmin, local_bvmax);
 +
 +      const float tmin[3] = {
 +              (local_bvmin[0] - data->ray_origin[0]) * data->ray_inv_dir[0],
 +              (local_bvmin[1] - data->ray_origin[1]) * data->ray_inv_dir[1],
 +              (local_bvmin[2] - data->ray_origin[2]) * data->ray_inv_dir[2],
 +      };
 +      const float tmax[3] = {
 +              (local_bvmax[0] - data->ray_origin[0]) * data->ray_inv_dir[0],
 +              (local_bvmax[1] - data->ray_origin[1]) * data->ray_inv_dir[1],
 +              (local_bvmax[2] - data->ray_origin[2]) * data->ray_inv_dir[2],
 +      };
 +      /* `va` and `vb` are the coordinates of the AABB edge closest to the ray */
 +      float va[3], vb[3];
 +      /* `rtmin` and `rtmax` are the minimum and maximum distances of the ray hits on the AABB */
 +      float rtmin, rtmax;
 +      int main_axis;
 +
 +      if ((tmax[0] <= tmax[1]) && (tmax[0] <= tmax[2])) {
 +              rtmax = tmax[0];
 +              va[0] = vb[0] = local_bvmax[0];
 +              main_axis = 3;
 +              r_axis_closest[0] = data->ray_direction[0] < 0.0f;
 +      }
 +      else if ((tmax[1] <= tmax[0]) && (tmax[1] <= tmax[2])) {
 +              rtmax = tmax[1];
 +              va[1] = vb[1] = local_bvmax[1];
 +              main_axis = 2;
 +              r_axis_closest[1] = data->ray_direction[1] < 0.0f;
 +      }
 +      else {
 +              rtmax = tmax[2];
 +              va[2] = vb[2] = local_bvmax[2];
 +              main_axis = 1;
 +              r_axis_closest[2] = data->ray_direction[2] < 0.0f;
 +      }
 +
 +      if ((tmin[0] >= tmin[1]) && (tmin[0] >= tmin[2])) {
 +              rtmin = tmin[0];
 +              va[0] = vb[0] = local_bvmin[0];
 +              main_axis -= 3;
 +              r_axis_closest[0] = data->ray_direction[0] >= 0.0f;
 +      }
 +      else if ((tmin[1] >= tmin[0]) && (tmin[1] >= tmin[2])) {
 +              rtmin = tmin[1];
 +              va[1] = vb[1] = local_bvmin[1];
 +              main_axis -= 1;
 +              r_axis_closest[1] = data->ray_direction[1] >= 0.0f;
 +      }
 +      else {
 +              rtmin = tmin[2];
 +              va[2] = vb[2] = local_bvmin[2];
 +              main_axis -= 2;
 +              r_axis_closest[2] = data->ray_direction[2] >= 0.0f;
 +      }
 +      if (main_axis < 0) {
 +              main_axis += 3;
 +      }
 +
 +      /* if rtmin <= rtmax, ray intersect `AABB` */
 +      if (rtmin <= rtmax) {
 +              return 0;
 +      }
 +
 +      if (data->ray_direction[main_axis] >= 0.0f) {
 +              va[main_axis] = local_bvmin[main_axis];
 +              vb[main_axis] = local_bvmax[main_axis];
 +      }
 +      else {
 +              va[main_axis] = local_bvmax[main_axis];
 +              vb[main_axis] = local_bvmin[main_axis];
 +      }
 +      float scale = fabsf(local_bvmax[main_axis] - local_bvmin[main_axis]);
 +
 +      float va2d[2] = {
 +              (dot_m4_v3_row_x(data->pmat, va) + data->pmat[3][0]),
 +              (dot_m4_v3_row_y(data->pmat, va) + data->pmat[3][1]),
 +      };
 +      float vb2d[2] = {
 +              (va2d[0] + data->pmat[main_axis][0] * scale),
 +              (va2d[1] + data->pmat[main_axis][1] * scale),
 +      };
 +
 +      float w_a = mul_project_m4_v3_zfac(data->pmat, va);
 +      if (w_a != 1.0f) {
 +              /* Perspective Projection. */
 +              float w_b = w_a + data->pmat[main_axis][3] * scale;
 +              va2d[0] /= w_a;
 +              va2d[1] /= w_a;
 +              vb2d[0] /= w_b;
 +              vb2d[1] /= w_b;
 +      }
 +
 +      float dvec[2], edge[2], lambda, rdist_sq;
 +      sub_v2_v2v2(dvec, data->mval, va2d);
 +      sub_v2_v2v2(edge, vb2d, va2d);
 +      lambda = dot_v2v2(dvec, edge);
 +      if (lambda != 0.0f) {
 +              lambda /= len_squared_v2(edge);
 +              if (lambda <= 0.0f) {
 +                      rdist_sq = len_squared_v2v2(data->mval, va2d);
 +                      r_axis_closest[main_axis] = true;
 +              }
 +              else if (lambda >= 1.0f) {
 +                      rdist_sq = len_squared_v2v2(data->mval, vb2d);
 +                      r_axis_closest[main_axis] = false;
 +              }
 +              else {
 +                      madd_v2_v2fl(va2d, edge, lambda);
 +                      rdist_sq = len_squared_v2v2(data->mval, va2d);
 +                      r_axis_closest[main_axis] = lambda < 0.5f;
 +              }
 +      }
 +      else {
 +              rdist_sq = len_squared_v2v2(data->mval, va2d);
 +      }
 +
 +      return rdist_sq;
 +}
 +
 +float dist_squared_to_projected_aabb_simple(
 +        const float projmat[4][4], const float winsize[2], const float mval[2],
 +        const float bbmin[3], const float bbmax[3])
 +{
 +      struct DistProjectedAABBPrecalc data;
 +      dist_squared_to_projected_aabb_precalc(&data, projmat, winsize, mval);
 +
 +      bool dummy[3] = {true, true, true};
 +      return dist_squared_to_projected_aabb(&data, bbmin, bbmax, dummy);
 +}
 +/** \} */
 +
 +
  /* Adapted from "Real-Time Collision Detection" by Christer Ericson,
   * published by Morgan Kaufmann Publishers, copyright 2005 Elsevier Inc.
-  * 
+  *
   * Set 'r' to the point in triangle (a, b, c) closest to point 'p' */
  void closest_on_tri_to_point_v3(float r[3], const float p[3],
                                  const float a[3], const float b[3], const float c[3])
@@@ -178,12 -165,10 +178,12 @@@ static bool pose_has_protected_selected
  /* For the object with pose/action: update paths for those that have got them
   * This should selectively update paths that exist...
   *
-  * To be called from various tools that do incremental updates 
+  * To be called from various tools that do incremental updates
   */
 -void ED_pose_recalculate_paths(Scene *scene, Object *ob)
 +void ED_pose_recalculate_paths(bContext *C, Scene *scene, Object *ob)
  {
 +      struct Main *bmain = CTX_data_main(C);
 +      Depsgraph *depsgraph = CTX_data_depsgraph(C);
        ListBase targets = {NULL, NULL};
        
        /* set flag to force recalc, then grab the relevant bones to target */
@@@ -106,10 -104,10 +106,10 @@@ int insert_vert_fcurve(struct FCurve *f
  /* -------- */
  
  /* Secondary Keyframing API calls: 
-  *    Use this to insert a keyframe using the current value being keyframed, in the 
+  *    Use this to insert a keyframe using the current value being keyframed, in the
   *    nominated F-Curve (no creation of animation data performed). Returns success.
   */
 -bool insert_keyframe_direct(struct ReportList *reports, struct PointerRNA ptr, struct PropertyRNA *prop, struct FCurve *fcu, float cfra, eBezTriple_KeyframeType keytype, eInsertKeyFlags flag);
 +bool insert_keyframe_direct(struct Depsgraph *depsgraph, struct ReportList *reports, struct PointerRNA ptr, struct PropertyRNA *prop, struct FCurve *fcu, float cfra, eBezTriple_KeyframeType keytype, eInsertKeyFlags flag);
  
  /* -------- */
  
Simple merge
@@@ -409,27 -396,39 +409,27 @@@ static void draw_fcurve_handles(SpaceIp
  /* Samples ---------------- */
  
  /* helper func - draw sample-range marker for an F-Curve as a cross 
-  * NOTE: the caller MUST HAVE GL_LINE_SMOOTH & GL_BLEND ENABLED, otherwise, the controls don't 
+  * NOTE: the caller MUST HAVE GL_LINE_SMOOTH & GL_BLEND ENABLED, otherwise, the controls don't
   * have a consistent appearance (due to off-pixel alignments)...
   */
 -static void draw_fcurve_sample_control(float x, float y, float xscale, float yscale, float hsize)
 +static void draw_fcurve_sample_control(float x, float y, float xscale, float yscale, float hsize, unsigned int pos)
  {
 -      static GLuint displist = 0;
 -      
 -      /* initialize X shape */
 -      if (displist == 0) {
 -              displist = glGenLists(1);
 -              glNewList(displist, GL_COMPILE);
 -              
 -              glBegin(GL_LINES);
 -              glVertex2f(-0.7f, -0.7f);
 -              glVertex2f(+0.7f, +0.7f);
 -                      
 -              glVertex2f(-0.7f, +0.7f);
 -              glVertex2f(+0.7f, -0.7f);
 -              glEnd();  /* GL_LINES */
 -              
 -              glEndList();
 -      }
 -      
        /* adjust view transform before starting */
 -      glTranslatef(x, y, 0.0f);
 -      glScalef(1.0f / xscale * hsize, 1.0f / yscale * hsize, 1.0f);
 -      
 -      /* draw! */
 -      glCallList(displist);
 -      
 +      gpuPushMatrix();
 +      gpuTranslate2f(x, y);
 +      gpuScale2f(1.0f / xscale * hsize, 1.0f / yscale * hsize);
 +
 +      /* draw X shape */
 +      immBegin(GWN_PRIM_LINES, 4);
 +      immVertex2f(pos, -0.7f, -0.7f);
 +      immVertex2f(pos, +0.7f, +0.7f);
 +
 +      immVertex2f(pos, -0.7f, +0.7f);
 +      immVertex2f(pos, +0.7f, -0.7f);
 +      immEnd();
 +
        /* restore view transform */
 -      glScalef(xscale / hsize, yscale / hsize, 1.0);
 -      glTranslatef(-x, -y, 0.0f);
 +      gpuPopMatrix();
  }
  
  /* helper func - draw keyframe vertices only for an F-Curve */
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -249,106 -197,204 +249,106 @@@ static void wm_draw_callbacks(wmWindow 
        }
  }
  
 -static void wm_method_draw_full(bContext *C, wmWindow *win)
 -{
 -      bScreen *screen = win->screen;
 -      ScrArea *sa;
 -      ARegion *ar;
  
 -      /* draw area regions */
 -      for (sa = screen->areabase.first; sa; sa = sa->next) {
 -              CTX_wm_area_set(C, sa);
 +/************************* Region drawing. ********************************
-  * 
++ *
 + * Each region draws into its own framebuffer, which is then blit on the
 + * window draw buffer. This helps with fast redrawing if only some regions
 + * change. It also means we can share a single context for multiple windows,
 + * so that for example VAOs can be shared between windows. */
  
 -              for (ar = sa->regionbase.first; ar; ar = ar->next) {
 -                      if (ar->swinid) {
 -                              CTX_wm_region_set(C, ar);
 -                              ED_region_do_draw(C, ar);
 -                              ar->do_draw = false;
 -                              wm_paintcursor_draw(C, ar);
 -                              CTX_wm_region_set(C, NULL);
 +static void wm_draw_region_buffer_free(ARegion *ar)
 +{
 +      if (ar->draw_buffer) {
 +              for (int view = 0; view < 2; view++) {
 +                      if (ar->draw_buffer->offscreen[view]) {
 +                              GPU_offscreen_free(ar->draw_buffer->offscreen[view]);
 +                      }
 +                      if (ar->draw_buffer->viewport[view]) {
 +                              GPU_viewport_free(ar->draw_buffer->viewport[view]);
                        }
                }
 -              
 -              wm_area_mark_invalid_backbuf(sa);
 -              CTX_wm_area_set(C, NULL);
 -      }
  
 -      ED_screen_draw_edges(win);
 -      screen->do_draw = false;
 -      wm_draw_callbacks(win);
 -
 -      /* draw overlapping regions */
 -      for (ar = screen->regionbase.first; ar; ar = ar->next) {
 -              if (ar->swinid) {
 -                      CTX_wm_menu_set(C, ar);
 -                      ED_region_do_draw(C, ar);
 -                      ar->do_draw = false;
 -                      CTX_wm_menu_set(C, NULL);
 -              }
 +              MEM_freeN(ar->draw_buffer);
 +              ar->draw_buffer = NULL;
        }
 -
 -      if (screen->do_draw_gesture)
 -              wm_gesture_draw(win);
  }
  
 -/****************** draw overlap all **********************/
 -/* - redraw marked areas, and anything that overlaps it   */
 -/* - it also handles swap exchange optionally, assuming   */
 -/*   that on swap no clearing happens and we get back the */
 -/*   same buffer as we swapped to the front               */
 -
 -/* mark area-regions to redraw if overlapped with rect */
 -static void wm_flush_regions_down(bScreen *screen, rcti *dirty)
 +static void wm_draw_offscreen_texture_parameters(GPUOffScreen *offscreen)
  {
 -      ScrArea *sa;
 -      ARegion *ar;
 +      /* Setup offscreen color texture for drawing. */
 +      GPUTexture *texture = GPU_offscreen_color_texture(offscreen);
  
 -      for (sa = screen->areabase.first; sa; sa = sa->next) {
 -              for (ar = sa->regionbase.first; ar; ar = ar->next) {
 -                      if (BLI_rcti_isect(dirty, &ar->winrct, NULL)) {
 -                              ar->do_draw = RGN_DRAW;
 -                              memset(&ar->drawrct, 0, sizeof(ar->drawrct));
 -                              ar->swap = WIN_NONE_OK;
 -                      }
 -              }
 -      }
 +      /* We don't support multisample textures here. */
 +      BLI_assert(GPU_texture_target(texture) == GL_TEXTURE_2D);
 +
 +      glBindTexture(GL_TEXTURE_2D, GPU_texture_opengl_bindcode(texture));
 +
 +      /* No mipmaps or filtering. */
 +      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
 +      /* GL_TEXTURE_BASE_LEVEL = 0 by default */
 +      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
 +      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 +
 +      glBindTexture(GL_TEXTURE_2D, 0);
  }
  
 -/* mark menu-regions to redraw if overlapped with rect */
 -static void wm_flush_regions_up(bScreen *screen, rcti *dirty)
 +static void wm_draw_region_buffer_create(ARegion *ar, bool stereo, bool use_viewport)
  {
 -      ARegion *ar;
 -      
 -      for (ar = screen->regionbase.first; ar; ar = ar->next) {
 -              if (BLI_rcti_isect(dirty, &ar->winrct, NULL)) {
 -                      ar->do_draw = RGN_DRAW;
 -                      memset(&ar->drawrct, 0, sizeof(ar->drawrct));
 -                      ar->swap = WIN_NONE_OK;
 +      if (ar->draw_buffer) {
 +              if (ar->draw_buffer->stereo != stereo) {
 +                      /* Free draw buffer on stereo changes. */
 +                      wm_draw_region_buffer_free(ar);
 +              }
 +              else {
 +                      /* Free offscreen buffer on size changes. Viewport auto resizes. */
 +                      GPUOffScreen *offscreen = ar->draw_buffer->offscreen[0];
 +                      if (offscreen && (GPU_offscreen_width(offscreen) != ar->winx ||
 +                                        GPU_offscreen_height(offscreen) != ar->winy))
 +                      {
 +                              wm_draw_region_buffer_free(ar);
 +                      }
                }
        }
 -}
 -
 -static void wm_method_draw_overlap_all(bContext *C, wmWindow *win, int exchange)
 -{
 -      wmWindowManager *wm = CTX_wm_manager(C);
 -      bScreen *screen = win->screen;
 -      ScrArea *sa;
 -      ARegion *ar;
 -      static rcti rect = {0, 0, 0, 0};
  
 -      /* after backbuffer selection draw, we need to redraw */
 -      for (sa = screen->areabase.first; sa; sa = sa->next)
 -              for (ar = sa->regionbase.first; ar; ar = ar->next)
 -                      if (ar->swinid && !wm_area_test_invalid_backbuf(sa))
 -                              ED_region_tag_redraw(ar);
 -
 -      /* flush overlapping regions */
 -      if (screen->regionbase.first) {
 -              /* flush redraws of area regions up to overlapping regions */
 -              for (sa = screen->areabase.first; sa; sa = sa->next)
 -                      for (ar = sa->regionbase.first; ar; ar = ar->next)
 -                              if (ar->swinid && ar->do_draw)
 -                                      wm_flush_regions_up(screen, &ar->winrct);
 -              
 -              /* flush between overlapping regions */
 -              for (ar = screen->regionbase.last; ar; ar = ar->prev)
 -                      if (ar->swinid && ar->do_draw)
 -                              wm_flush_regions_up(screen, &ar->winrct);
 -              
 -              /* flush redraws of overlapping regions down to area regions */
 -              for (ar = screen->regionbase.last; ar; ar = ar->prev)
 -                      if (ar->swinid && ar->do_draw)
 -                              wm_flush_regions_down(screen, &ar->winrct);
 -      }
 +      if (!ar->draw_buffer) {
 +              if (use_viewport) {
 +                      /* Allocate viewport which includes an offscreen buffer with depth
 +                       * multisample, etc. */
 +                      ar->draw_buffer = MEM_callocN(sizeof(wmDrawBuffer), "wmDrawBuffer");
 +                      ar->draw_buffer->viewport[0] = GPU_viewport_create();
 +                      ar->draw_buffer->viewport[1] = (stereo) ? GPU_viewport_create() : NULL;
 +              }
 +              else {
 +                      /* Allocate offscreen buffer if it does not exist. This one has no
 +                       * depth or multisample buffers. 3D view creates own buffers with
 +                       * the data it needs. */
 +                      GPUOffScreen *offscreen = GPU_offscreen_create(ar->winx, ar->winy, 0, false, false, NULL);
 +                      if (!offscreen) {
 +                              return;
 +                      }
  
 -      /* flush drag item */
 -      if (rect.xmin != rect.xmax) {
 -              wm_flush_regions_down(screen, &rect);
 -              rect.xmin = rect.xmax = 0;
 -      }
 -      if (wm->drags.first) {
 -              /* doesnt draw, fills rect with boundbox */
 -              wm_drags_draw(C, win, &rect);
 -      }
 -      
 -      /* draw marked area regions */
 -      for (sa = screen->areabase.first; sa; sa = sa->next) {
 -              CTX_wm_area_set(C, sa);
 +                      wm_draw_offscreen_texture_parameters(offscreen);
  
 -              for (ar = sa->regionbase.first; ar; ar = ar->next) {
 -                      if (ar->swinid) {
 -                              if (ar->do_draw) {
 -                                      CTX_wm_region_set(C, ar);
 -                                      ED_region_do_draw(C, ar);
 -                                      ar->do_draw = false;
 -                                      wm_paintcursor_draw(C, ar);
 -                                      CTX_wm_region_set(C, NULL);
 +                      GPUOffScreen *offscreen_right = NULL;
 +                      if (stereo) {
 +                              offscreen_right = GPU_offscreen_create(ar->winx, ar->winy, 0, false, false, NULL);
  
 -                                      if (exchange)
 -                                              ar->swap = WIN_FRONT_OK;
 +                              if (!offscreen_right) {
 +                                      GPU_offscreen_free(offscreen);
 +                                      return;
                                }
 -                              else if (exchange) {
 -                                      if (ar->swap == WIN_FRONT_OK) {
 -                                              CTX_wm_region_set(C, ar);
 -                                              ED_region_do_draw(C, ar);
 -                                              ar->do_draw = false;
 -                                              wm_paintcursor_draw(C, ar);
 -                                              CTX_wm_region_set(C, NULL);
  
 -                                              ar->swap = WIN_BOTH_OK;
 -                                      }
 -                                      else if (ar->swap == WIN_BACK_OK)
 -                                              ar->swap = WIN_FRONT_OK;
 -                                      else if (ar->swap == WIN_BOTH_OK)
 -                                              ar->swap = WIN_BOTH_OK;
 -                              }
 +                              wm_draw_offscreen_texture_parameters(offscreen_right);
                        }
 -              }
 -
 -              wm_area_mark_invalid_backbuf(sa);
 -              CTX_wm_area_set(C, NULL);
 -      }
  
 -      /* after area regions so we can do area 'overlay' drawing */
 -      if (screen->do_draw) {
 -              ED_screen_draw_edges(win);
 -              screen->do_draw = false;
 -              wm_draw_callbacks(win);
 -
 -              if (exchange)
 -                      screen->swap = WIN_FRONT_OK;
 -      }
 -      else if (exchange) {
 -              if (screen->swap == WIN_FRONT_OK) {
 -                      ED_screen_draw_edges(win);
 -                      screen->do_draw = false;
 -                      screen->swap = WIN_BOTH_OK;
 -                      wm_draw_callbacks(win);
 +                      ar->draw_buffer = MEM_callocN(sizeof(wmDrawBuffer), "wmDrawBuffer");
 +                      ar->draw_buffer->offscreen[0] = offscreen;
 +                      ar->draw_buffer->offscreen[1] = offscreen_right;
                }
 -              else if (screen->swap == WIN_BACK_OK)
 -                      screen->swap = WIN_FRONT_OK;
 -              else if (screen->swap == WIN_BOTH_OK)
 -                      screen->swap = WIN_BOTH_OK;
 -      }
  
 -      /* draw marked overlapping regions */
 -      for (ar = screen->regionbase.first; ar; ar = ar->next) {
 -              if (ar->swinid && ar->do_draw) {
 -                      CTX_wm_menu_set(C, ar);
 -                      ED_region_do_draw(C, ar);
 -                      ar->do_draw = false;
 -                      CTX_wm_menu_set(C, NULL);
 -              }
 -      }
 -
 -      if (screen->do_draw_gesture)
 -              wm_gesture_draw(win);
 -      
 -      /* needs pixel coords in screen */
 -      if (wm->drags.first) {
 -              wm_drags_draw(C, win, NULL);
 +              ar->draw_buffer->bound_view = -1;
 +              ar->draw_buffer->stereo = stereo;
        }
  }
  
Simple merge