Merging r47507 through r47534 from trunk into soc-2011-tomato
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 6 Jun 2012 19:11:06 +0000 (19:11 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 6 Jun 2012 19:11:06 +0000 (19:11 +0000)
1  2 
release/scripts/startup/bl_ui/space_clip.py
source/blender/blenkernel/intern/movieclip.c
source/blender/blenkernel/intern/tracking.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/space_clip/clip_draw.c
source/blender/editors/space_clip/space_clip.c
source/blender/editors/space_clip/tracking_ops.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform_conversions.c
source/blender/makesrna/intern/rna_movieclip.c

@@@ -1627,8 -1400,8 +1629,8 @@@ void BKE_tracking_sync_user(MovieClipUs
  
  int BKE_tracking_next(MovieTrackingContext *context)
  {
 -      ImBuf *ibuf_new;
 +      ImBuf *destination_ibuf;
-       int curfra = context->user.framenr;
+       int curfra =  BKE_movieclip_remap_scene_to_clip_frame(context->clip, context->user.framenr);
        int a, ok = FALSE, map_size;
  
        map_size = tracks_map_size(context->tracks_map);
@@@ -7646,69 -7648,40 +7646,80 @@@ static void do_versions(FileData *fd, L
                                }
                        }
                }
+               {
+                       bScreen *sc;
+                       for (sc = main->screen.first; sc; sc = sc->id.next) {
+                               ScrArea *sa;
+                               for (sa = sc->areabase.first; sa; sa = sa->next) {
+                                       SpaceLink *sl;
+                                       for (sl = sa->spacedata.first; sl; sl = sl->next) {
+                                               if (sl->spacetype == SPACE_CLIP) {
+                                                       SpaceClip *sclip = (SpaceClip *)sl;
+                                                       if (sclip->around == 0) {
+                                                               sclip->around = V3D_CENTROID;
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               }
+               {
+                       MovieClip *clip;
+                       for (clip = main->movieclip.first; clip; clip = clip->id.next) {
+                               clip->start_frame = 1;
+                       }
+               }
        }
  
-       {
-               bScreen *sc;
-               for (sc = main->screen.first; sc; sc = sc->id.next) {
-                       ScrArea *sa;
-                       for (sa = sc->areabase.first; sa; sa = sa->next) {
-                               SpaceLink *sl;
-                               for (sl = sa->spacedata.first; sl; sl = sl->next) {
-                                       if (sl->spacetype == SPACE_CLIP) {
-                                               SpaceClip *sclip = (SpaceClip *)sl;
-                                               if (sclip->around == 0) {
-                                                       sclip->around = V3D_CENTROID;
-                                               }
-                                       }
-                               }
-                       }
-               }
-       }
 +      {
 +              MovieClip *clip;
 +
 +              for (clip = main->movieclip.first; clip; clip = clip->id.next) {
 +                      MovieTrackingTrack *track;
 +
 +                      track = clip->tracking.tracks.first;
 +                      while (track) {
 +                              int i;
 +
 +                              for (i = 0; i < track->markersnr; i++) {
 +                                      MovieTrackingMarker *marker = &track->markers[i];
 +
 +                                      if (is_zero_v2(marker->pattern_corners[0]) && is_zero_v2(marker->pattern_corners[1]) &&
 +                                          is_zero_v2(marker->pattern_corners[3]) && is_zero_v2(marker->pattern_corners[3]))
 +                                      {
 +                                              marker->pattern_corners[0][0] = track->pat_min[0];
 +                                              marker->pattern_corners[0][1] = track->pat_min[1];
 +
 +                                              marker->pattern_corners[1][0] = track->pat_max[0];
 +                                              marker->pattern_corners[1][1] = track->pat_min[1];
 +
 +                                              marker->pattern_corners[2][0] = track->pat_max[0];
 +                                              marker->pattern_corners[2][1] = track->pat_max[1];
 +
 +                                              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;
 +                      }
 +              }
 +      }
 +
+       /* WATCH IT!!!: pointers from libdata have not been converted yet here! */
+       /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */
  
        /* don't forget to set version number in blender.c! */
  }
@@@ -392,12 -392,9 +392,12 @@@ static void clip_listener(ScrArea *sa, 
                                        break;
                        }
                        break;
-                case NC_SCREEN:
+               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:
@@@ -268,12 -267,12 +269,13 @@@ typedef struct 
  } SlideMarkerData;
  
  static SlideMarkerData *create_slide_marker_data(SpaceClip *sc, MovieTrackingTrack *track,
 -                      MovieTrackingMarker *marker, wmEvent *event, int area, int action, int width, int height)
 +                                                 MovieTrackingMarker *marker, wmEvent *event,
 +                                                                                               int area, int corner, int action, int width, int height)
  {
        SlideMarkerData *data = MEM_callocN(sizeof(SlideMarkerData), "slide marker data");
+       int framenr = ED_space_clip_clip_framenr(sc);
  
-       marker = BKE_tracking_ensure_marker(track, sc->user.framenr);
+       marker = BKE_tracking_ensure_marker(track, framenr);
  
        data->area = area;
        data->action = action;
@@@ -502,24 -420,21 +505,24 @@@ static void *slide_marker_customdata(bC
        track = tracksbase->first;
        while (track) {
                if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) {
-                       MovieTrackingMarker *marker = BKE_tracking_get_marker(track, sc->user.framenr);
+                       MovieTrackingMarker *marker = BKE_tracking_get_marker(track, framenr);
  
                        if ((marker->flag & MARKER_DISABLED) == 0) {
 -                              if (!customdata)
 +                              if (!customdata) {
                                        if (mouse_on_offset(sc, track, marker, co, width, height))
 -                                              customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_POINT,
 +                                              customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_POINT, 0,
                                                                                      SLIDE_ACTION_POS, width, height);
 +                              }
  
                                if (sc->flag & SC_SHOW_MARKER_SEARCH) {
 -                                      if (mouse_on_corner(sc, track, marker, TRACK_AREA_SEARCH, co, 1, width, height))
 -                                              customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_SEARCH,
 +                                      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))
 -                                              customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_SEARCH,
 +                                      }
 +                                      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);
 +                                      }
                                }
  
                                if (!customdata && (sc->flag & SC_SHOW_MARKER_PATTERN)) {
@@@ -828,17 -672,10 +831,18 @@@ static int mouse_on_rect(float co[2], f
               mouse_on_side(co, pos[0] + max[0], pos[1] + min[1], pos[0] + max[0], pos[1] + max[1], epsx, epsy);
  }
  
 +static int mouse_on_crns(float co[2], float pos[2], float crns[4][2], float epsx, float epsy)
 +{
 +      float dist = dist_to_crns(co, pos, crns);
 +
 +      return dist < MAX2(epsx, epsy);
 +}
 +
  static int track_mouse_area(SpaceClip *sc, float co[2], MovieTrackingTrack *track)
  {
-       MovieTrackingMarker *marker = BKE_tracking_get_marker(track, sc->user.framenr);
+       int framenr = ED_space_clip_clip_framenr(sc);
+       MovieTrackingMarker *marker = BKE_tracking_get_marker(track, framenr);
 +      float pat_min[2], pat_max[2];
        float epsx, epsy;
        int width, height;
  
@@@ -5476,28 -5472,22 +5476,29 @@@ static void markerToTransDataInit(Trans
  }
  
  static void trackToTransData(SpaceClip *sc, TransData *td, TransData2D *td2d,
 -                             TransDataTracking *tdt, MovieTrackingTrack *track)
 +                             TransDataTracking *tdt, MovieTrackingTrack *track, float aspx, float aspy)
  {
-       MovieTrackingMarker *marker = BKE_tracking_ensure_marker(track, sc->user.framenr);
+       int framenr = ED_space_clip_clip_framenr(sc);
+       MovieTrackingMarker *marker = BKE_tracking_ensure_marker(track, framenr);
  
        tdt->flag = marker->flag;
 -      marker->flag &= ~(MARKER_DISABLED|MARKER_TRACKED);
 +      marker->flag &= ~(MARKER_DISABLED | MARKER_TRACKED);
  
 -      markerToTransDataInit(td++, td2d++, tdt++, track, TRACK_AREA_POINT, track->offset, marker->pos, track->offset);
 +      markerToTransDataInit(td++, td2d++, tdt++, track, marker, TRACK_AREA_POINT,
 +                            track->offset, marker->pos, track->offset, aspx, aspy);
  
 -      if (track->flag & SELECT)
 -              markerToTransDataInit(td++, td2d++, tdt++, track, TRACK_AREA_POINT, marker->pos, NULL, NULL);
 +      if (track->flag & SELECT) {
 +              markerToTransDataInit(td++, td2d++, tdt++, track, marker, TRACK_AREA_POINT,
 +                                    marker->pos, NULL, NULL, aspx, aspy);
 +      }
  
        if (track->pat_flag & SELECT) {
 -              markerToTransDataInit(td++, td2d++, tdt++, track, TRACK_AREA_PAT, track->pat_min, marker->pos, NULL);
 -              markerToTransDataInit(td++, td2d++, tdt++, track, TRACK_AREA_PAT, track->pat_max, marker->pos, NULL);
 +              int a;
 +
 +              for (a = 0; a < 4; a++) {
 +                      markerToTransDataInit(td++, td2d++, tdt++, track, marker, TRACK_AREA_PAT,
 +                                            marker->pattern_corners[a], marker->pos, NULL, aspx, aspy);
 +              }
        }
  
        if (track->search_flag & SELECT) {
@@@ -5531,8 -5518,7 +5532,8 @@@ static void createTransTrackingTracksDa
        MovieTrackingTrack *track;
        MovieTrackingMarker *marker;
        TransDataTracking *tdt;
-       int framenr = sc->user.framenr;
+       int framenr = ED_space_clip_clip_framenr(sc);
 +      float aspx, aspy;
  
        /* count */
        t->total = 0;
@@@ -284,15 -284,7 +284,8 @@@ static void rna_def_movieclip(BlenderRN
        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);
  
-       /* use custom offset */
-       prop = RNA_def_property(srna, "use_custom_start_frame", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_sdna(prop, NULL, "flag", MCLIP_CUSTOM_START_FRAME);
-       RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
-       RNA_def_property_ui_text(prop, "Custom Start Frame", "Use custom first frame offset instead of automatic frame number");
-       RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClip_reload_update");
        /* frame offset */
        prop = RNA_def_property(srna, "start_frame", PROP_INT, PROP_NONE);
        RNA_def_property_int_sdna(prop, NULL, "start_frame");