[Bf-blender-cvs] [00dcfdf916c] xr-dev: Merge branch 'master' into xr-dev

Peter Kim noreply at git.blender.org
Thu Sep 8 06:02:04 CEST 2022


Commit: 00dcfdf916c69672210b006e62d966f1bc2fbeb7
Author: Peter Kim
Date:   Thu Sep 8 13:00:12 2022 +0900
Branches: xr-dev
https://developer.blender.org/rB00dcfdf916c69672210b006e62d966f1bc2fbeb7

Merge branch 'master' into xr-dev

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



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

diff --cc source/blender/editors/space_view3d/view3d_select.cc
index 00000000000,ad816f420fe..f00bee54ed6
mode 000000,100644..100644
--- a/source/blender/editors/space_view3d/view3d_select.cc
+++ b/source/blender/editors/space_view3d/view3d_select.cc
@@@ -1,0 -1,4780 +1,4779 @@@
+ /* SPDX-License-Identifier: GPL-2.0-or-later
+  * Copyright 2008 Blender Foundation. All rights reserved. */
+ 
+ /** \file
+  * \ingroup spview3d
+  */
+ 
+ #include <cfloat>
+ #include <cmath>
+ #include <cstdio>
+ #include <cstring>
+ 
+ #include "DNA_action_types.h"
+ #include "DNA_armature_types.h"
+ #include "DNA_curve_types.h"
+ #include "DNA_gpencil_types.h"
+ #include "DNA_mesh_types.h"
+ #include "DNA_meshdata_types.h"
+ #include "DNA_meta_types.h"
+ #include "DNA_object_types.h"
+ #include "DNA_scene_types.h"
+ #include "DNA_tracking_types.h"
+ 
+ #include "MEM_guardedalloc.h"
+ 
+ #include "BLI_bitmap.h"
+ #include "BLI_lasso_2d.h"
+ #include "BLI_linklist.h"
+ #include "BLI_listbase.h"
+ #include "BLI_math.h"
+ #include "BLI_rect.h"
+ #include "BLI_string.h"
+ #include "BLI_utildefines.h"
+ #include "BLI_vector.hh"
+ 
+ #ifdef __BIG_ENDIAN__
+ #  include "BLI_endian_switch.h"
+ #endif
+ 
+ /* vertex box select */
+ #include "BKE_global.h"
+ #include "BKE_main.h"
+ #include "IMB_imbuf.h"
+ #include "IMB_imbuf_types.h"
+ 
+ #include "BKE_action.h"
+ #include "BKE_armature.h"
+ #include "BKE_context.h"
+ #include "BKE_curve.h"
+ #include "BKE_editmesh.h"
+ #include "BKE_layer.h"
+ #include "BKE_mball.h"
+ #include "BKE_mesh.h"
+ #include "BKE_object.h"
+ #include "BKE_paint.h"
+ #include "BKE_scene.h"
+ #include "BKE_tracking.h"
+ #include "BKE_workspace.h"
+ 
+ #include "WM_api.h"
+ #include "WM_toolsystem.h"
+ #include "WM_types.h"
+ 
+ #include "RNA_access.h"
+ #include "RNA_define.h"
+ #include "RNA_enum_types.h"
+ 
+ #include "ED_armature.h"
+ #include "ED_curve.h"
+ #include "ED_gpencil.h"
+ #include "ED_lattice.h"
+ #include "ED_mball.h"
+ #include "ED_mesh.h"
+ #include "ED_object.h"
+ #include "ED_outliner.h"
+ #include "ED_particle.h"
+ #include "ED_screen.h"
+ #include "ED_sculpt.h"
+ #include "ED_select_utils.h"
+ 
+ #include "UI_interface.h"
+ #include "UI_resources.h"
+ 
+ #include "GPU_matrix.h"
+ #include "GPU_select.h"
+ 
+ #include "DEG_depsgraph.h"
+ #include "DEG_depsgraph_query.h"
+ 
+ #include "DRW_engine.h"
+ #include "DRW_select_buffer.h"
+ 
+ #include "view3d_intern.h" /* own include */
+ 
+ // #include "PIL_time_utildefines.h"
+ 
+ /* -------------------------------------------------------------------- */
+ /** \name Public Utilities
+  * \{ */
+ 
+ float ED_view3d_select_dist_px(void)
+ {
+   return 75.0f * U.pixelsize;
+ }
+ 
+ void ED_view3d_viewcontext_init(bContext *C, ViewContext *vc, Depsgraph *depsgraph)
+ {
+   /* TODO: should return whether there is valid context to continue. */
+ 
+   memset(vc, 0, sizeof(ViewContext));
+   vc->C = C;
+   vc->region = CTX_wm_region(C);
+   vc->bmain = CTX_data_main(C);
+   vc->depsgraph = depsgraph;
+   vc->scene = CTX_data_scene(C);
+   vc->view_layer = CTX_data_view_layer(C);
+   vc->v3d = CTX_wm_view3d(C);
+   vc->win = CTX_wm_window(C);
+   vc->rv3d = CTX_wm_region_view3d(C);
+   vc->obact = CTX_data_active_object(C);
+   vc->obedit = CTX_data_edit_object(C);
+ }
+ 
+ void ED_view3d_viewcontext_init_object(ViewContext *vc, Object *obact)
+ {
+   vc->obact = obact;
+   /* See public doc-string for rationale on checking the existing values first. */
+   if (vc->obedit) {
+     BLI_assert(BKE_object_is_in_editmode(obact));
+     vc->obedit = obact;
+     if (vc->em) {
+       vc->em = BKE_editmesh_from_object(vc->obedit);
+     }
+   }
+ }
+ 
 -/** \} */
 -
 -/* -------------------------------------------------------------------- */
 -/** \name Internal Object Utilities
 - * \{ */
 -
 -static bool object_deselect_all_visible(ViewLayer *view_layer, View3D *v3d)
