OpenGl immediate mode: clip_draw.c and clip_graph_draw.c fixes
authorLuca Rood <dev@lucarood.com>
Thu, 23 Feb 2017 16:35:16 +0000 (13:35 -0300)
committerLuca Rood <dev@lucarood.com>
Thu, 23 Feb 2017 19:12:08 +0000 (16:12 -0300)
Fixed little typo in clip_draw.c and special case assert in
clip_graph_draw.c (track segments with single point).

Part of T49043

source/blender/editors/space_clip/clip_draw.c
source/blender/editors/space_clip/clip_graph_draw.c
source/blender/editors/space_clip/clip_intern.h
source/blender/editors/space_clip/clip_utils.c

index 670ed2f29ebc294a744a6042a3f93f52eb0fc3cb..6c1dc8c73353183c54584bc8ce7a4e8505f6af30 100644 (file)
@@ -889,7 +889,7 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo
                float tilt_ctrl[2];
 
                if (!outline) {
-                       immUniformColor3fv((track->search_flag & SELECT) ? scol : col);
+                       immUniformColor3fv((track->pat_flag & SELECT) ? scol : col);
                }
 
                /* pattern's corners sliding squares */
index b373358b49c5a41f091c7f18af4418185e2a1525..7afa2ae814569572879b3c4c676608d0d8a02cc2 100644 (file)
@@ -72,7 +72,7 @@ static void tracking_segment_point_cb(void *userdata, MovieTrackingTrack *UNUSED
        immVertex2f(data->pos, scene_framenr, val);
 }
 
-static void tracking_segment_start_cb(void *userdata, MovieTrackingTrack *track, int coord)
+static void tracking_segment_start_cb(void *userdata, MovieTrackingTrack *track, int coord, bool is_point)
 {
        TrackMotionCurveUserData *data = (TrackMotionCurveUserData *) userdata;
        float col[4] = {0.0f, 0.0f, 0.0f, 0.0f};
@@ -90,8 +90,13 @@ static void tracking_segment_start_cb(void *userdata, MovieTrackingTrack *track,
 
        immUniformColor4fv(col);
 
-       /* Graph can be composed of smaller segments, if any marker is disabled */
-       immBeginAtMost(GL_LINE_STRIP, track->markersnr);
+       if (is_point) {
+               immBeginAtMost(GL_POINTS, 1);
+       }
+       else {
+               /* Graph can be composed of smaller segments, if any marker is disabled */
+               immBeginAtMost(GL_LINE_STRIP, track->markersnr);
+       }
 }
 
 static void tracking_segment_end_cb(void *UNUSED(userdata), int UNUSED(coord))
@@ -220,7 +225,7 @@ static void tracking_error_segment_point_cb(void *userdata,
        }
 }
 
-static void tracking_error_segment_start_cb(void *userdata, MovieTrackingTrack *track, int coord)
+static void tracking_error_segment_start_cb(void *userdata, MovieTrackingTrack *track, int coord, bool is_point)
 {
        if (coord == 1) {
                TrackErrorCurveUserData *data = (TrackErrorCurveUserData *) userdata;
@@ -237,8 +242,13 @@ static void tracking_error_segment_start_cb(void *userdata, MovieTrackingTrack *
 
                immUniformColor4fv(col);
 
-               /* Graph can be composed of smaller segments, if any marker is disabled */
-               immBeginAtMost(GL_LINE_STRIP, track->markersnr);
+               if (is_point) { /* This probably never happens here, but just in case... */
+                       immBeginAtMost(GL_POINTS, 1);
+               }
+               else {
+                       /* Graph can be composed of smaller segments, if any marker is disabled */
+                       immBeginAtMost(GL_LINE_STRIP, track->markersnr);
+               }
        }
 }
 
@@ -323,11 +333,12 @@ void clip_draw_graph(SpaceClip *sc, ARegion *ar, Scene *scene)
        UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL);
        UI_view2d_grid_free(grid);
 
-       unsigned int pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 2, KEEP_FLOAT);
+       if (clip) {
+               unsigned int pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 2, KEEP_FLOAT);
+               immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 
-       immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
+               glPointSize(3.0f);
 
