[Bf-blender-cvs] [bb764e418aa] sculpt-dev: sculpt-dev: DynTopo cleanup

Joseph Eagar noreply at git.blender.org
Sun Dec 11 09:41:50 CET 2022


Commit: bb764e418aa2d92661812885e4b4343558005244
Author: Joseph Eagar
Date:   Sun Dec 11 00:38:14 2022 -0800
Branches: sculpt-dev
https://developer.blender.org/rBbb764e418aa2d92661812885e4b4343558005244

sculpt-dev: DynTopo cleanup

* Moved dyntopo.c to c++.
* The new element id system now mostly
  works. Doesn't yet work with collapse
  though, which is a tricky case.  Element
  IDs have to be manually freed now, doing that
  with something as convoluted as a non-manifold
  BREP's edge collapse is not easy.

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

M	release/scripts/startup/bl_ui/properties_data_mesh.py
M	release/scripts/startup/bl_ui/properties_paint_common.py
M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/blenkernel/BKE_paint.h
M	source/blender/blenkernel/BKE_pbvh.h
M	source/blender/blenkernel/CMakeLists.txt
R090	source/blender/blenkernel/intern/dyntopo.c	source/blender/blenkernel/intern/dyntopo.cc
M	source/blender/blenkernel/intern/paint.cc
M	source/blender/blenkernel/intern/pbvh_bmesh.c
M	source/blender/blenkernel/intern/pbvh_intern.h
M	source/blender/blenlib/BLI_ghash.h
M	source/blender/blenlib/intern/smallhash.c
M	source/blender/bmesh/intern/bmesh_core.c
M	source/blender/bmesh/intern/bmesh_idmap.cc
M	source/blender/bmesh/intern/bmesh_idmap.h
M	source/blender/bmesh/intern/bmesh_interp.h
M	source/blender/bmesh/intern/bmesh_log.c
M	source/blender/bmesh/intern/bmesh_log.h
M	source/blender/bmesh/intern/bmesh_log_intern.h
M	source/blender/bmesh/intern/bmesh_mods.c
M	source/blender/draw/intern/draw_manager_data.cc
M	source/blender/draw/intern/draw_pbvh.cc
M	source/blender/editors/sculpt_paint/paint_mask.c
M	source/blender/editors/sculpt_paint/sculpt_dyntopo.c
M	source/blender/editors/sculpt_paint/sculpt_ops.c
M	source/blender/editors/sculpt_paint/sculpt_undo.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py
index 56252ff113a..9452e72b684 100644
--- a/release/scripts/startup/bl_ui/properties_data_mesh.py
+++ b/release/scripts/startup/bl_ui/properties_data_mesh.py
@@ -540,7 +540,7 @@ class MESH_UL_attributes(UIList):
         show_all = _context.tool_settings.save_temp_layers if hasattr(_context, "tool_settings") else False
 
         for item in attributes:
-            flags.append(0 if item.is_internal else self.bitflag_filter_item)
+            flags.append(0 if (not show_all and item.is_internal) else self.bitflag_filter_item)
 
         return flags, indices
 
diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index ca7bbdf38c4..5c045df9148 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -2158,10 +2158,10 @@ def brush_settings_advanced(layout, context, brush, popover=False):
         is_cavity_active = "CAVITY" in flags or "CAVITY_INVERTED" in flags
 
         if is_cavity_active:
-            props = row.operator("sculpt.mask_from_cavity", text="Create Mask")
+            props = layout.operator("sculpt.mask_from_cavity", text="Create Mask")
             props.settings_source = "BRUSH"
 
-        col.prop(brush, "use_automasking_cavity_inverted", text="Cavity (inverted)")
+        layout.prop(brush, "use_automasking_cavity_inverted", text="Cavity (inverted)")
 
         if is_cavity_active:
             col = layout.column(align=True)
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 9328a08f98d..0b99bc81d95 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -1148,6 +1148,8 @@ class SCULPT_OT_set_dyntopo_mode(Operator):
         elif self.mode == "C":
             finalch.flags_value = oldf.union({"COLLAPSE"})
 
+        print("NEWF", finalch.flags_value)
+
         return {'FINISHED'}
 
 
@@ -2891,7 +2893,8 @@ class VIEW3D_PT_gpencil_brush_presets(Panel, PresetPanel):
     preset_add_operator = "scene.gpencil_brush_preset_add"
 
 
