[Bf-blender-cvs] [64337d087de] temp_bmesh_multires: * Merge branch 'master' into temp_bmesh_multires * Implemented DynTopo option to dissolve 3 and 4-valence vertices. * Fixed bug in dyntopo collapse customdata snapping.
Joseph Eagar
noreply at git.blender.org
Mon Apr 12 03:19:48 CEST 2021
Commit: 64337d087de74ec5ddaa06ac9852817bec1fa297
Author: Joseph Eagar
Date: Sun Apr 11 17:58:51 2021 -0700
Branches: temp_bmesh_multires
https://developer.blender.org/rB64337d087de74ec5ddaa06ac9852817bec1fa297
* Merge branch 'master' into temp_bmesh_multires
* Implemented DynTopo option to dissolve 3 and 4-valence
vertices.
* Fixed bug in dyntopo collapse customdata snapping.
===================================================================
===================================================================
diff --cc release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 108758f0eea,ab012a6f2ef..8de62e27bee
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@@ -754,70 -754,6 +754,71 @@@ class VIEW3D_PT_tools_brush_falloff_nor
layout.prop(ipaint, "normal_angle", text="Angle")
+# TODO, move to space_view3d.py
+class VIEW3D_PT_sculpt_dyntopo_advanced(Panel, View3DPaintPanel):
+ bl_context = ".sculpt_mode" # dot on purpose (access from topbar)
+ bl_label = "Dyntopo (Advanced)"
+ #bl_options = {'DEFAULT_CLOSED'}
+ bl_ui_units_x = 12
+
+ @classmethod
+ def poll(cls, context):
+ paint_settings = cls.paint_settings(context)
+ return (context.sculpt_object and context.tool_settings.sculpt and paint_settings)
+
+ def draw_header(self, context):
+ pass
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+ layout.use_property_decorate = False
+
+ tool_settings = context.tool_settings
+ sculpt = tool_settings.sculpt
+ settings = self.paint_settings(context)
+ brush = settings.brush
+
+ col = layout.column()
+ col.label(text="Local Brush Settings")
+
+ row = col.row()
+ row.prop(brush.dyntopo, "disabled", text="Disable Dyntopo")
+
+ col.label(text="Overrides")
+ inherit_all = "ALL" in brush.dyntopo.inherit
+
+ col.prop_enum(brush.dyntopo, "inherit", value="ALL", text="Use All Defaults", icon="LOCKED" if inherit_all else "UNLOCKED")
+
+
+ def do_prop(key):
+ row = col.row()
+ if key.upper() in brush.dyntopo.inherit:
+ icon = "UNLOCKED"
+ else:
+ icon = "LOCKED"
+
+ row.prop_enum(brush.dyntopo, "inherit", value=key.upper(), icon=icon, text="")
+
+ row2 = row.row()
+ row2.prop(brush.dyntopo, key)
+
+ if icon == "UNLOCKED":
+ row2.enabled = False
+
+ if inherit_all:
+ row.enabled = False
+
+ col = layout.column()
+ do_prop("subdivide")
+ do_prop("collapse")
++ do_prop("cleanup")
+ do_prop("spacing")
+ do_prop("detail_range")
+ do_prop("detail_percent")
+ do_prop("constant_detail")
+ do_prop("mode")
+
# TODO, move to space_view3d.py
class VIEW3D_PT_sculpt_dyntopo(Panel, View3DPaintPanel):
bl_context = ".sculpt_mode" # dot on purpose (access from topbar)
@@@ -870,10 -806,7 +871,11 @@@
if sculpt.detail_type_method in {'CONSTANT', 'MANUAL'}:
col.operator("sculpt.detail_flood_fill")
++ col.prop(sculpt, "use_dyntopo_cleanup")
col.prop(sculpt, "use_smooth_shading")
+ col.prop(sculpt, "use_flat_vcol_shading")
+
+ col.prop(sculpt, "dyntopo_spacing")
class VIEW3D_PT_sculpt_voxel_remesh(Panel, View3DPaintPanel):
diff --cc source/blender/blenkernel/BKE_pbvh.h
index 045d8b5db53,0fa44067b16..0e0ab799fe6
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@@ -355,6 -243,6 +355,7 @@@ void BKE_pbvh_bmesh_detail_size_set(PBV
typedef enum {
PBVH_Subdivide = 1,
PBVH_Collapse = 2,
++ PBVH_Cleanup = 4, //dissolve verts surrounded by either 3 or 4 triangles then triangulate
} PBVHTopologyUpdateMode;
bool BKE_pbvh_bmesh_update_topology(PBVH *pbvh,
PBVHTopologyUpdateMode mode,
diff --cc source/blender/blenkernel/intern/brush.c
index 6ab546fff68,ef567044282..b63e881a21c
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@@ -2589,82 -2542,3 +2589,91 @@@ struct ImBuf *BKE_brush_gen_radial_cont
return im;
}
+
+void BKE_brush_get_dyntopo(Brush *brush, Sculpt *sd, DynTopoSettings *out)
+{
+ *out = brush->dyntopo;
+
+ // detect unconverted file data
+ if (!out->inherit && !out->detail_range) {
+ //reload default dyntopo settings
+ Brush brush2 = *brush;
+
+ //don't copy heap allocd data
+ brush2.curve = NULL;
+ brush2.icon_imbuf = NULL;
+ brush2.gpencil_settings = NULL;
+ brush2.gradient = NULL;
+ brush2.preview = NULL;
+
+ BKE_brush_sculpt_reset(&brush2);
+
+ brush->dyntopo = *out = brush2.dyntopo;
+
+ brush_free_data((ID*)&brush2);
+ }
+
+ int inherit = out->inherit;
+
+ if (inherit & DYNTOPO_INHERIT_ALL) {
+ inherit = 0x7FFFFFF;
+ }
+
+ if (inherit & DYNTOPO_INHERIT_MODE) {
+ if (sd->flags & SCULPT_DYNTOPO_DETAIL_CONSTANT) {
+ out->mode = DYNTOPO_DETAIL_CONSTANT;
+ }
+ else if (sd->flags & SCULPT_DYNTOPO_DETAIL_BRUSH) {
+ out->mode = DYNTOPO_DETAIL_BRUSH;
+ }
+ else if (sd->flags & SCULPT_DYNTOPO_DETAIL_MANUAL) {
+ out->mode = DYNTOPO_DETAIL_MANUAL;
+ }
+ else {
+ out->mode = DYNTOPO_DETAIL_RELATIVE;
+ }
+ }
+
+ if (inherit & DYNTOPO_INHERIT_DETAIL_RANGE) {
+ out->detail_range = sd->detail_range;
+ }
+
+ if (inherit & DYNTOPO_INHERIT_DETAIL_PERCENT) {
+ out->detail_percent = sd->detail_percent;
+ }
+
+ if (inherit & DYNTOPO_INHERIT_SPACING) {
+ out->spacing = sd->dyntopo_spacing;
+ }
+
+ if (inherit & DYNTOPO_INHERIT_CONSTANT_DETAIL) {
+ out->constant_detail = sd->constant_detail;
+ }
+
+ if (inherit & DYNTOPO_SUBDIVIDE) {
+ if (sd->flags & SCULPT_DYNTOPO_SUBDIVIDE) {
+ out->flag |= DYNTOPO_SUBDIVIDE;
+ }
+ else {
+ out->flag &= ~DYNTOPO_SUBDIVIDE;
+ }
+ }
+
+ if (inherit & DYNTOPO_COLLAPSE) {
+ if (sd->flags & SCULPT_DYNTOPO_COLLAPSE) {
+ out->flag |= DYNTOPO_COLLAPSE;
+ }
+ else {
+ out->flag &= ~DYNTOPO_COLLAPSE;
+ }
+ }
++
++ if (inherit & DYNTOPO_CLEANUP) {
++ if (sd->flags & SCULPT_DYNTOPO_CLEANUP) {
++ out->flag |= DYNTOPO_CLEANUP;
++ }
++ else {
++ out->flag &= ~DYNTOPO_CLEANUP;
++ }
++ }
+};
diff --cc source/blender/blenkernel/intern/pbvh_bmesh.c
index f7581db5fd8,09e4ad93baa..55995d0187e
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@@ -641,10 -524,10 +641,18 @@@ static BMFace *pbvh_bmesh_face_create
/* ensure we never add existing face */
BLI_assert(!BM_face_exists(v_tri, 3));
-- BMFace *f = BM_face_create(pbvh->bm, v_tri, e_tri, 3, f_example, BM_CREATE_NOP);
++ BMFace *f;
++
++ if (!e_tri) {
++ f = BM_face_create_verts(pbvh->bm, v_tri, 3, f_example, BM_CREATE_NOP, true);
++ }
++ else {
++ f = BM_face_create(pbvh->bm, v_tri, e_tri, 3, f_example, BM_CREATE_NOP);
++ }
++
f->head.hflag = f_example->head.hflag;
- BLI_gset_insert(node->bm_faces, f);
+ BLI_table_gset_insert(node->bm_faces, f);
BM_ELEM_CD_SET_INT(f, pbvh->cd_face_node_offset, node_index);
/* mark node for update */
@@@ -2294,51 -1329,7 +2302,66 @@@ static void pbvh_bmesh_collapse_edge(PB
* really buy anything. */
BLI_buffer_clear(deleted_faces);
- #define MAX_LS 24
++#define MAX_LS 64
+
BMLoop *l;
+ BMLoop *ls[MAX_LS];
+
+ int totl = 0;
+
+ BM_LOOPS_OF_VERT_ITER_BEGIN (l, v_del) {
+ if (totl >= MAX_LS) {
+ break;
+ }
+ ls[totl++] = l;
+ }
+ BM_LOOPS_OF_VERT_ITER_END;
+
+ BM_LOOPS_OF_VERT_ITER_BEGIN (l, v_conn) {
+ if (totl >= MAX_LS) {
+ break;
+ }
+ ls[totl++] = l;
+ }
+ BM_LOOPS_OF_VERT_ITER_END;
+
+ void *blocks[MAX_LS];
- float ws[MAX_LS], w = totl > 1 ? 1.0f / (float)(totl - 1) : 1.0f;
++ float ws[MAX_LS], w = totl > 0 ? 1.0f / (float)(totl) : 1.0f;
+
- for (int i = 0; i < totl - 1; i++) {
- blocks[i] = ls[i + 1]->head.data;
++ for (int i = 0; i < totl; i++) {
++ blocks[i] = ls[i]->head.data;
+ ws[i] = w;
+ }
+
- if (totl > 1) {
- CustomData_bmesh_interp(&pbvh->bm->ldata, blocks, ws, NULL, totl - 1, ls[0]->head.data);
-
++ //snap customdata
++ if (totl > 0) {
++ CustomData_bmesh_interp(&pbvh->bm->ldata, blocks, ws, NULL, totl, ls[0]->head.data);
++ //*
+ BM_LOOPS_OF_VERT_ITER_BEGIN (l, v_del) {
++ BMLoop *l2 = l->v != v_del ? l->next : l;
++
++ if (l2 == ls[0]) {
++ continue;
++ }
++
+ CustomData_bmesh_copy_data(
- &pbvh->bm->ldata, &pbvh->bm->ldata, ls[0]->head.data, &l->head.data);
++ &pbvh->bm->ldata, &pbvh->bm->ldata, ls[0]->head.data, &l2->head.data);
+ }
+ BM_LOOPS_OF_VERT_ITER_END;
++
+ BM_LOOPS_OF_VERT_ITER_BEGIN (l, v_conn) {
++ BMLoop *l2 = l->v != v_conn ? l->next : l;
++
++ if (l2 == ls[0]) {
++ continue;
++ }
++
+ CustomData_bmesh_copy_data(
- &pbvh->bm->ldata, &pbvh->bm->ldata, ls[0]->head.data, &l->head.data);
++ &pbvh->bm->ldata, &pbvh->bm->ldata, ls[0]->head.data, &l2->head.data);
+ }
+ BM_LOOPS_OF_VERT_ITER_END;
++ //*/
+ }
BM_LOOPS_OF_VERT_ITER_BEGIN (l, v_del) {
BMFace *existing_face;
@@@ -2453,12 -1430,7 +2476,10 @@@
/* Move v_conn to the midpoint of v_conn and v_del (if v_conn still exists, it
* may have been deleted above) */
if (v_conn != NULL) {
- BM_log_vert_before_modified(pbvh->bm_log, v_conn, eq_ctx->cd_vert_mask_offset);
+ // log vert in bmlog, but don't update original customata layers, we want them to be
+ // interpolated
+ BM_log_vert_before_modified(pbvh->bm_log, v_conn, eq_ctx->cd_vert_mask_offset, true);
- // void *dummy;
- // BKE_pbvh_bmesh_update_origvert(pbvh, v_conn, &dummy, &dummy, &dummy);
+
mid_v3_v3v3(v_conn->co, v_conn->co, v_del->co);
add_v3_v3(v_conn->no, v_del->no);
normalize_v3(v_conn->no);
@@@ -3094,7 -1869,7 +3115,7 @@@ static void pbvh_bmesh_create_nodes_fas
BKE_pbvh_node_mark_rebuild_draw(n);
BKE_pbvh_node_fully_hidden_set(n, !has_visible);
- n->flag |= PBVH_UpdateNormals|PBVH_UpdateCurvatureDir;
- n->flag |= PBVH_UpdateNormals;
++ n->flag |= PBVH_UpdateNormals | PBVH_UpdateCurvatureDir;
}
}
@@@ -3207,53 -1953,6 +3228,198 @@@ void BKE_pbvh_build_bmesh(PBVH *pbvh
MEM_freeN(nodeinfo);
}
+static double last_updat
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list