Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_clip/tracking_ops_orient.c
| Show All 33 Lines | |||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_constraint.h" | #include "BKE_constraint.h" | ||||
| #include "BKE_tracking.h" | #include "BKE_tracking.h" | ||||
| #include "BKE_layer.h" | #include "BKE_layer.h" | ||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| #include "BKE_report.h" | #include "BKE_report.h" | ||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "DEG_depsgraph_query.h" | |||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "ED_clip.h" | #include "ED_clip.h" | ||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "RNA_define.h" | #include "RNA_define.h" | ||||
| ▲ Show 20 Lines • Show All 340 Lines • ▼ Show 20 Lines | static int set_plane_exec(bContext *C, wmOperator *op) | ||||
| MovieClip *clip = ED_space_clip_get_clip(sc); | MovieClip *clip = ED_space_clip_get_clip(sc); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| MovieTracking *tracking = &clip->tracking; | MovieTracking *tracking = &clip->tracking; | ||||
| MovieTrackingObject *tracking_object; | MovieTrackingObject *tracking_object; | ||||
| MovieTrackingTrack *track, *axis_track = NULL, *act_track; | MovieTrackingTrack *track, *axis_track = NULL, *act_track; | ||||
| ListBase *tracksbase; | ListBase *tracksbase; | ||||
| Object *object; | Object *object; | ||||
| Object *camera = get_camera_with_movieclip(scene, clip); | Object *camera = get_camera_with_movieclip(scene, clip); | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | |||||
| int tot = 0; | int tot = 0; | ||||
| float vec[3][3], mat[4][4], obmat[4][4], newmat[4][4], orig[3] = {0.0f, 0.0f, 0.0f}; | 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"); | int plane = RNA_enum_get(op->ptr, "plane"); | ||||
| float rot[4][4] = { | float rot[4][4] = { | ||||
| {0.0f, 0.0f, -1.0f, 0.0f}, | {0.0f, 0.0f, -1.0f, 0.0f}, | ||||
| {0.0f, 1.0f, 0.0f, 0.0f}, | {0.0f, 1.0f, 0.0f, 0.0f}, | ||||
| {1.0f, 0.0f, 0.0f, 0.0f}, | {1.0f, 0.0f, 0.0f, 0.0f}, | ||||
| {0.0f, 0.0f, 0.0f, 1.0f}, | {0.0f, 0.0f, 0.0f, 1.0f}, | ||||
| ▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | if (object->loc[2] < 0) { | ||||
| mul_m4_m4m4(newmat, rot, mat); | mul_m4_m4m4(newmat, rot, mat); | ||||
| BKE_object_apply_mat4(object, newmat, 0, 0); | BKE_object_apply_mat4(object, newmat, 0, 0); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| BKE_object_apply_mat4(object, mat, 0, 0); | 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'); | set_axis(scene, object, clip, tracking_object, axis_track, 'X'); | ||||
| DEG_id_tag_update(&clip->id, 0); | DEG_id_tag_update(&clip->id, 0); | ||||
| DEG_id_tag_update(&object->id, ID_RECALC_TRANSFORM); | DEG_id_tag_update(&object->id, ID_RECALC_TRANSFORM); | ||||
| WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); | WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); | ||||
| WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); | WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); | ||||
| ▲ Show 20 Lines • Show All 363 Lines • Show Last 20 Lines | |||||