[Bf-blender-cvs] [03afa6f] master: Experimental dyntopo feature:

Antony Riakiotakis noreply at git.blender.org
Thu Mar 6 19:17:48 CET 2014


Commit: 03afa6f9e7546d26766f0ac7bdb23da56a708306
Author: Antony Riakiotakis
Date:   Thu Mar 6 20:04:57 2014 +0200
https://developer.blender.org/rB03afa6f9e7546d26766f0ac7bdb23da56a708306

Experimental dyntopo feature:

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.

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

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 d331ddd..cc85471 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -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")
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index e2df6a4..9b92ca6 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -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);
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 8c4026e..d66a1f3 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -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)
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index 5827458..e13e9b3 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -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);




More information about the Bf-blender-cvs mailing list