[Bf-blender-cvs] [ca4ac36c59e] temp_bmesh_multires: Merge branch 'master' into temp_bmesh_multires

Joseph Eagar noreply at git.blender.org
Mon Jun 21 00:58:36 CEST 2021


Commit: ca4ac36c59edf97e2bf25f56ba5646b51cf8c22f
Author: Joseph Eagar
Date:   Sun Jun 20 15:58:24 2021 -0700
Branches: temp_bmesh_multires
https://developer.blender.org/rBca4ac36c59edf97e2bf25f56ba5646b51cf8c22f

Merge branch 'master' into temp_bmesh_multires

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



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

diff --cc source/blender/blenkernel/intern/mesh.c
index 5ab7b38ed69,08d3236f3a9..190596571b0
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@@ -1012,7 -1027,7 +1028,7 @@@ BMesh *BKE_mesh_to_bmesh_ex(const Objec
    const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(me);
  
    BMesh *bm = BM_mesh_create(&allocsize, create_params);
-   BM_mesh_bm_from_me((Object*)ob, bm, me, convert_params);
 -  BM_mesh_bm_from_me(bm, me, convert_params);
++  BM_mesh_bm_from_me((Object *)ob, bm, me, convert_params);
  
    return bm;
  }
@@@ -1039,12 -1053,8 +1055,13 @@@ Mesh *BKE_mesh_from_bmesh_nomain(BMesh 
  {
    BLI_assert(params->calc_object_remap == false);
    Mesh *mesh = BKE_id_new_nomain(ID_ME, NULL);
 -  BM_mesh_bm_to_me(NULL, bm, mesh, params);
 -  BKE_mesh_copy_parameters_for_eval(mesh, me_settings);
++
 +  BM_mesh_bm_to_me(NULL, NULL, bm, mesh, params);
 +
 +  if (me_settings) {
-     BKE_mesh_copy_settings(mesh, me_settings);
++    BKE_mesh_copy_parameters_for_eval(mesh, me_settings);
 +  }
 +
    return mesh;
  }
  
diff --cc source/blender/blenlib/BLI_mempool.h
index 6109a216d95,4d9381093c7..90d78a1d055
--- a/source/blender/blenlib/BLI_mempool.h
+++ b/source/blender/blenlib/BLI_mempool.h
@@@ -88,24 -89,6 +89,19 @@@ enum 
  void BLI_mempool_iternew(BLI_mempool *pool, BLI_mempool_iter *iter) ATTR_NONNULL();
  void *BLI_mempool_iterstep(BLI_mempool_iter *iter) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
  
- BLI_mempool_iter *BLI_mempool_iter_threadsafe_create(BLI_mempool *pool,
-                                                      const size_t num_iter) ATTR_WARN_UNUSED_RESULT
-     ATTR_NONNULL();
- void BLI_mempool_iter_threadsafe_free(BLI_mempool_iter *iter_arr) ATTR_NONNULL();
- 
 +/*
 +This preallocates a mempool suitable for threading.  totelem elements are preallocated
 +in chunks of size pchunk, and returned in r_chunks.
 +*/
 +
 +BLI_mempool *BLI_mempool_create_for_tasks(const unsigned int esize,
 +                                          unsigned int totelem,
 +                                          const unsigned int pchunk,
 +                                          void ***r_chunks,
 +                                          unsigned int *r_totchunk,
 +                                          unsigned int *r_esize,
 +                                          unsigned int flag);
 +
  #ifdef __cplusplus
  }
  #endif
diff --cc source/blender/editors/mesh/editmesh_tools.c
index bf0b6f4a7ca,d4491721689..4c3149f2529
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@@ -4206,7 -4391,7 +4391,8 @@@ static Base *mesh_separate_tagged
  
    BM_mesh_normals_update(bm_new);
  
-   BM_mesh_bm_to_me(bmain, base_new->object, bm_new, base_new->object->data, (&(struct BMeshToMeshParams){0}));
 -  BM_mesh_bm_to_me(bmain, bm_new, base_new->object->data, (&(struct BMeshToMeshParams){0}));
