Ignore track's disabled channels when requesting for pattern used in keying screen...
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 1 Jun 2012 14:42:55 +0000 (14:42 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 1 Jun 2012 14:42:55 +0000 (14:42 +0000)
source/blender/blenkernel/BKE_tracking.h
source/blender/blenkernel/intern/tracking.c
source/blender/compositor/operations/COM_KeyingScreenOperation.cpp
source/blender/nodes/composite/nodes/node_composite_keyingscreen.c

index 40a023101ba97d98c154622b53b8fd464e409684..e2f17a1dd18e3095395d7bfc43a5971d9526e448 100644 (file)
@@ -74,6 +74,8 @@ void BKE_tracking_free(struct MovieTracking *tracking);
 struct ImBuf *BKE_tracking_get_pattern_imbuf(struct ImBuf *ibuf, struct MovieTrackingTrack *track,
                                              struct MovieTrackingMarker *marker, int margin, int anchored,
                                              float pos[2], int origin[2]);
+struct ImBuf *BKE_tracking_get_pattern_color_imbuf(struct ImBuf *ibuf, struct MovieTrackingTrack *track,
+                                                   struct MovieTrackingMarker *marker, int anchored);
 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,
index c51601202ff3ce0d3e1d47d20c397c2825a9be09..8f181311a6f219b94a2f985e25320a778ed999c0 100644 (file)
@@ -1177,7 +1177,8 @@ static void disable_imbuf_channels(ImBuf *ibuf, MovieTrackingTrack *track, int g
 }
 
 static ImBuf *get_area_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTrackingMarker *marker,
-                             float min[2], float max[2], int margin, int anchored, float pos[2], int origin[2])
+                             float min[2], float max[2], int margin, int anchored,
+                                                        int grayscale, float pos[2], int origin[2])
 {
        ImBuf *tmpibuf;
        int x, y;
@@ -1223,12 +1224,14 @@ static ImBuf *get_area_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTracki
                origin[1] = y1 - margin;
        }
 
-       if ((track->flag & TRACK_PREVIEW_GRAYSCALE) ||
-          (track->flag & TRACK_DISABLE_RED)       ||
-          (track->flag & TRACK_DISABLE_GREEN)     ||
-          (track->flag & TRACK_DISABLE_BLUE))
-       {
-               disable_imbuf_channels(tmpibuf, track, TRUE /* grayscale */);
+       if (grayscale) {
+               if ((track->flag & TRACK_PREVIEW_GRAYSCALE) ||
+                   (track->flag & TRACK_DISABLE_RED)       ||
+                   (track->flag & TRACK_DISABLE_GREEN)     ||
+                   (track->flag & TRACK_DISABLE_BLUE))
+               {
+                       disable_imbuf_channels(tmpibuf, track, TRUE /* grayscale */);
+               }
        }
 
        return tmpibuf;
@@ -1244,7 +1247,18 @@ ImBuf *BKE_tracking_get_pattern_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, Mo
         */
        BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
 
-       return get_area_imbuf(ibuf, track, marker, pat_min, pat_max, margin, anchored, pos, origin);
+       return get_area_imbuf(ibuf, track, marker, pat_min, pat_max, margin, anchored, TRUE, pos, origin);
+}
+
+ImBuf *BKE_tracking_get_pattern_color_imbuf(ImBuf *ibuf, MovieTrackingTrack *track,
+                                            MovieTrackingMarker *marker, int anchored)
+{
+       float pat_min[2], pat_max[2];
+
+       /* see comment above */
+       BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max);
+
+       return get_area_imbuf(ibuf, track, marker, pat_min, pat_max, 0, anchored, FALSE, NULL, NULL);
 }
 
 ImBuf *BKE_tracking_get_search_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTrackingMarker *marker)
index f9c9216b75a40b9af57390c60af6307402e448c8..4f6abdcbc228541059720e527e25e996b3708440 100644 (file)
@@ -116,7 +116,7 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri
        while (track) {
                VoronoiSite *site = &sites[i];
                MovieTrackingMarker *marker = BKE_tracking_get_marker(track, framenumber);
-               ImBuf *pattern_ibuf = BKE_tracking_get_pattern_imbuf(ibuf, track, marker, 0, TRUE, NULL, NULL);
+               ImBuf *pattern_ibuf = BKE_tracking_get_pattern_color_imbuf(ibuf, track, marker, TRUE);
                int j;
 
                zero_v3(site->color);
index 5cbaf4ae2ba663df17c0536a8fda627b6e66cfda..b7ce621a9e12c613ab7b7930965341cfe0048dcb 100644 (file)
@@ -91,7 +91,7 @@ static void compute_gradient_screen(RenderData *rd, NodeKeyingScreenData *keying
        while (track) {
                VoronoiSite *site = &sites[i];
                MovieTrackingMarker *marker = BKE_tracking_get_marker(track, rd->cfra);
-               ImBuf *pattern_ibuf = BKE_tracking_get_pattern_imbuf(ibuf, track, marker, 0, FALSE, NULL, NULL);
+               ImBuf *pattern_ibuf = BKE_tracking_get_pattern_color_imbuf(ibuf, track, marker, TRUE);
                int j;
 
                zero_v3(site->color);