Commit: de180aba35ea0bc203abb4995b9fbcaa2d97aaa2
Author: Antony Riakiotakis
Date:   Wed May 6 22:51:49 2015 +0200
Branches: master
https://developer.blender.org/rBde180aba35ea0bc203abb4995b9fbcaa2d97aaa2

Feature request: Dyntopo detail expressed in percentage of brush radius.

Not sure how useful this will be but people have requested it so, here
it is...

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

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

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

diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py 
b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 51dd8b0..5fa3a55 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -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="")
diff --git a/source/blender/editors/sculpt_paint/sculpt.c 
b/source/blender/editors/sculpt_paint/sculpt.c
index 1d2f623..e2403a5 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -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");
diff --git a/source/blender/makesdna/DNA_scene_types.h 
b/source/blender/makesdna/DNA_scene_types.h
index ff2a746..a40b8af 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -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 {
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c 
b/source/blender/makesrna/intern/rna_sculpt_paint.c
index a975ea3..d5e99d4 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -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);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to