Feature request: Dyntopo detail expressed in percentage of brush radius.
authorAntony Riakiotakis <kalast@gmail.com>
Wed, 6 May 2015 20:51:49 +0000 (22:51 +0200)
committerAntony Riakiotakis <kalast@gmail.com>
Wed, 6 May 2015 20:51:49 +0000 (22:51 +0200)
Not sure how useful this will be but people have requested it so, here
it is...

release/scripts/startup/bl_ui/space_view3d_toolbar.py
source/blender/editors/sculpt_paint/sculpt.c
source/blender/makesdna/DNA_scene_types.h
source/blender/makesrna/intern/rna_sculpt_paint.c

index 51dd8b05f93f555db9b90b5a270a7d927eca705a..5fa3a559ab986c23a3e2b3aa7b4f1e52b2848268 100644 (file)
@@ -1471,6 +1471,8 @@ class VIEW3D_PT_sculpt_dyntopo(Panel, View3DPaintPanel):
             row = sub.row(align=True)
             row.prop(sculpt, "constant_detail")
             row.operator("sculpt.sample_detail_size", text="", icon='EYEDROPPER')
+        elif (sculpt.detail_type_method == 'BRUSH'):
+            sub.prop(sculpt, "detail_percent")
         else:
             sub.prop(sculpt, "detail_size")
         sub.prop(sculpt, "detail_refine_method", text="")
index 1d2f623bf9d7d2f0a27abfc7f362d36fcf10cfdd..e2403a57556826a06ba0d697049321f63b712b44 100644 (file)
@@ -4379,6 +4379,9 @@ static void sculpt_stroke_update_step(bContext *C, struct PaintStroke *UNUSED(st
        if (sd->flags & SCULPT_DYNTOPO_DETAIL_CONSTANT) {
                BKE_pbvh_bmesh_detail_size_set(ss->pbvh, sd->constant_detail / 100.0f);
        }
+       else if (sd->flags & SCULPT_DYNTOPO_DETAIL_BRUSH) {
+               BKE_pbvh_bmesh_detail_size_set(ss->pbvh, ss->cache->radius * sd->detail_percent / 100.0f);
+       }
        else {
                BKE_pbvh_bmesh_detail_size_set(
                        ss->pbvh,
@@ -5072,10 +5075,10 @@ static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op)
                        ts->sculpt->flags |= SCULPT_DYNTOPO_SUBDIVIDE | SCULPT_DYNTOPO_COLLAPSE;
                }
 
-               if (!ts->sculpt->detail_size) {
+               if (!ts->sculpt->detail_size)
                        ts->sculpt->detail_size = 12;
-               }
-
+               if (!ts->sculpt->detail_percent)
+                       ts->sculpt->detail_percent = 25;
                if (ts->sculpt->constant_detail == 0.0f)
                        ts->sculpt->constant_detail = 30.0f;
 
@@ -5308,6 +5311,10 @@ static int sculpt_set_detail_size_exec(bContext *C, wmOperator *UNUSED(op))
                set_brush_rc_props(&props_ptr, "sculpt", "constant_detail", NULL, 0);
                RNA_string_set(&props_ptr, "data_path_primary", "tool_settings.sculpt.constant_detail");
        }
+       else if (sd->flags & SCULPT_DYNTOPO_DETAIL_BRUSH) {
+               set_brush_rc_props(&props_ptr, "sculpt", "constant_detail", NULL, 0);
+               RNA_string_set(&props_ptr, "data_path_primary", "tool_settings.sculpt.detail_percent");
+       }
        else {
                set_brush_rc_props(&props_ptr, "sculpt", "detail_size", NULL, 0);
                RNA_string_set(&props_ptr, "data_path_primary", "tool_settings.sculpt.detail_size");
index ff2a74688321f90a1b39a91373fe324034e3947b..a40b8aff08e43d664000d9948950c566923bb437 100644 (file)
@@ -1021,6 +1021,8 @@ typedef struct Sculpt {
 
        /* scale for constant detail size */
        float constant_detail;
+       float detail_percent;
+       float pad;
 
        struct Object *gravity_object;
        void *pad2;
@@ -1851,7 +1853,8 @@ typedef enum SculptFlags {
        SCULPT_DYNTOPO_COLLAPSE = (1 << 11),
 
        /* If set, dynamic-topology detail size will be constant in object space */
-       SCULPT_DYNTOPO_DETAIL_CONSTANT = (1 << 13)
+       SCULPT_DYNTOPO_DETAIL_CONSTANT = (1 << 13),
+       SCULPT_DYNTOPO_DETAIL_BRUSH = (1 << 14),
 } SculptFlags;
 
 typedef enum ImagePaintMode {
index a975ea3d7e4dcdb2ea4f574f4cdb4a0746cd0264..d5e99d4f3e97ede4c3e82eca45e284deabe05b8a 100644 (file)
@@ -462,6 +462,8 @@ static void rna_def_sculpt(BlenderRNA  *brna)
                 "Relative Detail", "Mesh detail is relative to the brush size and detail size"},
                {SCULPT_DYNTOPO_DETAIL_CONSTANT, "CONSTANT", 0,
                 "Constant Detail", "Mesh detail is constant in object space according to detail size"},
+           {SCULPT_DYNTOPO_DETAIL_BRUSH, "BRUSH", 0,
+                "Brush Detail", "Mesh detail is relative to brush radius"},
                {0, NULL, 0, NULL, NULL}
        };
 
@@ -519,6 +521,11 @@ static void rna_def_sculpt(BlenderRNA  *brna)
        RNA_def_property_ui_text(prop, "Detail Size", "Maximum edge length for dynamic topology sculpting (in pixels)");
        RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
 
+       prop = RNA_def_property(srna, "detail_percent", PROP_FLOAT, PROP_PERCENTAGE);
+       RNA_def_property_ui_range(prop, 0.5, 100.0, 10, 2);
+       RNA_def_property_ui_text(prop, "Detail Percentage", "Maximum edge length for dynamic topology sculpting (in brush percenage)");
+       RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
+
        prop = RNA_def_property(srna, "constant_detail", PROP_FLOAT, PROP_PERCENTAGE);
        RNA_def_property_range(prop, 0.001, 10000.0);
        RNA_def_property_ui_range(prop, 0.1, 100.0, 10, 2);