[Bf-blender-cvs] [b8a0434bc53] blender2.8: GP: New automatic adaptative UVs parameter
Antonioya
noreply at git.blender.org
Mon Oct 8 18:35:10 CEST 2018
Commit: b8a0434bc53b338ee657497d5d6884880a055bb3
Author: Antonioya
Date: Mon Oct 8 18:33:26 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBb8a0434bc53b338ee657497d5d6884880a055bb3
GP: New automatic adaptative UVs parameter
Now by default the UVs are calculated with a fixed size and this makes easier to add patterns for drawings like Manga. Before, the texture changed depending of the stroke size.
===================================================================
M release/scripts/startup/bl_ui/properties_data_gpencil.py
M source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M source/blender/draw/engines/gpencil/gpencil_draw_utils.c
M source/blender/draw/engines/gpencil/gpencil_engine.h
M source/blender/makesdna/DNA_gpencil_types.h
M source/blender/makesrna/intern/rna_gpencil.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_data_gpencil.py b/release/scripts/startup/bl_ui/properties_data_gpencil.py
index e9fb859c3e9..8bb1c2641f2 100644
--- a/release/scripts/startup/bl_ui/properties_data_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_data_gpencil.py
@@ -345,6 +345,7 @@ class DATA_PT_gpencil_display(DataButtonsPanel, Panel):
layout.prop(gpd, "show_stroke_direction", text="Show Stroke Directions")
layout.prop(gpd, "use_force_fill_recalc", text="Force Fill Update")
+ layout.prop(gpd, "use_adaptative_uv", text="Adaptative UVs")
layout.prop(gpd, "zdepth_offset", text="Surface Offset")
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index 40245810f42..8957e641e99 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -414,7 +414,7 @@ GPUBatch *DRW_gpencil_get_fill_geom(Object *ob, bGPDstroke *gps, const float col
/* Calculate triangles cache for filling area (must be done only after changes) */
if ((gps->flag & GP_STROKE_RECALC_CACHES) || (gps->tot_triangles == 0) || (gps->triangles == NULL)) {
- DRW_gpencil_triangulate_stroke_fill(gps);
+ DRW_gpencil_triangulate_stroke_fill(ob, gps);
ED_gpencil_calc_stroke_uv(ob, gps);
}
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index f7823a2fced..03a6f7342ab 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -92,7 +92,7 @@ static bool gpencil_can_draw_stroke(
/* calc bounding box in 2d using flat projection data */
static void gpencil_calc_2d_bounding_box(
- const float(*points2d)[2], int totpoints, float minv[2], float maxv[2], bool expand)
+ const float(*points2d)[2], int totpoints, float minv[2], float maxv[2])
{
minv[0] = points2d[0][0];
minv[1] = points2d[0][1];
@@ -115,14 +115,12 @@ static void gpencil_calc_2d_bounding_box(
maxv[1] = points2d[i][1];
}
}
- /* If not expanded, use a perfect square */
- if (expand == false) {
- if (maxv[0] > maxv[1]) {
- maxv[1] = maxv[0];
- }
- else {
- maxv[0] = maxv[1];
- }
+ /* use a perfect square */
+ if (maxv[0] > maxv[1]) {
+ maxv[1] = maxv[0];
+ }
+ else {
+ maxv[0] = maxv[1];
}
}
@@ -184,10 +182,12 @@ static void gpencil_stroke_2d_flat(const bGPDspoint *points, int totpoints, floa
}
/* Triangulate stroke for high quality fill (this is done only if cache is null or stroke was modified) */
-void DRW_gpencil_triangulate_stroke_fill(bGPDstroke *gps)
+void DRW_gpencil_triangulate_stroke_fill(Object *ob, bGPDstroke *gps)
{
BLI_assert(gps->totpoints >= 3);
+ bGPdata *gpd = (bGPdata *)ob->data;
+
/* allocate memory for temporary areas */
gps->tot_triangles = gps->totpoints - 2;
uint(*tmp_triangles)[3] = MEM_mallocN(sizeof(*tmp_triangles) * gps->tot_triangles, "GP Stroke temp triangulation");
@@ -204,7 +204,14 @@ void DRW_gpencil_triangulate_stroke_fill(bGPDstroke *gps)
float minv[2];
float maxv[2];
/* first needs bounding box data */
- gpencil_calc_2d_bounding_box(points2d, gps->totpoints, minv, maxv, false);
+ if (gpd->flag & GP_DATA_UV_ADAPTATIVE) {
+ gpencil_calc_2d_bounding_box(points2d, gps->totpoints, minv, maxv);
+ }
+ else {
+ ARRAY_SET_ITEMS(minv, -1.0f, -1.0f);
+ ARRAY_SET_ITEMS(maxv, 1.0f, 1.0f);
+ }
+
/* calc uv data */
gpencil_calc_stroke_fill_uv(points2d, gps->totpoints, minv, maxv, uv);
@@ -256,7 +263,7 @@ static void DRW_gpencil_recalc_geometry_caches(Object *ob, MaterialGPencilStyle
if ((gps->totpoints > 2) &&
((gp_style->fill_rgba[3] > GPENCIL_ALPHA_OPACITY_THRESH) || (gp_style->fill_style > 0)))
{
- DRW_gpencil_triangulate_stroke_fill(gps);
+ DRW_gpencil_triangulate_stroke_fill(ob, gps);
}
}
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index df051f4697b..7a9e93ec105 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -303,7 +303,7 @@ void DRW_gpencil_populate_buffer_strokes(
void DRW_gpencil_populate_multiedit(
struct GPENCIL_e_data *e_data, void *vedata,
struct Scene *scene, struct Object *ob, struct tGPencilObjectCache *cache_ob);
-void DRW_gpencil_triangulate_stroke_fill(struct bGPDstroke *gps);
+void DRW_gpencil_triangulate_stroke_fill(struct Object *ob, struct bGPDstroke *gps);
void DRW_gpencil_multisample_ensure(struct GPENCIL_Data *vedata, int rect_w, int rect_h);
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index 2a79880f221..8465d1634a4 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -442,6 +442,8 @@ typedef enum eGPdata_Flag {
GP_DATA_STROKE_FORCE_RECALC = (1 << 17),
/* Special mode drawing polygons */
GP_DATA_STROKE_POLYGON = (1 << 18),
+ /* Use adaptative UV scales */
+ GP_DATA_UV_ADAPTATIVE = (1 << 19),
} eGPdata_Flag;
/* gpd->onion_flag */
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index 36330f1e17a..4a2c8055a37 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -1383,6 +1383,11 @@ static void rna_def_gpencil_data(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Force Fill Update", "Force recalc of fill data after use deformation modifiers (reduce FPS)");
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+ prop = RNA_def_property(srna, "use_adaptative_uv", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_UV_ADAPTATIVE);
+ RNA_def_property_ui_text(prop, "Adaptative UV", "Automatic UVs are calculated depending of the stroke size");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+
prop = RNA_def_property(srna, "edit_line_color", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_float_sdna(prop, NULL, "line_color");
RNA_def_property_array(prop, 4);
More information about the Bf-blender-cvs
mailing list