[Bf-blender-cvs] [2027a7213a9] temp-gpencil-io: More cleanup of variables
Antonio Vazquez
noreply at git.blender.org
Wed Mar 17 19:32:34 CET 2021
Commit: 2027a7213a9546f776930ae01a0b9cd535705d19
Author: Antonio Vazquez
Date: Wed Mar 17 19:07:47 2021 +0100
Branches: temp-gpencil-io
https://developer.blender.org/rB2027a7213a9546f776930ae01a0b9cd535705d19
More cleanup of variables
===================================================================
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 24d403d382b..e254a6bccc8 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc
@@ -254,11 +254,9 @@ void GpencilExporterPDF::export_stroke_to_polyline(bGPDlayer *gpl,
const bool is_thickness_const = is_stroke_thickness_constant(gps);
const bool cyclic = ((gps->flag & GP_STROKE_CYCLIC) != 0);
- bGPDspoint *pt = &gps->points[0];
- float avg_pressure = pt->pressure;
- if (!is_thickness_const) {
- avg_pressure = stroke_average_pressure_get(gps);
- }
+ /* For constant thickness, use first point pressure. */
+ const float avg_pressure = is_thickness_const ? gps->points[0].pressure :
+ stroke_average_pressure_get(gps);
/* Get the thickness in pixels using a simple 1 point stroke. */
bGPDstroke *gps_temp = BKE_gpencil_stroke_duplicate(gps, false, false);
@@ -269,7 +267,7 @@ void GpencilExporterPDF::export_stroke_to_polyline(bGPDlayer *gpl,
copy_v3_v3(&pt_dst->x, &pt_src->x);
pt_dst->pressure = avg_pressure;
- float radius = stroke_point_radius_get(gpl, gps_temp);
+ const float radius = stroke_point_radius_get(gpl, gps_temp);
BKE_gpencil_free_stroke(gps_temp);
@@ -281,8 +279,8 @@ void GpencilExporterPDF::export_stroke_to_polyline(bGPDlayer *gpl,
}
/* Loop all points. */
- for (int32_t i = 0; i < gps->totpoints; i++) {
- pt = &gps->points[i];
+ for (const int i : IndexRange(gps->totpoints)) {
+ bGPDspoint *pt = &gps->points[i];
float screen_co[2];
HPDF_STATUS err;
gpencil_3d_point_to_2D(&pt->x, screen_co);
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 1b1974dc09f..374e8b1f885 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc
@@ -222,8 +222,8 @@ void GpencilExporterSVG::export_gpencil_layers()
export_stroke_to_point(gpl, gps_duplicate, node_gpl);
}
else {
- bool is_normalized = ((params_.flag & GP_EXPORT_NORM_THICKNESS) != 0) ||
- is_stroke_thickness_constant(gps);
+ const bool is_normalized = ((params_.flag & GP_EXPORT_NORM_THICKNESS) != 0) ||
+ is_stroke_thickness_constant(gps);
/* Fill. */
if ((material_is_fill()) && (params_.flag & GP_EXPORT_FILL)) {
@@ -348,11 +348,9 @@ void GpencilExporterSVG::export_stroke_to_polyline(struct bGPDlayer *gpl,
const bool is_thickness_const = is_stroke_thickness_constant(gps);
const bool cyclic = ((gps->flag & GP_STROKE_CYCLIC) != 0);
- bGPDspoint *pt = &gps->points[0];
- float avg_pressure = pt->pressure;
- if (!is_thickness_const) {
- avg_pressure = stroke_average_pressure_get(gps);
- }
+ /* For constant thickness, use first point pressure. */
+ const float avg_pressure = (is_thickness_const) ? gps->points[0].pressure :
+ stroke_average_pressure_get(gps);
/* Get the thickness in pixels using a simple 1 point stroke. */
bGPDstroke *gps_temp = BKE_gpencil_stroke_duplicate(gps, false, false);
@@ -363,7 +361,7 @@ void GpencilExporterSVG::export_stroke_to_polyline(struct bGPDlayer *gpl,
copy_v3_v3(&pt_dst->x, &pt_src->x);
pt_dst->pressure = avg_pressure;
- float radius = stroke_point_radius_get(gpl, gps_temp);
+ const float radius = stroke_point_radius_get(gpl, gps_temp);
BKE_gpencil_free_stroke(gps_temp);
@@ -376,11 +374,11 @@ void GpencilExporterSVG::export_stroke_to_polyline(struct bGPDlayer *gpl,
}
std::string txt;
- for (int32_t i = 0; i < gps->totpoints; i++) {
+ for (const int i : IndexRange(gps->totpoints)) {
if (i > 0) {
txt.append(" ");
}
- pt = &gps->points[i];
+ bGPDspoint *pt = &gps->points[i];
float screen_co[2];
gpencil_3d_point_to_2D(&pt->x, screen_co);
txt.append(std::to_string(screen_co[0]) + "," + std::to_string(screen_co[1]));
More information about the Bf-blender-cvs
mailing list