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.
This commit is contained in:
Antonis Ryakiotakis 2014-03-06 20:04:57 +02:00
parent 2a167dafc2
commit 03afa6f9e7
4 changed files with 30 additions and 6 deletions

View 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")

View 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);

View 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)

View 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);