Commit: 06e8cc0256541ae33d22edc7290bc7842f87271c Author: Joseph Eagar Date: Tue Sep 28 23:14:27 2021 -0700 Branches: sculpt-dev https://developer.blender.org/rB06e8cc0256541ae33d22edc7290bc7842f87271c
Sculpt-dev: Improve autosmooth performance * PBVH_FACES now uses MDynTopoVert (have got to rename it) to store boundary/corner/visibility flags the same way PBVH_BMESH does. * Fixed brush add/sub buttons in header not working * Fixed inverted brushes feeding negative strength to sub commands (like autosmooth, which flips it to sharpen mode). =================================================================== M extern/rangetree/intern/range_tree.c M release/scripts/startup/bl_ui/properties_paint_common.py M release/scripts/startup/bl_ui/space_view3d.py M source/blender/blenkernel/BKE_paint.h M source/blender/blenkernel/BKE_pbvh.h M source/blender/blenkernel/intern/brush_channel_define.h M source/blender/blenkernel/intern/brush_engine.c M source/blender/blenkernel/intern/brush_engine_presets.c M source/blender/blenkernel/intern/paint.c M source/blender/blenkernel/intern/pbvh.c M source/blender/blenkernel/intern/pbvh_intern.h M source/blender/bmesh/intern/bmesh_construct.c M source/blender/bmesh/intern/bmesh_mesh.h M source/blender/editors/sculpt_paint/sculpt.c M source/blender/editors/sculpt_paint/sculpt_array.c M source/blender/editors/sculpt_paint/sculpt_cloth.c =================================================================== diff --git a/extern/rangetree/intern/range_tree.c b/extern/rangetree/intern/range_tree.c index 87bae433101..77496e32fa3 100644 --- a/extern/rangetree/intern/range_tree.c +++ b/extern/rangetree/intern/range_tree.c @@ -794,7 +794,6 @@ void range_tree_uint_take(RangeTreeUInt *rt, const uint value) range_tree_uint_take_impl(rt, value, node); } -#pragma optimize("", off) bool range_tree_uint_retake(RangeTreeUInt *rt, const uint value) { Node *node = rt_find_node_from_value(rt, value); diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py index df1dbd5b655..d6c2c7cff3c 100644 --- a/release/scripts/startup/bl_ui/properties_paint_common.py +++ b/release/scripts/startup/bl_ui/properties_paint_common.py @@ -300,6 +300,15 @@ class UnifiedPaintPanel: itemicon = "CHECKBOX_DEHLT" row3.prop_enum(finalch, typeprop, item.identifier, icon=itemicon) + elif header and ch.idname == "direction": + row2 = row.row(align=True) + row2.use_property_split = False + row2.use_property_decorate = False + + #replicate pre-existing functionality of direction showing up as +/- in the header + row2.prop_enum(finalch, typeprop, "ADD", text="") + row2.prop_enum(finalch, typeprop, "SUBTRACT", text="") + pass elif expand is not None: row.prop(finalch, typeprop, icon=icon, text=text, slider=slider, expand=expand) else: diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index c13cd0d66f7..e05b6478462 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -274,7 +274,19 @@ class _draw_tool_settings_context_mode: # direction if not capabilities.has_direction: - layout.row().prop(brush, "direction", expand=True, text="") + row = layout.row() + + UnifiedPaintPanel.prop_unified( + layout, + context, + brush, + "direction", + pressure_name=pressure_name, + unified_name="use_unified_strength", + text="", + header=True, + expand=True + ) if capabilities.has_color: UnifiedPaintPanel.prop_unified_color(layout, context, brush, "color", text="") diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index bc35fd30094..63d0357de49 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -538,7 +538,7 @@ typedef struct SculptArray { int *symmetry_pass; float *smooth_strength; - + struct SculptCustomLayer *scl_inst, *scl_sym; } SculptArray; typedef struct SculptFakeNeighbors { diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h index dd6d5bf1bda..6db155e03f1 100644 --- a/source/blender/blenkernel/BKE_pbvh.h +++ b/source/blender/blenkernel/BKE_pbvh.h @@ -110,6 +110,7 @@ struct BMVert; struct BMEdge; struct BMFace; struct CCGElem; +struct MeshElemMap; struct CCGKey; struct CustomData; struct TableGSet; @@ -913,6 +914,15 @@ typedef struct SculptLayerEntry { int BKE_pbvh_do_fset_symmetry(int fset, const int symflag, const float *co); bool BKE_pbvh_check_vert_boundary(PBVH *pbvh, struct BMVert *v); +void BKE_pbvh_update_vert_boundary_faces(int *face_sets, + struct MVert *mvert, + struct MEdge *medge, + struct MLoop *mloop, + struct MPoly *mpoly, + struct MDynTopoVert *mdyntopo_verts, + struct MeshElemMap *pmap, + SculptVertRef vertex); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/intern/brush_channel_define.h b/source/blender/blenkernel/intern/brush_channel_define.h index c89c63e1b03..effdcb957b5 100644 --- a/source/blender/blenkernel/intern/brush_channel_define.h +++ b/source/blender/blenkernel/intern/brush_channel_define.h @@ -441,6 +441,7 @@ MAKE_ENUM(elastic_deform_type, "Deformation", "Deformation type that is used in {BRUSH_ELASTIC_DEFORM_TWIST, "TWIST", "NONE", "Twist", ""}, {-1} }) +MAKE_BOOL(use_ctrl_invert, "Use Ctrl Invert", "Take brush addition or subtraction mode into account", true) //MAKE_FLOAT3_EX /* clang-format on */ diff --git a/source/blender/blenkernel/intern/brush_engine.c b/source/blender/blenkernel/intern/brush_engine.c index f0f8065f801..3e4974b3427 100644 --- a/source/blender/blenkernel/intern/brush_engine.c +++ b/source/blender/blenkernel/intern/brush_engine.c @@ -1397,6 +1397,9 @@ BrushCommand *BKE_brush_command_init(BrushCommand *command, int tool) #define float_set_uninherit(chset, channel, val) \ _float_set_uninherit(chset, MAKE_BUILTIN_CH_NAME(channel), val) +#define int_set_uninherit(chset, channel, val) \ + _int_set_uninherit(chset, MAKE_BUILTIN_CH_NAME(channel), val) + static void _float_set_uninherit(BrushChannelSet *chset, const char *channel, float val) { BrushChannel *ch = BKE_brush_channelset_lookup(chset, channel); @@ -1410,6 +1413,19 @@ static void _float_set_uninherit(BrushChannelSet *chset, const char *channel, fl ch->flag &= ~BRUSH_CHANNEL_INHERIT; } +static void _int_set_uninherit(BrushChannelSet *chset, const char *channel, int val) +{ + BrushChannel *ch = BKE_brush_channelset_lookup(chset, channel); + + if (!ch) { + printf("%s: unknown channel %s\n", __func__, channel); + return; + } + + ch->ivalue = val; + ch->flag &= ~BRUSH_CHANNEL_INHERIT; +} + /*flag all mappings to use inherited curves even if owning channel is not set to inherit.*/ void BKE_brush_commandset_inherit_all_mappings(BrushChannelSet *chset) @@ -1463,6 +1479,7 @@ static void bke_builtin_commandlist_create_paint(Brush *brush, ch->flag |= BRUSH_CHANNEL_INHERIT; } + int_set_uninherit(cmd->params, use_ctrl_invert, false); float_set_uninherit(cmd->params, strength, autosmooth); float_set_uninherit(cmd->params, radius, radius * autosmooth_scale); float_set_uninherit(cmd->params, projection, autosmooth_projection); @@ -1580,6 +1597,7 @@ void BKE_builtin_commandlist_create(Brush *brush, ch->flag |= BRUSH_CHANNEL_INHERIT; } + int_set_uninherit(cmd->params, use_ctrl_invert, false); float_set_uninherit(cmd->params, strength, autosmooth); float_set_uninherit(cmd->params, radius, radius * autosmooth_scale); float_set_uninherit(cmd->params, projection, autosmooth_projection); @@ -1620,6 +1638,7 @@ void BKE_builtin_commandlist_create(Brush *brush, ch->flag |= BRUSH_CHANNEL_INHERIT; } + int_set_uninherit(cmd->params, use_ctrl_invert, false); float_set_uninherit(cmd->params, strength, topology_rake); float_set_uninherit(cmd->params, radius, radius * topology_rake_scale); float_set_uninherit(cmd->params, projection, topology_rake_projection); @@ -1637,6 +1656,7 @@ void BKE_builtin_commandlist_create(Brush *brush, radius2 *= radius; + int_set_uninherit(cmd->params, use_ctrl_invert, false); float_set_uninherit(cmd->params, spacing, spacing); float_set_uninherit(cmd->params, radius, radius2); } diff --git a/source/blender/blenkernel/intern/brush_engine_presets.c b/source/blender/blenkernel/intern/brush_engine_presets.c index d26b179c46c..418f340dd7e 100644 --- a/source/blender/blenkernel/intern/brush_engine_presets.c +++ b/source/blender/blenkernel/intern/brush_engine_presets.c @@ -807,6 +807,7 @@ void BKE_brush_builtin_patch(Brush *brush, int tool) ADDCH(radius_unit); ADDCH(unprojected_radius); + ADDCH(use_ctrl_invert); ADDCH(tilt_strength_factor); ADDCH(autosmooth); diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index fb5db35b339..61e83f4d090 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -2203,6 +2203,7 @@ static PBVH *build_pbvh_for_dynamic_topology(Object *ob) static PBVH *build_pbvh_from_regular_mesh(Object *ob, Mesh *me_eval_deform, bool respect_hide) { + SculptSession *ss = ob->sculpt; Mesh *me = BKE_object_get_original_mesh(ob); const int looptris_num = poly_to_tri_count(me->totpoly, me->totloop); PBVH *pbvh = BKE_pbvh_new(); @@ -2214,6 +2215,19 @@ static PBVH *build_pbvh_from_regular_mesh(Object *ob, Mesh *me_eval_deform, bool BKE_sculpt_sync_face_set_visibility(me, NULL); + if (!ss->pmap) { + BKE_mesh_vert_poly_map_create(&ss->pmap, + &ss->pmap_mem, + me->mvert, + me->medge, + me->mpoly, + me->mloop, + me->totvert, + me->totpoly, + me->totloop, + false); + } + BKE_sculptsession_check_mdyntopo(ob->sculpt, me->totvert); BKE_pbvh_build_mesh(pbvh, @@ -2294,6 +2308,16 @@ static void init_mdyntopo_layer(SculptSession *ss, int totvert) for (int i = 0; i < totvert; i++, mv++) { mv->flag = DYNVERT_NEED_BOUNDARY | DYNVERT_NEED_VALENCE | DYNVERT_NEED_DISK_SORT; mv->stroke_id = -1; + + SculptVertRef vertex = {.i = i}; + BKE_pbvh_update_vert_boundary_faces(ss->face_sets, + ss->mvert, + ss->medge, + ss->mloop, + ss->mpoly, + ss->mdyntopo_verts, + ss->pmap, + vertex); } } PBVH *BKE_sculpt_object_pbvh_ensure(Depsgraph *depsgraph, Object *ob) diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blen @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs