[Bf-blender-cvs] [e11704ae6da] temp-gpencil-io: GPencil: No export in SVG and PDF 1 point strokes
Antonio Vazquez
noreply at git.blender.org
Mon Mar 22 16:07:09 CET 2021
Commit: e11704ae6da6c436f3fb23aeb3b8fab35eedd350
Author: Antonio Vazquez
Date: Mon Mar 22 16:07:03 2021 +0100
Branches: temp-gpencil-io
https://developer.blender.org/rBe11704ae6da6c436f3fb23aeb3b8fab35eedd350
GPencil: No export in SVG and PDF 1 point strokes
Thess strokes produce weird results and usually are errors in the original file. Now the minimum size to export must be 2 points to create a polyline.
===================================================================
M source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc
M source/blender/io/gpencil/intern/gpencil_io_export_pdf.h
M source/blender/io/gpencil/intern/gpencil_io_export_svg.cc
M source/blender/io/gpencil/intern/gpencil_io_export_svg.h
===================================================================
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 6b5d76d390a..a6da54272c1 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc
@@ -174,7 +174,7 @@ void GpencilExporterPDF::export_gpencil_layers()
}
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
- if (gps->totpoints == 0) {
+ if (gps->totpoints < 2) {
continue;
}
if (!ED_gpencil_stroke_material_visible(ob, gpl, gps)) {
@@ -189,34 +189,29 @@ void GpencilExporterPDF::export_gpencil_layers()
/* Apply object scale to thickness. */
gps_duplicate->thickness *= mat4_to_scale(ob->obmat);
CLAMP_MIN(gps_duplicate->thickness, 1.0f);
- if (gps_duplicate->totpoints == 1) {
- export_stroke_to_point(gpl, gps_duplicate);
+ /* Fill. */
+ if ((material_is_fill()) && (params_.flag & GP_EXPORT_FILL)) {
+ /* Fill is exported as polygon for fill and stroke in a different shape. */
+ export_stroke_to_polyline(gpl, gps_duplicate, true, false);
}
- else {
- /* Fill. */
- if ((material_is_fill()) && (params_.flag & GP_EXPORT_FILL)) {
- /* Fill is exported as polygon for fill and stroke in a different shape. */
- export_stroke_to_polyline(gpl, gps_duplicate, true, false);
+
+ /* Stroke. */
+ if (material_is_stroke()) {
+ if (is_normalized) {
+ export_stroke_to_polyline(gpl, gps_duplicate, false, true);
}
+ else {
+ bGPDstroke *gps_perimeter = BKE_gpencil_stroke_perimeter_from_view(
+ rv3d_, gpd_, gpl, gps_duplicate, 3, diff_mat_);
- /* Stroke. */
- if (material_is_stroke()) {
- if (is_normalized) {
- export_stroke_to_polyline(gpl, gps_duplicate, false, true);
+ /* Sample stroke. */
+ if (params_.stroke_sample > 0.0f) {
+ BKE_gpencil_stroke_sample(gpd_eval, gps_perimeter, params_.stroke_sample, false);
}
- else {
- bGPDstroke *gps_perimeter = BKE_gpencil_stroke_perimeter_from_view(
- rv3d_, gpd_, gpl, gps_duplicate, 3, diff_mat_);
-
- /* Sample stroke. */
- if (params_.stroke_sample > 0.0f) {
- BKE_gpencil_stroke_sample(gpd_eval, gps_perimeter, params_.stroke_sample, false);
- }
- export_stroke_to_polyline(gpl, gps_perimeter, false, false);
+ export_stroke_to_polyline(gpl, gps_perimeter, false, false);
- BKE_gpencil_free_stroke(gps_perimeter);
- }
+ BKE_gpencil_free_stroke(gps_perimeter);
}
}
BKE_gpencil_free_stroke(gps_duplicate);
@@ -225,23 +220,6 @@ void GpencilExporterPDF::export_gpencil_layers()
}
}
-/**
- * Export a point
- */
-void GpencilExporterPDF::export_stroke_to_point(bGPDlayer *gpl, bGPDstroke *gps)
-{
- BLI_assert(gps->totpoints == 1);
- float screen_co[2];
-
- bGPDspoint *pt = &gps->points[0];
- gpencil_3d_point_to_2D(&pt->x, screen_co);
- /* Radius. */
- float radius = stroke_point_radius_get(gpl, gps);
-
- HPDF_Page_Circle(page_, screen_co[0], screen_co[1], radius);
- HPDF_Page_ClosePathFillStroke(page_);
-}
-
/**
* Export a stroke using polyline or polygon
* \param do_fill: True if the stroke is only fill
diff --git a/source/blender/io/gpencil/intern/gpencil_io_export_pdf.h b/source/blender/io/gpencil/intern/gpencil_io_export_pdf.h
index 1a175afed98..e5f11fdd526 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_export_pdf.h
+++ b/source/blender/io/gpencil/intern/gpencil_io_export_pdf.h
@@ -59,7 +59,6 @@ class GpencilExporterPDF : public GpencilExporter {
bool add_page();
void export_gpencil_layers();
- void export_stroke_to_point(bGPDlayer *gpl, bGPDstroke *gps);
void export_stroke_to_polyline(bGPDlayer *gpl,
bGPDstroke *gps,
const bool is_fill,
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 a890ab02965..feed02dccc7 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc
@@ -200,7 +200,7 @@ void GpencilExporterSVG::export_gpencil_layers()
node_gpl.append_attribute("id").set_value(gpl->info);
LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
- if (gps->totpoints == 0) {
+ if (gps->totpoints < 2) {
continue;
}
if (!ED_gpencil_stroke_material_visible(ob, gpl, gps)) {
@@ -218,38 +218,33 @@ void GpencilExporterSVG::export_gpencil_layers()
gps_duplicate->thickness *= mat4_to_scale(ob->obmat);
CLAMP_MIN(gps_duplicate->thickness, 1.0f);
- if (gps_duplicate->totpoints == 1) {
- export_stroke_to_point(gpl, gps_duplicate, node_gpl);
+ const bool is_normalized = ((params_.flag & GP_EXPORT_NORM_THICKNESS) != 0) ||
+ BKE_gpencil_stroke_is_thickness_constant(gps);
+
+ /* Fill. */
+ if ((material_is_fill()) && (params_.flag & GP_EXPORT_FILL)) {
+ /* Fill is always exported as polygon because the stroke of the fill is done
+ * in a different SVG command. */
+ export_stroke_to_polyline(gpl, gps_duplicate, node_gpl, true);
}
- else {
- const bool is_normalized = ((params_.flag & GP_EXPORT_NORM_THICKNESS) != 0) ||
- BKE_gpencil_stroke_is_thickness_constant(gps);
-
- /* Fill. */
- if ((material_is_fill()) && (params_.flag & GP_EXPORT_FILL)) {
- /* Fill is always exported as polygon because the stroke of the fill is done
- * in a different SVG command. */
- export_stroke_to_polyline(gpl, gps_duplicate, node_gpl, true);
+
+ /* Stroke. */
+ if (material_is_stroke()) {
+ if (is_normalized) {
+ export_stroke_to_polyline(gpl, gps_duplicate, node_gpl, false);
}
+ else {
+ bGPDstroke *gps_perimeter = BKE_gpencil_stroke_perimeter_from_view(
+ rv3d_, gpd_, gpl, gps_duplicate, 3, diff_mat_);
- /* Stroke. */
- if (material_is_stroke()) {
- if (is_normalized) {
- export_stroke_to_polyline(gpl, gps_duplicate, node_gpl, false);
+ /* Sample stroke. */
+ if (params_.stroke_sample > 0.0f) {
+ BKE_gpencil_stroke_sample(gpd_eval, gps_perimeter, params_.stroke_sample, false);
}
- else {
- bGPDstroke *gps_perimeter = BKE_gpencil_stroke_perimeter_from_view(
- rv3d_, gpd_, gpl, gps_duplicate, 3, diff_mat_);
- /* Sample stroke. */
- if (params_.stroke_sample > 0.0f) {
- BKE_gpencil_stroke_sample(gpd_eval, gps_perimeter, params_.stroke_sample, false);
- }
+ export_stroke_to_path(gpl, gps_perimeter, node_gpl, false);
- export_stroke_to_path(gpl, gps_perimeter, node_gpl, false);
-
- BKE_gpencil_free_stroke(gps_perimeter);
- }
+ BKE_gpencil_free_stroke(gps_perimeter);
}
}
@@ -259,32 +254,6 @@ void GpencilExporterSVG::export_gpencil_layers()
}
}
-/**
- * Export a point
- * \param node_gpl: Node of the layer.
- */
-void GpencilExporterSVG::export_stroke_to_point(struct bGPDlayer *gpl,
- struct bGPDstroke *gps,
- pugi::xml_node node_gpl)
-{
- BLI_assert(gps->totpoints == 1);
- float screen_co[2];
-
- pugi::xml_node node_gps = node_gpl.append_child("circle");
-
- color_string_set(gpl, gps, node_gps, false);
-
- bGPDspoint *pt = &gps->points[0];
- gpencil_3d_point_to_2D(&pt->x, screen_co);
-
- node_gps.append_attribute("cx").set_value(screen_co[0]);
- node_gps.append_attribute("cy").set_value(screen_co[1]);
-
- /* Radius. */
- float radius = stroke_point_radius_get(gpl, gps);
- node_gps.append_attribute("r").set_value(radius);
-}
-
/**
* Export a stroke using SVG path
* \param node_gpl: Node of the layer.
diff --git a/source/blender/io/gpencil/intern/gpencil_io_export_svg.h b/source/blender/io/gpencil/intern/gpencil_io_export_svg.h
index 4e1a4b8fc1c..70c1e586b39 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_export_svg.h
+++ b/source/blender/io/gpencil/intern/gpencil_io_export_svg.h
@@ -69,10 +69,6 @@ class GpencilExporterSVG : public GpencilExporter {
void create_document_header();
void export_gpencil_layers();
- void export_stroke_to_point(struct bGPDlayer *gpl,
- struct bGPDstroke *gps,
- pugi::xml_node node_gpl);
-
void export_stroke_to_path(struct bGPDlayer *gpl,
struct bGPDstroke *gps,
pugi::xml_node node_gpl,
More information about the Bf-blender-cvs
mailing list