[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38508] branches/soc-2011-tomato: Camera tracking integration
Sergey Sharybin
g.ulairi at gmail.com
Tue Jul 19 14:42:02 CEST 2011
Revision: 38508
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38508
Author: nazgul
Date: 2011-07-19 12:42:01 +0000 (Tue, 19 Jul 2011)
Log Message:
-----------
Camera tracking integration
===========================
- Fixed smal lbug with mouse selection.
- Added option to show tracks names and their states
(disabled, keyframed, estimated, tracked).
Modified Paths:
--------------
branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py
branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c
branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c
branches/soc-2011-tomato/source/blender/editors/transform/transform_conversions.c
branches/soc-2011-tomato/source/blender/makesdna/DNA_space_types.h
branches/soc-2011-tomato/source/blender/makesdna/DNA_tracking_types.h
branches/soc-2011-tomato/source/blender/makesrna/intern/rna_space.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-19 10:40:22 UTC (rev 38507)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py 2011-07-19 12:42:01 UTC (rev 38508)
@@ -319,6 +319,7 @@
row.prop(sc, "show_disabled", text="Disabled")
row.prop(sc, "show_bundles", text="Bundles")
+ layout.prop(sc, "show_names", text="Names")
layout.prop(sc, "show_tiny_markers", text="Tiny Markers")
layout.prop(sc, "lock_selection")
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c 2011-07-19 10:40:22 UTC (rev 38507)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c 2011-07-19 12:42:01 UTC (rev 38508)
@@ -693,6 +693,7 @@
memset(&marker_new, 0, sizeof(marker_new));
marker_new.pos[0]= (origin[0]+x2)/ibuf_new->x;
marker_new.pos[1]= (origin[1]+y2)/ibuf_new->y;
+ marker_new.flag|= MARKER_TRACKED;
if(context->backwards) marker_new.framenr= curfra-1;
else marker_new.framenr= curfra+1;
Modified: branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c 2011-07-19 10:40:22 UTC (rev 38507)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c 2011-07-19 12:42:01 UTC (rev 38508)
@@ -46,6 +46,7 @@
#include "BLI_utildefines.h"
#include "BLI_math.h"
+#include "BLI_string.h"
#include "ED_screen.h"
#include "ED_clip.h"
@@ -485,6 +486,47 @@
glLineWidth(1.0f);
}
+static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, int act,
+ int width, int height, float zoomx, float zoomy)
+{
+ char str[128]= {0}, state[64]= {0};
+ float x, y, dx= 0.f, dy= 0.f;
+
+ if(!TRACK_SELECTED(track))
+ return;
+
+ if(marker->flag&MARKER_DISABLED) {
+ if(act) UI_ThemeColor(TH_ACT_MARKER);
+ else UI_ThemeColorShade(TH_DIS_MARKER, 128);
+ } else {
+ if(act) UI_ThemeColor(TH_ACT_MARKER);
+ else UI_ThemeColor(TH_SEL_MARKER);
+ }
+
+ if(sc->flag&SC_SHOW_MARKER_SEARCH) {
+ dx= track->search_min[0];
+ dy= track->search_min[1];
+ } else if(sc->flag&SC_SHOW_MARKER_PATTERN) {
+ dx= track->pat_min[0];
+ dy= track->pat_min[1];
+ }
+
+ x= (marker->pos[0]+dx)*width*zoomx;
+ y= (marker->pos[1]+dy)*height*zoomy-14.f*UI_DPI_FAC;
+
+ if(marker->flag&MARKER_DISABLED) strcpy(state, "disabled");
+ else if(marker->flag&MARKER_TRACKED) strcpy(state, "tracked");
+ else if(marker->framenr!=sc->user.framenr) strcpy(state, "estimated");
+ else strcpy(state, "keyframed");
+
+ if(state[0])
+ BLI_snprintf(str, sizeof(str), "%s: %s", track->name, state);
+ else
+ BLI_snprintf(str, sizeof(str), "%s", track->name);
+
+ UI_DrawString(x, y, str);
+}
+
static void view2d_to_region_float(View2D *v2d, float x, float y, float *regionx, float *regiony)
{
/* express given coordinates as proportional values */
@@ -517,6 +559,8 @@
glPushMatrix();
glTranslatef(x, y, 0);
+
+ glPushMatrix();
glScalef(zoomx, zoomy, 0);
glScalef(width, height, 0);
@@ -625,6 +669,23 @@
}
glPopMatrix();
+
+ if(sc->flag&SC_SHOW_NAMES) {
+ /* scaling should be cleared before drawing texts, otherwise font would also be scaled */
+ track= tracking->tracks.first;
+ while(track) {
+ if(TRACK_VISIBLE(track)) {
+ int act= sel_type==MCLIP_SEL_TRACK && sel==track;
+
+ marker= BKE_tracking_get_marker(track, framenr);
+ draw_marker_texts(sc, track, marker, act, width, height, zoomx, zoomy);
+ }
+
+ track= track->next;
+ }
+ }
+
+ glPopMatrix();
}
static void draw_tracking(SpaceClip *sc, ARegion *ar, MovieClip *clip,
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-19 10:40:22 UTC (rev 38507)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c 2011-07-19 12:42:01 UTC (rev 38508)
@@ -412,19 +412,24 @@
SpaceClip *sc= CTX_wm_space_clip(C);
MovieClip *clip= ED_space_clip(sc);
MovieTrackingTrack *track= NULL; /* selected marker */
+ int hidden= 0;
track= find_nearest_track(sc, clip, co);
+ if((sc->flag&SC_SHOW_MARKER_PATTERN)==0) hidden|= TRACK_AREA_PAT;
+ if((sc->flag&SC_SHOW_MARKER_SEARCH)==0) hidden|= TRACK_AREA_SEARCH;
+
if(track) {
int area= track_mouse_area(sc, co, track);
if(!extend || !TRACK_SELECTED(track))
- area= TRACK_AREA_ALL;
+ area= TRACK_AREA_ALL & ~hidden;
if(extend && TRACK_AREA_SELECTED(track, area)) {
BKE_movieclip_deselect_track(clip, track, area);
} else {
- if(area==TRACK_AREA_POINT) area= TRACK_AREA_ALL;
+ if(area==TRACK_AREA_POINT)
+ area= TRACK_AREA_ALL & ~hidden;
BKE_movieclip_select_track(clip, track, area, extend);
BKE_movieclip_set_selection(clip, MCLIP_SEL_TRACK, track);
@@ -1607,6 +1612,7 @@
typedef struct {
int area;
MovieTrackingTrack *track;
+ MovieTrackingMarker *marker;
int mval[2];
int width, height;
@@ -1625,6 +1631,7 @@
data->area= area;
data->track= track;
+ data->marker= marker;
if(area==TRACK_AREA_POINT) {
data->pos= marker->pos;
@@ -1767,6 +1774,8 @@
if(data->area == TRACK_AREA_POINT) {
data->pos[0]= data->spos[0]+dx;
data->pos[1]= data->spos[1]+dy;
+
+ data->marker->flag&= ~MARKER_TRACKED;
} else {
data->min[0]= data->smin[0]-dx;
data->max[0]= data->smax[0]+dx;
Modified: branches/soc-2011-tomato/source/blender/editors/transform/transform_conversions.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/transform/transform_conversions.c 2011-07-19 10:40:22 UTC (rev 38507)
+++ branches/soc-2011-tomato/source/blender/editors/transform/transform_conversions.c 2011-07-19 12:42:01 UTC (rev 38508)
@@ -5251,7 +5251,7 @@
track->transflag= marker->flag;
- marker->flag&= ~MARKER_DISABLED;
+ marker->flag&= ~(MARKER_DISABLED|MARKER_TRACKED);
if(track->flag&SELECT)
markerToTransDataInit(td++, td2d++, marker->pos, NULL);
Modified: branches/soc-2011-tomato/source/blender/makesdna/DNA_space_types.h
===================================================================
--- branches/soc-2011-tomato/source/blender/makesdna/DNA_space_types.h 2011-07-19 10:40:22 UTC (rev 38507)
+++ branches/soc-2011-tomato/source/blender/makesdna/DNA_space_types.h 2011-07-19 12:42:01 UTC (rev 38508)
@@ -970,6 +970,7 @@
#define SC_SHOW_BUNDLES (1<<5)
#define SC_MUTE_FOOTAGE (1<<6)
#define SC_HIDE_DISABLED (1<<7)
+#define SC_SHOW_NAMES (1<<8)
/* space types, moved from DNA_screen_types.h */
Modified: branches/soc-2011-tomato/source/blender/makesdna/DNA_tracking_types.h
===================================================================
--- branches/soc-2011-tomato/source/blender/makesdna/DNA_tracking_types.h 2011-07-19 10:40:22 UTC (rev 38507)
+++ branches/soc-2011-tomato/source/blender/makesdna/DNA_tracking_types.h 2011-07-19 12:42:01 UTC (rev 38508)
@@ -122,7 +122,8 @@
};
/* MovieTrackingMarker->flag */
-#define MARKER_DISABLED 1
+#define MARKER_DISABLED (1<<0)
+#define MARKER_TRACKED (1<<1)
/* MovieTrackingTrack->flag */
#define TRACK_HAS_BUNDLE (1<<1)
Modified: branches/soc-2011-tomato/source/blender/makesrna/intern/rna_space.c
===================================================================
--- branches/soc-2011-tomato/source/blender/makesrna/intern/rna_space.c 2011-07-19 10:40:22 UTC (rev 38507)
+++ branches/soc-2011-tomato/source/blender/makesrna/intern/rna_space.c 2011-07-19 12:42:01 UTC (rev 38508)
@@ -2700,6 +2700,12 @@
RNA_def_property_pointer_sdna(prop, NULL, "scopes");
RNA_def_property_struct_type(prop, "MovieClipScopes");
RNA_def_property_ui_text(prop, "Scopes", "Scopes to visualize movie clip statistics.");
+
+ /* show names */
+ prop= RNA_def_property(srna, "show_names", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", SC_SHOW_NAMES);
+ RNA_def_property_ui_text(prop, "Show Names", "Show track names and status");
+ RNA_def_property_update(prop, NC_SPACE|ND_SPACE_CLIP, NULL);
}
More information about the Bf-blender-cvs
mailing list