Experimental dyntopo feature:
authorAntony Riakiotakis <kalast@gmail.com>
Thu, 6 Mar 2014 18:04:57 +0000 (20:04 +0200)
committerAntony Riakiotakis <kalast@gmail.com>
Thu, 6 Mar 2014 18:15:44 +0000 (20:15 +0200)
Dyntopo detail in object space. This allows to set the detail in
percentage of blender units and sculpt in this detail constantly,
regardless of the distance to the mesh.

This commit just enables the functionality, which is really trivial.
There will be some more commits like detail flood fill and
detail sampling in the future.

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 d331ddd53f482ca82a0b6765f42c6d5e9111b1cd..cc85471943e814450afb448d9ab5fce7fe3d6dba 100644 (file)
@@ -1221,6 +1221,7 @@ class VIEW3D_PT_sculpt_topology(Panel, View3DPaintPanel):
         sub.active = brush and brush.sculpt_tool not in ('MASK')
         sub.prop(sculpt, "detail_size")
         sub.prop(sculpt, "detail_refine_method", text="")
+        sub.prop(sculpt, "detail_type_method", text="")
         col.separator()
         col.prop(sculpt, "use_smooth_shading")
         col.operator("sculpt.optimize")
index e2df6a4a197818cd3f51a8af57dc1ed160971d8a..9b92ca6ccf8ef1b6abcd107c6c625f49d2ee1c95 100644 (file)
@@ -4485,10 +4485,15 @@ static void sculpt_stroke_update_step(bContext *C, struct PaintStroke *UNUSED(st
        sculpt_update_cache_variants(C, sd, ob, itemptr);
        sculpt_restore_mesh(sd, ob);
 
-       BKE_pbvh_bmesh_detail_size_set(ss->pbvh,
-                                      (ss->cache->radius /
-                                       (float)ups->pixel_radius) *
-                                      (float)sd->detail_size);
+       if (sd->flags & SCULPT_DYNTOPO_DETAIL_CONSTANT) {
+               BKE_pbvh_bmesh_detail_size_set(ss->pbvh, (float)sd->detail_size/100.0f);
+       }
+       else {
+               BKE_pbvh_bmesh_detail_size_set(ss->pbvh,
+                                                                          (ss->cache->radius /
+                                                                               (float)ups->pixel_radius) *
+                                                                          (float)sd->detail_size);
+       }
 
        if (sculpt_stroke_dynamic_topology(ss, brush)) {
                do_symmetrical_brush_actions(sd, ob, sculpt_topology_update);
index 8c4026e8b670099f03422a5240ccdfb813348e72..d66a1f3ab0b28dbf750a527fdb3f507993c208fc 100644 (file)
@@ -1626,7 +1626,10 @@ typedef enum SculptFlags {
        /* If set, dynamic-topology brushes will subdivide short edges */
        SCULPT_DYNTOPO_SUBDIVIDE = (1 << 12),
        /* If set, dynamic-topology brushes will collapse short edges */
-       SCULPT_DYNTOPO_COLLAPSE = (1 << 11)
+       SCULPT_DYNTOPO_COLLAPSE = (1 << 11),
+
+       /* If set, dynamic-topology detail size will be constant in object space */
+       SCULPT_DYNTOPO_DETAIL_CONSTANT = (1 << 13)
 } SculptFlags;
 
 #if (DNA_DEPRECATED_GCC_POISON == 1)
index 58274589126eb1c019cb1a62da796ecb3cdb326a..e13e9b3cad4d4a87b9e6582480c2f3e6f8fe2c24 100644 (file)
@@ -357,6 +357,14 @@ static void rna_def_sculpt(BlenderRNA  *brna)
                {0, NULL, 0, NULL, NULL}
        };
 
+       static EnumPropertyItem detail_type_items[] = {
+               {0, "RELATIVE", 0,
+                "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"},
+               {0, NULL, 0, NULL, NULL}
+       };
+
        StructRNA *srna;
        PropertyRNA *prop;
 
@@ -406,7 +414,7 @@ static void rna_def_sculpt(BlenderRNA  *brna)
                                 "Show diffuse color of object and overlay sculpt mask on top of it");
        RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_ShowDiffuseColor_update");
 
-       prop = RNA_def_property(srna, "detail_size", PROP_INT, PROP_PIXEL);
+       prop = RNA_def_property(srna, "detail_size", PROP_INT, PROP_NONE);
        RNA_def_property_ui_range(prop, 2, 100, 0, -1);
        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);
@@ -429,6 +437,13 @@ static void rna_def_sculpt(BlenderRNA  *brna)
                                 "In dynamic-topology mode, how to add or remove mesh detail");
        RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
 
+       prop = RNA_def_property(srna, "detail_type_method", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_bitflag_sdna(prop, NULL, "flags");
+       RNA_def_property_enum_items(prop, detail_type_items);
+       RNA_def_property_ui_text(prop, "Detail Type Method",
+                                                        "In dynamic-topology mode, how mesh detail size is calculated");
+       RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
+
        prop = RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_NONE);
        RNA_def_property_float_sdna(prop, NULL, "gravity_factor");
        RNA_def_property_range(prop, 0.0f, 1.0f);