-classes = (VIEW3D_MT_brush_context_menu,
+classes = (SCULPT_OT_set_dyntopo_mode,
+    VIEW3D_MT_brush_context_menu,
     VIEW3D_MT_brush_gpencil_context_menu,
     VIEW3D_PT_tools_object_options,
     VIEW3D_PT_tools_object_options_transform,
@@ -2990,8 +2993,7 @@ classes = (VIEW3D_MT_brush_context_menu,
     VIEW3D_PT_tools_grease_pencil_brush_vertex_falloff,
     VIEW3D_PT_tools_brush_swatches_channels,
     VIEW3D_PT_tools_persistent_base_channels,
-    VIEW3D_PT_sculpt_dyntopo_advanced,
-    SCULPT_OT_set_dyntopo_mode)
+    VIEW3D_PT_sculpt_dyntopo_advanced)
 
 if __name__ == "__main__":  # only for live edit.
     from bpy.utils import register_class
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index e2921441b33..36217320263 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -30,6 +30,7 @@ struct SculptAttribute;
 struct MSculptVert;
 struct BMFace;
 struct BMesh;
+struct BMIdMap;
 struct BlendDataReader;
 struct BlendLibReader;
 struct BlendWriter;
@@ -821,6 +822,7 @@ typedef struct SculptSession {
 
   /* BMesh for dynamic topology sculpting */
   struct BMesh *bm;
+  struct BMIdMap *bm_idmap;
 
   /* TODO: get rid of these cd_ members and use
    * .attrs.XXX.bmesh_cd_offset directly.
@@ -1042,7 +1044,9 @@ void BKE_sculptsession_bm_to_me(struct Object *ob, bool reorder);
 void BKE_sculptsession_bm_to_me_for_render(struct Object *object);
 int BKE_sculptsession_vertex_count(const SculptSession *ss);
 
-/* Ensure an attribute layer exists. */
+void BKE_sculpt_ensure_idmap(struct Object *ob);
+
+    /* Ensure an attribute layer exists. */
 SculptAttribute *BKE_sculpt_attribute_ensure(struct Object *ob,
                                              eAttrDomain domain,
                                              eCustomDataType proptype,
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index 2efed15b921..77ce9bfb7d1 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -98,6 +98,7 @@ struct BMesh;
 struct BMVert;
 struct BMEdge;
 struct BMFace;
+struct BMIdMap;
 struct Scene;
 struct CCGElem;
 struct MeshElemMap;
@@ -276,6 +277,8 @@ typedef enum {
   PBVH_UpdateOtherVerts = 1 << 21
 } PBVHNodeFlags;
 
+ENUM_OPERATORS(PBVHNodeFlags, PBVH_UpdateOtherVerts);
+
 typedef struct PBVHFrustumPlanes {
   float (*planes)[4];
   int num_planes;
@@ -433,6 +436,7 @@ void BKE_pbvh_build_bmesh(PBVH *pbvh,
                           struct BMesh *bm,
                           bool smooth_shading,
                           struct BMLog *log,
+                          struct BMIdMap *idmap,
                           const int cd_vert_node_offset,
                           const int cd_face_node_offset,
                           const int cd_sculpt_vert,
@@ -440,6 +444,9 @@ void BKE_pbvh_build_bmesh(PBVH *pbvh,
                           const int cd_boundary_flag,
                           bool fast_draw,
                           bool update_sculptverts);
+
+void BKE_pbvh_set_idmap(PBVH *pbvh, struct BMIdMap *idmap);
+
 void BKE_pbvh_update_offsets(PBVH *pbvh,
                              const int cd_vert_node_offset,
                              const int cd_face_node_offset,
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 6e9588a41d6..602c2e26db1 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -131,7 +131,7 @@ set(SRC
   intern/deform.c
   intern/displist.cc
   intern/dynamicpaint.c
-  intern/dyntopo.c
+  intern/dyntopo.cc
   intern/editlattice.c
   intern/editmesh.cc
   intern/editmesh_bvh.c
diff --git a/source/blender/blenkernel/intern/dyntopo.c b/source/blender/blenkernel/intern/dyntopo.cc
similarity index 90%
rename from source/blender/blenkernel/intern/dyntopo.c
rename to source/blender/blenkernel/intern/dyntopo.cc
index 706ada16f1d..baab7497ec9 100644
--- a/source/blender/blenkernel/intern/dyntopo.c
+++ b/source/blender/blenkernel/intern/dyntopo.cc
@@ -5,6 +5,13 @@
 #include "DNA_meshdata_types.h"
 #include "DNA_modifier_types.h"
 
+#include "BLI_array.hh"
+#include "BLI_index_range.hh"
+#include "BLI_map.hh"
+#include "BLI_set.hh"
+#include "BLI_task.hh"
+#include "BLI_vector.hh"
+
 #include "BLI_alloca.h"
 #include "BLI_array.h"
 #include "BLI_asan.h"
@@ -38,6 +45,14 @@
 
 #include <stdio.h>
 
+using blender::float2;
+using blender::float3;
+using blender::float4;
+using blender::IndexRange;
+using blender::Map;
+using blender::Set;
+using blender::Vector;
+
 //#define DYNTOPO_VALIDATE_LOG
 
 #ifdef DYNTOPO_VALIDATE_LOG
@@ -208,7 +223,7 @@ static void pbvh_split_edges(struct EdgeQueueContext *eq_ctx,
                              BMEdge **edges,
                              int totedge,
                              bool ignore_isolated_edges);
-void bm_log_message(const char *fmt, ...);
+extern "C" void bm_log_message(const char *fmt, ...);
 
 static void edge_queue_create_local(struct EdgeQueueContext *eq_ctx,
                                     PBVH *pbvh,
@@ -219,11 +234,13 @@ static void edge_queue_create_local(struct EdgeQueueContext *eq_ctx,
                                     const bool use_projected,
                                     PBVHTopologyUpdateMode local_mode);
 
+extern "C" {
 void bmesh_disk_edge_append(BMEdge *e, BMVert *v);
 void bmesh_radial_loop_append(BMEdge *e, BMLoop *l);
 void bm_kill_only_edge(BMesh *bm, BMEdge *e);
 void bm_kill_only_loop(BMesh *bm, BMLoop *l);
 void bm_kill_only_face(BMesh *bm, BMFace *f);
+}
 static bool edge_queue_test(struct EdgeQueueContext *eq_ctx, PBVH *pbvh, BMEdge *e);
 
 static void fix_mesh(PBVH *pbvh, BMesh *bm)
@@ -236,7 +253,7 @@ static void fix_mesh(PBVH *pbvh, BMesh *bm)
   printf("fixing mesh. . .\n");
 
   BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
-    v->e = NULL;
+    v->e = nullptr;
     MSculptVert *mv = BKE_PBVH_SCULPTVERT(pbvh->cd_sculpt_vert, v);
 
     MV_ADD_FLAG(mv,
@@ -244,9 +261,9 @@ static void fix_mesh(PBVH *pbvh, BMesh *bm)
   }
 
   BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
-    e->v1_disk_link.next = e->v1_disk_link.prev = NULL;
-    e->v2_disk_link.next = e->v2_disk_link.prev = NULL;
-    e->l = NULL;
+    e->v1_disk_link.next = e->v1_disk_link.prev = nullptr;
+    e->v2_disk_link.next = e->v2_disk_link.prev = nullptr;
+    e->l = nullptr;
 
     if (e->v1 == e->v2) {
       bm_kill_only_edge(bm, e);
@@ -298,7 +315,7 @@ static void fix_mesh(PBVH *pbvh, BMesh *bm)
       int ni = BM_ELEM_CD_GET_INT(f, pbvh->cd_face_node_offset);
 
       if (ni >= 0 && ni < pbvh->totnode && (pbvh->nodes[ni].flag & PBVH_Leaf)) {
-        BLI_table_gset_remove(pbvh->nodes[ni].bm_faces, f, NULL);
+        BLI_table_gset_remove(pbvh->nodes[ni].bm_faces, f, nullptr);
       }
 
       bm_kill_only_face(bm, f);
@@ -309,7 +326,7 @@ static void fix_mesh(PBVH *pbvh, BMesh *bm)
       l->e = BM_edge_exists(l->v, l->next->v);
 
       if (!l->e) {
-        l->e = BM_edge_create(bm, l->v, l->next->v, NULL, BM_CREATE_NOP);
+        l->e = BM_edge_create(bm, l->v, l->next->v, nullptr, BM_CREATE_NOP);
       }
 
       bmesh_radial_loop_append(l->e, l);
@@ -523,7 +540,7 @@ static bool validate_face(PBVH *pbvh, BMesh *bm, BMFace *f, bool autofix, bool c
     return false;
   }
 
-  BMLoop **ls = NULL;
+  BMLoop **ls = nullptr;
   BLI_array_staticdeclare(ls, 32);
 
   BMLoop *l = f->l_first;
@@ -776,6 +793,9 @@ static void pbvh_kill_vert(PBVH *pbvh, BMVert *v, bool log_vert, bool log_edges)
     BM_log_vert_removed(pbvh->bm_log, v, -1);
   }
 
+#ifdef USE_NEW_IDMAP
+  BM_idmap_release(pbvh->bm_idmap, (BMElem *)v, true);
+#endif
   BM_vert_kill(pbvh->header.bm, v);
   bm_logstack_pop();
 }
@@ -797,9 +817,9 @@ static void pbvh_log_vert_edges_kill(PBVH *pbvh, BMVert *v)
 
 static void bm_edges_from_tri(PBVH *pbvh, BMVert *v_t

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list