diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-12-15 20:10:49 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-12-15 20:10:49 +0400 |
commit | e534af906a938b6e3cf0727d577c89a51052f6ff (patch) | |
tree | 28b719240db65d87bcb45363d1638782cc410312 /source/blender/editors/space_view3d/view3d_snap.c | |
parent | 53f37cd1edb6e4aa5ea1c8a0da2c466e0cad497c (diff) |
Object tracking: various fixes and improvements
- Bundles selection is now available for object's bundles
- If bundles selection wasn't changed in 3D viewport, fallback to regular
object selection, so objects behind bundles can be selected
- Snap cursor to selection now respects object's bundle selection
- Object and rack name now can be selected from list in constraint settings
- Added preset for tracks used for object tracking
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_snap.c')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_snap.c | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index ecb54c77e0c..db33426a804 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -55,6 +55,7 @@ #include "BKE_lattice.h" #include "BKE_main.h" #include "BKE_object.h" +#include "BKE_scene.h" #include "BKE_tracking.h" #include "WM_api.h" @@ -756,28 +757,55 @@ void VIEW3D_OT_snap_cursor_to_grid(wmOperatorType *ot) static void bundle_midpoint(Scene *scene, Object *ob, float vec[3]) { - MovieTrackingTrack *track; MovieClip *clip= object_get_movieclip(scene, ob, 0); + MovieTracking *tracking= &clip->tracking; + MovieTrackingObject *object= tracking->objects.first; int ok= 0; - float min[3], max[3], mat[4][4], pos[3]; + float min[3], max[3], mat[4][4], pos[3], cammat[4][4]; if(!clip) return; + unit_m4(cammat); + + if(!scene->camera) + scene->camera= scene_find_camera(scene); + + if(scene->camera) + copy_m4_m4(cammat, scene->camera->obmat); + BKE_get_tracking_mat(scene, ob, mat); INIT_MINMAX(min, max); - track= clip->tracking.tracks.first; - while(track) { - int selected= (track->flag&SELECT) || (track->pat_flag&SELECT) || (track->search_flag&SELECT); - if((track->flag&TRACK_HAS_BUNDLE) && selected) { - ok= 1; - mul_v3_m4v3(pos, mat, track->bundle_pos); - DO_MINMAX(pos, min, max); + while(object) { + ListBase *tracksbase= BKE_tracking_object_tracks(tracking, object); + MovieTrackingTrack *track= tracksbase->first; + float obmat[4][4]; + + if(object->flag & TRACKING_OBJECT_CAMERA) { + copy_m4_m4(obmat, mat); + } + else { + float imat[4][4]; + + BKE_tracking_get_interpolated_camera(tracking, object, scene->r.cfra, imat); + invert_m4(imat); + + mul_m4_m4m4(obmat, imat, cammat); + } + + while(track) { + if((track->flag&TRACK_HAS_BUNDLE) && TRACK_SELECTED(track)) { + ok= 1; + mul_v3_m4v3(pos, obmat, track->bundle_pos); + DO_MINMAX(pos, min, max); + } + + track= track->next; } - track= track->next; + object= object->next; } if(ok) { |