[Bf-blender-cvs] [e6daa161ddb] master: Tracking: Remove limit of 50 points of the track history

Sergey Sharybin noreply at git.blender.org
Fri Aug 4 09:12:40 CEST 2017


Commit: e6daa161ddb98e5dac6df0ed5f88e2f8c0d13522
Author: Sergey Sharybin
Date:   Fri Aug 4 09:11:26 2017 +0200
Branches: master
https://developer.blender.org/rBe6daa161ddb98e5dac6df0ed5f88e2f8c0d13522

Tracking: Remove limit of 50 points of the track history

Was quite stupid reason for this: static size of array.

Now we allocate needed amount of points in heap if requested path length is
getting too big.

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

M	source/blender/editors/space_clip/clip_draw.c
M	source/blender/makesrna/intern/rna_space.c

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

diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index 695d04d3850..3ca25b26bdf 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -365,9 +365,11 @@ static void draw_stabilization_border(SpaceClip *sc, ARegion *ar, int width, int
 
 static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackingTrack *track)
 {
+#define MAX_STATIC_PATH 64
 	int count = sc->path_length;
 	int i, a, b, curindex = -1;
-	float path[102][2];
+	float path_static[(MAX_STATIC_PATH + 1) * 2][2];
+	float (*path)[2];
 	int tiny = sc->flag & SC_SHOW_TINY_MARKER, framenr, start_frame;
 	MovieTrackingMarker *marker;
 
@@ -380,6 +382,13 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
 	if (marker->framenr != framenr || marker->flag & MARKER_DISABLED)
 		return;
 
+	if (count < MAX_STATIC_PATH) {
+		path = path_static;
+	}
+	else {
+		path = MEM_mallocN(sizeof(*path) * (count + 1) * 2, "path");
+	}
+
 	a = count;
 	i = framenr - 1;
 	while (i >= framenr - count) {
@@ -470,6 +479,10 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin
 		glVertex2f(path[i][0], path[i][1]);
 	}
 	glEnd();
+
+	if (path != path_static) {
+		MEM_freeN(path);
+	}
 }
 
 static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker,
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index f2e856bf1ba..7a1b5bb678b 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -4605,7 +4605,7 @@ static void rna_def_space_clip(BlenderRNA *brna)
 	/* path length */
 	prop = RNA_def_property(srna, "path_length", PROP_INT, PROP_NONE);
 	RNA_def_property_int_sdna(prop, NULL, "path_length");
-	RNA_def_property_range(prop, 0, 50);
+	RNA_def_property_range(prop, 0, INT_MAX);
 	RNA_def_property_ui_text(prop, "Path Length", "Length of displaying path, in frames");
 	RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);




More information about the Bf-blender-cvs mailing list