[Bf-blender-cvs] [4f504f27802] greasepencil-object: Update strokes UV when change UV factor in color
Antonio Vazquez
noreply at git.blender.org
Fri Feb 23 23:34:36 CET 2018
Commit: 4f504f27802cd62827e59ad75250f8cfff3d5ef2
Author: Antonio Vazquez
Date: Fri Feb 23 23:33:57 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rB4f504f27802cd62827e59ad75250f8cfff3d5ef2
Update strokes UV when change UV factor in color
Recalc UV data for any stroke that is using the color.
===================================================================
M source/blender/editors/gpencil/gpencil_utils.c
M source/blender/editors/include/ED_gpencil.h
M source/blender/makesrna/intern/rna_palette.c
===================================================================
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index 72b04941730..c482dcc2d95 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -48,6 +48,7 @@
#include "DNA_space_types.h"
#include "DNA_view3d_types.h"
+#include "BKE_main.h"
#include "BKE_context.h"
#include "BKE_gpencil.h"
#include "BKE_object.h"
@@ -1618,5 +1619,33 @@ void ED_gpencil_calc_stroke_uv(bGPDstroke *gps)
}
}
+/* recalc uv for any stroke using the color */
+void ED_gpencil_update_color_uv(Main *bmain, Palette *palette, PaletteColor *palcolor)
+{
+ /* read all strokes */
+ for (bGPdata *gpd = bmain->gpencil.first; gpd; gpd = gpd->id.next) {
+ for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+ /* only editable and visible layers are considered */
+ if (gpencil_layer_is_editable(gpl)) {
+ for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
+ for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
+ /* check if the color is editable */
+ if (ED_gpencil_stroke_color_use(gpl, gps) == false) {
+ continue;
+ }
+ if (gps->palette != palette) {
+ continue;
+ }
+
+ /* update */
+ if (strcmp(palcolor->info, gps->colorname) == 0) {
+ ED_gpencil_calc_stroke_uv(gps);
+ }
+ }
+ }
+ }
+ }
+ }
+}
/* ******************************************************** */
diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h
index f3c3891a9b1..ea2f8527946 100644
--- a/source/blender/editors/include/ED_gpencil.h
+++ b/source/blender/editors/include/ED_gpencil.h
@@ -41,6 +41,7 @@ struct bGPDframe;
struct bGPDstroke;
struct bGPDspoint;
+struct Main;
struct bContext;
struct EvaluationContext;
struct Depsgraph;
@@ -214,5 +215,6 @@ int ED_gpencil_join_objects_exec(struct bContext *C, struct wmOperator *op);
/* texture coordinate utilities */
void ED_gpencil_tpoint_to_point(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, float origin[3], const struct tGPspoint *tpt, struct bGPDspoint *pt);
void ED_gpencil_calc_stroke_uv(struct bGPDstroke *gps);
+void ED_gpencil_update_color_uv(struct Main *bmain, struct Palette *palette, struct PaletteColor *palcolor);
#endif /* __ED_GPENCIL_H__ */
diff --git a/source/blender/makesrna/intern/rna_palette.c b/source/blender/makesrna/intern/rna_palette.c
index f7c268d374f..bbe4298f7a3 100644
--- a/source/blender/makesrna/intern/rna_palette.c
+++ b/source/blender/makesrna/intern/rna_palette.c
@@ -62,6 +62,16 @@ static void rna_Palette_dependency_update(Main *UNUSED(bmain), Scene *UNUSED(sce
WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
}
+static void rna_Palette_uv_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ /* update all uv strokes of this color */
+ Palette *palette = ptr->id.data;
+ PaletteColor *palcolor = (PaletteColor *)ptr->data;
+ ED_gpencil_update_color_uv(bmain, palette, palcolor);
+
+ rna_Palette_dependency_update(bmain, scene, ptr);
+}
+
static PaletteColor *rna_Palette_color_new(Palette *palette)
{
PaletteColor *color = BKE_palette_color_add(palette);
@@ -387,7 +397,7 @@ static void rna_def_palettecolor(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "t_pixsize");
RNA_def_property_range(prop, 1, 5000);
RNA_def_property_ui_text(prop, "UV Factor", "Texture Pixel Size factor along the stroke");
- RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_Palette_dependency_update");
+ RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS | ND_DATA | NC_GPENCIL, "rna_Palette_uv_update");
/* Flags */
prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
More information about the Bf-blender-cvs
mailing list