Merge branch 'master' into blender2.8
authorCampbell Barton <ideasman42@gmail.com>
Fri, 4 Aug 2017 21:53:07 +0000 (07:53 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 4 Aug 2017 21:53:07 +0000 (07:53 +1000)
1  2 
intern/cycles/blender/addon/properties.py
intern/cycles/blender/addon/ui.py
intern/cycles/blender/blender_sync.cpp
source/blender/editors/curve/editcurve_paint.c
source/blender/editors/include/ED_view3d.h
source/blender/editors/space_clip/clip_draw.c
source/blender/editors/space_view3d/view3d_view.c
source/blender/editors/transform/transform_conversions.c
source/blender/makesrna/intern/rna_space.c

Simple merge
index 7f3ec5cc9ef4c60c50240f31f8b0c2fb82b023d4,5c3a694929e0a9d4afb9b921598ea810f1917913..25bad71af88593d24e5c961aee69f06c95981c42
@@@ -304,9 -212,9 +216,9 @@@ static bool stroke_elem_project
                    ((unsigned int)mval_i[0] < depths->w) &&
                    ((unsigned int)mval_i[1] < depths->h))
                {
-                       const double depth = (double)depth_read_zbuf(&cdd->vc, mval_i[0], mval_i[1]);
+                       const double depth = (double)ED_view3d_depth_read_cached(&cdd->vc, mval_i);
                        if ((depth > depths->depth_range[0]) && (depth < depths->depth_range[1])) {
-                               if (depth_unproject(ar, mval_i, depth, r_location_world)) {
 -                              if (ED_view3d_depth_unproject(ar, &cdd->mats, mval_i, depth, r_location_world)) {
++                              if (ED_view3d_depth_unproject(ar, mval_i, depth, r_location_world)) {
                                        is_location_world_set = true;
                                        if (r_normal_world) {
                                                zero_v3(r_normal_world);
                                        if (surface_offset != 0.0f) {
                                                const float offset = cdd->project.use_surface_offset_absolute ? 1.0f : radius;
                                                float normal[3];
-                                               if (depth_read_normal(&cdd->vc, mval_i, normal)) {
 -                                              if (ED_view3d_depth_read_cached_normal(&cdd->vc, &cdd->mats, mval_i, normal)) {
++                                              if (ED_view3d_depth_read_cached_normal(&cdd->vc, mval_i, normal)) {
                                                        madd_v3_v3fl(r_location_world, normal, offset * surface_offset);
                                                        if (r_normal_world) {
                                                                copy_v3_v3(r_normal_world, normal);
@@@ -642,7 -531,7 +554,7 @@@ static void curve_draw_event_add_first(
                         CURVE_PAINT_SURFACE_PLANE_NORMAL_VIEW,
                         CURVE_PAINT_SURFACE_PLANE_NORMAL_SURFACE))
                {
-                       if (depth_read_normal(&cdd->vc, event->mval, normal)) {
 -                      if (ED_view3d_depth_read_cached_normal(&cdd->vc, &cdd->mats, event->mval, normal)) {
++                      if (ED_view3d_depth_read_cached_normal(&cdd->vc, event->mval, normal)) {
                                if (cps->surface_plane == CURVE_PAINT_SURFACE_PLANE_NORMAL_VIEW) {
                                        float cross_a[3], cross_b[3];
                                        cross_v3_v3v3(cross_a, rv3d->viewinv[2], normal);
index f34afd176e1132de1f67d23ced9abd04dcacabea,85fb0ee4447403201da84b61f40fdff99cbf62b5..4b7eaa4f3d43dfa0f3758090f28862c8a168e0b8
@@@ -110,7 -106,14 +110,14 @@@ void ED_view3d_lastview_store(struct Re
  
  /* Depth buffer */
  void  ED_view3d_depth_update(struct ARegion *ar);
- float ED_view3d_depth_read_cached(const struct ViewContext *vc, int x, int y);
+ float ED_view3d_depth_read_cached(const struct ViewContext *vc, const int mval[2]);
+ bool  ED_view3d_depth_read_cached_normal(
 -        const ViewContext *vc, const struct bglMats *mats, const int mval[2],
++        const ViewContext *vc, const int mval[2],
+         float r_normal[3]);
+ bool ED_view3d_depth_unproject(
 -        const struct ARegion *ar, const struct bglMats *mats,
++        const struct ARegion *ar,
+         const int mval[2], const double depth,
+         float r_location_world[3]);
  void  ED_view3d_depth_tag_update(struct RegionView3D *rv3d);
  
  /* Projection */
index 95ff76e48cccef3dd12945468e9cd2eb5563f22d,a71b2baa96f868d7ca7cb30edd4e843863f9a22f..f5680bf22656946228f2d49e263ada44904a67d6
@@@ -508,31 -471,19 +517,36 @@@ static void draw_track_path(SpaceClip *
  
        glLineWidth(1);
  
 -      glBegin(GL_LINE_STRIP);
 -      for (i = a; i < b; i++) {
 -              if (i == count + 1)
 -                      UI_ThemeColor(TH_PATH_AFTER);
 +      if ((curindex - a + 1) >= 2) {
 +              immUniformThemeColor(TH_PATH_BEFORE);
 +
 +              immBegin(GWN_PRIM_LINE_STRIP, curindex - a + 1);
 +
 +              for (i = a; i <= curindex; i++) {
 +                      immVertex2f(pos, path[i][0], path[i][1]);
 +              }
 +
 +              immEnd();
 +      }
 +
 +      if ((b - curindex) >= 2) {
 +              immUniformThemeColor(TH_PATH_AFTER);
 +
 +              immBegin(GWN_PRIM_LINE_STRIP, b - curindex);
 +
 +              for (i = curindex; i < b; i++) {
 +                      immVertex2f(pos, path[i][0], path[i][1]);
 +              }
  
 -              glVertex2f(path[i][0], path[i][1]);
 +              immEnd();
        }
 -      glEnd();
 +
 +      immUnbindProgram();
+       if (path != path_static) {
+               MEM_freeN(path);
+       }
+ #undef MAX_STATIC_PATH
  }
  
  static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker,
index 580213e1fb5ea649cfed90ab229e781a8cdf1249,1c919ba1e7500675bdf236c732434d758ff02ff0..3ffd21294df8fe4f1f9a12ba178b6b00f850c156
@@@ -816,15 -821,99 +821,91 @@@ float ED_view3d_depth_read_cached(cons
  {
        ViewDepths *vd = vc->rv3d->depths;
                
-       x -= vc->ar->winrct.xmin;
-       y -= vc->ar->winrct.ymin;
+       int x = mval[0];
+       int y = mval[1];
  
-       if (vd && vd->depths && x > 0 && y > 0 && x < vd->w && y < vd->h)
+       if (vd && vd->depths && x > 0 && y > 0 && x < vd->w && y < vd->h) {
                return vd->depths[y * vd->w + x];
-       else
-               return 1;
+       }
+       else {
+               BLI_assert(1.0 <= vd->depth_range[1]);
+               return 1.0f;
+       }
+ }
+ bool ED_view3d_depth_read_cached_normal(
 -        const ViewContext *vc, const bglMats *mats, const int mval[2],
++        const ViewContext *vc, const int mval[2],
+         float r_normal[3])
+ {
+       /* Note: we could support passing in a radius.
+        * For now just read 9 pixels. */
+       /* pixels surrounding */
+       bool  depths_valid[9] = {false};
+       float coords[9][3] = {{0}};
+       ARegion *ar = vc->ar;
+       const ViewDepths *depths = vc->rv3d->depths;
+       for (int x = 0, i = 0; x < 2; x++) {
+               for (int y = 0; y < 2; y++) {
+                       const int mval_ofs[2] = {mval[0] + (x - 1), mval[1] + (y - 1)};
+                       const double depth = (double)ED_view3d_depth_read_cached(vc, mval_ofs);
+                       if ((depth > depths->depth_range[0]) && (depth < depths->depth_range[1])) {
 -                              if (ED_view3d_depth_unproject(ar, mats, mval_ofs, depth, coords[i])) {
++                              if (ED_view3d_depth_unproject(ar, mval_ofs, depth, coords[i])) {
+                                       depths_valid[i] = true;
+                               }
+                       }
+                       i++;
+               }
+       }
+       const int edges[2][6][2] = {
+           /* x edges */
+           {{0, 1}, {1, 2},
+            {3, 4}, {4, 5},
+            {6, 7}, {7, 8}},
+           /* y edges */
+           {{0, 3}, {3, 6},
+            {1, 4}, {4, 7},
+            {2, 5}, {5, 8}},
+       };
+       float cross[2][3] = {{0.0f}};
+       for (int i = 0; i < 6; i++) {
+               for (int axis = 0; axis < 2; axis++) {
+                       if (depths_valid[edges[axis][i][0]] && depths_valid[edges[axis][i][1]]) {
+                               float delta[3];
+                               sub_v3_v3v3(delta, coords[edges[axis][i][0]], coords[edges[axis][i][1]]);
+                               add_v3_v3(cross[axis], delta);
+                       }
+               }
+       }
+       cross_v3_v3v3(r_normal, cross[0], cross[1]);
+       if (normalize_v3(r_normal) != 0.0f) {
+               return true;
+       }
+       else {
+               return false;
+       }
  }
  
 -        const ARegion *ar, const bglMats *mats,
+ bool ED_view3d_depth_unproject(
 -      double p[3];
 -      if (gluUnProject(
 -              (double)ar->winrct.xmin + mval[0] + 0.5,
 -              (double)ar->winrct.ymin + mval[1] + 0.5,
 -              depth, mats->modelview, mats->projection, (const GLint *)mats->viewport,
 -              &p[0], &p[1], &p[2]))
 -      {
 -              copy_v3fl_v3db(r_location_world, p);
 -              return true;
 -      }
 -      return false;
++        const ARegion *ar,
+         const int mval[2], const double depth,
+         float r_location_world[3])
+ {
++      float centx = (float)mval[0] + 0.5f;
++      float centy = (float)mval[1] + 0.5f;
++      return ED_view3d_unproject(ar, centx, centy, depth, r_location_world);
+ }
+ /** \} */
  void ED_view3d_depth_tag_update(RegionView3D *rv3d)
  {
        if (rv3d->depths)