-       if (clip) {
                if (sc->flag & SC_SHOW_GRAPH_TRACKS_MOTION) {
                        draw_tracks_motion_curves(v2d, sc, pos);
                }
@@ -339,9 +350,9 @@ void clip_draw_graph(SpaceClip *sc, ARegion *ar, Scene *scene)
                if (sc->flag & SC_SHOW_GRAPH_FRAMES) {
                        draw_frame_curves(sc, pos);
                }
-       }
 
-       immUnbindProgram();
+               immUnbindProgram();
+       }
 
        /* frame range */
        clip_draw_sfra_efra(v2d, scene);
index 14393c6968b8461157616c92a846cebd8bd7f8e2..ffc7a41f0aa984979b6537455554124742a9edf2 100644 (file)
@@ -125,12 +125,12 @@ void ED_clip_tool_props_register(struct ARegionType *art);
 /* clip_utils.c */
 void clip_graph_tracking_values_iterate_track(struct SpaceClip *sc, struct MovieTrackingTrack *track, void *userdata,
                                               void (*func)(void *userdata, struct MovieTrackingTrack *track, struct MovieTrackingMarker *marker, int coord, int scene_framenr, float val),
-                                              void (*segment_start)(void *userdata, struct MovieTrackingTrack *track, int coord),
+                                              void (*segment_start)(void *userdata, struct MovieTrackingTrack *track, int coord, bool is_point),
                                               void (*segment_end)(void *userdata, int coord));
 
 void clip_graph_tracking_values_iterate(struct SpaceClip *sc, bool selected_only, bool include_hidden, void *userdata,
                                         void (*func)(void *userdata, struct MovieTrackingTrack *track, struct MovieTrackingMarker *marker, int coord, int scene_framenr, float val),
-                                        void (*segment_start)(void *userdata, struct MovieTrackingTrack *track, int coord),
+                                        void (*segment_start)(void *userdata, struct MovieTrackingTrack *track, int coord, bool is_point),
                                         void (*segment_end)(void *userdata, int coord));
 
 void clip_graph_tracking_iterate(struct SpaceClip *sc, bool selected_only, bool include_hidden, void *userdata,
index 6026036c05d2433a3486e854a51940dbd6a9c762..560cf1f905a5585f06c97882740839c14a4569d5 100644 (file)
@@ -61,7 +61,7 @@ void clip_graph_tracking_values_iterate_track(
         SpaceClip *sc, MovieTrackingTrack *track, void *userdata,
         void (*func)(void *userdata, MovieTrackingTrack *track, MovieTrackingMarker *marker, int coord,
                      int scene_framenr, float val),
-        void (*segment_start)(void *userdata, MovieTrackingTrack *track, int coord),
+        void (*segment_start)(void *userdata, MovieTrackingTrack *track, int coord, bool is_point),
         void (*segment_end)(void *userdata, int coord))
 {
        MovieClip *clip = ED_space_clip_get_clip(sc);
@@ -90,8 +90,14 @@ void clip_graph_tracking_values_iterate_track(
                        }
 
                        if (!open) {
-                               if (segment_start)
-                                       segment_start(userdata, track, coord);
+                               if (segment_start) {
+                                       if ((i + 1) == track->markersnr) {
+                                               segment_start(userdata, track, coord, true);
+                                       }
+                                       else {
+                                               segment_start(userdata, track, coord, (track->markers[i + 1].flag & MARKER_DISABLED));
+                                       }
+                               }
 
                                open = true;
                                prevval = marker->pos[coord];
@@ -122,7 +128,7 @@ void clip_graph_tracking_values_iterate(
         SpaceClip *sc, bool selected_only, bool include_hidden, void *userdata,
         void (*func)(void *userdata, MovieTrackingTrack *track, MovieTrackingMarker *marker,
                      int coord, int scene_framenr, float val),
-        void (*segment_start)(void *userdata, MovieTrackingTrack *track, int coord),
+        void (*segment_start)(void *userdata, MovieTrackingTrack *track, int coord, bool is_point),
         void (*segment_end)(void *userdata, int coord))
 {
        MovieClip *clip = ED_space_clip_get_clip(sc);