[Bf-blender-cvs] [fe67ca56d6b] temp_bmesh_multires: * Fixed wireframe drawing in vcol cell drawing mode * Added UI for editing local brush dyntopo settings.

Joseph Eagar noreply at git.blender.org
Sun Apr 11 20:40:41 CEST 2021


Commit: fe67ca56d6b426bb70ed284dbf23249f2d6d3054
Author: Joseph Eagar
Date:   Sun Apr 11 11:38:27 2021 -0700
Branches: temp_bmesh_multires
https://developer.blender.org/rBfe67ca56d6b426bb70ed284dbf23249f2d6d3054

* Fixed wireframe drawing in vcol cell drawing mode
* Added UI for editing local brush dyntopo settings.

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

M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/gpu/intern/gpu_buffers.c
M	source/blender/makesrna/intern/rna_brush.c

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

diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index f857f9fef95..286b44a18db 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -754,6 +754,66 @@ class VIEW3D_PT_tools_brush_falloff_normal(View3DPaintPanel, Panel):
         layout.prop(ipaint, "normal_angle", text="Angle")
 
 
+# TODO, move to space_view3d.py
+class VIEW3D_PT_sculpt_dyntopo_advanced(Panel, View3DPaintPanel):
+    bl_context = ".sculpt_mode"  # dot on purpose (access from topbar)
+    bl_label = "Dyntopo (Advanced)"
+    #bl_options = {'DEFAULT_CLOSED'}
+    bl_ui_units_x = 12
+
+    @classmethod
+    def poll(cls, context):
+        paint_settings = cls.paint_settings(context)
+        return (context.sculpt_object and context.tool_settings.sculpt and paint_settings)
+
+    def draw_header(self, context):
+        pass
+
+    def draw(self, context):
+        layout = self.layout
+        layout.use_property_split = True
+        layout.use_property_decorate = False
+
+        tool_settings = context.tool_settings
+        sculpt = tool_settings.sculpt
+        settings = self.paint_settings(context)
+        brush = settings.brush
+
+        col = layout.column()
+        print(dir(col))
+        col.label(text="Local Brush Settings")
+        inherit_all = "ALL" in brush.dyntopo.inherit
+
+        col.prop_enum(brush.dyntopo, "inherit", value="ALL", text="All Scene Defaults", icon="LOCKED" if inherit_all else "UNLOCKED");
+
+
+        def do_prop(key):
+            row = col.row()
+            if key.upper() in brush.dyntopo.inherit:
+                icon = "LOCKED"
+            else:
+                icon = "UNLOCKED"
+
+            row.prop_enum(brush.dyntopo, "inherit", value=key.upper(), icon=icon, text="");
+
+            row2 = row.row()
+            row2.prop(brush.dyntopo, key)
+
+            if icon == "UNLOCKED":
+                row2.enabled = False
+
+            if inherit_all:
+                row.enabled = False
+
+        col = layout.column()
+        do_prop("subdivide");
+        do_prop("collapse");
+        do_prop("spacing");
+        do_prop("detail_range");
+        do_prop("detail_percent");
+        do_prop("constant_detail");
+        do_prop("mode")
+
 # TODO, move to space_view3d.py
 class VIEW3D_PT_sculpt_dyntopo(Panel, View3DPaintPanel):
     bl_context = ".sculpt_mode"  # dot on purpose (access from topbar)
@@ -2242,6 +2302,7 @@ classes = (
     VIEW3D_PT_tools_grease_pencil_brush_vertex_color,
     VIEW3D_PT_tools_grease_pencil_brush_vertex_palette,
     VIEW3D_PT_tools_grease_pencil_brush_vertex_falloff,
+    VIEW3D_PT_sculpt_dyntopo_advanced
 )
 
 if __name__ == "__main__":  # only for live edit.
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index dce0cec2ecb..c7de4a45a6f 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -1130,21 +1130,6 @@ static void GPU_pbvh_bmesh_buffers_update_flat_vcol(GPU_PBVH_Buffers *buffers,
       }
       fmask /= 3.0f;
 
