[Bf-blender-cvs] [8184bf56f53] temp-gpencil-io: Remove class member variables
Antonio Vazquez
noreply at git.blender.org
Tue Mar 23 09:46:39 CET 2021
Commit: 8184bf56f5370edf651f3a2473314d1dec7c6e87
Author: Antonio Vazquez
Date: Tue Mar 23 09:46:36 2021 +0100
Branches: temp-gpencil-io
https://developer.blender.org/rB8184bf56f5370edf651f3a2473314d1dec7c6e87
Remove class member variables
===================================================================
M source/blender/io/gpencil/intern/gpencil_io_base.cc
M source/blender/io/gpencil/intern/gpencil_io_base.h
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_base.cc b/source/blender/io/gpencil/intern/gpencil_io_base.cc
index e67d742b44a..da8f67a9f27 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_base.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_base.cc
@@ -327,17 +327,12 @@ void GpencilIO::gpl_matrix_set(struct Object *ob, struct bGPDlayer *gpl)
mul_m4_m4m4(diff_mat_, diff_mat_, gpl->layer_invmat);
}
-void GpencilIO::gps_current_color_set(struct Object *ob, struct bGPDstroke *gps)
+void GpencilIO::gps_material_data_prepare(struct Object *ob, struct bGPDstroke *gps)
{
- gp_style_ = BKE_gpencil_material_settings(ob, gps->mat_nr + 1);
-
- is_stroke_ = ((gp_style_->flag & GP_MATERIAL_STROKE_SHOW) &&
- (gp_style_->stroke_rgba[3] > GPENCIL_ALPHA_OPACITY_THRESH));
- is_fill_ = ((gp_style_->flag & GP_MATERIAL_FILL_SHOW) &&
- (gp_style_->fill_rgba[3] > GPENCIL_ALPHA_OPACITY_THRESH));
+ MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(ob, gps->mat_nr + 1);
/* Stroke color. */
- copy_v4_v4(stroke_color_, gp_style_->stroke_rgba);
+ copy_v4_v4(stroke_color_, gp_style->stroke_rgba);
avg_opacity_ = 0;
/* Get average vertex color and apply. */
float avg_color[4] = {0.0f, 0.0f, 0.0f, 0.0f};
@@ -351,26 +346,11 @@ void GpencilIO::gps_current_color_set(struct Object *ob, struct bGPDstroke *gps)
avg_opacity_ /= (float)gps->totpoints;
/* Fill color. */
- copy_v4_v4(fill_color_, gp_style_->fill_rgba);
+ copy_v4_v4(fill_color_, gp_style->fill_rgba);
/* Apply vertex color for fill. */
interp_v3_v3v3(fill_color_, fill_color_, gps->vert_color_fill, gps->vert_color_fill[3]);
}
-struct MaterialGPencilStyle *GpencilIO::gp_style_current_get()
-{
- return gp_style_;
-}
-
-bool GpencilIO::material_is_stroke()
-{
- return is_stroke_;
-}
-
-bool GpencilIO::material_is_fill()
-{
- return is_fill_;
-}
-
float GpencilIO::stroke_average_opacity_get()
{
return avg_opacity_;
diff --git a/source/blender/io/gpencil/intern/gpencil_io_base.h b/source/blender/io/gpencil/intern/gpencil_io_base.h
index 8955d5365df..e860265e05f 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_base.h
+++ b/source/blender/io/gpencil/intern/gpencil_io_base.h
@@ -98,25 +98,18 @@ class GpencilIO {
float stroke_point_radius_get(struct bGPDlayer *gpl, struct bGPDstroke *gps);
void create_object_list();
- struct MaterialGPencilStyle *gp_style_current_get();
- bool material_is_stroke();
- bool material_is_fill();
-
bool is_camera_mode();
float stroke_average_opacity_get();
void gpl_matrix_set(struct Object *ob, struct bGPDlayer *gpl);
- void gps_current_color_set(struct Object *ob, struct bGPDstroke *gps);
+ void gps_material_data_prepare(struct Object *ob, struct bGPDstroke *gps);
void selected_objects_boundbox_calc();
void selected_objects_boundbox_get(rctf *boundbox);
void filename_set(const char *filename);
private:
- struct MaterialGPencilStyle *gp_style_;
- bool is_stroke_;
- bool is_fill_;
float avg_opacity_;
bool is_camera_;
rctf select_boundbox_;
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 637e30bc5f0..b2602ae8183 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc
@@ -182,7 +182,14 @@ void GpencilExporterPDF::export_gpencil_layers()
}
/* Duplicate the stroke to apply any layer thickness change. */
bGPDstroke *gps_duplicate = BKE_gpencil_stroke_duplicate(gps, true, false);
- gps_current_color_set(ob, gps_duplicate);
+ MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(ob,
+ gps_duplicate->mat_nr + 1);
+
+ const bool is_stroke = ((gp_style->flag & GP_MATERIAL_STROKE_SHOW) &&
+ (gp_style->stroke_rgba[3] > GPENCIL_ALPHA_OPACITY_THRESH));
+ const bool is_fill = ((gp_style->flag & GP_MATERIAL_FILL_SHOW) &&
+ (gp_style->fill_rgba[3] > GPENCIL_ALPHA_OPACITY_THRESH));
+ gps_material_data_prepare(ob, gps_duplicate);
/* Apply layer thickness change. */
gps_duplicate->thickness += gpl->line_change;
@@ -190,15 +197,15 @@ void GpencilExporterPDF::export_gpencil_layers()
gps_duplicate->thickness *= mat4_to_scale(ob->obmat);
CLAMP_MIN(gps_duplicate->thickness, 1.0f);
/* Fill. */
- if ((material_is_fill()) && (params_.flag & GP_EXPORT_FILL)) {
+ if ((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);
+ export_stroke_to_polyline(gpl, gps_duplicate, is_stroke, true, false);
}
/* Stroke. */
- if (material_is_stroke()) {
+ if (is_stroke) {
if (is_normalized) {
- export_stroke_to_polyline(gpl, gps_duplicate, false, true);
+ export_stroke_to_polyline(gpl, gps_duplicate, is_stroke, false, true);
}
else {
bGPDstroke *gps_perimeter = BKE_gpencil_stroke_perimeter_from_view(
@@ -209,7 +216,7 @@ void GpencilExporterPDF::export_gpencil_layers()
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, is_stroke, false, false);
BKE_gpencil_free_stroke(gps_perimeter);
}
@@ -226,6 +233,7 @@ void GpencilExporterPDF::export_gpencil_layers()
*/
void GpencilExporterPDF::export_stroke_to_polyline(bGPDlayer *gpl,
bGPDstroke *gps,
+ const bool is_stroke,
const bool do_fill,
const bool normalize)
{
@@ -247,7 +255,7 @@ void GpencilExporterPDF::export_stroke_to_polyline(bGPDlayer *gpl,
color_set(gpl, do_fill);
- if (material_is_stroke() && !do_fill) {
+ 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));
}
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 e5f11fdd526..f34449655ee 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_export_pdf.h
+++ b/source/blender/io/gpencil/intern/gpencil_io_export_pdf.h
@@ -61,7 +61,8 @@ class GpencilExporterPDF : public GpencilExporter {
void export_stroke_to_polyline(bGPDlayer *gpl,
bGPDstroke *gps,
- const bool is_fill,
+ const bool is_stroke,
+ const bool do_fill,
const bool normalize);
void color_set(bGPDlayer *gpl, const bool do_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 eaba97dffff..05bf8f7cac1 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc
@@ -210,7 +210,15 @@ void GpencilExporterSVG::export_gpencil_layers()
/* Duplicate the stroke to apply any layer thickness change. */
bGPDstroke *gps_duplicate = BKE_gpencil_stroke_duplicate(gps, true, false);
- gps_current_color_set(ob, gps_duplicate);
+ MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(ob,
+ gps_duplicate->mat_nr + 1);
+
+ const bool is_stroke = ((gp_style->flag & GP_MATERIAL_STROKE_SHOW) &&
+ (gp_style->stroke_rgba[3] > GPENCIL_ALPHA_OPACITY_THRESH));
+ const bool is_fill = ((gp_style->flag & GP_MATERIAL_FILL_SHOW) &&
+ (gp_style->fill_rgba[3] > GPENCIL_ALPHA_OPACITY_THRESH));
+
+ gps_material_data_prepare(ob, gps_duplicate);
/* Apply layer thickness change. */
gps_duplicate->thickness += gpl->line_change;
@@ -222,16 +230,16 @@ void GpencilExporterSVG::export_gpencil_layers()
BKE_gpencil_stroke_is_pressure_constant(gps);
/* Fill. */
- if ((material_is_fill()) && (params_.flag & GP_EXPORT_FILL)) {
+ if ((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);
+ export_stroke_to_polyline(gpl, gps_duplicate, node_gpl, is_stroke, true);
}
/* Stroke. */
- if (material_is_stroke()) {
+ if (is_stroke) {
if (is_normalized) {
- export_stroke_to_polyline(gpl, gps_duplicate, node_gpl, false);
+ export_stroke_to_polyline(gpl, gps_duplicate, node_gpl, is_stroke, false);
}
else {
bGPDstroke *gps_perimeter = BKE_gpencil_stroke_perimeter_from_view(
@@ -312,6 +320,7 @@ void GpencilExporterSVG::export_stroke_to_path(struct bGPDlayer *gpl,
void GpencilExporterSVG::export_stroke_to_polyline(struct bGPDlayer *gpl,
struct bGPDstroke *gps,
pugi::xml_node node_gpl,
+ const bool is_stroke,
const bool do_fill)
{
const bool cyclic = ((gps->flag & GP_STROKE_CYCLIC) != 0);
@@ -334,7 +343,7 @@ void GpencilExporterSVG::export_stroke_to_polyline(struct bGPDlayer *gpl,
color_string_set(gpl, gps, node_gps, do_fill);
- if (material_is_stroke()
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list