diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2020-05-14 16:40:58 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2020-05-14 16:44:18 +0300 |
commit | a260d1cd69bca84b46e995910181615c7d096dee (patch) | |
tree | 97084a8414676d7f305385de3be369d720426140 | |
parent | 236794d07a707a5cf4b8aff9d441f88590d69901 (diff) |
Clip Editor: Fix camera error curve drawing
It didn't work correctly when there in no continuously solved camera
segment (aka there is a single isolated frame with solved camera).
Basically, don't start drawing curve segment until it's known there
is enough points for at least one segment.
On user level it seemed to be fine, but it was assert failure in
debug builds.
-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(); } } |