Move search area form track to marker structure
This allows different markers has different size of search area which
makes it possible to scale search area when doing planar tracking.
Made changes to all related areas such as transformation, tracking,
finally ported marker clamping function, added python bindings for
changed search area and added python API for pattern corners.
TODO: It's still possible to make marker's center go outside of pattern
corners when translating pattern area or rotating it around median
point.
This commit is contained in:
@@ -48,7 +48,7 @@ struct Object;
|
||||
struct Scene;
|
||||
|
||||
void BKE_tracking_init_settings(struct MovieTracking *tracking);
|
||||
void BKE_tracking_clamp_track(struct MovieTrackingTrack *track, int event);
|
||||
void BKE_tracking_clamp_marker(struct MovieTrackingMarker *marker, int event);
|
||||
void BKE_tracking_track_flag(struct MovieTrackingTrack *track, int area, int flag, int clear);
|
||||
|
||||
struct MovieTrackingTrack *BKE_tracking_add_track(struct MovieTracking *tracking, struct ListBase *tracksbase,
|
||||
@@ -76,7 +76,8 @@ struct ImBuf *BKE_tracking_get_pattern_imbuf(struct ImBuf *ibuf, struct MovieTra
|
||||
float pos[2], int origin[2]);
|
||||
struct ImBuf *BKE_tracking_get_search_imbuf(struct ImBuf *ibuf, struct MovieTrackingTrack *track,
|
||||
struct MovieTrackingMarker *marker);
|
||||
struct ImBuf *BKE_tracking_track_mask_get(struct MovieTracking *tracking, struct MovieTrackingTrack *track, int width, int height);
|
||||
struct ImBuf *BKE_tracking_track_mask_get(struct MovieTracking *tracking, struct MovieTrackingTrack *track,
|
||||
struct MovieTrackingMarker *marker, int width, int height);
|
||||
|
||||
void BKE_track_unique_name(struct ListBase *tracksbase, struct MovieTrackingTrack *track);
|
||||
|
||||
|
||||
@@ -104,11 +104,10 @@ static void marker_unified_to_frame_pixel_coordinates(const ImBuf *ibuf, const M
|
||||
unified_to_pixel(ibuf, frame_pixel_coords, frame_pixel_coords);
|
||||
}
|
||||
|
||||
static void get_search_origin_frame_pixel(const ImBuf *ibuf, const MovieTrackingTrack *track,
|
||||
const MovieTrackingMarker *marker, float frame_pixel[2])
|
||||
static void get_search_origin_frame_pixel(const ImBuf *ibuf, const MovieTrackingMarker *marker, float frame_pixel[2])
|
||||
{
|
||||
/* Get the lower left coordinate of the search window and snap to pixel coordinates */
|
||||
marker_unified_to_frame_pixel_coordinates(ibuf, marker, track->search_min, frame_pixel);
|
||||
marker_unified_to_frame_pixel_coordinates(ibuf, marker, marker->search_min, frame_pixel);
|
||||
frame_pixel[0] = (int)frame_pixel[0];
|
||||
frame_pixel[1] = (int)frame_pixel[1];
|
||||
}
|
||||
@@ -120,26 +119,24 @@ static void pixel_to_unified(const ImBuf *ibuf, const float pixel_coords[2], flo
|
||||
unified_coords[1] = pixel_coords[1] / ibuf->y;
|
||||
}
|
||||
|
||||
static void marker_unified_to_search_pixel(const ImBuf *ibuf, const MovieTrackingTrack *track,
|
||||
const MovieTrackingMarker *marker, const float marker_unified[2],
|
||||
float search_pixel[2])
|
||||
static void marker_unified_to_search_pixel(const ImBuf *ibuf, const MovieTrackingMarker *marker,
|
||||
const float marker_unified[2], float search_pixel[2])
|
||||
{
|
||||
float frame_pixel[2];
|
||||
float search_origin_frame_pixel[2];
|
||||
|
||||
marker_unified_to_frame_pixel_coordinates(ibuf, marker, marker_unified, frame_pixel);
|
||||
get_search_origin_frame_pixel(ibuf, track, marker, search_origin_frame_pixel);
|
||||
get_search_origin_frame_pixel(ibuf, marker, search_origin_frame_pixel);
|
||||
sub_v2_v2v2(search_pixel, frame_pixel, search_origin_frame_pixel);
|
||||
}
|
||||
|
||||
static void search_pixel_to_marker_unified(const ImBuf *ibuf, const MovieTrackingTrack *track,
|
||||
const MovieTrackingMarker *marker, const float search_pixel[2],
|
||||
float marker_unified[2])
|
||||
static void search_pixel_to_marker_unified(const ImBuf *ibuf, const MovieTrackingMarker *marker,
|
||||
const float search_pixel[2], float marker_unified[2])
|
||||
{
|
||||
float frame_unified[2];
|
||||
float search_origin_frame_pixel[2];
|
||||
|
||||
get_search_origin_frame_pixel(ibuf, track, marker, search_origin_frame_pixel);
|
||||
get_search_origin_frame_pixel(ibuf, marker, search_origin_frame_pixel);
|
||||
add_v2_v2v2(frame_unified, search_pixel, search_origin_frame_pixel);
|
||||
pixel_to_unified(ibuf, frame_unified, frame_unified);
|
||||
|
||||
@@ -173,34 +170,18 @@ void BKE_tracking_init_settings(MovieTracking *tracking)
|
||||
BKE_tracking_new_object(tracking, "Camera");
|
||||
}
|
||||
|
||||
void BKE_tracking_clamp_track(MovieTrackingTrack *track, int event)
|
||||
void BKE_tracking_clamp_marker(MovieTrackingMarker *marker, int event)
|
||||
{
|
||||
int a;
|
||||
float pat_min[2], pat_max[2];
|
||||
float eff_pat_min[2], eff_pat_max[2];
|
||||
|
||||
/* XXX: currently search area is global, pattern size is per-marker, so we'll need to
|
||||
* find maximal size of pattern to clamp search size nicely
|
||||
*/
|
||||
INIT_MINMAX2(pat_min, pat_max);
|
||||
|
||||
for (a = 0; a < track->markersnr; a++) {
|
||||
float cur_pat_min[2], cur_pat_max[2];
|
||||
|
||||
BKE_tracking_marker_pattern_minmax(&track->markers[a], cur_pat_min, cur_pat_max);
|
||||
|
||||
DO_MINMAX2(cur_pat_min, pat_min, pat_max);
|
||||
DO_MINMAX2(cur_pat_max, pat_min, pat_max);
|
||||
}
|
||||
|
||||
copy_v2_v2(eff_pat_min, pat_min);
|
||||
copy_v2_v2(eff_pat_max, pat_max);
|
||||
BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
|
||||
|
||||
if (event == CLAMP_PAT_DIM) {
|
||||
for (a = 0; a < 2; a++) {
|
||||
/* search shouldn't be resized smaller than pattern */
|
||||
track->search_min[a] = MIN2(eff_pat_min[a], track->search_min[a]);
|
||||
track->search_max[a] = MAX2(eff_pat_max[a], track->search_max[a]);
|
||||
marker->search_min[a] = MIN2(pat_min[a], marker->search_min[a]);
|
||||
marker->search_max[a] = MAX2(pat_max[a], marker->search_max[a]);
|
||||
}
|
||||
}
|
||||
else if (event == CLAMP_PAT_POS) {
|
||||
@@ -208,44 +189,40 @@ void BKE_tracking_clamp_track(MovieTrackingTrack *track, int event)
|
||||
|
||||
sub_v2_v2v2(dim, pat_max, pat_min);
|
||||
|
||||
#if 0
|
||||
/* XXX: needs porting, but we need to know marker here, will be ported after a bit
|
||||
* more global refactoring
|
||||
*/
|
||||
for (a = 0; a < 2; a++) {
|
||||
int b;
|
||||
/* pattern shouldn't be moved outside of search */
|
||||
if (eff_pat_min[a] < track->search_min[a]) {
|
||||
track->pat_min[a] = track->search_min[a] - (eff_pat_min[a] - pat_min[a]);
|
||||
track->pat_max[a] = track->pat_min[a] + dim[a];
|
||||
if (pat_min[a] < marker->search_min[a]) {
|
||||
for (b = 0; b < 4; b++)
|
||||
marker->pattern_corners[b][a] += marker->search_min[a] - pat_min[a];
|
||||
}
|
||||
if (eff_pat_max[a] > track->search_max[a]) {
|
||||
track->pat_max[a] = track->search_max[a] - (eff_pat_max[a] - pat_max[a]);
|
||||
track->pat_min[a] = track->pat_max[a] - dim[a];
|
||||
if (pat_max[a] > marker->search_max[a]) {
|
||||
for (b = 0; b < 4; b++)
|
||||
marker->pattern_corners[b][a] -= pat_max[a] - marker->search_max[a];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (event == CLAMP_SEARCH_DIM) {
|
||||
for (a = 0; a < 2; a++) {
|
||||
/* search shouldn't be resized smaller than pattern */
|
||||
track->search_min[a] = MIN2(eff_pat_min[a], track->search_min[a]);
|
||||
track->search_max[a] = MAX2(eff_pat_max[a], track->search_max[a]);
|
||||
marker->search_min[a] = MIN2(pat_min[a], marker->search_min[a]);
|
||||
marker->search_max[a] = MAX2(pat_max[a], marker->search_max[a]);
|
||||
}
|
||||
}
|
||||
else if (event == CLAMP_SEARCH_POS) {
|
||||
float dim[2];
|
||||
|
||||
sub_v2_v2v2(dim, track->search_max, track->search_min);
|
||||
sub_v2_v2v2(dim, marker->search_max, marker->search_min);
|
||||
|
||||
for (a = 0; a < 2; a++) {
|
||||
/* search shouldn't be moved inside pattern */
|
||||
if (track->search_min[a] > eff_pat_min[a]) {
|
||||
track->search_min[a] = eff_pat_min[a];
|
||||
track->search_max[a] = track->search_min[a] + dim[a];
|
||||
if (marker->search_min[a] > pat_min[a]) {
|
||||
marker->search_min[a] = pat_min[a];
|
||||
marker->search_max[a] = marker->search_min[a] + dim[a];
|
||||
}
|
||||
if (track->search_max[a] < eff_pat_max[a]) {
|
||||
track->search_max[a] = eff_pat_max[a];
|
||||
track->search_min[a] = track->search_max[a] - dim[a];
|
||||
if (marker->search_max[a] < pat_max[a]) {
|
||||
marker->search_max[a] = pat_max[a];
|
||||
marker->search_min[a] = marker->search_max[a] - dim[a];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -253,8 +230,8 @@ void BKE_tracking_clamp_track(MovieTrackingTrack *track, int event)
|
||||
float dim[2];
|
||||
sub_v2_v2v2(dim, pat_max, pat_min);
|
||||
for (a = 0; a < 2; a++) {
|
||||
track->search_min[a] = pat_min[a];
|
||||
track->search_max[a] = pat_max[a];
|
||||
marker->search_min[a] = pat_min[a];
|
||||
marker->search_max[a] = pat_max[a];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -324,8 +301,8 @@ MovieTrackingTrack *BKE_tracking_add_track(MovieTracking *tracking, ListBase *tr
|
||||
negate_v2_v2(marker.pattern_corners[2], marker.pattern_corners[0]);
|
||||
negate_v2_v2(marker.pattern_corners[3], marker.pattern_corners[1]);
|
||||
|
||||
copy_v2_v2(track->search_max, search);
|
||||
negate_v2_v2(track->search_min, search);
|
||||
copy_v2_v2(marker.search_max, search);
|
||||
negate_v2_v2(marker.search_min, search);
|
||||
|
||||
BKE_tracking_insert_marker(track, &marker);
|
||||
|
||||
@@ -1276,13 +1253,13 @@ ImBuf *BKE_tracking_get_search_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, Mov
|
||||
int x, y, w, h;
|
||||
float search_origin[2];
|
||||
|
||||
get_search_origin_frame_pixel(ibuf, track, marker, search_origin);
|
||||
get_search_origin_frame_pixel(ibuf, marker, search_origin);
|
||||
|
||||
x = search_origin[0];
|
||||
y = search_origin[1];
|
||||
|
||||
w = (track->search_max[0] - track->search_min[0]) * ibuf->x;
|
||||
h = (track->search_max[1] - track->search_min[1]) * ibuf->y;
|
||||
w = (marker->search_max[0] - marker->search_min[0]) * ibuf->x;
|
||||
h = (marker->search_max[1] - marker->search_min[1]) * ibuf->y;
|
||||
|
||||
searchibuf = IMB_allocImBuf(w, h, 32, ibuf->rect_float ? IB_rectfloat : IB_rect);
|
||||
searchibuf->profile = ibuf->profile;
|
||||
@@ -1319,7 +1296,7 @@ static bGPDlayer *track_mask_gpencil_layer_get(MovieTrackingTrack *track)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void track_mask_gpencil_layer_rasterize(MovieTracking *tracking, MovieTrackingTrack *track,
|
||||
static void track_mask_gpencil_layer_rasterize(MovieTracking *tracking, MovieTrackingMarker *marker,
|
||||
bGPDlayer *layer, ImBuf *ibuf, int width, int height)
|
||||
{
|
||||
bGPDframe *frame = layer->frames.first;
|
||||
@@ -1342,8 +1319,8 @@ static void track_mask_gpencil_layer_rasterize(MovieTracking *tracking, MovieTra
|
||||
"track mask rasterization points");
|
||||
|
||||
for (i = 0; i < stroke->totpoints; i++, fp += 2) {
|
||||
fp[0] = stroke_points[i].x * width / ibuf->x - track->search_min[0];
|
||||
fp[1] = stroke_points[i].y * height * aspy / ibuf->x - track->search_min[1];
|
||||
fp[0] = stroke_points[i].x * width / ibuf->x - marker->search_min[0];
|
||||
fp[1] = stroke_points[i].y * height * aspy / ibuf->x - marker->search_min[1];
|
||||
}
|
||||
|
||||
PLX_raskterize(mask_points, stroke->totpoints, mask, ibuf->x, ibuf->y);
|
||||
@@ -1374,19 +1351,20 @@ static void track_mask_gpencil_layer_rasterize(MovieTracking *tracking, MovieTra
|
||||
IMB_rect_from_float(ibuf);
|
||||
}
|
||||
|
||||
ImBuf *BKE_tracking_track_mask_get(MovieTracking *tracking, MovieTrackingTrack *track, int width, int height)
|
||||
ImBuf *BKE_tracking_track_mask_get(MovieTracking *tracking, MovieTrackingTrack *track, MovieTrackingMarker *marker,
|
||||
int width, int height)
|
||||
{
|
||||
ImBuf *ibuf;
|
||||
bGPDlayer *layer = track_mask_gpencil_layer_get(track);
|
||||
int mask_width, mask_height;
|
||||
|
||||
mask_width = (track->search_max[0] - track->search_min[0]) * width;
|
||||
mask_height = (track->search_max[1] - track->search_min[1]) * height;
|
||||
mask_width = (marker->search_max[0] - marker->search_min[0]) * width;
|
||||
mask_height = (marker->search_max[1] - marker->search_min[1]) * height;
|
||||
|
||||
ibuf = IMB_allocImBuf(mask_width, mask_height, 32, IB_rect | IB_rectfloat);
|
||||
|
||||
if (layer) {
|
||||
track_mask_gpencil_layer_rasterize(tracking, track, layer, ibuf, width, height);
|
||||
track_mask_gpencil_layer_rasterize(tracking, marker, layer, ibuf, width, height);
|
||||
}
|
||||
else {
|
||||
float white[4] = {1.0f, 1.0f, 1.0f, 1.0f};
|
||||
@@ -1459,8 +1437,7 @@ static float *get_search_floatbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieT
|
||||
* This function puts those 5 points into the appropriate frame for tracking
|
||||
* (the "search" coordinate frame).
|
||||
*/
|
||||
static void get_marker_coords_for_tracking(const ImBuf *ibuf, const MovieTrackingTrack *track,
|
||||
const MovieTrackingMarker *marker,
|
||||
static void get_marker_coords_for_tracking(const ImBuf *ibuf, const MovieTrackingMarker *marker,
|
||||
double search_pixel_x[5], double search_pixel_y[5])
|
||||
{
|
||||
int i;
|
||||
@@ -1469,23 +1446,22 @@ static void get_marker_coords_for_tracking(const ImBuf *ibuf, const MovieTrackin
|
||||
|
||||
/* Convert the corners into search space coordinates. */
|
||||
for (i = 0; i < 4; i++) {
|
||||
marker_unified_to_search_pixel(ibuf, track, marker, marker->pattern_corners[i], pixel_coords);
|
||||
marker_unified_to_search_pixel(ibuf, marker, marker->pattern_corners[i], pixel_coords);
|
||||
search_pixel_x[i] = pixel_coords[0];
|
||||
search_pixel_y[i] = pixel_coords[1];
|
||||
}
|
||||
/* Convert the center position (aka "pos"); this is the origin */
|
||||
unified_coords[0] = 0.0;
|
||||
unified_coords[1] = 0.0;
|
||||
marker_unified_to_search_pixel(ibuf, track, marker, unified_coords, pixel_coords);
|
||||
marker_unified_to_search_pixel(ibuf, marker, unified_coords, pixel_coords);
|
||||
|
||||
search_pixel_x[4] = pixel_coords[0];
|
||||
search_pixel_y[4] = pixel_coords[1];
|
||||
}
|
||||
|
||||
/* Inverse of above. */
|
||||
static void set_marker_coords_from_tracking(const ImBuf *ibuf, const MovieTrackingTrack *track,
|
||||
MovieTrackingMarker *marker, const double search_pixel_x[5],
|
||||
const double search_pixel_y[5])
|
||||
static void set_marker_coords_from_tracking(const ImBuf *ibuf, MovieTrackingMarker *marker,
|
||||
const double search_pixel_x[5], const double search_pixel_y[5])
|
||||
{
|
||||
int i;
|
||||
float marker_unified[2];
|
||||
@@ -1495,13 +1471,13 @@ static void set_marker_coords_from_tracking(const ImBuf *ibuf, const MovieTracki
|
||||
for (i = 0; i < 4; i++) {
|
||||
search_pixel[0] = search_pixel_x[i];
|
||||
search_pixel[1] = search_pixel_y[i];
|
||||
search_pixel_to_marker_unified(ibuf, track, marker, search_pixel, marker->pattern_corners[i]);
|
||||
search_pixel_to_marker_unified(ibuf, marker, search_pixel, marker->pattern_corners[i]);
|
||||
}
|
||||
|
||||
/* Convert the center position (aka "pos"); this is the origin */
|
||||
search_pixel[0] = search_pixel_x[4];
|
||||
search_pixel[1] = search_pixel_y[4];
|
||||
search_pixel_to_marker_unified(ibuf, track, marker, search_pixel, marker_unified);
|
||||
search_pixel_to_marker_unified(ibuf, marker, search_pixel, marker_unified);
|
||||
|
||||
/* If the tracker tracked nothing, then "marker_unified" would be zero.
|
||||
* Otherwise, the entire patch shifted, and that delta should be applied to
|
||||
@@ -1727,9 +1703,10 @@ int BKE_tracking_next(MovieTrackingContext *context)
|
||||
IMB_freeImBuf(reference_ibuf);
|
||||
}
|
||||
|
||||
/* XXX: for now, the width & height always match because the
|
||||
* settings are per-track. This will change soon and in that
|
||||
* case different sizes must be used */
|
||||
/* for now track to the same search area dimension as marker has got for current frame
|
||||
* will make all tracked markers in currently tracked segment have the same search area
|
||||
* size, but it's quite close to what is actually needed
|
||||
*/
|
||||
patch_new = get_search_floatbuf(destination_ibuf, track, marker, &width, &height);
|
||||
|
||||
/* Configure the tracker */
|
||||
@@ -1746,11 +1723,8 @@ int BKE_tracking_next(MovieTrackingContext *context)
|
||||
options.sigma = 0.9;
|
||||
|
||||
/* Convert the marker corners and center into pixel coordinates in the search/destination images. */
|
||||
get_marker_coords_for_tracking(destination_ibuf, track, &track_context->marker,
|
||||
src_pixel_x, src_pixel_y);
|
||||
|
||||
get_marker_coords_for_tracking(destination_ibuf, track, marker,
|
||||
dst_pixel_x, dst_pixel_y);
|
||||
get_marker_coords_for_tracking(destination_ibuf, &track_context->marker, src_pixel_x, src_pixel_y);
|
||||
get_marker_coords_for_tracking(destination_ibuf, marker, dst_pixel_x, dst_pixel_y);
|
||||
|
||||
/* Run the tracker! */
|
||||
tracked = libmv_trackRegion(&options,
|
||||
@@ -1765,7 +1739,7 @@ int BKE_tracking_next(MovieTrackingContext *context)
|
||||
if (tracked && !onbound) {
|
||||
memset(&marker_new, 0, sizeof(marker_new));
|
||||
marker_new = *marker;
|
||||
set_marker_coords_from_tracking(destination_ibuf, track, &marker_new, dst_pixel_x, dst_pixel_y);
|
||||
set_marker_coords_from_tracking(destination_ibuf, &marker_new, dst_pixel_x, dst_pixel_y);
|
||||
marker_new.flag |= MARKER_TRACKED;
|
||||
marker_new.framenr = nextfra;
|
||||
|
||||
|
||||
@@ -7633,6 +7633,11 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
marker->pattern_corners[3][0] = track->pat_min[0];
|
||||
marker->pattern_corners[3][1] = track->pat_max[1];
|
||||
}
|
||||
|
||||
if (is_zero_v2(marker->search_min) && is_zero_v2(marker->search_max)) {
|
||||
copy_v2_v2(marker->search_min, track->search_min);
|
||||
copy_v2_v2(marker->search_max, track->search_max);
|
||||
}
|
||||
}
|
||||
|
||||
track = track->next;
|
||||
|
||||
@@ -190,9 +190,9 @@ typedef struct {
|
||||
|
||||
int framenr; /* current frame number */
|
||||
float marker_pos[2]; /* position of marker in pixel coords */
|
||||
float track_pat[2]; /* position and dimensions of marker pattern in pixel coords */
|
||||
float marker_pat[2]; /* position and dimensions of marker pattern in pixel coords */
|
||||
float track_offset[2]; /* offset of "parenting" point */
|
||||
float track_search_pos[2], track_search[2]; /* position and dimensions of marker search in pixel coords */
|
||||
float marker_search_pos[2], marker_search[2]; /* position and dimensions of marker search in pixel coords */
|
||||
int marker_flag; /* marker's flags */
|
||||
} MarkerUpdateCb;
|
||||
|
||||
@@ -240,67 +240,62 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event)
|
||||
}
|
||||
else if (event == B_MARKER_PAT_DIM) {
|
||||
float dim[2], pat_dim[2], pat_min[2], pat_max[2];
|
||||
float scale_x, scale_y;
|
||||
int a;
|
||||
|
||||
BKE_tracking_marker_pattern_minmax(cb->marker, pat_min, pat_max);
|
||||
|
||||
sub_v2_v2v2(pat_dim, pat_max, pat_min);
|
||||
|
||||
dim[0] = cb->track_pat[0] / width;
|
||||
dim[1] = cb->track_pat[1] / height;
|
||||
dim[0] = cb->marker_pat[0] / width;
|
||||
dim[1] = cb->marker_pat[1] / height;
|
||||
|
||||
sub_v2_v2(dim, pat_dim);
|
||||
mul_v2_fl(dim, 0.5f);
|
||||
scale_x = dim[0] / pat_dim[0];
|
||||
scale_y = dim[1] / pat_dim[1];
|
||||
|
||||
cb->marker->pattern_corners[0][0] -= dim[0];
|
||||
cb->marker->pattern_corners[0][1] -= dim[1];
|
||||
for (a = 0; a < 4; a++) {
|
||||
cb->marker->pattern_corners[a][0] *= scale_x;
|
||||
cb->marker->pattern_corners[a][1] *= scale_y;
|
||||
}
|
||||
|
||||
cb->marker->pattern_corners[1][0] += dim[0];
|
||||
cb->marker->pattern_corners[1][1] -= dim[1];
|
||||
|
||||
cb->marker->pattern_corners[2][0] += dim[0];
|
||||
cb->marker->pattern_corners[2][1] += dim[1];
|
||||
|
||||
cb->marker->pattern_corners[3][0] -= dim[0];
|
||||
cb->marker->pattern_corners[3][1] += dim[1];
|
||||
|
||||
BKE_tracking_clamp_track(cb->track, CLAMP_PAT_DIM);
|
||||
BKE_tracking_clamp_marker(cb->marker, CLAMP_PAT_DIM);
|
||||
|
||||
ok = TRUE;
|
||||
}
|
||||
else if (event == B_MARKER_SEARCH_POS) {
|
||||
float delta[2], side[2];
|
||||
|
||||
sub_v2_v2v2(side, cb->track->search_max, cb->track->search_min);
|
||||
sub_v2_v2v2(side, cb->marker->search_max, cb->marker->search_min);
|
||||
mul_v2_fl(side, 0.5f);
|
||||
|
||||
delta[0] = cb->track_search_pos[0] / width;
|
||||
delta[1] = cb->track_search_pos[1] / height;
|
||||
delta[0] = cb->marker_search_pos[0] / width;
|
||||
delta[1] = cb->marker_search_pos[1] / height;
|
||||
|
||||
sub_v2_v2v2(cb->track->search_min, delta, side);
|
||||
add_v2_v2v2(cb->track->search_max, delta, side);
|
||||
sub_v2_v2v2(cb->marker->search_min, delta, side);
|
||||
add_v2_v2v2(cb->marker->search_max, delta, side);
|
||||
|
||||
BKE_tracking_clamp_track(cb->track, CLAMP_SEARCH_POS);
|
||||
BKE_tracking_clamp_marker(cb->marker, CLAMP_SEARCH_POS);
|
||||
|
||||
ok = TRUE;
|
||||
}
|
||||
else if (event == B_MARKER_SEARCH_DIM) {
|
||||
float dim[2], search_dim[2];
|
||||
|
||||
sub_v2_v2v2(search_dim, cb->track->search_max, cb->track->search_min);
|
||||
sub_v2_v2v2(search_dim, cb->marker->search_max, cb->marker->search_min);
|
||||
|
||||
dim[0] = cb->track_search[0] / width;
|
||||
dim[1] = cb->track_search[1] / height;
|
||||
dim[0] = cb->marker_search[0] / width;
|
||||
dim[1] = cb->marker_search[1] / height;
|
||||
|
||||
sub_v2_v2(dim, search_dim);
|
||||
mul_v2_fl(dim, 0.5f);
|
||||
|
||||
cb->track->search_min[0] -= dim[0];
|
||||
cb->track->search_min[1] -= dim[1];
|
||||
cb->marker->search_min[0] -= dim[0];
|
||||
cb->marker->search_min[1] -= dim[1];
|
||||
|
||||
cb->track->search_max[0] += dim[0];
|
||||
cb->track->search_max[1] += dim[1];
|
||||
cb->marker->search_max[0] += dim[0];
|
||||
cb->marker->search_max[1] += dim[1];
|
||||
|
||||
BKE_tracking_clamp_track(cb->track, CLAMP_SEARCH_DIM);
|
||||
BKE_tracking_clamp_marker(cb->marker, CLAMP_SEARCH_DIM);
|
||||
|
||||
ok = TRUE;
|
||||
}
|
||||
@@ -413,15 +408,15 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P
|
||||
BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
|
||||
|
||||
sub_v2_v2v2(pat_dim, pat_max, pat_min);
|
||||
sub_v2_v2v2(search_dim, track->search_max, track->search_min);
|
||||
sub_v2_v2v2(search_dim, marker->search_max, marker->search_min);
|
||||
|
||||
add_v2_v2v2(search_pos, track->search_max, track->search_min);
|
||||
add_v2_v2v2(search_pos, marker->search_max, marker->search_min);
|
||||
mul_v2_fl(search_pos, 0.5);
|
||||
|
||||
to_pixel_space(cb->marker_pos, marker->pos, width, height);
|
||||
to_pixel_space(cb->track_pat, pat_dim, width, height);
|
||||
to_pixel_space(cb->track_search, search_dim, width, height);
|
||||
to_pixel_space(cb->track_search_pos, search_pos, width, height);
|
||||
to_pixel_space(cb->marker_pat, pat_dim, width, height);
|
||||
to_pixel_space(cb->marker_search, search_dim, width, height);
|
||||
to_pixel_space(cb->marker_search_pos, search_pos, width, height);
|
||||
to_pixel_space(cb->track_offset, track->offset, width, height);
|
||||
|
||||
cb->marker_flag = marker->flag;
|
||||
@@ -457,19 +452,19 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P
|
||||
-10*height, 10.0*height, step, digits, "Y-offset to parenting point");
|
||||
|
||||
uiDefBut(block, LABEL, 0, "Pattern Area:", 0, 114, 300, 19, NULL, 0, 0, 0, 0, "");
|
||||
uiDefButF(block, NUM, B_MARKER_PAT_DIM, "Width:", 10, 95, 300, 19, &cb->track_pat[0], 3.0f,
|
||||
uiDefButF(block, NUM, B_MARKER_PAT_DIM, "Width:", 10, 95, 300, 19, &cb->marker_pat[0], 3.0f,
|
||||
10.0*width, step, digits, "Width of marker's pattern in screen coordinates");
|
||||
uiDefButF(block, NUM, B_MARKER_PAT_DIM, "Height:", 10, 76, 300, 19, &cb->track_pat[1], 3.0f,
|
||||
uiDefButF(block, NUM, B_MARKER_PAT_DIM, "Height:", 10, 76, 300, 19, &cb->marker_pat[1], 3.0f,
|
||||
10.0*height, step, digits, "Height of marker's pattern in screen coordinates");
|
||||
|
||||
uiDefBut(block, LABEL, 0, "Search Area:", 0, 57, 300, 19, NULL, 0, 0, 0, 0, "");
|
||||
uiDefButF(block, NUM, B_MARKER_SEARCH_POS, "X:", 10, 38, 145, 19, &cb->track_search_pos[0],
|
||||
uiDefButF(block, NUM, B_MARKER_SEARCH_POS, "X:", 10, 38, 145, 19, &cb->marker_search_pos[0],
|
||||
-width, width, step, digits, "X-position of search at frame relative to marker's position");
|
||||
uiDefButF(block, NUM, B_MARKER_SEARCH_POS, "Y:", 165, 38, 145, 19, &cb->track_search_pos[1],
|
||||
uiDefButF(block, NUM, B_MARKER_SEARCH_POS, "Y:", 165, 38, 145, 19, &cb->marker_search_pos[1],
|
||||
-height, height, step, digits, "X-position of search at frame relative to marker's position");
|
||||
uiDefButF(block, NUM, B_MARKER_SEARCH_DIM, "Width:", 10, 19, 300, 19, &cb->track_search[0], 3.0f,
|
||||
uiDefButF(block, NUM, B_MARKER_SEARCH_DIM, "Width:", 10, 19, 300, 19, &cb->marker_search[0], 3.0f,
|
||||
10.0*width, step, digits, "Width of marker's search in screen soordinates");
|
||||
uiDefButF(block, NUM, B_MARKER_SEARCH_DIM, "Height:", 10, 0, 300, 19, &cb->track_search[1], 3.0f,
|
||||
uiDefButF(block, NUM, B_MARKER_SEARCH_DIM, "Height:", 10, 0, 300, 19, &cb->marker_search[1], 3.0f,
|
||||
10.0*height, step, digits, "Height of marker's search in screen soordinates");
|
||||
|
||||
uiBlockEndAlign(block);
|
||||
|
||||
@@ -485,10 +485,10 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT
|
||||
((marker->flag & MARKER_DISABLED) == 0 || (sc->flag & SC_SHOW_MARKER_PATTERN) == 0);
|
||||
if (sc->flag & SC_SHOW_MARKER_SEARCH && show_search) {
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glVertex2f(track->search_min[0], track->search_min[1]);
|
||||
glVertex2f(track->search_max[0], track->search_min[1]);
|
||||
glVertex2f(track->search_max[0], track->search_max[1]);
|
||||
glVertex2f(track->search_min[0], track->search_max[1]);
|
||||
glVertex2f(marker->search_min[0], marker->search_min[1]);
|
||||
glVertex2f(marker->search_max[0], marker->search_min[1]);
|
||||
glVertex2f(marker->search_max[0], marker->search_max[1]);
|
||||
glVertex2f(marker->search_min[0], marker->search_max[1]);
|
||||
glEnd();
|
||||
}
|
||||
glPopMatrix();
|
||||
@@ -661,10 +661,10 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
|
||||
}
|
||||
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glVertex2f(track->search_min[0], track->search_min[1]);
|
||||
glVertex2f(track->search_max[0], track->search_min[1]);
|
||||
glVertex2f(track->search_max[0], track->search_max[1]);
|
||||
glVertex2f(track->search_min[0], track->search_max[1]);
|
||||
glVertex2f(marker->search_min[0], marker->search_min[1]);
|
||||
glVertex2f(marker->search_max[0], marker->search_min[1]);
|
||||
glVertex2f(marker->search_max[0], marker->search_max[1]);
|
||||
glVertex2f(marker->search_min[0], marker->search_max[1]);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
@@ -761,8 +761,8 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
|
||||
patdx = MIN2(dx * 2.0f / 3.0f, side / 6.0f);
|
||||
patdy = MIN2(dy * 2.0f / 3.0f, side * width / height / 6.0f);
|
||||
|
||||
searchdx = MIN2(dx, (track->search_max[0] - track->search_min[0]) / 6.0f);
|
||||
searchdy = MIN2(dy, (track->search_max[1] - track->search_min[1]) / 6.0f);
|
||||
searchdx = MIN2(dx, (marker->search_max[0] - marker->search_min[0]) / 6.0f);
|
||||
searchdy = MIN2(dy, (marker->search_max[1] - marker->search_min[1]) / 6.0f);
|
||||
|
||||
px[0] = 1.0f / sc->zoom / width / sc->scale;
|
||||
px[1] = 1.0f / sc->zoom / height / sc->scale;
|
||||
@@ -776,10 +776,10 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
|
||||
}
|
||||
|
||||
/* search offset square */
|
||||
draw_marker_slide_square(track->search_min[0], track->search_max[1], searchdx, searchdy, outline, px);
|
||||
draw_marker_slide_square(marker->search_min[0], marker->search_max[1], searchdx, searchdy, outline, px);
|
||||
|
||||
/* search re-sizing triangle */
|
||||
draw_marker_slide_triangle(track->search_max[0], track->search_min[1], searchdx, searchdy, outline, px);
|
||||
draw_marker_slide_triangle(marker->search_max[0], marker->search_min[1], searchdx, searchdy, outline, px);
|
||||
}
|
||||
|
||||
if ((sc->flag & SC_SHOW_MARKER_PATTERN) && ((track->pat_flag & SELECT) == sel || outline)) {
|
||||
@@ -848,8 +848,8 @@ static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTra
|
||||
if ((sc->flag & SC_SHOW_MARKER_SEARCH) &&
|
||||
((marker->flag & MARKER_DISABLED) == 0 || (sc->flag & SC_SHOW_MARKER_PATTERN) == 0))
|
||||
{
|
||||
dx = track->search_min[0];
|
||||
dy = track->search_min[1];
|
||||
dx = marker->search_min[0];
|
||||
dy = marker->search_min[1];
|
||||
}
|
||||
else if (sc->flag & SC_SHOW_MARKER_PATTERN) {
|
||||
float pat_min[2], pat_max[2];
|
||||
|
||||
@@ -310,8 +310,8 @@ static SlideMarkerData *create_slide_marker_data(SpaceClip *sc, MovieTrackingTra
|
||||
}
|
||||
}
|
||||
else if (area == TRACK_AREA_SEARCH) {
|
||||
data->min = track->search_min;
|
||||
data->max = track->search_max;
|
||||
data->min = marker->search_min;
|
||||
data->max = marker->search_max;
|
||||
}
|
||||
|
||||
if ((area == TRACK_AREA_SEARCH) ||
|
||||
@@ -338,7 +338,7 @@ static SlideMarkerData *create_slide_marker_data(SpaceClip *sc, MovieTrackingTra
|
||||
return data;
|
||||
}
|
||||
|
||||
static int mouse_on_corner(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker,
|
||||
static int mouse_on_corner(SpaceClip *sc, MovieTrackingMarker *marker,
|
||||
int area, float co[2], int corner, int width, int height)
|
||||
{
|
||||
int inside = 0;
|
||||
@@ -347,8 +347,8 @@ static int mouse_on_corner(SpaceClip *sc, MovieTrackingTrack *track, MovieTracki
|
||||
float crn[2], dx, dy, tdx, tdy;
|
||||
|
||||
if (area == TRACK_AREA_SEARCH) {
|
||||
copy_v2_v2(min, track->search_min);
|
||||
copy_v2_v2(max, track->search_max);
|
||||
copy_v2_v2(min, marker->search_min);
|
||||
copy_v2_v2(max, marker->search_max);
|
||||
}
|
||||
else {
|
||||
BKE_tracking_marker_pattern_minmax(marker, min, max);
|
||||
@@ -512,11 +512,11 @@ static void *slide_marker_customdata(bContext *C, wmEvent *event)
|
||||
}
|
||||
|
||||
if (sc->flag & SC_SHOW_MARKER_SEARCH) {
|
||||
if (mouse_on_corner(sc, track, marker, TRACK_AREA_SEARCH, co, 1, width, height)) {
|
||||
if (mouse_on_corner(sc, marker, TRACK_AREA_SEARCH, co, 1, width, height)) {
|
||||
customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_SEARCH, 0,
|
||||
SLIDE_ACTION_OFFSET, width, height);
|
||||
}
|
||||
else if (mouse_on_corner(sc, track, marker, TRACK_AREA_SEARCH, co, 0, width, height)) {
|
||||
else if (mouse_on_corner(sc, marker, TRACK_AREA_SEARCH, co, 0, width, height)) {
|
||||
customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_SEARCH, 0,
|
||||
SLIDE_ACTION_SIZE, width, height);
|
||||
}
|
||||
@@ -534,12 +534,12 @@ static void *slide_marker_customdata(bContext *C, wmEvent *event)
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (mouse_on_corner(sc, track, marker, TRACK_AREA_PAT, co, 1, width, height)) {
|
||||
if (mouse_on_corner(sc, marker, TRACK_AREA_PAT, co, 1, width, height)) {
|
||||
customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_PAT, 0,
|
||||
SLIDE_ACTION_OFFSET, width, height);
|
||||
}
|
||||
|
||||
if (!customdata && mouse_on_corner(sc, track, marker, TRACK_AREA_PAT, co, 0, width, height)) {
|
||||
if (!customdata && mouse_on_corner(sc, marker, TRACK_AREA_PAT, co, 0, width, height)) {
|
||||
customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_PAT, 0,
|
||||
SLIDE_ACTION_SIZE, width, height);
|
||||
}
|
||||
@@ -698,9 +698,9 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event)
|
||||
}
|
||||
|
||||
if (data->area == TRACK_AREA_SEARCH)
|
||||
BKE_tracking_clamp_track(data->track, CLAMP_SEARCH_DIM);
|
||||
BKE_tracking_clamp_marker(data->marker, CLAMP_SEARCH_DIM);
|
||||
else
|
||||
BKE_tracking_clamp_track(data->track, CLAMP_PAT_DIM);
|
||||
BKE_tracking_clamp_marker(data->marker, CLAMP_PAT_DIM);
|
||||
}
|
||||
else if (data->action == SLIDE_ACTION_OFFSET) {
|
||||
float d[2] = {dx, dy};
|
||||
@@ -719,7 +719,7 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event)
|
||||
}
|
||||
|
||||
if (data->area == TRACK_AREA_SEARCH)
|
||||
BKE_tracking_clamp_track(data->track, CLAMP_SEARCH_POS);
|
||||
BKE_tracking_clamp_marker(data->marker, CLAMP_SEARCH_POS);
|
||||
}
|
||||
else if (data->action == SLIDE_ACTION_POS) {
|
||||
if (data->scale) {
|
||||
@@ -750,7 +750,7 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event)
|
||||
}
|
||||
|
||||
/* currently only patterns are allowed to have such combination of event and data */
|
||||
BKE_tracking_clamp_track(data->track, CLAMP_PAT_DIM);
|
||||
BKE_tracking_clamp_marker(data->marker, CLAMP_PAT_DIM);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -846,16 +846,16 @@ static int track_mouse_area(SpaceClip *sc, float co[2], MovieTrackingTrack *trac
|
||||
|
||||
BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
|
||||
|
||||
epsx = MIN4(pat_min[0] - track->search_min[0], track->search_max[0] - pat_max[0],
|
||||
epsx = MIN4(pat_min[0] - marker->search_min[0], marker->search_max[0] - pat_max[0],
|
||||
fabsf(pat_min[0]), fabsf(pat_max[0])) / 2;
|
||||
epsy = MIN4(pat_min[1] - track->search_min[1], track->search_max[1] - pat_max[1],
|
||||
epsy = MIN4(pat_min[1] - marker->search_min[1], marker->search_max[1] - pat_max[1],
|
||||
fabsf(pat_min[1]), fabsf(pat_max[1])) / 2;
|
||||
|
||||
epsx = MAX2(epsx, 2.0f / width);
|
||||
epsy = MAX2(epsy, 2.0f / height);
|
||||
|
||||
if (sc->flag & SC_SHOW_MARKER_SEARCH) {
|
||||
if (mouse_on_rect(co, marker->pos, track->search_min, track->search_max, epsx, epsy))
|
||||
if (mouse_on_rect(co, marker->pos, marker->search_min, marker->search_max, epsx, epsy))
|
||||
return TRACK_AREA_SEARCH;
|
||||
}
|
||||
|
||||
@@ -929,7 +929,7 @@ static MovieTrackingTrack *find_nearest_track(SpaceClip *sc, ListBase *tracksbas
|
||||
|
||||
/* distance to search boundbox */
|
||||
if (sc->flag & SC_SHOW_MARKER_SEARCH && TRACK_VIEW_SELECTED(sc, cur))
|
||||
d3 = dist_to_rect(co, marker->pos, cur->search_min, cur->search_max);
|
||||
d3 = dist_to_rect(co, marker->pos, marker->search_min, marker->search_max);
|
||||
|
||||
/* choose minimal distance. useful for cases of overlapped markers. */
|
||||
dist = MIN3(d1, d2, d3);
|
||||
|
||||
@@ -5456,7 +5456,7 @@ static void trackToTransData(SpaceClip *sc, TransData *td, TransData2D *td2d,
|
||||
MovieTrackingMarker *marker = BKE_tracking_ensure_marker(track, sc->user.framenr);
|
||||
|
||||
tdt->flag = marker->flag;
|
||||
marker->flag &= ~(MARKER_DISABLED|MARKER_TRACKED);
|
||||
marker->flag &= ~(MARKER_DISABLED | MARKER_TRACKED);
|
||||
|
||||
markerToTransDataInit(td++, td2d++, tdt++, track, marker, TRACK_AREA_POINT,
|
||||
track->offset, marker->pos, track->offset, aspx, aspy);
|
||||
@@ -5477,10 +5477,10 @@ static void trackToTransData(SpaceClip *sc, TransData *td, TransData2D *td2d,
|
||||
|
||||
if (track->search_flag & SELECT) {
|
||||
markerToTransDataInit(td++, td2d++, tdt++, track, marker, TRACK_AREA_SEARCH,
|
||||
track->search_min, marker->pos, NULL, aspx, aspy);
|
||||
marker->search_min, marker->pos, NULL, aspx, aspy);
|
||||
|
||||
markerToTransDataInit(td++, td2d++, tdt++, track, marker, TRACK_AREA_SEARCH,
|
||||
track->search_max, marker->pos, NULL, aspx, aspy);
|
||||
marker->search_max, marker->pos, NULL, aspx, aspy);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5556,18 +5556,16 @@ static void createTransTrackingTracksData(bContext *C, TransInfo *t)
|
||||
td2d++;
|
||||
tdt++;
|
||||
|
||||
if ((marker->flag & MARKER_DISABLED) == 0) {
|
||||
if (track->flag & SELECT) {
|
||||
td++;
|
||||
td2d++;
|
||||
tdt++;
|
||||
}
|
||||
if (track->flag & SELECT) {
|
||||
td++;
|
||||
td2d++;
|
||||
tdt++;
|
||||
}
|
||||
|
||||
if (track->pat_flag & SELECT) {
|
||||
td += 4;
|
||||
td2d += 4;
|
||||
tdt += 4;
|
||||
}
|
||||
if (track->pat_flag & SELECT) {
|
||||
td += 4;
|
||||
td2d += 4;
|
||||
tdt += 4;
|
||||
}
|
||||
|
||||
if (track->search_flag & SELECT) {
|
||||
|
||||
@@ -642,27 +642,30 @@ static void recalcData_spaceclip(TransInfo *t)
|
||||
MovieClip *clip = ED_space_clip(sc);
|
||||
ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking);
|
||||
MovieTrackingTrack *track;
|
||||
int framenr = sc->user.framenr;
|
||||
|
||||
flushTransTracking(t);
|
||||
|
||||
track = tracksbase->first;
|
||||
while (track) {
|
||||
if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED)==0) {
|
||||
MovieTrackingMarker *marker = BKE_tracking_get_marker(track, framenr);
|
||||
|
||||
if (t->mode == TFM_TRANSLATION) {
|
||||
if (TRACK_AREA_SELECTED(track, TRACK_AREA_PAT))
|
||||
BKE_tracking_clamp_track(track, CLAMP_PAT_POS);
|
||||
BKE_tracking_clamp_marker(marker, CLAMP_PAT_POS);
|
||||
if (TRACK_AREA_SELECTED(track, TRACK_AREA_SEARCH))
|
||||
BKE_tracking_clamp_track(track, CLAMP_SEARCH_POS);
|
||||
BKE_tracking_clamp_marker(marker, CLAMP_SEARCH_POS);
|
||||
}
|
||||
else if (t->mode == TFM_RESIZE) {
|
||||
if (TRACK_AREA_SELECTED(track, TRACK_AREA_PAT))
|
||||
BKE_tracking_clamp_track(track, CLAMP_PAT_DIM);
|
||||
BKE_tracking_clamp_marker(marker, CLAMP_PAT_DIM);
|
||||
if (TRACK_AREA_SELECTED(track, TRACK_AREA_SEARCH))
|
||||
BKE_tracking_clamp_track(track, CLAMP_SEARCH_DIM);
|
||||
BKE_tracking_clamp_marker(marker, CLAMP_SEARCH_DIM);
|
||||
}
|
||||
else if (t->mode == TFM_ROTATION) {
|
||||
if (TRACK_AREA_SELECTED(track, TRACK_AREA_PAT))
|
||||
BKE_tracking_clamp_track(track, CLAMP_PAT_DIM);
|
||||
BKE_tracking_clamp_marker(marker, CLAMP_PAT_POS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -81,11 +81,16 @@ typedef struct MovieTrackingMarker {
|
||||
* | | |
|
||||
* | (0) --- (1)
|
||||
* +-------------> X
|
||||
*
|
||||
* the coordinates are stored relative to pos.
|
||||
*
|
||||
* the coordinates are stored relative to pos.
|
||||
*/
|
||||
float pattern_corners[4][2];
|
||||
|
||||
/* positions of left-bottom and right-top corners of search area (in unified 0..1 units,
|
||||
* relative to marker->pos
|
||||
*/
|
||||
float search_min[2], search_max[2];
|
||||
|
||||
int framenr; /* number of frame marker is associated with */
|
||||
int flag; /* Marker's flag (alive, ...) */
|
||||
} MovieTrackingMarker;
|
||||
@@ -97,11 +102,17 @@ typedef struct MovieTrackingTrack {
|
||||
|
||||
/* ** setings ** */
|
||||
|
||||
/* positions of left-bottom and right-top corners of pattern (in unified 0..1 units, relative to marker->pos) */
|
||||
float pat_min[2], pat_max[2] DNA_DEPRECATED;
|
||||
/* positions of left-bottom and right-top corners of pattern (in unified 0..1 units,
|
||||
* relative to marker->pos)
|
||||
* moved to marker's corners since planar tracking implementation
|
||||
*/
|
||||
float pat_min[2] DNA_DEPRECATED, pat_max[2] DNA_DEPRECATED;
|
||||
|
||||
/* positions of left-bottom and right-top corners of search area (in unified 0..1 units, relative to marker->pos */
|
||||
float search_min[2], search_max[2];
|
||||
/* positions of left-bottom and right-top corners of search area (in unified 0..1 units,
|
||||
* relative to marker->pos
|
||||
* moved to marker since affine tracking implementation
|
||||
*/
|
||||
float search_min[2] DNA_DEPRECATED, search_max[2] DNA_DEPRECATED;
|
||||
|
||||
float offset[2]; /* offset to "parenting" point */
|
||||
|
||||
|
||||
@@ -195,13 +195,6 @@ static void rna_trackingTrack_select_set(PointerRNA *ptr, int value)
|
||||
}
|
||||
}
|
||||
|
||||
static void rna_tracking_trackerSearch_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
|
||||
{
|
||||
MovieTrackingTrack *track = (MovieTrackingTrack *)ptr->data;
|
||||
|
||||
BKE_tracking_clamp_track(track, CLAMP_SEARCH_DIM);
|
||||
}
|
||||
|
||||
static char *rna_trackingCamera_path(PointerRNA *UNUSED(ptr))
|
||||
{
|
||||
return BLI_sprintfN("tracking.camera");
|
||||
@@ -361,6 +354,20 @@ static void rna_trackingMarker_frame_set(PointerRNA *ptr, int value)
|
||||
}
|
||||
}
|
||||
|
||||
static void rna_tracking_markerPattern_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
|
||||
{
|
||||
MovieTrackingMarker *marker = (MovieTrackingMarker *)ptr->data;
|
||||
|
||||
BKE_tracking_clamp_marker(marker, CLAMP_PAT_DIM);
|
||||
}
|
||||
|
||||
static void rna_tracking_markerSearch_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
|
||||
{
|
||||
MovieTrackingMarker *marker = (MovieTrackingMarker *)ptr->data;
|
||||
|
||||
BKE_tracking_clamp_marker(marker, CLAMP_SEARCH_DIM);
|
||||
}
|
||||
|
||||
/* API */
|
||||
|
||||
static void add_tracks_to_base(MovieClip *clip, MovieTracking *tracking, ListBase *tracksbase, int frame, int number)
|
||||
@@ -467,6 +474,7 @@ static EnumPropertyItem pattern_match_items[] = {
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
|
||||
static int rna_matrix_dimsize_4x4[] = {4, 4};
|
||||
static int rna_matrix_dimsize_4x2[] = {4, 2};
|
||||
|
||||
static void rna_def_trackingSettings(BlenderRNA *brna)
|
||||
{
|
||||
@@ -797,6 +805,38 @@ static void rna_def_trackingMarker(BlenderRNA *brna)
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", MARKER_DISABLED);
|
||||
RNA_def_property_ui_text(prop, "Mode", "Is marker muted for current frame");
|
||||
RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
|
||||
|
||||
/* pattern */
|
||||
prop = RNA_def_property(srna, "pattern_corners", PROP_FLOAT, PROP_MATRIX);
|
||||
RNA_def_property_float_sdna(prop, NULL, "pattern_corners");
|
||||
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x2);
|
||||
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
|
||||
RNA_def_property_ui_text(prop, "Pattern Corners",
|
||||
"Array of coordinates which represents patter's corners in "
|
||||
" normalized coordinates relative to marker position");
|
||||
RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, "rna_tracking_markerPattern_update");
|
||||
|
||||
/* search */
|
||||
prop = RNA_def_property(srna, "search_min", PROP_FLOAT, PROP_TRANSLATION);
|
||||
RNA_def_property_array(prop, 2);
|
||||
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
|
||||
RNA_def_property_float_sdna(prop, NULL, "search_min");
|
||||
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
RNA_def_property_ui_text(prop, "Search Min",
|
||||
"Left-bottom corner of search area in normalized coordinates relative "
|
||||
"to marker position");
|
||||
RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, "rna_tracking_markerSearch_update");
|
||||
|
||||
prop = RNA_def_property(srna, "search_max", PROP_FLOAT, PROP_TRANSLATION);
|
||||
RNA_def_property_array(prop, 2);
|
||||
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
|
||||
RNA_def_property_float_sdna(prop, NULL, "search_max");
|
||||
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
RNA_def_property_ui_text(prop, "Search Max",
|
||||
"Right-bottom corner of search area in normalized coordinates relative "
|
||||
"to marker position");
|
||||
RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, "rna_tracking_markerSearch_update");
|
||||
}
|
||||
|
||||
static void rna_def_trackingMarkers(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
@@ -857,30 +897,6 @@ static void rna_def_trackingTrack(BlenderRNA *brna)
|
||||
RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, NULL);
|
||||
RNA_def_struct_name_property(srna, prop);
|
||||
|
||||
/* Pattern */
|
||||
/* XXX The four pattern corners are not exported to rna yet */
|
||||
|
||||
/* Search */
|
||||
prop = RNA_def_property(srna, "search_min", PROP_FLOAT, PROP_TRANSLATION);
|
||||
RNA_def_property_array(prop, 2);
|
||||
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
|
||||
RNA_def_property_float_sdna(prop, NULL, "search_min");
|
||||
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
RNA_def_property_ui_text(prop, "Search Min",
|
||||
"Left-bottom corner of search area in normalized coordinates relative "
|
||||
"to marker position");
|
||||
RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, "rna_tracking_trackerSearch_update");
|
||||
|
||||
prop = RNA_def_property(srna, "search_max", PROP_FLOAT, PROP_TRANSLATION);
|
||||
RNA_def_property_array(prop, 2);
|
||||
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
|
||||
RNA_def_property_float_sdna(prop, NULL, "search_max");
|
||||
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
RNA_def_property_ui_text(prop, "Search Max",
|
||||
"Right-bottom corner of search area in normalized coordinates relative "
|
||||
"to marker position");
|
||||
RNA_def_property_update(prop, NC_MOVIECLIP|NA_EDITED, "rna_tracking_trackerSearch_update");
|
||||
|
||||
/* limit frames */
|
||||
prop = RNA_def_property(srna, "frames_limit", PROP_INT, PROP_NONE);
|
||||
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
|
||||
Reference in New Issue
Block a user