diff options
Diffstat (limited to 'source/blender/editors/space_clip/clip_graph_draw.c')
-rw-r--r-- | source/blender/editors/space_clip/clip_graph_draw.c | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c index dc212741e6b..277930495bd 100644 --- a/source/blender/editors/space_clip/clip_graph_draw.c +++ b/source/blender/editors/space_clip/clip_graph_draw.c @@ -220,31 +220,46 @@ static void draw_frame_curves(SpaceClip *sc, uint pos) MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingReconstruction *reconstruction = BKE_tracking_get_active_reconstruction(tracking); - int i, lines = 0, prevfra = 0; + + int previous_frame; + float previous_error; + bool have_previous_point = false; + + /* Indicates whether immBegin() was called. */ + bool is_lines_segment_open = false; immUniformColor3f(0.0f, 0.0f, 1.0f); - for (i = 0; i < reconstruction->camnr; i++) { + for (int i = 0; i < reconstruction->camnr; i++) { MovieReconstructedCamera *camera = &reconstruction->cameras[i]; - int framenr; - if (lines && camera->framenr != prevfra + 1) { - immEnd(); - lines = 0; - } + const int current_frame = BKE_movieclip_remap_clip_to_scene_frame(clip, camera->framenr); + const float current_error = camera->error; - if (!lines) { - immBeginAtMost(GPU_PRIM_LINE_STRIP, reconstruction->camnr); - lines = 1; + if (have_previous_point && current_frame != previous_frame + 1) { + if (is_lines_segment_open) { + immEnd(); + is_lines_segment_open = false; + } + have_previous_point = false; } - framenr = BKE_movieclip_remap_clip_to_scene_frame(clip, camera->framenr); - immVertex2f(pos, framenr, camera->error); + if (have_previous_point) { + if (!is_lines_segment_open) { + immBeginAtMost(GPU_PRIM_LINE_STRIP, reconstruction->camnr); + is_lines_segment_open = true; + + immVertex2f(pos, previous_frame, previous_error); + } + immVertex2f(pos, current_frame, current_error); + } - prevfra = camera->framenr; + previous_frame = current_frame; + previous_error = current_error; + have_previous_point = true; } - if (lines) { + if (is_lines_segment_open) { immEnd(); } } |