[Bf-blender-cvs] [80779629dc9] soc-2019-npr: GPencil: Sample function new counter (not working properly).

YimingWu noreply at git.blender.org
Wed Jul 17 16:11:04 CEST 2019


Commit: 80779629dc9dce4e06f958af07a84842a78efcbb
Author: YimingWu
Date:   Wed Jul 17 22:10:12 2019 +0800
Branches: soc-2019-npr
https://developer.blender.org/rB80779629dc9dce4e06f958af07a84842a78efcbb

GPencil: Sample function new counter (not working properly).

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

M	source/blender/blenkernel/intern/gpencil.c
M	source/blender/editors/io/io_svg.c

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

diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index b690ee10cd1..67cb0baa1d9 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -1584,6 +1584,48 @@ static int stroke_march_next_point(bGPDstroke *gps,
   }
 }
 
+/* This is still problematic... */
+static int stroke_march_count(bGPDstroke *gps, float dist)
+{
+  float remaining_till_next = 0.0f;
+  float remaining_march = dist;
+  int point_count = 0;
+  float step_start[3];
+  float point[3];
+  float current[3];
+  int next_point_index = 1;
+  bGPDspoint *pt = NULL;
+
+  pt = &gps->points[0];
+  copy_v3_v3(point, &pt->x);
+  remaining_till_next = len_v3v3(point, &gps->points[1].x);
+
+  while (next_point_index < gps->totpoints){
+    while (remaining_till_next < remaining_march) {
+      remaining_march -= remaining_till_next;
+      pt = &gps->points[next_point_index];
+      copy_v3_v3(point, &pt->x);
+      copy_v3_v3(step_start, point);
+      next_point_index++;
+      if (!(next_point_index < gps->totpoints)) {
+        break;
+      }
+      pt = &gps->points[next_point_index];
+      copy_v3_v3(point, &pt->x);
+      remaining_till_next = len_v3v3(point, step_start);
+    }
+    if (next_point_index < gps->totpoints) {
+      pt = &gps->points[next_point_index];
+      copy_v3_v3(point, &pt->x);
+      remaining_till_next = len_v3v3(point, step_start);
+      next_point_index++;
+    }
+    point_count++;
+  }
+  return point_count+3;
+}
+
+
 /**
  * Resample a stroke
  * \param gps: Stroke to sample
@@ -1617,7 +1659,7 @@ bool BKE_gpencil_sample_stroke(bGPDstroke *gps, float dist)
     copy_v3_v3(last_coord, &pt1->x);
   }
 
-  int count = (int)(length / dist) + 3; /* Head + tail + float point precision tolerance */
+  int count = stroke_march_count(gps, dist);
 
   bGPDspoint *new_pt = MEM_callocN(sizeof(bGPDspoint) * count, "gp_stroke_points_sampled");
   MDeformVert *new_dv = NULL;
diff --git a/source/blender/editors/io/io_svg.c b/source/blender/editors/io/io_svg.c
index 7cbc7264061..d6b3bf56bf6 100644
--- a/source/blender/editors/io/io_svg.c
+++ b/source/blender/editors/io/io_svg.c
@@ -46,16 +46,15 @@
 
 static void write_svg_head(Text *ta)
 {
-  BKE_text_write(ta, NULL, "<?xml version=\"1.0\" standalone=\"no\"?>\n");
+  BKE_text_write(ta, "<?xml version=\"1.0\" standalone=\"no\"?>\n");
   BKE_text_write(ta,
-                 NULL,
                  "<svg width=\"10\" height=\"10\" viewBox=\"-5 -5 10 10\" "
                  "xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">\n");
 }
 
 static void write_svg_end(Text *ta)
 {
-  BKE_text_write(ta, NULL, "</svg>");
+  BKE_text_write(ta, "</svg>");
 }
 
 typedef int(svg_get_path_callback)(void *iterator,
@@ -81,7 +80,7 @@ static void write_paths_from_callback(void *iterator,
   while (get_path(iterator, fill_color, stroke_color, &stroke_width)) {
 
     /* beginning of a path item */
-    BKE_text_write(ta, NULL, "<path d=\"");
+    BKE_text_write(ta, "<path d=\"");
 
     first_in = 1;
     while (get_node(iterator, &x, &y)) {
@@ -90,7 +89,7 @@ static void write_paths_from_callback(void *iterator,
               first_in ? 'M' : 'L',
               x,
               y); /* Should handle closed stroke as well. */
-      BKE_text_write(ta, NULL, buf);
+      BKE_text_write(ta, buf);
       first_in = 0;
     }
 
@@ -103,7 +102,7 @@ static void write_paths_from_callback(void *iterator,
             FAC_255_COLOR3(fill_color),
             FAC_255_COLOR3(stroke_color),
             stroke_width / 1000.0f);
-    BKE_text_write(ta, NULL, buf);
+    BKE_text_write(ta, buf);
   }
 }



More information about the Bf-blender-cvs mailing list