[Bf-blender-cvs] [94e7e83cd99] blender-v3.4-release: Fix T103061: GPencil export to SVG wrong line thickness

Antonio Vazquez noreply at git.blender.org
Wed Dec 14 22:23:26 CET 2022


Commit: 94e7e83cd997170d42ddb1155814b8eda127a104
Author: Antonio Vazquez
Date:   Tue Dec 13 11:39:13 2022 +0100
Branches: blender-v3.4-release
https://developer.blender.org/rB94e7e83cd997170d42ddb1155814b8eda127a104

Fix T103061: GPencil export to SVG wrong line thickness

When the line was very thin the precision of the thickness
calculation was not precise enough.

The algorithm has been improved. This affects SVG and PDF.

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

M	source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc
M	source/blender/io/gpencil/intern/gpencil_io_export_svg.cc

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

diff --git a/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc b/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc
index c042ca597c8..23fea9b6460 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc
@@ -177,7 +177,8 @@ void GpencilExporterPDF::export_gpencil_layers()
         /* Apply layer thickness change. */
         gps_duplicate->thickness += gpl->line_change;
         /* Apply object scale to thickness. */
-        gps_duplicate->thickness *= mat4_to_scale(ob->object_to_world);
+        const float scalef = mat4_to_scale(ob->object_to_world);
+        gps_duplicate->thickness = ceilf((float)gps_duplicate->thickness * scalef);
         CLAMP_MIN(gps_duplicate->thickness, 1.0f);
         /* Fill. */
         if ((is_fill) && (params_.flag & GP_EXPORT_FILL)) {
@@ -236,7 +237,9 @@ void GpencilExporterPDF::export_stroke_to_polyline(bGPDlayer *gpl,
 
   if (is_stroke && !do_fill) {
     HPDF_Page_SetLineJoin(page_, HPDF_ROUND_JOIN);
-    HPDF_Page_SetLineWidth(page_, MAX2((radius * 2.0f) - gpl->line_change, 1.0f));
+    const float width = MAX2(
+        MAX2(gps->thickness + gpl->line_change, (radius * 2.0f) + gpl->line_change), 1.0f);
+    HPDF_Page_SetLineWidth(page_, width);
   }
 
   /* Loop all points. */
diff --git a/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc b/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc
index b85fd33e116..2c4c09ce1a0 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc
@@ -198,7 +198,8 @@ void GpencilExporterSVG::export_gpencil_layers()
         /* Apply layer thickness change. */
         gps_duplicate->thickness += gpl->line_change;
         /* Apply object scale to thickness. */
-        gps_duplicate->thickness *= mat4_to_scale(ob->object_to_world);
+        const float scalef = mat4_to_scale(ob->object_to_world);
+        gps_duplicate->thickness = ceilf((float)gps_duplicate->thickness * scalef);
         CLAMP_MIN(gps_duplicate->thickness, 1.0f);
 
         const bool is_normalized = ((params_.flag & GP_EXPORT_NORM_THICKNESS) != 0) ||
@@ -308,7 +309,9 @@ void GpencilExporterSVG::export_stroke_to_polyline(bGPDlayer *gpl,
   color_string_set(gpl, gps, node_gps, do_fill);
 
   if (is_stroke && !do_fill) {
-    node_gps.append_attribute("stroke-width").set_value((radius * 2.0f) - gpl->line_change);
+    const float width = MAX2(
+        MAX2(gps->thickness + gpl->line_change, (radius * 2.0f) + gpl->line_change), 1.0f);
+    node_gps.append_attribute("stroke-width").set_value(width);
   }
 
   std::string txt;



More information about the Bf-blender-cvs mailing list