diff options
Diffstat (limited to 'source/blender/editors/sculpt_paint')
14 files changed, 181 insertions, 250 deletions
diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt index 23617e687ea..2a8ff9d4f78 100644 --- a/source/blender/editors/sculpt_paint/CMakeLists.txt +++ b/source/blender/editors/sculpt_paint/CMakeLists.txt @@ -29,6 +29,7 @@ set(INC ../../makesrna ../../render/extern/include ../../windowmanager + ../../../../intern/atomic ../../../../intern/glew-mx ../../../../intern/guardedalloc ) diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index ac74afce79e..576baf5794b 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -148,7 +148,7 @@ typedef struct LoadTexData { static void load_tex_task_cb_ex(void *__restrict userdata, const int j, - const ParallelRangeTLS *__restrict tls) + const TaskParallelTLS *__restrict tls) { LoadTexData *data = userdata; Brush *br = data->br; @@ -328,7 +328,7 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima .radius = radius, }; - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); BLI_task_parallel_range(0, size, &data, load_tex_task_cb_ex, &settings); @@ -385,7 +385,7 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima static void load_tex_cursor_task_cb(void *__restrict userdata, const int j, - const ParallelRangeTLS *__restrict UNUSED(tls)) + const TaskParallelTLS *__restrict UNUSED(tls)) { LoadTexData *data = userdata; Brush *br = data->br; @@ -468,7 +468,7 @@ static int load_tex_cursor(Brush *br, ViewContext *vc, float zoom) .size = size, }; - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); BLI_task_parallel_range(0, size, &data, load_tex_cursor_task_cb, &settings); diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c index d7e1b47d973..5852012891d 100644 --- a/source/blender/editors/sculpt_paint/paint_hide.c +++ b/source/blender/editors/sculpt_paint/paint_hide.c @@ -339,7 +339,7 @@ static int hide_show_exec(bContext *C, wmOperator *op) { ARegion *ar = CTX_wm_region(C); Object *ob = CTX_data_active_object(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Mesh *me = ob->data; PartialVisAction action; PartialVisArea area; diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 41dfd6f68c3..f3a6cfa0d5c 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -1238,7 +1238,7 @@ void PAINT_OT_texture_paint_toggle(wmOperatorType *ot) ot->poll = texture_paint_toggle_poll; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int brush_colors_flip_exec(bContext *C, wmOperator *UNUSED(op)) @@ -1246,8 +1246,7 @@ static int brush_colors_flip_exec(bContext *C, wmOperator *UNUSED(op)) Scene *scene = CTX_data_scene(C); UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; - ViewLayer *view_layer = CTX_data_view_layer(C); - Paint *paint = BKE_paint_get_active(scene, view_layer); + Paint *paint = BKE_paint_get_active_from_context(C); Brush *br = BKE_paint_brush(paint); if (ups->flag & UNIFIED_PAINT_COLOR) { @@ -1256,6 +1255,10 @@ static int brush_colors_flip_exec(bContext *C, wmOperator *UNUSED(op)) else if (br) { swap_v3_v3(br->rgb, br->secondary_rgb); } + else { + return OPERATOR_CANCELLED; + } + WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, br); return OPERATOR_FINISHED; diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c index 474d3a8ceba..8f1156295a3 100644 --- a/source/blender/editors/sculpt_paint/paint_image_2d.c +++ b/source/blender/editors/sculpt_paint/paint_image_2d.c @@ -1251,7 +1251,7 @@ typedef struct Paint2DForeachData { static void paint_2d_op_foreach_do(void *__restrict data_v, const int iter, - const ParallelRangeTLS *__restrict UNUSED(tls)) + const TaskParallelTLS *__restrict UNUSED(tls)) { Paint2DForeachData *data = (Paint2DForeachData *)data_v; paint_2d_do_making_brush(data->s, @@ -1360,7 +1360,7 @@ static int paint_2d_op(void *state, data.tilex = tilex; data.tilew = tilew; - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); BLI_task_parallel_range(tiley, tileh + 1, &data, paint_2d_op_foreach_do, &settings); } diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 22de22e8e59..e5527e7210d 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -44,6 +44,8 @@ #include "BLI_threads.h" #include "BLI_utildefines.h" +#include "atomic_ops.h" + #include "BLT_translation.h" #include "IMB_imbuf.h" @@ -366,7 +368,7 @@ typedef struct ProjPaintState { int bucketMin[2]; int bucketMax[2]; /** must lock threads while accessing these. */ - int context_bucket_x, context_bucket_y; + int context_bucket_index; struct CurveMapping *cavity_curve; BlurKernel *blurkernel; @@ -1769,7 +1771,7 @@ static float project_paint_uvpixel_mask(const ProjPaintState *ps, } else if (angle_cos < ps->normal_angle_inner__cos) { mask *= (ps->normal_angle - acosf(angle_cos)) / ps->normal_angle_range; - } /* otherwise no mask normal is needed, were within the limit */ + } /* otherwise no mask normal is needed, we're within the limit */ } /* This only works when the opacity doesn't change while painting, stylus pressure messes with @@ -3157,7 +3159,7 @@ static void project_paint_face_init(const ProjPaintState *ps, //#endif } -#if 0 /* TODO - investigate why this dosnt work sometimes! it should! */ +#if 0 /* TODO - investigate why this doesn't work sometimes! it should! */ /* no intersection for this entire row, * after some intersection above means we can quit now */ if (has_x_isect == 0 && has_isect) { @@ -3213,7 +3215,7 @@ static void project_paint_face_init(const ProjPaintState *ps, * clipped by the bucket's screen aligned rectangle. */ float bucket_clip_edges[2][2]; float edge_verts_inset_clip[2][3]; - /* face edge pairs - loop throuh these: + /* face edge pairs - loop through these: * ((0,1), (1,2), (2,3), (3,0)) or ((0,1), (1,2), (2,0)) for a tri */ int fidx1, fidx2; @@ -3393,12 +3395,12 @@ static void project_paint_face_init(const ProjPaintState *ps, } else if (has_x_isect) { /* assuming the face is not a bow-tie - we know - * we cant intersect again on the X */ + * we can't intersect again on the X */ break; } } -# if 0 /* TODO - investigate why this dosnt work sometimes! it should! */ +# if 0 /* TODO - investigate why this doesn't work sometimes! it should! */ /* no intersection for this entire row, * after some intersection above means we can quit now */ if (has_x_isect == 0 && has_isect) { @@ -4010,7 +4012,7 @@ static void project_paint_bleed_add_face_user(const ProjPaintState *ps, /* Return true if evaluated mesh can be painted on, false otherwise */ static bool proj_paint_state_mesh_eval_init(const bContext *C, ProjPaintState *ps) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *ob = ps->ob; Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); @@ -4386,7 +4388,7 @@ static void project_paint_prepare_all_faces(ProjPaintState *ps, image_index = BLI_linklist_index(image_LinkList.list, tpage); if (image_index == -1 && BKE_image_has_ibuf(tpage, NULL)) { - /* MemArena dosnt have an append func */ + /* MemArena doesn't have an append func */ BLI_linklist_append(&image_LinkList, tpage); image_index = ps->image_tot; ps->image_tot++; @@ -4712,11 +4714,8 @@ static bool project_bucket_iter_init(ProjPaintState *ps, const float mval_f[2]) /* mouse outside the model areas? */ if (ps->bucketMin[0] == ps->bucketMax[0] || ps->bucketMin[1] == ps->bucketMax[1]) { - return 0; + return false; } - - ps->context_bucket_x = ps->bucketMin[0]; - ps->context_bucket_y = ps->bucketMin[1]; } else { /* reproject: PROJ_SRC_* */ ps->bucketMin[0] = 0; @@ -4724,11 +4723,10 @@ static bool project_bucket_iter_init(ProjPaintState *ps, const float mval_f[2]) ps->bucketMax[0] = ps->buckets_x; ps->bucketMax[1] = ps->buckets_y; - - ps->context_bucket_x = 0; - ps->context_bucket_y = 0; } - return 1; + + ps->context_bucket_index = ps->bucketMin[0] + ps->bucketMin[1] * ps->buckets_x; + return true; } static bool project_bucket_iter_next(ProjPaintState *ps, @@ -4738,37 +4736,28 @@ static bool project_bucket_iter_next(ProjPaintState *ps, { const int diameter = 2 * ps->brush_size; - if (ps->thread_tot > 1) { - BLI_thread_lock(LOCK_CUSTOM1); - } - - // printf("%d %d\n", ps->context_bucket_x, ps->context_bucket_y); + const int max_bucket_idx = ps->bucketMax[0] + (ps->bucketMax[1] - 1) * ps->buckets_x; - for (; ps->context_bucket_y < ps->bucketMax[1]; ps->context_bucket_y++) { - for (; ps->context_bucket_x < ps->bucketMax[0]; ps->context_bucket_x++) { + for (int bidx = atomic_fetch_and_add_int32(&ps->context_bucket_index, 1); bidx < max_bucket_idx; + bidx = atomic_fetch_and_add_int32(&ps->context_bucket_index, 1)) { + const int bucket_y = bidx / ps->buckets_x; + const int bucket_x = bidx - (bucket_y * ps->buckets_x); + BLI_assert(bucket_y >= ps->bucketMin[1] && bucket_y < ps->bucketMax[1]); + if (bucket_x >= ps->bucketMin[0] && bucket_x < ps->bucketMax[0]) { /* use bucket_bounds for project_bucket_isect_circle and project_bucket_init*/ - project_bucket_bounds(ps, ps->context_bucket_x, ps->context_bucket_y, bucket_bounds); + project_bucket_bounds(ps, bucket_x, bucket_y, bucket_bounds); if ((ps->source != PROJ_SRC_VIEW) || project_bucket_isect_circle(mval, (float)(diameter * diameter), bucket_bounds)) { - *bucket_index = ps->context_bucket_x + (ps->context_bucket_y * ps->buckets_x); - ps->context_bucket_x++; - - if (ps->thread_tot > 1) { - BLI_thread_unlock(LOCK_CUSTOM1); - } + *bucket_index = bidx; - return 1; + return true; } } - ps->context_bucket_x = ps->bucketMin[0]; } - if (ps->thread_tot > 1) { - BLI_thread_unlock(LOCK_CUSTOM1); - } - return 0; + return false; } /* Each thread gets one of these, also used as an argument to pass to project_paint_op */ @@ -5721,7 +5710,7 @@ void paint_proj_stroke(const bContext *C, /* clone gets special treatment here to avoid going through image initialization */ if (ps_handle->is_clone_cursor_pick) { Scene *scene = ps_handle->scene; - struct Depsgraph *depsgraph = CTX_data_depsgraph(C); + struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); View3D *v3d = CTX_wm_view3d(C); ARegion *ar = CTX_wm_region(C); float *cursor = scene->cursor.location; @@ -5733,6 +5722,7 @@ void paint_proj_stroke(const bContext *C, return; } + DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE); ED_region_tag_redraw(ar); return; @@ -5789,7 +5779,7 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps, int ps->rv3d = CTX_wm_region_view3d(C); ps->ar = CTX_wm_region(C); - ps->depsgraph = CTX_data_depsgraph(C); + ps->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ps->scene = scene; /* allow override of active object */ ps->ob = ob; @@ -6153,7 +6143,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) char filename[FILE_MAX]; Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); ToolSettings *settings = scene->toolsettings; int w = settings->imapaint.screen_grab_size[0]; @@ -6244,8 +6234,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) array += sizeof(rv3d->winmat) / sizeof(float); memcpy(array, rv3d->viewmat, sizeof(rv3d->viewmat)); array += sizeof(rv3d->viewmat) / sizeof(float); - is_ortho = ED_view3d_clip_range_get( - CTX_data_depsgraph(C), v3d, rv3d, &array[0], &array[1], true); + is_ortho = ED_view3d_clip_range_get(depsgraph, v3d, rv3d, &array[0], &array[1], true); /* using float for a bool is dodgy but since its an extra member in the array... * easier then adding a single bool prop */ array[2] = is_ortho ? 1.0f : 0.0f; diff --git a/source/blender/editors/sculpt_paint/paint_image_undo.c b/source/blender/editors/sculpt_paint/paint_image_undo.c index e7f100ebacb..2a1158ec804 100644 --- a/source/blender/editors/sculpt_paint/paint_image_undo.c +++ b/source/blender/editors/sculpt_paint/paint_image_undo.c @@ -69,7 +69,10 @@ typedef struct UndoImageTile { int x, y; - Image *ima; + /* TODO(campbell): avoid storing the ID per tile, + * adds unnecessary overhead restoring undo steps when most tiles share the same image. */ + UndoRefID_Image image_ref; + short source, use_float; char gen_type; bool valid; @@ -245,7 +248,7 @@ void *image_undo_push_tile(ListBase *undo_tiles, tile->source = ima->source; tile->use_float = use_float; tile->valid = true; - tile->ima = ima; + tile->image_ref.ptr = ima; if (valid) { *valid = &tile->valid; @@ -284,7 +287,7 @@ static void image_undo_restore_runtime(ListBase *lb) tmpibuf = IMB_allocImBuf(IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, 32, IB_rectfloat | IB_rect); for (tile = lb->first; tile; tile = tile->next) { - Image *ima = tile->ima; + Image *ima = tile->image_ref.ptr; ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); undo_copy_tile(tile, tmpibuf, ibuf, RESTORE); @@ -304,19 +307,15 @@ static void image_undo_restore_runtime(ListBase *lb) IMB_freeImBuf(tmpibuf); } -static void image_undo_restore_list(ListBase *lb, struct UndoIDPtrMap *id_map) +static void image_undo_restore_list(ListBase *lb) { ImBuf *tmpibuf = IMB_allocImBuf( IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, 32, IB_rectfloat | IB_rect); - /* Store last found image. */ - ID *image_prev[2] = {NULL}; - for (UndoImageTile *tile = lb->first; tile; tile = tile->next) { short use_float; - Image *ima = (Image *)BKE_undosys_ID_map_lookup_with_prev(id_map, &tile->ima->id, image_prev); - + Image *ima = tile->image_ref.ptr; ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); if (ima && ibuf && !STREQ(tile->ibufname, ibuf->name)) { @@ -398,33 +397,8 @@ typedef struct ImageUndoStep { ListBase tiles; bool is_encode_init; ePaintMode paint_mode; - - /* Use for all ID lookups (can be NULL). */ - struct UndoIDPtrMap *id_map; } ImageUndoStep; -static void image_undosys_step_encode_store_ids(ImageUndoStep *us) -{ - us->id_map = BKE_undosys_ID_map_create(); - - ID *image_prev = NULL; - for (UndoImageTile *tile = us->tiles.first; tile; tile = tile->next) { - BKE_undosys_ID_map_add_with_prev(us->id_map, &tile->ima->id, &image_prev); - } -} - -/* Restore at runtime. */ -#if 0 -static void paint_undosys_step_decode_restore_ids(ImageUndoStep *us) -{ - ID *image_prev[2] = {NULL}; - for (UndoImageTile *tile = us->tiles.first; tile; tile = tile->next) { - tile->ima = (Image *)BKE_undosys_ID_map_lookup_with_prev( - us->id_map, &tile->ima->id, image_prev); - } -} -#endif - static bool image_undosys_poll(bContext *C) { Object *obact = CTX_data_active_object(C); @@ -486,8 +460,6 @@ static bool image_undosys_step_encode(struct bContext *C, us->paint_mode = paint_mode; } - image_undosys_step_encode_store_ids(us); - us_p->is_applied = true; return true; @@ -496,18 +468,18 @@ static bool image_undosys_step_encode(struct bContext *C, static void image_undosys_step_decode_undo_impl(ImageUndoStep *us) { BLI_assert(us->step.is_applied == true); - image_undo_restore_list(&us->tiles, us->id_map); + image_undo_restore_list(&us->tiles); us->step.is_applied = false; } static void image_undosys_step_decode_redo_impl(ImageUndoStep *us) { BLI_assert(us->step.is_applied == false); - image_undo_restore_list(&us->tiles, us->id_map); + image_undo_restore_list(&us->tiles); us->step.is_applied = true; } -static void image_undosys_step_decode_undo(ImageUndoStep *us) +static void image_undosys_step_decode_undo(ImageUndoStep *us, bool is_final) { ImageUndoStep *us_iter = us; while (us_iter->step.next && (us_iter->step.next->type == us_iter->step.type)) { @@ -516,8 +488,11 @@ static void image_undosys_step_decode_undo(ImageUndoStep *us) } us_iter = (ImageUndoStep *)us_iter->step.next; } - while (us_iter != us) { + while (us_iter != us || (!is_final && us_iter == us)) { image_undosys_step_decode_undo_impl(us_iter); + if (us_iter == us) { + break; + } us_iter = (ImageUndoStep *)us_iter->step.prev; } } @@ -541,15 +516,11 @@ static void image_undosys_step_decode_redo(ImageUndoStep *us) } static void image_undosys_step_decode( - struct bContext *C, struct Main *bmain, UndoStep *us_p, int dir, bool UNUSED(is_final)) + struct bContext *C, struct Main *bmain, UndoStep *us_p, int dir, bool is_final) { ImageUndoStep *us = (ImageUndoStep *)us_p; -#if 0 - paint_undosys_step_decode_restore_ids(us); -#endif - if (dir < 0) { - image_undosys_step_decode_undo(us); + image_undosys_step_decode_undo(us, is_final); } else { image_undosys_step_decode_redo(us); @@ -567,7 +538,6 @@ static void image_undosys_step_free(UndoStep *us_p) { ImageUndoStep *us = (ImageUndoStep *)us_p; image_undo_free_list(&us->tiles); - BKE_undosys_ID_map_destroy(us->id_map); } static void image_undosys_foreach_ID_ref(UndoStep *us_p, @@ -575,8 +545,8 @@ static void image_undosys_foreach_ID_ref(UndoStep *us_p, void *user_data) { ImageUndoStep *us = (ImageUndoStep *)us_p; - if (us->id_map != NULL) { - BKE_undosys_ID_map_foreach_ID_ref(us->id_map, foreach_ID_ref_fn, user_data); + for (UndoImageTile *tile = us->tiles.first; tile; tile = tile->next) { + foreach_ID_ref_fn(user_data, ((UndoRefID *)&tile->image_ref)); } } diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c index f60ea8410ef..74212058fc7 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.c +++ b/source/blender/editors/sculpt_paint/paint_mask.c @@ -101,7 +101,7 @@ typedef struct MaskTaskData { static void mask_flood_fill_task_cb(void *__restrict userdata, const int i, - const ParallelRangeTLS *__restrict UNUSED(tls)) + const TaskParallelTLS *__restrict UNUSED(tls)) { MaskTaskData *data = userdata; @@ -130,7 +130,7 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op) { ARegion *ar = CTX_wm_region(C); Object *ob = CTX_data_active_object(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); PaintMaskFloodMode mode; float value; PBVH *pbvh; @@ -159,7 +159,7 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op) .value = value, }; - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); BLI_task_parallel_range( @@ -243,7 +243,7 @@ static void flip_plane(float out[4], const float in[4], const char symm) static void mask_box_select_task_cb(void *__restrict userdata, const int i, - const ParallelRangeTLS *__restrict UNUSED(tls)) + const TaskParallelTLS *__restrict UNUSED(tls)) { MaskTaskData *data = userdata; @@ -277,7 +277,7 @@ static void mask_box_select_task_cb(void *__restrict userdata, bool ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti *rect, bool select) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Sculpt *sd = vc->scene->toolsettings->sculpt; BoundBox bb; float clip_planes[4][4]; @@ -328,7 +328,7 @@ bool ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti * .clip_planes_final = clip_planes_final, }; - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); @@ -405,7 +405,7 @@ static void mask_lasso_px_cb(int x, int x_end, int y, void *user_data) static void mask_gesture_lasso_task_cb(void *__restrict userdata, const int i, - const ParallelRangeTLS *__restrict UNUSED(tls)) + const TaskParallelTLS *__restrict UNUSED(tls)) { LassoMaskData *lasso_data = userdata; MaskTaskData *data = &lasso_data->task_data; @@ -444,7 +444,7 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) const int(*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot); if (mcords) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); float clip_planes[4][4], clip_planes_final[4][4]; BoundBox bb; Object *ob; @@ -515,7 +515,7 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) data.task_data.mode = mode; data.task_data.value = value; - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && (totnode > SCULPT_THREADED_LIMIT)); diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 12891484e73..f073877ebcf 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -1329,7 +1329,7 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event) redraw = true; } - /* do updates for redraw. if event is inbetween mousemove there are more + /* do updates for redraw. if event is in between mouse-move there are more * coming, so postpone potentially slow redraw updates until all are done */ if (event->type != INBETWEEN_MOUSEMOVE) { wmWindow *window = CTX_wm_window(C); diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index c8ad1b5781d..0f37968f599 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -463,7 +463,7 @@ void paint_sample_color( bContext *C, ARegion *ar, int x, int y, bool texpaint_proj, bool use_palette) { Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Paint *paint = BKE_paint_get_active_from_context(C); Palette *palette = BKE_paint_palette(paint); PaletteColor *color = NULL; diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 980b043bf8b..9215a90c446 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -1171,30 +1171,11 @@ void ED_object_vpaintmode_enter_ex( { ed_vwpaintmode_enter_generic(bmain, depsgraph, wm, scene, ob, OB_MODE_VERTEX_PAINT); } -void ED_object_vpaintmode_enter(struct bContext *C) -{ - Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); - wmWindowManager *wm = CTX_wm_manager(C); - Scene *scene = CTX_data_scene(C); - Object *ob = CTX_data_active_object(C); - ED_object_vpaintmode_enter_ex(bmain, depsgraph, wm, scene, ob); -} - void ED_object_wpaintmode_enter_ex( Main *bmain, Depsgraph *depsgraph, wmWindowManager *wm, Scene *scene, Object *ob) { ed_vwpaintmode_enter_generic(bmain, depsgraph, wm, scene, ob, OB_MODE_WEIGHT_PAINT); } -void ED_object_wpaintmode_enter(struct bContext *C) -{ - Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); - wmWindowManager *wm = CTX_wm_manager(C); - Scene *scene = CTX_data_scene(C); - Object *ob = CTX_data_active_object(C); - ED_object_wpaintmode_enter_ex(bmain, depsgraph, wm, scene, ob); -} /** \} */ @@ -1396,7 +1377,7 @@ void PAINT_OT_weight_paint_toggle(wmOperatorType *ot) ot->poll = paint_poll_test; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /** \} */ @@ -1556,7 +1537,7 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float mo bool *defbase_sel; SculptSession *ss = ob->sculpt; VPaint *vp = CTX_data_tool_settings(C)->wpaint; - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); if (ED_wpaint_ensure_data(C, op->reports, WPAINT_ENSURE_MIRROR, &vgroup_index) == false) { return false; @@ -1713,7 +1694,7 @@ static float wpaint_get_active_weight(const MDeformVert *dv, const WeightPaintIn static void do_wpaint_precompute_weight_cb_ex(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict UNUSED(tls)) + const TaskParallelTLS *__restrict UNUSED(tls)) { SculptThreadedTaskData *data = userdata; const MDeformVert *dv = &data->me->dvert[n]; @@ -1737,7 +1718,7 @@ static void precompute_weight_values( .me = me, }; - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); BLI_task_parallel_range(0, me->totvert, &data, do_wpaint_precompute_weight_cb_ex, &settings); @@ -1746,7 +1727,7 @@ static void precompute_weight_values( static void do_wpaint_brush_blur_task_cb_ex(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict UNUSED(tls)) + const TaskParallelTLS *__restrict UNUSED(tls)) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -1838,7 +1819,7 @@ static void do_wpaint_brush_blur_task_cb_ex(void *__restrict userdata, static void do_wpaint_brush_smear_task_cb_ex(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict UNUSED(tls)) + const TaskParallelTLS *__restrict UNUSED(tls)) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -1949,7 +1930,7 @@ static void do_wpaint_brush_smear_task_cb_ex(void *__restrict userdata, static void do_wpaint_brush_draw_task_cb_ex(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict UNUSED(tls)) + const TaskParallelTLS *__restrict UNUSED(tls)) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -2022,7 +2003,7 @@ static void do_wpaint_brush_draw_task_cb_ex(void *__restrict userdata, } static void do_wpaint_brush_calc_average_weight_cb_ex( - void *__restrict userdata, const int n, const ParallelRangeTLS *__restrict UNUSED(tls)) + void *__restrict userdata, const int n, const TaskParallelTLS *__restrict UNUSED(tls)) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -2078,7 +2059,7 @@ static void calculate_average_weight(SculptThreadedTaskData *data, struct WPaintAverageAccum *accum = MEM_mallocN(sizeof(*accum) * totnode, __func__); data->custom_data = accum; - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.use_threading = ((data->sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); @@ -2127,7 +2108,7 @@ static void wpaint_paint_leaves(bContext *C, /* Use this so average can modify its weight without touching the brush. */ data.strength = BKE_brush_weight_get(scene, brush); - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); /* NOTE: current mirroring code cannot be run in parallel */ settings.use_threading = !(me->editflag & ME_EDIT_MIRROR_X); @@ -2569,7 +2550,7 @@ void PAINT_OT_vertex_paint_toggle(wmOperatorType *ot) ot->poll = paint_poll_test; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /** \} */ @@ -2638,7 +2619,7 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f Object *ob = CTX_data_active_object(C); Mesh *me; SculptSession *ss = ob->sculpt; - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); /* context checks could be a poll() */ me = BKE_mesh_from_object(ob); @@ -2705,8 +2686,9 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f return 1; } -static void do_vpaint_brush_calc_average_color_cb_ex( - void *__restrict userdata, const int n, const ParallelRangeTLS *__restrict UNUSED(tls)) +static void do_vpaint_brush_calc_average_color_cb_ex(void *__restrict userdata, + const int n, + const TaskParallelTLS *__restrict UNUSED(tls)) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -2772,7 +2754,7 @@ static float tex_color_alpha_ubyte(SculptThreadedTaskData *data, static void do_vpaint_brush_draw_task_cb_ex(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict UNUSED(tls)) + const TaskParallelTLS *__restrict UNUSED(tls)) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -2871,7 +2853,7 @@ static void do_vpaint_brush_draw_task_cb_ex(void *__restrict userdata, static void do_vpaint_brush_blur_task_cb_ex(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict UNUSED(tls)) + const TaskParallelTLS *__restrict UNUSED(tls)) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -2989,7 +2971,7 @@ static void do_vpaint_brush_blur_task_cb_ex(void *__restrict userdata, static void do_vpaint_brush_smear_task_cb_ex(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict UNUSED(tls)) + const TaskParallelTLS *__restrict UNUSED(tls)) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -3139,7 +3121,7 @@ static void calculate_average_color(SculptThreadedTaskData *data, struct VPaintAverageAccum *accum = MEM_mallocN(sizeof(*accum) * totnode, __func__); data->custom_data = accum; - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); BLI_task_parallel_range(0, totnode, data, do_vpaint_brush_calc_average_color_cb_ex, &settings); @@ -3185,7 +3167,7 @@ static void vpaint_paint_leaves(bContext *C, .lcol = (uint *)me->mloopcol, .me = me, }; - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); switch ((eBrushVertexPaintTool)brush->vertexpaint_tool) { case VPAINT_TOOL_AVERAGE: diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c index b6a6c897606..1dc28328244 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c @@ -119,7 +119,7 @@ static bool weight_from_bones_poll(bContext *C) static int weight_from_bones_exec(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); Object *armob = modifiers_isDeformedByArmature(ob); @@ -161,7 +161,7 @@ void PAINT_OT_weight_from_bones(wmOperatorType *ot) ot->poll = weight_from_bones_poll; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum( @@ -746,7 +746,7 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op) float sco_end[2] = {x_end, y_end}; const bool is_interactive = (gesture != NULL); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); WPGradient_userData data = {NULL}; @@ -880,7 +880,7 @@ void PAINT_OT_weight_gradient(wmOperatorType *ot) ot->cancel = WM_gesture_straightline_cancel; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; prop = RNA_def_enum(ot->srna, "type", gradient_types, 0, "Type", ""); RNA_def_property_flag(prop, PROP_SKIP_SAVE); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 173d6ed5085..c8709d40f96 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -368,7 +368,7 @@ static bool sculpt_stroke_is_dynamic_topology(const SculptSession *ss, const Bru static void paint_mesh_restore_co_task_cb(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict UNUSED(tls)) + const TaskParallelTLS *__restrict UNUSED(tls)) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -438,7 +438,7 @@ static void paint_mesh_restore_co(Sculpt *sd, Object *ob) .nodes = nodes, }; - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && !ss->bm && totnode > SCULPT_THREADED_LIMIT); @@ -801,7 +801,7 @@ static float calc_symmetry_feather(Sculpt *sd, StrokeCache *cache) static void calc_area_normal_and_center_task_cb(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict UNUSED(tls)) + const TaskParallelTLS *__restrict UNUSED(tls)) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -961,7 +961,7 @@ static void calc_area_center( }; BLI_mutex_init(&data.mutex); - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); BLI_task_parallel_range(0, totnode, &data, calc_area_normal_and_center_task_cb, &settings); @@ -1018,7 +1018,7 @@ void sculpt_pbvh_calc_area_normal(const Brush *brush, }; BLI_mutex_init(&data.mutex); - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.use_threading = use_threading; BLI_task_parallel_range(0, totnode, &data, calc_area_normal_and_center_task_cb, &settings); @@ -1063,7 +1063,7 @@ static void calc_area_normal_and_center( }; BLI_mutex_init(&data.mutex); - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); BLI_task_parallel_range(0, totnode, &data, calc_area_normal_and_center_task_cb, &settings); @@ -1262,7 +1262,6 @@ float tex_strength(SculptSession *ss, /* Falloff curve */ avg *= BKE_brush_curve_strength(br, len, cache->radius); - avg *= frontface(br, cache->view_normal, vno, fno); /* Paint mask */ @@ -1758,7 +1757,7 @@ typedef struct { static void do_smooth_brush_mesh_task_cb_ex(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict tls) + const TaskParallelTLS *__restrict tls) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -1813,7 +1812,7 @@ static void do_smooth_brush_mesh_task_cb_ex(void *__restrict userdata, static void do_smooth_brush_bmesh_task_cb_ex(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict tls) + const TaskParallelTLS *__restrict tls) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -1868,7 +1867,7 @@ static void do_smooth_brush_bmesh_task_cb_ex(void *__restrict userdata, static void do_topology_rake_bmesh_task_cb_ex(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict tls) + const TaskParallelTLS *__restrict tls) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -1925,7 +1924,7 @@ static void do_topology_rake_bmesh_task_cb_ex(void *__restrict userdata, static void do_smooth_brush_multires_task_cb_ex(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict tls) + const TaskParallelTLS *__restrict tls) { SculptThreadedTaskData *data = userdata; SculptDoBrushSmoothGridDataChunk *data_chunk = tls->userdata_chunk; @@ -2115,7 +2114,7 @@ static void smooth(Sculpt *sd, .strength = strength, }; - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); @@ -2175,7 +2174,7 @@ static void bmesh_topology_rake( .nodes = nodes, .strength = factor, }; - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); @@ -2191,7 +2190,7 @@ static void do_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod static void do_mask_brush_draw_task_cb_ex(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict tls) + const TaskParallelTLS *__restrict tls) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -2233,7 +2232,7 @@ static void do_mask_brush_draw(Sculpt *sd, Object *ob, PBVHNode **nodes, int tot .nodes = nodes, }; - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); BLI_task_parallel_range(0, totnode, &data, do_mask_brush_draw_task_cb_ex, &settings); @@ -2256,7 +2255,7 @@ static void do_mask_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) static void do_draw_brush_task_cb_ex(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict tls) + const TaskParallelTLS *__restrict tls) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -2320,7 +2319,7 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) .offset = offset, }; - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); BLI_task_parallel_range(0, totnode, &data, do_draw_brush_task_cb_ex, &settings); @@ -2331,7 +2330,7 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) */ static void do_crease_brush_task_cb_ex(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict tls) + const TaskParallelTLS *__restrict tls) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -2436,7 +2435,7 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod .flippedbstrength = flippedbstrength, }; - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); BLI_task_parallel_range(0, totnode, &data, do_crease_brush_task_cb_ex, &settings); @@ -2444,7 +2443,7 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod static void do_pinch_brush_task_cb_ex(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict tls) + const TaskParallelTLS *__restrict tls) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -2498,7 +2497,7 @@ static void do_pinch_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode .nodes = nodes, }; - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); BLI_task_parallel_range(0, totnode, &data, do_pinch_brush_task_cb_ex, &settings); @@ -2506,7 +2505,7 @@ static void do_pinch_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode static void do_grab_brush_task_cb_ex(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict tls) + const TaskParallelTLS *__restrict tls) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -2570,7 +2569,7 @@ static void do_grab_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) .grab_delta = grab_delta, }; - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); BLI_task_parallel_range(0, totnode, &data, do_grab_brush_task_cb_ex, &settings); @@ -2578,7 +2577,7 @@ static void do_grab_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) static void do_nudge_brush_task_cb_ex(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict tls) + const TaskParallelTLS *__restrict tls) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -2637,7 +2636,7 @@ static void do_nudge_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode .cono = cono, }; - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); BLI_task_parallel_range(0, totnode, &data, do_nudge_brush_task_cb_ex, &settings); @@ -2645,7 +2644,7 @@ static void do_nudge_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode static void do_snake_hook_brush_task_cb_ex(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict tls) + const TaskParallelTLS *__restrict tls) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -2758,7 +2757,7 @@ static void do_snake_hook_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to .grab_delta = grab_delta, }; - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); BLI_task_parallel_range(0, totnode, &data, do_snake_hook_brush_task_cb_ex, &settings); @@ -2766,7 +2765,7 @@ static void do_snake_hook_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to static void do_thumb_brush_task_cb_ex(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict tls) + const TaskParallelTLS *__restrict tls) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -2830,7 +2829,7 @@ static void do_thumb_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode .cono = cono, }; - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); BLI_task_parallel_range(0, totnode, &data, do_thumb_brush_task_cb_ex, &settings); @@ -2838,7 +2837,7 @@ static void do_thumb_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode static void do_rotate_brush_task_cb_ex(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict tls) + const TaskParallelTLS *__restrict tls) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -2903,7 +2902,7 @@ static void do_rotate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod .angle = angle, }; - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); BLI_task_parallel_range(0, totnode, &data, do_rotate_brush_task_cb_ex, &settings); @@ -2911,7 +2910,7 @@ static void do_rotate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod static void do_layer_brush_task_cb_ex(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict tls) + const TaskParallelTLS *__restrict tls) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -3000,7 +2999,7 @@ static void do_layer_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode }; BLI_mutex_init(&data.mutex); - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); BLI_task_parallel_range(0, totnode, &data, do_layer_brush_task_cb_ex, &settings); @@ -3010,7 +3009,7 @@ static void do_layer_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode static void do_inflate_brush_task_cb_ex(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict tls) + const TaskParallelTLS *__restrict tls) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -3068,7 +3067,7 @@ static void do_inflate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno .nodes = nodes, }; - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); BLI_task_parallel_range(0, totnode, &data, do_inflate_brush_task_cb_ex, &settings); @@ -3184,7 +3183,7 @@ static float get_offset(Sculpt *sd, SculptSession *ss) static void do_flatten_brush_task_cb_ex(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict tls) + const TaskParallelTLS *__restrict tls) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -3266,7 +3265,7 @@ static void do_flatten_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno .area_co = area_co, }; - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); BLI_task_parallel_range(0, totnode, &data, do_flatten_brush_task_cb_ex, &settings); @@ -3274,7 +3273,7 @@ static void do_flatten_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno static void do_clay_brush_task_cb_ex(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict tls) + const TaskParallelTLS *__restrict tls) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -3364,7 +3363,7 @@ static void do_clay_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) .area_co = area_co, }; - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); BLI_task_parallel_range(0, totnode, &data, do_clay_brush_task_cb_ex, &settings); @@ -3372,7 +3371,7 @@ static void do_clay_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) static void do_clay_strips_brush_task_cb_ex(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict tls) + const TaskParallelTLS *__restrict tls) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -3494,7 +3493,7 @@ static void do_clay_strips_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t .mat = mat, }; - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); BLI_task_parallel_range(0, totnode, &data, do_clay_strips_brush_task_cb_ex, &settings); @@ -3502,7 +3501,7 @@ static void do_clay_strips_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t static void do_fill_brush_task_cb_ex(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict tls) + const TaskParallelTLS *__restrict tls) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -3587,7 +3586,7 @@ static void do_fill_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) .area_co = area_co, }; - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); BLI_task_parallel_range(0, totnode, &data, do_fill_brush_task_cb_ex, &settings); @@ -3595,7 +3594,7 @@ static void do_fill_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) static void do_scrape_brush_task_cb_ex(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict tls) + const TaskParallelTLS *__restrict tls) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -3679,7 +3678,7 @@ static void do_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod .area_co = area_co, }; - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); BLI_task_parallel_range(0, totnode, &data, do_scrape_brush_task_cb_ex, &settings); @@ -3687,7 +3686,7 @@ static void do_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod static void do_gravity_task_cb_ex(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict tls) + const TaskParallelTLS *__restrict tls) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -3748,7 +3747,7 @@ static void do_gravity(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, fl .offset = offset, }; - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); BLI_task_parallel_range(0, totnode, &data, do_gravity_task_cb_ex, &settings); @@ -3862,7 +3861,7 @@ static void sculpt_topology_update(Sculpt *sd, static void do_brush_action_task_cb(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict UNUSED(tls)) + const TaskParallelTLS *__restrict UNUSED(tls)) { SculptThreadedTaskData *data = userdata; @@ -3896,7 +3895,7 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe .nodes = nodes, }; - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); BLI_task_parallel_range(0, totnode, &task_data, do_brush_action_task_cb, &settings); @@ -4021,7 +4020,7 @@ static void sculpt_flush_pbvhvert_deform(Object *ob, PBVHVertexIter *vd) static void sculpt_combine_proxies_task_cb(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict UNUSED(tls)) + const TaskParallelTLS *__restrict UNUSED(tls)) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -4093,7 +4092,7 @@ static void sculpt_combine_proxies(Sculpt *sd, Object *ob) .nodes = nodes, }; - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); BLI_task_parallel_range(0, totnode, &data, sculpt_combine_proxies_task_cb, &settings); @@ -4130,7 +4129,7 @@ static void sculpt_update_keyblock(Object *ob) static void sculpt_flush_stroke_deform_task_cb(void *__restrict userdata, const int n, - const ParallelRangeTLS *__restrict UNUSED(tls)) + const TaskParallelTLS *__restrict UNUSED(tls)) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -4186,7 +4185,7 @@ static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob) .vertCos = vertCos, }; - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); BLI_task_parallel_range(0, totnode, &data, sculpt_flush_stroke_deform_task_cb, &settings); @@ -4923,7 +4922,7 @@ static void sculpt_stroke_modifiers_check(const bContext *C, Object *ob, const B SculptSession *ss = ob->sculpt; if (ss->kb || ss->modifiers_active) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); bool need_pmap = sculpt_any_smooth_mode(brush, ss->cache, 0); BKE_sculpt_update_object_for_edit(depsgraph, ob, need_pmap, false); } @@ -5136,7 +5135,7 @@ static void sculpt_brush_init_tex(const Scene *scene, Sculpt *sd, SculptSession static void sculpt_brush_stroke_init(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); Sculpt *sd = CTX_data_tool_settings(C)->sculpt; @@ -5184,7 +5183,7 @@ void sculpt_update_object_bounding_box(Object *ob) static void sculpt_flush_update_step(bContext *C) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); Object *ob = CTX_data_active_object(C); SculptSession *ss = ob->sculpt; ARegion *ar = CTX_wm_region(C); @@ -5753,7 +5752,7 @@ static void sculpt_dynamic_topology_disable_ex( void sculpt_dynamic_topology_disable(bContext *C, SculptUndoNode *unode) { Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); sculpt_dynamic_topology_disable_ex(bmain, depsgraph, scene, ob, unode); @@ -5790,7 +5789,7 @@ static void sculpt_dynamic_topology_enable_with_undo(Main *bmain, static int sculpt_dynamic_topology_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); SculptSession *ss = ob->sculpt; @@ -6153,16 +6152,6 @@ void ED_object_sculptmode_enter_ex(Main *bmain, DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); } -void ED_object_sculptmode_enter(struct bContext *C, ReportList *reports) -{ - Main *bmain = CTX_data_main(C); - Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = CTX_data_view_layer(C); - Object *ob = OBACT(view_layer); - Depsgraph *depsgraph = CTX_data_depsgraph(C); - ED_object_sculptmode_enter_ex(bmain, depsgraph, scene, ob, false, reports); -} - void ED_object_sculptmode_exit_ex(Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob) { const int mode_flag = OB_MODE_SCULPT; @@ -6209,16 +6198,6 @@ void ED_object_sculptmode_exit_ex(Main *bmain, Depsgraph *depsgraph, Scene *scen DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); } -void ED_object_sculptmode_exit(bContext *C) -{ - Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); - Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = CTX_data_view_layer(C); - Object *ob = OBACT(view_layer); - ED_object_sculptmode_exit_ex(bmain, depsgraph, scene, ob); -} - static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op) { struct wmMsgBus *mbus = CTX_wm_message_bus(C); @@ -6265,7 +6244,7 @@ static void SCULPT_OT_sculptmode_toggle(wmOperatorType *ot) ot->exec = sculpt_mode_toggle_exec; ot->poll = ED_operator_object_active_editable_mesh; - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static bool sculpt_and_constant_or_manual_detail_poll(bContext *C) diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index 81bb9c35817..dde1e51e764 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -127,11 +127,10 @@ static bool sculpt_undo_restore_deformed( } } -static bool sculpt_undo_restore_coords(bContext *C, SculptUndoNode *unode) +static bool sculpt_undo_restore_coords(bContext *C, Depsgraph *depsgraph, SculptUndoNode *unode) { ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = OBACT(view_layer); - Depsgraph *depsgraph = CTX_data_depsgraph(C); SculptSession *ss = ob->sculpt; SubdivCCG *subdiv_ccg = ss->subdiv_ccg; MVert *mvert; @@ -323,7 +322,7 @@ static bool sculpt_undo_restore_mask(bContext *C, SculptUndoNode *unode) } static void sculpt_undo_bmesh_restore_generic_task_cb( - void *__restrict userdata, const int n, const ParallelRangeTLS *__restrict UNUSED(tls)) + void *__restrict userdata, const int n, const TaskParallelTLS *__restrict UNUSED(tls)) { PBVHNode **nodes = userdata; @@ -351,7 +350,7 @@ static void sculpt_undo_bmesh_restore_generic(bContext *C, BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode); - ParallelRangeSettings settings; + TaskParallelSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); BLI_task_parallel_range( @@ -455,13 +454,12 @@ static int sculpt_undo_bmesh_restore(bContext *C, return false; } -static void sculpt_undo_restore_list(bContext *C, ListBase *lb) +static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase *lb) { Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); View3D *v3d = CTX_wm_view3d(C); Object *ob = OBACT(view_layer); - Depsgraph *depsgraph = CTX_data_depsgraph(C); SculptSession *ss = ob->sculpt; SubdivCCG *subdiv_ccg = ss->subdiv_ccg; SculptUndoNode *unode; @@ -512,7 +510,7 @@ static void sculpt_undo_restore_list(bContext *C, ListBase *lb) switch (unode->type) { case SCULPT_UNDO_COORDS: - if (sculpt_undo_restore_coords(C, unode)) { + if (sculpt_undo_restore_coords(C, depsgraph, unode)) { update = true; } break; @@ -1062,21 +1060,27 @@ static bool sculpt_undosys_step_encode(struct bContext *UNUSED(C), return true; } -static void sculpt_undosys_step_decode_undo_impl(struct bContext *C, SculptUndoStep *us) +static void sculpt_undosys_step_decode_undo_impl(struct bContext *C, + Depsgraph *depsgraph, + SculptUndoStep *us) { BLI_assert(us->step.is_applied == true); - sculpt_undo_restore_list(C, &us->data.nodes); + sculpt_undo_restore_list(C, depsgraph, &us->data.nodes); us->step.is_applied = false; } -static void sculpt_undosys_step_decode_redo_impl(struct bContext *C, SculptUndoStep *us) +static void sculpt_undosys_step_decode_redo_impl(struct bContext *C, + Depsgraph *depsgraph, + SculptUndoStep *us) { BLI_assert(us->step.is_applied == false); - sculpt_undo_restore_list(C, &us->data.nodes); + sculpt_undo_restore_list(C, depsgraph, &us->data.nodes); us->step.is_applied = true; } -static void sculpt_undosys_step_decode_undo(struct bContext *C, SculptUndoStep *us) +static void sculpt_undosys_step_decode_undo(struct bContext *C, + Depsgraph *depsgraph, + SculptUndoStep *us) { SculptUndoStep *us_iter = us; while (us_iter->step.next && (us_iter->step.next->type == us_iter->step.type)) { @@ -1086,12 +1090,14 @@ static void sculpt_undosys_step_decode_undo(struct bContext *C, SculptUndoStep * us_iter = (SculptUndoStep *)us_iter->step.next; } while (us_iter != us) { - sculpt_undosys_step_decode_undo_impl(C, us_iter); + sculpt_undosys_step_decode_undo_impl(C, depsgraph, us_iter); us_iter = (SculptUndoStep *)us_iter->step.prev; } } -static void sculpt_undosys_step_decode_redo(struct bContext *C, SculptUndoStep *us) +static void sculpt_undosys_step_decode_redo(struct bContext *C, + Depsgraph *depsgraph, + SculptUndoStep *us) { SculptUndoStep *us_iter = us; while (us_iter->step.prev && (us_iter->step.prev->type == us_iter->step.type)) { @@ -1101,7 +1107,7 @@ static void sculpt_undosys_step_decode_redo(struct bContext *C, SculptUndoStep * us_iter = (SculptUndoStep *)us_iter->step.prev; } while (us_iter && (us_iter->step.is_applied == false)) { - sculpt_undosys_step_decode_redo_impl(C, us_iter); + sculpt_undosys_step_decode_redo_impl(C, depsgraph, us_iter); if (us_iter == us) { break; } @@ -1112,6 +1118,8 @@ static void sculpt_undosys_step_decode_redo(struct bContext *C, SculptUndoStep * static void sculpt_undosys_step_decode( struct bContext *C, struct Main *bmain, UndoStep *us_p, int dir, bool UNUSED(is_final)) { + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); + /* Ensure sculpt mode. */ { Scene *scene = CTX_data_scene(C); @@ -1120,7 +1128,6 @@ static void sculpt_undosys_step_decode( BKE_scene_view_layer_graph_evaluated_ensure(bmain, scene, view_layer); Object *ob = OBACT(view_layer); if (ob && (ob->type == OB_MESH)) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); if (ob->mode & OB_MODE_SCULPT) { /* pass */ } @@ -1142,10 +1149,10 @@ static void sculpt_undosys_step_decode( SculptUndoStep *us = (SculptUndoStep *)us_p; if (dir < 0) { - sculpt_undosys_step_decode_undo(C, us); + sculpt_undosys_step_decode_undo(C, depsgraph, us); } else { - sculpt_undosys_step_decode_redo(C, us); + sculpt_undosys_step_decode_redo(C, depsgraph, us); } } |