[Bf-blender-cvs] [e6fab8dc399] greasepencil-object: GPencil: New function to determine if the stroke has same thickness in all points

Antonio Vazquez noreply at git.blender.org
Mon Jul 27 19:00:13 CEST 2020


Commit: e6fab8dc399302d35fe1bb8266f8672852dafb50
Author: Antonio Vazquez
Date:   Mon Jul 27 18:59:57 2020 +0200
Branches: greasepencil-object
https://developer.blender.org/rBe6fab8dc399302d35fe1bb8266f8672852dafb50

GPencil: New function to determine if the stroke has same thickness in all points

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

M	source/blender/io/gpencil/intern/gpencil_io_base.cc
M	source/blender/io/gpencil/intern/gpencil_io_base.h

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

diff --git a/source/blender/io/gpencil/intern/gpencil_io_base.cc b/source/blender/io/gpencil/intern/gpencil_io_base.cc
index 528a5d16112..e3917e304df 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_base.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_base.cc
@@ -33,6 +33,7 @@
 #include "BLI_string.h"
 #include "BLI_utildefines.h"
 
+#include "DNA_gpencil_types.h"
 #include "DNA_object_types.h"
 
 #ifdef WIN32
@@ -91,6 +92,30 @@ bool GpencilExporter::gpencil_3d_point_to_screen_space(struct ARegion *region,
   return false;
 }
 
+/**
+ * Check if the thickness of the stroke is constant
+ * \param gps: Pointer to stroke
+ * \retun true if all points thickness are equal.
+ */
+bool GpencilExporter::is_stroke_thickness_constant(struct bGPDstroke *gps)
+{
+  if (gps->totpoints == 1) {
+    return true;
+  }
+
+  bGPDspoint *pt = &gps->points[0];
+  float prv_pressure = pt->pressure;
+
+  for (int i = 0; i < gps->totpoints; i++) {
+    pt = &gps->points[i];
+    if (pt->pressure != prv_pressure) {
+      return false;
+    }
+  }
+
+  return true;
+}
+
 /**
  * Convert a color to Hex value (#FFFFFF)
  * \param color: Original RGB color
diff --git a/source/blender/io/gpencil/intern/gpencil_io_base.h b/source/blender/io/gpencil/intern/gpencil_io_base.h
index 28e0650f5e1..1dfce8b4f36 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_base.h
+++ b/source/blender/io/gpencil/intern/gpencil_io_base.h
@@ -47,6 +47,8 @@ class GpencilExporter {
                                         const float co[3],
                                         float r_co[2]);
 
+  bool is_stroke_thickness_constant(struct bGPDstroke *gps);
+
   std::string rgb_to_hex(float color[3]);
   std::string to_lower_string(char *input_text);



More information about the Bf-blender-cvs mailing list