++bool ED_view3d_object_deselect_all_except(ViewLayer *view_layer, Base *b)
+ {
+   bool changed = false;
+   LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
+     if (base->flag & BASE_SELECTED) {
 -      if (BASE_SELECTABLE(v3d, base)) {
++      if (b != base) {
+         ED_object_base_select(base, BA_DESELECT);
+         changed = true;
+       }
+     }
+   }
+   return changed;
+ }
+ 
 -/* deselect all except b */
 -static bool object_deselect_all_except(ViewLayer *view_layer, Base *b)
++/** \} */
++
++/* -------------------------------------------------------------------- */
++/** \name Internal Object Utilities
++ * \{ */
++
++static bool object_deselect_all_visible(ViewLayer *view_layer, View3D *v3d)
+ {
+   bool changed = false;
+   LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) {
+     if (base->flag & BASE_SELECTED) {
 -      if (b != base) {
++      if (BASE_SELECTABLE(v3d, base)) {
+         ED_object_base_select(base, BA_DESELECT);
+         changed = true;
+       }
+     }
+   }
+   return changed;
+ }
+ 
+ /** \} */
+ 
+ /* -------------------------------------------------------------------- */
+ /** \name Internal Edit-Mesh Select Buffer Wrapper
+  *
+  * Avoid duplicate code when using edit-mode selection,
+  * actual logic is handled outside of this function.
+  *
+  * \note Currently this #EDBMSelectID_Context which is mesh specific
+  * however the logic could also be used for non-meshes too.
+  *
+  * \{ */
+ 
+ struct EditSelectBuf_Cache {
+   BLI_bitmap *select_bitmap;
+ };
+ 
+ static void editselect_buf_cache_init(ViewContext *vc, short select_mode)
+ {
+   if (vc->obedit) {
+     uint bases_len = 0;
+     Base **bases = BKE_view_layer_array_from_bases_in_edit_mode(
+         vc->view_layer, vc->v3d, &bases_len);
+ 
+     DRW_select_buffer_context_create(bases, bases_len, select_mode);
+     MEM_freeN(bases);
+   }
+   else {
+     /* Use for paint modes, currently only a single object at a time. */
+     if (vc->obact) {
+       Base *base = BKE_view_layer_base_find(vc->view_layer, vc->obact);
+       DRW_select_buffer_context_create(&base, 1, select_mode);
+     }
+   }
+ }
+ 
+ static void editselect_buf_cache_free(EditSelectBuf_Cache *esel)
+ {
+   MEM_SAFE_FREE(esel->select_bitmap);
+ }
+ 
+ static void editselect_buf_cache_free_voidp(void *esel_voidp)
+ {
+   editselect_buf_cache_free(static_cast<EditSelectBuf_Cache *>(esel_voidp));
+   MEM_freeN(esel_voidp);
+ }
+ 
+ static void editselect_buf_cache_init_with_generic_userdata(wmGenericUserData *wm_userdata,
+                                                             ViewContext *vc,
+                                                             short select_mode)
+ {
+   EditSelectBuf_Cache *esel = MEM_cnew<EditSelectBuf_Cache>(__func__);
+   wm_userdata->data = esel;
+   wm_userdata->free_fn = editselect_buf_cache_free_voidp;
+   wm_userdata->use_free = true;
+   editselect_buf_cache_init(vc, select_mode);
+ }
+ 
+ /** \} */
+ 
+ /* -------------------------------------------------------------------- */
+ /** \name Internal Edit-Mesh Utilities
+  * \{ */
+ 
+ static bool edbm_backbuf_check_and_select_verts(EditSelectBuf_Cache *esel,
+                                                 Depsgraph *depsgraph,
+                                                 Object *ob,
+                                                 BMEditMesh *em,
+                                                 const eSelectOp sel_op)
+ {
+   BMVert *eve;
+   BMIter iter;
+   bool changed = false;
+ 
+   const BLI_bitmap *select_bitmap = esel->select_bitmap;
+   uint index = DRW_select_buffer_context_offset_for_object_elem(depsgraph, ob, SCE_SELECT_VERTEX);
+   if (index == 0) {
+     return false;
+   }
+ 
+   index -= 1;
+   BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
+     if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
+       const bool is_select = BM_elem_flag_test(eve, BM_ELEM_SELECT);
+       const bool is_inside = BLI_BITMAP_TEST_BOOL(select_bitmap, index);
+       const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside);
+       if (sel_op_result != -1) {
+         BM_vert_select_set(em->bm, eve, sel_op_result);
+         changed = true;
+       }
+     }
+     index++;
+   }
+   return changed;
+ }
+ 
+ static bool edbm_backbuf_check_and_select_edges(EditSelectBuf_Cache *esel,
+                                                 Depsgraph *depsgraph,
+                                                 Object *ob,
+                                                 BMEditMesh *em,
+                                                 const eSelectOp sel_op)
+ {
+   BMEdge *eed;
+   BMIter iter;
+   bool changed = false;
+ 
+   const BLI_bitmap *select_bitmap = esel->select_bitmap;
+   uint index = DRW_select_buffer_context_offset_for_object_elem(depsgraph, ob, SCE_SELECT_EDGE);
+   if (index == 0) {
+     return false;
+   }
+ 
+   index -= 1;
+   BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
+     if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
+       const bool is_select = BM_elem_flag_test(eed, BM_ELEM_SELECT);
+       const bool is_inside = BLI_BITMAP_TEST_BOOL(select_bitmap, index);
+       const int sel_op_result = ED_select_op_action_deselected(sel_op, is_select, is_inside);
+       if (sel_op_result != -1) {
+         BM_edge_select_set(em->bm, eed, sel_op_result);
+         changed = true;
+       }
+     }
+     index++;
+   }
+   return changed;
+ }
+ 
+ static bool edbm_backbuf_check_and_select_faces(EditSelectBuf_Cache *esel,
+                                                 Depsgraph *depsgraph,
+                                                 Object *ob,
+                                                 BMEditMesh *em,
+                                                 const eSelectOp sel_op)
+ {
+   BMFace *efa;
+   BMIter iter;
+   bool changed = false;
+ 
+   const BLI_bitmap *select_bitmap = esel->select_bitmap;
+   uint index = DRW_select_buffer_context_offset_for_object_elem(depsgraph, ob, SCE_SELECT_FACE);
+   if (index == 0) {
+     return false;
+   }
+ 
+   index -= 1;
+   BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
+     if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
+       const bool is_select = BM_elem_flag_test(efa, BM_ELEM_SELECT);
+       const bool is_inside = BLI_BI

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list