-      /*
-
-
-      v1
-      |\
-      |   \
-      v3    v4
-      |  v6   \
-      |         \
-      v0---v5---v2
-      */
-      GPU_indexbuf_add_line_verts(&elb_lines, v_index + 0, v_index + 1);
-      GPU_indexbuf_add_line_verts(&elb_lines, v_index + 1, v_index + 2);
-      GPU_indexbuf_add_line_verts(&elb_lines, v_index + 2, v_index + 0);
-
       uchar face_set_color[4] = {UCHAR_MAX, UCHAR_MAX, UCHAR_MAX, UCHAR_MAX};
 
       if (show_face_sets && cd_fset_offset >= 0) {
@@ -1180,6 +1165,8 @@ static void GPU_pbvh_bmesh_buffers_update_flat_vcol(GPU_PBVH_Buffers *buffers,
       interp_v3_v3v3(cos[4], v[1]->co, v[2]->co, 0.5f);
       interp_v3_v3v3(cos[5], v[2]->co, v[0]->co, 0.5f);
 
+      const int v_start = v_index;
+
       for (int j = 0; j < 3; j++) {
         int next = 3 + ((j) % 3);
         int prev = 3 + ((j + 3 - 1) % 3);
@@ -1198,6 +1185,23 @@ static void GPU_pbvh_bmesh_buffers_update_flat_vcol(GPU_PBVH_Buffers *buffers,
         gpu_flat_vcol_make_vert(
             cos[prev], v[j], buffers->vert_buf, v_index + 5, cd_vcols, cd_vcol_count, f->no);
 
+
+      /*
+        v1
+        |\
+        |   \
+        v3    v4
+        |  v6   \
+        |         \
+        v0---v5---v2
+        */
+
+        next = j == 2 ? v_start : v_index + 6;
+
+        GPU_indexbuf_add_line_verts(&elb_lines, v_index, next);
+        // GPU_indexbuf_add_line_verts(&elb_lines, v_index + 1, v_index + 2);
+        // GPU_indexbuf_add_line_verts(&elb_lines, v_index + 2, v_index + 0);
+
         v_index += 6;
       }
       /*
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index 8f16fb0c5f1..8dbd417f923 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -363,10 +363,11 @@ static EnumPropertyItem rna_enum_brush_dyntopo_inherit[] = {
     {DYNTOPO_COLLAPSE, "COLLAPSE", ICON_NONE, "Collapse", ""},
     {DYNTOPO_DISABLED, "DISABLED", ICON_NONE, "Disable", ""},
     {DYNTOPO_INHERIT_ALL, "ALL", ICON_NONE, "All", "Inherit All"},
-    {DYNTOPO_INHERIT_DETAIL_RANGE, "RANGE", ICON_NONE, "All", ""},
-    {DYNTOPO_INHERIT_DETAIL_PERCENT, "PERCENT", ICON_NONE, "Percent", ""},
+    {DYNTOPO_INHERIT_DETAIL_RANGE, "DETAIL_RANGE", ICON_NONE, "All", ""},
+    {DYNTOPO_INHERIT_DETAIL_PERCENT, "DETAIL_PERCENT", ICON_NONE, "Percent", ""},
     {DYNTOPO_INHERIT_MODE, "MODE", ICON_NONE, "Mode", ""},
     {DYNTOPO_INHERIT_CONSTANT_DETAIL, "CONSTANT_DETAIL", ICON_NONE, "Constant Detail", ""},
+    {DYNTOPO_INHERIT_SPACING, "SPACING", ICON_NONE, "Spacing", ""},
     {0, NULL, 0, NULL, NULL},
 };
 
@@ -1180,6 +1181,30 @@ static void rna_def_dyntopo_settings(BlenderRNA *brna) {
       prop, "Spacing", "Spacing between DynTopo daubs as a percentage of brush diameter");
   RNA_def_property_update(prop, 0, "rna_Brush_update");
 
+  prop = RNA_def_property(srna, "detail_percent", PROP_FLOAT, PROP_PERCENTAGE);
+  RNA_def_property_float_sdna(prop, NULL, "detail_percent");
+  RNA_def_property_range(prop, 1, 1000);
+  RNA_def_property_ui_range(prop, 1, 500, 5, -1);
+  RNA_def_property_ui_text(
+      prop, "Detail Percent", "");
+  RNA_def_property_update(prop, 0, "rna_Brush_update");
+
+  prop = RNA_def_property(srna, "detail_range", PROP_FLOAT, PROP_NONE);
+  RNA_def_property_float_sdna(prop, NULL, "detail_range");
+  RNA_def_property_range(prop, 0.0, 1.0);
+  RNA_def_property_ui_range(prop, 0.0, 1.0, 0.001, 4);
+  RNA_def_property_ui_text(
+      prop, "Detail Range", "Higher values are faster but produce lower quality topology");
+  RNA_def_property_update(prop, 0, "rna_Brush_update");
+
+  prop = RNA_def_property(srna, "constant_detail", PROP_FLOAT, PROP_NONE);
+  RNA_def_property_float_sdna(prop, NULL, "constant_detail");
+  RNA_def_property_range(prop, 0.0, 1.0);
+  RNA_def_property_ui_range(prop, 0.0, 1.0, 0.001, 4);
+  RNA_def_property_ui_text(
+      prop, "Constant Detail", "");
+  RNA_def_property_update(prop, 0, "rna_Brush_update");
+
   prop = RNA_def_property(srna, "subdivide", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "flag", DYNTOPO_SUBDIVIDE);
   RNA_def_property_ui_icon(prop, ICON_NONE, 0);
@@ -1201,6 +1226,12 @@ static void rna_def_dyntopo_settings(BlenderRNA *brna) {
   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
   RNA_def_property_update(prop, 0, "rna_Brush_update");
 
+  prop = RNA_def_property(srna, "mode", PROP_ENUM, 0);
+  RNA_def_property_enum_sdna(prop, NULL, "mode");
+  RNA_def_property_enum_items(prop, rna_enum_brush_dyntopo_mode);
+  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+  RNA_def_property_ui_text(prop, "Mode", "Detail Mode");
+
   prop = RNA_def_property(srna, "inherit", PROP_ENUM, 0);
   RNA_def_property_enum_sdna(prop, NULL, "inherit");
   RNA_def_property_enum_items(prop, rna_enum_brush_dyntopo_inherit);



More information about the Bf-blender-cvs mailing list