++  BM_mesh_bm_to_me(
++      bmain, base_new->object, bm_new, base_new->object->data, (&(struct BMeshToMeshParams){0}));
  
    BM_mesh_free(bm_new);
    ((Mesh *)base_new->object->data)->edit_mesh = NULL;
@@@ -4272,7 -4457,7 +4458,8 @@@ static Base *mesh_separate_arrays(Main 
      BM_vert_kill(bm_old, verts[i]);
    }
  
-   BM_mesh_bm_to_me(bmain, base_new->object, bm_new, base_new->object->data, (&(struct BMeshToMeshParams){0}));
 -  BM_mesh_bm_to_me(bmain, bm_new, base_new->object->data, (&(struct BMeshToMeshParams){0}));
++  BM_mesh_bm_to_me(
++      bmain, base_new->object, bm_new, base_new->object->data, (&(struct BMeshToMeshParams){0}));
  
    BM_mesh_free(bm_new);
    ((Mesh *)base_new->object->data)->edit_mesh = NULL;
@@@ -4454,7 -4639,7 +4641,8 @@@ static bool mesh_separate_loose
    BM_mesh_elem_hflag_disable_all(bm_old, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, false);
  
    if (clear_object_data) {
-     BM_mesh_bm_to_me(NULL, base_old->object,
+     BM_mesh_bm_to_me(NULL,
++                     base_old->object,
                       bm_old,
                       me_old,
                       (&(struct BMeshToMeshParams){
@@@ -5706,112 -5933,6 +5937,116 @@@ static void edbm_dissolve_prop__use_bou
                    "Split off face corners instead of merging faces");
  }
  
 +static int edbm_mres_test_exec(bContext *C, wmOperator *op)
 +{
 +  const bool use_face_split = RNA_boolean_get(op->ptr, "use_face_split");
 +  const bool use_boundary_tear = RNA_boolean_get(op->ptr, "use_boundary_tear");
 +
 +  ViewLayer *view_layer = CTX_data_view_layer(C);
 +  uint objects_len = 0;
 +  Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
 +      view_layer, CTX_wm_view3d(C), &objects_len);
 +
 +  for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
 +    Object *obedit = objects[ob_index];
 +    BMEditMesh *em = BKE_editmesh_from_object(obedit);
 +
 +    if (em->bm->totvertsel == 0) {
 +      continue;
 +    }
 +
 +    BM_custom_loop_normals_to_vector_layer(em->bm);
 +
-     if (!EDBM_op_callf(em,
-                        op,
-                        "test_mres_smooth")) {
++    if (!EDBM_op_callf(em, op, "test_mres_smooth")) {
 +      continue;
 +    }
 +
 +    BM_custom_loop_normals_from_vector_layer(em->bm, false);
-     EDBM_update_generic(obedit->data, true, true);
++
++    EDBM_update(obedit->data,
++                &(const struct EDBMUpdate_Params){
++                    .calc_looptri = true,
++                    .calc_normals = false,
++                    .is_destructive = true,
++                });
++    // EDBM_update_generic(obedit->data, true, true);
 +  }
 +
 +  MEM_freeN(objects);
 +  return OPERATOR_FINISHED;
 +}
 +
- 
 +extern Object *multires_dump_grids_bmesh(Object *bmob, BMesh *bm);
 +
 +static int edbm_dump_mres_grids_exec(bContext *C, wmOperator *op)
 +{
 +  const bool use_face_split = RNA_boolean_get(op->ptr, "use_face_split");
 +  const bool use_boundary_tear = RNA_boolean_get(op->ptr, "use_boundary_tear");
 +
 +  ViewLayer *view_layer = CTX_data_view_layer(C);
 +  uint objects_len = 0;
 +  Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
 +      view_layer, CTX_wm_view3d(C), &objects_len);
 +
 +  for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
 +    Object *obedit = objects[ob_index];
 +    BMEditMesh *em = BKE_editmesh_from_object(obedit);
 +
 +    multires_dump_grids_bmesh(obedit, em->bm);
 +  }
 +
 +  WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, CTX_data_scene(C));
 +
 +  MEM_freeN(objects);
 +  return OPERATOR_FINISHED;
 +}
 +
 +static bool mres_test_poll(bContext *C)
 +{
 +  Object *obedit = CTX_data_edit_object(C);
 +  if (obedit && obedit->type == OB_MESH) {
 +    BMEditMesh *em = BKE_editmesh_from_object(obedit);
 +
 +    if (!em || !CustomData_has_layer(&em->bm->ldata, CD_MDISPS)) {
 +      return false;
 +    }
 +
 +    return true;
 +  }
 +
 +  return false;
 +}
 +
