Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-06-10 19:26:50 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-06-10 19:26:50 +0400
commit39e591d3d04015b84fe5f12e7ef5af6507df92af (patch)
tree9e529ea6658e526a56e108866aab9578209b6de8 /source/blender
parent5534701e5d7659d8fdd73ef64375116bb07463e8 (diff)
Support for per-track Grease Pencil datablocks for motion tracking
Originally was needed to reach easy way of defining masks used for tracking (do eliminate textures which doesn't belong to feature when tracking. Implemented as alternative to GP datablock for clip and added switch between per-clip and per-track GP datablocks -- internal limitations of GP doesn't allow to display all GP datablocks easily. So either you see.edit GP associated with clip or with track. GP strokes associated with track are relative to track's position, following tracks during tracking and could be shared between several tracks. Masking code presents in libmv and there's rasterizer of GP datablocks for masks in blender's tracking module, but they still need to be glued together. Some documentation cound be found at this page: http://wiki.blender.org/index.php/Dev:Ref/Release_Notes/2.64/Motion_Tracker#Grease_Pencil
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenloader/intern/readfile.c18
-rw-r--r--source/blender/editors/gpencil/gpencil_buttons.c29
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c21
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c10
-rw-r--r--source/blender/editors/space_clip/clip_draw.c46
-rw-r--r--source/blender/editors/space_clip/space_clip.c7
-rw-r--r--source/blender/makesdna/DNA_space_types.h11
-rw-r--r--source/blender/makesdna/DNA_tracking_types.h3
-rw-r--r--source/blender/makesrna/intern/rna_movieclip.c1
-rw-r--r--source/blender/makesrna/intern/rna_space.c13
-rw-r--r--source/blender/makesrna/intern/rna_tracking.c8
11 files changed, 147 insertions, 20 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 85d597ccbdd..fccdcbef564 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6164,17 +6164,35 @@ static void direct_link_movieclip(FileData *fd, MovieClip *clip)
}
}
+static void lib_link_movieTracks(FileData *fd, MovieClip *clip, ListBase *tracksbase)
+{
+ MovieTrackingTrack *track;
+
+ for (track = tracksbase->first; track; track = track->next) {
+ track->gpd = newlibadr_us(fd, clip->id.lib, track->gpd);
+ }
+}
+
static void lib_link_movieclip(FileData *fd, Main *main)
{
MovieClip *clip;
for (clip = main->movieclip.first; clip; clip = clip->id.next) {
if (clip->id.flag & LIB_NEEDLINK) {
+ MovieTracking *tracking = &clip->tracking;
+ MovieTrackingObject *object;
+
if (clip->adt)
lib_link_animdata(fd, &clip->id, clip->adt);
clip->gpd = newlibadr_us(fd, clip->id.lib, clip->gpd);
+ lib_link_movieTracks(fd, clip, &tracking->tracks);
+
+ for (object = tracking->objects.first; object; object = object->next) {
+ lib_link_movieTracks(fd, clip, &object->tracks);
+ }
+
clip->id.flag -= LIB_NEEDLINK;
}
}
diff --git a/source/blender/editors/gpencil/gpencil_buttons.c b/source/blender/editors/gpencil/gpencil_buttons.c
index 3a7e806c2ed..b59f3756819 100644
--- a/source/blender/editors/gpencil/gpencil_buttons.c
+++ b/source/blender/editors/gpencil/gpencil_buttons.c
@@ -40,6 +40,7 @@
#include "DNA_gpencil_types.h"
#include "DNA_screen_types.h"
+#include "DNA_space_types.h"
#include "BKE_context.h"
#include "BKE_global.h"
@@ -236,6 +237,7 @@ static void draw_gpencil_panel(bContext *C, uiLayout *layout, bGPdata *gpd, Poin
PointerRNA gpd_ptr;
bGPDlayer *gpl;
uiLayout *col, *row;
+ SpaceClip *sc= CTX_wm_space_clip(C);
short v3d_stroke_opts = STROKE_OPTS_NORMAL;
const short is_v3d = CTX_wm_view3d(C) != NULL;
@@ -244,6 +246,16 @@ static void draw_gpencil_panel(bContext *C, uiLayout *layout, bGPdata *gpd, Poin
/* draw gpd settings first ------------------------------------- */
col = uiLayoutColumn(layout, 0);
+
+ if (sc) {
+ bScreen *screen = CTX_wm_screen(C);
+ PointerRNA sc_ptr;
+
+ RNA_pointer_create(&screen->id, &RNA_SpaceClipEditor, sc, &sc_ptr);
+ row = uiLayoutRow(col, 1);
+ uiItemR(row, &sc_ptr, "grease_pencil_source", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
+ }
+
/* current Grease Pencil block */
/* TODO: show some info about who owns this? */
uiTemplateID(col, C, ctx_ptr, "grease_pencil", "GPENCIL_OT_data_add", NULL, "GPENCIL_OT_data_unlink");
@@ -281,14 +293,17 @@ static void draw_gpencil_panel(bContext *C, uiLayout *layout, bGPdata *gpd, Poin
row = uiLayoutRow(col, 1);
uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "VIEW", NULL, ICON_NONE);
uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "CURSOR", NULL, ICON_NONE);
- row = uiLayoutRow(col, 1);
- uiLayoutSetActive(row, v3d_stroke_opts);
- uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "SURFACE", NULL, ICON_NONE);
- uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "STROKE", NULL, ICON_NONE);
- row = uiLayoutRow(col, 0);
- uiLayoutSetActive(row, v3d_stroke_opts == STROKE_OPTS_V3D_ON);
- uiItemR(row, &gpd_ptr, "use_stroke_endpoints", 0, NULL, ICON_NONE);
+ if (sc == NULL) {
+ row = uiLayoutRow(col, 1);
+ uiLayoutSetActive(row, v3d_stroke_opts);
+ uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "SURFACE", NULL, ICON_NONE);
+ uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "STROKE", NULL, ICON_NONE);
+
+ row = uiLayoutRow(col, 0);
+ uiLayoutSetActive(row, v3d_stroke_opts == STROKE_OPTS_V3D_ON);
+ uiItemR(row, &gpd_ptr, "use_stroke_endpoints", 0, NULL, ICON_NONE);
+ }
}
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 9250d48a20c..71cbabe9114 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -57,6 +57,7 @@
#include "BKE_library.h"
#include "BKE_object.h"
#include "BKE_report.h"
+#include "BKE_tracking.h"
#include "WM_api.h"
@@ -144,9 +145,23 @@ bGPdata **gpencil_data_get_pointers(bContext *C, PointerRNA *ptr)
MovieClip *clip = ED_space_clip(sc);
if (clip) {
- /* for now, as long as there's a clip, default to using that in Clip Editor */
- if (ptr) RNA_id_pointer_create(&clip->id, ptr);
- return &clip->gpd;
+ if (sc->gpencil_src == SC_GPENCIL_SRC_TRACK) {
+ MovieTrackingTrack *track = BKE_tracking_active_track(&clip->tracking);
+
+ if (!track)
+ return NULL;
+
+ if (ptr)
+ RNA_pointer_create(&clip->id, &RNA_MovieTrackingTrack, track, ptr);
+
+ return &track->gpd;
+ }
+ else {
+ if (ptr)
+ RNA_id_pointer_create(&clip->id, ptr);
+
+ return &clip->gpd;
+ }
}
}
break;
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 3e569f8eb96..89d8ed9c465 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -44,6 +44,7 @@
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_report.h"
+#include "BKE_tracking.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
@@ -1125,6 +1126,15 @@ static int gp_session_initdata(bContext *C, tGPsdata *p)
p->custom_color[1] = 0.0f;
p->custom_color[2] = 0.5f;
p->custom_color[3] = 0.9f;
+
+ if (sc->gpencil_src == SC_GPENCIL_SRC_TRACK) {
+ int framenr = sc->user.framenr;
+ MovieTrackingTrack *track = BKE_tracking_active_track(&sc->clip->tracking);
+ MovieTrackingMarker *marker = BKE_tracking_exact_marker(track, framenr);
+
+ p->imat[3][0] -= marker->pos[0];
+ p->imat[3][1] -= marker->pos[1];
+ }
}
break;
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index cca72e7469a..93a32fb06fc 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -1203,8 +1203,10 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip,
int i, j, a;
float pos[2], tpos[2], grid[11][11][2];
MovieTracking *tracking = &clip->tracking;
+ bGPdata *gpd = NULL;
float aspy = 1.0f / tracking->camera.pixel_aspect;
float dx = (float)width / n, dy = (float)height / n * aspy;
+ float offsx = 0.0f, offsy = 0.0f;
if (sc->mode != SC_MODE_DISTORTION)
return;
@@ -1312,8 +1314,26 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip,
}
}
- if (sc->flag & SC_MANUAL_CALIBRATION && clip->gpd) {
- bGPDlayer *layer = clip->gpd->layers.first;
+ if (sc->gpencil_src == SC_GPENCIL_SRC_TRACK) {
+ MovieTrackingTrack *track = BKE_tracking_active_track(&sc->clip->tracking);
+
+ if (track) {
+ int framenr = sc->user.framenr;
+ MovieTrackingMarker *marker = BKE_tracking_exact_marker(track, framenr);
+
+ offsx = marker->pos[0];
+ offsy = marker->pos[1];
+
+ gpd = track->gpd;
+ }
+
+ }
+ else {
+ gpd = clip->gpd;
+ }
+
+ if (sc->flag & SC_MANUAL_CALIBRATION && gpd) {
+ bGPDlayer *layer = gpd->layers.first;
while (layer) {
bGPDframe *frame = layer->frames.first;
@@ -1338,11 +1358,11 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip,
float npos[2], dpos[2], len;
int steps;
- pos[0] = stroke->points[i].x * width;
- pos[1] = stroke->points[i].y * height * aspy;
+ pos[0] = (stroke->points[i].x + offsx) * width;
+ pos[1] = (stroke->points[i].y + offsy) * height * aspy;
- npos[0] = stroke->points[i + 1].x * width;
- npos[1] = stroke->points[i + 1].y * height * aspy;
+ npos[0] = (stroke->points[i + 1].x + offsx) * width;
+ npos[1] = (stroke->points[i + 1].y + offsy) * height * aspy;
len = len_v2v2(pos, npos);
steps = ceil(len / 5.0f);
@@ -1367,7 +1387,7 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip,
}
else if (stroke->totpoints == 1) {
glBegin(GL_POINTS);
- glVertex2f(stroke->points[0].x, stroke->points[0].y);
+ glVertex2f(stroke->points[0].x + offsx, stroke->points[0].y + offsy);
glEnd();
}
}
@@ -1467,6 +1487,18 @@ void clip_draw_grease_pencil(bContext *C, int onlyv2d)
if ((sc->flag & SC_MANUAL_CALIBRATION) == 0 || sc->mode != SC_MODE_DISTORTION) {
glPushMatrix();
glMultMatrixf(sc->unistabmat);
+
+ if (sc->gpencil_src == SC_GPENCIL_SRC_TRACK) {
+ MovieTrackingTrack *track = BKE_tracking_active_track(&sc->clip->tracking);
+
+ if (track) {
+ int framenr = sc->user.framenr;
+ MovieTrackingMarker *marker = BKE_tracking_exact_marker(track, framenr);
+
+ glTranslatef(marker->pos[0], marker->pos[1], 0.0f);
+ }
+ }
+
draw_gpencil_2dimage(C);
glPopMatrix();
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index 92ba194c8e1..a49319abd20 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -393,8 +393,11 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn)
}
break;
case NC_SCREEN:
- if (wmn->data == ND_ANIMPLAY) {
- ED_area_tag_redraw(sa);
+ switch (wmn->data) {
+ case ND_ANIMPLAY:
+ case ND_GPENCIL:
+ ED_area_tag_redraw(sa);
+ break;
}
break;
case NC_SPACE:
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 7e9a1d976d8..a315feed6c5 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -999,7 +999,10 @@ typedef struct SpaceClip {
* defined when drawing and used for mouse position calculation */
/* movie postprocessing */
- int postproc_flag, pad2;
+ int postproc_flag;
+
+ /* grease pencil */
+ short gpencil_src, pad2;
void *draw_context;
@@ -1068,6 +1071,12 @@ typedef enum eSpaceClip_Dopesheet_Flag {
SC_DOPE_SORT_INVERSE = (1 << 0),
} eSpaceClip_Dopesheet_Flag;
+/* SpaceClip->gpencil_src */
+typedef enum eSpaceClip_GPencil_Source {
+ SC_GPENCIL_SRC_CLIP = 0,
+ SC_GPENCIL_SRC_TRACK = 1,
+} eSpaceClip_GPencil_Source;
+
/* **************** SPACE DEFINES ********************* */
/* headerbuttons: 450-499 */
diff --git a/source/blender/makesdna/DNA_tracking_types.h b/source/blender/makesdna/DNA_tracking_types.h
index 6bf059c7ecb..823ecbbbba6 100644
--- a/source/blender/makesdna/DNA_tracking_types.h
+++ b/source/blender/makesdna/DNA_tracking_types.h
@@ -39,6 +39,7 @@
/* match-moving data */
+struct bGPdata;
struct ImBuf;
struct MovieReconstructedCamera;
struct MovieTrackingCamera;
@@ -107,6 +108,8 @@ typedef struct MovieTrackingTrack {
/* ** SAD tracker settings ** */
float minimum_correlation; /* minimal correlation which is still treated as successful tracking */
+
+ struct bGPdata *gpd; /* grease-pencil data */
} MovieTrackingTrack;
typedef struct MovieTrackingSettings {
diff --git a/source/blender/makesrna/intern/rna_movieclip.c b/source/blender/makesrna/intern/rna_movieclip.c
index 592e2c9f348..a4b7516a930 100644
--- a/source/blender/makesrna/intern/rna_movieclip.c
+++ b/source/blender/makesrna/intern/rna_movieclip.c
@@ -284,6 +284,7 @@ static void rna_def_movieclip(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_struct_type(prop, "GreasePencil");
RNA_def_property_ui_text(prop, "Grease Pencil", "Grease pencil data for this movie clip");
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
/* frame offset */
prop = RNA_def_property(srna, "start_frame", PROP_INT, PROP_NONE);
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 98ff8ab70bf..cafe8ebefad 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -3003,6 +3003,12 @@ static void rna_def_space_clip(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL}
};
+ static EnumPropertyItem gpencil_source_items[] = {
+ {SC_GPENCIL_SRC_CLIP, "CLIP", 0, "Clip", "Show grease pencil datablock which belongs to movie clip"},
+ {SC_GPENCIL_SRC_TRACK, "TRACK", 0, "Track", "Show grease pencil datablock which belongs to active track"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
static EnumPropertyItem pivot_items[] = {
{V3D_CENTER, "BOUNDING_BOX_CENTER", ICON_ROTATE, "Bounding Box Center",
"Pivot around bounding box center of selected object(s)"},
@@ -3212,6 +3218,13 @@ static void rna_def_space_clip(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Show Seconds", "Show timing in seconds not frames");
RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
+ /* grease pencil source */
+ prop = RNA_def_property(srna, "grease_pencil_source", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "gpencil_src");
+ RNA_def_property_enum_items(prop, gpencil_source_items);
+ RNA_def_property_ui_text(prop, "Grease Pencil Source", "Where the grease pencil comes from");
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
+
/* pivot point */
prop = RNA_def_property(srna, "pivot_point", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "around");
diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c
index b1d2bc7ac8d..17940dfca92 100644
--- a/source/blender/makesrna/intern/rna_tracking.c
+++ b/source/blender/makesrna/intern/rna_tracking.c
@@ -1102,6 +1102,14 @@ static void rna_def_trackingTrack(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "error");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Average Error", "Average error of re-projection");
+
+ /* grease pencil */
+ prop = RNA_def_property(srna, "grease_pencil", PROP_POINTER, PROP_NONE);
+ RNA_def_property_pointer_sdna(prop, NULL, "gpd");
+ RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_struct_type(prop, "GreasePencil");
+ RNA_def_property_ui_text(prop, "Grease Pencil", "Grease pencil data for this track");
+ RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
}
static void rna_def_trackingStabilization(BlenderRNA *brna)