[Bf-blender-cvs] [164b6c5b047] master: Cleanup: remove EDBM_backbuf API

Campbell Barton noreply at git.blender.org
Mon May 20 04:41:12 CEST 2019


Commit: 164b6c5b047e82c84793ecb43cbbee9f3b6e245e
Author: Campbell Barton
Date:   Mon May 20 12:39:01 2019 +1000
Branches: master
https://developer.blender.org/rB164b6c5b047e82c84793ecb43cbbee9f3b6e245e

Cleanup: remove EDBM_backbuf API

===================================================================

M	source/blender/editors/include/ED_mesh.h
M	source/blender/editors/include/ED_view3d.h
M	source/blender/editors/mesh/editmesh_select.c
M	source/blender/editors/space_view3d/view3d_draw_legacy.c

===================================================================

diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h
index 0f3c425d1cf..0a8304f3f8a 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -162,20 +162,6 @@ void EDBM_select_mirrored(
     struct BMEditMesh *em, const int axis, const bool extend, int *r_totmirr, int *r_totfail);
 void EDBM_automerge(struct Scene *scene, struct Object *ob, bool update, const char hflag);
 
-bool EDBM_backbuf_border_init(
-    struct ViewContext *vc, short xmin, short ymin, short xmax, short ymax);
-bool EDBM_backbuf_check(unsigned int index);
-void EDBM_backbuf_free(void);
-
-bool EDBM_backbuf_border_mask_init(struct ViewContext *vc,
-                                   const int mcords[][2],
-                                   short tot,
-                                   short xmin,
-                                   short ymin,
-                                   short xmax,
-                                   short ymax);
-bool EDBM_backbuf_circle_init(struct ViewContext *vc, short xs, short ys, short rads);
-
 struct BMVert *EDBM_vert_find_nearest_ex(struct ViewContext *vc,
                                          float *r_dist,
                                          const bool use_select_bias,
@@ -255,9 +241,6 @@ void em_setup_viewcontext(struct bContext *C, struct ViewContext *vc); /* rename
 bool EDBM_mesh_deselect_all_multi_ex(struct Base **bases, const uint bases_len);
 bool EDBM_mesh_deselect_all_multi(struct bContext *C);
 
-/* Only use for modes that don't support multi-edit-modes (painting). */
-extern unsigned int bm_vertoffs, bm_solidoffs, bm_wireoffs;
-
 /* editmesh_preselect_edgering.c */
 struct EditMesh_PreSelEdgeRing;
 struct EditMesh_PreSelEdgeRing *EDBM_preselect_edgering_create(void);
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index 61d1670b88d..6110d35ab0d 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -450,7 +450,6 @@ void ED_view3d_backbuf_depth_validate(struct ViewContext *vc);
 int ED_view3d_backbuf_sample_size_clamp(struct ARegion *ar, const float dist);
 
 void ED_view3d_select_id_validate(struct ViewContext *vc);
-void ED_view3d_select_id_validate_with_select_mode(struct ViewContext *vc, short select_mode);
 
 uint ED_view3d_select_id_sample(struct ViewContext *vc, int x, int y);
 uint *ED_view3d_select_id_read(int xmin, int ymin, int xmax, int ymax, uint *r_buf_len);
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index d20a9bb3bea..b1cd21e9e32 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -365,192 +365,6 @@ void EDBM_select_id_context_destroy(struct EDBMSelectID_Context *sel_id_ctx)
   MEM_freeN(sel_id_ctx);
 }
 
