[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38238] branches/soc-2011-tomato: Camera tracking integration
Sergey Sharybin
g.ulairi at gmail.com
Fri Jul 8 19:42:13 CEST 2011
Revision: 38238
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38238
Author: nazgul
Date: 2011-07-08 17:42:13 +0000 (Fri, 08 Jul 2011)
Log Message:
-----------
Camera tracking integration
===========================
- Made settings for tracking non-animatable.
- Fixed crash when enabling/disabling markers from
"Specials" menu.
- Translate all coords to make first reconstructed camera
be at position (0,0,0).
- Blender's camera now affects on reconstructed data.
Bundles are "parented" to active scene camera. So now
bundles' could could be scaled and rotated when camera
is rotating/scaling.
Modified Paths:
--------------
branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py
branches/soc-2011-tomato/source/blender/blenkernel/BKE_tracking.h
branches/soc-2011-tomato/source/blender/blenkernel/intern/constraint.c
branches/soc-2011-tomato/source/blender/blenkernel/intern/depsgraph.c
branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c
branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
branches/soc-2011-tomato/source/blender/editors/space_clip/clip_intern.h
branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c
branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_draw.c
branches/soc-2011-tomato/source/blender/makesrna/intern/rna_tracking.c
Modified: branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py
===================================================================
--- branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py 2011-07-08 17:40:29 UTC (rev 38237)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py 2011-07-08 17:42:13 UTC (rev 38238)
@@ -124,6 +124,9 @@
col.label(text="Reconstruction:")
col.operator("clip.solve_camera")
col.operator("clip.clear_reconstruction")
+
+ col = layout.column(align=True)
+ col.label(text="Scene Orientation:")
col.operator("clip.set_origin")
else:
layout.operator('clip.open')
Modified: branches/soc-2011-tomato/source/blender/blenkernel/BKE_tracking.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/BKE_tracking.h 2011-07-08 17:40:29 UTC (rev 38237)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_tracking.h 2011-07-08 17:42:13 UTC (rev 38238)
@@ -40,6 +40,7 @@
struct MovieTracking;
struct MovieTrackingContext;
struct MovieClipUser;
+struct Scene;
void BKE_tracking_clamp_track(struct MovieTrackingTrack *track, int event);
void BKE_tracking_track_flag(struct MovieTrackingTrack *track, int area, int flag, int clear);
@@ -73,6 +74,8 @@
struct MovieReconstructedCamera *BKE_tracking_get_reconstructed_camera(struct MovieTracking *tracking, int framenr);
+void BKE_get_tracking_mat(struct Scene *scene, float mat[4][4]);
+
#define TRACK_SELECTED(track) ((track)->flag&SELECT || (track)->pat_flag&SELECT || (track)->search_flag&SELECT)
#define TRACK_AREA_SELECTED(track, area) ((area)==TRACK_AREA_POINT?(track)->flag&SELECT : ((area)==TRACK_AREA_PAT?(track)->pat_flag&SELECT:(track)->search_flag&SELECT))
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/constraint.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/constraint.c 2011-07-08 17:40:29 UTC (rev 38237)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/constraint.c 2011-07-08 17:42:13 UTC (rev 38238)
@@ -3969,8 +3969,18 @@
return;
if(data->flag&FOLLOWTRACK_BUNDLE) {
- if(track->flag&TRACK_HAS_BUNDLE)
- translate_m4(cob->matrix, track->bundle_pos[0], track->bundle_pos[1], track->bundle_pos[2]);
+ if(track->flag&TRACK_HAS_BUNDLE) {
+ float pos[3], mat[4][4], obmat[4][4];
+
+ copy_m4_m4(obmat, cob->matrix);
+
+ BKE_get_tracking_mat(cob->scene, mat);
+ mul_v3_m4v3(pos, mat, track->bundle_pos);
+
+ cob->matrix[3][0]+= pos[0];
+ cob->matrix[3][1]+= pos[1];
+ cob->matrix[3][2]+= pos[2];
+ }
} else {
user.framenr= scene->r.cfra;
BKE_movieclip_acquire_size(clip, &user, &width, &height);
@@ -4027,9 +4037,10 @@
camera= BKE_tracking_get_reconstructed_camera(&clip->tracking, scene->r.cfra);
if(camera) {
- float m[4][4];
- copy_m4_m4(m, cob->matrix);
- mul_m4_m4m4(cob->matrix, m, camera->mat);
+ float obmat[4][4];
+
+ copy_m4_m4(obmat, cob->matrix);
+ mul_m4_m4m4(cob->matrix, camera->mat, obmat);
}
}
}
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/depsgraph.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/depsgraph.c 2011-07-08 17:40:29 UTC (rev 38237)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/depsgraph.c 2011-07-08 17:42:13 UTC (rev 38238)
@@ -2019,6 +2019,18 @@
flush_pointcache_reset(sce, itA->node, lasttime, 0);
}
}
+
+ /* also all objects which are parented to tracking data should be re-calculated */
+ for(ob=bmain->object.first; ob; ob= ob->id.next){
+ bConstraint *con;
+ for (con = ob->constraints.first; con; con=con->next) {
+ bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
+ if(ELEM(cti->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_CAMERASOLVER)) {
+ ob->recalc |= OB_RECALC_OB;
+ break;
+ }
+ }
+ }
}
dag_tag_renderlayers(sce, lay);
@@ -2471,6 +2483,13 @@
}
}
+ /* camera's matrix is used to orient reconstructed stuff,
+ so it should happen tracking-related constraints recalculation
+ when camera is changing */
+ if(sce->camera && &sce->camera->id == id && sce->clip) {
+ dag_id_flush_update(sce, &sce->clip->id);
+ }
+
/* update editors */
dag_editors_update(bmain, id);
}
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c 2011-07-08 17:40:29 UTC (rev 38237)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c 2011-07-08 17:42:13 UTC (rev 38238)
@@ -59,6 +59,7 @@
#include "BLI_utildefines.h"
#include "BLI_ghash.h"
#include "BLI_mempool.h"
+#include "BLI_math.h"
#include "BKE_library.h"
#include "BKE_global.h"
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c 2011-07-08 17:40:29 UTC (rev 38237)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c 2011-07-08 17:42:13 UTC (rev 38238)
@@ -37,15 +37,18 @@
#include "DNA_movieclip_types.h"
#include "DNA_object_types.h" /* SELECT */
+#include "DNA_scene_types.h"
#include "BLI_utildefines.h"
#include "BLI_math.h"
#include "BLI_listbase.h"
#include "BLI_ghash.h"
+#include "BKE_global.h"
#include "BKE_tracking.h"
#include "BKE_movieclip.h"
-#include "BKE_global.h"
+#include "BKE_object.h"
+#include "BKE_scene.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
@@ -712,11 +715,12 @@
static void retrive_libmv_reconstruct(MovieClip *clip, struct libmv_Reconstruction *reconstruction)
{
int tracknr= 0;
- int sfra= INT_MAX, efra= INT_MIN, a;
+ int sfra= INT_MAX, efra= INT_MIN, a, origin_set= 0;
MovieTracking *tracking= &clip->tracking;
MovieTrackingTrack *track;
MovieTrackingCamera *camera;
MovieReconstructedCamera *reconstructed;
+ float origin[3]= {0.0f, 0.f, 0.0f};
track= tracking->tracks.first;
while(track) {
@@ -757,6 +761,14 @@
float mat[4][4];
if(libmv_reporojectionCameraForImage(reconstruction, a, mat)) {
+ if(!origin_set) {
+ copy_v3_v3(origin, mat[3]);
+ origin_set= 1;
+ }
+
+ if(origin_set)
+ sub_v3_v3(mat[3], origin);
+
copy_m4_m4(reconstructed[camera->reconnr].mat, mat);
reconstructed[camera->reconnr].framenr= a;
camera->reconnr++;
@@ -770,6 +782,16 @@
memcpy(camera->reconstructed, reconstructed, camera->reconnr*sizeof(MovieReconstructedCamera));
}
+ if(origin_set) {
+ track= tracking->tracks.first;
+ while(track) {
+ if(track->flag&TRACK_HAS_BUNDLE)
+ sub_v3_v3(track->bundle_pos, origin);
+
+ track= track->next;
+ }
+ }
+
MEM_freeN(reconstructed);
}
@@ -825,3 +847,18 @@
return NULL;
}
+
+void BKE_get_tracking_mat(Scene *scene, float mat[4][4])
+{
+ float obmat[4][4];
+
+ unit_m4(obmat);
+
+ if(!scene->camera)
+ scene->camera= scene_find_camera(scene);
+
+ if(scene->camera)
+ object_to_mat4(scene->camera, obmat);
+
+ copy_m4_m4(mat, obmat);
+}
Modified: branches/soc-2011-tomato/source/blender/editors/space_clip/clip_intern.h
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_clip/clip_intern.h 2011-07-08 17:40:29 UTC (rev 38237)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/clip_intern.h 2011-07-08 17:42:13 UTC (rev 38238)
@@ -74,6 +74,7 @@
void CLIP_OT_clear_track_path(struct wmOperatorType *ot);
void CLIP_OT_disable_markers(struct wmOperatorType *ot);
+
void CLIP_OT_set_origin(struct wmOperatorType *ot);
void CLIP_OT_track_to_fcurves(struct wmOperatorType *ot);
Modified: branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c 2011-07-08 17:40:29 UTC (rev 38237)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c 2011-07-08 17:42:13 UTC (rev 38238)
@@ -47,6 +47,7 @@
#include "BKE_global.h"
#include "BKE_animsys.h"
#include "BKE_depsgraph.h"
+#include "BKE_scene.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -483,7 +484,7 @@
/* api callbacks */
ot->exec= select_exec;
ot->invoke= select_invoke;
- ot->poll= space_clip_frame_poll;
+ ot->poll= space_clip_tracking_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -554,7 +555,7 @@
ot->invoke= WM_border_select_invoke;
ot->exec= border_select_exec;
ot->modal= WM_border_select_modal;
- ot->poll= space_clip_frame_poll;
+ ot->poll= space_clip_tracking_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -637,7 +638,7 @@
ot->invoke= WM_gesture_circle_invoke;
ot->modal= WM_gesture_circle_modal;
ot->exec= circle_select_exec;
- ot->poll= space_clip_frame_poll;
+ ot->poll= space_clip_tracking_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -719,7 +720,7 @@
/* api callbacks */
ot->exec= select_all_exec;
- ot->poll= space_clip_frame_poll;
+ ot->poll= space_clip_tracking_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1018,7 +1019,7 @@
/* api callbacks */
ot->exec= solve_camera_exec;
- ot->poll= space_clip_frame_poll;
+ ot->poll= space_clip_tracking_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1062,7 +1063,7 @@
/* api callbacks */
ot->exec= clear_reconstruction_exec;
- ot->poll= space_clip_frame_poll;
+ ot->poll= space_clip_tracking_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1145,7 +1146,7 @@
while(track) {
if(TRACK_SELECTED(track)) {
- MovieTrackingMarker *marker= BKE_tracking_exact_marker(track, sc->user.framenr);
+ MovieTrackingMarker *marker= BKE_tracking_ensure_marker(track, sc->user.framenr);
if(action==0) marker->flag|= MARKER_DISABLED;
else if(action==1) marker->flag&= ~MARKER_DISABLED;
@@ -1178,7 +1179,7 @@
/* api callbacks */
ot->exec= disable_markers_exec;
- ot->poll= space_clip_frame_poll;
+ ot->poll= space_clip_tracking_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
@@ -1193,31 +1194,24 @@
{
SpaceClip *sc= CTX_wm_space_clip(C);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list