Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2019-05-31 13:50:15 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-05-31 18:17:03 +0300
commit151f69a5c214691de0665affcd8a49cecd6dd0aa (patch)
tree9ae399a893921e8ba0829657f211d9540e1332e2 /source/blender/editors/sculpt_paint
parent692891f69ea42af0ba890f5f92cbd1a3260442c9 (diff)
Fix various missing updates in sculpt mode, when changing modifiers and dyntopo
This restores the code that updates the sculpt session and PBVH from dependency graph evaluation.
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r--source/blender/editors/sculpt_paint/paint_mask.c9
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c10
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c44
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_intern.h12
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c7
5 files changed, 29 insertions, 53 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c
index 79d09967b75..0dd2e8ee968 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -129,7 +129,6 @@ static void mask_flood_fill_task_cb(void *__restrict userdata,
static int mask_flood_fill_exec(bContext *C, wmOperator *op)
{
ARegion *ar = CTX_wm_region(C);
- struct Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
PaintMaskFloodMode mode;
@@ -143,7 +142,7 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op)
mode = RNA_enum_get(op->ptr, "mode");
value = RNA_float_get(op->ptr, "value");
- BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, false, true);
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, false, true);
pbvh = ob->sculpt->pbvh;
multires = (BKE_pbvh_type(pbvh) == PBVH_GRIDS);
@@ -284,7 +283,6 @@ bool ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti *
float clip_planes[4][4];
float clip_planes_final[4][4];
ARegion *ar = vc->ar;
- struct Scene *scene = vc->scene;
Object *ob = vc->obact;
PaintMaskFloodMode mode;
float value;
@@ -301,7 +299,7 @@ bool ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti *
ED_view3d_clipping_calc(&bb, clip_planes, vc->ar, vc->obact, rect);
negate_m4(clip_planes);
- BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, false, true);
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, false, true);
pbvh = ob->sculpt->pbvh;
multires = (BKE_pbvh_type(pbvh) == PBVH_GRIDS);
@@ -452,7 +450,6 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op)
Object *ob;
ViewContext vc;
LassoMaskData data;
- struct Scene *scene = CTX_data_scene(C);
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
int symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL;
PBVH *pbvh;
@@ -488,7 +485,7 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op)
ED_view3d_clipping_calc(&bb, clip_planes, vc.ar, vc.obact, &data.rect);
negate_m4(clip_planes);
- BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, false, true);
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, false, true);
pbvh = ob->sculpt->pbvh;
multires = (BKE_pbvh_type(pbvh) == PBVH_GRIDS);
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index f9db589405e..bdb8ccb09a4 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -1014,12 +1014,12 @@ static void vertex_paint_init_session(Depsgraph *depsgraph,
BLI_assert(ob->sculpt == NULL);
ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session");
ob->sculpt->mode_type = object_mode;
- BKE_sculpt_update_mesh_elements(depsgraph, scene, scene->toolsettings->sculpt, ob, false, false);
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, false, false);
}
-static void vertex_paint_init_stroke(Depsgraph *depsgraph, Scene *scene, Object *ob)
+static void vertex_paint_init_stroke(Depsgraph *depsgraph, Object *ob)
{
- BKE_sculpt_update_mesh_elements(depsgraph, scene, scene->toolsettings->sculpt, ob, false, false);
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, false, false);
}
static void vertex_paint_init_session_data(const ToolSettings *ts, Object *ob)
@@ -1619,7 +1619,7 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float mo
}
/* If not previously created, create vertex/weight paint mode session data */
- vertex_paint_init_stroke(depsgraph, scene, ob);
+ vertex_paint_init_stroke(depsgraph, ob);
vwpaint_update_cache_invariants(C, vp, ss, op, mouse);
vertex_paint_init_session_data(ts, ob);
@@ -2646,7 +2646,7 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f
}
/* If not previously created, create vertex/weight paint mode session data */
- vertex_paint_init_stroke(depsgraph, scene, ob);
+ vertex_paint_init_stroke(depsgraph, ob);
vwpaint_update_cache_invariants(C, vp, ss, op, mouse);
vertex_paint_init_session_data(ts, ob);
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 7b8461f5011..2855e3181c0 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -4920,10 +4920,8 @@ static void sculpt_stroke_modifiers_check(const bContext *C, Object *ob, const B
if (ss->kb || ss->modifiers_active) {
Depsgraph *depsgraph = CTX_data_depsgraph(C);
- Scene *scene = CTX_data_scene(C);
- Sculpt *sd = scene->toolsettings->sculpt;
bool need_pmap = sculpt_any_smooth_mode(brush, ss->cache, 0);
- BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, need_pmap, false);
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, need_pmap, false);
}
}
@@ -5152,7 +5150,7 @@ static void sculpt_brush_stroke_init(bContext *C, wmOperator *op)
sculpt_brush_init_tex(scene, sd, ss);
is_smooth = sculpt_any_smooth_mode(brush, NULL, mode);
- BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, is_smooth, need_mask);
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, is_smooth, need_mask);
}
static void sculpt_restore_mesh(Sculpt *sd, Object *ob)
@@ -5622,16 +5620,10 @@ void sculpt_dyntopo_node_layers_add(SculptSession *ss)
ss->bm->pdata.layers[cd_node_layer_index].flag |= CD_FLAG_TEMPORARY;
}
-void sculpt_update_after_dynamic_topology_toggle(Depsgraph *depsgraph, Scene *scene, Object *ob)
-{
- Sculpt *sd = scene->toolsettings->sculpt;
-
- /* Create the PBVH */
- BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, false, false);
- WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob);
-}
-
-void sculpt_dynamic_topology_enable_ex(Depsgraph *depsgraph, Scene *scene, Object *ob)
+static void sculpt_dynamic_topology_enable_ex(Main *bmain,
+ Depsgraph *depsgraph,
+ Scene *scene,
+ Object *ob)
{
SculptSession *ss = ob->sculpt;
Mesh *me = ob->data;
@@ -5672,15 +5664,17 @@ void sculpt_dynamic_topology_enable_ex(Depsgraph *depsgraph, Scene *scene, Objec
/* Enable logging for undo/redo */
ss->bm_log = BM_log_create(ss->bm);
- /* Refresh */
- sculpt_update_after_dynamic_topology_toggle(depsgraph, scene, ob);
+ /* Update dependency graph, so modifiers that depend on dyntopo being enabled
+ * are re-evaluated and the PBVH is re-created */
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+ BKE_scene_graph_update_tagged(depsgraph, bmain);
}
/* Free the sculpt BMesh and BMLog
*
* If 'unode' is given, the BMesh's data is copied out to the unode
* before the BMesh is deleted so that it can be restored from */
-void sculpt_dynamic_topology_disable_ex(
+static void sculpt_dynamic_topology_disable_ex(
Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob, SculptUndoNode *unode)
{
SculptSession *ss = ob->sculpt;
@@ -5745,11 +5739,10 @@ void sculpt_dynamic_topology_disable_ex(
BKE_particlesystem_reset_all(ob);
BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_OUTDATED);
+ /* Update dependency graph, so modifiers that depend on dyntopo being enabled
+ * are re-evaluated and the PBVH is re-created */
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
BKE_scene_graph_update_tagged(depsgraph, bmain);
-
- /* Refresh */
- sculpt_update_after_dynamic_topology_toggle(depsgraph, scene, ob);
}
void sculpt_dynamic_topology_disable(bContext *C, SculptUndoNode *unode)
@@ -5775,14 +5768,15 @@ static void sculpt_dynamic_topology_disable_with_undo(Main *bmain,
}
}
-static void sculpt_dynamic_topology_enable_with_undo(Depsgraph *depsgraph,
+static void sculpt_dynamic_topology_enable_with_undo(Main *bmain,
+ Depsgraph *depsgraph,
Scene *scene,
Object *ob)
{
SculptSession *ss = ob->sculpt;
if (ss->bm == NULL) {
sculpt_undo_push_begin("Dynamic topology enable");
- sculpt_dynamic_topology_enable_ex(depsgraph, scene, ob);
+ sculpt_dynamic_topology_enable_ex(bmain, depsgraph, scene, ob);
sculpt_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_BEGIN);
sculpt_undo_push_end();
}
@@ -5802,7 +5796,7 @@ static int sculpt_dynamic_topology_toggle_exec(bContext *C, wmOperator *UNUSED(o
sculpt_dynamic_topology_disable_with_undo(bmain, depsgraph, scene, ob);
}
else {
- sculpt_dynamic_topology_enable_with_undo(depsgraph, scene, ob);
+ sculpt_dynamic_topology_enable_with_undo(bmain, depsgraph, scene, ob);
}
WM_cursor_wait(0);
@@ -6027,7 +6021,7 @@ static void sculpt_init_session(Depsgraph *depsgraph, Scene *scene, Object *ob)
ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session");
ob->sculpt->mode_type = OB_MODE_SCULPT;
- BKE_sculpt_update_mesh_elements(depsgraph, scene, scene->toolsettings->sculpt, ob, false, false);
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, false, false);
}
static int ed_object_sculptmode_flush_recalc_flag(Scene *scene,
@@ -6136,7 +6130,7 @@ void ED_object_sculptmode_enter_ex(Main *bmain,
if (has_undo) {
sculpt_undo_push_begin("Dynamic topology enable");
}
- sculpt_dynamic_topology_enable_ex(depsgraph, scene, ob);
+ sculpt_dynamic_topology_enable_ex(bmain, depsgraph, scene, ob);
if (has_undo) {
sculpt_undo_push_node(ob, NULL, SCULPT_UNDO_DYNTOPO_BEGIN);
sculpt_undo_push_end();
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index b29ca1b4dd7..4287feed92c 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -52,18 +52,6 @@ bool sculpt_stroke_get_location(struct bContext *C, float out[3], const float mo
/* Dynamic topology */
void sculpt_pbvh_clear(Object *ob);
void sculpt_dyntopo_node_layers_add(struct SculptSession *ss);
-void sculpt_update_after_dynamic_topology_toggle(struct Depsgraph *depsgraph,
- struct Scene *scene,
- struct Object *ob);
-void sculpt_dynamic_topology_enable_ex(struct Depsgraph *depsgraph,
- struct Scene *scene,
- struct Object *ob);
-
-void sculpt_dynamic_topology_disable_ex(struct Main *bmain,
- struct Depsgraph *depsgraph,
- struct Scene *scene,
- struct Object *ob,
- struct SculptUndoNode *unode);
void sculpt_dynamic_topology_disable(bContext *C, struct SculptUndoNode *unode);
/* Undo */
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index 965f31cbb6b..3c26a0e2541 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -129,8 +129,6 @@ static bool sculpt_undo_restore_deformed(
static bool sculpt_undo_restore_coords(bContext *C, SculptUndoNode *unode)
{
- Scene *scene = CTX_data_scene(C);
- Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = OBACT(view_layer);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
@@ -151,7 +149,7 @@ static bool sculpt_undo_restore_coords(bContext *C, SculptUndoNode *unode)
if (kb) {
ob->shapenr = BLI_findindex(&key->block, kb) + 1;
- BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, false, false);
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, false, false);
WM_event_add_notifier(C, NC_OBJECT | ND_DATA, ob);
}
else {
@@ -460,7 +458,6 @@ static int sculpt_undo_bmesh_restore(bContext *C,
static void sculpt_undo_restore_list(bContext *C, ListBase *lb)
{
Scene *scene = CTX_data_scene(C);
- Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = OBACT(view_layer);
Depsgraph *depsgraph = CTX_data_depsgraph(C);
@@ -484,7 +481,7 @@ static void sculpt_undo_restore_list(bContext *C, ListBase *lb)
DEG_id_tag_update(&ob->id, ID_RECALC_SHADING);
- BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, false, need_mask);
+ BKE_sculpt_update_object_for_edit(depsgraph, ob, false, need_mask);
if (lb->first && sculpt_undo_bmesh_restore(C, lb->first, ob, ss)) {
return;