-/* set in view3d_draw_legacy.c ... for colorindices */
-unsigned int bm_solidoffs = 0, bm_wireoffs = 0, bm_vertoffs = 0;
-
-/* facilities for box select and circle select */
-static BLI_bitmap *selbuf = NULL;
-
-static BLI_bitmap *edbm_backbuf_alloc(const int size)
-{
-  return BLI_BITMAP_NEW(size, "selbuf");
-}
-
-/* reads rect, and builds selection array for quick lookup */
-/* returns if all is OK */
-bool EDBM_backbuf_border_init(ViewContext *vc, short xmin, short ymin, short xmax, short ymax)
-{
-  uint *buf, *dr, buf_len;
-
-  if (vc->obedit == NULL || XRAY_FLAG_ENABLED(vc->v3d)) {
-    return false;
-  }
-
-  ED_view3d_select_id_validate(vc);
-  buf = ED_view3d_select_id_read(xmin, ymin, xmax, ymax, &buf_len);
-  if ((buf == NULL) || (bm_vertoffs == 0)) {
-    return false;
-  }
-
-  dr = buf;
-
-  /* build selection lookup */
-  selbuf = edbm_backbuf_alloc(bm_vertoffs + 1);
-
-  while (buf_len--) {
-    if (*dr > 0 && *dr <= bm_vertoffs) {
-      BLI_BITMAP_ENABLE(selbuf, *dr);
-    }
-    dr++;
-  }
-  MEM_freeN(buf);
-  return true;
-}
-
-bool EDBM_backbuf_check(unsigned int index)
-{
-  /* odd logic, if selbuf is NULL we assume no zbuf-selection is enabled
-   * and just ignore the depth buffer, this is error prone since its possible
-   * code doesn't set the depth buffer by accident, but leave for now. - Campbell */
-  if (selbuf == NULL) {
-    return true;
-  }
-
-  if (index > 0 && index <= bm_vertoffs) {
-    return BLI_BITMAP_TEST_BOOL(selbuf, index);
-  }
-
-  return false;
-}
-
-void EDBM_backbuf_free(void)
-{
-  if (selbuf) {
-    MEM_freeN(selbuf);
-  }
-  selbuf = NULL;
-}
-
-struct LassoMaskData {
-  unsigned int *px;
-  int width;
-};
-
-static void edbm_mask_lasso_px_cb(int x, int x_end, int y, void *user_data)
-{
-  struct LassoMaskData *data = user_data;
-  unsigned int *px = &data->px[(y * data->width) + x];
-  do {
-    *px = true;
-    px++;
-  } while (++x != x_end);
-}
-
-/* mcords is a polygon mask
- * - grab backbuffer,
- * - draw with black in backbuffer,
- * - grab again and compare
- * returns 'OK'
- */
-bool EDBM_backbuf_border_mask_init(ViewContext *vc,
-                                   const int mcords[][2],
-                                   short tot,
-                                   short xmin,
-                                   short ymin,
-                                   short xmax,
-                                   short ymax)
-{
-  uint *buf, *dr, *dr_mask, *dr_mask_arr, buf_len;
-  struct LassoMaskData lasso_mask_data;
-
-  /* method in use for face selecting too */
-  if (vc->obedit == NULL) {
-    if (!BKE_paint_select_elem_test(vc->obact)) {
-      return false;
-    }
-  }
-  else if (XRAY_FLAG_ENABLED(vc->v3d)) {
-    return false;
-  }
-
-  ED_view3d_select_id_validate(vc);
-  buf = ED_view3d_select_id_read(xmin, ymin, xmax, ymax, &buf_len);
-  if ((buf == NULL) || (bm_vertoffs == 0)) {
-    return false;
-  }
-
-  dr = buf;
-
-  dr_mask = dr_mask_arr = MEM_callocN(sizeof(*dr_mask) * buf_len, __func__);
-  lasso_mask_data.px = dr_mask;
-  lasso_mask_data.width = (xmax - xmin) + 1;
-
-  BLI_bitmap_draw_2d_poly_v2i_n(
-      xmin, ymin, xmax + 1, ymax + 1, mcords, tot, edbm_mask_lasso_px_cb, &lasso_mask_data);
-
-  /* build selection lookup */
-  selbuf = edbm_backbuf_alloc(bm_vertoffs + 1);
-
-  while (buf_len--) {
-    if (*dr > 0 && *dr <= bm_vertoffs && *dr_mask == true) {
-      BLI_BITMAP_ENABLE(selbuf, *dr);
-    }
-    dr++;
-    dr_mask++;
-  }
-  MEM_freeN(buf);
-  MEM_freeN(dr_mask_arr);
-
-  return true;
-}
-
-/* circle shaped sample area */
-bool EDBM_backbuf_circle_init(ViewContext *vc, short xs, short ys, short rads)
-{
-  uint *buf, *dr;
-  short xmin, ymin, xmax, ymax, xc, yc;
-  int radsq;
-
-  /* method in use for face selecting too */
-  if (vc->obedit == NULL) {
-    if (!BKE_paint_select_elem_test(vc->obact)) {
-      return false;
-    }
-  }
-  else if (XRAY_FLAG_ENABLED(vc->v3d)) {
-    return false;
-  }
-
-  xmin = xs - rads;
-  xmax = xs + rads;
-  ymin = ys - rads;
-  ymax = ys + rads;
-
-  ED_view3d_select_id_validate(vc);
-  buf = ED_view3d_select_id_read(xmin, ymin, xmax, ymax, NULL);
-  if ((buf == NULL) || (bm_vertoffs == 0)) {
-    return false;
-  }
-
-  dr = buf;
-
-  /* build selection lookup */
-  selbuf = edbm_backbuf_alloc(bm_vertoffs + 1);
-  radsq = rads * rads;
-  for (yc = -rads; yc <= rads; yc++) {
-    for (xc = -rads; xc <= rads; xc++, dr++) {
-      if (xc * xc + yc * yc < radsq) {
-        if (*dr > 0 && *dr <= bm_vertoffs) {
-          BLI_BITMAP_ENABLE(selbuf, *dr);
-        }
-      }
-    }
-  }
-
-  MEM_freeN(buf);
-  return true;
-}
-
 /** \} */
 
 /* -------------------------------------------------------------------- */
diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c
index 2ad61314430..1d785c67e8b 100644
--- a/source/blender/editors/space_view3d/view3d_draw_legacy.c
+++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c
@@ -152,13 +152,11 @@ void ED_view3d_clipping_enable(void)
 
 /* *********************** backdraw for selection *************** */
 
-static void validate_object_select_id(struct Depsgraph *depsgraph,
-                                      Scene *scene,
-                                      ARegion *ar,
-                                      View3D *v3d,
-                                      Object *obact,
-                                      Object *obedit,
-                                      short select_mode)
+/**
+ * \note Only use in object mode.
+ */
+static void validate_object_select_id(
+    struct Depsgraph *depsgraph, Scene *scene, ARegion *ar, View3D *v3d, Object *obact)
 {
   RegionView3D *rv3d = ar->regiondata;
   Scene *scene_eval = (Scene *)DEG_get_evaluated_id(depsgraph, &scene->id);
@@ -188,16 +186,17 @@ static void validate_object_select_id(struct Depsgraph *depsgraph,
   }
 
   if (obact_eval && ((obact_eval->base_flag & BASE_VISIBLE) != 0)) {
+    uint dummy_vert_ofs, dummy_edge_ofs, dummy_face_ofs;
     DRW_framebuffer_select_id_setup(ar, true);
     DRW_draw_select_id_object(scene_eval,
                               rv3d,
                               obact_eval,
-                              select_mode,
+                              scene->toolsettings->selectmode,
                               false,
                               1,
-                              &bm_vertoffs,
-                              &bm_wireoffs,
-                              &bm_solidoffs);
+                              &dummy_vert_ofs,
+                              &dummy_edge_ofs,
+                              &dummy_face_ofs);
 
     DRW_framebuffer_select_id_release(ar);
   }
@@ -229,21 +228,15 @@ static void view3d_opengl_read_Z_pixels(GPUViewport *viewport, rcti *rect, void
   GPU_framebuffer_free(tmp_fb);
 }
 
-void ED_view3d_select_id_validate_with_select_mode(ViewContext *vc, short select_mode)
+void ED_view3d_select_id_validate(ViewContext *vc)
 {
   /* TODO: Create a flag in `DRW_manager` because the drawing is no longer
    *       made on the backbuffer in this case. */
   if (vc->v3d->flag & V3D_INVALID_BACKBUF) {
-    validate_object_select_id(
-        vc->depsgraph, vc->scene, vc->ar, vc->v3d, vc->obact, vc->obedit, select_

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list