[Bf-blender-cvs] [a260d1cd69b] master: Clip Editor: Fix camera error curve drawing

Sergey Sharybin noreply at git.blender.org
Thu May 14 15:50:18 CEST 2020


Commit: a260d1cd69bca84b46e995910181615c7d096dee
Author: Sergey Sharybin
Date:   Thu May 14 15:40:58 2020 +0200
Branches: master
https://developer.blender.org/rBa260d1cd69bca84b46e995910181615c7d096dee

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.

===================================================================

M	source/blender/editors/space_clip/clip_graph_draw.c

===================================================================

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();
   }
 }



More information about the Bf-blender-cvs mailing list