diff options
Diffstat (limited to 'source/blender/editors/space_clip/tracking_ops_orient.c')
-rw-r--r-- | source/blender/editors/space_clip/tracking_ops_orient.c | 68 |
1 files changed, 38 insertions, 30 deletions
diff --git a/source/blender/editors/space_clip/tracking_ops_orient.c b/source/blender/editors/space_clip/tracking_ops_orient.c index 8c5be7c9d04..3db52e6a39b 100644 --- a/source/blender/editors/space_clip/tracking_ops_orient.c +++ b/source/blender/editors/space_clip/tracking_ops_orient.c @@ -42,10 +42,12 @@ #include "BKE_context.h" #include "BKE_constraint.h" #include "BKE_tracking.h" -#include "BKE_depsgraph.h" +#include "BKE_layer.h" #include "BKE_object.h" #include "BKE_report.h" +#include "DEG_depsgraph.h" + #include "WM_api.h" #include "WM_types.h" @@ -68,17 +70,16 @@ static Object *get_camera_with_movieclip(Scene *scene, MovieClip *clip) return camera; } - for (Base *base = scene->base.first; - base != NULL; - base = base->next) + FOREACH_SCENE_OBJECT_BEGIN(scene, ob) { - if (base->object->type == OB_CAMERA) { - if (BKE_object_movieclip_get(scene, base->object, false) == clip) { - camera = base->object; + if (ob->type == OB_CAMERA) { + if (BKE_object_movieclip_get(scene, ob, false) == clip) { + camera = ob; break; } } } + FOREACH_SCENE_OBJECT_END; return camera; } @@ -86,6 +87,7 @@ static Object *get_camera_with_movieclip(Scene *scene, MovieClip *clip) static Object *get_orientation_object(bContext *C) { Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; @@ -96,7 +98,7 @@ static Object *get_orientation_object(bContext *C) object = get_camera_with_movieclip(scene, clip); } else { - object = OBACT; + object = OBACT(view_layer); } if (object != NULL && object->parent != NULL) { @@ -110,7 +112,7 @@ static int set_orientation_poll(bContext *C) { SpaceClip *sc = CTX_wm_space_clip(C); if (sc != NULL) { - Scene *scene = CTX_data_scene(C); + ViewLayer *view_layer = CTX_data_view_layer(C); MovieClip *clip = ED_space_clip_get_clip(sc); if (clip != NULL) { MovieTracking *tracking = &clip->tracking; @@ -119,7 +121,7 @@ static int set_orientation_poll(bContext *C) return true; } else { - return OBACT != NULL; + return OBACT(view_layer) != NULL; } } } @@ -143,7 +145,8 @@ static int count_selected_bundles(bContext *C) return tot; } -static void object_solver_inverted_matrix(Scene *scene, +static void object_solver_inverted_matrix(Depsgraph *depsgraph, + Scene *scene, Object *ob, float invmat[4][4]) { @@ -160,7 +163,7 @@ static void object_solver_inverted_matrix(Scene *scene, bObjectSolverConstraint *data = (bObjectSolverConstraint *)con->data; if (!found) { Object *cam = data->camera ? data->camera : scene->camera; - BKE_object_where_is_calc_mat4(scene, cam, invmat); + BKE_object_where_is_calc_mat4(depsgraph, scene, cam, invmat); } mul_m4_m4m4(invmat, invmat, data->invmat); found = true; @@ -198,6 +201,7 @@ static int set_origin_exec(bContext *C, wmOperator *op) MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; Scene *scene = CTX_data_scene(C); + Depsgraph *depsgraph = CTX_data_depsgraph(C); Object *camera = get_camera_with_movieclip(scene, clip); int selected_count = count_selected_bundles(C); @@ -234,20 +238,20 @@ static int set_origin_exec(bContext *C, wmOperator *op) mul_v3_fl(median, 1.0f / selected_count); float mat[4][4], vec[3]; - BKE_tracking_get_camera_object_matrix(scene, camera, mat); + BKE_tracking_get_camera_object_matrix(depsgraph, scene, camera, mat); mul_v3_m4v3(vec, mat, median); if (tracking_object->flag & TRACKING_OBJECT_CAMERA) { sub_v3_v3(object->loc, vec); } else { - object_solver_inverted_matrix(scene, object, mat); + object_solver_inverted_matrix(depsgraph, scene, object, mat); mul_v3_m4v3(vec, mat, vec); copy_v3_v3(object->loc, vec); } - DAG_id_tag_update(&clip->id, 0); - DAG_id_tag_update(&object->id, OB_RECALC_OB); + DEG_id_tag_update(&clip->id, 0); + DEG_id_tag_update(&object->id, OB_RECALC_OB); WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); @@ -276,7 +280,8 @@ void CLIP_OT_set_origin(wmOperatorType *ot) /********************** set floor operator *********************/ -static void set_axis(Scene *scene, +static void set_axis(Depsgraph *depsgraph, + Scene *scene, Object *ob, MovieClip *clip, MovieTrackingObject *tracking_object, @@ -290,14 +295,14 @@ static void set_axis(Scene *scene, BKE_object_to_mat4(ob, obmat); - BKE_tracking_get_camera_object_matrix(scene, camera, mat); + BKE_tracking_get_camera_object_matrix(depsgraph, scene, camera, mat); mul_v3_m4v3(vec, mat, track->bundle_pos); copy_v3_v3(dvec, vec); if (!is_camera) { float imat[4][4]; - object_solver_inverted_matrix(scene, ob, imat); + object_solver_inverted_matrix(depsgraph, scene, ob, imat); mul_v3_m4v3(vec, imat, vec); invert_m4_m4(imat, obmat); @@ -403,6 +408,7 @@ 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"); @@ -427,7 +433,7 @@ static int set_plane_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - BKE_tracking_get_camera_object_matrix(scene, camera, mat); + BKE_tracking_get_camera_object_matrix(depsgraph, scene, camera, mat); /* Get 3 bundles to use as reference. */ track = tracksbase->first; @@ -489,11 +495,11 @@ static int set_plane_exec(bContext *C, wmOperator *op) BKE_object_apply_mat4(object, mat, 0, 0); } - BKE_object_where_is_calc(scene, object); - set_axis(scene, object, clip, tracking_object, axis_track, 'X'); + BKE_object_where_is_calc(depsgraph, scene, object); + set_axis(depsgraph, scene, object, clip, tracking_object, axis_track, 'X'); - DAG_id_tag_update(&clip->id, 0); - DAG_id_tag_update(&object->id, OB_RECALC_OB); + DEG_id_tag_update(&clip->id, 0); + DEG_id_tag_update(&object->id, OB_RECALC_OB); WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); @@ -536,6 +542,7 @@ static int set_axis_exec(bContext *C, wmOperator *op) MovieTracking *tracking = &clip->tracking; MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(tracking); Scene *scene = CTX_data_scene(C); + Depsgraph *depsgraph = CTX_data_depsgraph(C); Object *object; int axis = RNA_enum_get(op->ptr, "axis"); @@ -564,10 +571,10 @@ static int set_axis_exec(bContext *C, wmOperator *op) track = track->next; } - set_axis(scene, object, clip, tracking_object, track, axis == 0 ? 'X' : 'Y'); + set_axis(depsgraph, scene, object, clip, tracking_object, track, axis == 0 ? 'X' : 'Y'); - DAG_id_tag_update(&clip->id, 0); - DAG_id_tag_update(&object->id, OB_RECALC_OB); + DEG_id_tag_update(&clip->id, 0); + DEG_id_tag_update(&object->id, OB_RECALC_OB); WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); @@ -615,6 +622,7 @@ static int do_set_scale(bContext *C, MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(tracking); MovieTrackingTrack *track; Scene *scene = CTX_data_scene(C); + Depsgraph *depsgraph = CTX_data_depsgraph(C); Object *object = NULL; Object *camera = get_camera_with_movieclip(scene, clip); ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); @@ -639,7 +647,7 @@ static int do_set_scale(bContext *C, } } - BKE_tracking_get_camera_object_matrix(scene, camera, mat); + BKE_tracking_get_camera_object_matrix(depsgraph, scene, camera, mat); track = tracksbase->first; while (track) { @@ -693,10 +701,10 @@ static int do_set_scale(bContext *C, tracking_object->scale = scale; } - DAG_id_tag_update(&clip->id, 0); + DEG_id_tag_update(&clip->id, 0); if (object) - DAG_id_tag_update(&object->id, OB_RECALC_OB); + DEG_id_tag_update(&object->id, OB_RECALC_OB); WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); |