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:
authorAntonio Vazquez <blendergit@gmail.com>2019-08-01 18:05:53 +0300
committerAntonio Vazquez <blendergit@gmail.com>2019-08-01 18:05:53 +0300
commit03bbd5f9dedf7b3dfea7119c172c61f0b50ae28c (patch)
tree79ab34e79af6a700c6f73f331e4ee4e253ab3751 /source/blender/editors
parent2204bfcf9e1c3a38e60830bd97775dd72158f4d6 (diff)
parent49b2162309da6abf66764d41d9fc4c45ad01936c (diff)
Merge branch 'master' into temp-gpencil-drw-engine
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/animation/anim_channels_defines.c14
-rw-r--r--source/blender/editors/animation/anim_channels_edit.c7
-rw-r--r--source/blender/editors/animation/anim_draw.c43
-rw-r--r--source/blender/editors/animation/anim_filter.c1
-rw-r--r--source/blender/editors/animation/anim_ipo_utils.c2
-rw-r--r--source/blender/editors/animation/anim_markers.c12
-rw-r--r--source/blender/editors/animation/keyframing.c80
-rw-r--r--source/blender/editors/animation/keyingsets.c2
-rw-r--r--source/blender/editors/armature/pose_edit.c6
-rw-r--r--source/blender/editors/armature/pose_lib.c3
-rw-r--r--source/blender/editors/armature/pose_slide.c14
-rw-r--r--source/blender/editors/armature/pose_transform.c23
-rw-r--r--source/blender/editors/curve/editcurve.c11
-rw-r--r--source/blender/editors/curve/editcurve_paint.c6
-rw-r--r--source/blender/editors/curve/editfont.c6
-rw-r--r--source/blender/editors/gizmo_library/gizmo_library_presets.c4
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c2
-rw-r--r--source/blender/editors/gpencil/annotate_draw.c2
-rw-r--r--source/blender/editors/gpencil/annotate_paint.c95
-rw-r--r--source/blender/editors/gpencil/drawgpencil.c3
-rw-r--r--source/blender/editors/gpencil/gpencil_add_monkey.c7
-rw-r--r--source/blender/editors/gpencil/gpencil_add_stroke.c7
-rw-r--r--source/blender/editors/gpencil/gpencil_armature.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_brush.c44
-rw-r--r--source/blender/editors/gpencil/gpencil_convert.c47
-rw-r--r--source/blender/editors/gpencil/gpencil_data.c9
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c71
-rw-r--r--source/blender/editors/gpencil/gpencil_fill.c20
-rw-r--r--source/blender/editors/gpencil/gpencil_intern.h8
-rw-r--r--source/blender/editors/gpencil/gpencil_interpolate.c12
-rw-r--r--source/blender/editors/gpencil/gpencil_merge.c5
-rw-r--r--source/blender/editors/gpencil/gpencil_ops.c8
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c118
-rw-r--r--source/blender/editors/gpencil/gpencil_primitive.c38
-rw-r--r--source/blender/editors/gpencil/gpencil_select.c13
-rw-r--r--source/blender/editors/gpencil/gpencil_utils.c47
-rw-r--r--source/blender/editors/include/ED_anim_api.h3
-rw-r--r--source/blender/editors/include/ED_gpencil.h6
-rw-r--r--source/blender/editors/include/ED_keyframes_draw.h2
-rw-r--r--source/blender/editors/include/ED_keyframing.h4
-rw-r--r--source/blender/editors/include/ED_mesh.h5
-rw-r--r--source/blender/editors/include/ED_object.h5
-rw-r--r--source/blender/editors/include/ED_view3d.h26
-rw-r--r--source/blender/editors/include/UI_icons.h4
-rw-r--r--source/blender/editors/include/UI_interface.h3
-rw-r--r--source/blender/editors/interface/interface_anim.c9
-rw-r--r--source/blender/editors/interface/interface_draw.c5
-rw-r--r--source/blender/editors/interface/interface_eyedropper_depth.c2
-rw-r--r--source/blender/editors/interface/interface_handlers.c21
-rw-r--r--source/blender/editors/interface/interface_icons.c2
-rw-r--r--source/blender/editors/interface/interface_intern.h3
-rw-r--r--source/blender/editors/interface/interface_query.c26
-rw-r--r--source/blender/editors/interface/interface_region_hud.c59
-rw-r--r--source/blender/editors/interface/interface_region_popover.c24
-rw-r--r--source/blender/editors/interface/view2d_ops.c55
-rw-r--r--source/blender/editors/io/io_cache.c2
-rw-r--r--source/blender/editors/mask/mask_add.c2
-rw-r--r--source/blender/editors/mask/mask_ops.c4
-rw-r--r--source/blender/editors/mesh/CMakeLists.txt1
-rw-r--r--source/blender/editors/mesh/editface.c2
-rw-r--r--source/blender/editors/mesh/editmesh_extrude.c5
-rw-r--r--source/blender/editors/mesh/editmesh_knife_project.c4
-rw-r--r--source/blender/editors/mesh/editmesh_loopcut.c2
-rw-r--r--source/blender/editors/mesh/editmesh_select.c31
-rw-r--r--source/blender/editors/mesh/editmesh_tools.c9
-rw-r--r--source/blender/editors/mesh/editmesh_undo.c9
-rw-r--r--source/blender/editors/mesh/mesh_mirror.c2
-rw-r--r--source/blender/editors/mesh/meshtools.c6
-rw-r--r--source/blender/editors/object/object_add.c24
-rw-r--r--source/blender/editors/object/object_constraint.c16
-rw-r--r--source/blender/editors/object/object_data_transfer.c14
-rw-r--r--source/blender/editors/object/object_edit.c6
-rw-r--r--source/blender/editors/object/object_gpencil_modifier.c2
-rw-r--r--source/blender/editors/object/object_hook.c11
-rw-r--r--source/blender/editors/object/object_intern.h5
-rw-r--r--source/blender/editors/object/object_modes.c22
-rw-r--r--source/blender/editors/object/object_modifier.c54
-rw-r--r--source/blender/editors/object/object_relations.c7
-rw-r--r--source/blender/editors/object/object_transform.c10
-rw-r--r--source/blender/editors/object/object_vgroup.c2
-rw-r--r--source/blender/editors/physics/dynamicpaint_ops.c4
-rw-r--r--source/blender/editors/physics/particle_edit.c53
-rw-r--r--source/blender/editors/physics/particle_object.c16
-rw-r--r--source/blender/editors/physics/physics_fluid.c20
-rw-r--r--source/blender/editors/physics/physics_intern.h2
-rw-r--r--source/blender/editors/physics/physics_pointcache.c3
-rw-r--r--source/blender/editors/physics/rigidbody_object.c4
-rw-r--r--source/blender/editors/render/render_intern.h1
-rw-r--r--source/blender/editors/render/render_internal.c9
-rw-r--r--source/blender/editors/render/render_opengl.c6
-rw-r--r--source/blender/editors/render/render_ops.c1
-rw-r--r--source/blender/editors/render/render_preview.c7
-rw-r--r--source/blender/editors/render/render_shading.c71
-rw-r--r--source/blender/editors/render/render_update.c2
-rw-r--r--source/blender/editors/screen/area.c2
-rw-r--r--source/blender/editors/screen/screen_edit.c2
-rw-r--r--source/blender/editors/screen/screen_ops.c4
-rw-r--r--source/blender/editors/sculpt_paint/CMakeLists.txt1
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c8
-rw-r--r--source/blender/editors/sculpt_paint/paint_hide.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c9
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_2d.c4
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c71
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_undo.c68
-rw-r--r--source/blender/editors/sculpt_paint/paint_mask.c18
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c58
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c8
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c137
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c43
-rw-r--r--source/blender/editors/sound/sound_ops.c6
-rw-r--r--source/blender/editors/space_action/action_edit.c2
-rw-r--r--source/blender/editors/space_action/action_select.c7
-rw-r--r--source/blender/editors/space_clip/clip_graph_draw.c220
-rw-r--r--source/blender/editors/space_clip/clip_graph_ops.c55
-rw-r--r--source/blender/editors/space_clip/clip_intern.h57
-rw-r--r--source/blender/editors/space_clip/clip_ops.c39
-rw-r--r--source/blender/editors/space_clip/clip_utils.c178
-rw-r--r--source/blender/editors/space_clip/space_clip.c12
-rw-r--r--source/blender/editors/space_clip/tracking_ops.c2
-rw-r--r--source/blender/editors/space_clip/tracking_ops_orient.c10
-rw-r--r--source/blender/editors/space_clip/tracking_ops_solve.c11
-rw-r--r--source/blender/editors/space_file/file_draw.c2
-rw-r--r--source/blender/editors/space_file/file_ops.c2
-rw-r--r--source/blender/editors/space_file/filelist.c3
-rw-r--r--source/blender/editors/space_file/filesel.c2
-rw-r--r--source/blender/editors/space_graph/graph_draw.c4
-rw-r--r--source/blender/editors/space_graph/graph_edit.c2
-rw-r--r--source/blender/editors/space_image/image_ops.c37
-rw-r--r--source/blender/editors/space_image/space_image.c2
-rw-r--r--source/blender/editors/space_info/info_stats.c2
-rw-r--r--source/blender/editors/space_node/node_ops.c3
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c6
-rw-r--r--source/blender/editors/space_outliner/outliner_tools.c11
-rw-r--r--source/blender/editors/space_sequencer/sequencer_buttons.c2
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c2
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c7
-rw-r--r--source/blender/editors/space_sequencer/sequencer_scopes.c8
-rw-r--r--source/blender/editors/space_sequencer/sequencer_view.c2
-rw-r--r--source/blender/editors/space_text/space_text.c5
-rw-r--r--source/blender/editors/space_text/text_intern.h1
-rw-r--r--source/blender/editors/space_text/text_ops.c298
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c12
-rw-r--r--source/blender/editors/space_view3d/view3d_draw_legacy.c28
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c59
-rw-r--r--source/blender/editors/space_view3d/view3d_fly.c10
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_camera.c3
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c4
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_ruler.c7
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c242
-rw-r--r--source/blender/editors/space_view3d/view3d_snap.c16
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c14
-rw-r--r--source/blender/editors/space_view3d/view3d_walk.c4
-rw-r--r--source/blender/editors/transform/transform.c98
-rw-r--r--source/blender/editors/transform/transform.h2
-rw-r--r--source/blender/editors/transform/transform_constraints.c5
-rw-r--r--source/blender/editors/transform/transform_conversions.c9
-rw-r--r--source/blender/editors/transform/transform_generics.c6
-rw-r--r--source/blender/editors/transform/transform_gizmo_3d.c4
-rw-r--r--source/blender/editors/undo/ed_undo.c11
-rw-r--r--source/blender/editors/util/ed_util.c2
-rw-r--r--source/blender/editors/util/select_buffer_utils.c2
-rw-r--r--source/blender/editors/uvedit/uvedit_buttons.c86
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c12
166 files changed, 1861 insertions, 1723 deletions
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index 7a7769ccc90..3d7178a4114 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -4340,7 +4340,6 @@ static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poi
AnimData *adt = BKE_animdata_from_id(id);
FCurve *fcu = (FCurve *)fcu_poin;
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
ReportList *reports = CTX_wm_reports(C);
Scene *scene = CTX_data_scene(C);
ToolSettings *ts = scene->toolsettings;
@@ -4356,7 +4355,7 @@ static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poi
/* Get NLA context for value remapping */
NlaKeyframingContext *nla_context = BKE_animsys_get_nla_keyframing_context(
- &nla_cache, depsgraph, &id_ptr, adt, (float)CFRA);
+ &nla_cache, &id_ptr, adt, (float)CFRA, false);
/* get current frame and apply NLA-mapping to it (if applicable) */
cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
@@ -4373,7 +4372,7 @@ static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poi
/* insert a keyframe for this F-Curve */
done = insert_keyframe_direct(
- depsgraph, reports, ptr, prop, fcu, cfra, ts->keyframe_type, nla_context, flag);
+ reports, ptr, prop, fcu, cfra, ts->keyframe_type, nla_context, flag);
if (done) {
if (adt->action != NULL) {
@@ -4395,7 +4394,6 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi
KeyBlock *kb = (KeyBlock *)kb_poin;
char *rna_path = BKE_keyblock_curval_rnapath_get(key, kb);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
ReportList *reports = CTX_wm_reports(C);
Scene *scene = CTX_data_scene(C);
ToolSettings *ts = scene->toolsettings;
@@ -4411,7 +4409,7 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi
/* Get NLA context for value remapping */
NlaKeyframingContext *nla_context = BKE_animsys_get_nla_keyframing_context(
- &nla_cache, depsgraph, &id_ptr, key->adt, (float)CFRA);
+ &nla_cache, &id_ptr, key->adt, (float)CFRA, false);
/* get current frame and apply NLA-mapping to it (if applicable) */
cfra = BKE_nla_tweakedit_remap(key->adt, (float)CFRA, NLATIME_CONVERT_UNMAP);
@@ -4433,7 +4431,7 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi
/* insert a keyframe for this F-Curve */
done = insert_keyframe_direct(
- depsgraph, reports, ptr, prop, fcu, cfra, ts->keyframe_type, nla_context, flag);
+ reports, ptr, prop, fcu, cfra, ts->keyframe_type, nla_context, flag);
if (done) {
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
@@ -4460,7 +4458,6 @@ static void achannel_setting_slider_nla_curve_cb(bContext *C,
PropertyRNA *prop;
int index;
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
ReportList *reports = CTX_wm_reports(C);
Scene *scene = CTX_data_scene(C);
ToolSettings *ts = scene->toolsettings;
@@ -4485,8 +4482,7 @@ static void achannel_setting_slider_nla_curve_cb(bContext *C,
}
/* insert a keyframe for this F-Curve */
- done = insert_keyframe_direct(
- depsgraph, reports, ptr, prop, fcu, cfra, ts->keyframe_type, NULL, flag);
+ done = insert_keyframe_direct(reports, ptr, prop, fcu, cfra, ts->keyframe_type, NULL, flag);
if (done) {
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL);
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c
index b93d52a1b2d..7e913014a87 100644
--- a/source/blender/editors/animation/anim_channels_edit.c
+++ b/source/blender/editors/animation/anim_channels_edit.c
@@ -1705,7 +1705,7 @@ static void ANIM_OT_channels_ungroup(wmOperatorType *ot)
/* ******************** Delete Channel Operator *********************** */
-static void update_dependencies_on_delete(bAnimListElem *ale)
+static void tag_update_animation_element(bAnimListElem *ale)
{
ID *id = ale->id;
AnimData *adt = BKE_animdata_from_id(id);
@@ -1801,7 +1801,7 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op))
/* try to free F-Curve */
ANIM_fcurve_delete_from_animdata(&ac, adt, fcu);
- update_dependencies_on_delete(ale);
+ tag_update_animation_element(ale);
break;
}
case ANIMTYPE_NLACURVE: {
@@ -1823,7 +1823,7 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op))
/* unlink and free the F-Curve */
BLI_remlink(&strip->fcurves, fcu);
free_fcurve(fcu);
- update_dependencies_on_delete(ale);
+ tag_update_animation_element(ale);
break;
}
case ANIMTYPE_GPLAYER: {
@@ -1967,6 +1967,7 @@ static void setflag_anim_channels(bAnimContext *ac,
/* set the setting in the appropriate way */
ANIM_channel_setting_set(ac, ale, setting, mode);
+ tag_update_animation_element(ale);
/* if flush status... */
if (flush) {
diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c
index 61bf7f95340..7ab50afe3a1 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -422,23 +422,16 @@ static float normalization_factor_get(Scene *scene, FCurve *fcu, short flag, flo
}
else {
const BezTriple *prev_bezt = bezt - 1;
- if (prev_bezt->ipo == BEZT_IPO_CONST) {
- /* Constant interpolation: previous CV value is used up
- * to the current keyframe.
- */
- max_coord = max_ff(max_coord, bezt->vec[1][1]);
- min_coord = min_ff(min_coord, bezt->vec[1][1]);
- }
- else if (prev_bezt->ipo == BEZT_IPO_LIN) {
- /* Linear interpolation: min/max using both previous and
- * and current CV.
+ if (!ELEM(prev_bezt->ipo, BEZT_IPO_BEZ, BEZT_IPO_BACK, BEZT_IPO_ELASTIC)) {
+ /* The points on the curve will lie inside the start and end points.
+ * Calculate min/max using both previous and current CV.
*/
max_coord = max_ff(max_coord, bezt->vec[1][1]);
min_coord = min_ff(min_coord, bezt->vec[1][1]);
max_coord = max_ff(max_coord, prev_bezt->vec[1][1]);
min_coord = min_ff(min_coord, prev_bezt->vec[1][1]);
}
- else if (prev_bezt->ipo == BEZT_IPO_BEZ) {
+ else {
const int resol = fcu->driver ?
32 :
min_ii((int)(5.0f * len_v2v2(bezt->vec[1], prev_bezt->vec[1])),
@@ -448,30 +441,12 @@ static float normalization_factor_get(Scene *scene, FCurve *fcu, short flag, flo
min_coord = min_ff(min_coord, prev_bezt->vec[1][1]);
}
else {
- float data[120];
- float v1[2], v2[2], v3[2], v4[2];
-
- v1[0] = prev_bezt->vec[1][0];
- v1[1] = prev_bezt->vec[1][1];
- v2[0] = prev_bezt->vec[2][0];
- v2[1] = prev_bezt->vec[2][1];
-
- v3[0] = bezt->vec[0][0];
- v3[1] = bezt->vec[0][1];
- v4[0] = bezt->vec[1][0];
- v4[1] = bezt->vec[1][1];
-
- correct_bezpart(v1, v2, v3, v4);
-
- BKE_curve_forward_diff_bezier(
- v1[0], v2[0], v3[0], v4[0], data, resol, sizeof(float) * 3);
- BKE_curve_forward_diff_bezier(
- v1[1], v2[1], v3[1], v4[1], data + 1, resol, sizeof(float) * 3);
-
+ float step_size = (bezt->vec[1][0] - prev_bezt->vec[1][0]) / resol;
for (int j = 0; j <= resol; ++j) {
- const float *fp = &data[j * 3];
- max_coord = max_ff(max_coord, fp[1]);
- min_coord = min_ff(min_coord, fp[1]);
+ float eval_time = prev_bezt->vec[1][0] + step_size * j;
+ float eval_value = evaluate_fcurve_only_curve(fcu, eval_time);
+ max_coord = max_ff(max_coord, eval_value);
+ min_coord = min_ff(min_coord, eval_value);
}
}
}
diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c
index 2d16ce30d31..625a52fc800 100644
--- a/source/blender/editors/animation/anim_filter.c
+++ b/source/blender/editors/animation/anim_filter.c
@@ -412,7 +412,6 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac)
if (scene) {
ac->markers = ED_context_get_markers(C);
}
- ac->depsgraph = CTX_data_depsgraph(C);
ac->view_layer = CTX_data_view_layer(C);
ac->obact = (ac->view_layer->basact) ? ac->view_layer->basact->object : NULL;
ac->sa = sa;
diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c
index f5bd7a47248..fad9a1a8e49 100644
--- a/source/blender/editors/animation/anim_ipo_utils.c
+++ b/source/blender/editors/animation/anim_ipo_utils.c
@@ -238,6 +238,6 @@ void getcolor_fcurve_rainbow(int cur, int tot, float out[3])
/* value is fixed at 1.0f, otherwise we cannot clearly see the curves... */
hsv[2] = 1.0f;
- /* finally, conver this to RGB colors */
+ /* finally, convert this to RGB colors */
hsv_to_rgb_v(hsv, out);
}
diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c
index 2bbb8e5888c..ded59466370 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -470,7 +470,7 @@ static void draw_marker_line_if_necessary(TimeMarker *marker, int flag, int xpos
}
static void draw_marker(
- const uiFontStyle *fstyle, TimeMarker *marker, int xpos, int flag, int region_height)
+ const uiFontStyle *fstyle, TimeMarker *marker, int cfra, int xpos, int flag, int region_height)
{
GPU_blend(true);
GPU_blend_set_func_separate(
@@ -484,7 +484,9 @@ static void draw_marker(
GPU_blend(false);
float name_y = UI_DPI_FAC * 18;
- if (marker->flag & SELECT) {
+ /* Give an offset to the marker name when selected,
+ * or when near the current frame (5 frames range, starting from the current one). */
+ if ((marker->flag & SELECT) || (IN_RANGE_INCL(marker->frame, cfra, cfra - 4))) {
name_y += UI_DPI_FAC * 10;
}
draw_marker_name(fstyle, marker, xpos, name_y);
@@ -547,6 +549,7 @@ void ED_markers_draw(const bContext *C, int flag)
ARegion *ar = CTX_wm_region(C);
View2D *v2d = UI_view2d_fromcontext(C);
+ int cfra = CTX_data_scene(C)->r.cfra;
rctf markers_region_rect;
get_marker_region_rect(v2d, &markers_region_rect);
@@ -564,17 +567,18 @@ void ED_markers_draw(const bContext *C, int flag)
const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
+ /* Separate loops in order to draw selected markers on top */
for (TimeMarker *marker = markers->first; marker; marker = marker->next) {
if ((marker->flag & SELECT) == 0) {
if (marker_is_in_frame_range(marker, clip_frame_range)) {
- draw_marker(fstyle, marker, marker->frame * xscale, flag, ar->winy);
+ draw_marker(fstyle, marker, cfra, marker->frame * xscale, flag, ar->winy);
}
}
}
for (TimeMarker *marker = markers->first; marker; marker = marker->next) {
if (marker->flag & SELECT) {
if (marker_is_in_frame_range(marker, clip_frame_range)) {
- draw_marker(fstyle, marker, marker->frame * xscale, flag, ar->winy);
+ draw_marker(fstyle, marker, cfra, marker->frame * xscale, flag, ar->winy);
}
}
}
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index 2e7ed7eae34..de6e4c2fd0d 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -721,23 +721,12 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue)
/* ------------------ RNA Data-Access Functions ------------------ */
/* Try to read value using RNA-properties obtained already */
-static float *setting_get_rna_values(Depsgraph *depsgraph,
- PointerRNA *ptr,
- PropertyRNA *prop,
- const bool get_evaluated,
- float *buffer,
- int buffer_size,
- int *r_count)
+static float *setting_get_rna_values(
+ PointerRNA *ptr, PropertyRNA *prop, float *buffer, int buffer_size, int *r_count)
{
BLI_assert(buffer_size >= 1);
float *values = buffer;
- PointerRNA ptr_eval;
-
- if (get_evaluated) {
- DEG_get_evaluated_rna_pointer(depsgraph, ptr, &ptr_eval);
- ptr = &ptr_eval;
- }
if (RNA_property_array_check(prop)) {
int length = *r_count = RNA_property_array_length(ptr, prop);
@@ -977,12 +966,8 @@ static bool visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop)
* In the event that it is not possible to perform visual keying, try to fall-back
* to using the default method. Assumes that all data it has been passed is valid.
*/
-static float *visualkey_get_values(Depsgraph *depsgraph,
- PointerRNA *ptr,
- PropertyRNA *prop,
- float *buffer,
- int buffer_size,
- int *r_count)
+static float *visualkey_get_values(
+ PointerRNA *ptr, PropertyRNA *prop, float *buffer, int buffer_size, int *r_count)
{
BLI_assert(buffer_size >= 4);
@@ -999,27 +984,21 @@ static float *visualkey_get_values(Depsgraph *depsgraph,
*/
if (ptr->type == &RNA_Object) {
Object *ob = (Object *)ptr->data;
- const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
-
/* Loc code is specific... */
if (strstr(identifier, "location")) {
- copy_v3_v3(buffer, ob_eval->obmat[3]);
+ copy_v3_v3(buffer, ob->obmat[3]);
*r_count = 3;
return buffer;
}
- copy_m4_m4(tmat, ob_eval->obmat);
- rotmode = ob_eval->rotmode;
+ copy_m4_m4(tmat, ob->obmat);
+ rotmode = ob->rotmode;
}
else if (ptr->type == &RNA_PoseBone) {
- Object *ob = (Object *)ptr->id.data;
bPoseChannel *pchan = (bPoseChannel *)ptr->data;
- const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
- bPoseChannel *pchan_eval = BKE_pose_channel_find_name(ob_eval->pose, pchan->name);
-
- BKE_armature_mat_pose_to_bone(pchan_eval, pchan_eval->pose_mat, tmat);
- rotmode = pchan_eval->rotmode;
+ BKE_armature_mat_pose_to_bone(pchan, pchan->pose_mat, tmat);
+ rotmode = pchan->rotmode;
/* Loc code is specific... */
if (strstr(identifier, "location")) {
@@ -1032,7 +1011,7 @@ static float *visualkey_get_values(Depsgraph *depsgraph,
}
}
else {
- return setting_get_rna_values(depsgraph, ptr, prop, true, buffer, buffer_size, r_count);
+ return setting_get_rna_values(ptr, prop, buffer, buffer_size, r_count);
}
/* Rot/Scale code are common! */
@@ -1066,7 +1045,7 @@ static float *visualkey_get_values(Depsgraph *depsgraph,
}
/* as the function hasn't returned yet, read value from system in the default way */
- return setting_get_rna_values(depsgraph, ptr, prop, true, buffer, buffer_size, r_count);
+ return setting_get_rna_values(ptr, prop, buffer, buffer_size, r_count);
}
/* ------------------------- Insert Key API ------------------------- */
@@ -1075,8 +1054,7 @@ static float *visualkey_get_values(Depsgraph *depsgraph,
* Retrieve current property values to keyframe,
* possibly applying NLA correction when necessary.
*/
-static float *get_keyframe_values(Depsgraph *depsgraph,
- ReportList *reports,
+static float *get_keyframe_values(ReportList *reports,
PointerRNA ptr,
PropertyRNA *prop,
int index,
@@ -1094,11 +1072,11 @@ static float *get_keyframe_values(Depsgraph *depsgraph,
* it works by keyframing using a value extracted from the final matrix
* instead of using the kt system to extract a value.
*/
- values = visualkey_get_values(depsgraph, &ptr, prop, buffer, buffer_size, r_count);
+ values = visualkey_get_values(&ptr, prop, buffer, buffer_size, r_count);
}
else {
/* read value from system */
- values = setting_get_rna_values(depsgraph, &ptr, prop, false, buffer, buffer_size, r_count);
+ values = setting_get_rna_values(&ptr, prop, buffer, buffer_size, r_count);
}
/* adjust the value for NLA factors */
@@ -1207,8 +1185,7 @@ static bool insert_keyframe_value(ReportList *reports,
* the keyframe insertion. These include the 'visual' keyframing modes, quick refresh,
* and extra keyframe filtering.
*/
-bool insert_keyframe_direct(Depsgraph *depsgraph,
- ReportList *reports,
+bool insert_keyframe_direct(ReportList *reports,
PointerRNA ptr,
PropertyRNA *prop,
FCurve *fcu,
@@ -1261,8 +1238,7 @@ bool insert_keyframe_direct(Depsgraph *depsgraph,
int value_count;
int index = fcu->array_index;
- float *values = get_keyframe_values(depsgraph,
- reports,
+ float *values = get_keyframe_values(reports,
ptr,
prop,
index,
@@ -1347,7 +1323,6 @@ static bool insert_keyframe_fcurve_value(Main *bmain,
* index of -1 keys all array indices
*/
short insert_keyframe(Main *bmain,
- Depsgraph *depsgraph,
ReportList *reports,
ID *id,
bAction *act,
@@ -1405,7 +1380,7 @@ short insert_keyframe(Main *bmain,
if (adt && adt->action == act) {
/* Get NLA context for value remapping. */
nla_context = BKE_animsys_get_nla_keyframing_context(
- nla_cache ? nla_cache : &tmp_nla_cache, depsgraph, &id_ptr, adt, cfra);
+ nla_cache ? nla_cache : &tmp_nla_cache, &id_ptr, adt, cfra, false);
/* Apply NLA-mapping to frame. */
cfra = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP);
@@ -1416,8 +1391,7 @@ short insert_keyframe(Main *bmain,
int value_count;
bool force_all;
- float *values = get_keyframe_values(depsgraph,
- reports,
+ float *values = get_keyframe_values(reports,
ptr,
prop,
array_index,
@@ -2373,7 +2347,6 @@ void ANIM_OT_keyframe_delete_v3d(wmOperatorType *ot)
static int insert_key_button_exec(bContext *C, wmOperator *op)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ToolSettings *ts = scene->toolsettings;
@@ -2407,7 +2380,7 @@ static int insert_key_button_exec(bContext *C, wmOperator *op)
if (fcu) {
success = insert_keyframe_direct(
- depsgraph, op->reports, ptr, prop, fcu, cfra, ts->keyframe_type, NULL, 0);
+ op->reports, ptr, prop, fcu, cfra, ts->keyframe_type, NULL, 0);
}
else {
BKE_report(op->reports,
@@ -2423,15 +2396,8 @@ static int insert_key_button_exec(bContext *C, wmOperator *op)
fcu = rna_get_fcurve_context_ui(C, &ptr, prop, index, NULL, NULL, &driven, &special);
if (fcu && driven) {
- success = insert_keyframe_direct(depsgraph,
- op->reports,
- ptr,
- prop,
- fcu,
- cfra,
- ts->keyframe_type,
- NULL,
- INSERTKEY_DRIVER);
+ success = insert_keyframe_direct(
+ op->reports, ptr, prop, fcu, cfra, ts->keyframe_type, NULL, INSERTKEY_DRIVER);
}
}
else {
@@ -2468,7 +2434,6 @@ static int insert_key_button_exec(bContext *C, wmOperator *op)
}
success = insert_keyframe(bmain,
- depsgraph,
op->reports,
ptr.id.data,
NULL,
@@ -2794,8 +2759,7 @@ bool fcurve_is_changed(PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, float fra
float buffer[RNA_MAX_ARRAY_LENGTH];
int count, index = fcu->array_index;
- float *values = setting_get_rna_values(
- NULL, &ptr, prop, false, buffer, RNA_MAX_ARRAY_LENGTH, &count);
+ float *values = setting_get_rna_values(&ptr, prop, buffer, RNA_MAX_ARRAY_LENGTH, &count);
float fcurve_val = calculate_fcurve(&anim_rna, fcu, frame);
float cur_val = (index >= 0 && index < count) ? values[index] : 0.0f;
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c
index 0cb83c79c85..ccd0fc54611 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -1030,7 +1030,6 @@ static short keyingset_apply_keying_flags(const short base_flags,
int ANIM_apply_keyingset(
bContext *C, ListBase *dsources, bAction *act, KeyingSet *ks, short mode, float cfra)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ReportList *reports = CTX_wm_reports(C);
@@ -1125,7 +1124,6 @@ int ANIM_apply_keyingset(
/* action to take depends on mode */
if (mode == MODIFYKEY_MODE_INSERT) {
success += insert_keyframe(bmain,
- depsgraph,
reports,
ksp->id,
act,
diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c
index 5daf6b584e5..8f4896c0b82 100644
--- a/source/blender/editors/armature/pose_edit.c
+++ b/source/blender/editors/armature/pose_edit.c
@@ -195,7 +195,9 @@ void ED_pose_recalculate_paths(bContext *C, Scene *scene, Object *ob, bool curre
}
Main *bmain = CTX_data_main(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ /* NOTE: Dependency graph will be evaluated at all the frames, but we first need to access some
+ * nested pointers, like animation data. */
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ListBase targets = {NULL, NULL};
bool free_depsgraph = false;
@@ -384,7 +386,7 @@ void POSE_OT_paths_update(wmOperatorType *ot)
ot->idname = "POSE_OT_paths_update";
ot->description = "Recalculate paths for bones that already have them";
- /* api callbakcs */
+ /* api callbacks */
ot->exec = pose_update_paths_exec;
ot->poll = pose_update_paths_poll;
diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c
index 3407b3e6b7f..4cda7f264aa 100644
--- a/source/blender/editors/armature/pose_lib.c
+++ b/source/blender/editors/armature/pose_lib.c
@@ -1731,9 +1731,6 @@ static void poselib_preview_cleanup(bContext *C, wmOperator *op)
if (IS_AUTOKEY_MODE(scene, NORMAL)) {
// remake_action_ipos(ob->action);
}
- else {
- BKE_pose_where_is(CTX_data_depsgraph(C), scene, ob);
- }
}
/* Request final redraw of the view. */
diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c
index 4c5a42cade6..c8e79b879a4 100644
--- a/source/blender/editors/armature/pose_slide.c
+++ b/source/blender/editors/armature/pose_slide.c
@@ -1122,7 +1122,7 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event)
break;
}
- /* Percentage Chane... */
+ /* Percentage Change... */
case MOUSEMOVE: /* calculate new position */
{
/* only handle mousemove if not doing numinput */
@@ -1373,7 +1373,7 @@ void POSE_OT_push(wmOperatorType *ot)
ot->poll = ED_operator_posemode;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_USE_EVAL_DATA;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* Properties */
pose_slide_opdef_properties(ot);
@@ -1435,7 +1435,7 @@ void POSE_OT_relax(wmOperatorType *ot)
ot->poll = ED_operator_posemode;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_USE_EVAL_DATA;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* Properties */
pose_slide_opdef_properties(ot);
@@ -1496,7 +1496,7 @@ void POSE_OT_push_rest(wmOperatorType *ot)
ot->poll = ED_operator_posemode;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_USE_EVAL_DATA;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* Properties */
pose_slide_opdef_properties(ot);
@@ -1558,7 +1558,7 @@ void POSE_OT_relax_rest(wmOperatorType *ot)
ot->poll = ED_operator_posemode;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_USE_EVAL_DATA;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* Properties */
pose_slide_opdef_properties(ot);
@@ -1620,7 +1620,7 @@ void POSE_OT_breakdown(wmOperatorType *ot)
ot->poll = ED_operator_posemode;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_USE_EVAL_DATA;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* Properties */
pose_slide_opdef_properties(ot);
@@ -2025,7 +2025,7 @@ void POSE_OT_propagate(wmOperatorType *ot)
ot->poll = ED_operator_posemode; /* XXX: needs selected bones! */
/* flag */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
/* TODO: add "fade out" control for tapering off amount of propagation as time goes by? */
diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c
index 325e6eaee2a..854fb237929 100644
--- a/source/blender/editors/armature/pose_transform.c
+++ b/source/blender/editors/armature/pose_transform.c
@@ -71,7 +71,15 @@
* that are bone-parented to armature */
static void applyarmature_fix_boneparents(const bContext *C, Scene *scene, Object *armob)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ /* Depsgraph has been ensured to be evaluated at the beginning of the operator.
+ *
+ * Must not evaluate depsgraph here yet, since this will ruin object matrix which we want to
+ * preserve after other changes has been done in the operator.
+ *
+ * TODO(sergey): This seems very similar to `ignore_parent_tx()`, which was now ensured to work
+ * quite reliably. Can we de-duplicate the code? Or at least verify we don't need an extra logic
+ * in this function. */
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
Main *bmain = CTX_data_main(C);
Object workob, *ob;
@@ -318,7 +326,7 @@ static void applyarmature_process_selected_rec(bArmature *arm,
static int apply_armature_pose2bones_exec(bContext *C, wmOperator *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);
// must be active object, not edit-object
Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
@@ -422,7 +430,7 @@ void POSE_OT_armature_apply(wmOperatorType *ot)
ot->ui = apply_armature_pose2bones_ui;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(ot->srna,
"selected",
@@ -436,7 +444,7 @@ static int pose_visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op))
{
ViewLayer *view_layer = CTX_data_view_layer(C);
View3D *v3d = CTX_wm_view3d(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob) {
/* loop over all selected pchans
@@ -1026,6 +1034,7 @@ static int pose_clear_transform_generic_exec(bContext *C,
void (*clear_func)(bPoseChannel *),
const char default_ksName[])
{
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene = CTX_data_scene(C);
bool changed_multi = false;
@@ -1041,8 +1050,8 @@ static int pose_clear_transform_generic_exec(bContext *C,
ViewLayer *view_layer = CTX_data_view_layer(C);
View3D *v3d = CTX_wm_view3d(C);
FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob_iter) {
- Object *ob_eval = DEG_get_evaluated_object(
- CTX_data_depsgraph(C), ob_iter); // XXX: UGLY HACK (for autokey + clear transforms)
+ // XXX: UGLY HACK (for autokey + clear transforms)
+ Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob_iter);
ListBase dsources = {NULL, NULL};
bool changed = false;
@@ -1217,7 +1226,7 @@ static int pose_clear_user_transforms_exec(bContext *C, wmOperator *op)
workob.adt = ob->adt;
workob.pose = dummyPose;
- BKE_animsys_evaluate_animdata(NULL, scene, &workob.id, workob.adt, cframe, ADT_RECALC_ANIM);
+ BKE_animsys_evaluate_animdata(scene, &workob.id, workob.adt, cframe, ADT_RECALC_ANIM, false);
/* copy back values, but on selected bones only */
for (pchan = dummyPose->chanbase.first; pchan; pchan = pchan->next) {
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index d1d43a49826..047b78af7b1 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -7094,16 +7094,17 @@ static bool match_texture_space_poll(bContext *C)
static int match_texture_space_exec(bContext *C, wmOperator *UNUSED(op))
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
- Scene *scene = CTX_data_scene(C);
+ /* Need to ensure the dependency graph is fully evaluated, so the display list is at a correct
+ * state. */
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
+ (void)depsgraph;
+
Object *object = CTX_data_active_object(C);
Curve *curve = (Curve *)object->data;
float min[3], max[3], size[3], loc[3];
int a;
- if (object->runtime.curve_cache == NULL) {
- BKE_displist_make_curveTypes(depsgraph, scene, object, false, false);
- }
+ BLI_assert(object->runtime.curve_cache != NULL);
INIT_MINMAX(min, max);
BKE_displist_minmax(&object->runtime.curve_cache->disp, min, max);
diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c
index 6811e32cc2a..5e0053782d4 100644
--- a/source/blender/editors/curve/editcurve_paint.c
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -89,8 +89,6 @@ struct StrokeElem {
};
struct CurveDrawData {
- Depsgraph *depsgraph;
-
short init_event_type;
short curve_type;
@@ -578,8 +576,6 @@ static bool curve_draw_init(bContext *C, wmOperator *op, bool is_invoke)
struct CurveDrawData *cdd = MEM_callocN(sizeof(*cdd), __func__);
- cdd->depsgraph = CTX_data_depsgraph(C);
-
if (is_invoke) {
ED_view3d_viewcontext_init(C, &cdd->vc);
if (ELEM(NULL, cdd->vc.ar, cdd->vc.rv3d, cdd->vc.v3d, cdd->vc.win, cdd->vc.scene)) {
@@ -590,7 +586,7 @@ static bool curve_draw_init(bContext *C, wmOperator *op, bool is_invoke)
}
else {
cdd->vc.bmain = CTX_data_main(C);
- cdd->vc.depsgraph = CTX_data_depsgraph(C);
+ cdd->vc.depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
cdd->vc.scene = CTX_data_scene(C);
cdd->vc.view_layer = CTX_data_view_layer(C);
cdd->vc.obedit = CTX_data_edit_object(C);
diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c
index db3d5ad401d..c912cea5937 100644
--- a/source/blender/editors/curve/editfont.c
+++ b/source/blender/editors/curve/editfont.c
@@ -407,7 +407,6 @@ static int insert_into_textbuf(Object *obedit, uintptr_t c)
static void text_update_edited(bContext *C, Object *obedit, int mode)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
Curve *cu = obedit->data;
EditFont *ef = cu->editfont;
@@ -421,6 +420,7 @@ static void text_update_edited(bContext *C, Object *obedit, int mode)
else {
/* depsgraph runs above, but since we're not tagging for update, call direct */
/* We need evaluated data here. */
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
BKE_vfont_to_curve(DEG_get_evaluated_object(depsgraph, obedit), mode);
}
@@ -590,7 +590,7 @@ void FONT_OT_text_paste_from_file(wmOperatorType *ot)
static void txt_add_object(bContext *C, TextLine *firstline, int totline, const float offset[3])
{
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);
ViewLayer *view_layer = CTX_data_view_layer(C);
Curve *cu;
@@ -1084,7 +1084,7 @@ static const EnumPropertyItem move_type_items[] = {
static int move_cursor(bContext *C, int type, const bool select)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Object *obedit = CTX_data_edit_object(C);
Curve *cu = obedit->data;
EditFont *ef = cu->editfont;
diff --git a/source/blender/editors/gizmo_library/gizmo_library_presets.c b/source/blender/editors/gizmo_library/gizmo_library_presets.c
index ce62171ccb0..ae43894b7b6 100644
--- a/source/blender/editors/gizmo_library/gizmo_library_presets.c
+++ b/source/blender/editors/gizmo_library/gizmo_library_presets.c
@@ -125,6 +125,8 @@ void ED_gizmo_draw_preset_circle(const struct wmGizmo *gz,
void ED_gizmo_draw_preset_facemap(
const bContext *C, const struct wmGizmo *gz, Object *ob, const int facemap, int select_id)
{
+ /* Dependency graph is supposed to be evaluated prior to draw. */
+ Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C);
const bool is_select = (select_id != -1);
const bool is_highlight = is_select && (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0;
@@ -137,7 +139,7 @@ void ED_gizmo_draw_preset_facemap(
GPU_matrix_push();
GPU_matrix_mul(ob->obmat);
- ED_draw_object_facemap(CTX_data_depsgraph(C), ob, color, facemap);
+ ED_draw_object_facemap(depsgraph, ob, color, facemap);
GPU_matrix_pop();
if (is_select) {
diff --git a/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c
index f9ad836b054..21f779b72b1 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c
@@ -363,7 +363,7 @@ static int gizmo_move_invoke(bContext *C, wmGizmo *gz, const wmEvent *event)
inter->snap_context_v3d = ED_transform_snap_object_context_create_view3d(
CTX_data_main(C),
CTX_data_scene(C),
- CTX_data_depsgraph(C),
+ CTX_data_ensure_evaluated_depsgraph(C),
0,
CTX_wm_region(C),
CTX_wm_view3d(C));
diff --git a/source/blender/editors/gpencil/annotate_draw.c b/source/blender/editors/gpencil/annotate_draw.c
index e8f97290173..dce6ed29c05 100644
--- a/source/blender/editors/gpencil/annotate_draw.c
+++ b/source/blender/editors/gpencil/annotate_draw.c
@@ -924,7 +924,7 @@ static void annotation_draw_data_layers(
* i.e. tGPspoints NOT bGPDspoints
*/
annotation_draw_stroke_buffer(gpd->runtime.sbuffer,
- gpd->runtime.sbuffer_size,
+ gpd->runtime.sbuffer_used,
lthick,
dflag,
gpd->runtime.sbuffer_sflag,
diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c
index 5962d95c5af..e59e5d6a878 100644
--- a/source/blender/editors/gpencil/annotate_paint.c
+++ b/source/blender/editors/gpencil/annotate_paint.c
@@ -281,7 +281,7 @@ static bool gp_stroke_filtermval(tGPsdata *p, const float mval[2], float pmval[2
int dy = (int)fabsf(mval[1] - pmval[1]);
/* if buffer is empty, just let this go through (i.e. so that dots will work) */
- if (p->gpd->runtime.sbuffer_size == 0) {
+ if (p->gpd->runtime.sbuffer_used == 0) {
return true;
/* check if mouse moved at least certain distance on both axes (best case)
@@ -382,7 +382,7 @@ static void gp_stroke_convertcoords(tGPsdata *p, const float mval[2], float out[
static void gp_smooth_buffer(tGPsdata *p, float inf, int idx)
{
bGPdata *gpd = p->gpd;
- short num_points = gpd->runtime.sbuffer_size;
+ short num_points = gpd->runtime.sbuffer_used;
/* Do nothing if not enough points to smooth out */
if ((num_points < 3) || (idx < 3) || (inf == 0.0f)) {
@@ -437,7 +437,7 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
/* check painting mode */
if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT) {
/* straight lines only - i.e. only store start and end point in buffer */
- if (gpd->runtime.sbuffer_size == 0) {
+ if (gpd->runtime.sbuffer_used == 0) {
/* first point in buffer (start point) */
pt = (tGPspoint *)(gpd->runtime.sbuffer);
@@ -449,7 +449,7 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
pt->time = (float)(curtime - p->inittime);
/* increment buffer size */
- gpd->runtime.sbuffer_size++;
+ gpd->runtime.sbuffer_used++;
}
else {
/* just reset the endpoint to the latest value
@@ -465,20 +465,19 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
pt->time = (float)(curtime - p->inittime);
/* now the buffer has 2 points (and shouldn't be allowed to get any larger) */
- gpd->runtime.sbuffer_size = 2;
+ gpd->runtime.sbuffer_used = 2;
}
/* can keep carrying on this way :) */
return GP_STROKEADD_NORMAL;
}
else if (p->paintmode == GP_PAINTMODE_DRAW) { /* normal drawing */
- /* check if still room in buffer */
- if (gpd->runtime.sbuffer_size >= GP_STROKE_BUFFER_MAX) {
- return GP_STROKEADD_OVERFLOW;
- }
+ /* check if still room in buffer or add more */
+ gpd->runtime.sbuffer = ED_gpencil_sbuffer_ensure(
+ gpd->runtime.sbuffer, &gpd->runtime.sbuffer_size, &gpd->runtime.sbuffer_used, false);
/* get pointer to destination point */
- pt = ((tGPspoint *)(gpd->runtime.sbuffer) + gpd->runtime.sbuffer_size);
+ pt = ((tGPspoint *)(gpd->runtime.sbuffer) + gpd->runtime.sbuffer_used);
/* store settings */
copy_v2_v2(&pt->x, mval);
@@ -490,19 +489,13 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
pt->time = (float)(curtime - p->inittime);
/* increment counters */
- gpd->runtime.sbuffer_size++;
+ gpd->runtime.sbuffer_used++;
/* smooth while drawing previous points with a reduction factor for previous */
for (int s = 0; s < 3; s++) {
- gp_smooth_buffer(p, 0.5f * ((3.0f - s) / 3.0f), gpd->runtime.sbuffer_size - s);
+ gp_smooth_buffer(p, 0.5f * ((3.0f - s) / 3.0f), gpd->runtime.sbuffer_used - s);
}
- /* check if another operation can still occur */
- if (gpd->runtime.sbuffer_size == GP_STROKE_BUFFER_MAX) {
- return GP_STROKEADD_FULL;
- }
- else {
- return GP_STROKEADD_NORMAL;
- }
+ return GP_STROKEADD_NORMAL;
}
else if (p->paintmode == GP_PAINTMODE_DRAW_POLY) {
/* get pointer to destination point */
@@ -524,7 +517,7 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
bGPDspoint *pts;
/* first time point is adding to temporary buffer -- need to allocate new point in stroke */
- if (gpd->runtime.sbuffer_size == 0) {
+ if (gpd->runtime.sbuffer_used == 0) {
gps->points = MEM_reallocN(gps->points, sizeof(bGPDspoint) * (gps->totpoints + 1));
gps->totpoints++;
}
@@ -557,8 +550,8 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
}
/* increment counters */
- if (gpd->runtime.sbuffer_size == 0) {
- gpd->runtime.sbuffer_size++;
+ if (gpd->runtime.sbuffer_used == 0) {
+ gpd->runtime.sbuffer_used++;
}
return GP_STROKEADD_NORMAL;
@@ -576,7 +569,7 @@ static void gp_stroke_simplify(tGPsdata *p)
{
bGPdata *gpd = p->gpd;
tGPspoint *old_points = (tGPspoint *)gpd->runtime.sbuffer;
- short num_points = gpd->runtime.sbuffer_size;
+ short num_points = gpd->runtime.sbuffer_used;
short flag = gpd->runtime.sbuffer_sflag;
short i, j;
@@ -668,17 +661,17 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
* - drawing straight-lines only requires the endpoints
*/
if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT) {
- totelem = (gpd->runtime.sbuffer_size >= 2) ? 2 : gpd->runtime.sbuffer_size;
+ totelem = (gpd->runtime.sbuffer_used >= 2) ? 2 : gpd->runtime.sbuffer_used;
}
else {
- totelem = gpd->runtime.sbuffer_size;
+ totelem = gpd->runtime.sbuffer_used;
}
/* exit with error if no valid points from this stroke */
if (totelem == 0) {
if (G.debug & G_DEBUG) {
printf("Error: No valid points in stroke buffer to convert (tot=%d)\n",
- gpd->runtime.sbuffer_size);
+ gpd->runtime.sbuffer_used);
}
return;
}
@@ -736,7 +729,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
if (totelem == 2) {
/* last point if applicable */
- ptc = ((tGPspoint *)gpd->runtime.sbuffer) + (gpd->runtime.sbuffer_size - 1);
+ ptc = ((tGPspoint *)gpd->runtime.sbuffer) + (gpd->runtime.sbuffer_used - 1);
/* convert screen-coordinates to appropriate coordinates (and store them) */
gp_stroke_convertcoords(p, &ptc->x, &pt->x, NULL);
@@ -769,9 +762,9 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
int interp_depth = 0;
int found_depth = 0;
- depth_arr = MEM_mallocN(sizeof(float) * gpd->runtime.sbuffer_size, "depth_points");
+ depth_arr = MEM_mallocN(sizeof(float) * gpd->runtime.sbuffer_used, "depth_points");
- for (i = 0, ptc = gpd->runtime.sbuffer; i < gpd->runtime.sbuffer_size; i++, ptc++, pt++) {
+ for (i = 0, ptc = gpd->runtime.sbuffer; i < gpd->runtime.sbuffer_used; i++, ptc++, pt++) {
round_v2i_v2fl(mval_i, &ptc->x);
if ((ED_view3d_autodist_depth(p->ar, mval_i, depth_margin, depth_arr + i) == 0) &&
@@ -788,7 +781,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
if (found_depth == false) {
/* eeh... not much we can do.. :/, ignore depth in this case, use the 3D cursor */
- for (i = gpd->runtime.sbuffer_size - 1; i >= 0; i--) {
+ for (i = gpd->runtime.sbuffer_used - 1; i >= 0; i--) {
depth_arr[i] = 0.9999f;
}
}
@@ -798,14 +791,14 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
int first_valid = 0;
int last_valid = 0;
- for (i = 0; i < gpd->runtime.sbuffer_size; i++) {
+ for (i = 0; i < gpd->runtime.sbuffer_used; i++) {
if (depth_arr[i] != FLT_MAX) {
break;
}
}
first_valid = i;
- for (i = gpd->runtime.sbuffer_size - 1; i >= 0; i--) {
+ for (i = gpd->runtime.sbuffer_used - 1; i >= 0; i--) {
if (depth_arr[i] != FLT_MAX) {
break;
}
@@ -821,7 +814,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
}
if (interp_depth) {
- interp_sparse_array(depth_arr, gpd->runtime.sbuffer_size, FLT_MAX);
+ interp_sparse_array(depth_arr, gpd->runtime.sbuffer_used, FLT_MAX);
}
}
}
@@ -829,7 +822,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
pt = gps->points;
/* convert all points (normal behavior) */
- for (i = 0, ptc = gpd->runtime.sbuffer; i < gpd->runtime.sbuffer_size && ptc;
+ for (i = 0, ptc = gpd->runtime.sbuffer; i < gpd->runtime.sbuffer_used && ptc;
i++, ptc++, pt++) {
/* convert screen-coordinates to appropriate coordinates (and store them) */
gp_stroke_convertcoords(p, &ptc->x, &pt->x, depth_arr ? depth_arr + i : NULL);
@@ -1049,19 +1042,8 @@ static void gp_session_validatebuffer(tGPsdata *p)
{
bGPdata *gpd = p->gpd;
- /* clear memory of buffer (or allocate it if starting a new session) */
- if (gpd->runtime.sbuffer) {
- /* printf("\t\tGP - reset sbuffer\n"); */
- memset(gpd->runtime.sbuffer, 0, sizeof(tGPspoint) * GP_STROKE_BUFFER_MAX);
- }
- else {
- /* printf("\t\tGP - allocate sbuffer\n"); */
- gpd->runtime.sbuffer = MEM_callocN(sizeof(tGPspoint) * GP_STROKE_BUFFER_MAX,
- "gp_session_strokebuffer");
- }
-
- /* reset indices */
- gpd->runtime.sbuffer_size = 0;
+ gpd->runtime.sbuffer = ED_gpencil_sbuffer_ensure(
+ gpd->runtime.sbuffer, &gpd->runtime.sbuffer_size, &gpd->runtime.sbuffer_used, true);
/* reset flags */
gpd->runtime.sbuffer_sflag = 0;
@@ -1091,7 +1073,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
/* pass on current scene and window */
p->bmain = CTX_data_main(C);
p->scene = CTX_data_scene(C);
- p->depsgraph = CTX_data_depsgraph(C);
+ p->depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
p->win = CTX_wm_window(C);
unit_m4(p->imat);
@@ -1295,6 +1277,7 @@ static void gp_session_cleanup(tGPsdata *p)
}
/* clear flags */
+ gpd->runtime.sbuffer_used = 0;
gpd->runtime.sbuffer_size = 0;
gpd->runtime.sbuffer_sflag = 0;
p->inittime = 0.0;
@@ -1647,7 +1630,7 @@ static int gpencil_draw_init(bContext *C, wmOperator *op, const wmEvent *event)
}
/* init painting data */
- gp_paint_initstroke(p, paintmode, CTX_data_depsgraph(C));
+ gp_paint_initstroke(p, paintmode, CTX_data_ensure_evaluated_depsgraph(C));
if (p->status == GP_STATUS_ERROR) {
gpencil_draw_exit(C, op);
return 0;
@@ -1920,7 +1903,7 @@ static void annotation_draw_apply_event(
static int gpencil_draw_exec(bContext *C, wmOperator *op)
{
tGPsdata *p = NULL;
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
/* printf("GPencil - Starting Re-Drawing\n"); */
@@ -2074,7 +2057,7 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event
p->status = GP_STATUS_PAINTING;
/* handle the initial drawing - i.e. for just doing a simple dot */
- annotation_draw_apply_event(op, event, CTX_data_depsgraph(C), 0.0f, 0.0f);
+ annotation_draw_apply_event(op, event, CTX_data_ensure_evaluated_depsgraph(C), 0.0f, 0.0f);
op->flag |= OP_IS_MODAL_CURSOR_REGION;
}
else {
@@ -2115,7 +2098,7 @@ static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op)
* it'd be nice to allow changing paint-mode when in sketching-sessions */
if (gp_session_initdata(C, p)) {
- gp_paint_initstroke(p, p->paintmode, CTX_data_depsgraph(C));
+ gp_paint_initstroke(p, p->paintmode, CTX_data_ensure_evaluated_depsgraph(C));
}
if (p->status != GP_STATUS_ERROR) {
@@ -2150,6 +2133,7 @@ static void annotation_add_missing_events(bContext *C,
const wmEvent *event,
tGPsdata *p)
{
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
float pt[2], a[2], b[2];
float factor = 10.0f;
@@ -2165,7 +2149,7 @@ static void annotation_add_missing_events(bContext *C,
interp_v2_v2v2(pt, a, b, 0.5f);
sub_v2_v2v2(pt, b, pt);
/* create fake event */
- annotation_draw_apply_event(op, event, CTX_data_depsgraph(C), pt[0], pt[1]);
+ annotation_draw_apply_event(op, event, depsgraph, pt[0], pt[1]);
}
else if (dist >= factor) {
int slices = 2 + (int)((dist - 1.0) / factor);
@@ -2174,7 +2158,7 @@ static void annotation_add_missing_events(bContext *C,
interp_v2_v2v2(pt, a, b, n * i);
sub_v2_v2v2(pt, b, pt);
/* create fake event */
- annotation_draw_apply_event(op, event, CTX_data_depsgraph(C), pt[0], pt[1]);
+ annotation_draw_apply_event(op, event, depsgraph, pt[0], pt[1]);
}
}
}
@@ -2404,7 +2388,8 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
annotation_add_missing_events(C, op, event, p);
}
- annotation_draw_apply_event(op, event, CTX_data_depsgraph(C), 0.0f, 0.0f);
+ /* TODO(sergey): Possibly evaluating dependency graph from modal operator? */
+ annotation_draw_apply_event(op, event, CTX_data_ensure_evaluated_depsgraph(C), 0.0f, 0.0f);
/* finish painting operation if anything went wrong just now */
if (p->status == GP_STATUS_ERROR) {
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index 809acc3b322..0c2af982279 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -1117,7 +1117,8 @@ void ED_gp_draw_interpolation(const bContext *C, tGPDinterpolate *tgpi, const in
RegionView3D *rv3d = ar->regiondata;
tGPDinterpolate_layer *tgpil;
Object *obact = CTX_data_active_object(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ /* Drawing code is expected to run with fully evaluated depsgraph. */
+ Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C);
float color[4];
diff --git a/source/blender/editors/gpencil/gpencil_add_monkey.c b/source/blender/editors/gpencil/gpencil_add_monkey.c
index 4d62d169bf8..c4528518009 100644
--- a/source/blender/editors/gpencil/gpencil_add_monkey.c
+++ b/source/blender/editors/gpencil/gpencil_add_monkey.c
@@ -829,8 +829,7 @@ static const ColorTemplate gp_monkey_pct_pupils = {
void ED_gpencil_create_monkey(bContext *C, Object *ob, float mat[4][4])
{
Main *bmain = CTX_data_main(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
- int cfra_eval = (int)DEG_get_ctime(depsgraph);
+ Scene *scene = CTX_data_scene(C);
bGPdata *gpd = (bGPdata *)ob->data;
bGPDstroke *gps;
@@ -852,8 +851,8 @@ void ED_gpencil_create_monkey(bContext *C, Object *ob, float mat[4][4])
/* frames */
/* NOTE: No need to check for existing, as this will take care of it for us */
- bGPDframe *frameFills = BKE_gpencil_frame_addnew(Fills, cfra_eval);
- bGPDframe *frameLines = BKE_gpencil_frame_addnew(Lines, cfra_eval);
+ bGPDframe *frameFills = BKE_gpencil_frame_addnew(Fills, CFRA);
+ bGPDframe *frameLines = BKE_gpencil_frame_addnew(Lines, CFRA);
/* generate strokes */
gps = BKE_gpencil_add_stroke(frameFills, color_Skin, 270, 75);
diff --git a/source/blender/editors/gpencil/gpencil_add_stroke.c b/source/blender/editors/gpencil/gpencil_add_stroke.c
index f6ff5ed4f13..80e239c9ae5 100644
--- a/source/blender/editors/gpencil/gpencil_add_stroke.c
+++ b/source/blender/editors/gpencil/gpencil_add_stroke.c
@@ -215,8 +215,7 @@ static const ColorTemplate gp_stroke_material_grey = {
void ED_gpencil_create_stroke(bContext *C, Object *ob, float mat[4][4])
{
Main *bmain = CTX_data_main(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
- int cfra_eval = (int)DEG_get_ctime(depsgraph);
+ Scene *scene = CTX_data_scene(C);
bGPdata *gpd = (bGPdata *)ob->data;
bGPDstroke *gps;
@@ -236,8 +235,8 @@ void ED_gpencil_create_stroke(bContext *C, Object *ob, float mat[4][4])
bGPDlayer *lines = BKE_gpencil_layer_addnew(gpd, "Lines", true);
/* frames */
- bGPDframe *frame_color = BKE_gpencil_frame_addnew(colors, cfra_eval);
- bGPDframe *frame_lines = BKE_gpencil_frame_addnew(lines, cfra_eval);
+ bGPDframe *frame_color = BKE_gpencil_frame_addnew(colors, CFRA);
+ bGPDframe *frame_lines = BKE_gpencil_frame_addnew(lines, CFRA);
UNUSED_VARS(frame_color);
/* generate stroke */
diff --git a/source/blender/editors/gpencil/gpencil_armature.c b/source/blender/editors/gpencil/gpencil_armature.c
index 08f752bb72e..9e70be323eb 100644
--- a/source/blender/editors/gpencil/gpencil_armature.c
+++ b/source/blender/editors/gpencil/gpencil_armature.c
@@ -554,7 +554,7 @@ static bool gpencil_generate_weights_poll(bContext *C)
static int gpencil_generate_weights_exec(bContext *C, wmOperator *op)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = CTX_data_active_object(C);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index 7d866aedd87..1a7422cd174 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -87,7 +87,6 @@
typedef struct tGP_BrushEditData {
/* Current editor/region/etc. */
/* NOTE: This stuff is mainly needed to handle 3D view projection stuff... */
- Depsgraph *depsgraph;
struct Main *bmain;
Scene *scene;
Object *object;
@@ -1051,11 +1050,8 @@ static void gp_brush_clone_add(bContext *C, tGP_BrushEditData *gso)
tGPSB_CloneBrushData *data = gso->customdata;
Object *ob = CTX_data_active_object(C);
- bGPDlayer *gpl = CTX_data_active_gpencil_layer(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
- int cfra_eval = (int)DEG_get_ctime(depsgraph);
-
- bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, cfra_eval, GP_GETFRAME_ADD_NEW);
+ bGPdata *gpd = (bGPdata *)ob->data;
+ Scene *scene = CTX_data_scene(C);
bGPDstroke *gps;
float delta[3];
@@ -1074,6 +1070,18 @@ static void gp_brush_clone_add(bContext *C, tGP_BrushEditData *gso)
bGPDspoint *pt;
int i;
+ bGPDlayer *gpl = NULL;
+ /* Try to use original layer. */
+ if (gps->runtime.tmp_layerinfo != NULL) {
+ gpl = BLI_findstring(&gpd->layers, gps->runtime.tmp_layerinfo, offsetof(bGPDlayer, info));
+ }
+
+ /* if not available, use active layer. */
+ if (gpl == NULL) {
+ gpl = CTX_data_active_gpencil_layer(C);
+ }
+ bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, CFRA, GP_GETFRAME_ADD_NEW);
+
/* Make a new stroke */
new_stroke = MEM_dupallocN(gps);
@@ -1088,10 +1096,10 @@ static void gp_brush_clone_add(bContext *C, tGP_BrushEditData *gso)
BLI_addtail(&gpf->strokes, new_stroke);
/* Fix color references */
- Material *ma = BLI_ghash_lookup(data->new_colors, &new_stroke->mat_nr);
- gps->mat_nr = BKE_gpencil_object_material_get_index(ob, ma);
- if (!ma || gps->mat_nr) {
- gps->mat_nr = 0;
+ Material *ma = BLI_ghash_lookup(data->new_colors, POINTER_FROM_INT(new_stroke->mat_nr));
+ new_stroke->mat_nr = BKE_gpencil_object_material_get_index(ob, ma);
+ if (!ma || new_stroke->mat_nr < 0) {
+ new_stroke->mat_nr = 0;
}
/* Adjust all the stroke's points, so that the strokes
* get pasted relative to where the cursor is now
@@ -1224,7 +1232,6 @@ static bool gpsculpt_brush_init(bContext *C, wmOperator *op)
gso = MEM_callocN(sizeof(tGP_BrushEditData), "tGP_BrushEditData");
op->customdata = gso;
- gso->depsgraph = CTX_data_depsgraph(C);
gso->bmain = CTX_data_main(C);
/* store state */
gso->settings = gpsculpt_get_settings(scene);
@@ -1400,10 +1407,11 @@ static void gpsculpt_brush_init_stroke(tGP_BrushEditData *gso)
bGPdata *gpd = gso->gpd;
bGPDlayer *gpl;
- int cfra_eval = (int)DEG_get_ctime(gso->depsgraph);
+ Scene *scene = gso->scene;
+ int cfra = CFRA;
/* only try to add a new frame if this is the first stroke, or the frame has changed */
- if ((gpd == NULL) || (cfra_eval == gso->cfra)) {
+ if ((gpd == NULL) || (cfra == gso->cfra)) {
return;
}
@@ -1419,14 +1427,14 @@ static void gpsculpt_brush_init_stroke(tGP_BrushEditData *gso)
* spent too much time editing the wrong frame.
*/
// XXX: should this be allowed when framelock is enabled?
- if (gpf->framenum != cfra_eval) {
- BKE_gpencil_frame_addcopy(gpl, cfra_eval);
+ if (gpf->framenum != cfra) {
+ BKE_gpencil_frame_addcopy(gpl, cfra);
}
}
}
/* save off new current frame, so that next update works fine */
- gso->cfra = cfra_eval;
+ gso->cfra = cfra;
}
/* Apply ----------------------------------------------- */
@@ -1478,7 +1486,7 @@ static bool gpsculpt_brush_do_stroke(tGP_BrushEditData *gso,
/* Skip if neither one is selected
* (and we are only allowed to edit/consider selected points) */
- if (gso->settings->flag & GP_SCULPT_SETT_FLAG_SELECT_MASK) {
+ if ((gso->settings->flag & GP_SCULPT_SETT_FLAG_SELECT_MASK) && (!gso->is_weight_mode)) {
if (!(pt1->flag & GP_SPOINT_SELECT) && !(pt2->flag & GP_SPOINT_SELECT)) {
include_last = false;
continue;
@@ -1642,7 +1650,7 @@ static bool gpsculpt_brush_do_frame(
static bool gpsculpt_brush_apply_standard(bContext *C, tGP_BrushEditData *gso)
{
ToolSettings *ts = CTX_data_tool_settings(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Object *obact = gso->object;
bGPdata *gpd = gso->gpd;
bool changed = false;
diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c
index 5afa379e04f..4a91a90c075 100644
--- a/source/blender/editors/gpencil/gpencil_convert.c
+++ b/source/blender/editors/gpencil/gpencil_convert.c
@@ -162,7 +162,10 @@ static void gp_strokepoint_convertcoords(bContext *C,
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
ARegion *ar = CTX_wm_region(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ /* TODO(sergey): This function might be called from a loop, but no tagging is happening in it,
+ * so it's not that expensive to ensure evaluated depsgraph here. However, ideally all the
+ * parameters are to wrapped into a context style struct and queried from Context once.*/
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Object *obact = CTX_data_active_object(C);
bGPDspoint mypt, *pt;
@@ -387,8 +390,7 @@ static void gp_stroke_path_animation_preprocess_gaps(tGpTimingData *gtd,
}
}
-static void gp_stroke_path_animation_add_keyframes(Depsgraph *depsgraph,
- ReportList *reports,
+static void gp_stroke_path_animation_add_keyframes(ReportList *reports,
PointerRNA ptr,
PropertyRNA *prop,
FCurve *fcu,
@@ -446,7 +448,7 @@ static void gp_stroke_path_animation_add_keyframes(Depsgraph *depsgraph,
cfra = last_valid_time + MIN_TIME_DELTA;
}
insert_keyframe_direct(
- depsgraph, reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_KEYFRAME, NULL, INSERTKEY_FAST);
+ reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_KEYFRAME, NULL, INSERTKEY_FAST);
last_valid_time = cfra;
}
else if (G.debug & G_DEBUG) {
@@ -459,7 +461,7 @@ static void gp_stroke_path_animation_add_keyframes(Depsgraph *depsgraph,
cfra = last_valid_time + MIN_TIME_DELTA;
}
insert_keyframe_direct(
- depsgraph, reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_KEYFRAME, NULL, INSERTKEY_FAST);
+ reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_KEYFRAME, NULL, INSERTKEY_FAST);
last_valid_time = cfra;
}
else {
@@ -467,15 +469,8 @@ static void gp_stroke_path_animation_add_keyframes(Depsgraph *depsgraph,
* and also far enough from (not yet added!) end_stroke keyframe!
*/
if ((cfra - last_valid_time) > MIN_TIME_DELTA && (end_stroke_time - cfra) > MIN_TIME_DELTA) {
- insert_keyframe_direct(depsgraph,
- reports,
- ptr,
- prop,
- fcu,
- cfra,
- BEZT_KEYTYPE_BREAKDOWN,
- NULL,
- INSERTKEY_FAST);
+ insert_keyframe_direct(
+ reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_BREAKDOWN, NULL, INSERTKEY_FAST);
last_valid_time = cfra;
}
else if (G.debug & G_DEBUG) {
@@ -493,7 +488,6 @@ static void gp_stroke_path_animation(bContext *C,
Curve *cu,
tGpTimingData *gtd)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
bAction *act;
@@ -538,7 +532,7 @@ static void gp_stroke_path_animation(bContext *C,
cu->ctime = 0.0f;
cfra = (float)gtd->start_frame;
insert_keyframe_direct(
- depsgraph, reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_KEYFRAME, NULL, INSERTKEY_FAST);
+ reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_KEYFRAME, NULL, INSERTKEY_FAST);
cu->ctime = cu->pathlen;
if (gtd->realtime) {
@@ -548,7 +542,7 @@ static void gp_stroke_path_animation(bContext *C,
cfra = (float)gtd->end_frame;
}
insert_keyframe_direct(
- depsgraph, reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_KEYFRAME, NULL, INSERTKEY_FAST);
+ reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_KEYFRAME, NULL, INSERTKEY_FAST);
}
else {
/* Use actual recorded timing! */
@@ -575,7 +569,7 @@ static void gp_stroke_path_animation(bContext *C,
}
gp_stroke_path_animation_add_keyframes(
- depsgraph, reports, ptr, prop, fcu, cu, gtd, rng, time_range, nbr_gaps, tot_gaps_time);
+ reports, ptr, prop, fcu, cu, gtd, rng, time_range, nbr_gaps, tot_gaps_time);
BLI_rng_free(rng);
}
@@ -1250,7 +1244,7 @@ static int gp_camera_view_subrect(bContext *C, rctf *subrect)
/* for camera view set the subrect */
if (rv3d->persp == RV3D_CAMOB) {
Scene *scene = CTX_data_scene(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, subrect, true);
return 1;
}
@@ -1274,10 +1268,9 @@ static void gp_layer_to_curve(bContext *C,
struct Main *bmain = CTX_data_main(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Collection *collection = CTX_data_collection(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
- int cfra_eval = (int)DEG_get_ctime(depsgraph);
+ Scene *scene = CTX_data_scene(C);
- bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, cfra_eval, GP_GETFRAME_USE_PREV);
+ bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, CFRA, GP_GETFRAME_USE_PREV);
bGPDstroke *gps, *prev_gps = NULL;
Object *ob;
Curve *cu;
@@ -1406,8 +1399,7 @@ static void gp_layer_to_curve(bContext *C,
*/
static bool gp_convert_check_has_valid_timing(bContext *C, bGPDlayer *gpl, wmOperator *op)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
- int cfra_eval = (int)DEG_get_ctime(depsgraph);
+ Scene *scene = CTX_data_scene(C);
bGPDframe *gpf = NULL;
bGPDstroke *gps = NULL;
@@ -1416,7 +1408,7 @@ static bool gp_convert_check_has_valid_timing(bContext *C, bGPDlayer *gpl, wmOpe
int i;
bool valid = true;
- if (!gpl || !(gpf = BKE_gpencil_layer_getframe(gpl, cfra_eval, GP_GETFRAME_USE_PREV)) ||
+ if (!gpl || !(gpf = BKE_gpencil_layer_getframe(gpl, CFRA, GP_GETFRAME_USE_PREV)) ||
!(gps = gpf->strokes.first)) {
return false;
}
@@ -1468,8 +1460,7 @@ static void gp_convert_set_end_frame(struct Main *UNUSED(main),
static bool gp_convert_poll(bContext *C)
{
Object *ob = CTX_data_active_object(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
- int cfra_eval = (int)DEG_get_ctime(depsgraph);
+ Scene *scene = CTX_data_scene(C);
if ((ob == NULL) || (ob->type != OB_GPENCIL)) {
return false;
@@ -1484,7 +1475,7 @@ static bool gp_convert_poll(bContext *C)
* and if we are not in edit mode!
*/
return ((sa && sa->spacetype == SPACE_VIEW3D) && (gpl = BKE_gpencil_layer_getactive(gpd)) &&
- (gpf = BKE_gpencil_layer_getframe(gpl, cfra_eval, GP_GETFRAME_USE_PREV)) &&
+ (gpf = BKE_gpencil_layer_getframe(gpl, CFRA, GP_GETFRAME_USE_PREV)) &&
(gpf->strokes.first) && (!GPENCIL_ANY_EDIT_MODE(gpd)));
}
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index 90a2b2d613c..696c98c6646 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -594,8 +594,7 @@ static int gp_frame_duplicate_exec(bContext *C, wmOperator *op)
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
- int cfra_eval = (int)DEG_get_ctime(depsgraph);
+ Scene *scene = CTX_data_scene(C);
int mode = RNA_enum_get(op->ptr, "mode");
@@ -605,12 +604,12 @@ static int gp_frame_duplicate_exec(bContext *C, wmOperator *op)
}
if (mode == 0) {
- BKE_gpencil_frame_addcopy(gpl, cfra_eval);
+ BKE_gpencil_frame_addcopy(gpl, CFRA);
}
else {
for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
if ((gpl->flag & GP_LAYER_LOCKED) == 0) {
- BKE_gpencil_frame_addcopy(gpl, cfra_eval);
+ BKE_gpencil_frame_addcopy(gpl, CFRA);
}
}
}
@@ -2201,7 +2200,7 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Object *ob_active = CTX_data_active_object(C);
bGPdata *gpd_dst = NULL;
bool ok = false;
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 0c1c24a9432..c6d0d6e3ce2 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -139,7 +139,6 @@ static int gpencil_editmode_toggle_exec(bContext *C, wmOperator *op)
const int back = RNA_boolean_get(op->ptr, "back");
struct wmMsgBus *mbus = CTX_wm_message_bus(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
bGPdata *gpd = ED_gpencil_data_get_active(C);
bool is_object = false;
short mode;
@@ -159,6 +158,7 @@ static int gpencil_editmode_toggle_exec(bContext *C, wmOperator *op)
gpd->flag ^= GP_DATA_STROKE_EDITMODE;
/* recalculate parent matrix */
if (gpd->flag & GP_DATA_STROKE_EDITMODE) {
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ED_gpencil_reset_layers_parent(depsgraph, ob, gpd);
}
/* set mode */
@@ -1237,8 +1237,7 @@ static int gp_strokes_paste_exec(bContext *C, wmOperator *op)
Object *ob = CTX_data_active_object(C);
bGPdata *gpd = ED_gpencil_data_get_active(C);
bGPDlayer *gpl = CTX_data_active_gpencil_layer(C); /* only use active for copy merge */
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
- int cfra_eval = (int)DEG_get_ctime(depsgraph);
+ Scene *scene = CTX_data_scene(C);
bGPDframe *gpf;
eGP_PasteMode type = RNA_enum_get(op->ptr, "type");
@@ -1329,7 +1328,7 @@ static int gp_strokes_paste_exec(bContext *C, wmOperator *op)
* we are obliged to add a new frame if one
* doesn't exist already
*/
- gpf = BKE_gpencil_layer_getframe(gpl, cfra_eval, GP_GETFRAME_ADD_NEW);
+ gpf = BKE_gpencil_layer_getframe(gpl, CFRA, GP_GETFRAME_ADD_NEW);
if (gpf) {
/* Create new stroke */
bGPDstroke *new_stroke = MEM_dupallocN(gps);
@@ -1382,7 +1381,7 @@ void GPENCIL_OT_paste(wmOperatorType *ot)
ot->poll = gp_strokes_paste_poll;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
ot->prop = RNA_def_enum(ot->srna, "type", copy_type, 0, "Type", "");
@@ -1408,8 +1407,7 @@ static int gp_move_to_layer_invoke(bContext *C, wmOperator *op, const wmEvent *U
static int gp_move_to_layer_exec(bContext *C, wmOperator *op)
{
bGPdata *gpd = CTX_data_gpencil_data(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
- int cfra_eval = (int)DEG_get_ctime(depsgraph);
+ Scene *scene = CTX_data_scene(C);
bGPDlayer *target_layer = NULL;
ListBase strokes = {NULL, NULL};
int layer_num = RNA_enum_get(op->ptr, "layer");
@@ -1482,7 +1480,7 @@ static int gp_move_to_layer_exec(bContext *C, wmOperator *op)
/* Paste them all in one go */
if (strokes.first) {
- bGPDframe *gpf = BKE_gpencil_layer_getframe(target_layer, cfra_eval, GP_GETFRAME_ADD_NEW);
+ bGPDframe *gpf = BKE_gpencil_layer_getframe(target_layer, CFRA, GP_GETFRAME_ADD_NEW);
BLI_movelisttolist(&gpf->strokes, &strokes);
BLI_assert((strokes.first == strokes.last) && (strokes.first == NULL));
@@ -1545,8 +1543,8 @@ static bool UNUSED_FUNCTION(gp_blank_frame_add_poll)(bContext *C)
static int gp_blank_frame_add_exec(bContext *C, wmOperator *op)
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
- int cfra_eval = (int)DEG_get_ctime(depsgraph);
+ Scene *scene = CTX_data_scene(C);
+ int cfra = CFRA;
bGPDlayer *active_gpl = BKE_gpencil_layer_getactive(gpd);
@@ -1568,7 +1566,7 @@ static int gp_blank_frame_add_exec(bContext *C, wmOperator *op)
}
/* 1) Check for an existing frame on the current frame */
- bGPDframe *gpf = BKE_gpencil_layer_find_frame(gpl, cfra_eval);
+ bGPDframe *gpf = BKE_gpencil_layer_find_frame(gpl, cfra);
if (gpf) {
/* Shunt all frames after (and including) the existing one later by 1-frame */
for (; gpf; gpf = gpf->next) {
@@ -1577,7 +1575,7 @@ static int gp_blank_frame_add_exec(bContext *C, wmOperator *op)
}
/* 2) Now add a new frame, with nothing in it */
- gpl->actframe = BKE_gpencil_layer_getframe(gpl, cfra_eval, GP_GETFRAME_ADD_NEW);
+ gpl->actframe = BKE_gpencil_layer_getframe(gpl, cfra, GP_GETFRAME_ADD_NEW);
}
CTX_DATA_END;
@@ -1627,10 +1625,9 @@ static int gp_actframe_delete_exec(bContext *C, wmOperator *op)
bGPdata *gpd = ED_gpencil_data_get_active(C);
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
- int cfra_eval = (int)DEG_get_ctime(depsgraph);
+ Scene *scene = CTX_data_scene(C);
- bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, cfra_eval, GP_GETFRAME_USE_PREV);
+ bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, CFRA, GP_GETFRAME_USE_PREV);
/* if there's no existing Grease-Pencil data there, add some */
if (gpd == NULL) {
@@ -1681,14 +1678,13 @@ static bool gp_actframe_delete_all_poll(bContext *C)
static int gp_actframe_delete_all_exec(bContext *C, wmOperator *op)
{
bGPdata *gpd = ED_gpencil_data_get_active(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
- int cfra_eval = (int)DEG_get_ctime(depsgraph);
+ Scene *scene = CTX_data_scene(C);
bool success = false;
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
/* try to get the "active" frame - but only if it actually occurs on this frame */
- bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, cfra_eval, GP_GETFRAME_USE_PREV);
+ bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, CFRA, GP_GETFRAME_USE_PREV);
if (gpf == NULL) {
continue;
@@ -1940,9 +1936,11 @@ static int gp_dissolve_selected_points(bContext *C, eGP_DissolveMode mode)
*ndvert = *dvert;
ndvert->dw = MEM_dupallocN(dvert->dw);
ndvert++;
- dvert++;
}
}
+ if (gps->dvert != NULL) {
+ dvert++;
+ }
}
break;
case GP_DISSOLVE_BETWEEN:
@@ -1970,9 +1968,11 @@ static int gp_dissolve_selected_points(bContext *C, eGP_DissolveMode mode)
*ndvert = *dvert;
ndvert->dw = MEM_dupallocN(dvert->dw);
ndvert++;
- dvert++;
}
}
+ if (gps->dvert != NULL) {
+ dvert++;
+ }
}
/* copy last segment */
(gps->dvert != NULL) ? dvert = gps->dvert + last : NULL;
@@ -2001,9 +2001,11 @@ static int gp_dissolve_selected_points(bContext *C, eGP_DissolveMode mode)
*ndvert = *dvert;
ndvert->dw = MEM_dupallocN(dvert->dw);
ndvert++;
- dvert++;
}
}
+ if (gps->dvert != NULL) {
+ dvert++;
+ }
}
break;
}
@@ -2493,7 +2495,7 @@ static int gp_snap_to_grid(bContext *C, wmOperator *UNUSED(op))
RegionView3D *rv3d = CTX_wm_region_data(C);
View3D *v3d = CTX_wm_view3d(C);
Scene *scene = CTX_data_scene(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Object *obact = CTX_data_active_object(C);
const float gridf = ED_view3d_grid_view_scale(scene, v3d, rv3d, NULL);
@@ -2568,7 +2570,7 @@ static int gp_snap_to_cursor(bContext *C, wmOperator *op)
bGPdata *gpd = ED_gpencil_data_get_active(C);
Scene *scene = CTX_data_scene(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Object *obact = CTX_data_active_object(C);
const bool use_offset = RNA_boolean_get(op->ptr, "use_offset");
@@ -2661,7 +2663,7 @@ static int gp_snap_cursor_to_sel(bContext *C, wmOperator *UNUSED(op))
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Object *obact = CTX_data_active_object(C);
float *cursor = scene->cursor.location;
@@ -3142,10 +3144,7 @@ static void gpencil_stroke_join_strokes(bGPDstroke *gps_a,
/* 3rd: add all points */
for (i = 0, pt = gps_b->points; i < gps_b->totpoints && pt; i++, pt++) {
- /* check if still room in buffer */
- if (gps_a->totpoints <= GP_STROKE_BUFFER_MAX - 2) {
- gpencil_stroke_copy_point(gps_a, pt, i, delta, pt->pressure, pt->strength, deltatime);
- }
+ gpencil_stroke_copy_point(gps_a, pt, i, delta, pt->pressure, pt->strength, deltatime);
}
}
@@ -3375,7 +3374,7 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
bGPdata *gpd = ED_gpencil_data_get_active(C);
Scene *scene = CTX_data_scene(C);
ToolSettings *ts = CTX_data_tool_settings(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Object *ob = CTX_data_active_object(C);
ARegion *ar = CTX_wm_region(C);
RegionView3D *rv3d = ar->regiondata;
@@ -3401,12 +3400,6 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
if (gps->flag & GP_STROKE_SELECT) {
bGPDspoint *pt;
int i;
- float inverse_diff_mat[4][4];
-
- /* Compute inverse matrix for unapplying parenting once instead of doing per-point */
- /* TODO: add this bit to the iteration macro? */
- invert_m4_m4(inverse_diff_mat, gpstroke_iter.diff_mat);
-
/* Adjust each point */
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
float xy[2];
@@ -3493,7 +3486,7 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
/* Unapply parent corrections */
if (!ELEM(mode, GP_REPROJECT_FRONT, GP_REPROJECT_SIDE, GP_REPROJECT_TOP)) {
- mul_m4_v3(inverse_diff_mat, &pt->x);
+ mul_m4_v3(gpstroke_iter.inverse_diff_mat, &pt->x);
}
}
}
@@ -3526,7 +3519,7 @@ void GPENCIL_OT_reproject(wmOperatorType *ot)
"CURSOR",
0,
"Cursor",
- "Reproject the strokes using the orienation of 3D cursor"},
+ "Reproject the strokes using the orientation of 3D cursor"},
{0, NULL, 0, NULL, NULL},
};
@@ -3544,7 +3537,7 @@ void GPENCIL_OT_reproject(wmOperatorType *ot)
ot->poll = gp_strokes_edit3d_poll;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
ot->prop = RNA_def_enum(
@@ -4534,7 +4527,7 @@ void GPENCIL_OT_stroke_cutter(wmOperatorType *ot)
ot->cancel = WM_gesture_lasso_cancel;
/* flag */
- ot->flag = OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA;
+ ot->flag = OPTYPE_UNDO;
/* properties */
WM_operator_properties_gesture_lasso(ot);
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index d914cdea442..5637e755198 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -135,7 +135,7 @@ typedef struct tGPDfill {
short fill_factor;
/** number of elements currently in cache */
- short sbuffer_size;
+ short sbuffer_used;
/** temporary points */
void *sbuffer;
/** depth array for reproject */
@@ -918,7 +918,7 @@ static void gpencil_get_depth_array(tGPDfill *tgpf)
{
tGPspoint *ptc;
ToolSettings *ts = tgpf->scene->toolsettings;
- int totpoints = tgpf->sbuffer_size;
+ int totpoints = tgpf->sbuffer_used;
int i = 0;
if (totpoints == 0) {
@@ -984,7 +984,7 @@ static void gpencil_points_from_stack(tGPDfill *tgpf)
return;
}
- tgpf->sbuffer_size = (short)totpoints;
+ tgpf->sbuffer_used = (short)totpoints;
tgpf->sbuffer = MEM_callocN(sizeof(tGPspoint) * totpoints, __func__);
point2D = tgpf->sbuffer;
@@ -1020,7 +1020,7 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf)
MDeformVert *dvert = NULL;
tGPspoint *point2D;
- if (tgpf->sbuffer_size == 0) {
+ if (tgpf->sbuffer_used == 0) {
return;
}
@@ -1041,8 +1041,8 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf)
gps->mat_nr = BKE_gpencil_object_material_ensure(tgpf->bmain, tgpf->ob, tgpf->mat);
/* allocate memory for storage points */
- gps->totpoints = tgpf->sbuffer_size;
- gps->points = MEM_callocN(sizeof(bGPDspoint) * tgpf->sbuffer_size, "gp_stroke_points");
+ gps->totpoints = tgpf->sbuffer_used;
+ gps->points = MEM_callocN(sizeof(bGPDspoint) * tgpf->sbuffer_used, "gp_stroke_points");
/* initialize triangle memory to dummy data */
gps->tot_triangles = 0;
@@ -1069,7 +1069,7 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf)
dvert = gps->dvert;
}
- for (int i = 0; i < tgpf->sbuffer_size && point2D; i++, point2D++, pt++) {
+ for (int i = 0; i < tgpf->sbuffer_used && point2D; i++, point2D++, pt++) {
/* convert screen-coordinates to 3D coordinates */
gp_stroke_convertcoords_tpoint(tgpf->scene,
tgpf->ar,
@@ -1120,7 +1120,7 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf)
}
/* if parented change position relative to parent object */
- for (int a = 0; a < tgpf->sbuffer_size; a++) {
+ for (int a = 0; a < tgpf->sbuffer_used; a++) {
pt = &gps->points[a];
gp_apply_parent_point(tgpf->depsgraph, tgpf->ob, tgpf->gpd, tgpf->gpl, pt);
}
@@ -1213,7 +1213,7 @@ static tGPDfill *gp_session_init_fill(bContext *C, wmOperator *UNUSED(op))
tgpf->ar = CTX_wm_region(C);
tgpf->rv3d = tgpf->ar->regiondata;
tgpf->v3d = tgpf->sa->spacedata.first;
- tgpf->depsgraph = CTX_data_depsgraph(C);
+ tgpf->depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
tgpf->win = CTX_wm_window(C);
/* set GP datablock */
@@ -1225,7 +1225,7 @@ static tGPDfill *gp_session_init_fill(bContext *C, wmOperator *UNUSED(op))
tgpf->lock_axis = ts->gp_sculpt.lock_axis;
tgpf->oldkey = -1;
- tgpf->sbuffer_size = 0;
+ tgpf->sbuffer_used = 0;
tgpf->sbuffer = NULL;
tgpf->depth_arr = NULL;
diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h
index df9cb2e9a01..a8a3c2f9306 100644
--- a/source/blender/editors/gpencil/gpencil_intern.h
+++ b/source/blender/editors/gpencil/gpencil_intern.h
@@ -378,8 +378,8 @@ typedef enum eGPencil_PaintModes {
GP_PAINTMODE_SET_CP,
} eGPencil_PaintModes;
-/* maximum sizes of gp-session buffer */
-#define GP_STROKE_BUFFER_MAX 5000
+/* chunk size for gp-session buffer (the total size is a multiple of this number) */
+#define GP_STROKE_BUFFER_CHUNK 2048
/* stroke editing ----- */
@@ -583,6 +583,7 @@ typedef enum ACTCONT_TYPES {
struct GP_EditableStrokes_Iter {
float diff_mat[4][4];
+ float inverse_diff_mat[4][4];
};
/**
@@ -598,7 +599,7 @@ struct GP_EditableStrokes_Iter {
#define GP_EDITABLE_STROKES_BEGIN(gpstroke_iter, C, gpl, gps) \
{ \
struct GP_EditableStrokes_Iter gpstroke_iter = {{{0}}}; \
- Depsgraph *depsgraph_ = CTX_data_depsgraph(C); \
+ Depsgraph *depsgraph_ = CTX_data_ensure_evaluated_depsgraph(C); \
Object *obact_ = CTX_data_active_object(C); \
bGPdata *gpd_ = CTX_data_gpencil_data(C); \
const bool is_multiedit_ = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd_); \
@@ -607,6 +608,7 @@ struct GP_EditableStrokes_Iter {
for (bGPDframe *gpf_ = init_gpf_; gpf_; gpf_ = gpf_->next) { \
if ((gpf_ == gpl->actframe) || ((gpf_->flag & GP_FRAME_SELECT) && is_multiedit_)) { \
ED_gpencil_parent_location(depsgraph_, obact_, gpd_, gpl, gpstroke_iter.diff_mat); \
+ invert_m4_m4(gpstroke_iter.inverse_diff_mat, gpstroke_iter.diff_mat); \
/* loop over strokes */ \
for (bGPDstroke *gps = gpf_->strokes.first; gps; gps = gps->next) { \
/* skip strokes that are invalid for current view */ \
diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c b/source/blender/editors/gpencil/gpencil_interpolate.c
index 4d5548dcdf3..698e508a2a5 100644
--- a/source/blender/editors/gpencil/gpencil_interpolate.c
+++ b/source/blender/editors/gpencil/gpencil_interpolate.c
@@ -511,8 +511,8 @@ static int gpencil_interpolate_invoke(bContext *C, wmOperator *op, const wmEvent
wmWindow *win = CTX_wm_window(C);
bGPdata *gpd = CTX_data_gpencil_data(C);
bGPDlayer *gpl = CTX_data_active_gpencil_layer(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
- int cfra_eval = (int)DEG_get_ctime(depsgraph);
+ Scene *scene = CTX_data_scene(C);
+ int cfra = CFRA;
bGPDframe *actframe = gpl->actframe;
tGPDinterpolate *tgpi = NULL;
@@ -526,7 +526,7 @@ static int gpencil_interpolate_invoke(bContext *C, wmOperator *op, const wmEvent
}
/* cannot interpolate in extremes */
- if (ELEM(cfra_eval, actframe->framenum, actframe->next->framenum)) {
+ if (ELEM(cfra, actframe->framenum, actframe->next->framenum)) {
BKE_report(op->reports,
RPT_ERROR,
"Cannot interpolate as current frame already has existing grease pencil frames");
@@ -949,8 +949,8 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
Object *ob = CTX_data_active_object(C);
ToolSettings *ts = CTX_data_tool_settings(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
- int cfra_eval = (int)DEG_get_ctime(depsgraph);
+ Scene *scene = CTX_data_scene(C);
+ int cfra = CFRA;
GP_Interpolate_Settings *ipo_settings = &ts->gp_interpolate;
eGP_Interpolate_SettingsFlag flag = ipo_settings->flag;
@@ -964,7 +964,7 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
/* cannot interpolate in extremes */
- if (ELEM(cfra_eval, actframe->framenum, actframe->next->framenum)) {
+ if (ELEM(cfra, actframe->framenum, actframe->next->framenum)) {
BKE_report(op->reports,
RPT_ERROR,
"Cannot interpolate as current frame already has existing grease pencil frames");
diff --git a/source/blender/editors/gpencil/gpencil_merge.c b/source/blender/editors/gpencil/gpencil_merge.c
index 93d8555e014..cb11bb4cd63 100644
--- a/source/blender/editors/gpencil/gpencil_merge.c
+++ b/source/blender/editors/gpencil/gpencil_merge.c
@@ -98,11 +98,10 @@ static void gpencil_insert_points_to_stroke(bGPDstroke *gps,
static bGPDstroke *gpencil_prepare_stroke(bContext *C, wmOperator *op, int totpoints)
{
ToolSettings *ts = CTX_data_tool_settings(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
Object *ob = CTX_data_active_object(C);
bGPDlayer *gpl = CTX_data_active_gpencil_layer(C);
- int cfra_eval = (int)DEG_get_ctime(depsgraph);
+ Scene *scene = CTX_data_scene(C);
const bool back = RNA_boolean_get(op->ptr, "back");
const bool additive = RNA_boolean_get(op->ptr, "additive");
@@ -124,7 +123,7 @@ static bGPDstroke *gpencil_prepare_stroke(bContext *C, wmOperator *op, int totpo
else {
add_frame_mode = GP_GETFRAME_ADD_NEW;
}
- bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, cfra_eval, add_frame_mode);
+ bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, CFRA, add_frame_mode);
/* stroke */
bGPDstroke *gps = MEM_callocN(sizeof(bGPDstroke), "gp_stroke");
diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c
index db4c601709c..d259bb9183c 100644
--- a/source/blender/editors/gpencil/gpencil_ops.c
+++ b/source/blender/editors/gpencil/gpencil_ops.c
@@ -81,9 +81,15 @@ static bool gp_stroke_paintmode_poll_with_tool(bContext *C, const char gpencil_t
{
/* TODO: limit this to mode, but review 2D editors */
bGPdata *gpd = CTX_data_gpencil_data(C);
+ if (!gpd)
+ return false;
+
ToolSettings *ts = CTX_data_tool_settings(C);
+ if (!ts || !ts->gp_paint)
+ return false;
+
Brush *brush = BKE_paint_brush(&ts->gp_paint->paint);
- return ((gpd) && (gpd->flag & GP_DATA_STROKE_PAINTMODE) && (brush && brush->gpencil_settings) &&
+ return ((gpd->flag & GP_DATA_STROKE_PAINTMODE) && (brush && brush->gpencil_settings) &&
WM_toolsystem_active_tool_is_brush(C) && (brush->gpencil_tool == gpencil_tool));
}
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index b49094c4fd6..a271274fa71 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -349,7 +349,7 @@ static bool gp_stroke_filtermval(tGPsdata *p, const float mval[2], float mvalo[2
brush->gpencil_settings->flag &= ~GP_BRUSH_STABILIZE_MOUSE_TEMP;
/* if buffer is empty, just let this go through (i.e. so that dots will work) */
- if (p->gpd->runtime.sbuffer_size == 0) {
+ if (p->gpd->runtime.sbuffer_used == 0) {
return true;
}
/* if lazy mouse, check minimum distance */
@@ -486,7 +486,7 @@ static void gp_brush_jitter(bGPdata *gpd,
/* Jitter is applied perpendicular to the mouse movement vector (2D space) */
float mvec[2], svec[2];
/* mouse movement in ints -> floats */
- if (gpd->runtime.sbuffer_size > 1) {
+ if (gpd->runtime.sbuffer_used > 1) {
mvec[0] = (mval[0] - (pt - 1)->x);
mvec[1] = (mval[1] - (pt - 1)->y);
normalize_v2(mvec);
@@ -524,7 +524,7 @@ static void gp_brush_angle(bGPdata *gpd, Brush *brush, tGPspoint *pt, const floa
float v0[2] = {cos(angle), sin(angle)};
/* Apply to first point (only if there are 2 points because before no data to do it ) */
- if (gpd->runtime.sbuffer_size == 1) {
+ if (gpd->runtime.sbuffer_used == 1) {
mvec[0] = (mval[0] - (pt - 1)->x);
mvec[1] = (mval[1] - (pt - 1)->y);
normalize_v2(mvec);
@@ -537,7 +537,7 @@ static void gp_brush_angle(bGPdata *gpd, Brush *brush, tGPspoint *pt, const floa
}
/* apply from second point */
- if (gpd->runtime.sbuffer_size >= 1) {
+ if (gpd->runtime.sbuffer_used >= 1) {
mvec[0] = (mval[0] - (pt - 1)->x);
mvec[1] = (mval[1] - (pt - 1)->y);
normalize_v2(mvec);
@@ -563,7 +563,7 @@ static void gp_brush_angle(bGPdata *gpd, Brush *brush, tGPspoint *pt, const floa
static void gp_smooth_buffer(tGPsdata *p, float inf, int idx)
{
bGPdata *gpd = p->gpd;
- short num_points = gpd->runtime.sbuffer_size;
+ short num_points = gpd->runtime.sbuffer_used;
/* Do nothing if not enough points to smooth out */
if ((num_points < 3) || (idx < 3) || (inf == 0.0f)) {
@@ -626,7 +626,7 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
/* check painting mode */
if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT) {
/* straight lines only - i.e. only store start and end point in buffer */
- if (gpd->runtime.sbuffer_size == 0) {
+ if (gpd->runtime.sbuffer_used == 0) {
/* first point in buffer (start point) */
pt = (tGPspoint *)(gpd->runtime.sbuffer);
@@ -638,7 +638,7 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
pt->time = (float)(curtime - p->inittime);
/* increment buffer size */
- gpd->runtime.sbuffer_size++;
+ gpd->runtime.sbuffer_used++;
}
else {
/* just reset the endpoint to the latest value
@@ -654,20 +654,19 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
pt->time = (float)(curtime - p->inittime);
/* now the buffer has 2 points (and shouldn't be allowed to get any larger) */
- gpd->runtime.sbuffer_size = 2;
+ gpd->runtime.sbuffer_used = 2;
}
/* can keep carrying on this way :) */
return GP_STROKEADD_NORMAL;
}
else if (p->paintmode == GP_PAINTMODE_DRAW) { /* normal drawing */
- /* check if still room in buffer */
- if (gpd->runtime.sbuffer_size >= GP_STROKE_BUFFER_MAX) {
- return GP_STROKEADD_OVERFLOW;
- }
+ /* check if still room in buffer or add more */
+ gpd->runtime.sbuffer = ED_gpencil_sbuffer_ensure(
+ gpd->runtime.sbuffer, &gpd->runtime.sbuffer_size, &gpd->runtime.sbuffer_used, false);
/* get pointer to destination point */
- pt = ((tGPspoint *)(gpd->runtime.sbuffer) + gpd->runtime.sbuffer_size);
+ pt = ((tGPspoint *)(gpd->runtime.sbuffer) + gpd->runtime.sbuffer_used);
/* store settings */
/* pressure */
@@ -760,9 +759,9 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
pt->time = (float)(curtime - p->inittime);
/* point uv (only 3d view) */
- if ((p->sa->spacetype == SPACE_VIEW3D) && (gpd->runtime.sbuffer_size > 0)) {
+ if ((p->sa->spacetype == SPACE_VIEW3D) && (gpd->runtime.sbuffer_used > 0)) {
float pixsize = gp_style->texture_pixsize / 1000000.0f;
- tGPspoint *ptb = (tGPspoint *)gpd->runtime.sbuffer + gpd->runtime.sbuffer_size - 1;
+ tGPspoint *ptb = (tGPspoint *)gpd->runtime.sbuffer + gpd->runtime.sbuffer_used - 1;
bGPDspoint spt, spt2;
/* get origin to reproject point */
@@ -787,24 +786,18 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
}
/* increment counters */
- gpd->runtime.sbuffer_size++;
+ gpd->runtime.sbuffer_used++;
/* smooth while drawing previous points with a reduction factor for previous */
if (brush->gpencil_settings->active_smooth > 0.0f) {
for (int s = 0; s < 3; s++) {
gp_smooth_buffer(p,
brush->gpencil_settings->active_smooth * ((3.0f - s) / 3.0f),
- gpd->runtime.sbuffer_size - s);
+ gpd->runtime.sbuffer_used - s);
}
}
- /* check if another operation can still occur */
- if (gpd->runtime.sbuffer_size == GP_STROKE_BUFFER_MAX) {
- return GP_STROKEADD_FULL;
- }
- else {
- return GP_STROKEADD_NORMAL;
- }
+ return GP_STROKEADD_NORMAL;
}
else if (p->paintmode == GP_PAINTMODE_DRAW_POLY) {
@@ -832,7 +825,7 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
MDeformVert *dvert = NULL;
/* first time point is adding to temporary buffer -- need to allocate new point in stroke */
- if (gpd->runtime.sbuffer_size == 0) {
+ if (gpd->runtime.sbuffer_used == 0) {
gps->points = MEM_reallocN(gps->points, sizeof(bGPDspoint) * (gps->totpoints + 1));
if (gps->dvert != NULL) {
gps->dvert = MEM_reallocN(gps->dvert, sizeof(MDeformVert) * (gps->totpoints + 1));
@@ -889,8 +882,8 @@ static short gp_stroke_addpoint(tGPsdata *p, const float mval[2], float pressure
}
/* increment counters */
- if (gpd->runtime.sbuffer_size == 0) {
- gpd->runtime.sbuffer_size++;
+ if (gpd->runtime.sbuffer_used == 0) {
+ gpd->runtime.sbuffer_used++;
}
return GP_STROKEADD_NORMAL;
@@ -930,17 +923,17 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
* - drawing straight-lines only requires the endpoints
*/
if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT) {
- totelem = (gpd->runtime.sbuffer_size >= 2) ? 2 : gpd->runtime.sbuffer_size;
+ totelem = (gpd->runtime.sbuffer_used >= 2) ? 2 : gpd->runtime.sbuffer_used;
}
else {
- totelem = gpd->runtime.sbuffer_size;
+ totelem = gpd->runtime.sbuffer_used;
}
/* exit with error if no valid points from this stroke */
if (totelem == 0) {
if (G.debug & G_DEBUG) {
printf("Error: No valid points in stroke buffer to convert (tot=%d)\n",
- gpd->runtime.sbuffer_size);
+ gpd->runtime.sbuffer_used);
}
return;
}
@@ -1024,7 +1017,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
if (totelem == 2) {
/* last point if applicable */
- ptc = ((tGPspoint *)gpd->runtime.sbuffer) + (gpd->runtime.sbuffer_size - 1);
+ ptc = ((tGPspoint *)gpd->runtime.sbuffer) + (gpd->runtime.sbuffer_used - 1);
/* convert screen-coordinates to appropriate coordinates (and store them) */
gp_stroke_convertcoords(p, &ptc->x, &pt->x, NULL);
@@ -1105,9 +1098,9 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
int interp_depth = 0;
int found_depth = 0;
- depth_arr = MEM_mallocN(sizeof(float) * gpd->runtime.sbuffer_size, "depth_points");
+ depth_arr = MEM_mallocN(sizeof(float) * gpd->runtime.sbuffer_used, "depth_points");
- for (i = 0, ptc = gpd->runtime.sbuffer; i < gpd->runtime.sbuffer_size; i++, ptc++, pt++) {
+ for (i = 0, ptc = gpd->runtime.sbuffer; i < gpd->runtime.sbuffer_used; i++, ptc++, pt++) {
round_v2i_v2fl(mval_i, &ptc->x);
@@ -1125,7 +1118,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
if (found_depth == false) {
/* eeh... not much we can do.. :/, ignore depth in this case, use the 3D cursor */
- for (i = gpd->runtime.sbuffer_size - 1; i >= 0; i--) {
+ for (i = gpd->runtime.sbuffer_used - 1; i >= 0; i--) {
depth_arr[i] = 0.9999f;
}
}
@@ -1137,7 +1130,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
int last_valid = 0;
/* find first valid contact point */
- for (i = 0; i < gpd->runtime.sbuffer_size; i++) {
+ for (i = 0; i < gpd->runtime.sbuffer_used; i++) {
if (depth_arr[i] != FLT_MAX) {
break;
}
@@ -1149,7 +1142,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
last_valid = first_valid;
}
else {
- for (i = gpd->runtime.sbuffer_size - 1; i >= 0; i--) {
+ for (i = gpd->runtime.sbuffer_used - 1; i >= 0; i--) {
if (depth_arr[i] != FLT_MAX) {
break;
}
@@ -1158,7 +1151,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
}
/* invalidate any other point, to interpolate between
* first and last contact in an imaginary line between them */
- for (i = 0; i < gpd->runtime.sbuffer_size; i++) {
+ for (i = 0; i < gpd->runtime.sbuffer_used; i++) {
if ((i != first_valid) && (i != last_valid)) {
depth_arr[i] = FLT_MAX;
}
@@ -1167,7 +1160,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
}
if (interp_depth) {
- interp_sparse_array(depth_arr, gpd->runtime.sbuffer_size, FLT_MAX);
+ interp_sparse_array(depth_arr, gpd->runtime.sbuffer_used, FLT_MAX);
}
}
}
@@ -1176,7 +1169,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
dvert = gps->dvert;
/* convert all points (normal behavior) */
- for (i = 0, ptc = gpd->runtime.sbuffer; i < gpd->runtime.sbuffer_size && ptc;
+ for (i = 0, ptc = gpd->runtime.sbuffer; i < gpd->runtime.sbuffer_used && ptc;
i++, ptc++, pt++) {
/* convert screen-coordinates to appropriate coordinates (and store them) */
gp_stroke_convertcoords(p, &ptc->x, &pt->x, depth_arr ? depth_arr + i : NULL);
@@ -1725,18 +1718,8 @@ static void gp_session_validatebuffer(tGPsdata *p)
Brush *brush = p->brush;
/* clear memory of buffer (or allocate it if starting a new session) */
- if (gpd->runtime.sbuffer) {
- /* printf("\t\tGP - reset sbuffer\n"); */
- memset(gpd->runtime.sbuffer, 0, sizeof(tGPspoint) * GP_STROKE_BUFFER_MAX);
- }
- else {
- /* printf("\t\tGP - allocate sbuffer\n"); */
- gpd->runtime.sbuffer = MEM_callocN(sizeof(tGPspoint) * GP_STROKE_BUFFER_MAX,
- "gp_session_strokebuffer");
- }
-
- /* reset indices */
- gpd->runtime.sbuffer_size = 0;
+ gpd->runtime.sbuffer = ED_gpencil_sbuffer_ensure(
+ gpd->runtime.sbuffer, &gpd->runtime.sbuffer_size, &gpd->runtime.sbuffer_used, true);
/* reset flags */
gpd->runtime.sbuffer_sflag = 0;
@@ -1911,7 +1894,7 @@ static bool gp_session_initdata(bContext *C, wmOperator *op, tGPsdata *p)
p->C = C;
p->bmain = CTX_data_main(C);
p->scene = CTX_data_scene(C);
- p->depsgraph = CTX_data_depsgraph(C);
+ p->depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
p->win = CTX_wm_window(C);
p->disable_fill = RNA_boolean_get(op->ptr, "disable_fill");
@@ -2070,6 +2053,7 @@ static void gp_session_cleanup(tGPsdata *p)
}
/* clear flags */
+ gpd->runtime.sbuffer_used = 0;
gpd->runtime.sbuffer_size = 0;
gpd->runtime.sbuffer_sflag = 0;
p->inittime = 0.0;
@@ -2089,7 +2073,6 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
{
Scene *scene = p->scene;
ToolSettings *ts = scene->toolsettings;
- int cfra_eval = (int)DEG_get_ctime(p->depsgraph);
/* get active layer (or add a new one if non-existent) */
p->gpl = BKE_gpencil_layer_getactive(p->gpd);
@@ -2131,7 +2114,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
* -> If there are no strokes in that frame, don't add a new empty frame
*/
if (gpl->actframe && gpl->actframe->strokes.first) {
- gpl->actframe = BKE_gpencil_layer_getframe(gpl, cfra_eval, GP_GETFRAME_ADD_COPY);
+ gpl->actframe = BKE_gpencil_layer_getframe(gpl, CFRA, GP_GETFRAME_ADD_COPY);
has_layer_to_erase = true;
}
@@ -2169,7 +2152,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode, Deps
add_frame_mode = GP_GETFRAME_ADD_NEW;
}
- p->gpf = BKE_gpencil_layer_getframe(p->gpl, cfra_eval, add_frame_mode);
+ p->gpf = BKE_gpencil_layer_getframe(p->gpl, CFRA, add_frame_mode);
if (p->gpf == NULL) {
p->status = GP_STATUS_ERROR;
@@ -2448,7 +2431,7 @@ static int gpencil_draw_init(bContext *C, wmOperator *op, const wmEvent *event)
}
/* init painting data */
- gp_paint_initstroke(p, paintmode, CTX_data_depsgraph(C));
+ gp_paint_initstroke(p, paintmode, CTX_data_ensure_evaluated_depsgraph(C));
if (p->status == GP_STATUS_ERROR) {
gpencil_draw_exit(C, op);
return 0;
@@ -2624,14 +2607,14 @@ static void gpencil_draw_apply(bContext *C, wmOperator *op, tGPsdata *p, Depsgra
p->opressure = p->pressure;
p->ocurtime = p->curtime;
- pt = (tGPspoint *)gpd->runtime.sbuffer + gpd->runtime.sbuffer_size - 1;
+ pt = (tGPspoint *)gpd->runtime.sbuffer + gpd->runtime.sbuffer_used - 1;
if (p->paintmode != GP_PAINTMODE_ERASER) {
ED_gpencil_toggle_brush_cursor(C, true, &pt->x);
}
}
else if ((p->brush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE_TEMP) &&
- (gpd->runtime.sbuffer_size > 0)) {
- pt = (tGPspoint *)gpd->runtime.sbuffer + gpd->runtime.sbuffer_size - 1;
+ (gpd->runtime.sbuffer_used > 0)) {
+ pt = (tGPspoint *)gpd->runtime.sbuffer + gpd->runtime.sbuffer_used - 1;
if (p->paintmode != GP_PAINTMODE_ERASER) {
ED_gpencil_toggle_brush_cursor(C, true, &pt->x);
}
@@ -2842,10 +2825,10 @@ static void gpencil_draw_apply_event(
float pt[2];
copy_v2_v2(tmp, p->mval);
sub_v2_v2v2(pt, p->mval, p->mvali);
- gpencil_draw_apply_event(C, op, event, CTX_data_depsgraph(C), pt[0], pt[1]);
+ gpencil_draw_apply_event(C, op, event, depsgraph, pt[0], pt[1]);
if (len_v2v2(p->mval, p->mvalo)) {
sub_v2_v2v2(pt, p->mval, p->mvalo);
- gpencil_draw_apply_event(C, op, event, CTX_data_depsgraph(C), pt[0], pt[1]);
+ gpencil_draw_apply_event(C, op, event, depsgraph, pt[0], pt[1]);
}
copy_v2_v2(p->mval, tmp);
}
@@ -2965,7 +2948,7 @@ static void gpencil_draw_apply_event(
static int gpencil_draw_exec(bContext *C, wmOperator *op)
{
tGPsdata *p = NULL;
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
/* printf("GPencil - Starting Re-Drawing\n"); */
@@ -3213,7 +3196,7 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event
p->status = GP_STATUS_PAINTING;
/* handle the initial drawing - i.e. for just doing a simple dot */
- gpencil_draw_apply_event(C, op, event, CTX_data_depsgraph(C), 0.0f, 0.0f);
+ gpencil_draw_apply_event(C, op, event, CTX_data_ensure_evaluated_depsgraph(C), 0.0f, 0.0f);
op->flag |= OP_IS_MODAL_CURSOR_REGION;
}
else {
@@ -3277,7 +3260,7 @@ static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op)
* it'd be nice to allow changing paint-mode when in sketching-sessions */
if (gp_session_initdata(C, op, p)) {
- gp_paint_initstroke(p, p->paintmode, CTX_data_depsgraph(C));
+ gp_paint_initstroke(p, p->paintmode, CTX_data_depsgraph_pointer(C));
}
if (p->status != GP_STATUS_ERROR) {
@@ -3338,6 +3321,7 @@ static void gpencil_add_missing_events(bContext *C,
{
Brush *brush = p->brush;
GP_Sculpt_Guide *guide = &p->scene->toolsettings->gp_sculpt.guide;
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
int input_samples = brush->gpencil_settings->input_samples;
/* ensure sampling when using circular guide */
@@ -3396,7 +3380,7 @@ static void gpencil_add_missing_events(bContext *C,
interp_v2_v2v2(pt, a, b, 0.5f);
sub_v2_v2v2(pt, b, pt);
/* create fake event */
- gpencil_draw_apply_event(C, op, event, CTX_data_depsgraph(C), pt[0], pt[1]);
+ gpencil_draw_apply_event(C, op, event, depsgraph, pt[0], pt[1]);
}
else if (dist >= factor) {
int slices = 2 + (int)((dist - 1.0) / factor);
@@ -3405,7 +3389,7 @@ static void gpencil_add_missing_events(bContext *C,
interp_v2_v2v2(pt, a, b, n * i);
sub_v2_v2v2(pt, b, pt);
/* create fake event */
- gpencil_draw_apply_event(C, op, event, CTX_data_depsgraph(C), pt[0], pt[1]);
+ gpencil_draw_apply_event(C, op, event, depsgraph, pt[0], pt[1]);
}
}
}
@@ -3712,7 +3696,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
gpencil_add_missing_events(C, op, event, p);
}
- gpencil_draw_apply_event(C, op, event, CTX_data_depsgraph(C), 0.0f, 0.0f);
+ gpencil_draw_apply_event(C, op, event, CTX_data_depsgraph_pointer(C), 0.0f, 0.0f);
/* finish painting operation if anything went wrong just now */
if (p->status == GP_STATUS_ERROR) {
diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index cca94925e6e..bdc65e7172a 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -114,16 +114,8 @@ static void gp_session_validatebuffer(tGPDprimitive *p)
bGPdata *gpd = p->gpd;
/* clear memory of buffer (or allocate it if starting a new session) */
- if (gpd->runtime.sbuffer) {
- memset(gpd->runtime.sbuffer, 0, sizeof(tGPspoint) * GP_STROKE_BUFFER_MAX);
- }
- else {
- gpd->runtime.sbuffer = MEM_callocN(sizeof(tGPspoint) * GP_STROKE_BUFFER_MAX,
- "gp_session_strokebuffer");
- }
-
- /* reset indices */
- gpd->runtime.sbuffer_size = 0;
+ gpd->runtime.sbuffer = ED_gpencil_sbuffer_ensure(
+ gpd->runtime.sbuffer, &gpd->runtime.sbuffer_size, &gpd->runtime.sbuffer_used, true);
/* reset flags */
gpd->runtime.sbuffer_sflag = 0;
@@ -305,8 +297,8 @@ static void gpencil_primitive_allocate_memory(tGPDprimitive *tgpi)
/* Helper: Create internal strokes primitives data */
static void gp_primitive_set_initdata(bContext *C, tGPDprimitive *tgpi)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
- int cfra_eval = (int)DEG_get_ctime(depsgraph);
+ Scene *scene = CTX_data_scene(C);
+ int cfra = CFRA;
bGPDlayer *gpl = CTX_data_active_gpencil_layer(C);
@@ -318,7 +310,7 @@ static void gp_primitive_set_initdata(bContext *C, tGPDprimitive *tgpi)
/* create a new temporary frame */
tgpi->gpf = MEM_callocN(sizeof(bGPDframe), "Temp bGPDframe");
- tgpi->gpf->framenum = tgpi->cframe = cfra_eval;
+ tgpi->gpf->framenum = tgpi->cframe = cfra;
/* create new temp stroke */
bGPDstroke *gps = MEM_callocN(sizeof(bGPDstroke), "Temp bGPDstroke");
@@ -828,7 +820,7 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
}
/* Copy points to buffer */
- tGPspoint *tpt = ((tGPspoint *)(gpd->runtime.sbuffer) + gpd->runtime.sbuffer_size);
+ tGPspoint *tpt = ((tGPspoint *)(gpd->runtime.sbuffer) + gpd->runtime.sbuffer_used);
/* Store original points */
float tmp_xyp[2];
@@ -927,10 +919,10 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
tpt->time = p2d->time;
/* point uv */
- if (gpd->runtime.sbuffer_size > 0) {
+ if (gpd->runtime.sbuffer_used > 0) {
MaterialGPencilStyle *gp_style = tgpi->mat->gp_style;
const float pixsize = gp_style->texture_pixsize / 1000000.0f;
- tGPspoint *tptb = (tGPspoint *)gpd->runtime.sbuffer + gpd->runtime.sbuffer_size - 1;
+ tGPspoint *tptb = (tGPspoint *)gpd->runtime.sbuffer + gpd->runtime.sbuffer_used - 1;
bGPDspoint spt, spt2;
/* get origin to reproject point */
@@ -958,7 +950,11 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
tpt->uv_rot = p2d->uv_rot;
- gpd->runtime.sbuffer_size++;
+ gpd->runtime.sbuffer_used++;
+
+ /* check if still room in buffer or add more */
+ gpd->runtime.sbuffer = ED_gpencil_sbuffer_ensure(
+ gpd->runtime.sbuffer, &gpd->runtime.sbuffer_size, &gpd->runtime.sbuffer_used, false);
/* add small offset to keep stroke over the surface */
if ((depth_arr) && (gpd->zdepth_offset > 0.0f)) {
@@ -1078,6 +1074,7 @@ static void gpencil_primitive_exit(bContext *C, wmOperator *op)
gpd->runtime.sbuffer = NULL;
/* clear flags */
+ gpd->runtime.sbuffer_used = 0;
gpd->runtime.sbuffer_size = 0;
gpd->runtime.sbuffer_sflag = 0;
}
@@ -1096,11 +1093,8 @@ static void gpencil_primitive_init(bContext *C, wmOperator *op)
bGPdata *gpd = CTX_data_gpencil_data(C);
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
Paint *paint = &ts->gp_paint->paint;
- int cfra_eval = (int)DEG_get_ctime(depsgraph);
-
/* create temporary operator data */
tGPDprimitive *tgpi = MEM_callocN(sizeof(tGPDprimitive), "GPencil Primitive Data");
op->customdata = tgpi;
@@ -1115,14 +1109,14 @@ static void gpencil_primitive_init(bContext *C, wmOperator *op)
tgpi->ar = CTX_wm_region(C);
tgpi->rv3d = tgpi->ar->regiondata;
tgpi->v3d = tgpi->sa->spacedata.first;
- tgpi->depsgraph = CTX_data_depsgraph(C);
+ tgpi->depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
tgpi->win = CTX_wm_window(C);
/* save original type */
tgpi->orign_type = RNA_enum_get(op->ptr, "type");
/* set current frame number */
- tgpi->cframe = cfra_eval;
+ tgpi->cframe = CFRA;
/* set GP datablock */
tgpi->gpd = gpd;
diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c
index ba806022d3e..5a962809954 100644
--- a/source/blender/editors/gpencil/gpencil_select.c
+++ b/source/blender/editors/gpencil/gpencil_select.c
@@ -302,11 +302,10 @@ typedef enum eGP_SelectGrouped {
/* On each visible layer, check for selected strokes - if found, select all others */
static void gp_select_same_layer(bContext *C)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
- int cfra_eval = (int)DEG_get_ctime(depsgraph);
+ Scene *scene = CTX_data_scene(C);
CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) {
- bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, cfra_eval, GP_GETFRAME_USE_PREV);
+ bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, CFRA, GP_GETFRAME_USE_PREV);
bGPDstroke *gps;
bool found = false;
@@ -990,7 +989,7 @@ void GPENCIL_OT_select_circle(wmOperatorType *ot)
ot->cancel = WM_gesture_circle_cancel;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
WM_operator_properties_gesture_circle(ot);
@@ -1181,7 +1180,7 @@ void GPENCIL_OT_select_box(wmOperatorType *ot)
ot->poll = gpencil_select_poll;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
WM_operator_properties_gesture_box(ot);
@@ -1249,7 +1248,7 @@ void GPENCIL_OT_select_lasso(wmOperatorType *ot)
ot->cancel = WM_gesture_lasso_cancel;
/* flags */
- ot->flag = OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA;
+ ot->flag = OPTYPE_UNDO;
/* properties */
WM_operator_properties_select_operation(ot);
@@ -1469,7 +1468,7 @@ void GPENCIL_OT_select(wmOperatorType *ot)
ot->poll = gpencil_select_poll;
/* flag */
- ot->flag = OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA;
+ ot->flag = OPTYPE_UNDO;
/* properties */
WM_operator_properties_mouse_select(ot);
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index 065c133bf97..a475e43755c 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -259,7 +259,7 @@ bGPdata *ED_gpencil_data_get_active_evaluated(const bContext *C)
ID *screen_id = (ID *)CTX_wm_screen(C);
ScrArea *sa = CTX_wm_area(C);
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Object *ob = CTX_data_active_object(C);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
@@ -548,7 +548,7 @@ void gp_point_conversion_init(bContext *C, GP_SpaceConversion *r_gsc)
if (sa->spacetype == SPACE_VIEW3D) {
wmWindow *win = CTX_wm_window(C);
Scene *scene = CTX_data_scene(C);
- struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
View3D *v3d = (View3D *)CTX_wm_space_data(C);
RegionView3D *rv3d = ar->regiondata;
@@ -560,8 +560,7 @@ void gp_point_conversion_init(bContext *C, GP_SpaceConversion *r_gsc)
/* for camera view set the subrect */
if (rv3d->persp == RV3D_CAMOB) {
- ED_view3d_calc_camera_border(
- scene, CTX_data_depsgraph(C), ar, v3d, rv3d, &r_gsc->subrect_data, true);
+ ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &r_gsc->subrect_data, true);
r_gsc->subrect = &r_gsc->subrect_data;
}
}
@@ -929,7 +928,7 @@ void ED_gp_get_drawing_reference(
void ED_gpencil_project_stroke_to_view(bContext *C, bGPDlayer *gpl, bGPDstroke *gps)
{
Scene *scene = CTX_data_scene(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Object *ob = CTX_data_active_object(C);
bGPdata *gpd = (bGPdata *)ob->data;
GP_SpaceConversion gsc = {NULL};
@@ -1094,7 +1093,7 @@ void ED_gp_project_point_to_plane(const Scene *scene,
/* get a vector from the point with the current view direction of the viewport */
ED_view3d_global_to_vector(rv3d, &pt->x, vn);
- /* calculate line extrem point to create a ray that cross the plane */
+ /* calculate line extreme point to create a ray that cross the plane */
mul_v3_fl(vn, -50.0f);
add_v3_v3v3(ray, &pt->x, vn);
@@ -1740,7 +1739,7 @@ static void gp_brush_cursor_draw(bContext *C, int x, int y, void *customdata)
}
/* while drawing hide */
- if ((gpd->runtime.sbuffer_size > 0) &&
+ if ((gpd->runtime.sbuffer_used > 0) &&
((brush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE) == 0) &&
((brush->gpencil_settings->flag & GP_BRUSH_STABILIZE_MOUSE_TEMP) == 0)) {
return;
@@ -2525,3 +2524,37 @@ void ED_gpencil_select_toggle_all(bContext *C, int action)
CTX_DATA_END;
}
}
+
+/* Ensure the SBuffer (while drawing stroke) size is enough to save all points of the stroke */
+tGPspoint *ED_gpencil_sbuffer_ensure(tGPspoint *buffer_array,
+ short *buffer_size,
+ short *buffer_used,
+ const bool clear)
+{
+ tGPspoint *p = NULL;
+
+ /* By default a buffer is created with one block with a predefined number of free points,
+ * if the size is not enough, the cache is reallocated adding a new block of free points.
+ * This is done in order to keep cache small and improve speed. */
+ if (*buffer_used + 1 > *buffer_size) {
+ if ((*buffer_size == 0) || (buffer_array == NULL)) {
+ p = MEM_callocN(sizeof(struct tGPspoint) * GP_STROKE_BUFFER_CHUNK, "GPencil Sbuffer");
+ *buffer_size = GP_STROKE_BUFFER_CHUNK;
+ }
+ else {
+ *buffer_size += GP_STROKE_BUFFER_CHUNK;
+ p = MEM_recallocN(buffer_array, sizeof(struct tGPspoint) * *buffer_size);
+ }
+ buffer_array = p;
+ }
+
+ /* clear old data */
+ if (clear) {
+ *buffer_used = 0;
+ if (buffer_array != NULL) {
+ memset(buffer_array, 0, sizeof(tGPspoint) * *buffer_size);
+ }
+ }
+
+ return buffer_array;
+}
diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h
index 230d62d400c..a232e1376d3 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -27,6 +27,7 @@
struct AnimData;
struct ID;
struct ListBase;
+struct Depsgraph;
struct ARegion;
struct Main;
@@ -84,8 +85,6 @@ typedef struct bAnimContext {
/** dopesheet data for editor (or which is being used) */
struct bDopeSheet *ads;
- /** active dependency graph */
- struct Depsgraph *depsgraph;
/** Current Main */
struct Main *bmain;
/** active scene */
diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h
index 0e3204b30c7..6410e6630a7 100644
--- a/source/blender/editors/include/ED_gpencil.h
+++ b/source/blender/editors/include/ED_gpencil.h
@@ -35,6 +35,7 @@ struct bGPDlayer;
struct bGPDspoint;
struct bGPDstroke;
struct bGPdata;
+struct tGPspoint;
struct ARegion;
struct Depsgraph;
@@ -287,4 +288,9 @@ int ED_gpencil_select_stroke_segment(struct bGPDlayer *gpl,
void ED_gpencil_select_toggle_all(struct bContext *C, int action);
+/* Ensure stroke sbuffer size is enough */
+struct tGPspoint *ED_gpencil_sbuffer_ensure(struct tGPspoint *buffer_array,
+ short *buffer_size,
+ short *buffer_used,
+ const bool clear);
#endif /* __ED_GPENCIL_H__ */
diff --git a/source/blender/editors/include/ED_keyframes_draw.h b/source/blender/editors/include/ED_keyframes_draw.h
index 9fa8996c384..05f641abe91 100644
--- a/source/blender/editors/include/ED_keyframes_draw.h
+++ b/source/blender/editors/include/ED_keyframes_draw.h
@@ -127,7 +127,7 @@ typedef enum eKeyframeExtremeDrawOpts {
KEYFRAME_EXTREME_MAX = (1 << 1),
/* Grouped keys have different states. */
KEYFRAME_EXTREME_MIXED = (1 << 2),
- /* Both neigbors are equal to this key. */
+ /* Both neighbors are equal to this key. */
KEYFRAME_EXTREME_FLAT = (1 << 3),
} eKeyframeExtremeDrawOpts;
diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h
index a893f03bd88..8f197fa9afe 100644
--- a/source/blender/editors/include/ED_keyframing.h
+++ b/source/blender/editors/include/ED_keyframing.h
@@ -113,8 +113,7 @@ int insert_vert_fcurve(
* Use this to insert a keyframe using the current value being keyframed, in the
* nominated F-Curve (no creation of animation data performed). Returns success.
*/
-bool insert_keyframe_direct(struct Depsgraph *depsgraph,
- struct ReportList *reports,
+bool insert_keyframe_direct(struct ReportList *reports,
struct PointerRNA ptr,
struct PropertyRNA *prop,
struct FCurve *fcu,
@@ -130,7 +129,6 @@ bool insert_keyframe_direct(struct Depsgraph *depsgraph,
* using the current value being keyframed, in the relevant place. Returns success.
*/
short insert_keyframe(struct Main *bmain,
- struct Depsgraph *depsgraph,
struct ReportList *reports,
struct ID *id,
struct bAction *act,
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h
index d2613facd83..5ebba4e5d25 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -254,7 +254,10 @@ void ED_operatormacros_mesh(void);
void ED_keymap_mesh(struct wmKeyConfig *keyconf);
/* editmesh_tools.c (could be moved) */
-void EDBM_project_snap_verts(struct bContext *C, struct ARegion *ar, struct BMEditMesh *em);
+void EDBM_project_snap_verts(struct bContext *C,
+ struct Depsgraph *depsgraph,
+ struct ARegion *ar,
+ struct BMEditMesh *em);
/* editface.c */
void paintface_flush_flags(struct bContext *C, struct Object *ob, short flag);
diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h
index 038f1bf52a6..5f9534a1f1c 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -166,13 +166,11 @@ void ED_object_vpaintmode_enter_ex(struct Main *bmain,
struct wmWindowManager *wm,
struct Scene *scene,
struct Object *ob);
-void ED_object_vpaintmode_enter(struct bContext *C);
void ED_object_wpaintmode_enter_ex(struct Main *bmain,
struct Depsgraph *depsgraph,
struct wmWindowManager *wm,
struct Scene *scene,
struct Object *ob);
-void ED_object_wpaintmode_enter(struct bContext *C);
void ED_object_vpaintmode_exit_ex(struct Object *ob);
void ED_object_vpaintmode_exit(struct bContext *C);
@@ -185,12 +183,10 @@ void ED_object_sculptmode_enter_ex(struct Main *bmain,
struct Object *ob,
const bool force_dyntopo,
struct ReportList *reports);
-void ED_object_sculptmode_enter(struct bContext *C, struct ReportList *reports);
void ED_object_sculptmode_exit_ex(struct Main *bmain,
struct Depsgraph *depsgraph,
struct Scene *scene,
struct Object *ob);
-void ED_object_sculptmode_exit(struct bContext *C);
void ED_object_location_from_view(struct bContext *C, float loc[3]);
void ED_object_rotation_from_quat(float rot[3], const float quat[4], const char align_axis);
@@ -271,7 +267,6 @@ bool ED_object_mode_compat_set(struct bContext *C,
struct ReportList *reports);
void ED_object_mode_toggle(struct bContext *C, eObjectMode mode);
void ED_object_mode_set(struct bContext *C, eObjectMode mode);
-void ED_object_mode_exit(struct bContext *C);
bool ED_object_mode_generic_enter(struct bContext *C, eObjectMode object_mode);
void ED_object_mode_generic_exit(struct Main *bmain,
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index 93268456277..081bcbf4746 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -76,6 +76,10 @@ enum eGPUFXFlags;
typedef struct ViewContext {
struct bContext *C;
struct Main *bmain;
+ /* Dependency graph is uses for depth drawing, viewport camera matrix access, and also some areas
+ * are re-using this to access evaluated entities.
+ *
+ * Moral of the story: assign to a fully evaluated state. */
struct Depsgraph *depsgraph;
struct Scene *scene;
struct ViewLayer *view_layer;
@@ -512,26 +516,6 @@ int view3d_opengl_select(struct ViewContext *vc,
eV3DSelectObjectFilter select_filter);
/* view3d_select.c */
-struct EDSelectID_Context;
-struct EDSelectID_Context *ED_view3d_select_id_context_create(struct ViewContext *vc,
- struct Base **bases,
- const uint bases_len,
- short select_mode);
-
-void ED_view3d_select_id_context_destroy(struct EDSelectID_Context *sel_id_ctx);
-void ED_view3d_select_id_validate_view_matrices(struct EDSelectID_Context *sel_id_ctx,
- struct ViewContext *vc);
-
-uint ED_view3d_select_id_context_offset_for_object_elem(
- const struct EDSelectID_Context *sel_id_ctx, int base_index, char elem_type);
-
-uint ED_view3d_select_id_context_elem_len(const struct EDSelectID_Context *sel_id_ctx);
-bool ED_view3d_select_id_elem_get(struct EDSelectID_Context *sel_id_ctx,
- const uint sel_id,
- uint *r_elem,
- uint *r_base_index,
- char *r_elem_type);
-
float ED_view3d_select_dist_px(void);
void ED_view3d_viewcontext_init(struct bContext *C, struct ViewContext *vc);
void ED_view3d_viewcontext_init_object(struct ViewContext *vc, struct Object *obact);
@@ -584,7 +568,7 @@ void ED_view3d_draw_offscreen(struct Depsgraph *depsgraph,
bool do_sky,
bool is_persp,
const char *viewname,
- const bool do_color_managment,
+ const bool do_color_management,
struct GPUOffScreen *ofs,
struct GPUViewport *viewport);
void ED_view3d_draw_setup_view(struct wmWindow *win,
diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h
index 47cf827ed66..03a49943ed3 100644
--- a/source/blender/editors/include/UI_icons.h
+++ b/source/blender/editors/include/UI_icons.h
@@ -90,8 +90,8 @@ DEF_ICON(COPY_ID)
DEF_ICON(EYEDROPPER)
DEF_ICON_BLANK(92)
DEF_ICON(AUTO)
-DEF_ICON(CHECKBOX_DEHLT) /* de-Hilight - Checkbox OFF */
-DEF_ICON(CHECKBOX_HLT) /* Hilight - Checkbox ON */
+DEF_ICON(CHECKBOX_DEHLT) /* de-Highlight - Checkbox OFF */
+DEF_ICON(CHECKBOX_HLT) /* Highlight - Checkbox ON */
DEF_ICON(UNLOCKED)
DEF_ICON(LOCKED)
DEF_ICON(UNPINNED)
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 3b2a80c1e05..5ef3e5d8987 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -562,7 +562,8 @@ int UI_popover_panel_invoke(struct bContext *C,
bool keep_open,
struct ReportList *reports);
-uiPopover *UI_popover_begin(struct bContext *C, int menu_width) ATTR_NONNULL(1);
+uiPopover *UI_popover_begin(struct bContext *C, int menu_width, bool from_active_button)
+ ATTR_NONNULL(1);
void UI_popover_end(struct bContext *C, struct uiPopover *head, struct wmKeyMap *keymap);
struct uiLayout *UI_popover_layout(uiPopover *head);
void UI_popover_once_clear(uiPopover *pup);
diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c
index 5ff200fa7e4..4d87cc22ef2 100644
--- a/source/blender/editors/interface/interface_anim.c
+++ b/source/blender/editors/interface/interface_anim.c
@@ -286,12 +286,11 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra)
if (special) {
/* NLA Strip property */
if (IS_AUTOKEY_ON(scene)) {
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
ReportList *reports = CTX_wm_reports(C);
ToolSettings *ts = scene->toolsettings;
insert_keyframe_direct(
- depsgraph, reports, but->rnapoin, but->rnaprop, fcu, cfra, ts->keyframe_type, NULL, 0);
+ reports, but->rnapoin, but->rnaprop, fcu, cfra, ts->keyframe_type, NULL, 0);
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
}
}
@@ -300,12 +299,10 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra)
* making it easier to set up corrective drivers
*/
if (IS_AUTOKEY_ON(scene)) {
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
ReportList *reports = CTX_wm_reports(C);
ToolSettings *ts = scene->toolsettings;
- insert_keyframe_direct(depsgraph,
- reports,
+ insert_keyframe_direct(reports,
but->rnapoin,
but->rnaprop,
fcu,
@@ -321,7 +318,6 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra)
/* TODO: this should probably respect the keyingset only option for anim */
if (autokeyframe_cfra_can_key(scene, id)) {
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
ReportList *reports = CTX_wm_reports(C);
ToolSettings *ts = scene->toolsettings;
short flag = ANIM_get_keyframing_flags(scene, 1);
@@ -333,7 +329,6 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra)
* E.g., color wheels (see T42567). */
BLI_assert((fcu->array_index == but->rnaindex) || (but->rnaindex == -1));
insert_keyframe(bmain,
- depsgraph,
reports,
id,
action,
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 7afdbe9d266..6a36bf364a3 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -1606,6 +1606,11 @@ void ui_draw_but_COLORBAND(uiBut *but, const uiWidgetColors *UNUSED(wcol), const
float sizey_solid = sizey * 0.25f;
float y1 = rect->ymin;
+ /* exit early if too narrow */
+ if (sizex <= 0) {
+ return;
+ }
+
GPUVertFormat *format = immVertexFormat();
pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
immBindBuiltinProgram(GPU_SHADER_2D_CHECKER);
diff --git a/source/blender/editors/interface/interface_eyedropper_depth.c b/source/blender/editors/interface/interface_eyedropper_depth.c
index fc60fc06ac0..2e51701e01d 100644
--- a/source/blender/editors/interface/interface_eyedropper_depth.c
+++ b/source/blender/editors/interface/interface_eyedropper_depth.c
@@ -168,7 +168,7 @@ static void depthdropper_depth_sample_pt(
if (sa->spacetype == SPACE_VIEW3D) {
ARegion *ar = BKE_area_find_region_xy(sa, RGN_TYPE_WINDOW, mx, my);
if (ar) {
- struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ struct Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
View3D *v3d = sa->spacedata.first;
RegionView3D *rv3d = ar->regiondata;
/* weak, we could pass in some reference point */
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index a7fc0cfec25..245277c8d22 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -10113,31 +10113,18 @@ static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *UNUSE
if (but) {
bScreen *screen = CTX_wm_screen(C);
- ARegion *ar_temp;
uiBut *but_other;
uiHandleButtonData *data;
- bool is_inside_menu = false;
-
- /* look for a popup menu containing the mouse */
- for (ar_temp = screen->regionbase.first; ar_temp; ar_temp = ar_temp->next) {
- rcti winrct;
-
- ui_region_winrct_get_no_margin(ar_temp, &winrct);
-
- if (BLI_rcti_isect_pt_v(&winrct, &event->x)) {
- BLI_assert(ar_temp->type->regionid == RGN_TYPE_TEMPORARY);
-
- is_inside_menu = true;
- break;
- }
- }
/* handle activated button events */
data = but->active;
if ((data->state == BUTTON_STATE_MENU_OPEN) &&
+ /* Make sure this popup isn't dragging a button.
+ * can happen with popovers (see T67882). */
+ (ui_region_find_active_but(data->menu->region) == NULL) &&
/* make sure mouse isn't inside another menu (see T43247) */
- (is_inside_menu == false) &&
+ (ui_screen_region_find_mouse_over(screen, event) == NULL) &&
(ELEM(but->type, UI_BTYPE_PULLDOWN, UI_BTYPE_POPOVER, UI_BTYPE_MENU)) &&
(but_other = ui_but_find_mouse_over(ar, event)) && (but != but_other) &&
(ELEM(but_other->type, UI_BTYPE_PULLDOWN, UI_BTYPE_POPOVER, UI_BTYPE_MENU))) {
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index ea5ef94d90d..7584a43a790 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -464,7 +464,7 @@ DEF_ICON_VECTOR_COLORSET_DRAW_NTH(20, 19)
# undef DEF_ICON_VECTOR_COLORSET_DRAW_NTH
/* Dynamically render icon instead of rendering a plain color to a texture/buffer
- * This is mot strictly a "vicon", as it needs access to icon->obj to get the color info,
+ * This is not strictly a "vicon", as it needs access to icon->obj to get the color info,
* but it works in a very similar way.
*/
static void vicon_gplayer_color_draw(Icon *icon, int x, int y, int w, int h)
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index fc65129ebf7..a5d9d35e2fe 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -938,6 +938,9 @@ uiBut *ui_region_find_active_but(struct ARegion *ar) ATTR_WARN_UNUSED_RESULT;
bool ui_region_contains_point_px(const struct ARegion *ar, int x, int y) ATTR_WARN_UNUSED_RESULT;
bool ui_region_contains_rect_px(const struct ARegion *ar, const rcti *rect_px);
+ARegion *ui_screen_region_find_mouse_over_ex(bScreen *screen, int x, int y);
+ARegion *ui_screen_region_find_mouse_over(bScreen *screen, const struct wmEvent *event);
+
/* interface_context_menu.c */
bool ui_popup_context_menu_for_button(struct bContext *C, uiBut *but);
void ui_popup_context_menu_for_panel(struct bContext *C, struct ARegion *ar, struct Panel *pa);
diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.c
index 462183b4245..d0efb3714bc 100644
--- a/source/blender/editors/interface/interface_query.c
+++ b/source/blender/editors/interface/interface_query.c
@@ -570,3 +570,29 @@ bool ui_region_contains_rect_px(const ARegion *ar, const rcti *rect_px)
}
/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Screen (#bScreen) Spatial
+ * \{ */
+
+/** Check if the cursor is over any popups. */
+ARegion *ui_screen_region_find_mouse_over_ex(bScreen *screen, int x, int y)
+{
+ for (ARegion *ar = screen->regionbase.first; ar; ar = ar->next) {
+ rcti winrct;
+
+ ui_region_winrct_get_no_margin(ar, &winrct);
+
+ if (BLI_rcti_isect_pt(&winrct, x, y)) {
+ return ar;
+ }
+ }
+ return NULL;
+}
+
+ARegion *ui_screen_region_find_mouse_over(bScreen *screen, const wmEvent *event)
+{
+ return ui_screen_region_find_mouse_over_ex(screen, event->x, event->y);
+}
+
+/** \} */
diff --git a/source/blender/editors/interface/interface_region_hud.c b/source/blender/editors/interface/interface_region_hud.c
index 43afdc534ad..54bdbe0ec6e 100644
--- a/source/blender/editors/interface/interface_region_hud.c
+++ b/source/blender/editors/interface/interface_region_hud.c
@@ -57,16 +57,32 @@
/* -------------------------------------------------------------------- */
/** \name Utilities
* \{ */
+struct HudRegionData {
+ short regionid;
+};
-static bool last_redo_poll(const bContext *C)
+static bool last_redo_poll(const bContext *C, short region_type)
{
wmOperator *op = WM_operator_last_redo(C);
if (op == NULL) {
return false;
}
+
bool success = false;
- if (WM_operator_repeat_check(C, op) && WM_operator_check_ui_empty(op->type) == false) {
- success = WM_operator_poll((bContext *)C, op->type);
+ {
+ /* Make sure that we are using the same region type as the original
+ * operator call. Otherwise we would be polling the operator with the
+ * wrong context.
+ */
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *ar_op = (region_type != -1) ? BKE_area_find_region_type(sa, region_type) : NULL;
+ ARegion *ar_prev = CTX_wm_region(C);
+ CTX_wm_region_set((bContext *)C, ar_op);
+
+ if (WM_operator_repeat_check(C, op) && WM_operator_check_ui_empty(op->type) == false) {
+ success = WM_operator_poll((bContext *)C, op->type);
+ }
+ CTX_wm_region_set((bContext *)C, ar_prev);
}
return success;
}
@@ -87,7 +103,15 @@ static void hud_region_hide(ARegion *ar)
static bool hud_panel_operator_redo_poll(const bContext *C, PanelType *UNUSED(pt))
{
- return last_redo_poll(C);
+ ScrArea *sa = CTX_wm_area(C);
+ ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_HUD);
+ if (ar != NULL) {
+ struct HudRegionData *hrd = ar->regiondata;
+ if (hrd != NULL) {
+ return last_redo_poll(C, hrd->regionid);
+ }
+ }
+ return false;
}
static void hud_panel_operator_redo_draw_header(const bContext *C, Panel *pa)
@@ -132,10 +156,6 @@ static void hud_panels_register(ARegionType *art, int space_type, int region_typ
/** \name Callbacks for Floating Region
* \{ */
-struct HudRegionData {
- short regionid;
-};
-
static void hud_region_init(wmWindowManager *wm, ARegion *ar)
{
ED_region_panels_init(wm, ar);
@@ -150,21 +170,8 @@ static void hud_region_free(ARegion *ar)
static void hud_region_layout(const bContext *C, ARegion *ar)
{
- bool ok = false;
-
- {
- struct HudRegionData *hrd = ar->regiondata;
- if (hrd != NULL) {
- ScrArea *sa = CTX_wm_area(C);
- ARegion *ar_op = (hrd->regionid != -1) ? BKE_area_find_region_type(sa, hrd->regionid) : NULL;
- ARegion *ar_prev = CTX_wm_region(C);
- CTX_wm_region_set((bContext *)C, ar_op);
- ok = last_redo_poll(C);
- CTX_wm_region_set((bContext *)C, ar_prev);
- }
- }
-
- if (!ok) {
+ struct HudRegionData *hrd = ar->regiondata;
+ if (hrd == NULL || !last_redo_poll(C, hrd->regionid)) {
ED_region_tag_redraw(ar);
hud_region_hide(ar);
return;
@@ -301,7 +308,9 @@ void ED_area_type_hud_ensure(bContext *C, ScrArea *sa)
bool init = false;
bool was_hidden = ar == NULL || ar->visible == false;
- if (!last_redo_poll(C)) {
+ ARegion *ar_op = CTX_wm_region(C);
+ BLI_assert((ar_op == NULL) || (ar_op->regiontype != RGN_TYPE_HUD));
+ if (!last_redo_poll(C, ar_op ? ar_op->regiontype : -1)) {
if (ar) {
ED_region_tag_redraw(ar);
hud_region_hide(ar);
@@ -328,8 +337,6 @@ void ED_area_type_hud_ensure(bContext *C, ScrArea *sa)
}
{
- ARegion *ar_op = CTX_wm_region(C);
- BLI_assert((ar_op == NULL) || (ar_op->regiontype != RGN_TYPE_HUD));
struct HudRegionData *hrd = ar->regiondata;
if (hrd == NULL) {
hrd = MEM_callocN(sizeof(*hrd), __func__);
diff --git a/source/blender/editors/interface/interface_region_popover.c b/source/blender/editors/interface/interface_region_popover.c
index 53c96fb72a7..028d99ac052 100644
--- a/source/blender/editors/interface/interface_region_popover.c
+++ b/source/blender/editors/interface/interface_region_popover.c
@@ -72,6 +72,7 @@ struct uiPopover {
uiBlock *block;
uiLayout *layout;
uiBut *but;
+ ARegion *butregion;
/* Needed for keymap removal. */
wmWindow *window;
@@ -325,7 +326,7 @@ int UI_popover_panel_invoke(bContext *C, const char *idname, bool keep_open, Rep
block = pup->block;
}
else {
- uiPopover *pup = UI_popover_begin(C, U.widget_unit * pt->ui_units_x);
+ uiPopover *pup = UI_popover_begin(C, U.widget_unit * pt->ui_units_x, false);
layout = UI_popover_layout(pup);
UI_paneltype_draw(C, pt, layout);
UI_popover_end(C, pup, NULL);
@@ -346,8 +347,11 @@ int UI_popover_panel_invoke(bContext *C, const char *idname, bool keep_open, Rep
/**
* Only return handler, and set optional title.
+ *
+ * \param from_active_button: Use the active button for positioning,
+ * use when the popover is activated from an operator instead of directly from the button.
*/
-uiPopover *UI_popover_begin(bContext *C, int ui_size_x)
+uiPopover *UI_popover_begin(bContext *C, int ui_size_x, bool from_active_button)
{
uiPopover *pup = MEM_callocN(sizeof(uiPopover), "popover menu");
if (ui_size_x == 0) {
@@ -355,6 +359,20 @@ uiPopover *UI_popover_begin(bContext *C, int ui_size_x)
}
pup->ui_size_x = ui_size_x;
+ ARegion *butregion = NULL;
+ uiBut *but = NULL;
+
+ if (from_active_button) {
+ butregion = CTX_wm_region(C);
+ but = UI_region_active_but_get(butregion);
+ if (but == NULL) {
+ butregion = NULL;
+ }
+ }
+
+ pup->but = but;
+ pup->butregion = butregion;
+
/* Operator context default same as menus, change if needed. */
ui_popover_create_block(C, pup, WM_OP_EXEC_REGION_WIN);
@@ -387,7 +405,7 @@ void UI_popover_end(bContext *C, uiPopover *pup, wmKeyMap *keymap)
}
handle = ui_popup_block_create(
- C, NULL, NULL, NULL, ui_block_func_POPOVER, pup, ui_block_free_func_POPOVER);
+ C, pup->butregion, pup->but, NULL, ui_block_func_POPOVER, pup, ui_block_free_func_POPOVER);
/* Add handlers. */
UI_popup_handlers_add(C, &window->modalhandlers, handle, 0);
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index 7d9b722fcc0..b57d100127e 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -31,6 +31,7 @@
#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
#include "BLI_math_base.h"
+#include "BLI_math_vector.h"
#include "BKE_context.h"
@@ -1146,33 +1147,49 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, const wmEvent *event
}
else if (event->type == MOUSEMOVE) {
float dx, dy;
+ float zoomfac = 0.01f;
+
+ /* some view2d's (graph) don't have min/max zoom, or extreme ones */
+ if (v2d->maxzoom > 0.0f) {
+ zoomfac = clamp_f(0.001f * v2d->maxzoom, 0.001f, 0.01f);
+ }
/* calculate new delta transform, based on zooming mode */
if (U.viewzoom == USER_ZOOM_SCALE) {
/* 'scale' zooming */
float dist;
+ float len_old[2];
+ float len_new[2];
/* x-axis transform */
dist = BLI_rcti_size_x(&v2d->mask) / 2.0f;
- dx = 1.0f - (fabsf(vzd->lastx - vzd->ar->winrct.xmin - dist) + 2.0f) /
- (fabsf(event->mval[0] - dist) + 2.0f);
- dx *= 0.5f * BLI_rctf_size_x(&v2d->cur);
+ len_old[0] = fabsf(vzd->lastx - vzd->ar->winrct.xmin - dist);
+ len_new[0] = fabsf(event->x - vzd->ar->winrct.xmin - dist);
+
+ len_old[0] *= zoomfac * BLI_rctf_size_x(&v2d->cur);
+ len_new[0] *= zoomfac * BLI_rctf_size_x(&v2d->cur);
/* y-axis transform */
dist = BLI_rcti_size_y(&v2d->mask) / 2.0f;
- dy = 1.0f - (fabsf(vzd->lasty - vzd->ar->winrct.ymin - dist) + 2.0f) /
- (fabsf(event->mval[1] - dist) + 2.0f);
- dy *= 0.5f * BLI_rctf_size_y(&v2d->cur);
+ len_old[1] = fabsf(vzd->lasty - vzd->ar->winrct.ymin - dist);
+ len_new[1] = fabsf(event->y - vzd->ar->winrct.ymin - dist);
+
+ len_old[1] *= zoomfac * BLI_rctf_size_y(&v2d->cur);
+ len_new[1] *= zoomfac * BLI_rctf_size_y(&v2d->cur);
+
+ /* Calculate distance */
+ if (v2d->keepzoom & V2D_KEEPASPECT) {
+ dist = len_v2(len_new) - len_v2(len_old);
+ dx = dy = dist;
+ }
+ else {
+ dx = len_new[0] - len_old[0];
+ dy = len_new[1] - len_old[1];
+ }
}
else {
/* 'continuous' or 'dolly' */
- float fac, zoomfac = 0.01f;
-
- /* some view2d's (graph) don't have min/max zoom, or extreme ones */
- if (v2d->maxzoom > 0.0f) {
- zoomfac = clamp_f(0.001f * v2d->maxzoom, 0.001f, 0.01f);
- }
-
+ float fac;
/* x-axis transform */
fac = zoomfac * (event->x - vzd->lastx);
dx = fac * BLI_rctf_size_x(&v2d->cur);
@@ -1180,6 +1197,18 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, const wmEvent *event
/* y-axis transform */
fac = zoomfac * (event->y - vzd->lasty);
dy = fac * BLI_rctf_size_y(&v2d->cur);
+
+ /* Only respect user setting zoom axis if the view does not have any zoom restrictions
+ * any will be scaled uniformly */
+ if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0 && (v2d->keepzoom & V2D_LOCKZOOM_Y) == 0 &&
+ (v2d->keepzoom & V2D_KEEPASPECT)) {
+ if (U.uiflag & USER_ZOOM_HORIZ) {
+ dy = 0;
+ }
+ else {
+ dx = 0;
+ }
+ }
}
/* support zoom to always zoom entirely - the v2d code uses portrait or
diff --git a/source/blender/editors/io/io_cache.c b/source/blender/editors/io/io_cache.c
index 9fdcec71cfd..ff2bc72c2f7 100644
--- a/source/blender/editors/io/io_cache.c
+++ b/source/blender/editors/io/io_cache.c
@@ -147,7 +147,7 @@ static int cachefile_reload_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
}
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
BKE_cachefile_reload(depsgraph, cache_file);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c
index 883dfe9ad7c..683e6d8a2b0 100644
--- a/source/blender/editors/mask/mask_add.c
+++ b/source/blender/editors/mask/mask_add.c
@@ -72,7 +72,7 @@ bool ED_mask_find_nearest_diff_point(const bContext *C,
float u = 0.0f;
float scalex, scaley;
- Depsgraph *depsgraph = CTX_data_evaluated_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Mask *mask_eval = (Mask *)DEG_get_evaluated_id(depsgraph, &mask_orig->id);
ED_mask_get_size(sa, &width, &height);
diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c
index 8e4efddd8a7..c91f431ad20 100644
--- a/source/blender/editors/mask/mask_ops.c
+++ b/source/blender/editors/mask/mask_ops.c
@@ -86,7 +86,7 @@ MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C,
eMaskWhichHandle which_handle = MASK_WHICH_HANDLE_NONE;
int width, height;
- Depsgraph *depsgraph = CTX_data_evaluated_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Mask *mask_eval = (Mask *)DEG_get_evaluated_id(depsgraph, &mask_orig->id);
ED_mask_get_size(sa, &width, &height);
@@ -241,7 +241,7 @@ bool ED_mask_feather_find_nearest(const bContext *C,
float scalex, scaley;
int width, height;
- Depsgraph *depsgraph = CTX_data_evaluated_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Mask *mask_eval = (Mask *)DEG_get_evaluated_id(depsgraph, &mask_orig->id);
ED_mask_get_size(sa, &width, &height);
diff --git a/source/blender/editors/mesh/CMakeLists.txt b/source/blender/editors/mesh/CMakeLists.txt
index 57bf67e825e..9a779db4812 100644
--- a/source/blender/editors/mesh/CMakeLists.txt
+++ b/source/blender/editors/mesh/CMakeLists.txt
@@ -23,6 +23,7 @@ set(INC
../../blentranslation
../../bmesh
../../depsgraph
+ ../../draw
../../gpu
../../imbuf
../../makesdna
diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c
index d61c340f7a2..9a70b0a8d36 100644
--- a/source/blender/editors/mesh/editface.c
+++ b/source/blender/editors/mesh/editface.c
@@ -77,7 +77,7 @@ void paintface_flush_flags(struct bContext *C, Object *ob, short flag)
BKE_mesh_flush_select_from_polys(me);
}
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
if (ob_eval == NULL) {
diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c
index 0da4d20c6b5..5b16cfd00f5 100644
--- a/source/blender/editors/mesh/editmesh_extrude.c
+++ b/source/blender/editors/mesh/editmesh_extrude.c
@@ -658,6 +658,7 @@ void MESH_OT_extrude_faces_indiv(wmOperatorType *ot)
static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
+ struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ViewContext vc;
BMVert *v1;
BMIter iter;
@@ -819,7 +820,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w
/* also project the source, for retopo workflow */
if (use_proj) {
- EDBM_project_snap_verts(C, vc.ar, vc.em);
+ EDBM_project_snap_verts(C, depsgraph, vc.ar, vc.em);
}
}
@@ -852,7 +853,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w
}
if (use_proj) {
- EDBM_project_snap_verts(C, vc.ar, vc.em);
+ EDBM_project_snap_verts(C, depsgraph, vc.ar, vc.em);
}
/* This normally happens when pushing undo but modal operators
diff --git a/source/blender/editors/mesh/editmesh_knife_project.c b/source/blender/editors/mesh/editmesh_knife_project.c
index 13bcb1334a9..3d34a4ad3b5 100644
--- a/source/blender/editors/mesh/editmesh_knife_project.c
+++ b/source/blender/editors/mesh/editmesh_knife_project.c
@@ -57,7 +57,7 @@ static LinkNode *knifeproject_poly_from_object(const bContext *C,
Object *ob,
LinkNode *polys)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ARegion *ar = CTX_wm_region(C);
struct Mesh *me_eval;
bool me_eval_needs_free;
@@ -173,7 +173,7 @@ void MESH_OT_knife_project(wmOperatorType *ot)
ot->poll = ED_operator_editmesh_region_view3d;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_USE_EVAL_DATA;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* parameters */
RNA_def_boolean(ot->srna,
diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c
index c7606758b63..2ddd654f824 100644
--- a/source/blender/editors/mesh/editmesh_loopcut.c
+++ b/source/blender/editors/mesh/editmesh_loopcut.c
@@ -272,7 +272,7 @@ static int ringsel_init(bContext *C, wmOperator *op, bool do_cut)
em_setup_viewcontext(C, &lcd->vc);
- lcd->depsgraph = CTX_data_depsgraph(C);
+ lcd->depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
/* assign the drawing handle for drawing preview line... */
lcd->ar = CTX_wm_region(C);
diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c
index 7b770f055b4..12b5a36c510 100644
--- a/source/blender/editors/mesh/editmesh_select.c
+++ b/source/blender/editors/mesh/editmesh_select.c
@@ -68,6 +68,8 @@
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
+#include "DRW_engine.h"
+
#include "mesh_intern.h" /* own include */
/* use bmesh operator flags for a few operators */
@@ -197,15 +199,11 @@ void EDBM_automerge(Scene *scene, Object *obedit, bool update, const char hflag)
/** \name Back-Buffer OpenGL Selection
* \{ */
-static BMElem *EDBM_select_id_bm_elem_get(struct EDSelectID_Context *sel_id_ctx,
- Base **bases,
- const uint sel_id,
- uint *r_base_index)
+static BMElem *edbm_select_id_bm_elem_get(Base **bases, const uint sel_id, uint *r_base_index)
{
uint elem_id;
char elem_type = 0;
- bool success = ED_view3d_select_id_elem_get(
- sel_id_ctx, sel_id, &elem_id, r_base_index, &elem_type);
+ bool success = DRW_select_elem_get(sel_id, &elem_id, r_base_index, &elem_type);
if (success) {
Object *obedit = bases[*r_base_index]->object;
@@ -335,20 +333,17 @@ BMVert *EDBM_vert_find_nearest_ex(ViewContext *vc,
{
FAKE_SELECT_MODE_BEGIN(vc, fake_select_mode, select_mode, SCE_SELECT_VERTEX);
- struct EDSelectID_Context *sel_id_ctx = ED_view3d_select_id_context_create(
- vc, bases, bases_len, select_mode);
+ DRW_draw_select_id(vc->depsgraph, vc->ar, vc->v3d, bases, bases_len, select_mode);
index = ED_select_buffer_find_nearest_to_point(vc->mval, 1, UINT_MAX, &dist_px);
if (index) {
- eve = (BMVert *)EDBM_select_id_bm_elem_get(sel_id_ctx, bases, index, &base_index);
+ eve = (BMVert *)edbm_select_id_bm_elem_get(bases, index, &base_index);
}
else {
eve = NULL;
}
- ED_view3d_select_id_context_destroy(sel_id_ctx);
-
FAKE_SELECT_MODE_END(vc, fake_select_mode);
}
@@ -564,20 +559,17 @@ BMEdge *EDBM_edge_find_nearest_ex(ViewContext *vc,
{
FAKE_SELECT_MODE_BEGIN(vc, fake_select_mode, select_mode, SCE_SELECT_EDGE);
- struct EDSelectID_Context *sel_id_ctx = ED_view3d_select_id_context_create(
- vc, bases, bases_len, select_mode);
+ DRW_draw_select_id(vc->depsgraph, vc->ar, vc->v3d, bases, bases_len, select_mode);
index = ED_select_buffer_find_nearest_to_point(vc->mval, 1, UINT_MAX, &dist_px);
if (index) {
- eed = (BMEdge *)EDBM_select_id_bm_elem_get(sel_id_ctx, bases, index, &base_index);
+ eed = (BMEdge *)edbm_select_id_bm_elem_get(bases, index, &base_index);
}
else {
eed = NULL;
}
- ED_view3d_select_id_context_destroy(sel_id_ctx);
-
FAKE_SELECT_MODE_END(vc, fake_select_mode);
}
@@ -777,20 +769,17 @@ BMFace *EDBM_face_find_nearest_ex(ViewContext *vc,
{
FAKE_SELECT_MODE_BEGIN(vc, fake_select_mode, select_mode, SCE_SELECT_FACE);
- struct EDSelectID_Context *sel_id_ctx = ED_view3d_select_id_context_create(
- vc, bases, bases_len, select_mode);
+ DRW_draw_select_id(vc->depsgraph, vc->ar, vc->v3d, bases, bases_len, select_mode);
index = ED_select_buffer_sample_point(vc->mval);
if (index) {
- efa = (BMFace *)EDBM_select_id_bm_elem_get(sel_id_ctx, bases, index, &base_index);
+ efa = (BMFace *)edbm_select_id_bm_elem_get(bases, index, &base_index);
}
else {
efa = NULL;
}
- ED_view3d_select_id_context_destroy(sel_id_ctx);
-
FAKE_SELECT_MODE_END(vc, fake_select_mode);
}
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 919de4cdb20..ecdf103e6eb 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -411,7 +411,7 @@ void MESH_OT_unsubdivide(wmOperatorType *ot)
ot->srna, "iterations", 2, 1, 1000, "Iterations", "Number of times to unsubdivide", 1, 100);
}
-void EDBM_project_snap_verts(bContext *C, ARegion *ar, BMEditMesh *em)
+void EDBM_project_snap_verts(bContext *C, Depsgraph *depsgraph, ARegion *ar, BMEditMesh *em)
{
Main *bmain = CTX_data_main(C);
Object *obedit = em->ob;
@@ -421,7 +421,7 @@ void EDBM_project_snap_verts(bContext *C, ARegion *ar, BMEditMesh *em)
ED_view3d_init_mats_rv3d(obedit, ar->regiondata);
struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d(
- bmain, CTX_data_scene(C), CTX_data_depsgraph(C), 0, ar, CTX_wm_view3d(C));
+ bmain, CTX_data_scene(C), depsgraph, 0, ar, CTX_wm_view3d(C));
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
@@ -4593,7 +4593,8 @@ static int edbm_fill_grid_exec(bContext *C, wmOperator *op)
/* Only reuse on redo because these settings need to match the current selection.
* We never want to use them on other geometry, repeat last for eg, see: T60777. */
- if ((op->flag & OP_IS_REPEAT_LAST) == 0 && RNA_property_is_set(op->ptr, prop_span)) {
+ if (((op->flag & OP_IS_INVOKE) || (op->flag & OP_IS_REPEAT_LAST) == 0) &&
+ RNA_property_is_set(op->ptr, prop_span)) {
span = RNA_property_int_get(op->ptr, prop_span);
span = min_ii(span, (clamp / 2) - 1);
calc_span = false;
@@ -8615,7 +8616,7 @@ static int edbm_normals_tools_exec(bContext *C, wmOperator *op)
switch (mode) {
case EDBM_CLNOR_TOOLS_COPY:
- if (bm->totfacesel == 0 || bm->totvertsel == 0) {
+ if (bm->totfacesel == 0 && bm->totvertsel == 0) {
BM_loop_normal_editdata_array_free(lnors_ed_arr);
continue;
}
diff --git a/source/blender/editors/mesh/editmesh_undo.c b/source/blender/editors/mesh/editmesh_undo.c
index e823fb46140..7071258d8cf 100644
--- a/source/blender/editors/mesh/editmesh_undo.c
+++ b/source/blender/editors/mesh/editmesh_undo.c
@@ -699,7 +699,6 @@ typedef struct MeshUndoStep_Elem {
typedef struct MeshUndoStep {
UndoStep step;
- struct UndoIDPtrMap *id_map;
MeshUndoStep_Elem *elems;
uint elems_len;
} MeshUndoStep;
@@ -788,10 +787,6 @@ static void mesh_undosys_step_free(UndoStep *us_p)
undomesh_free_data(&elem->data);
}
MEM_freeN(us->elems);
-
- if (us->id_map != NULL) {
- BKE_undosys_ID_map_destroy(us->id_map);
- }
}
static void mesh_undosys_foreach_ID_ref(UndoStep *us_p,
@@ -804,10 +799,6 @@ static void mesh_undosys_foreach_ID_ref(UndoStep *us_p,
MeshUndoStep_Elem *elem = &us->elems[i];
foreach_ID_ref_fn(user_data, ((UndoRefID *)&elem->obedit_ref));
}
-
- if (us->id_map != NULL) {
- BKE_undosys_ID_map_foreach_ID_ref(us->id_map, foreach_ID_ref_fn, user_data);
- }
}
/* Export for ED_undo_sys. */
diff --git a/source/blender/editors/mesh/mesh_mirror.c b/source/blender/editors/mesh/mesh_mirror.c
index d76801a2500..e086eda9b33 100644
--- a/source/blender/editors/mesh/mesh_mirror.c
+++ b/source/blender/editors/mesh/mesh_mirror.c
@@ -278,7 +278,7 @@ void ED_mesh_mirrtopo_init(Mesh *me,
}
if ((tot_unique <= tot_unique_prev) && (tot_unique_edges <= tot_unique_edges_prev)) {
- /* Finish searching for unique values when 1 loop dosn't give a
+ /* Finish searching for unique values when 1 loop doesn't give a
* higher number of unique values compared to the previous loop. */
break;
}
diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c
index 41736fb9a14..b082af352b2 100644
--- a/source/blender/editors/mesh/meshtools.c
+++ b/source/blender/editors/mesh/meshtools.c
@@ -311,7 +311,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
/* count & check */
CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) {
@@ -674,7 +674,7 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
Object *ob_active = CTX_data_active_object(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Mesh *me = (Mesh *)ob_active->data;
Mesh *selme = NULL;
Mesh *me_deformed = NULL;
@@ -1165,7 +1165,7 @@ static void ed_mesh_pick_face_vert__mpoly_find(
bool ED_mesh_pick_face_vert(
bContext *C, Object *ob, const int mval[2], uint dist_px, uint *r_index)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
unsigned int poly_index;
Mesh *me = ob->data;
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index f8cf55933aa..137af917f9a 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -236,7 +236,7 @@ void ED_object_base_init_transform(bContext *C, Base *base, const float loc[3],
{
Object *ob = base->object;
Scene *scene = CTX_data_scene(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
if (!scene) {
return;
@@ -250,7 +250,11 @@ void ED_object_base_init_transform(bContext *C, Base *base, const float loc[3],
copy_v3_v3(ob->rot, rot);
}
- BKE_object_where_is_calc(depsgraph, scene, ob);
+ Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
+ Object *object_eval = DEG_get_evaluated_object(depsgraph, ob);
+ BKE_object_transform_copy(object_eval, ob);
+ BKE_object_where_is_calc(depsgraph, scene_eval, object_eval);
+ BKE_object_transform_copy(ob, object_eval);
}
/* Uses context to figure out transform for primitive.
@@ -1758,12 +1762,15 @@ static bool dupliobject_instancer_cmp(const void *a_, const void *b_)
return false;
}
-static void make_object_duplilist_real(
- bContext *C, Scene *scene, Base *base, const bool use_base_parent, const bool use_hierarchy)
+static void make_object_duplilist_real(bContext *C,
+ Depsgraph *depsgraph,
+ Scene *scene,
+ Base *base,
+ const bool use_base_parent,
+ const bool use_hierarchy)
{
Main *bmain = CTX_data_main(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
ListBase *lb_duplis;
DupliObject *dob;
GHash *dupli_gh, *parent_gh = NULL, *instancer_gh = NULL;
@@ -1955,6 +1962,7 @@ static void make_object_duplilist_real(
static int object_duplicates_make_real_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene = CTX_data_scene(C);
const bool use_base_parent = RNA_boolean_get(op->ptr, "use_base_parent");
@@ -1963,7 +1971,7 @@ static int object_duplicates_make_real_exec(bContext *C, wmOperator *op)
BKE_main_id_clear_newpoins(bmain);
CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) {
- make_object_duplilist_real(C, scene, base, use_base_parent, use_hierarchy);
+ make_object_duplilist_real(C, depsgraph, scene, base, use_base_parent, use_hierarchy);
/* dependencies were changed */
WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, base->object);
@@ -1990,7 +1998,7 @@ void OBJECT_OT_duplicates_make_real(wmOperatorType *ot)
ot->poll = ED_operator_objectmode;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(ot->srna,
"use_base_parent",
@@ -2131,7 +2139,7 @@ static Base *duplibase_for_convert(
static int convert_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
- Depsgraph *depsgraph = CTX_data_evaluated_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Base *basen = NULL, *basact = NULL;
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index 5ef133e87de..7343dba420f 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -864,13 +864,12 @@ void CONSTRAINT_OT_limitdistance_reset(wmOperatorType *ot)
/* ------------- Child-Of Constraint ------------------ */
static void child_get_inverse_matrix_owner_bone(
- const bContext *C, wmOperator *op, Scene *scene, Object *ob, float invmat[4][4])
+ Depsgraph *depsgraph, wmOperator *op, Scene *scene, Object *ob, float invmat[4][4])
{
/* For bone owner we want to do this in evaluated domain.
* BKE_pose_where_is / BKE_pose_where_is_bone relies on (re)evaluating parts of the scene
* and copying new evaluated stuff back to original.
*/
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
bConstraint *con_eval = edit_constraint_property_get(op, ob_eval, CONSTRAINT_TYPE_CHILDOF);
@@ -947,9 +946,8 @@ static void child_get_inverse_matrix_owner_bone(
}
static void child_get_inverse_matrix_owner_object(
- const bContext *C, Scene *scene, Object *ob, bConstraint *con, float invmat[4][4])
+ Depsgraph *depsgraph, Scene *scene, Object *ob, bConstraint *con, float invmat[4][4])
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
/* nullify inverse matrix first */
unit_m4(invmat);
@@ -971,6 +969,7 @@ static void child_get_inverse_matrix_owner_object(
static int childof_set_inverse_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene = CTX_data_scene(C);
Object *ob = ED_object_active_context(C);
bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_CHILDOF);
@@ -985,10 +984,10 @@ static int childof_set_inverse_exec(bContext *C, wmOperator *op)
}
if (owner == EDIT_CONSTRAINT_OWNER_OBJECT) {
- child_get_inverse_matrix_owner_object(C, scene, ob, con, data->invmat);
+ child_get_inverse_matrix_owner_object(depsgraph, scene, ob, con, data->invmat);
}
else if (owner == EDIT_CONSTRAINT_OWNER_BONE) {
- child_get_inverse_matrix_owner_bone(C, op, scene, ob, data->invmat);
+ child_get_inverse_matrix_owner_bone(depsgraph, op, scene, ob, data->invmat);
}
ED_object_constraint_update(bmain, ob);
@@ -1224,6 +1223,7 @@ void CONSTRAINT_OT_followpath_path_animate(wmOperatorType *ot)
static int objectsolver_set_inverse_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene = CTX_data_scene(C);
Object *ob = ED_object_active_context(C);
bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_OBJECTSOLVER);
@@ -1238,10 +1238,10 @@ static int objectsolver_set_inverse_exec(bContext *C, wmOperator *op)
}
if (owner == EDIT_CONSTRAINT_OWNER_OBJECT) {
- child_get_inverse_matrix_owner_object(C, scene, ob, con, data->invmat);
+ child_get_inverse_matrix_owner_object(depsgraph, scene, ob, con, data->invmat);
}
else if (owner == EDIT_CONSTRAINT_OWNER_BONE) {
- child_get_inverse_matrix_owner_bone(C, op, scene, ob, data->invmat);
+ child_get_inverse_matrix_owner_bone(depsgraph, op, scene, ob, data->invmat);
}
ED_object_constraint_update(bmain, ob);
diff --git a/source/blender/editors/object/object_data_transfer.c b/source/blender/editors/object/object_data_transfer.c
index 690bc270605..79aafc6978f 100644
--- a/source/blender/editors/object/object_data_transfer.c
+++ b/source/blender/editors/object/object_data_transfer.c
@@ -111,8 +111,6 @@ static const EnumPropertyItem *dt_layers_select_src_itemf(bContext *C,
int totitem = 0;
const int data_type = RNA_enum_get(ptr, "data_type");
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
-
PropertyRNA *prop = RNA_struct_find_property(ptr, "use_reverse_transfer");
const bool reverse_transfer = prop != NULL && RNA_property_boolean_get(ptr, prop);
const int layers_select_dst = reverse_transfer ? RNA_enum_get(ptr, "layers_select_src") :
@@ -158,6 +156,7 @@ static const EnumPropertyItem *dt_layers_select_src_itemf(bContext *C,
Mesh *me_eval;
int num_data, i;
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Object *ob_src_eval = DEG_get_evaluated_object(depsgraph, ob_src);
@@ -183,6 +182,7 @@ static const EnumPropertyItem *dt_layers_select_src_itemf(bContext *C,
Mesh *me_eval;
int num_data, i;
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Object *ob_src_eval = DEG_get_evaluated_object(depsgraph, ob_src);
@@ -397,7 +397,7 @@ static bool data_transfer_exec_is_object_valid(wmOperator *op,
static int data_transfer_exec(bContext *C, wmOperator *op)
{
Object *ob_src = ED_object_active_context(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
ListBase ctx_objects;
@@ -613,7 +613,7 @@ void OBJECT_OT_data_transfer(wmOperatorType *ot)
ot->check = data_transfer_check;
/* Flags.*/
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* Properties.*/
prop = RNA_def_boolean(ot->srna,
@@ -760,14 +760,14 @@ void OBJECT_OT_data_transfer(wmOperatorType *ot)
static bool datalayout_transfer_poll(bContext *C)
{
- return (edit_modifier_poll_generic(C, &RNA_DataTransferModifier, (1 << OB_MESH)) ||
+ return (edit_modifier_poll_generic(C, &RNA_DataTransferModifier, (1 << OB_MESH), true) ||
data_transfer_poll(C));
}
static int datalayout_transfer_exec(bContext *C, wmOperator *op)
{
Object *ob_act = ED_object_active_context(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
DataTransferModifierData *dtmd;
@@ -873,7 +873,7 @@ void OBJECT_OT_datalayout_transfer(wmOperatorType *ot)
ot->check = data_transfer_check;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* Properties.*/
edit_modifier_properties(ot);
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index a390cf67cf5..ed40a4eb948 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -906,7 +906,9 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene, bool current_frame_
}
Main *bmain = CTX_data_main(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ /* NOTE: Dependency graph will be evaluated at all the frames, but we first need to access some
+ * nested pointers, like animation data. */
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ListBase targets = {NULL, NULL};
/* loop over objects in scene */
@@ -1056,7 +1058,7 @@ void OBJECT_OT_paths_update(wmOperatorType *ot)
ot->idname = "OBJECT_OT_paths_update";
ot->description = "Recalculate paths for selected objects";
- /* api callbakcs */
+ /* api callbacks */
ot->exec = object_update_paths_exec;
ot->poll = object_update_paths_poll;
diff --git a/source/blender/editors/object/object_gpencil_modifier.c b/source/blender/editors/object/object_gpencil_modifier.c
index 5c4fa5aeee6..075cd5acad6 100644
--- a/source/blender/editors/object/object_gpencil_modifier.c
+++ b/source/blender/editors/object/object_gpencil_modifier.c
@@ -596,7 +596,7 @@ void OBJECT_OT_gpencil_modifier_move_down(wmOperatorType *ot)
static int gpencil_modifier_apply_exec(bContext *C, wmOperator *op)
{
Main *bmain = CTX_data_main(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Object *ob = ED_object_active_context(C);
GpencilModifierData *md = gpencil_edit_modifier_property_get(op, ob, 0);
int apply_as = RNA_enum_get(op->ptr, "apply_as");
diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c
index c939cb0a61d..15c5ea40991 100644
--- a/source/blender/editors/object/object_hook.c
+++ b/source/blender/editors/object/object_hook.c
@@ -52,6 +52,7 @@
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
+#include "DEG_depsgraph_query.h"
#include "RNA_define.h"
#include "RNA_access.h"
@@ -527,6 +528,7 @@ static int add_hook_object(const bContext *C,
int mode,
ReportList *reports)
{
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ModifierData *md = NULL;
HookModifierData *hmd = NULL;
float cent[3];
@@ -601,11 +603,14 @@ static int add_hook_object(const bContext *C,
/* matrix calculus */
/* vert x (obmat x hook->imat) x hook->obmat x ob->imat */
/* (parentinv ) */
- BKE_object_where_is_calc(CTX_data_depsgraph(C), scene, ob);
+ Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
+ Object *object_eval = DEG_get_evaluated_object(depsgraph, ob);
+ BKE_object_transform_copy(object_eval, ob);
+ BKE_object_where_is_calc(depsgraph, scene_eval, object_eval);
- invert_m4_m4(ob->imat, ob->obmat);
+ invert_m4_m4(object_eval->imat, object_eval->obmat);
/* apparently this call goes from right to left... */
- mul_m4_series(hmd->parentinv, pose_mat, ob->imat, obedit->obmat);
+ mul_m4_series(hmd->parentinv, pose_mat, object_eval->imat, obedit->obmat);
DEG_relations_tag_update(bmain);
diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h
index b9350052093..e697c25b37f 100644
--- a/source/blender/editors/object/object_intern.h
+++ b/source/blender/editors/object/object_intern.h
@@ -137,7 +137,10 @@ void COLLECTION_OT_objects_add_active(struct wmOperatorType *ot);
void COLLECTION_OT_objects_remove_active(struct wmOperatorType *ot);
/* object_modifier.c */
-bool edit_modifier_poll_generic(struct bContext *C, struct StructRNA *rna_type, int obtype_flag);
+bool edit_modifier_poll_generic(struct bContext *C,
+ struct StructRNA *rna_type,
+ int obtype_flag,
+ const bool is_editmode_allowed);
bool edit_modifier_poll(struct bContext *C);
void edit_modifier_properties(struct wmOperatorType *ot);
int edit_modifier_invoke_properties(struct bContext *C, struct wmOperator *op);
diff --git a/source/blender/editors/object/object_modes.c b/source/blender/editors/object/object_modes.c
index 0ec98e089a2..271d8effd30 100644
--- a/source/blender/editors/object/object_modes.c
+++ b/source/blender/editors/object/object_modes.c
@@ -171,14 +171,6 @@ void ED_object_mode_toggle(bContext *C, eObjectMode mode)
if (opstring) {
wmOperatorType *ot = WM_operatortype_find(opstring, false);
- if (ot->flag & OPTYPE_USE_EVAL_DATA) {
- /* We need to force refresh of depsgraph after undo step,
- * redoing the operator *may* rely on some valid evaluated data. */
- struct Main *bmain = CTX_data_main(C);
- Scene *scene = CTX_data_scene(C);
- ViewLayer *view_layer = CTX_data_view_layer(C);
- BKE_scene_view_layer_graph_evaluated_ensure(bmain, scene, view_layer);
- }
WM_operator_name_call_ptr(C, ot, WM_OP_EXEC_REGION_WIN, NULL);
}
}
@@ -194,20 +186,6 @@ void ED_object_mode_set(bContext *C, eObjectMode mode)
wm->op_undo_depth--;
}
-void ED_object_mode_exit(bContext *C)
-{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
- struct Main *bmain = CTX_data_main(C);
- Scene *scene = CTX_data_scene(C);
- ViewLayer *view_layer = CTX_data_view_layer(C);
- FOREACH_OBJECT_BEGIN (view_layer, ob) {
- if (ob->mode & OB_MODE_ALL_MODE_DATA) {
- ED_object_mode_generic_exit(bmain, depsgraph, scene, ob);
- }
- }
- FOREACH_OBJECT_END;
-}
-
/** \} */
/* -------------------------------------------------------------------- */
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 08012842c37..8818fd71190 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -99,7 +99,7 @@ static void object_force_modifier_update_for_bind(Depsgraph *depsgraph, Object *
BKE_object_eval_reset(ob_eval);
if (ob->type == OB_MESH) {
Mesh *me_eval = mesh_create_eval_final_view(depsgraph, scene_eval, ob_eval, &CD_MASK_BAREMESH);
- BKE_id_free(NULL, me_eval);
+ BKE_mesh_eval_delete(me_eval);
}
else if (ob->type == OB_LATTICE) {
BKE_lattice_modifiers_calc(depsgraph, scene_eval, ob_eval);
@@ -912,7 +912,10 @@ void OBJECT_OT_modifier_add(wmOperatorType *ot)
/********** generic functions for operators using mod names and data context *********************/
-bool edit_modifier_poll_generic(bContext *C, StructRNA *rna_type, int obtype_flag)
+bool edit_modifier_poll_generic(bContext *C,
+ StructRNA *rna_type,
+ int obtype_flag,
+ const bool is_editmode_allowed)
{
PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", rna_type);
Object *ob = (ptr.id.data) ? ptr.id.data : ED_object_active_context(C);
@@ -932,12 +935,17 @@ bool edit_modifier_poll_generic(bContext *C, StructRNA *rna_type, int obtype_fla
return (((ModifierData *)ptr.data)->flag & eModifierFlag_OverrideLibrary_Local) != 0;
}
+ if (!is_editmode_allowed && CTX_data_edit_object(C) != NULL) {
+ CTX_wm_operator_poll_msg_set(C, "This modifier operation is not allowed from Edit mode");
+ return 0;
+ }
+
return 1;
}
bool edit_modifier_poll(bContext *C)
{
- return edit_modifier_poll_generic(C, &RNA_Modifier, 0);
+ return edit_modifier_poll_generic(C, &RNA_Modifier, 0, true);
}
void edit_modifier_properties(wmOperatorType *ot)
@@ -1122,7 +1130,7 @@ void OBJECT_OT_modifier_move_down(wmOperatorType *ot)
static int modifier_apply_exec(bContext *C, wmOperator *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 = ED_object_active_context(C);
ModifierData *md = edit_modifier_property_get(op, ob, 0);
@@ -1186,7 +1194,7 @@ void OBJECT_OT_modifier_apply(wmOperatorType *ot)
static int modifier_convert_exec(bContext *C, wmOperator *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);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *ob = ED_object_active_context(C);
@@ -1274,7 +1282,7 @@ void OBJECT_OT_modifier_copy(wmOperatorType *ot)
static bool multires_poll(bContext *C)
{
- return edit_modifier_poll_generic(C, &RNA_MultiresModifier, (1 << OB_MESH));
+ return edit_modifier_poll_generic(C, &RNA_MultiresModifier, (1 << OB_MESH), true);
}
static int multires_higher_levels_delete_exec(bContext *C, wmOperator *op)
@@ -1383,7 +1391,7 @@ void OBJECT_OT_multires_subdivide(wmOperatorType *ot)
static int multires_reshape_exec(bContext *C, wmOperator *op)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Object *ob = ED_object_active_context(C), *secondob = NULL;
MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(
op, ob, eModifierType_Multires);
@@ -1627,14 +1635,13 @@ static void modifier_skin_customdata_delete(Object *ob)
static bool skin_poll(bContext *C)
{
- return (!CTX_data_edit_object(C) &&
- edit_modifier_poll_generic(C, &RNA_SkinModifier, (1 << OB_MESH)));
+ return (edit_modifier_poll_generic(C, &RNA_SkinModifier, (1 << OB_MESH), false));
}
static bool skin_edit_poll(bContext *C)
{
return (CTX_data_edit_object(C) &&
- edit_modifier_poll_generic(C, &RNA_SkinModifier, (1 << OB_MESH)));
+ edit_modifier_poll_generic(C, &RNA_SkinModifier, (1 << OB_MESH), true));
}
static void skin_root_clear(BMVert *bm_vert, GSet *visited, const int cd_vert_skin_offset)
@@ -1927,7 +1934,7 @@ static Object *modifier_skin_armature_create(Depsgraph *depsgraph,
static int skin_armature_create_exec(bContext *C, wmOperator *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), *arm_ob;
Mesh *me = ob->data;
@@ -1987,12 +1994,12 @@ void OBJECT_OT_skin_armature_create(wmOperatorType *ot)
static bool correctivesmooth_poll(bContext *C)
{
- return edit_modifier_poll_generic(C, &RNA_CorrectiveSmoothModifier, 0);
+ return edit_modifier_poll_generic(C, &RNA_CorrectiveSmoothModifier, 0, true);
}
static int correctivesmooth_bind_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 = ED_object_active_context(C);
CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)edit_modifier_property_get(
@@ -2065,12 +2072,12 @@ void OBJECT_OT_correctivesmooth_bind(wmOperatorType *ot)
static bool meshdeform_poll(bContext *C)
{
- return edit_modifier_poll_generic(C, &RNA_MeshDeformModifier, 0);
+ return edit_modifier_poll_generic(C, &RNA_MeshDeformModifier, 0, true);
}
static int meshdeform_bind_exec(bContext *C, wmOperator *op)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Object *ob = ED_object_active_context(C);
MeshDeformModifierData *mmd = (MeshDeformModifierData *)edit_modifier_property_get(
op, ob, eModifierType_MeshDeform);
@@ -2138,7 +2145,7 @@ void OBJECT_OT_meshdeform_bind(wmOperatorType *ot)
static bool explode_poll(bContext *C)
{
- return edit_modifier_poll_generic(C, &RNA_ExplodeModifier, 0);
+ return edit_modifier_poll_generic(C, &RNA_ExplodeModifier, 0, true);
}
static int explode_refresh_exec(bContext *C, wmOperator *op)
@@ -2188,7 +2195,7 @@ void OBJECT_OT_explode_refresh(wmOperatorType *ot)
static bool ocean_bake_poll(bContext *C)
{
- return edit_modifier_poll_generic(C, &RNA_OceanModifier, 0);
+ return edit_modifier_poll_generic(C, &RNA_OceanModifier, 0, true);
}
typedef struct OceanBakeJob {
@@ -2309,8 +2316,9 @@ static int ocean_bake_exec(bContext *C, wmOperator *op)
for (f = omd->bakestart; f <= omd->bakeend; f++) {
/* For now only simple animation of time value is supported, nothing else.
* No drivers or other modifier parameters. */
- BKE_animsys_evaluate_animdata(
- CTX_data_depsgraph(C), scene, (ID *)ob, ob->adt, f, ADT_RECALC_ANIM);
+ /* TODO(sergey): This operates on an original data, so no flush is needed. However, baking
+ * usually should happen on an evaluated objects, so this seems to be deeper issue here. */
+ BKE_animsys_evaluate_animdata(scene, (ID *)ob, ob->adt, f, ADT_RECALC_ANIM, false);
och->time[i] = omd->time;
i++;
@@ -2389,13 +2397,13 @@ void OBJECT_OT_ocean_bake(wmOperatorType *ot)
static bool laplaciandeform_poll(bContext *C)
{
- return edit_modifier_poll_generic(C, &RNA_LaplacianDeformModifier, 0);
+ return edit_modifier_poll_generic(C, &RNA_LaplacianDeformModifier, 0, false);
}
static int laplaciandeform_bind_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_active_context(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)edit_modifier_property_get(
op, ob, eModifierType_LaplacianDeform);
@@ -2464,13 +2472,13 @@ void OBJECT_OT_laplaciandeform_bind(wmOperatorType *ot)
static bool surfacedeform_bind_poll(bContext *C)
{
- return edit_modifier_poll_generic(C, &RNA_SurfaceDeformModifier, 0);
+ return edit_modifier_poll_generic(C, &RNA_SurfaceDeformModifier, 0, true);
}
static int surfacedeform_bind_exec(bContext *C, wmOperator *op)
{
Object *ob = ED_object_active_context(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)edit_modifier_property_get(
op, ob, eModifierType_SurfaceDeform);
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index e6637265fbc..a69f4872e72 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -124,7 +124,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
Object *obedit = CTX_data_edit_object(C);
BMVert *eve;
@@ -677,7 +677,7 @@ bool ED_object_parent_set(ReportList *reports,
const int vert_par[3])
{
Main *bmain = CTX_data_main(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
bPoseChannel *pchan = NULL;
bPoseChannel *pchan_eval = NULL;
const bool pararm = ELEM(
@@ -1582,6 +1582,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op)
id_us_plus(&ob_dst->instance_collection->id);
ob_dst->transflag |= OB_DUPLICOLLECTION;
}
+ DEG_id_tag_update(&ob_dst->id, ID_RECALC_COPY_ON_WRITE);
break;
case MAKE_LINKS_MODIFIERS:
BKE_object_link_modifiers(scene, ob_dst, ob_src);
@@ -1726,7 +1727,7 @@ static Collection *single_object_users_collection(Main *bmain,
const bool is_master_collection)
{
/* Generate new copies for objects in given collection and all its children,
- * and optionnaly also copy collections themselves. */
+ * and optionally also copy collections themselves. */
if (copy_collections && !is_master_collection) {
collection = ID_NEW_SET(collection, BKE_collection_copy(bmain, NULL, collection));
}
diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c
index 9c98fdc2a2e..5934eab62bb 100644
--- a/source/blender/editors/object/object_transform.c
+++ b/source/blender/editors/object/object_transform.c
@@ -547,7 +547,7 @@ static int apply_objects_internal(bContext *C,
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
- Depsgraph *depsgraph = CTX_data_evaluated_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
float rsmat[3][3], obmat[3][3], iobmat[3][3], mat[4][4], scale;
bool changed = true;
@@ -856,6 +856,7 @@ static int apply_objects_internal(bContext *C,
BKE_object_where_is_calc(depsgraph, scene, ob_eval);
if (ob->type == OB_ARMATURE) {
/* needed for bone parents */
+ BKE_armature_copy_bone_transforms(ob_eval->data, ob->data);
BKE_pose_where_is(depsgraph, scene, ob_eval);
}
@@ -880,7 +881,7 @@ static int apply_objects_internal(bContext *C,
static int visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
- Depsgraph *depsgraph = CTX_data_evaluated_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
bool changed = false;
CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) {
@@ -975,7 +976,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
Scene *scene = CTX_data_scene(C);
Object *obact = CTX_data_active_object(C);
Object *obedit = CTX_data_edit_object(C);
- Depsgraph *depsgraph = CTX_data_evaluated_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Object *tob;
float cent[3], cent_neg[3], centn[3];
const float *cursor = scene->cursor.location;
@@ -1229,6 +1230,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
BKE_object_transform_copy(ob_eval, ob);
+ BKE_armature_copy_bone_transforms(ob_eval->data, ob->data);
BKE_object_where_is_calc(depsgraph, scene, ob_eval);
BKE_pose_where_is(depsgraph, scene, ob_eval); /* needed for bone parents */
@@ -1370,6 +1372,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
BKE_object_where_is_calc(depsgraph, scene, ob_eval);
if (ob->type == OB_ARMATURE) {
/* needed for bone parents */
+ BKE_armature_copy_bone_transforms(ob_eval->data, ob->data);
BKE_pose_where_is(depsgraph, scene, ob_eval);
}
@@ -1398,6 +1401,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op)
BKE_object_where_is_calc(depsgraph, scene, ob_other_eval);
if (ob_other->type == OB_ARMATURE) {
/* needed for bone parents */
+ BKE_armature_copy_bone_transforms(ob_eval->data, ob->data);
BKE_pose_where_is(depsgraph, scene, ob_other_eval);
}
ignore_parent_tx(bmain, depsgraph, scene, ob_other);
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index 4f61443ac54..a43ac59c9b8 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -1514,7 +1514,7 @@ static void moveCloserToDistanceFromPlane(Depsgraph *depsgraph,
static void vgroup_fix(
const bContext *C, Scene *UNUSED(scene), Object *ob, float distToBe, float strength, float cp)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Object *object_eval = DEG_get_evaluated_object(depsgraph, ob);
int i;
diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c
index 40b7a245f69..c06c21b9057 100644
--- a/source/blender/editors/physics/dynamicpaint_ops.c
+++ b/source/blender/editors/physics/dynamicpaint_ops.c
@@ -473,7 +473,7 @@ static void dpaint_bake_startjob(void *customdata, short *stop, short *do_update
*/
static int dynamicpaint_bake_exec(struct bContext *C, struct wmOperator *op)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Object *ob_ = ED_object_context(C);
Object *object_eval = DEG_get_evaluated_object(depsgraph, ob_);
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
@@ -505,7 +505,7 @@ static int dynamicpaint_bake_exec(struct bContext *C, struct wmOperator *op)
DynamicPaintBakeJob *job = MEM_mallocN(sizeof(DynamicPaintBakeJob), "DynamicPaintBakeJob");
job->bmain = CTX_data_main(C);
job->scene = scene_eval;
- job->depsgraph = CTX_data_depsgraph(C);
+ job->depsgraph = depsgraph;
job->ob = object_eval;
job->canvas = canvas;
job->surface = surface;
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index 4e6022cf18c..e6870cda19d 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -252,7 +252,7 @@ static void pe_update_hair_particle_edit_pointers(PTCacheEdit *edit)
/* always gets at least the first particlesystem even if PSYS_CURRENT flag is not set
*
- * note: this function runs on poll, therefor it can runs many times a second
+ * note: this function runs on poll, therefore it can runs many times a second
* keep it fast! */
static PTCacheEdit *pe_get_current(Depsgraph *depsgraph, Scene *scene, Object *ob, int create)
{
@@ -465,7 +465,7 @@ static void PE_set_data(bContext *C, PEData *data)
data->scene = CTX_data_scene(C);
data->view_layer = CTX_data_view_layer(C);
data->ob = CTX_data_active_object(C);
- data->depsgraph = CTX_data_depsgraph(C);
+ data->depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
data->edit = PE_get_current(data->scene, data->ob);
}
@@ -785,7 +785,7 @@ typedef struct KeyIterData {
static void foreach_mouse_hit_key_iter(void *__restrict iter_data_v,
const int iter,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
KeyIterData *iter_data = (KeyIterData *)iter_data_v;
PEData *data = iter_data->data;
@@ -855,7 +855,7 @@ static void foreach_mouse_hit_key(PEData *data, ForHitKeyMatFunc func, int selec
iter_data.selected = selected;
iter_data.func = func;
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.scheduling_mode = TASK_SCHEDULING_DYNAMIC;
BLI_task_parallel_range(0, edit->totpoint, &iter_data, foreach_mouse_hit_key_iter, &settings);
@@ -1152,7 +1152,7 @@ typedef struct DeflectEmitterIter {
static void deflect_emitter_iter(void *__restrict iter_data_v,
const int iter,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
DeflectEmitterIter *iter_data = (DeflectEmitterIter *)iter_data_v;
PTCacheEdit *edit = iter_data->edit;
@@ -1246,7 +1246,7 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit)
iter_data.dist = dist;
iter_data.emitterdist = pset->emitterdist;
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.scheduling_mode = TASK_SCHEDULING_DYNAMIC;
BLI_task_parallel_range(0, edit->totpoint, &iter_data, deflect_emitter_iter, &settings);
@@ -1258,7 +1258,7 @@ typedef struct ApplyLengthsIterData {
static void apply_lengths_iter(void *__restrict iter_data_v,
const int iter,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
ApplyLengthsIterData *iter_data = (ApplyLengthsIterData *)iter_data_v;
PTCacheEdit *edit = iter_data->edit;
@@ -1296,7 +1296,7 @@ static void PE_apply_lengths(Scene *scene, PTCacheEdit *edit)
ApplyLengthsIterData iter_data;
iter_data.edit = edit;
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.scheduling_mode = TASK_SCHEDULING_DYNAMIC;
BLI_task_parallel_range(0, edit->totpoint, &iter_data, apply_lengths_iter, &settings);
@@ -1309,7 +1309,7 @@ typedef struct IterateLengthsIterData {
static void iterate_lengths_iter(void *__restrict iter_data_v,
const int iter,
- const ParallelRangeTLS *__restrict UNUSED(tls))
+ const TaskParallelTLS *__restrict UNUSED(tls))
{
IterateLengthsIterData *iter_data = (IterateLengthsIterData *)iter_data_v;
PTCacheEdit *edit = iter_data->edit;
@@ -1371,7 +1371,7 @@ static void pe_iterate_lengths(Scene *scene, PTCacheEdit *edit)
iter_data.edit = edit;
iter_data.pset = pset;
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.scheduling_mode = TASK_SCHEDULING_DYNAMIC;
BLI_task_parallel_range(0, edit->totpoint, &iter_data, iterate_lengths_iter, &settings);
@@ -1499,7 +1499,7 @@ static void PE_update_selection(Depsgraph *depsgraph, Scene *scene, Object *ob,
DEG_id_tag_update(&ob->id, ID_RECALC_SELECT);
}
-void update_world_cos(Depsgraph *UNUSED(depsgraph), Object *ob, PTCacheEdit *edit)
+void update_world_cos(Object *ob, PTCacheEdit *edit)
{
ParticleSystem *psys = edit->psys;
ParticleSystemModifierData *psmd_eval = edit->psmd_eval;
@@ -1619,7 +1619,7 @@ void PE_update_object(Depsgraph *depsgraph, Scene *scene, Object *ob, int usefla
PE_apply_mirror(ob, edit->psys);
}
if (edit->psys) {
- update_world_cos(depsgraph, ob, edit);
+ update_world_cos(ob, edit);
}
if (pset->flag & PE_AUTO_VELOCITY) {
update_velocities(edit);
@@ -1778,7 +1778,7 @@ static bool select_action_apply(PTCacheEditPoint *point, PTCacheEditKey *key, in
static int pe_select_all_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Object *ob = CTX_data_active_object(C);
PTCacheEdit *edit = PE_get_current(scene, ob);
POINT_P;
@@ -2348,7 +2348,7 @@ static int hide_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_active_object(C);
Scene *scene = CTX_data_scene(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
PTCacheEdit *edit = PE_get_current(scene, ob);
POINT_P;
@@ -2409,7 +2409,7 @@ static int reveal_exec(bContext *C, wmOperator *op)
{
Object *ob = CTX_data_active_object(C);
Scene *scene = CTX_data_scene(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
PTCacheEdit *edit = PE_get_current(scene, ob);
const bool select = RNA_boolean_get(op->ptr, "select");
POINT_P;
@@ -2709,7 +2709,7 @@ static void rekey_particle_to_time(
psys = edit->psys;
- sim.depsgraph = CTX_data_depsgraph(C);
+ sim.depsgraph = CTX_data_depsgraph_pointer(C);
sim.scene = scene;
sim.ob = ob;
sim.psys = psys;
@@ -3519,7 +3519,7 @@ static int mirror_exec(bContext *C, wmOperator *UNUSED(op))
PE_mirror_x(scene, ob, 0);
- update_world_cos(CTX_data_depsgraph(C), ob, edit);
+ update_world_cos(ob, edit);
WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_EDITED, ob);
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
@@ -4116,7 +4116,7 @@ typedef struct BrushAddCountIterTLSData {
static void brush_add_count_iter(void *__restrict iter_data_v,
const int iter,
- const ParallelRangeTLS *__restrict tls_v)
+ const TaskParallelTLS *__restrict tls_v)
{
BrushAddCountIterData *iter_data = (BrushAddCountIterData *)iter_data_v;
Depsgraph *depsgraph = iter_data->depsgraph;
@@ -4211,7 +4211,7 @@ static void brush_add_count_iter_finalize(void *__restrict userdata_v,
static int brush_add(const bContext *C, PEData *data, short number)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
Scene *scene = data->scene;
Object *ob = data->ob;
Mesh *mesh;
@@ -4272,7 +4272,7 @@ static int brush_add(const bContext *C, PEData *data, short number)
BrushAddCountIterTLSData tls = {NULL};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.scheduling_mode = TASK_SCHEDULING_DYNAMIC;
settings.userdata_chunk = &tls;
@@ -4542,7 +4542,7 @@ static int brush_edit_init(bContext *C, wmOperator *op)
static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
{
BrushEdit *bedit = op->customdata;
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
Scene *scene = bedit->scene;
Object *ob = bedit->ob;
PTCacheEdit *edit = bedit->edit;
@@ -4747,7 +4747,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
PE_mirror_x(scene, ob, 1);
}
- update_world_cos(depsgraph, ob, edit);
+ update_world_cos(ob, edit);
psys_free_path_cache(NULL, edit);
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
@@ -4993,7 +4993,6 @@ static void shape_cut(PEData *data, int pa_index)
static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op))
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
ParticleEditSettings *pset = PE_settings(scene);
@@ -5032,7 +5031,7 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op))
recalc_lengths(edit);
if (removed) {
- update_world_cos(depsgraph, ob, edit);
+ update_world_cos(ob, edit);
psys_free_path_cache(NULL, edit);
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
}
@@ -5203,7 +5202,7 @@ void PE_create_particle_edit(
}
pa++;
}
- update_world_cos(depsgraph, ob, edit);
+ update_world_cos(ob, edit);
}
else {
PTCacheMem *pm;
@@ -5295,7 +5294,7 @@ static void free_all_psys_edit(Object *object)
static int particle_edit_toggle_exec(bContext *C, wmOperator *op)
{
struct wmMsgBus *mbus = CTX_wm_message_bus(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
const int mode_flag = OB_MODE_PARTICLE_EDIT;
@@ -5496,7 +5495,7 @@ static int unify_length_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob = CTX_data_active_object(C);
Scene *scene = CTX_data_scene(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
PTCacheEdit *edit = PE_get_current(scene, ob);
float average_length = calculate_average_length(edit);
diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c
index b03ec56c7e4..0999d1f3588 100644
--- a/source/blender/editors/physics/particle_object.c
+++ b/source/blender/editors/physics/particle_object.c
@@ -652,7 +652,7 @@ static void disconnect_hair(Depsgraph *depsgraph, Scene *scene, Object *ob, Part
static int disconnect_hair_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 = ED_object_context(C);
ParticleSystem *psys = NULL;
@@ -934,7 +934,7 @@ static bool connect_hair(Depsgraph *depsgraph, Scene *scene, Object *ob, Particl
static int connect_hair_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 = ED_object_context(C);
ParticleSystem *psys = NULL;
@@ -1037,7 +1037,7 @@ static void copy_particle_edit(Depsgraph *depsgraph,
pa++;
}
- update_world_cos(depsgraph, ob, edit);
+ update_world_cos(ob, edit);
UI_GetThemeColor3ubv(TH_EDGE_SELECT, edit->sel_col);
UI_GetThemeColor3ubv(TH_WIRE, edit->nosel_col);
@@ -1086,11 +1086,10 @@ static bool copy_particle_systems_to_object(const bContext *C,
bool duplicate_settings)
{
Main *bmain = CTX_data_main(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ModifierData *md;
ParticleSystem *psys_start = NULL, *psys, *psys_from;
ParticleSystem **tmp_psys;
- Mesh *final_mesh;
CustomData_MeshMasks cdmask = {0};
int i, totpsys;
@@ -1132,9 +1131,6 @@ static bool copy_particle_systems_to_object(const bContext *C,
*/
psys_start = totpsys > 0 ? tmp_psys[0] : NULL;
- /* Get the evaluated mesh (psys and their modifiers have not been appended yet) */
- final_mesh = mesh_get_eval_final(depsgraph, scene, ob_to, &cdmask);
-
/* now append psys to the object and make modifiers */
for (i = 0, psys_from = PSYS_FROM_FIRST; i < totpsys;
++i, psys_from = PSYS_FROM_NEXT(psys_from)) {
@@ -1155,10 +1151,6 @@ static bool copy_particle_systems_to_object(const bContext *C,
modifier_unique_name(&ob_to->modifiers, (ModifierData *)psmd);
psmd->psys = psys;
- BKE_id_copy_ex(NULL, &final_mesh->id, (ID **)&psmd->mesh_final, LIB_ID_COPY_LOCALIZE);
-
- BKE_mesh_calc_normals(psmd->mesh_final);
- BKE_mesh_tessface_ensure(psmd->mesh_final);
if (psys_from->edit) {
copy_particle_edit(depsgraph, scene, ob_to, psys, psys_from);
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c
index dc3673c972f..44858e36fab 100644
--- a/source/blender/editors/physics/physics_fluid.c
+++ b/source/blender/editors/physics/physics_fluid.c
@@ -334,6 +334,7 @@ static void free_all_fluidobject_channels(ListBase *fobjects)
}
static void fluid_init_all_channels(bContext *C,
+ Depsgraph *depsgraph,
Object *UNUSED(fsDomain),
FluidsimSettings *domainSettings,
FluidAnimChannels *channels,
@@ -341,7 +342,6 @@ static void fluid_init_all_channels(bContext *C,
{
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
Base *base;
int i;
int length = channels->length;
@@ -514,9 +514,11 @@ static void fluid_init_all_channels(bContext *C,
}
}
-static void export_fluid_objects(const bContext *C, ListBase *fobjects, Scene *scene, int length)
+static void export_fluid_objects(Depsgraph *depsgraph,
+ ListBase *fobjects,
+ Scene *scene,
+ int length)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
FluidObject *fobj;
for (fobj = fobjects->first; fobj; fobj = fobj->next) {
@@ -714,7 +716,7 @@ static bool fluid_init_filepaths(Main *bmain,
/* .tmp: don't overwrite/delete original file */
BLI_join_dirfile(targetFile, FILE_MAX, targetDir, suffixConfigTmp);
- /* Ensure whole path exists and is wirtable. */
+ /* Ensure whole path exists and is writeable. */
const bool dir_exists = BLI_dir_create_recursive(targetDir);
const bool is_writable = BLI_file_is_writable(targetFile);
@@ -747,7 +749,7 @@ static bool fluid_init_filepaths(Main *bmain,
/* .tmp: don't overwrite/delete original file */
BLI_join_dirfile(targetFile, FILE_MAX, targetDir, suffixConfigTmp);
- /* Ensure whole path exists and is wirtable. */
+ /* Ensure whole path exists and is writeable. */
if (!BLI_dir_create_recursive(targetDir) || !BLI_file_is_writable(targetFile)) {
BKE_reportf(reports,
RPT_ERROR,
@@ -922,7 +924,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
int i;
FluidsimSettings *domainSettings;
@@ -1051,11 +1053,11 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
(double)noFrames;
/* ******** initialize and allocate animation channels ******** */
- fluid_init_all_channels(C, fsDomain, domainSettings, channels, fobjects);
+ fluid_init_all_channels(C, depsgraph, fsDomain, domainSettings, channels, fobjects);
/* reset to original current frame */
scene->r.cfra = origFrame;
- ED_update_for_newframe(CTX_data_main(C), depsgraph);
+ ED_update_for_newframe(CTX_data_main(C), CTX_data_depsgraph_pointer(C));
/* ******** init domain object's matrix ******** */
copy_m4_m4(domainMat, fsDomain->obmat);
@@ -1153,7 +1155,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
elbeemAddDomain(fsset);
/* ******** export all fluid objects to elbeem ******** */
- export_fluid_objects(C, fobjects, scene, channels->length);
+ export_fluid_objects(depsgraph, fobjects, scene, channels->length);
/* custom data for fluid bake job */
fb->settings = fsset;
diff --git a/source/blender/editors/physics/physics_intern.h b/source/blender/editors/physics/physics_intern.h
index bb7cfe9b1a3..9ebbba07fdf 100644
--- a/source/blender/editors/physics/physics_intern.h
+++ b/source/blender/editors/physics/physics_intern.h
@@ -70,7 +70,7 @@ void recalc_lengths(struct PTCacheEdit *edit);
void recalc_emitter_field(struct Depsgraph *depsgraph,
struct Object *ob,
struct ParticleSystem *psys);
-void update_world_cos(struct Depsgraph *depsgraph, struct Object *ob, struct PTCacheEdit *edit);
+void update_world_cos(struct Object *ob, struct PTCacheEdit *edit);
/* particle_object.c */
void OBJECT_OT_particle_system_add(struct wmOperatorType *ot);
diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c
index e9e89a31f94..bc2f1d6cef6 100644
--- a/source/blender/editors/physics/physics_pointcache.c
+++ b/source/blender/editors/physics/physics_pointcache.c
@@ -156,7 +156,8 @@ static PTCacheBaker *ptcache_baker_create(bContext *C, wmOperator *op, bool all)
baker->bmain = CTX_data_main(C);
baker->scene = CTX_data_scene(C);
baker->view_layer = CTX_data_view_layer(C);
- baker->depsgraph = CTX_data_depsgraph(C);
+ /* Depsgraph is used to sweep the frame range and evaluate scene at different times. */
+ baker->depsgraph = CTX_data_depsgraph_pointer(C);
baker->bake = RNA_boolean_get(op->ptr, "bake");
baker->render = 0;
baker->anim_init = 0;
diff --git a/source/blender/editors/physics/rigidbody_object.c b/source/blender/editors/physics/rigidbody_object.c
index aa323dc53eb..70142b790c0 100644
--- a/source/blender/editors/physics/rigidbody_object.c
+++ b/source/blender/editors/physics/rigidbody_object.c
@@ -464,7 +464,7 @@ static const EnumPropertyItem *rigidbody_materials_itemf(bContext *UNUSED(C),
static int rigidbody_objects_calc_mass_exec(bContext *C, wmOperator *op)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
int material = RNA_enum_get(op->ptr, "material");
float density;
bool changed = false;
@@ -537,7 +537,7 @@ void RIGIDBODY_OT_mass_calculate(wmOperatorType *ot)
ot->poll = ED_operator_scene_editable;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
ot->prop = prop = RNA_def_enum(
diff --git a/source/blender/editors/render/render_intern.h b/source/blender/editors/render/render_intern.h
index 1e03d986e3e..50f0b53c037 100644
--- a/source/blender/editors/render/render_intern.h
+++ b/source/blender/editors/render/render_intern.h
@@ -37,6 +37,7 @@ void OBJECT_OT_material_slot_select(struct wmOperatorType *ot);
void OBJECT_OT_material_slot_deselect(struct wmOperatorType *ot);
void OBJECT_OT_material_slot_copy(struct wmOperatorType *ot);
void OBJECT_OT_material_slot_move(struct wmOperatorType *ot);
+void OBJECT_OT_material_slot_remove_unused(struct wmOperatorType *ot);
void MATERIAL_OT_new(struct wmOperatorType *ot);
void TEXTURE_OT_new(struct wmOperatorType *ot);
diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c
index 9ac93f07300..acd7126e56a 100644
--- a/source/blender/editors/render/render_internal.c
+++ b/source/blender/editors/render/render_internal.c
@@ -368,7 +368,7 @@ static int screen_render_exec(bContext *C, wmOperator *op)
RE_SetReports(re, NULL);
// no redraw needed, we leave state as we entered it
- ED_update_for_newframe(mainp, CTX_data_depsgraph(C));
+ ED_update_for_newframe(mainp, CTX_data_depsgraph_pointer(C));
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, scene);
@@ -978,8 +978,11 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even
rj->scene = scene;
rj->current_scene = rj->scene;
rj->single_layer = single_layer;
- /* TODO(sergey): Render engine should be using own depsgraph. */
- rj->depsgraph = CTX_data_depsgraph(C);
+ /* TODO(sergey): Render engine should be using own depsgraph.
+ *
+ * NOTE: Currently is only used by ED_update_for_newframe() at the end of the render, so no
+ * need to ensure evaluation here. */
+ rj->depsgraph = CTX_data_depsgraph_pointer(C);
rj->camera_override = camera_override;
rj->anim = is_animation;
rj->write_still = is_write_still && !is_animation;
diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c
index 72e6c6fdf03..f419d30a17e 100644
--- a/source/blender/editors/render/render_opengl.c
+++ b/source/blender/editors/render/render_opengl.c
@@ -273,7 +273,7 @@ static void screen_opengl_views_setup(OGLRender *oglrender)
static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, RenderResult *rr)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene = oglrender->scene;
ARegion *ar = oglrender->ar;
View3D *v3d = oglrender->v3d;
@@ -592,7 +592,9 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op)
oglrender->scene = scene;
oglrender->workspace = workspace;
oglrender->view_layer = CTX_data_view_layer(C);
- oglrender->depsgraph = CTX_data_depsgraph(C);
+ /* NOTE: The depsgraph is not only used to update scene for a new frames, but also to initialize
+ * output video handles, which does need evaluated scene. */
+ oglrender->depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
oglrender->cfrao = scene->r.cfra;
oglrender->ofs_samples = samples;
diff --git a/source/blender/editors/render/render_ops.c b/source/blender/editors/render/render_ops.c
index b77f5c2bbad..8156f48343f 100644
--- a/source/blender/editors/render/render_ops.c
+++ b/source/blender/editors/render/render_ops.c
@@ -42,6 +42,7 @@ void ED_operatortypes_render(void)
WM_operatortype_append(OBJECT_OT_material_slot_deselect);
WM_operatortype_append(OBJECT_OT_material_slot_copy);
WM_operatortype_append(OBJECT_OT_material_slot_move);
+ WM_operatortype_append(OBJECT_OT_material_slot_remove_unused);
WM_operatortype_append(MATERIAL_OT_new);
WM_operatortype_append(TEXTURE_OT_new);
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c
index fbabdc2f3c1..9b380ad5db1 100644
--- a/source/blender/editors/render/render_preview.c
+++ b/source/blender/editors/render/render_preview.c
@@ -153,7 +153,6 @@ typedef struct ShaderPreview {
short *stop, *do_update;
Scene *scene;
- Depsgraph *depsgraph;
ID *id, *id_copy;
ID *parent;
MTex *slot;
@@ -185,7 +184,6 @@ typedef struct IconPreviewSize {
typedef struct IconPreview {
Main *bmain;
Scene *scene;
- Depsgraph *depsgraph;
void *owner;
ID *id, *id_copy;
ListBase sizes;
@@ -292,7 +290,7 @@ static void set_preview_visibility(Scene *scene,
char pr_type,
int pr_method)
{
- /* Set appropriate layer as visibile. */
+ /* Set appropriate layer as visible. */
LayerCollection *lc = view_layer->layer_collections.first;
const char *collection_name = preview_collection_name(pr_type);
@@ -1229,7 +1227,6 @@ static void icon_preview_startjob_all_sizes(void *customdata,
/* construct shader preview from image size and previewcustomdata */
sp->scene = ip->scene;
- sp->depsgraph = ip->depsgraph;
sp->owner = ip->owner;
sp->sizex = cur_size->sizex;
sp->sizey = cur_size->sizey;
@@ -1372,7 +1369,6 @@ void ED_preview_icon_job(const bContext *C,
/* customdata for preview thread */
ip->bmain = CTX_data_main(C);
ip->scene = CTX_data_scene(C);
- ip->depsgraph = CTX_data_depsgraph(C);
ip->owner = owner;
ip->id = id;
ip->id_copy = duplicate_ids(id);
@@ -1439,7 +1435,6 @@ void ED_preview_shader_job(const bContext *C,
/* customdata for preview thread */
sp->scene = scene;
- sp->depsgraph = CTX_data_depsgraph(C);
sp->owner = owner;
sp->sizex = sizex;
sp->sizey = sizey;
diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index f7a1d7187f1..01740c13c9d 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -310,7 +310,7 @@ static int material_slot_de_select(bContext *C, bool select)
}
else {
/* Find the first matching material.
- * Note: there may be multiple but thats not a common use case. */
+ * Note: there may be multiple but that's not a common use case. */
for (short i = 0; i < ob->totcol; i++) {
const Material *mat = give_current_material(ob, i + 1);
if (mat_active == mat) {
@@ -549,6 +549,73 @@ void OBJECT_OT_material_slot_move(wmOperatorType *ot)
"Direction to move the active material towards");
}
+static int material_slot_remove_unused_exec(bContext *C, wmOperator *op)
+{
+ Object *ob = CTX_data_active_object(C);
+
+ if (!ob) {
+ return OPERATOR_CANCELLED;
+ }
+
+ /* Removing material slots in edit mode screws things up, see bug #21822.*/
+ if (ob == CTX_data_edit_object(C)) {
+ BKE_report(op->reports, RPT_ERROR, "Unable to remove material slot in edit mode");
+ return OPERATOR_CANCELLED;
+ }
+
+ int actcol = ob->actcol;
+
+ int removed = 0;
+ for (int slot = 1; slot <= ob->totcol; slot++) {
+ while (slot <= ob->totcol && !BKE_object_material_slot_used(ob->data, slot)) {
+ ob->actcol = slot;
+ BKE_object_material_slot_remove(CTX_data_main(C), ob);
+
+ if (actcol >= slot) {
+ actcol--;
+ }
+
+ removed++;
+ }
+ }
+
+ ob->actcol = actcol;
+
+ if (!removed) {
+ return OPERATOR_CANCELLED;
+ }
+
+ BKE_reportf(op->reports, RPT_INFO, "Removed %d slots", removed);
+
+ if (ob->mode & OB_MODE_TEXTURE_PAINT) {
+ Scene *scene = CTX_data_scene(C);
+ BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL);
+ WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL);
+ }
+
+ DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
+ WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, ob);
+ WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_PREVIEW, ob);
+
+ return OPERATOR_FINISHED;
+}
+
+void OBJECT_OT_material_slot_remove_unused(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Remove Unused Slots";
+ ot->idname = "OBJECT_OT_material_slot_remove_unused";
+ ot->description = "Remove unused material slots";
+
+ /* api callbacks */
+ ot->exec = material_slot_remove_unused_exec;
+ ot->poll = ED_operator_object_active_editable;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
/********************** new material operator *********************/
static int new_material_exec(bContext *C, wmOperator *UNUSED(op))
@@ -859,7 +926,7 @@ static int light_cache_bake_exec(bContext *C, wmOperator *op)
EEVEE_lightbake_job_data_free(rj);
// no redraw needed, we leave state as we entered it
- ED_update_for_newframe(bmain, CTX_data_depsgraph(C));
+ ED_update_for_newframe(bmain, CTX_data_depsgraph_pointer(C));
WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene);
diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c
index 64869b71746..82e4d577777 100644
--- a/source/blender/editors/render/render_update.c
+++ b/source/blender/editors/render/render_update.c
@@ -135,7 +135,7 @@ void ED_render_scene_update(const DEGEditorUpdateContext *update_ctx, int update
/* NOTE: Important to pass non-updated depsgraph, This is because this function is called
* from inside dependency graph evaluation. Additionally, if we pass fully evaluated one
* we will loose updates stored in the graph. */
- engine->type->view_update(engine, C, CTX_data_depsgraph(C));
+ engine->type->view_update(engine, C, CTX_data_depsgraph_pointer(C));
}
else {
RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->shading.type);
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index e5bbeafd89d..5099c370a85 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -2696,7 +2696,7 @@ void ED_region_header_init(ARegion *ar)
int ED_area_headersize(void)
{
- /* Accomodate widget and padding. */
+ /* Accommodate widget and padding. */
return U.widget_unit + (int)(UI_DPI_FAC * HEADER_PADDING_Y);
}
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index e59477fbe6e..dddc33e3ad0 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -1457,6 +1457,8 @@ void ED_update_for_newframe(Main *bmain, Depsgraph *depsgraph)
{
Scene *scene = DEG_get_input_scene(depsgraph);
+ DEG_id_tag_update_ex(bmain, &scene->id, ID_RECALC_TIME);
+
#ifdef DURIAN_CAMERA_SWITCH
void *camera = BKE_scene_camera_switch_find(scene);
if (camera && scene->camera != camera) {
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index c9a45728bc2..eccd85ab276 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -1059,7 +1059,7 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event)
is_gesture = (delta_max > split_threshold);
}
else {
- /* Different area, so posible join. */
+ /* Different area, so possible join. */
if (sad->gesture_dir == 'n') {
WM_cursor_set(win, BC_N_ARROWCURSOR);
}
@@ -4465,7 +4465,7 @@ int ED_screen_animation_play(bContext *C, int sync, int mode)
{
bScreen *screen = CTX_wm_screen(C);
Scene *scene = CTX_data_scene(C);
- Scene *scene_eval = DEG_get_evaluated_scene(CTX_data_depsgraph(C));
+ Scene *scene_eval = DEG_get_evaluated_scene(CTX_data_ensure_evaluated_depsgraph(C));
if (ED_screen_animation_playing(CTX_wm_manager(C))) {
/* stop playback now */
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);
}
}
diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c
index 0241a2fbe88..10d38055085 100644
--- a/source/blender/editors/sound/sound_ops.c
+++ b/source/blender/editors/sound/sound_ops.c
@@ -305,7 +305,9 @@ static int sound_bake_animation_exec(bContext *C, wmOperator *UNUSED(op))
{
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
- struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ /* NOTE: We will be forefully evaluating dependency graph at every frame, so no need to ensure
+ * current scene state is evaluated as it will be lost anyway. */
+ struct Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
int oldfra = scene->r.cfra;
int cfra;
@@ -343,7 +345,7 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op)
#ifdef WITH_AUDASPACE
char path[FILE_MAX];
char filename[FILE_MAX];
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Main *bmain = CTX_data_main(C);
int split;
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index 7fc84db3f75..944a0c74f4c 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -704,7 +704,6 @@ static void insert_action_keys(bAnimContext *ac, short mode)
bAnimListElem *ale;
int filter;
- struct Depsgraph *depsgraph = ac->depsgraph;
ReportList *reports = ac->reports;
Scene *scene = ac->scene;
ToolSettings *ts = scene->toolsettings;
@@ -741,7 +740,6 @@ static void insert_action_keys(bAnimContext *ac, short mode)
*/
if (ale->id && !ale->owner) {
insert_keyframe(ac->bmain,
- depsgraph,
reports,
ale->id,
NULL,
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index 7cc222ea529..9e2634b183a 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -1199,9 +1199,14 @@ static void select_moreless_action_keys(bAnimContext *ac, short mode)
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
for (ale = anim_data.first; ale; ale = ale->next) {
- FCurve *fcu = (FCurve *)ale->key_data;
+
+ /* TODO: other types. */
+ if (ale->datatype != ALE_FCURVE) {
+ continue;
+ }
/* only continue if F-Curve has keyframes */
+ FCurve *fcu = (FCurve *)ale->key_data;
if (fcu->bezt == NULL) {
continue;
}
diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c
index ef5de1acee3..3f705aad89a 100644
--- a/source/blender/editors/space_clip/clip_graph_draw.c
+++ b/source/blender/editors/space_clip/clip_graph_draw.c
@@ -48,6 +48,7 @@
#include "clip_intern.h" // own include
typedef struct TrackMotionCurveUserData {
+ SpaceClip *sc;
MovieTrackingTrack *act_track;
bool sel;
float xscale, yscale, hsize;
@@ -57,24 +58,43 @@ typedef struct TrackMotionCurveUserData {
static void tracking_segment_point_cb(void *userdata,
MovieTrackingTrack *UNUSED(track),
MovieTrackingMarker *UNUSED(marker),
- int UNUSED(coord),
+ eClipCurveValueSource value_source,
int scene_framenr,
float val)
{
TrackMotionCurveUserData *data = (TrackMotionCurveUserData *)userdata;
+ if (!clip_graph_value_visible(data->sc, value_source)) {
+ return;
+ }
+
immVertex2f(data->pos, scene_framenr, val);
}
static void tracking_segment_start_cb(void *userdata,
MovieTrackingTrack *track,
- int coord,
+ eClipCurveValueSource value_source,
bool is_point)
{
TrackMotionCurveUserData *data = (TrackMotionCurveUserData *)userdata;
+ SpaceClip *sc = data->sc;
float col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
- col[coord] = 1.0f;
+ if (!clip_graph_value_visible(sc, value_source)) {
+ return;
+ }
+
+ switch (value_source) {
+ case CLIP_VALUE_SOURCE_SPEED_X:
+ col[0] = 1.0f;
+ break;
+ case CLIP_VALUE_SOURCE_SPEED_Y:
+ col[1] = 1.0f;
+ break;
+ case CLIP_VALUE_SOURCE_REPROJECTION_ERROR:
+ col[2] = 1.0f;
+ break;
+ }
if (track == data->act_track) {
col[3] = 1.0f;
@@ -96,15 +116,20 @@ static void tracking_segment_start_cb(void *userdata,
}
}
-static void tracking_segment_end_cb(void *UNUSED(userdata), int UNUSED(coord))
+static void tracking_segment_end_cb(void *userdata, eClipCurveValueSource value_source)
{
+ TrackMotionCurveUserData *data = (TrackMotionCurveUserData *)userdata;
+ SpaceClip *sc = data->sc;
+ if (!clip_graph_value_visible(sc, value_source)) {
+ return;
+ }
immEnd();
}
static void tracking_segment_knot_cb(void *userdata,
MovieTrackingTrack *track,
MovieTrackingMarker *marker,
- int coord,
+ eClipCurveValueSource value_source,
int scene_framenr,
float val)
{
@@ -114,8 +139,11 @@ static void tracking_segment_knot_cb(void *userdata,
if (track != data->act_track) {
return;
}
+ if (!ELEM(value_source, CLIP_VALUE_SOURCE_SPEED_X, CLIP_VALUE_SOURCE_SPEED_Y)) {
+ return;
+ }
- sel_flag = coord == 0 ? MARKER_GRAPH_SEL_X : MARKER_GRAPH_SEL_Y;
+ sel_flag = value_source == CLIP_VALUE_SOURCE_SPEED_X ? MARKER_GRAPH_SEL_X : MARKER_GRAPH_SEL_Y;
sel = (marker->flag & sel_flag) ? 1 : 0;
if (sel == data->sel) {
@@ -131,34 +159,39 @@ static void tracking_segment_knot_cb(void *userdata,
}
}
-static void draw_tracks_motion_curves(View2D *v2d, SpaceClip *sc, unsigned int pos)
+static void draw_tracks_motion_and_error_curves(View2D *v2d, SpaceClip *sc, unsigned int pos)
{
MovieClip *clip = ED_space_clip_get_clip(sc);
MovieTracking *tracking = &clip->tracking;
MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);
- int width, height;
- TrackMotionCurveUserData userdata;
+ const bool draw_knots = (sc->flag & SC_SHOW_GRAPH_TRACKS_MOTION) != 0;
+ int width, height;
BKE_movieclip_get_size(clip, &sc->user, &width, &height);
-
if (!width || !height) {
return;
}
- /* non-selected knot handles */
+ TrackMotionCurveUserData userdata;
+ userdata.sc = sc;
userdata.hsize = UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE);
userdata.sel = false;
userdata.act_track = act_track;
userdata.pos = pos;
- UI_view2d_scale_get(v2d, &userdata.xscale, &userdata.yscale);
- clip_graph_tracking_values_iterate(sc,
- (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0,
- (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0,
- &userdata,
- tracking_segment_knot_cb,
- NULL,
- NULL);
- /* draw graph lines */
+
+ /* Non-selected knot handles. */
+ if (draw_knots) {
+ UI_view2d_scale_get(v2d, &userdata.xscale, &userdata.yscale);
+ clip_graph_tracking_values_iterate(sc,
+ (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0,
+ (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0,
+ &userdata,
+ tracking_segment_knot_cb,
+ NULL,
+ NULL);
+ }
+
+ /* Draw graph lines. */
GPU_blend(true);
clip_graph_tracking_values_iterate(sc,
(sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0,
@@ -169,138 +202,19 @@ static void draw_tracks_motion_curves(View2D *v2d, SpaceClip *sc, unsigned int p
tracking_segment_end_cb);
GPU_blend(false);
- /* selected knot handles on top of curves */
- userdata.sel = true;
- clip_graph_tracking_values_iterate(sc,
- (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0,
- (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0,
- &userdata,
- tracking_segment_knot_cb,
- NULL,
- NULL);
-}
-
-typedef struct TrackErrorCurveUserData {
- MovieClip *clip;
- MovieTracking *tracking;
- MovieTrackingObject *tracking_object;
- MovieTrackingTrack *active_track;
- bool matrix_initialized;
- int matrix_frame;
- float projection_matrix[4][4];
- int width, height;
- float aspy;
- unsigned int pos;
-} TrackErrorCurveUserData;
-
-static void tracking_error_segment_point_cb(void *userdata,
- MovieTrackingTrack *track,
- MovieTrackingMarker *marker,
- int coord,
- int scene_framenr,
- float UNUSED(value))
-{
- if (coord == 1) {
- TrackErrorCurveUserData *data = (TrackErrorCurveUserData *)userdata;
- float reprojected_position[4], bundle_position[4], marker_position[2], delta[2];
- float reprojection_error;
- float weight = BKE_tracking_track_get_weight_for_marker(data->clip, track, marker);
-
- if (!data->matrix_initialized || data->matrix_frame != scene_framenr) {
- BKE_tracking_get_projection_matrix(data->tracking,
- data->tracking_object,
- scene_framenr,
- data->width,
- data->height,
- data->projection_matrix);
- }
-
- copy_v3_v3(bundle_position, track->bundle_pos);
- bundle_position[3] = 1;
-
- mul_v4_m4v4(reprojected_position, data->projection_matrix, bundle_position);
- reprojected_position[0] = (reprojected_position[0] / (reprojected_position[3] * 2.0f) + 0.5f) *
- data->width;
- reprojected_position[1] = (reprojected_position[1] / (reprojected_position[3] * 2.0f) + 0.5f) *
- data->height * data->aspy;
-
- BKE_tracking_distort_v2(data->tracking, reprojected_position, reprojected_position);
-
- marker_position[0] = (marker->pos[0] + track->offset[0]) * data->width;
- marker_position[1] = (marker->pos[1] + track->offset[1]) * data->height * data->aspy;
-
- sub_v2_v2v2(delta, reprojected_position, marker_position);
- reprojection_error = len_v2(delta) * weight;
-
- immVertex2f(data->pos, scene_framenr, reprojection_error);
- }
-}
-
-static void tracking_error_segment_start_cb(void *userdata,
- MovieTrackingTrack *track,
- int coord,
- bool is_point)
-{
- if (coord == 1) {
- TrackErrorCurveUserData *data = (TrackErrorCurveUserData *)userdata;
- float col[4] = {0.0f, 0.0f, 1.0f, 1.0f};
-
- if (track == data->active_track) {
- col[3] = 1.0f;
- GPU_line_width(2.0f);
- }
- else {
- col[3] = 0.5f;
- GPU_line_width(1.0f);
- }
-
- immUniformColor4fv(col);
-
- if (is_point) { /* This probably never happens here, but just in case... */
- immBeginAtMost(GPU_PRIM_POINTS, 1);
- }
- else {
- /* Graph can be composed of smaller segments, if any marker is disabled */
- immBeginAtMost(GPU_PRIM_LINE_STRIP, track->markersnr);
- }
- }
-}
-
-static void tracking_error_segment_end_cb(void *UNUSED(userdata), int coord)
-{
- if (coord == 1) {
- immEnd();
+ /* Selected knot handles on top of curves. */
+ if (draw_knots) {
+ userdata.sel = true;
+ clip_graph_tracking_values_iterate(sc,
+ (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0,
+ (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0,
+ &userdata,
+ tracking_segment_knot_cb,
+ NULL,
+ NULL);
}
}
-static void draw_tracks_error_curves(SpaceClip *sc, unsigned int pos)
-{
- MovieClip *clip = ED_space_clip_get_clip(sc);
- MovieTracking *tracking = &clip->tracking;
- TrackErrorCurveUserData data;
-
- data.clip = clip;
- data.tracking = tracking;
- data.tracking_object = BKE_tracking_object_get_active(tracking);
- data.active_track = BKE_tracking_track_get_active(tracking);
- data.matrix_initialized = false;
- data.pos = pos;
- BKE_movieclip_get_size(clip, &sc->user, &data.width, &data.height);
- data.aspy = 1.0f / tracking->camera.pixel_aspect;
-
- if (!data.width || !data.height) {
- return;
- }
-
- clip_graph_tracking_values_iterate(sc,
- (sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0,
- (sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0,
- &data,
- tracking_error_segment_point_cb,
- tracking_error_segment_start_cb,
- tracking_error_segment_end_cb);
-}
-
static void draw_frame_curves(SpaceClip *sc, unsigned int pos)
{
MovieClip *clip = ED_space_clip_get_clip(sc);
@@ -350,12 +264,8 @@ void clip_draw_graph(SpaceClip *sc, ARegion *ar, Scene *scene)
GPU_point_size(3.0f);
- if (sc->flag & SC_SHOW_GRAPH_TRACKS_MOTION) {
- draw_tracks_motion_curves(v2d, sc, pos);
- }
-
- if (sc->flag & SC_SHOW_GRAPH_TRACKS_ERROR) {
- draw_tracks_error_curves(sc, pos);
+ if (sc->flag & (SC_SHOW_GRAPH_TRACKS_MOTION | SC_SHOW_GRAPH_TRACKS_ERROR)) {
+ draw_tracks_motion_and_error_curves(v2d, sc, pos);
}
if (sc->flag & SC_SHOW_GRAPH_FRAMES) {
diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c
index a3722433e33..58a00d2e6b9 100644
--- a/source/blender/editors/space_clip/clip_graph_ops.c
+++ b/source/blender/editors/space_clip/clip_graph_ops.c
@@ -64,7 +64,7 @@ static bool clip_graph_knots_poll(bContext *C)
if (ED_space_clip_graph_poll(C)) {
SpaceClip *sc = CTX_wm_space_clip(C);
- return (sc->flag & SC_SHOW_GRAPH_TRACKS_MOTION) != 0;
+ return (sc->flag & (SC_SHOW_GRAPH_TRACKS_MOTION | SC_SHOW_GRAPH_TRACKS_ERROR)) != 0;
}
return false;
}
@@ -93,13 +93,14 @@ static void toggle_selection_cb(void *userdata, MovieTrackingMarker *marker)
/******************** mouse select operator ********************/
typedef struct {
- int coord; /* coordinate index of found entuty (0 = X-axis, 1 = Y-axis) */
+ SpaceClip *sc;
+ eClipCurveValueSource value_source;
bool has_prev; /* if there's valid coordinate of previous point of curve segment */
- float min_dist_sq, /* minimal distance between mouse and currently found entity */
- mouse_co[2], /* mouse coordinate */
- prev_co[2], /* coordinate of previeous point of segment */
- min_co[2]; /* coordinate of entity with minimal distance */
+ float min_dist_sq; /* minimal distance between mouse and currently found entity */
+ float mouse_co[2]; /* mouse coordinate */
+ float prev_co[2]; /* coordinate of previous point of segment */
+ float min_co[2]; /* coordinate of entity with minimal distance */
MovieTrackingTrack *track; /* nearest found track */
MovieTrackingMarker *marker; /* nearest found marker */
@@ -108,20 +109,24 @@ typedef struct {
static void find_nearest_tracking_segment_cb(void *userdata,
MovieTrackingTrack *track,
MovieTrackingMarker *UNUSED(marker),
- int coord,
+ eClipCurveValueSource value_source,
int scene_framenr,
float val)
{
MouseSelectUserData *data = userdata;
float co[2] = {scene_framenr, val};
+ if (!clip_graph_value_visible(data->sc, value_source)) {
+ return;
+ }
+
if (data->has_prev) {
float dist_sq = dist_squared_to_line_segment_v2(data->mouse_co, data->prev_co, co);
if (data->track == NULL || dist_sq < data->min_dist_sq) {
data->track = track;
data->min_dist_sq = dist_sq;
- data->coord = coord;
+ data->value_source = value_source;
copy_v2_v2(data->min_co, co);
}
}
@@ -130,7 +135,8 @@ static void find_nearest_tracking_segment_cb(void *userdata,
copy_v2_v2(data->prev_co, co);
}
-static void find_nearest_tracking_segment_end_cb(void *userdata, int UNUSED(coord))
+static void find_nearest_tracking_segment_end_cb(void *userdata,
+ eClipCurveValueSource UNUSED(source_value))
{
MouseSelectUserData *data = userdata;
@@ -140,7 +146,7 @@ static void find_nearest_tracking_segment_end_cb(void *userdata, int UNUSED(coor
static void find_nearest_tracking_knot_cb(void *userdata,
MovieTrackingTrack *track,
MovieTrackingMarker *marker,
- int coord,
+ eClipCurveValueSource value_source,
int scene_framenr,
float val)
{
@@ -148,20 +154,26 @@ static void find_nearest_tracking_knot_cb(void *userdata,
float mdiff[2] = {scene_framenr - data->mouse_co[0], val - data->mouse_co[1]};
float dist_sq = len_squared_v2(mdiff);
+ if (!clip_graph_value_visible(data->sc, value_source)) {
+ return;
+ }
+
if (data->marker == NULL || dist_sq < data->min_dist_sq) {
float co[2] = {scene_framenr, val};
data->track = track;
data->marker = marker;
data->min_dist_sq = dist_sq;
- data->coord = coord;
+ data->value_source = value_source;
copy_v2_v2(data->min_co, co);
}
}
-static void mouse_select_init_data(MouseSelectUserData *userdata, const float co[2])
+static void mouse_select_init_data(bContext *C, MouseSelectUserData *userdata, const float co[2])
{
+ SpaceClip *sc = CTX_wm_space_clip(C);
memset(userdata, 0, sizeof(MouseSelectUserData));
+ userdata->sc = sc;
userdata->min_dist_sq = FLT_MAX;
copy_v2_v2(userdata->mouse_co, co);
}
@@ -179,7 +191,7 @@ static bool mouse_select_knot(bContext *C, float co[2], bool extend)
if (act_track) {
MouseSelectUserData userdata;
- mouse_select_init_data(&userdata, co);
+ mouse_select_init_data(C, &userdata, co);
clip_graph_tracking_values_iterate_track(
sc, act_track, &userdata, find_nearest_tracking_knot_cb, NULL, NULL);
@@ -199,7 +211,7 @@ static bool mouse_select_knot(bContext *C, float co[2], bool extend)
toggle_selection_cb);
}
- if (userdata.coord == 0) {
+ if (userdata.value_source == CLIP_VALUE_SOURCE_SPEED_X) {
if (extend && (userdata.marker->flag & MARKER_GRAPH_SEL_X) != 0) {
userdata.marker->flag &= ~MARKER_GRAPH_SEL_X;
}
@@ -207,7 +219,7 @@ static bool mouse_select_knot(bContext *C, float co[2], bool extend)
userdata.marker->flag |= MARKER_GRAPH_SEL_X;
}
}
- else {
+ else if (userdata.value_source == CLIP_VALUE_SOURCE_SPEED_Y) {
if (extend && (userdata.marker->flag & MARKER_GRAPH_SEL_Y) != 0) {
userdata.marker->flag &= ~MARKER_GRAPH_SEL_Y;
}
@@ -232,7 +244,7 @@ static bool mouse_select_curve(bContext *C, float co[2], bool extend)
MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking);
MouseSelectUserData userdata;
- mouse_select_init_data(&userdata, co);
+ mouse_select_init_data(C, &userdata, co);
clip_graph_tracking_values_iterate(sc,
(sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0,
(sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0,
@@ -281,7 +293,7 @@ static int mouse_select(bContext *C, float co[2], bool extend)
sel = mouse_select_knot(C, co, extend);
if (!sel) {
- /* if there's no close enough knot to mouse osition, select nearest curve */
+ /* if there's no close enough knot to mouse position, select nearest curve */
sel = mouse_select_curve(C, co, extend);
}
@@ -356,16 +368,19 @@ typedef struct BoxSelectuserData {
static void box_select_cb(void *userdata,
MovieTrackingTrack *UNUSED(track),
MovieTrackingMarker *marker,
- int coord,
+ eClipCurveValueSource value_source,
int scene_framenr,
float val)
{
BoxSelectuserData *data = (BoxSelectuserData *)userdata;
+ if (!ELEM(value_source, CLIP_VALUE_SOURCE_SPEED_X, CLIP_VALUE_SOURCE_SPEED_Y)) {
+ return;
+ }
if (BLI_rctf_isect_pt(&data->rect, scene_framenr, val)) {
int flag = 0;
- if (coord == 0) {
+ if (value_source == CLIP_VALUE_SOURCE_SPEED_X) {
flag = MARKER_GRAPH_SEL_X;
}
else {
@@ -591,7 +606,7 @@ typedef struct {
static void view_all_cb(void *userdata,
MovieTrackingTrack *UNUSED(track),
MovieTrackingMarker *UNUSED(marker),
- int UNUSED(coord),
+ eClipCurveValueSource UNUSED(value_source),
int UNUSED(scene_framenr),
float val)
{
diff --git a/source/blender/editors/space_clip/clip_intern.h b/source/blender/editors/space_clip/clip_intern.h
index 7683823a79f..8599de9f16f 100644
--- a/source/blender/editors/space_clip/clip_intern.h
+++ b/source/blender/editors/space_clip/clip_intern.h
@@ -112,35 +112,44 @@ void CLIP_OT_cursor_set(struct wmOperatorType *ot);
struct ARegion *ED_clip_has_properties_region(struct ScrArea *sa);
/* clip_utils.c */
-void clip_graph_tracking_values_iterate_track(
- struct SpaceClip *sc,
- struct MovieTrackingTrack *track,
- void *userdata,
- void (*func)(void *userdata,
- struct MovieTrackingTrack *track,
- struct MovieTrackingMarker *marker,
- int coord,
- int scene_framenr,
- float val),
- void (*segment_start)(
- void *userdata, struct MovieTrackingTrack *track, int coord, bool is_point),
- void (*segment_end)(void *userdata, int coord));
+
+typedef enum {
+ CLIP_VALUE_SOURCE_SPEED_X,
+ CLIP_VALUE_SOURCE_SPEED_Y,
+ CLIP_VALUE_SOURCE_REPROJECTION_ERROR,
+} eClipCurveValueSource;
+
+typedef void (*ClipTrackValueCallback)(void *userdata,
+ struct MovieTrackingTrack *track,
+ struct MovieTrackingMarker *marker,
+ eClipCurveValueSource value_source,
+ int scene_framenr,
+ float val);
+
+typedef void (*ClipTrackValueSegmentStartCallback)(void *userdata,
+ struct MovieTrackingTrack *track,
+ eClipCurveValueSource value_source,
+ bool is_point);
+
+typedef void (*ClipTrackValueSegmentEndCallback)(void *userdata,
+ eClipCurveValueSource value_source);
+
+bool clip_graph_value_visible(struct SpaceClip *sc, eClipCurveValueSource value_source);
+
+void clip_graph_tracking_values_iterate_track(struct SpaceClip *sc,
+ struct MovieTrackingTrack *track,
+ void *userdata,
+ ClipTrackValueCallback func,
+ ClipTrackValueSegmentStartCallback segment_start,
+ ClipTrackValueSegmentEndCallback segment_end);
void clip_graph_tracking_values_iterate(struct SpaceClip *sc,
bool selected_only,
bool include_hidden,
void *userdata,
- void (*func)(void *userdata,
- struct MovieTrackingTrack *track,
- struct MovieTrackingMarker *marker,
- int coord,
- int scene_framenr,
- float val),
- void (*segment_start)(void *userdata,
- struct MovieTrackingTrack *track,
- int coord,
- bool is_point),
- void (*segment_end)(void *userdata, int coord));
+ ClipTrackValueCallback func,
+ ClipTrackValueSegmentStartCallback segment_start,
+ ClipTrackValueSegmentEndCallback segment_end);
void clip_graph_tracking_iterate(struct SpaceClip *sc,
bool selected_only,
diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c
index 45479c4253d..5f04d0863a7 100644
--- a/source/blender/editors/space_clip/clip_ops.c
+++ b/source/blender/editors/space_clip/clip_ops.c
@@ -626,36 +626,35 @@ static void view_zoom_apply(
bContext *C, ViewZoomData *vpd, wmOperator *op, const wmEvent *event, const bool zoom_to_pos)
{
float factor;
+ float delta;
- if (U.viewzoom == USER_ZOOM_CONT) {
- SpaceClip *sclip = CTX_wm_space_clip(C);
- double time = PIL_check_seconds_timer();
- float time_step = (float)(time - vpd->timer_lastdraw);
- float fac;
- float zfac;
-
+ if (U.viewzoom != USER_ZOOM_SCALE) {
if (U.uiflag & USER_ZOOM_HORIZ) {
- fac = (float)(event->x - vpd->x);
+ delta = (float)(event->x - vpd->x);
}
else {
- fac = (float)(event->y - vpd->y);
+ delta = (float)(event->y - vpd->y);
}
+ }
+ else {
+ delta = event->x - vpd->x + event->y - vpd->y;
+ }
- if (U.uiflag & USER_ZOOM_INVERT) {
- fac = -fac;
- }
+ if (U.uiflag & USER_ZOOM_INVERT) {
+ delta = -delta;
+ }
- zfac = 1.0f + ((fac / 20.0f) * time_step);
+ if (U.viewzoom == USER_ZOOM_CONT) {
+ SpaceClip *sclip = CTX_wm_space_clip(C);
+ double time = PIL_check_seconds_timer();
+ float time_step = (float)(time - vpd->timer_lastdraw);
+ float zfac;
+
+ zfac = 1.0f + ((delta / 20.0f) * time_step);
vpd->timer_lastdraw = time;
factor = (sclip->zoom * zfac) / vpd->zoom;
}
else {
- float delta = event->x - vpd->x + event->y - vpd->y;
-
- if (U.uiflag & USER_ZOOM_INVERT) {
- delta *= -1;
- }
-
factor = 1.0f + delta / 300.0f;
}
@@ -1434,7 +1433,7 @@ static void proxy_endjob(void *pjv)
if (pj->clip->source == MCLIP_SRC_MOVIE) {
/* Timecode might have changed, so do a full reload to deal with this. */
- BKE_movieclip_reload(pj->main, pj->clip);
+ DEG_id_tag_update(&pj->clip->id, ID_RECALC_SOURCE);
}
else {
/* For image sequences we'll preserve original cache. */
diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c
index 3dfe529f8e8..48f788e2e3a 100644
--- a/source/blender/editors/space_clip/clip_utils.c
+++ b/source/blender/editors/space_clip/clip_utils.c
@@ -27,6 +27,7 @@
#include "BLI_utildefines.h"
#include "BLI_listbase.h"
+#include "BLI_math.h"
#include "BKE_animsys.h"
#include "BKE_context.h"
@@ -52,18 +53,28 @@
#include "clip_intern.h" // own include
-void clip_graph_tracking_values_iterate_track(
+bool clip_graph_value_visible(SpaceClip *sc, eClipCurveValueSource value_source)
+{
+ if (ELEM(value_source, CLIP_VALUE_SOURCE_SPEED_X, CLIP_VALUE_SOURCE_SPEED_Y)) {
+ if ((sc->flag & SC_SHOW_GRAPH_TRACKS_MOTION) == 0) {
+ return false;
+ }
+ }
+ else if (value_source == CLIP_VALUE_SOURCE_REPROJECTION_ERROR) {
+ if ((sc->flag & SC_SHOW_GRAPH_TRACKS_ERROR) == 0) {
+ return false;
+ }
+ }
+ return true;
+}
+
+static void clip_graph_tracking_values_iterate_track_speed_values(
SpaceClip *sc,
MovieTrackingTrack *track,
void *userdata,
- void (*func)(void *userdata,
- MovieTrackingTrack *track,
- MovieTrackingMarker *marker,
- int coord,
- int scene_framenr,
- float val),
- void (*segment_start)(void *userdata, MovieTrackingTrack *track, int coord, bool is_point),
- void (*segment_end)(void *userdata, int coord))
+ ClipTrackValueCallback func,
+ ClipTrackValueSegmentStartCallback segment_start,
+ ClipTrackValueSegmentEndCallback segment_end)
{
MovieClip *clip = ED_space_clip_get_clip(sc);
int width, height, coord;
@@ -71,6 +82,8 @@ void clip_graph_tracking_values_iterate_track(
BKE_movieclip_get_size(clip, &sc->user, &width, &height);
for (coord = 0; coord < 2; coord++) {
+ eClipCurveValueSource value_source = (coord == 0) ? CLIP_VALUE_SOURCE_SPEED_X :
+ CLIP_VALUE_SOURCE_SPEED_Y;
int i, prevfra = track->markers[0].framenr;
bool open = false;
float prevval = 0.0f;
@@ -82,7 +95,7 @@ void clip_graph_tracking_values_iterate_track(
if (marker->flag & MARKER_DISABLED) {
if (open) {
if (segment_end) {
- segment_end(userdata, coord);
+ segment_end(userdata, value_source);
}
open = false;
@@ -94,10 +107,11 @@ void clip_graph_tracking_values_iterate_track(
if (!open) {
if (segment_start) {
if ((i + 1) == track->markersnr) {
- segment_start(userdata, track, coord, true);
+ segment_start(userdata, track, value_source, true);
}
else {
- segment_start(userdata, track, coord, (track->markers[i + 1].flag & MARKER_DISABLED));
+ segment_start(
+ userdata, track, value_source, (track->markers[i + 1].flag & MARKER_DISABLED));
}
}
@@ -112,7 +126,7 @@ void clip_graph_tracking_values_iterate_track(
if (func) {
int scene_framenr = BKE_movieclip_remap_clip_to_scene_frame(clip, marker->framenr);
- func(userdata, track, marker, coord, scene_framenr, val);
+ func(userdata, track, marker, value_source, scene_framenr, val);
}
prevval = marker->pos[coord];
@@ -121,25 +135,139 @@ void clip_graph_tracking_values_iterate_track(
if (open) {
if (segment_end) {
- segment_end(userdata, coord);
+ segment_end(userdata, value_source);
}
}
}
}
-void clip_graph_tracking_values_iterate(
+static float calculate_reprojection_error_at_marker(MovieClip *clip,
+ MovieTracking *tracking,
+ MovieTrackingObject *tracking_object,
+ MovieTrackingTrack *track,
+ MovieTrackingMarker *marker,
+ const int clip_width,
+ const int clip_height,
+ const int scene_framenr)
+{
+ float reprojected_position[4], bundle_position[4], marker_position[2], delta[2];
+ float weight = BKE_tracking_track_get_weight_for_marker(clip, track, marker);
+ const float aspy = 1.0f / tracking->camera.pixel_aspect;
+
+ float projection_matrix[4][4];
+ BKE_tracking_get_projection_matrix(
+ tracking, tracking_object, scene_framenr, clip_width, clip_height, projection_matrix);
+
+ copy_v3_v3(bundle_position, track->bundle_pos);
+ bundle_position[3] = 1;
+
+ mul_v4_m4v4(reprojected_position, projection_matrix, bundle_position);
+ reprojected_position[0] = (reprojected_position[0] / (reprojected_position[3] * 2.0f) + 0.5f) *
+ clip_width;
+ reprojected_position[1] = (reprojected_position[1] / (reprojected_position[3] * 2.0f) + 0.5f) *
+ clip_height * aspy;
+
+ BKE_tracking_distort_v2(tracking, reprojected_position, reprojected_position);
+
+ marker_position[0] = (marker->pos[0] + track->offset[0]) * clip_width;
+ marker_position[1] = (marker->pos[1] + track->offset[1]) * clip_height * aspy;
+
+ sub_v2_v2v2(delta, reprojected_position, marker_position);
+ return len_v2(delta) * weight;
+}
+
+static void clip_graph_tracking_values_iterate_track_reprojection_error_values(
SpaceClip *sc,
- bool selected_only,
- bool include_hidden,
+ MovieTrackingTrack *track,
void *userdata,
- void (*func)(void *userdata,
- MovieTrackingTrack *track,
- MovieTrackingMarker *marker,
- int coord,
- int scene_framenr,
- float val),
- void (*segment_start)(void *userdata, MovieTrackingTrack *track, int coord, bool is_point),
- void (*segment_end)(void *userdata, int coord))
+ ClipTrackValueCallback func,
+ ClipTrackValueSegmentStartCallback segment_start,
+ ClipTrackValueSegmentEndCallback segment_end)
+{
+ /* Tracks without bundle can not have any reprojection error curve. */
+ if ((track->flag & TRACK_HAS_BUNDLE) == 0) {
+ return;
+ }
+
+ MovieClip *clip = ED_space_clip_get_clip(sc);
+ MovieTracking *tracking = &clip->tracking;
+ MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(tracking);
+
+ int clip_width, clip_height;
+ BKE_movieclip_get_size(clip, &sc->user, &clip_width, &clip_height);
+
+ /* Iterate over segments. */
+ bool is_segment_open = false;
+ for (int marker_index = 0; marker_index < track->markersnr; marker_index++) {
+ MovieTrackingMarker *marker = &track->markers[marker_index];
+
+ /* End of tracked segment, no reprojection error can be calculated here since the ground truth
+ * 2D position is not known. */
+ if (marker->flag & MARKER_DISABLED) {
+ if (is_segment_open) {
+ if (segment_end != NULL) {
+ segment_end(userdata, CLIP_VALUE_SOURCE_REPROJECTION_ERROR);
+ }
+ is_segment_open = false;
+ }
+ continue;
+ }
+
+ /* Begin new segment if it is not open yet. */
+ if (!is_segment_open) {
+ if (segment_start != NULL) {
+ if ((marker_index + 1) == track->markersnr) {
+ segment_start(userdata, track, CLIP_VALUE_SOURCE_REPROJECTION_ERROR, true);
+ }
+ else {
+ segment_start(userdata,
+ track,
+ CLIP_VALUE_SOURCE_REPROJECTION_ERROR,
+ (track->markers[marker_index + 1].flag & MARKER_DISABLED));
+ }
+ }
+ is_segment_open = true;
+ }
+
+ if (func != NULL) {
+ const int scene_framenr = BKE_movieclip_remap_clip_to_scene_frame(clip, marker->framenr);
+ const float reprojection_error = calculate_reprojection_error_at_marker(
+ clip, tracking, tracking_object, track, marker, clip_width, clip_height, scene_framenr);
+ func(userdata,
+ track,
+ marker,
+ CLIP_VALUE_SOURCE_REPROJECTION_ERROR,
+ scene_framenr,
+ reprojection_error);
+ }
+ }
+
+ if (is_segment_open && segment_end != NULL) {
+ segment_end(userdata, CLIP_VALUE_SOURCE_REPROJECTION_ERROR);
+ }
+}
+
+void clip_graph_tracking_values_iterate_track(SpaceClip *sc,
+ MovieTrackingTrack *track,
+ void *userdata,
+ ClipTrackValueCallback func,
+ ClipTrackValueSegmentStartCallback segment_start,
+ ClipTrackValueSegmentEndCallback segment_end)
+{
+ clip_graph_tracking_values_iterate_track_speed_values(
+ sc, track, userdata, func, segment_start, segment_end);
+
+ clip_graph_tracking_values_iterate_track_reprojection_error_values(
+ sc, track, userdata, func, segment_start, segment_end);
+}
+
+void clip_graph_tracking_values_iterate(SpaceClip *sc,
+ bool selected_only,
+ bool include_hidden,
+ void *userdata,
+ ClipTrackValueCallback func,
+ ClipTrackValueSegmentStartCallback segment_start,
+ ClipTrackValueSegmentEndCallback segment_end)
{
MovieClip *clip = ED_space_clip_get_clip(sc);
MovieTracking *tracking = &clip->tracking;
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index 7e19ac255f0..c1cb975447f 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -556,17 +556,17 @@ static void clip_operatortypes(void)
static void clip_keymap(struct wmKeyConfig *keyconf)
{
- /* ******** Global hotkeys avalaible for all regions ******** */
+ /* ******** Global hotkeys available for all regions ******** */
WM_keymap_ensure(keyconf, "Clip", SPACE_CLIP, 0);
- /* ******** Hotkeys avalaible for main region only ******** */
+ /* ******** Hotkeys available for main region only ******** */
WM_keymap_ensure(keyconf, "Clip Editor", SPACE_CLIP, 0);
// keymap->poll = ED_space_clip_tracking_poll;
- /* ******** Hotkeys avalaible for preview region only ******** */
+ /* ******** Hotkeys available for preview region only ******** */
WM_keymap_ensure(keyconf, "Clip Graph Editor", SPACE_CLIP, 0);
- /* ******** Hotkeys avalaible for channels region only ******** */
+ /* ******** Hotkeys available for channels region only ******** */
WM_keymap_ensure(keyconf, "Clip Dopesheet Editor", SPACE_CLIP, 0);
}
@@ -947,7 +947,7 @@ static void clip_main_region_draw(const bContext *C, ARegion *ar)
ScrArea *sa = CTX_wm_area(C);
int mask_width, mask_height;
ED_mask_get_size(sa, &mask_width, &mask_height);
- ED_mask_draw_region(CTX_data_depsgraph(C),
+ ED_mask_draw_region(CTX_data_expect_evaluated_depsgraph(C),
mask,
ar,
sc->mask_info.draw_flag,
@@ -1224,7 +1224,7 @@ static void clip_header_region_listener(wmWindow *UNUSED(win),
switch (wmn->data) {
/* for proportional editmode only */
case ND_TOOLSETTINGS:
- /* TODO - should do this when in mask mode only but no datas available */
+ /* TODO - should do this when in mask mode only but no data available */
// if (sc->mode == SC_MODE_MASKEDIT)
{
ED_region_tag_redraw(ar);
diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c
index d8d50ba72b5..1375b99bdaa 100644
--- a/source/blender/editors/space_clip/tracking_ops.c
+++ b/source/blender/editors/space_clip/tracking_ops.c
@@ -1894,6 +1894,7 @@ static int tracking_object_new_exec(bContext *C, wmOperator *UNUSED(op))
BKE_tracking_object_add(tracking, "Object");
+ DEG_id_tag_update(&clip->id, ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip);
return OPERATOR_FINISHED;
@@ -1932,6 +1933,7 @@ static int tracking_object_remove_exec(bContext *C, wmOperator *op)
BKE_tracking_object_delete(tracking, object);
+ DEG_id_tag_update(&clip->id, ID_RECALC_COPY_ON_WRITE);
WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/space_clip/tracking_ops_orient.c b/source/blender/editors/space_clip/tracking_ops_orient.c
index 61991993b10..de0025a53d2 100644
--- a/source/blender/editors/space_clip/tracking_ops_orient.c
+++ b/source/blender/editors/space_clip/tracking_ops_orient.c
@@ -39,6 +39,7 @@
#include "BKE_report.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -395,7 +396,6 @@ static int set_plane_exec(bContext *C, wmOperator *op)
ListBase *tracksbase;
Object *object;
Object *camera = get_camera_with_movieclip(scene, clip);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
int tot = 0;
float vec[3][3], mat[4][4], obmat[4][4], newmat[4][4], orig[3] = {0.0f, 0.0f, 0.0f};
int plane = RNA_enum_get(op->ptr, "plane");
@@ -484,7 +484,13 @@ static int set_plane_exec(bContext *C, wmOperator *op)
BKE_object_apply_mat4(object, mat, 0, 0);
}
- BKE_object_where_is_calc(depsgraph, scene, object);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
+ Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
+ Object *object_eval = DEG_get_evaluated_object(depsgraph, object);
+ BKE_object_transform_copy(object_eval, object);
+ BKE_object_where_is_calc(depsgraph, scene_eval, object_eval);
+ BKE_object_transform_copy(object, object_eval);
+
set_axis(scene, object, clip, tracking_object, axis_track, 'X');
DEG_id_tag_update(&clip->id, 0);
diff --git a/source/blender/editors/space_clip/tracking_ops_solve.c b/source/blender/editors/space_clip/tracking_ops_solve.c
index 4490655393e..806df4dbaff 100644
--- a/source/blender/editors/space_clip/tracking_ops_solve.c
+++ b/source/blender/editors/space_clip/tracking_ops_solve.c
@@ -122,8 +122,14 @@ static void solve_camera_freejob(void *scv)
solved = BKE_tracking_reconstruction_finish(scj->context, tracking);
if (!solved) {
- BKE_report(
- scj->reports, RPT_WARNING, "Some data failed to reconstruct (see console for details)");
+ const char *error_message = BKE_tracking_reconstruction_error_message_get(scj->context);
+ if (error_message[0]) {
+ BKE_report(scj->reports, RPT_ERROR, error_message);
+ }
+ else {
+ BKE_report(
+ scj->reports, RPT_WARNING, "Some data failed to reconstruct (see console for details)");
+ }
}
else {
BKE_reportf(scj->reports,
@@ -146,6 +152,7 @@ static void solve_camera_freejob(void *scv)
int width, height;
BKE_movieclip_get_size(clip, &scj->user, &width, &height);
BKE_tracking_camera_to_blender(tracking, scene, camera, width, height);
+ DEG_id_tag_update(&camera->id, ID_RECALC_COPY_ON_WRITE);
WM_main_add_notifier(NC_OBJECT, camera);
}
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 9bdea13276b..3a6d59c1dbf 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -536,7 +536,7 @@ static void renamebutton_cb(bContext *C, void *UNUSED(arg1), char *oldname)
WM_report_banner_show();
}
else {
- /* If rename is sucessfull, scroll to newly renamed entry. */
+ /* If rename is successful, scroll to newly renamed entry. */
BLI_strncpy(sfile->params->renamefile, filename, sizeof(sfile->params->renamefile));
sfile->params->rename_flag = FILE_PARAMS_RENAME_POSTSCROLL_PENDING;
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 4e50413513a..eb5f02b6e13 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -1757,7 +1757,7 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w
(middle_offset - min_middle_offset < items_block_size));
/* OR edited item must be towards the end, and we are scrolled fully to the end.
* This one is crucial (unlike the one for the beginning), because without it we won't scroll
- * fully to the end, and last column or row wil end up only partially drawn. */
+ * fully to the end, and last column or row will end up only partially drawn. */
const bool is_full_end = ((sfile->scroll_offset > max_middle_offset) &&
(max_tot_scroll - max_curr_scroll < 1.0f) &&
(max_middle_offset - middle_offset < items_block_size));
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 9004eaa7bf6..e06ee620ea7 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -1317,6 +1317,9 @@ static void filelist_cache_init(FileListEntryCache *cache, size_t cache_size)
cache->size = cache_size;
cache->flags = FLC_IS_INIT;
+
+ /* We cannot translate from non-main thread, so init translated strings once from here. */
+ IMB_thumb_ensure_translations();
}
static void filelist_cache_free(FileListEntryCache *cache)
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index faaecd975a3..db42d007b8e 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -28,7 +28,7 @@
#include <sys/stat.h>
#include <sys/types.h>
-/* path/file handeling stuff */
+/* path/file handling stuff */
#ifdef WIN32
# include <io.h>
# include <direct.h>
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index b16374e0d66..e7ba498fc11 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -721,7 +721,7 @@ static void draw_fcurve_curve_bezts(
v1[1] = prevbezt->vec[1][1];
}
else if (prevbezt->ipo == BEZT_IPO_LIN) {
- /* extrapolate linear dosnt use the handle, use the next points center instead */
+ /* extrapolate linear doesn't use the handle, use the next points center instead */
fac = (prevbezt->vec[1][0] - bezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]);
if (fac) {
fac = 1.0f / fac;
@@ -840,7 +840,7 @@ static void draw_fcurve_curve_bezts(
v1[1] = prevbezt->vec[1][1];
}
else if (prevbezt->ipo == BEZT_IPO_LIN) {
- /* extrapolate linear dosnt use the handle, use the previous points center instead */
+ /* extrapolate linear doesn't use the handle, use the previous points center instead */
bezt = prevbezt - 1;
fac = (prevbezt->vec[1][0] - bezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]);
if (fac) {
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index dc5837e3fd1..b624e21937f 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -604,7 +604,6 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode)
ReportList *reports = ac->reports;
SpaceGraph *sipo = (SpaceGraph *)ac->sl;
- struct Depsgraph *depsgraph = ac->depsgraph;
Scene *scene = ac->scene;
ToolSettings *ts = scene->toolsettings;
short flag = 0;
@@ -696,7 +695,6 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode)
*/
if (ale->id && !ale->owner && !fcu->driver) {
insert_keyframe(ac->bmain,
- depsgraph,
reports,
ale->id,
NULL,
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index b79ed1c83c4..374a58d1808 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -556,39 +556,36 @@ static void image_zoom_apply(ViewZoomData *vpd,
const bool zoom_to_pos)
{
float factor;
+ float delta;
- if (viewzoom == USER_ZOOM_CONT) {
- double time = PIL_check_seconds_timer();
- float time_step = (float)(time - vpd->timer_lastdraw);
- float fac;
- float zfac;
-
+ if (viewzoom != USER_ZOOM_SCALE) {
if (U.uiflag & USER_ZOOM_HORIZ) {
- fac = (float)(x - vpd->origx);
+ delta = (float)(x - vpd->origx);
}
else {
- fac = (float)(y - vpd->origy);
+ delta = (float)(y - vpd->origy);
}
+ }
+ else {
+ delta = x - vpd->origx + y - vpd->origy;
+ }
- if (zoom_invert) {
- fac = -fac;
- }
+ if (zoom_invert) {
+ delta = -delta;
+ }
+
+ if (viewzoom == USER_ZOOM_CONT) {
+ double time = PIL_check_seconds_timer();
+ float time_step = (float)(time - vpd->timer_lastdraw);
+ float zfac;
/* oldstyle zoom */
- zfac = 1.0f + ((fac / 20.0f) * time_step);
+ zfac = 1.0f + ((delta / 20.0f) * time_step);
vpd->timer_lastdraw = time;
/* this is the final zoom, but instead make it into a factor */
- // zoom = vpd->sima->zoom * zfac;
factor = (vpd->sima->zoom * zfac) / vpd->zoom;
}
else {
- /* for now do the same things for scale and dolly */
- float delta = x - vpd->origx + y - vpd->origy;
-
- if (zoom_invert) {
- delta *= -1.0f;
- }
-
factor = 1.0f + delta / 300.0f;
}
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index e8116193c1f..7ff075bf819 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -576,7 +576,7 @@ static void image_main_region_draw(const bContext *C, ARegion *ar)
SpaceImage *sima = CTX_wm_space_image(C);
Object *obact = CTX_data_active_object(C);
Object *obedit = CTX_data_edit_object(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C);
Mask *mask = NULL;
bool show_uvedit = false;
bool show_curve = false;
diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c
index 1c9a7d3584c..946274de882 100644
--- a/source/blender/editors/space_info/info_stats.c
+++ b/source/blender/editors/space_info/info_stats.c
@@ -158,7 +158,7 @@ static void stats_object(Object *ob, SceneStats *stats, GSet *objects_gset)
if (stats_mesheval(me_eval, is_selected, stats)) {
break;
}
- ATTR_FALLTHROUGH; /* Falltrough to displist. */
+ ATTR_FALLTHROUGH; /* Fallthrough to displist. */
}
case OB_MBALL: {
int totv = 0, totf = 0, tottri = 0;
diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c
index 0836617ab44..11933ef0811 100644
--- a/source/blender/editors/space_node/node_ops.c
+++ b/source/blender/editors/space_node/node_ops.c
@@ -143,7 +143,6 @@ void ED_operatormacros_node(void)
"Move nodes and attach to frame",
OPTYPE_UNDO | OPTYPE_REGISTER);
mot = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_boolean_set(mot->ptr, "release_confirm", true);
WM_operatortype_macro_define(ot, "NODE_OT_attach");
WM_operatortype_macro_define(ot, "NODE_OT_insert_offset");
@@ -153,7 +152,6 @@ void ED_operatormacros_node(void)
"Move nodes and attach to frame",
OPTYPE_UNDO | OPTYPE_REGISTER);
mot = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_boolean_set(mot->ptr, "release_confirm", true);
RNA_boolean_set(mot->ptr, "remove_on_cancel", true);
WM_operatortype_macro_define(ot, "NODE_OT_attach");
WM_operatortype_macro_define(ot, "NODE_OT_insert_offset");
@@ -168,7 +166,6 @@ void ED_operatormacros_node(void)
OPTYPE_UNDO | OPTYPE_REGISTER);
WM_operatortype_macro_define(ot, "NODE_OT_detach");
mot = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
- RNA_boolean_set(mot->ptr, "release_confirm", true);
WM_operatortype_macro_define(ot, "NODE_OT_attach");
ot = WM_operatortype_append_macro("NODE_OT_duplicate_move",
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index bee615108f9..c932766ab93 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -113,7 +113,7 @@ static void do_outliner_activate_obdata(
bContext *C, Scene *scene, ViewLayer *view_layer, Base *base, const bool extend)
{
Main *bmain = CTX_data_main(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Object *obact = OBACT(view_layer);
Object *ob = base->object;
bool use_all = false;
@@ -161,7 +161,7 @@ static void do_outliner_activate_pose(
bContext *C, Scene *scene, ViewLayer *view_layer, Base *base, const bool extend)
{
Main *bmain = CTX_data_main(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Object *obact = OBACT(view_layer);
Object *ob = base->object;
bool use_all = false;
@@ -341,7 +341,7 @@ static eOLDrawState tree_element_set_active_object(bContext *C,
if (base && !BKE_object_is_mode_compat(base->object, object_mode)) {
if (object_mode == OB_MODE_OBJECT) {
struct Main *bmain = CTX_data_main(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ED_object_mode_generic_exit(bmain, depsgraph, scene, base->object);
}
if (!BKE_object_is_mode_compat(base->object, object_mode)) {
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index 89eb3b9d953..f9905cc4fcd 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -747,6 +747,7 @@ static void clear_animdata_cb(int UNUSED(event),
void *UNUSED(arg))
{
BKE_animdata_free(tselem->id, true);
+ DEG_id_tag_update(tselem->id, ID_RECALC_ANIMATION);
}
static void unlinkact_animdata_cb(int UNUSED(event),
@@ -756,6 +757,7 @@ static void unlinkact_animdata_cb(int UNUSED(event),
{
/* just set action to NULL */
BKE_animdata_set_action(NULL, tselem->id, NULL);
+ DEG_id_tag_update(tselem->id, ID_RECALC_ANIMATION);
}
static void cleardrivers_animdata_cb(int UNUSED(event),
@@ -767,6 +769,7 @@ static void cleardrivers_animdata_cb(int UNUSED(event),
/* just free drivers - stored as a list of F-Curves */
free_fcurves(&iat->adt->drivers);
+ DEG_id_tag_update(tselem->id, ID_RECALC_ANIMATION);
}
static void refreshdrivers_animdata_cb(int UNUSED(event),
@@ -1899,7 +1902,6 @@ static int outliner_animdata_operation_exec(bContext *C, wmOperator *op)
SpaceOutliner *soops = CTX_wm_space_outliner(C);
int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0;
eOutliner_AnimDataOps event;
- short updateDeps = 0;
/* check for invalid states */
if (soops == NULL) {
@@ -1943,7 +1945,6 @@ static int outliner_animdata_operation_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN, NULL);
// ED_undo_push(C, "Refresh Drivers"); /* no undo needed - shouldn't have any impact? */
- updateDeps = 1;
break;
case OUTLINER_ANIMOP_CLEAR_DRV:
@@ -1952,7 +1953,6 @@ static int outliner_animdata_operation_exec(bContext *C, wmOperator *op)
WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN, NULL);
ED_undo_push(C, "Clear Drivers");
- updateDeps = 1;
break;
default: // invalid
@@ -1960,10 +1960,7 @@ static int outliner_animdata_operation_exec(bContext *C, wmOperator *op)
}
/* update dependencies */
- if (updateDeps) {
- /* rebuild depsgraph for the new deps */
- DEG_relations_tag_update(CTX_data_main(C));
- }
+ DEG_relations_tag_update(CTX_data_main(C));
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/space_sequencer/sequencer_buttons.c b/source/blender/editors/space_sequencer/sequencer_buttons.c
index a6458ee5d31..6740c2baad2 100644
--- a/source/blender/editors/space_sequencer/sequencer_buttons.c
+++ b/source/blender/editors/space_sequencer/sequencer_buttons.c
@@ -76,7 +76,7 @@ static void metadata_panel_context_draw(const bContext *C, Panel *panel)
return;
}
struct Main *bmain = CTX_data_main(C);
- struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ struct Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C);
struct Scene *scene = CTX_data_scene(C);
SpaceSeq *space_sequencer = CTX_wm_space_seq(C);
/* NOTE: We can only reliably show metadata for the original (current)
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 76c198b3d6b..ea815bd5456 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -1546,7 +1546,7 @@ void sequencer_draw_preview(const bContext *C,
bool draw_backdrop)
{
struct Main *bmain = CTX_data_main(C);
- struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ struct Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C);
struct View2D *v2d = &ar->v2d;
struct ImBuf *ibuf = NULL;
struct ImBuf *scope = NULL;
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index ff0ab9285db..2cdadfbd2ab 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -181,7 +181,7 @@ static void seq_proxy_build_job(const bContext *C)
{
wmJob *wm_job;
ProxyJob *pj;
- struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ struct Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, false);
ScrArea *sa = CTX_wm_area(C);
@@ -1135,6 +1135,7 @@ static int sequencer_gap_remove_exec(bContext *C, wmOperator *op)
}
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
+ DEG_id_tag_update(&scene->id, ID_RECALC_SEQUENCER_STRIPS);
return OPERATOR_FINISHED;
}
@@ -2886,7 +2887,7 @@ static int sequencer_view_all_preview_exec(bContext *C, wmOperator *UNUSED(op))
imgwidth = (scene->r.size * scene->r.xsch) / 100;
imgheight = (scene->r.size * scene->r.ysch) / 100;
- /* Apply aspect, dosnt need to be that accurate */
+ /* Apply aspect, doesn't need to be that accurate */
imgwidth = (int)(imgwidth * (scene->r.xasp / scene->r.yasp));
if (((imgwidth >= width) || (imgheight >= height)) && ((width > 0) && (height > 0))) {
@@ -3612,7 +3613,7 @@ static int sequencer_rebuild_proxy_invoke(bContext *C,
static int sequencer_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op))
{
Main *bmain = CTX_data_main(C);
- struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene = CTX_data_scene(C);
Editing *ed = BKE_sequencer_editing_get(scene, false);
Sequence *seq;
diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c
index 2aebc6c97fb..c55d77800ff 100644
--- a/source/blender/editors/space_sequencer/sequencer_scopes.c
+++ b/source/blender/editors/space_sequencer/sequencer_scopes.c
@@ -452,7 +452,7 @@ typedef struct MakeHistogramViewData {
static void make_histogram_view_from_ibuf_byte_cb_ex(void *__restrict userdata,
const int y,
- const ParallelRangeTLS *__restrict tls)
+ const TaskParallelTLS *__restrict tls)
{
MakeHistogramViewData *data = userdata;
const ImBuf *ibuf = data->ibuf;
@@ -498,7 +498,7 @@ static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf)
.ibuf = ibuf,
.bins = bins,
};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (ibuf->y >= 256);
settings.userdata_chunk = bins;
@@ -553,7 +553,7 @@ BLI_INLINE int get_bin_float(float f)
static void make_histogram_view_from_ibuf_float_cb_ex(void *__restrict userdata,
const int y,
- const ParallelRangeTLS *__restrict tls)
+ const TaskParallelTLS *__restrict tls)
{
const MakeHistogramViewData *data = userdata;
const ImBuf *ibuf = data->ibuf;
@@ -584,7 +584,7 @@ static ImBuf *make_histogram_view_from_ibuf_float(ImBuf *ibuf)
.ibuf = ibuf,
.bins = bins,
};
- ParallelRangeSettings settings;
+ TaskParallelSettings settings;
BLI_parallel_range_settings_defaults(&settings);
settings.use_threading = (ibuf->y >= 256);
settings.userdata_chunk = bins;
diff --git a/source/blender/editors/space_sequencer/sequencer_view.c b/source/blender/editors/space_sequencer/sequencer_view.c
index 593dd86477a..534d02c7bf3 100644
--- a/source/blender/editors/space_sequencer/sequencer_view.c
+++ b/source/blender/editors/space_sequencer/sequencer_view.c
@@ -92,7 +92,7 @@ static void sample_draw(const bContext *C, ARegion *ar, void *arg_info)
static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
{
Main *bmain = CTX_data_main(C);
- struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene = CTX_data_scene(C);
SpaceSeq *sseq = (SpaceSeq *)CTX_wm_space_data(C);
ARegion *ar = CTX_wm_region(C);
diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c
index 24f282ff920..7d8424a5996 100644
--- a/source/blender/editors/space_text/space_text.c
+++ b/source/blender/editors/space_text/space_text.c
@@ -199,6 +199,7 @@ static void text_operatortypes(void)
WM_operatortype_append(TEXT_OT_convert_whitespace);
WM_operatortype_append(TEXT_OT_uncomment);
WM_operatortype_append(TEXT_OT_comment);
+ WM_operatortype_append(TEXT_OT_toggle_comment);
WM_operatortype_append(TEXT_OT_unindent);
WM_operatortype_append(TEXT_OT_indent);
@@ -254,7 +255,9 @@ static int text_context(const bContext *C, const char *member, bContextDataResul
return 1;
}
else if (CTX_data_equals(member, "edit_text")) {
- CTX_data_id_pointer_set(result, &st->text->id);
+ if (st->text != NULL) {
+ CTX_data_id_pointer_set(result, &st->text->id);
+ }
return 1;
}
diff --git a/source/blender/editors/space_text/text_intern.h b/source/blender/editors/space_text/text_intern.h
index aab5069f919..400405155f8 100644
--- a/source/blender/editors/space_text/text_intern.h
+++ b/source/blender/editors/space_text/text_intern.h
@@ -121,6 +121,7 @@ void TEXT_OT_duplicate_line(struct wmOperatorType *ot);
void TEXT_OT_convert_whitespace(struct wmOperatorType *ot);
void TEXT_OT_uncomment(struct wmOperatorType *ot);
void TEXT_OT_comment(struct wmOperatorType *ot);
+void TEXT_OT_toggle_comment(struct wmOperatorType *ot);
void TEXT_OT_unindent(struct wmOperatorType *ot);
void TEXT_OT_indent(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index 8f7bd83cbf4..95e7d906b11 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -61,7 +61,9 @@
static void txt_screen_clamp(SpaceText *st, ARegion *ar);
-/************************ util ***************************/
+/* -------------------------------------------------------------------- */
+/** \name Util
+ * \{ */
/**
* Tests if the given character represents a start of a new line or the
@@ -138,14 +140,18 @@ static char *buf_tabs_to_spaces(const char *in_buf, const int tab_size)
return out_buf;
}
-/************************ poll ***************************/
-
BLI_INLINE int text_pixel_x_to_column(SpaceText *st, const int x)
{
/* add half the char width so mouse cursor selection is inbetween letters */
return (x + (st->cwidth / 2)) / st->cwidth;
}
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Operator Poll
+ * \{ */
+
static bool text_new_poll(bContext *UNUSED(C))
{
return 1;
@@ -206,7 +212,11 @@ static bool text_region_edit_poll(bContext *C)
return 1;
}
-/********************** updates *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Updates
+ * \{ */
void text_update_line_edited(TextLine *line)
{
@@ -230,7 +240,11 @@ void text_update_edited(Text *text)
}
}
-/******************* new operator *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name New Operator
+ * \{ */
static int text_new_exec(bContext *C, wmOperator *UNUSED(op))
{
@@ -281,7 +295,11 @@ void TEXT_OT_new(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
}
-/******************* open operator *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Open Operator
+ * \{ */
static void text_open_init(bContext *C, wmOperator *op)
{
@@ -392,7 +410,11 @@ void TEXT_OT_open(wmOperatorType *ot)
ot->srna, "internal", 0, "Make internal", "Make text file internal after loading");
}
-/******************* reload operator *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Reload Operator
+ * \{ */
static int text_reload_exec(bContext *C, wmOperator *op)
{
@@ -443,7 +465,11 @@ void TEXT_OT_reload(wmOperatorType *ot)
ot->poll = text_edit_poll;
}
-/******************* delete operator *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Delete Operator
+ * \{ */
static bool text_unlink_poll(bContext *C)
{
@@ -495,7 +521,11 @@ void TEXT_OT_unlink(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
}
-/******************* make internal operator *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Make Internal Operator
+ * \{ */
static int text_make_internal_exec(bContext *C, wmOperator *UNUSED(op))
{
@@ -529,7 +559,11 @@ void TEXT_OT_make_internal(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
}
-/******************* save operator *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Save Operator
+ * \{ */
static bool text_save_poll(bContext *C)
{
@@ -614,7 +648,11 @@ void TEXT_OT_save(wmOperatorType *ot)
ot->poll = text_save_poll;
}
-/******************* save as operator *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Save As Operator
+ * \{ */
static int text_save_as_exec(bContext *C, wmOperator *op)
{
@@ -690,7 +728,11 @@ void TEXT_OT_save_as(wmOperatorType *ot)
FILE_SORT_ALPHA); // XXX TODO, relative_path
}
-/******************* run script operator *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Run Script Operator
+ * \{ */
static bool text_run_script_poll(bContext *C)
{
@@ -765,7 +807,11 @@ void TEXT_OT_run_script(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-/******************* refresh pyconstraints operator *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Refresh Pyconstraints Operator
+ * \{ */
static int text_refresh_pyconstraints_exec(bContext *UNUSED(C), wmOperator *UNUSED(op))
{
@@ -825,7 +871,11 @@ void TEXT_OT_refresh_pyconstraints(wmOperatorType *ot)
ot->poll = text_edit_poll;
}
-/******************* paste operator *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Paste Operator
+ * \{ */
static int text_paste_exec(bContext *C, wmOperator *op)
{
@@ -889,7 +939,11 @@ void TEXT_OT_paste(wmOperatorType *ot)
"Paste text selected elsewhere rather than copied (X11 only)");
}
-/**************** duplicate operator *******************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Duplicate Operator
+ * \{ */
static int text_duplicate_line_exec(bContext *C, wmOperator *UNUSED(op))
{
@@ -924,7 +978,11 @@ void TEXT_OT_duplicate_line(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
}
-/******************* copy operator *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Copy Operator
+ * \{ */
static void txt_copy_clipboard(Text *text)
{
@@ -963,7 +1021,11 @@ void TEXT_OT_copy(wmOperatorType *ot)
ot->poll = text_edit_poll;
}
-/******************* cut operator *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Cut Operator
+ * \{ */
static int text_cut_exec(bContext *C, wmOperator *UNUSED(op))
{
@@ -1002,7 +1064,11 @@ void TEXT_OT_cut(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
}
-/******************* indent operator *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Indent Operator
+ * \{ */
static int text_indent_exec(bContext *C, wmOperator *UNUSED(op))
{
@@ -1043,7 +1109,11 @@ void TEXT_OT_indent(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
}
-/******************* unindent operator *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Unindent Operator
+ * \{ */
static int text_unindent_exec(bContext *C, wmOperator *UNUSED(op))
{
@@ -1079,7 +1149,11 @@ void TEXT_OT_unindent(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
}
-/******************* line break operator *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Line Break Operator
+ * \{ */
static int text_line_break_exec(bContext *C, wmOperator *UNUSED(op))
{
@@ -1132,7 +1206,11 @@ void TEXT_OT_line_break(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
}
-/******************* comment operator *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Comment Operator
+ * \{ */
static int text_comment_exec(bContext *C, wmOperator *UNUSED(op))
{
@@ -1170,7 +1248,11 @@ void TEXT_OT_comment(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
}
-/******************* uncomment operator *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Uncomment Operator
+ * \{ */
static int text_uncomment_exec(bContext *C, wmOperator *UNUSED(op))
{
@@ -1209,7 +1291,55 @@ void TEXT_OT_uncomment(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
}
-/******************* convert whitespace operator *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Toggle-Comment Operator
+ * \{ */
+
+static int text_toggle_comment_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Text *text = CTX_data_edit_text(C);
+
+ if (txt_has_sel(text)) {
+ text_drawcache_tag_update(CTX_wm_space_text(C), 0);
+
+ ED_text_undo_push_init(C);
+
+ txt_order_cursors(text, false);
+ if (txt_uncomment(text) == false) {
+ txt_comment(text);
+ }
+ text_update_edited(text);
+
+ text_update_cursor_moved(C);
+ WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
+
+ return OPERATOR_FINISHED;
+ }
+
+ return OPERATOR_CANCELLED;
+}
+
+void TEXT_OT_toggle_comment(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Toggle Comment";
+ ot->idname = "TEXT_OT_toggle_comment";
+
+ /* api callbacks */
+ ot->exec = text_toggle_comment_exec;
+ ot->poll = text_edit_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_UNDO;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Convert Whitespace Operator
+ * \{ */
enum { TO_SPACES, TO_TABS };
static const EnumPropertyItem whitespace_type_items[] = {
@@ -1360,7 +1490,11 @@ void TEXT_OT_convert_whitespace(wmOperatorType *ot)
"Type of whitespace to convert to");
}
-/******************* select all operator *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Select All Operator
+ * \{ */
static int text_select_all_exec(bContext *C, wmOperator *UNUSED(op))
{
@@ -1386,7 +1520,11 @@ void TEXT_OT_select_all(wmOperatorType *ot)
ot->poll = text_edit_poll;
}
-/******************* select line operator *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Select Line Operator
+ * \{ */
static int text_select_line_exec(bContext *C, wmOperator *UNUSED(op))
{
@@ -1412,7 +1550,11 @@ void TEXT_OT_select_line(wmOperatorType *ot)
ot->poll = text_edit_poll;
}
-/******************* select word operator *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Select Word Operator
+ * \{ */
static int text_select_word_exec(bContext *C, wmOperator *UNUSED(op))
{
@@ -1441,7 +1583,11 @@ void TEXT_OT_select_word(wmOperatorType *ot)
ot->poll = text_edit_poll;
}
-/********************* move lines operators ***********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Move Lines Operators
+ * \{ */
static int move_lines_exec(bContext *C, wmOperator *op)
{
@@ -1487,7 +1633,11 @@ void TEXT_OT_move_lines(wmOperatorType *ot)
RNA_def_enum(ot->srna, "direction", direction_items, 1, "Direction", "");
}
-/************************ move operator ************************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Move Operator
+ * \{ */
static const EnumPropertyItem move_type_items[] = {
{LINE_BEGIN, "LINE_BEGIN", 0, "Line Begin", ""},
@@ -2126,7 +2276,11 @@ void TEXT_OT_move(wmOperatorType *ot)
RNA_def_enum(ot->srna, "type", move_type_items, LINE_BEGIN, "Type", "Where to move cursor to");
}
-/******************* move select operator ********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Move Select Operator
+ * \{ */
static int text_move_select_exec(bContext *C, wmOperator *op)
{
@@ -2155,7 +2309,11 @@ void TEXT_OT_move_select(wmOperatorType *ot)
"Where to move cursor to, to make a selection");
}
-/******************* jump operator *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Jump Operator
+ * \{ */
static int text_jump_exec(bContext *C, wmOperator *op)
{
@@ -2203,7 +2361,11 @@ void TEXT_OT_jump(wmOperatorType *ot)
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_TEXT);
}
-/******************* delete operator **********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Delete Operator
+ * \{ */
static const EnumPropertyItem delete_type_items[] = {
{DEL_NEXT_CHAR, "NEXT_CHARACTER", 0, "Next Character", ""},
@@ -2317,7 +2479,11 @@ void TEXT_OT_delete(wmOperatorType *ot)
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
}
-/******************* toggle overwrite operator **********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Toggle Overwrite Operator
+ * \{ */
static int text_toggle_overwrite_exec(bContext *C, wmOperator *UNUSED(op))
{
@@ -2342,7 +2508,11 @@ void TEXT_OT_overwrite_toggle(wmOperatorType *ot)
ot->poll = text_space_edit_poll;
}
-/******************* scroll operator **********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Scroll Operator
+ * \{ */
static void txt_screen_clamp(SpaceText *st, ARegion *ar)
{
@@ -2571,7 +2741,11 @@ void TEXT_OT_scroll(wmOperatorType *ot)
ot->srna, "lines", 1, INT_MIN, INT_MAX, "Lines", "Number of lines to scroll", -100, 100);
}
-/******************** scroll bar operator *******************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Scroll Bar Operator
+ * \{ */
static bool text_region_scroll_poll(bContext *C)
{
@@ -3073,7 +3247,11 @@ void TEXT_OT_selection_set(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "select", 0, "Select", "Set selection end rather than cursor");
}
-/******************* set cursor operator **********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Set Cursor Operator
+ * \{ */
static int text_cursor_set_exec(bContext *C, wmOperator *op)
{
@@ -3121,7 +3299,11 @@ void TEXT_OT_cursor_set(wmOperatorType *ot)
RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX);
}
-/******************* line number operator **********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Line Number Operator
+ * \{ */
static int text_line_number_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
{
@@ -3177,7 +3359,11 @@ void TEXT_OT_line_number(wmOperatorType *ot)
ot->poll = text_region_edit_poll;
}
-/******************* insert operator **********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Insert Operator
+ * \{ */
static int text_insert_exec(bContext *C, wmOperator *op)
{
@@ -3284,7 +3470,11 @@ void TEXT_OT_insert(wmOperatorType *ot)
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
}
-/******************* find operator *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Find Operator
+ * \{ */
/* mode */
#define TEXT_FIND 0
@@ -3378,7 +3568,11 @@ void TEXT_OT_find(wmOperatorType *ot)
ot->poll = text_space_edit_poll;
}
-/******************* replace operator *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Replace Operator
+ * \{ */
static int text_replace_exec(bContext *C, wmOperator *op)
{
@@ -3400,7 +3594,11 @@ void TEXT_OT_replace(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
}
-/******************* find set selected *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Find Set Selected
+ * \{ */
static int text_find_set_selected_exec(bContext *C, wmOperator *op)
{
@@ -3431,7 +3629,11 @@ void TEXT_OT_find_set_selected(wmOperatorType *ot)
ot->poll = text_space_edit_poll;
}
-/******************* replace set selected *********************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Replace Set Selected
+ * \{ */
static int text_replace_set_selected_exec(bContext *C, wmOperator *UNUSED(op))
{
@@ -3461,7 +3663,11 @@ void TEXT_OT_replace_set_selected(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
}
-/****************** resolve conflict operator ******************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Resolve Conflict Operator
+ * \{ */
enum { RESOLVE_IGNORE, RESOLVE_RELOAD, RESOLVE_SAVE, RESOLVE_MAKE_INTERNAL };
static const EnumPropertyItem resolution_items[] = {
@@ -3574,7 +3780,11 @@ void TEXT_OT_resolve_conflict(wmOperatorType *ot)
"How to solve conflict due to differences in internal and external text");
}
-/********************** to 3d object operator *****************/
+/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name To 3D Object Operator
+ * \{ */
static int text_to_3d_object_exec(bContext *C, wmOperator *op)
{
@@ -3604,3 +3814,5 @@ void TEXT_OT_to_3d_object(wmOperatorType *ot)
RNA_def_boolean(
ot->srna, "split_lines", 0, "Split Lines", "Create one object per line in the text");
}
+
+/** \} */
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 57b98ffeda3..d1ea01146bc 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -1140,7 +1140,7 @@ static void view3d_header_region_listener(wmWindow *UNUSED(win),
}
/* From topbar, which ones are needed? split per header? */
- /* Disable for now, re-enable if neede, or remove - campbell. */
+ /* Disable for now, re-enable if needed, or remove - campbell. */
#if 0
/* context changes */
switch (wmn->category) {
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index eef36dae86a..8844428b1bf 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -803,13 +803,19 @@ void ED_view3d_draw_depth(Depsgraph *depsgraph, ARegion *ar, View3D *v3d, bool a
GPU_depth_test(true);
+ /* Needed in cases the view-port isn't already setup. */
+ WM_draw_region_viewport_ensure(ar, SPACE_VIEW3D);
+ WM_draw_region_viewport_bind(ar);
+
GPUViewport *viewport = WM_draw_region_get_viewport(ar, 0);
/* When Blender is starting, a click event can trigger a depth test while the viewport is not
* yet available. */
if (viewport != NULL) {
- DRW_draw_depth_loop(depsgraph, ar, v3d, viewport);
+ DRW_draw_depth_loop(depsgraph, ar, v3d, viewport, false);
}
+ WM_draw_region_viewport_unbind(ar);
+
if (rv3d->rflag & RV3D_CLIPPING) {
ED_view3d_clipping_disable();
}
@@ -1076,7 +1082,7 @@ static void draw_rotation_guide(const RegionView3D *rv3d)
static void view3d_draw_border(const bContext *C, ARegion *ar)
{
Scene *scene = CTX_data_scene(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C);
RegionView3D *rv3d = ar->regiondata;
View3D *v3d = CTX_wm_view3d(C);
@@ -1447,7 +1453,7 @@ void view3d_draw_region_info(const bContext *C, ARegion *ar)
static void view3d_draw_view(const bContext *C, ARegion *ar)
{
ED_view3d_draw_setup_view(CTX_wm_window(C),
- CTX_data_depsgraph(C),
+ CTX_data_expect_evaluated_depsgraph(C),
CTX_data_scene(C),
ar,
CTX_wm_view3d(C),
diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c
index 386c3164843..4c03995307a 100644
--- a/source/blender/editors/space_view3d/view3d_draw_legacy.c
+++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c
@@ -155,11 +155,13 @@ void ED_view3d_clipping_enable(void)
/**
* \note Only use in object mode.
*/
-static void validate_object_select_id(
- struct Depsgraph *depsgraph, Scene *scene, ARegion *ar, View3D *v3d, Object *obact)
+static void validate_object_select_id(struct Depsgraph *depsgraph,
+ Scene *scene,
+ ViewLayer *view_layer,
+ ARegion *ar,
+ View3D *v3d,
+ Object *obact)
{
- RegionView3D *rv3d = ar->regiondata;
- Scene *scene_eval = (Scene *)DEG_get_evaluated_id(depsgraph, &scene->id);
Object *obact_eval = DEG_get_evaluated_object(depsgraph, obact);
BLI_assert(ar->regiontype == RGN_TYPE_WINDOW);
@@ -186,19 +188,8 @@ static void validate_object_select_id(
}
if (obact_eval && ((obact_eval->base_flag & BASE_VISIBLE) != 0)) {
- uint dummy_vert_ofs, dummy_edge_ofs, dummy_face_ofs;
- DRW_framebuffer_select_id_setup(ar, true);
- DRW_draw_select_id_object(scene_eval,
- rv3d,
- obact_eval,
- scene->toolsettings->selectmode,
- false,
- 1,
- &dummy_vert_ofs,
- &dummy_edge_ofs,
- &dummy_face_ofs);
-
- DRW_framebuffer_select_id_release(ar);
+ DRW_draw_select_id_object(
+ depsgraph, view_layer, ar, v3d, obact, scene->toolsettings->selectmode);
}
/* TODO: Create a flag in `DRW_manager` because the drawing is no longer
@@ -233,7 +224,8 @@ void ED_view3d_select_id_validate(ViewContext *vc)
/* TODO: Create a flag in `DRW_manager` because the drawing is no longer
* made on the backbuffer in this case. */
if (vc->v3d->flag & V3D_INVALID_BACKBUF) {
- validate_object_select_id(vc->depsgraph, vc->scene, vc->ar, vc->v3d, vc->obact);
+ validate_object_select_id(
+ vc->depsgraph, vc->scene, vc->view_layer, vc->ar, vc->v3d, vc->obact);
}
}
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 7c4b35507b9..826eddc63d1 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -219,7 +219,7 @@ static void viewops_data_alloc(bContext *C, wmOperator *op)
/* store data */
op->customdata = vod;
vod->bmain = CTX_data_main(C);
- vod->depsgraph = CTX_data_depsgraph(C);
+ vod->depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
vod->scene = CTX_data_scene(C);
vod->sa = CTX_wm_area(C);
vod->ar = CTX_wm_region(C);
@@ -249,7 +249,7 @@ static bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3])
static float lastofs[3] = {0, 0, 0};
bool is_set = false;
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene = CTX_data_scene(C);
ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph);
View3D *v3d = CTX_wm_view3d(C);
@@ -373,7 +373,7 @@ static void viewops_data_create(bContext *C,
const wmEvent *event,
enum eViewOpsFlag viewops_flag)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ViewOpsData *vod = op->customdata;
RegionView3D *rv3d = vod->rv3d;
@@ -1317,7 +1317,7 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_CANCELLED;
}
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ViewOpsData *vod;
View3D *v3d;
RegionView3D *rv3d;
@@ -1397,7 +1397,7 @@ static int ndof_orbit_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *ev
return OPERATOR_CANCELLED;
}
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ViewOpsData *vod;
View3D *v3d;
RegionView3D *rv3d;
@@ -1511,7 +1511,7 @@ static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *e
return OPERATOR_CANCELLED;
}
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = CTX_wm_region_view3d(C);
const wmNDOFMotionData *ndof = event->customdata;
@@ -2188,7 +2188,7 @@ static int viewzoom_modal(bContext *C, wmOperator *op, const wmEvent *event)
static int viewzoom_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);
View3D *v3d;
RegionView3D *rv3d;
@@ -2553,7 +2553,7 @@ static int viewdolly_exec(bContext *C, wmOperator *op)
ED_view3d_depth_tag_update(rv3d);
- ED_view3d_camera_lock_sync(CTX_data_depsgraph(C), v3d, rv3d);
+ ED_view3d_camera_lock_sync(CTX_data_ensure_evaluated_depsgraph(C), v3d, rv3d);
ED_region_tag_redraw(ar);
@@ -2588,7 +2588,7 @@ static int viewdolly_invoke(bContext *C, wmOperator *op, const wmEvent *event)
if (vod->rv3d->persp != RV3D_PERSP) {
if (vod->rv3d->persp == RV3D_CAMOB) {
/* ignore rv3d->lpersp because dolly only makes sense in perspective mode */
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ED_view3d_persp_switch_from_camera(depsgraph, vod->v3d, vod->rv3d, RV3D_PERSP);
}
else {
@@ -2749,8 +2749,9 @@ static void view3d_from_minmax(bContext *C,
}
if (ok_dist) {
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
new_dist = ED_view3d_radius_to_dist(
- v3d, ar, CTX_data_depsgraph(C), persp, true, (size / 2) * VIEW3D_MARGIN);
+ v3d, ar, depsgraph, persp, true, (size / 2) * VIEW3D_MARGIN);
if (rv3d->is_persp) {
/* don't zoom closer than the near clipping plane */
new_dist = max_ff(new_dist, v3d->clip_start * 1.5f);
@@ -2817,7 +2818,7 @@ static int view3d_all_exec(bContext *C, wmOperator *op)
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = CTX_wm_region_view3d(C);
Scene *scene = CTX_data_scene(C);
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph);
Base *base_eval;
const bool use_all_regions = RNA_boolean_get(op->ptr, "use_all_regions");
@@ -2922,14 +2923,14 @@ static int viewselected_exec(bContext *C, wmOperator *op)
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = CTX_wm_region_view3d(C);
Scene *scene = CTX_data_scene(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph);
- bGPdata *gpd = CTX_data_gpencil_data(C);
- const bool is_gp_edit = GPENCIL_ANY_MODE(gpd);
- const bool is_face_map = ((is_gp_edit == false) && ar->gizmo_map &&
- WM_gizmomap_is_any_selected(ar->gizmo_map));
Object *ob_eval = OBACT(view_layer_eval);
Object *obedit = CTX_data_edit_object(C);
+ const bGPdata *gpd_eval = ob_eval && (ob_eval->type == OB_GPENCIL) ? ob_eval->data : NULL;
+ const bool is_gp_edit = gpd_eval ? GPENCIL_ANY_MODE(gpd_eval) : false;
+ const bool is_face_map = ((is_gp_edit == false) && ar->gizmo_map &&
+ WM_gizmomap_is_any_selected(ar->gizmo_map));
float min[3], max[3];
bool ok = false, ok_dist = true;
const bool use_all_regions = RNA_boolean_get(op->ptr, "use_all_regions");
@@ -3120,7 +3121,8 @@ static int view_lock_to_active_exec(bContext *C, wmOperator *UNUSED(op))
if (obact && obact->type == OB_ARMATURE) {
if (obact->mode & OB_MODE_POSE) {
- Object *obact_eval = DEG_get_evaluated_object(CTX_data_depsgraph(C), obact);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
+ Object *obact_eval = DEG_get_evaluated_object(depsgraph, obact);
bPoseChannel *pcham_act = BKE_pose_channel_active(obact_eval);
if (pcham_act) {
BLI_strncpy(v3d->ob_centre_bone, pcham_act->name, sizeof(v3d->ob_centre_bone));
@@ -3216,7 +3218,7 @@ static int viewcenter_pick_invoke(bContext *C, wmOperator *op, const wmEvent *ev
ARegion *ar = CTX_wm_region(C);
if (rv3d) {
- struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
float new_ofs[3];
const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
@@ -3262,7 +3264,7 @@ void VIEW3D_OT_view_center_pick(wmOperatorType *ot)
static int view3d_center_camera_exec(bContext *C, wmOperator *UNUSED(op))
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene = CTX_data_scene(C);
float xfac, yfac;
float size[2];
@@ -3361,7 +3363,7 @@ static int render_border_exec(bContext *C, wmOperator *op)
/* calculate range */
if (rv3d->persp == RV3D_CAMOB) {
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &vb, false);
}
else {
@@ -3530,7 +3532,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
ED_view3d_dist_range_get(v3d, dist_range);
/* Get Z Depths, needed for perspective, nice for ortho */
- ED_view3d_draw_depth(CTX_data_depsgraph(C), ar, v3d, true);
+ ED_view3d_draw_depth(CTX_data_ensure_evaluated_depsgraph(C), ar, v3d, true);
{
/* avoid allocating the whole depth buffer */
@@ -3585,7 +3587,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
float mval_f[2];
float zfac;
- /* We cant use the depth, fallback to the old way that dosnt set the center depth */
+ /* We can't use the depth, fallback to the old way that doesn't set the center depth */
copy_v3_v3(new_ofs, rv3d->ofs);
{
@@ -3619,7 +3621,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
/* TODO(campbell): 'is_camera_lock' not currently working well. */
const bool is_camera_lock = ED_view3d_camera_lock_check(v3d, rv3d);
if ((rv3d->persp == RV3D_CAMOB) && (is_camera_lock == false)) {
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ED_view3d_persp_switch_from_camera(depsgraph, v3d, rv3d, RV3D_PERSP);
}
@@ -3686,7 +3688,7 @@ static void view3d_set_1_to_1_viewborder(Scene *scene,
static int view3d_zoom_1_to_1_camera_exec(bContext *C, wmOperator *UNUSED(op))
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene = CTX_data_scene(C);
View3D *v3d;
@@ -3794,7 +3796,8 @@ static void axis_set_view(bContext *C,
dist = rv3d->dist;
/* so we animate _from_ the camera location */
- Object *camera_eval = DEG_get_evaluated_object(CTX_data_depsgraph(C), v3d->camera);
+ Object *camera_eval = DEG_get_evaluated_object(CTX_data_ensure_evaluated_depsgraph(C),
+ v3d->camera);
ED_view3d_from_object(camera_eval, rv3d->ofs, NULL, &rv3d->dist, NULL);
ED_view3d_smooth_view(C,
@@ -4124,7 +4127,7 @@ static int vieworbit_exec(bContext *C, wmOperator *op)
float quat_new[4];
if (view_opposite == RV3D_VIEW_USER) {
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ED_view3d_persp_ensure(depsgraph, v3d, ar);
}
@@ -4874,7 +4877,7 @@ void ED_view3d_cursor3d_position(bContext *C,
}
if (use_depth) { /* maybe this should be accessed some other way */
- struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
view3d_operator_needs_opengl(C);
if (ED_view3d_autodist(depsgraph, ar, v3d, mval, cursor_co, true, NULL)) {
@@ -4930,7 +4933,7 @@ void ED_view3d_cursor3d_position_rotation(bContext *C,
float ray_co[3];
struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d(
- bmain, scene, CTX_data_depsgraph(C), 0, ar, v3d);
+ bmain, scene, CTX_data_ensure_evaluated_depsgraph(C), 0, ar, v3d);
float obmat[4][4];
Object *ob_dummy = NULL;
diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c
index 3fa0c2c59b7..961ac4c26fb 100644
--- a/source/blender/editors/space_view3d/view3d_fly.c
+++ b/source/blender/editors/space_view3d/view3d_fly.c
@@ -270,7 +270,7 @@ static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent
fly->rv3d = CTX_wm_region_view3d(C);
fly->v3d = CTX_wm_view3d(C);
fly->ar = CTX_wm_region(C);
- fly->depsgraph = CTX_data_depsgraph(C);
+ fly->depsgraph = CTX_data_expect_evaluated_depsgraph(C);
fly->scene = CTX_data_scene(C);
#ifdef NDOF_FLY_DEBUG
@@ -337,12 +337,8 @@ static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent
fly->zlock = FLY_AXISLOCK_STATE_IDLE;
}
- fly->v3d_camera_control = ED_view3d_cameracontrol_acquire(CTX_data_depsgraph(C),
- fly->scene,
- fly->v3d,
- fly->rv3d,
- (U.uiflag & USER_CAM_LOCK_NO_PARENT) ==
- 0);
+ fly->v3d_camera_control = ED_view3d_cameracontrol_acquire(
+ fly->depsgraph, fly->scene, fly->v3d, fly->rv3d, (U.uiflag & USER_CAM_LOCK_NO_PARENT) == 0);
/* calculate center */
if (ED_view3d_cameracontrol_object_get(fly->v3d_camera_control)) {
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_camera.c b/source/blender/editors/space_view3d/view3d_gizmo_camera.c
index 002a7e12515..1bb10697936 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_camera.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_camera.c
@@ -437,7 +437,8 @@ static void WIDGETGROUP_camera_view_draw_prepare(const bContext *C, wmGizmoGroup
struct CameraViewWidgetGroup *viewgroup = gzgroup->customdata;
ARegion *ar = CTX_wm_region(C);
- struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ /* Drawing code should happen with fully evaluated graph. */
+ struct Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C);
RegionView3D *rv3d = ar->regiondata;
if (rv3d->persp == RV3D_CAMOB) {
Scene *scene = CTX_data_scene(C);
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c b/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c
index 64697a59019..a984e339305 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c
@@ -176,7 +176,7 @@ static int gizmo_preselect_elem_test_select(bContext *C, wmGizmo *gz, const int
const float(*coords)[3] = NULL;
{
Object *ob = gz_ele->bases[gz_ele->base_index]->object;
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Mesh *me_eval = (Mesh *)DEG_get_evaluated_id(depsgraph, ob->data);
if (me_eval->runtime.edit_data) {
coords = me_eval->runtime.edit_data->vertexCos;
@@ -334,7 +334,7 @@ static int gizmo_preselect_edgering_test_select(bContext *C, wmGizmo *gz, const
const float(*coords)[3] = NULL;
{
Object *ob = gz_ring->bases[gz_ring->base_index]->object;
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Mesh *me_eval = (Mesh *)DEG_get_evaluated_id(depsgraph, ob->data);
if (me_eval->runtime.edit_data) {
coords = me_eval->runtime.edit_data->vertexCos;
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
index e781e129540..97a12c7100e 100644
--- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
+++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c
@@ -289,7 +289,12 @@ static void ruler_state_set(bContext *C, RulerInfo *ruler_info, int state)
else if (state == RULER_STATE_DRAG) {
memset(&ruler_info->drag_state_prev, 0x0, sizeof(ruler_info->drag_state_prev));
ruler_info->snap_context = ED_transform_snap_object_context_create_view3d(
- bmain, CTX_data_scene(C), CTX_data_depsgraph(C), 0, ruler_info->ar, CTX_wm_view3d(C));
+ bmain,
+ CTX_data_scene(C),
+ CTX_data_ensure_evaluated_depsgraph(C),
+ 0,
+ ruler_info->ar,
+ CTX_wm_view3d(C));
}
else {
BLI_assert(0);
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 61de61c8e31..36eb07e9a2f 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -111,192 +111,6 @@
// #include "PIL_time_utildefines.h"
/* -------------------------------------------------------------------- */
-/** \name Selection Utilities
- * \{ */
-
-struct EDBaseOffset {
- /* For convenience only. */
- union {
- uint offset;
- uint face_start;
- };
- union {
- uint face;
- uint edge_start;
- };
- union {
- uint edge;
- uint vert_start;
- };
- uint vert;
-};
-
-struct EDSelectID_Context {
- struct EDBaseOffset *base_array_index_offsets;
- /** Borrow from caller (not freed). */
- struct Base **bases;
- uint bases_len;
- /** Total number of items `base_array_index_offsets[bases_len - 1].vert`. */
- uint base_array_index_len;
- /** Used to check for changes. (Use depsgraph instead?). */
- float persmat[4][4];
- short select_mode;
-};
-
-static bool check_ob_drawface_dot(short select_mode, const View3D *v3d, char dt)
-{
- if (select_mode & SCE_SELECT_FACE) {
- if ((dt < OB_SOLID) || XRAY_FLAG_ENABLED(v3d)) {
- return true;
- }
- if (v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_FACE_DOT) {
- return true;
- }
- if ((v3d->overlay.edit_flag & V3D_OVERLAY_EDIT_EDGES) == 0) {
- /* Since we can't deduce face selection when edges aren't visible - show dots. */
- return true;
- }
- }
- return false;
-}
-
-static void ed_select_id_draw_bases(struct EDSelectID_Context *sel_id_ctx,
- ViewContext *vc,
- short select_mode)
-{
- Scene *scene_eval = (Scene *)DEG_get_evaluated_id(vc->depsgraph, &vc->scene->id);
- DRW_framebuffer_select_id_setup(vc->ar, true);
-
- uint offset = 1;
- for (uint base_index = 0; base_index < sel_id_ctx->bases_len; base_index++) {
- Object *ob_eval = DEG_get_evaluated_object(vc->depsgraph,
- sel_id_ctx->bases[base_index]->object);
-
- struct EDBaseOffset *base_ofs = &sel_id_ctx->base_array_index_offsets[base_index];
- bool draw_facedot = check_ob_drawface_dot(select_mode, vc->v3d, ob_eval->dt);
-
- DRW_draw_select_id_object(scene_eval,
- vc->rv3d,
- ob_eval,
- select_mode,
- draw_facedot,
- offset,
- &base_ofs->vert,
- &base_ofs->edge,
- &base_ofs->face);
-
- base_ofs->offset = offset;
- offset = base_ofs->vert;
- }
-
- sel_id_ctx->base_array_index_len = offset;
-
- DRW_framebuffer_select_id_release(vc->ar);
-}
-
-void ED_view3d_select_id_validate_view_matrices(struct EDSelectID_Context *sel_id_ctx,
- ViewContext *vc)
-{
- if (!compare_m4m4(sel_id_ctx->persmat, vc->rv3d->persmat, FLT_EPSILON)) {
- ed_select_id_draw_bases(sel_id_ctx, vc, sel_id_ctx->select_mode);
- }
-}
-
-uint ED_view3d_select_id_context_offset_for_object_elem(
- const struct EDSelectID_Context *sel_id_ctx, int base_index, char elem_type)
-{
- struct EDBaseOffset *base_ofs = &sel_id_ctx->base_array_index_offsets[base_index];
- if (elem_type == SCE_SELECT_VERTEX) {
- return base_ofs->vert_start - 1;
- }
- if (elem_type == SCE_SELECT_EDGE) {
- return base_ofs->edge_start - 1;
- }
- if (elem_type == SCE_SELECT_FACE) {
- return base_ofs->face_start - 1;
- }
- BLI_assert(0);
- return 0;
-}
-
-uint ED_view3d_select_id_context_elem_len(const struct EDSelectID_Context *sel_id_ctx)
-{
- return sel_id_ctx->base_array_index_len;
-}
-
-struct EDSelectID_Context *ED_view3d_select_id_context_create(ViewContext *vc,
- Base **bases,
- const uint bases_len,
- short select_mode)
-{
- struct EDSelectID_Context *sel_id_ctx = MEM_mallocN(sizeof(*sel_id_ctx), __func__);
- sel_id_ctx->base_array_index_offsets = MEM_mallocN(sizeof(struct EDBaseOffset) * bases_len,
- __func__);
- sel_id_ctx->bases = bases;
- sel_id_ctx->bases_len = bases_len;
- copy_m4_m4(sel_id_ctx->persmat, vc->rv3d->persmat);
- sel_id_ctx->select_mode = select_mode;
- ed_select_id_draw_bases(sel_id_ctx, vc, select_mode);
-
- return sel_id_ctx;
-}
-
-void ED_view3d_select_id_context_destroy(struct EDSelectID_Context *sel_id_ctx)
-{
- MEM_freeN(sel_id_ctx->base_array_index_offsets);
- MEM_freeN(sel_id_ctx);
-}
-
-bool ED_view3d_select_id_elem_get(struct EDSelectID_Context *sel_id_ctx,
- const uint sel_id,
- uint *r_elem,
- uint *r_base_index,
- char *r_elem_type)
-{
- char elem_type = 0;
- uint elem_id;
- uint base_index = 0;
-
- while (true) {
- struct EDBaseOffset *base_ofs = &sel_id_ctx->base_array_index_offsets[base_index];
- if (base_ofs->face > sel_id) {
- elem_id = sel_id - base_ofs->face_start;
- elem_type = SCE_SELECT_FACE;
- break;
- }
- if (base_ofs->edge > sel_id) {
- elem_id = sel_id - base_ofs->edge_start;
- elem_type = SCE_SELECT_EDGE;
- break;
- }
- if (base_ofs->vert > sel_id) {
- elem_id = sel_id - base_ofs->vert_start;
- elem_type = SCE_SELECT_VERTEX;
- break;
- }
-
- base_index++;
- if (base_index >= sel_id_ctx->bases_len) {
- return false;
- }
- }
-
- *r_elem = elem_id;
-
- if (r_base_index) {
- *r_base_index = base_index;
- }
-
- if (r_elem_type) {
- *r_elem_type = elem_type;
- }
-
- return true;
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
/** \name Public Utilities
* \{ */
@@ -312,7 +126,7 @@ void ED_view3d_viewcontext_init(bContext *C, ViewContext *vc)
vc->C = C;
vc->ar = CTX_wm_region(C);
vc->bmain = CTX_data_main(C);
- vc->depsgraph = CTX_data_depsgraph(C);
+ vc->depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
vc->scene = CTX_data_scene(C);
vc->view_layer = CTX_data_view_layer(C);
vc->v3d = CTX_wm_view3d(C);
@@ -385,7 +199,6 @@ static bool object_deselect_all_except(ViewLayer *view_layer, Base *b)
struct EditSelectBuf_Cache {
Base **bases;
uint bases_len;
- struct EDSelectID_Context *sel_id_ctx;
BLI_bitmap *select_bitmap;
};
@@ -407,8 +220,12 @@ static void editselect_buf_cache_init(struct EditSelectBuf_Cache *esel, ViewCont
esel->bases_len = 0;
}
}
- esel->sel_id_ctx = ED_view3d_select_id_context_create(
- vc, esel->bases, esel->bases_len, vc->scene->toolsettings->selectmode);
+ DRW_draw_select_id(vc->depsgraph,
+ vc->ar,
+ vc->v3d,
+ esel->bases,
+ esel->bases_len,
+ vc->scene->toolsettings->selectmode);
for (int i = 0; i < esel->bases_len; i++) {
esel->bases[i]->object->runtime.select_id = i;
}
@@ -416,9 +233,6 @@ static void editselect_buf_cache_init(struct EditSelectBuf_Cache *esel, ViewCont
static void editselect_buf_cache_free(struct EditSelectBuf_Cache *esel)
{
- if (esel->sel_id_ctx) {
- ED_view3d_select_id_context_destroy(esel->sel_id_ctx);
- }
MEM_SAFE_FREE(esel->select_bitmap);
MEM_SAFE_FREE(esel->bases);
}
@@ -455,8 +269,7 @@ static bool edbm_backbuf_check_and_select_verts(struct EditSelectBuf_Cache *esel
bool changed = false;
const BLI_bitmap *select_bitmap = esel->select_bitmap;
- uint index = ED_view3d_select_id_context_offset_for_object_elem(
- esel->sel_id_ctx, ob->runtime.select_id, SCE_SELECT_VERTEX);
+ uint index = DRW_select_context_offset_for_object_elem(ob->runtime.select_id, SCE_SELECT_VERTEX);
BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
if (!BM_elem_flag_test(eve, BM_ELEM_HIDDEN)) {
@@ -483,8 +296,7 @@ static bool edbm_backbuf_check_and_select_edges(struct EditSelectBuf_Cache *esel
bool changed = false;
const BLI_bitmap *select_bitmap = esel->select_bitmap;
- uint index = ED_view3d_select_id_context_offset_for_object_elem(
- esel->sel_id_ctx, ob->runtime.select_id, SCE_SELECT_EDGE);
+ uint index = DRW_select_context_offset_for_object_elem(ob->runtime.select_id, SCE_SELECT_EDGE);
BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) {
if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
@@ -511,8 +323,7 @@ static bool edbm_backbuf_check_and_select_faces(struct EditSelectBuf_Cache *esel
bool changed = false;
const BLI_bitmap *select_bitmap = esel->select_bitmap;
- uint index = ED_view3d_select_id_context_offset_for_object_elem(
- esel->sel_id_ctx, ob->runtime.select_id, SCE_SELECT_FACE);
+ uint index = DRW_select_context_offset_for_object_elem(ob->runtime.select_id, SCE_SELECT_FACE);
BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) {
@@ -1017,7 +828,7 @@ static bool do_lasso_select_mesh(ViewContext *vc,
if (wm_userdata->data == NULL) {
editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc);
esel = wm_userdata->data;
- const uint buffer_len = ED_view3d_select_id_context_elem_len(esel->sel_id_ctx);
+ const uint buffer_len = DRW_select_context_elem_len();
esel->select_bitmap = ED_select_buffer_bitmap_from_poly(buffer_len, mcords, moves, &rect);
}
}
@@ -1036,10 +847,8 @@ static bool do_lasso_select_mesh(ViewContext *vc,
struct LassoSelectUserData_ForMeshEdge data_for_edge = {
.data = &data,
.esel = use_zbuf ? esel : NULL,
- .backbuf_offset = use_zbuf ? ED_view3d_select_id_context_offset_for_object_elem(
- esel->sel_id_ctx,
- vc->obedit->runtime.select_id,
- SCE_SELECT_EDGE) :
+ .backbuf_offset = use_zbuf ? DRW_select_context_offset_for_object_elem(
+ vc->obedit->runtime.select_id, SCE_SELECT_EDGE) :
0,
};
mesh_foreachScreenEdge(
@@ -1327,7 +1136,7 @@ static bool do_lasso_select_paintvert(ViewContext *vc,
if (wm_userdata->data == NULL) {
editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc);
esel = wm_userdata->data;
- const uint buffer_len = ED_view3d_select_id_context_elem_len(esel->sel_id_ctx);
+ const uint buffer_len = DRW_select_context_elem_len();
esel->select_bitmap = ED_select_buffer_bitmap_from_poly(buffer_len, mcords, moves, &rect);
}
}
@@ -1386,7 +1195,7 @@ static bool do_lasso_select_paintface(ViewContext *vc,
if (esel == NULL) {
editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc);
esel = wm_userdata->data;
- const uint buffer_len = ED_view3d_select_id_context_elem_len(esel->sel_id_ctx);
+ const uint buffer_len = DRW_select_context_elem_len();
esel->select_bitmap = ED_select_buffer_bitmap_from_poly(buffer_len, mcords, moves, &rect);
}
@@ -2742,7 +2551,7 @@ static bool do_paintvert_box_select(ViewContext *vc,
if (wm_userdata->data == NULL) {
editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc);
esel = wm_userdata->data;
- const uint buffer_len = ED_view3d_select_id_context_elem_len(esel->sel_id_ctx);
+ const uint buffer_len = DRW_select_context_elem_len();
esel->select_bitmap = ED_select_buffer_bitmap_from_rect(buffer_len, rect);
}
if (esel->select_bitmap != NULL) {
@@ -2797,7 +2606,7 @@ static bool do_paintface_box_select(ViewContext *vc,
if (wm_userdata->data == NULL) {
editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc);
esel = wm_userdata->data;
- const uint buffer_len = ED_view3d_select_id_context_elem_len(esel->sel_id_ctx);
+ const uint buffer_len = DRW_select_context_elem_len();
esel->select_bitmap = ED_select_buffer_bitmap_from_rect(buffer_len, rect);
}
if (esel->select_bitmap != NULL) {
@@ -2995,7 +2804,7 @@ static bool do_mesh_box_select(ViewContext *vc,
if (wm_userdata->data == NULL) {
editselect_buf_cache_init_with_generic_userdata(wm_userdata, vc);
esel = wm_userdata->data;
- const uint buffer_len = ED_view3d_select_id_context_elem_len(esel->sel_id_ctx);
+ const uint buffer_len = DRW_select_context_elem_len();
esel->select_bitmap = ED_select_buffer_bitmap_from_rect(buffer_len, rect);
}
}
@@ -3014,10 +2823,8 @@ static bool do_mesh_box_select(ViewContext *vc,
struct BoxSelectUserData_ForMeshEdge cb_data = {
.data = &data,
.esel = use_zbuf ? esel : NULL,
- .backbuf_offset = use_zbuf ? ED_view3d_select_id_context_offset_for_object_elem(
- esel->sel_id_ctx,
- vc->obedit->runtime.select_id,
- SCE_SELECT_EDGE) :
+ .backbuf_offset = use_zbuf ? DRW_select_context_offset_for_object_elem(
+ vc->obedit->runtime.select_id, SCE_SELECT_EDGE) :
0,
};
mesh_foreachScreenEdge(
@@ -3582,8 +3389,7 @@ static bool mesh_circle_select(ViewContext *vc,
struct EditSelectBuf_Cache *esel = wm_userdata->data;
if (use_zbuf) {
- ED_view3d_select_id_validate_view_matrices(esel->sel_id_ctx, vc);
- const uint buffer_len = ED_view3d_select_id_context_elem_len(esel->sel_id_ctx);
+ const uint buffer_len = DRW_select_context_elem_len();
esel->select_bitmap = ED_select_buffer_bitmap_from_circle(buffer_len, mval, (int)(rad + 1.0f));
}
@@ -3660,7 +3466,7 @@ static bool paint_facesel_circle_select(ViewContext *vc,
{
struct EditSelectBuf_Cache *esel = wm_userdata->data;
- const uint buffer_len = ED_view3d_select_id_context_elem_len(esel->sel_id_ctx);
+ const uint buffer_len = DRW_select_context_elem_len();
esel->select_bitmap = ED_select_buffer_bitmap_from_circle(buffer_len, mval, (int)(rad + 1.0f));
if (esel->select_bitmap != NULL) {
changed |= edbm_backbuf_check_and_select_faces_obmode(me, esel, sel_op);
@@ -3715,7 +3521,7 @@ static bool paint_vertsel_circle_select(ViewContext *vc,
if (use_zbuf) {
struct EditSelectBuf_Cache *esel = wm_userdata->data;
- const uint buffer_len = ED_view3d_select_id_context_elem_len(esel->sel_id_ctx);
+ const uint buffer_len = DRW_select_context_elem_len();
esel->select_bitmap = ED_select_buffer_bitmap_from_circle(buffer_len, mval, (int)(rad + 1.0f));
if (esel->select_bitmap != NULL) {
changed |= edbm_backbuf_check_and_select_verts_obmode(me, esel, sel_op);
@@ -4150,7 +3956,7 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op)
const int radius = RNA_int_get(op->ptr, "radius");
const int mval[2] = {RNA_int_get(op->ptr, "x"), RNA_int_get(op->ptr, "y")};
- /* Allow each selection type to allocate their own data thats used between executions. */
+ /* Allow each selection type to allocate their own data that's used between executions. */
wmGesture *gesture = op->customdata; /* NULL when non-modal. */
wmGenericUserData wm_userdata_buf = {0};
wmGenericUserData *wm_userdata = gesture ? &gesture->user_data : &wm_userdata_buf;
diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c
index 0103fd0df53..9a2f4062631 100644
--- a/source/blender/editors/space_view3d/view3d_snap.c
+++ b/source/blender/editors/space_view3d/view3d_snap.c
@@ -66,7 +66,7 @@ static bool snap_calc_active_center(bContext *C, const bool select_only, float r
/** Snaps every individual object center to its nearest point on the grid. */
static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op))
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph);
Object *obedit = CTX_data_edit_object(C);
Scene *scene = CTX_data_scene(C);
@@ -226,7 +226,7 @@ void VIEW3D_OT_snap_selected_to_grid(wmOperatorType *ot)
ot->poll = ED_operator_region_view3d_active;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* *************************************************** */
@@ -243,7 +243,6 @@ static int snap_selected_to_location(bContext *C,
const float snap_target_global[3],
const bool use_offset)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *scene = CTX_data_scene(C);
Object *obedit = CTX_data_edit_object(C);
Object *obact = CTX_data_active_object(C);
@@ -431,6 +430,7 @@ static int snap_selected_to_location(bContext *C,
float originmat[3][3], parentmat[4][4];
/* Use the evaluated object here because sometimes
* `ob->parent->runtime.curve_cache` is required. */
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
BKE_object_get_parent_matrix(ob_eval, ob_eval->parent, parentmat);
@@ -486,7 +486,7 @@ void VIEW3D_OT_snap_selected_to_cursor(wmOperatorType *ot)
ot->poll = ED_operator_view3d_active;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* rna */
RNA_def_boolean(ot->srna,
@@ -523,7 +523,7 @@ void VIEW3D_OT_snap_selected_to_active(wmOperatorType *ot)
ot->poll = ED_operator_view3d_active;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* *************************************************** */
@@ -626,7 +626,7 @@ static void bundle_midpoint(Scene *scene, Object *ob, float r_vec[3])
/** Snaps the 3D cursor location to the median point of the selection. */
static bool snap_curs_to_sel_ex(bContext *C, float cursor[3])
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph);
Object *obedit = CTX_data_edit_object(C);
Scene *scene = CTX_data_scene(C);
@@ -757,7 +757,7 @@ void VIEW3D_OT_snap_cursor_to_selected(wmOperatorType *ot)
ot->poll = ED_operator_view3d_active;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* ********************************************** */
@@ -804,7 +804,7 @@ void VIEW3D_OT_snap_cursor_to_active(wmOperatorType *ot)
ot->poll = ED_operator_view3d_active;
/* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* **************************************************** */
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index c0902cd1cd5..2515ee6e482 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -304,7 +304,7 @@ void ED_view3d_smooth_view(bContext *C,
const int smooth_viewtx,
const struct V3D_SmoothParams *sview)
{
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = CTX_wm_window(C);
ScrArea *sa = CTX_wm_area(C);
@@ -315,7 +315,6 @@ void ED_view3d_smooth_view(bContext *C,
/* only meant for timer usage */
static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *ar, bool sync_boxview)
{
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
RegionView3D *rv3d = ar->regiondata;
struct SmoothView3DStore *sms = rv3d->sms;
float step, step_inv;
@@ -336,6 +335,8 @@ static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *ar, bool
view3d_smooth_view_state_restore(&sms->org, v3d, rv3d);
}
else {
+ const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
+
view3d_smooth_view_state_restore(&sms->dst, v3d, rv3d);
ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d);
@@ -372,6 +373,7 @@ static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *ar, bool
rv3d->dist = sms->dst.dist * step + sms->src.dist * step_inv;
v3d->lens = sms->dst.lens * step + sms->src.lens * step_inv;
+ const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d);
if (ED_screen_animation_playing(CTX_wm_manager(C))) {
ED_view3d_camera_lock_autokey(v3d, rv3d, C, true, true);
@@ -428,7 +430,7 @@ void ED_view3d_smooth_view_force_finish(bContext *C, View3D *v3d, ARegion *ar)
/* force update of view matrix so tools that run immediately after
* can use them without redrawing first */
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene = CTX_data_scene(C);
ED_view3d_update_viewmat(depsgraph, scene, v3d, ar, NULL, NULL, NULL, false);
}
@@ -457,7 +459,7 @@ void VIEW3D_OT_smoothview(wmOperatorType *ot)
static int view3d_camera_to_view_exec(bContext *C, wmOperator *UNUSED(op))
{
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
View3D *v3d;
ARegion *ar;
RegionView3D *rv3d;
@@ -527,7 +529,7 @@ void VIEW3D_OT_camera_to_view(wmOperatorType *ot)
* meant to take into account vertex/bone selection for eg. */
static int view3d_camera_to_view_selected_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);
View3D *v3d = CTX_wm_view3d(C); /* can be NULL */
Object *camera_ob = v3d ? v3d->camera : scene->camera;
@@ -1413,7 +1415,7 @@ static void view3d_localview_exit(const Depsgraph *depsgraph,
static int localview_exec(bContext *C, wmOperator *op)
{
- const Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = CTX_wm_window(C);
diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c
index 853955a4078..c5585857b55 100644
--- a/source/blender/editors/space_view3d/view3d_walk.c
+++ b/source/blender/editors/space_view3d/view3d_walk.c
@@ -426,7 +426,7 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op)
walk->rv3d = CTX_wm_region_view3d(C);
walk->v3d = CTX_wm_view3d(C);
walk->ar = CTX_wm_region(C);
- walk->depsgraph = CTX_data_depsgraph(C);
+ walk->depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
walk->scene = CTX_data_scene(C);
#ifdef NDOF_WALK_DEBUG
@@ -520,7 +520,7 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op)
walk->rv3d->rflag |= RV3D_NAVIGATING;
walk->snap_context = ED_transform_snap_object_context_create_view3d(
- bmain, walk->scene, CTX_data_depsgraph(C), 0, walk->ar, walk->v3d);
+ bmain, walk->scene, CTX_data_ensure_evaluated_depsgraph(C), 0, walk->ar, walk->v3d);
walk->v3d_camera_control = ED_view3d_cameracontrol_acquire(
walk->depsgraph,
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index a316567fc63..5ef86c71d2d 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1595,11 +1595,8 @@ int transformEvent(TransInfo *t, const wmEvent *event)
}
/* confirm transform if launch key is released after mouse move */
- if (t->flag & T_RELEASE_CONFIRM) {
- /* XXX Keyrepeat bug in Xorg messes this up, will test when fixed */
- if ((event->type == t->launch_event) && ISMOUSE(t->launch_event)) {
- t->state = TRANS_CONFIRM;
- }
+ if ((t->flag & T_RELEASE_CONFIRM) && event->type == t->launch_event) {
+ t->state = TRANS_CONFIRM;
}
}
@@ -2157,16 +2154,6 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
}
}
- /* do we check for parameter? */
- if (transformModeUseSnap(t)) {
- if (t->modifiers & MOD_SNAP) {
- ts->snap_flag |= SCE_SNAP;
- }
- else {
- ts->snap_flag &= ~SCE_SNAP;
- }
- }
-
if (t->spacetype == SPACE_VIEW3D) {
if ((prop = RNA_struct_find_property(op->ptr, "orient_type")) &&
!RNA_property_is_set(op->ptr, prop) &&
@@ -2180,6 +2167,18 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
}
}
+ if (t->flag & T_MODAL) {
+ /* do we check for parameter? */
+ if (transformModeUseSnap(t)) {
+ if (t->modifiers & MOD_SNAP) {
+ ts->snap_flag |= SCE_SNAP;
+ }
+ else {
+ ts->snap_flag &= ~SCE_SNAP;
+ }
+ }
+ }
+
if ((prop = RNA_struct_find_property(op->ptr, "use_proportional_edit"))) {
RNA_property_boolean_set(op->ptr, prop, proportional & PROP_EDIT_USE);
RNA_boolean_set(op->ptr, "use_proportional_connected", proportional & PROP_EDIT_CONNECTED);
@@ -4581,17 +4580,42 @@ static void ElementRotation(
ElementRotation_ex(t, tc, td, mat, center);
}
-static void applyRotationValue(TransInfo *t, float angle, float axis[3])
+static float large_rotation_limit(float angle)
+{
+ /* Limit rotation to 1001 turns max
+ * (otherwise iterative handling of 'large' rotations would become too slow). */
+ const float angle_max = (float)(M_PI * 2000.0);
+ if (fabsf(angle) > angle_max) {
+ const float angle_sign = angle < 0.0f ? -1.0f : 1.0f;
+ angle = angle_sign * (fmodf(fabsf(angle), (float)(M_PI * 2.0)) + angle_max);
+ }
+ return angle;
+}
+
+static void applyRotationValue(TransInfo *t,
+ float angle,
+ float axis[3],
+ const bool is_large_rotation)
{
float mat[3][3];
int i;
+ const float angle_sign = angle < 0.0f ? -1.0f : 1.0f;
+ /* We cannot use something too close to 180°, or 'continuous' rotation may fail
+ * due to computing error... */
+ const float angle_step = angle_sign * (float)(0.9 * M_PI);
+
+ if (is_large_rotation) {
+ /* Just in case, calling code should have already done that in practice
+ * (for UI feedback reasons). */
+ angle = large_rotation_limit(angle);
+ }
+
axis_angle_normalized_to_mat3(mat, axis, angle);
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
TransData *td = tc->data;
for (i = 0; i < tc->data_len; i++, td++) {
-
if (td->flag & TD_NOACTION) {
break;
}
@@ -4600,14 +4624,37 @@ static void applyRotationValue(TransInfo *t, float angle, float axis[3])
continue;
}
+ float angle_final = angle;
if (t->con.applyRot) {
t->con.applyRot(t, tc, td, axis, NULL);
- axis_angle_normalized_to_mat3(mat, axis, angle * td->factor);
+ angle_final = angle * td->factor;
}
else if (t->flag & T_PROP_EDIT) {
- axis_angle_normalized_to_mat3(mat, axis, angle * td->factor);
+ angle_final = angle * td->factor;
+ }
+
+ /* Rotation is very likely to be above 180°, we need to do rotation by steps.
+ * Note that this is only needed when doing 'absolute' rotation
+ * (i.e. from initial rotation again, typically when using numinput).
+ * regular incremental rotation (from mouse/widget/...) will be called often enough,
+ * hence steps are small enough to be properly handled without that complicated trick.
+ * Note that we can only do that kind of stepped rotation if we have initial rotation values
+ * (and access to some actual rotation value storage).
+ * Otherwise, just assume it's useless (e.g. in case of mesh/UV/etc. editing).
+ * Also need to be in Euler rotation mode, the others never allow more than one turn anyway.
+ */
+ if (is_large_rotation && td->ext != NULL && td->ext->rotOrder == ROT_MODE_EUL) {
+ copy_v3_v3(td->ext->rot, td->ext->irot);
+ for (float angle_progress = angle_step; fabsf(angle_progress) < fabsf(angle_final);
+ angle_progress += angle_step) {
+ axis_angle_normalized_to_mat3(mat, axis, angle_progress);
+ ElementRotation(t, tc, td, mat, t->around);
+ }
+ axis_angle_normalized_to_mat3(mat, axis, angle_final);
+ }
+ else if (angle_final != angle) {
+ axis_angle_normalized_to_mat3(mat, axis, angle_final);
}
-
ElementRotation(t, tc, td, mat, t->around);
}
}
@@ -4632,15 +4679,18 @@ static void applyRotation(TransInfo *t, const int UNUSED(mval[2]))
applySnapping(t, &final);
- /* Used to clamp final result in [-PI, PI[ range, no idea why,
- * inheritance from 2.4x area, see T48998. */
- applyNumInput(&t->num, &final);
+ if (applyNumInput(&t->num, &final)) {
+ /* We have to limit the amount of turns to a reasonable number here,
+ * to avoid things getting *very* slow, see how applyRotationValue() handles those... */
+ final = large_rotation_limit(final);
+ }
t->values[0] = final;
headerRotation(t, str, final);
- applyRotationValue(t, final, axis_final);
+ const bool is_large_rotation = hasNumInput(&t->num);
+ applyRotationValue(t, final, axis_final, is_large_rotation);
recalcData(t);
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index b0f720bfdf7..833792379ae 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -102,7 +102,7 @@ typedef struct TransSnap {
* Get the transform distance between two points (used by Closest snap)
*
* \note Return value can be anything,
- * where the smallest absolute value defines whats closest.
+ * where the smallest absolute value defines what's closest.
*/
float (*distance)(struct TransInfo *t, const float p1[3], const float p2[3]);
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 208242d53b3..3a204d0d157 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -263,9 +263,8 @@ static void axisProjection(const TransInfo *t,
/* Use ray-ray intersection instead of line-line because this gave
* precision issues adding small values to large numbers. */
float mul;
- if (isect_ray_ray_v3(v, norm, t_con_center, axis, &mul, NULL)) {
- madd_v3_v3v3fl(out, t_con_center, axis, mul);
- sub_v3_v3(out, t_con_center);
+ if (isect_ray_ray_v3(t_con_center, axis, v, norm, &mul, NULL)) {
+ mul_v3_v3fl(out, axis, mul);
}
else {
/* In practice this should never fail. */
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index d13c0f8e8f1..4eccf4c5071 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -6133,6 +6133,8 @@ static void freeSeqData(TransInfo *t, TransDataContainer *tc, TransCustomData *c
MEM_freeN(custom_data->data);
custom_data->data = NULL;
}
+
+ DEG_id_tag_update(&t->scene->id, ID_RECALC_SEQUENCER_STRIPS);
}
static void createTransSeqData(bContext *C, TransInfo *t)
@@ -6629,7 +6631,6 @@ void autokeyframe_object(bContext *C, Scene *scene, ViewLayer *view_layer, Objec
// TODO: this should probably be done per channel instead...
if (autokeyframe_cfra_can_key(scene, id)) {
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
ReportList *reports = CTX_wm_reports(C);
ToolSettings *ts = scene->toolsettings;
KeyingSet *active_ks = ANIM_scene_get_active_keyingset(scene);
@@ -6656,11 +6657,9 @@ void autokeyframe_object(bContext *C, Scene *scene, ViewLayer *view_layer, Objec
/* only key on available channels */
if (adt && adt->action) {
ListBase nla_cache = {NULL, NULL};
-
for (fcu = adt->action->curves.first; fcu; fcu = fcu->next) {
fcu->flag &= ~FCURVE_SELECTED;
insert_keyframe(bmain,
- depsgraph,
reports,
id,
adt->action,
@@ -6775,7 +6774,6 @@ void autokeyframe_pose(bContext *C, Scene *scene, Object *ob, int tmode, short t
// TODO: this should probably be done per channel instead...
if (autokeyframe_cfra_can_key(scene, id)) {
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
ReportList *reports = CTX_wm_reports(C);
ToolSettings *ts = scene->toolsettings;
KeyingSet *active_ks = ANIM_scene_get_active_keyingset(scene);
@@ -6823,7 +6821,6 @@ void autokeyframe_pose(bContext *C, Scene *scene, Object *ob, int tmode, short t
*/
if (pchanName && STREQ(pchanName, pchan->name)) {
insert_keyframe(bmain,
- depsgraph,
reports,
id,
act,
@@ -9018,7 +9015,7 @@ static void createTransGPencil_center_get(bGPDstroke *gps, float r_center[3])
static void createTransGPencil(bContext *C, TransInfo *t)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
bGPdata *gpd = ED_gpencil_data_get_active(C);
ToolSettings *ts = CTX_data_tool_settings(C);
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 4a9584ed9be..969e2558abb 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -1391,7 +1391,6 @@ void initTransDataContainers_FromObjectData(TransInfo *t,
*/
void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *event)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
Scene *sce = CTX_data_scene(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
const eObjectMode object_mode = OBACT(view_layer) ? OBACT(view_layer)->mode : OB_MODE_OBJECT;
@@ -1403,7 +1402,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
bGPdata *gpd = CTX_data_gpencil_data(C);
PropertyRNA *prop;
- t->depsgraph = depsgraph;
+ t->depsgraph = CTX_data_depsgraph_pointer(C);
t->scene = sce;
t->view_layer = view_layer;
t->sa = sa;
@@ -1692,7 +1691,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
}
}
else {
- if (U.flag & USER_RELEASECONFIRM) {
+ if (ISMOUSE(t->launch_event) && (U.flag & USER_RELEASECONFIRM)) {
+ /* Global "release confirm" on mouse bindings */
t->flag |= T_RELEASE_CONFIRM;
}
}
diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c
index a883b5b6ba5..fbfeb4f53de 100644
--- a/source/blender/editors/transform/transform_gizmo_3d.c
+++ b/source/blender/editors/transform/transform_gizmo_3d.c
@@ -731,7 +731,9 @@ int ED_transform_calc_gizmo_stats(const bContext *C,
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
Scene *scene = CTX_data_scene(C);
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ /* TODO(sergey): This function is used from operator's modal() and from gizmo's refresh().
+ * Is it fine to possibly evaluate dependency graph here? */
+ Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
View3D *v3d = sa->spacedata.first;
Object *obedit = CTX_data_edit_object(C);
diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c
index 183e140169d..c84d7539cce 100644
--- a/source/blender/editors/undo/ed_undo.c
+++ b/source/blender/editors/undo/ed_undo.c
@@ -568,15 +568,6 @@ int ED_undo_operator_repeat(bContext *C, wmOperator *op)
}
}
- if (op->type->flag & OPTYPE_USE_EVAL_DATA) {
- /* We need to force refresh of depsgraph after undo step,
- * redoing the operator *may* rely on some valid evaluated data. */
- Main *bmain = CTX_data_main(C);
- scene = CTX_data_scene(C);
- ViewLayer *view_layer = CTX_data_view_layer(C);
- BKE_scene_view_layer_graph_evaluated_ensure(bmain, scene, view_layer);
- }
-
retval = WM_operator_repeat(C, op);
if ((retval & OPERATOR_FINISHED) == 0) {
if (G.debug & G_DEBUG) {
@@ -748,7 +739,7 @@ void ED_undo_object_editmode_restore_helper(struct bContext *C,
Main *bmain = CTX_data_main(C);
ViewLayer *view_layer = CTX_data_view_layer(C);
uint bases_len = 0;
- /* Don't request unique data because we wan't to de-select objects when exiting edit-mode
+ /* Don't request unique data because we want to de-select objects when exiting edit-mode
* for that to be done on all objects we can't skip ones that share data. */
Base **bases = BKE_view_layer_array_from_bases_in_edit_mode(view_layer, NULL, &bases_len);
for (uint i = 0; i < bases_len; i++) {
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index c1b6a7b42b2..c2566d111cf 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -99,7 +99,7 @@ void ED_editors_init_for_undo(Main *bmain)
void ED_editors_init(bContext *C)
{
- struct Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ struct Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C);
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
wmWindowManager *wm = CTX_wm_manager(C);
diff --git a/source/blender/editors/util/select_buffer_utils.c b/source/blender/editors/util/select_buffer_utils.c
index 79f0f48830e..2201ee5cec2 100644
--- a/source/blender/editors/util/select_buffer_utils.c
+++ b/source/blender/editors/util/select_buffer_utils.c
@@ -216,7 +216,7 @@ uint ED_select_buffer_sample_point(const int center[2])
/**
* Find the selection id closest to \a center.
* \param dist[in,out]: Use to initialize the distance,
- * when found, this value is set to the distance of the selection thats returned.
+ * when found, this value is set to the distance of the selection that's returned.
*/
uint ED_select_buffer_find_nearest_to_point(const int center[2],
const uint id_min,
diff --git a/source/blender/editors/uvedit/uvedit_buttons.c b/source/blender/editors/uvedit/uvedit_buttons.c
index 1482fea456d..2abbe67237e 100644
--- a/source/blender/editors/uvedit/uvedit_buttons.c
+++ b/source/blender/editors/uvedit/uvedit_buttons.c
@@ -40,8 +40,9 @@
#include "BKE_context.h"
#include "BKE_customdata.h"
-#include "BKE_screen.h"
#include "BKE_editmesh.h"
+#include "BKE_layer.h"
+#include "BKE_screen.h"
#include "DEG_depsgraph.h"
@@ -57,7 +58,8 @@
/* UV Utilities */
-static int uvedit_center(Scene *scene, Object *obedit, BMEditMesh *em, Image *ima, float center[2])
+static int uvedit_center(
+ Scene *scene, Object **objects, uint objects_len, Image *ima, float center[2])
{
BMFace *f;
BMLoop *l;
@@ -65,19 +67,24 @@ static int uvedit_center(Scene *scene, Object *obedit, BMEditMesh *em, Image *im
MLoopUV *luv;
int tot = 0;
- const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
-
zero_v2(center);
- BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, f)) {
- continue;
- }
- BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
- if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
- luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
- add_v2_v2(center, luv->uv);
- tot++;
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
+ const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
+
+ BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) {
+ if (!uvedit_face_visible_test(scene, obedit, ima, f)) {
+ continue;
+ }
+
+ BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
+ if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
+ luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
+ add_v2_v2(center, luv->uv);
+ tot++;
+ }
}
}
}
@@ -91,24 +98,29 @@ static int uvedit_center(Scene *scene, Object *obedit, BMEditMesh *em, Image *im
}
static void uvedit_translate(
- Scene *scene, Object *obedit, BMEditMesh *em, Image *ima, float delta[2])
+ Scene *scene, Object **objects, uint objects_len, Image *ima, float delta[2])
{
BMFace *f;
BMLoop *l;
BMIter iter, liter;
MLoopUV *luv;
- const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ BMEditMesh *em = BKE_editmesh_from_object(obedit);
- BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) {
- if (!uvedit_face_visible_test(scene, obedit, ima, f)) {
- continue;
- }
+ const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV);
- BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
- if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
- luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
- add_v2_v2(luv->uv, delta);
+ BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) {
+ if (!uvedit_face_visible_test(scene, obedit, ima, f)) {
+ continue;
+ }
+
+ BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
+ if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) {
+ luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
+ add_v2_v2(luv->uv, delta);
+ }
}
}
}
@@ -122,18 +134,17 @@ static void uvedit_vertex_buttons(const bContext *C, uiBlock *block)
{
SpaceImage *sima = CTX_wm_space_image(C);
Scene *scene = CTX_data_scene(C);
- Object *obedit = CTX_data_edit_object(C);
Image *ima = sima->image;
- BMEditMesh *em;
float center[2];
int imx, imy, step, digits;
float width = 8 * UI_UNIT_X;
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(
+ CTX_data_view_layer(C), CTX_wm_view3d(C), &objects_len);
ED_space_image_get_size(sima, &imx, &imy);
- em = BKE_editmesh_from_object(obedit);
-
- if (uvedit_center(scene, obedit, em, ima, center)) {
+ if (uvedit_center(scene, objects, objects_len, ima, center)) {
float range_xy[2][2] = {
{-10.0f, 10.0f},
{-10.0f, 10.0f},
@@ -193,15 +204,15 @@ static void uvedit_vertex_buttons(const bContext *C, uiBlock *block)
"");
UI_block_align_end(block);
}
+
+ MEM_freeN(objects);
}
static void do_uvedit_vertex(bContext *C, void *UNUSED(arg), int event)
{
SpaceImage *sima = CTX_wm_space_image(C);
Scene *scene = CTX_data_scene(C);
- Object *obedit = CTX_data_edit_object(C);
Image *ima = sima->image;
- BMEditMesh *em;
float center[2], delta[2];
int imx, imy;
@@ -209,10 +220,12 @@ static void do_uvedit_vertex(bContext *C, void *UNUSED(arg), int event)
return;
}
- em = BKE_editmesh_from_object(obedit);
+ uint objects_len = 0;
+ Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs(
+ CTX_data_view_layer(C), CTX_wm_view3d(C), &objects_len);
ED_space_image_get_size(sima, &imx, &imy);
- uvedit_center(scene, obedit, em, ima, center);
+ uvedit_center(scene, objects, objects_len, ima, center);
if (sima->flag & SI_COORDFLOATS) {
delta[0] = uvedit_old_center[0] - center[0];
@@ -223,10 +236,15 @@ static void do_uvedit_vertex(bContext *C, void *UNUSED(arg), int event)
delta[1] = uvedit_old_center[1] / imy - center[1];
}
- uvedit_translate(scene, obedit, em, ima, delta);
+ uvedit_translate(scene, objects, objects_len, ima, delta);
WM_event_add_notifier(C, NC_IMAGE, sima->image);
- DEG_id_tag_update((ID *)obedit->data, ID_RECALC_GEOMETRY);
+ for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
+ Object *obedit = objects[ob_index];
+ DEG_id_tag_update((ID *)obedit->data, ID_RECALC_GEOMETRY);
+ }
+
+ MEM_freeN(objects);
}
/* Panels */
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index 71bf6a1946a..6a2f740ba51 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -2376,7 +2376,7 @@ static void uv_select_all_perform_multi(
static int uv_select_all_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);
ToolSettings *ts = scene->toolsettings;
Image *ima = CTX_data_edit_image(C);
@@ -2456,7 +2456,7 @@ static int uv_mouse_select_multi(bContext *C,
const bool deselect_all,
const bool loop)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
SpaceImage *sima = CTX_wm_space_image(C);
Scene *scene = CTX_data_scene(C);
ToolSettings *ts = scene->toolsettings;
@@ -3429,7 +3429,7 @@ static void uv_select_flush_from_tag_loop(SpaceImage *sima,
static int uv_box_select_exec(bContext *C, wmOperator *op)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
SpaceImage *sima = CTX_wm_space_image(C);
Scene *scene = CTX_data_scene(C);
ToolSettings *ts = scene->toolsettings;
@@ -3587,7 +3587,7 @@ static int uv_inside_circle(const float uv[2], const float offset[2], const floa
static int uv_circle_select_exec(bContext *C, wmOperator *op)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
SpaceImage *sima = CTX_wm_space_image(C);
Image *ima = CTX_data_edit_image(C);
Scene *scene = CTX_data_scene(C);
@@ -3727,7 +3727,7 @@ static bool do_lasso_select_mesh_uv(bContext *C,
short moves,
const eSelectOp sel_op)
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
SpaceImage *sima = CTX_wm_space_image(C);
Image *ima = CTX_data_edit_image(C);
ARegion *ar = CTX_wm_region(C);
@@ -4278,7 +4278,7 @@ static void UV_OT_pin(wmOperatorType *ot)
static int uv_select_pinned_exec(bContext *C, wmOperator *UNUSED(op))
{
- Depsgraph *depsgraph = CTX_data_depsgraph(C);
+ Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
Scene *scene = CTX_data_scene(C);
ToolSettings *ts = scene->toolsettings;
ViewLayer *view_layer = CTX_data_view_layer(C);