- void MESH_OT_dump_mres_grids(wmOperatorType *ot) {
++void MESH_OT_dump_mres_grids(wmOperatorType *ot)
++{
 +  /* identifiers */
 +  ot->name = "Dump Multires Grids";
 +  ot->description = "Dump Multires Grids";
 +  ot->idname = "MESH_OT_dump_mres_grids";
 +
 +  /* api callbacks */
 +  ot->exec = edbm_dump_mres_grids_exec;
 +  ot->poll = mres_test_poll;
 +
 +  /* flags */
 +  ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 +}
 +
 +void MESH_OT_mres_test(wmOperatorType *ot)
 +{
 +  /* identifiers */
 +  ot->name = "Test Multires Boundary Smooth";
 +  ot->description = "Test multires boundary smooth";
 +  ot->idname = "MESH_OT_mres_test";
 +
 +  /* api callbacks */
 +  ot->exec = edbm_mres_test_exec;
 +  ot->poll = mres_test_poll;
 +
 +  /* flags */
 +  ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 +}
 +
- 
  static int edbm_dissolve_verts_exec(bContext *C, wmOperator *op)
  {
    const bool use_face_split = RNA_boolean_get(op->ptr, "use_face_split");
diff --cc source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
index d3a2337b1a1,3796e374db7..0b7e50e29a6
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
@@@ -1517,240 -1562,232 +1562,233 @@@ static void lineart_geometry_object_loa
    LineartTriangle *ort;
    Object *orig_ob;
    int CanFindFreestyle = 0;
-   int i, global_i = (*global_vindex);
-   Mesh *use_mesh;
+   int i;
    float use_crease = 0;
  
-   int usage = override_usage ? override_usage : ob->lineart.usage;
+   int usage = obi->usage;
  
- #define LRT_MESH_FINISH \
-   BM_mesh_free(bm); \
-   if (ob->type != OB_MESH) { \
-     BKE_mesh_free(use_mesh); \
-     MEM_freeN(use_mesh); \
+   if (obi->original_me->edit_mesh) {
+     /* Do not use edit_mesh directly because we will modify it, so create a copy. */
+     bm = BM_mesh_copy(obi->original_me->edit_mesh->bm);
+   }
+   else {
+     const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(((Mesh *)(obi->original_me)));
+     bm = BM_mesh_create(&allocsize,
+                         &((struct BMeshCreateParams){
+                             .use_toolflags = true,
+                         }));
 -    BM_mesh_bm_from_me(bm,
++    BM_mesh_bm_from_me(orig_ob,
++                       bm,
+                        obi->original_me,
+                        &((struct BMeshFromMeshParams){
+                            .calc_face_normal = true,
+                        }));
    }
  
-   if (usage == OBJECT_LRT_EXCLUDE) {
-     return;
+   if (obi->free_use_mesh) {
+     BKE_mesh_free(obi->original_me);
+     MEM_freeN(obi->original_me);
    }
  
-   if (ELEM(ob->type, OB_MESH, OB_MBALL, OB_CURVE, OB_SURF, OB_FONT)) {
+   if (rb->remove_doubles) {
+     BMEditMesh *em = BKE_editmesh_create(bm, false);
+     BMOperator findop, weldop;
  
-     if (ob->type == OB_MESH) {
-       use_mesh = DEG_get_evaluated_object(dg, ob)->data;
-     }
-     else {
-       use_mesh = BKE_mesh_new_from_object(NULL, ob, false, false);
-     }
+     /* See bmesh_opdefines.c and bmesh_operators.c for op names and argument formatting. */
+     BMO_op_initf(bm, &findop, BMO_FLAG_DEFAULTS, "find_doubles verts=%av dist=%f", 0.0001);
  
-     /* In case we can not get any mesh geometry data from the object */
-     if (!use_mesh) {
-       ret

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list