[Bf-blender-cvs] [15669c1c024] soc-2020-greasepencil-curve: GPencil: Convert from curve to stroke in update_geometry
Falk David
noreply at git.blender.org
Thu Jun 11 12:23:13 CEST 2020
Commit: 15669c1c02468e52acd96fc03cb5af7802594a39
Author: Falk David
Date: Thu Jun 11 12:22:06 2020 +0200
Branches: soc-2020-greasepencil-curve
https://developer.blender.org/rB15669c1c02468e52acd96fc03cb5af7802594a39
GPencil: Convert from curve to stroke in update_geometry
Call the function BKE_gpencil_stroke_update_geometry_from_editcurve
in BKE_gpencil_stroke_geometry_update and force
an update when curve handles change position in RNA.
===================================================================
M source/blender/blenkernel/intern/gpencil_geom.c
M source/blender/makesrna/intern/rna_gpencil.c
===================================================================
diff --git a/source/blender/blenkernel/intern/gpencil_geom.c b/source/blender/blenkernel/intern/gpencil_geom.c
index d200e4e3a15..9caff009cbe 100644
--- a/source/blender/blenkernel/intern/gpencil_geom.c
+++ b/source/blender/blenkernel/intern/gpencil_geom.c
@@ -40,6 +40,7 @@
#include "BKE_deform.h"
#include "BKE_gpencil.h"
+#include "BKE_gpencil_curve.h"
#include "BKE_gpencil_geom.h"
#include "BKE_object.h"
@@ -1197,6 +1198,11 @@ void BKE_gpencil_stroke_geometry_update(bGPDstroke *gps)
return;
}
+ if (gps->editcurve != NULL && gps->editcurve->flag & GP_CURVE_RECALC_GEOMETRY) {
+ BKE_gpencil_stroke_update_geometry_from_editcurve(gps);
+ gps->editcurve->flag &= ~GP_CURVE_RECALC_GEOMETRY;
+ }
+
if (gps->totpoints > 2) {
BKE_gpencil_stroke_fill_triangulate(gps);
}
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index 1ea27a68d90..c665719928b 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -131,6 +131,7 @@ static const EnumPropertyItem rna_enum_gpencil_caps_modes_items[] = {
#ifdef RNA_RUNTIME
# include "BLI_ghash.h"
+# include "BLI_listbase.h"
# include "BLI_string_utils.h"
# include "WM_api.h"
@@ -151,7 +152,7 @@ static void rna_GPencil_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Pointe
WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
}
-static void rna_GPencil_curve_edit_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+static void rna_GPencil_curve_edit_mode_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
ToolSettings *ts = scene->toolsettings;
bGPdata *gpd = (bGPdata *)ptr->owner_id;
@@ -170,6 +171,28 @@ static void rna_GPencil_curve_edit_update(Main *bmain, Scene *scene, PointerRNA
rna_GPencil_update(bmain, scene, ptr);
}
+static void rna_GPencil_stroke_curve_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ bGPdata *gpd = (bGPdata *)ptr->owner_id;
+
+ if (GPENCIL_CURVE_EDIT_SESSIONS_ON(gpd)) {
+ LISTBASE_FOREACH(bGPDlayer *, gpl, &gpd->layers) {
+ if (gpl->actframe != NULL) {
+ bGPDframe *gpf = gpl->actframe;
+ LISTBASE_FOREACH(bGPDstroke *, gps, &gpf->strokes) {
+ if (gps->editcurve != NULL) {
+ gps->editcurve->flag |= GP_CURVE_RECALC_GEOMETRY;
+ BKE_gpencil_stroke_geometry_update(gps);
+ }
+ }
+ }
+ }
+ }
+
+ /* Standard update. */
+ rna_GPencil_update(bmain, scene, ptr);
+}
+
static void rna_GPencil_dependency_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
{
DEG_id_tag_update(ptr->owner_id, ID_RECALC_TRANSFORM);
@@ -1209,7 +1232,8 @@ static void rna_def_gpencil_curve_point(BlenderRNA *brna)
prop, "rna_BezTriple_handle1_get", "rna_BezTriple_handle1_set", NULL);
RNA_def_property_ui_text(prop, "Handle 1", "Coordinates of the first handle");
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
- RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_stroke_curve_update");
+ // RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_array(prop, 3);
@@ -1217,7 +1241,8 @@ static void rna_def_gpencil_curve_point(BlenderRNA *brna)
prop, "rna_BezTriple_ctrlpoint_get", "rna_BezTriple_ctrlpoint_set", NULL);
RNA_def_property_ui_text(prop, "Control Point", "Coordinates of the control point");
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
- RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_stroke_curve_update");
+ // RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
prop = RNA_def_property(srna, "handle_right", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_array(prop, 3);
@@ -1225,7 +1250,8 @@ static void rna_def_gpencil_curve_point(BlenderRNA *brna)
prop, "rna_BezTriple_handle2_get", "rna_BezTriple_handle2_set", NULL);
RNA_def_property_ui_text(prop, "Handle 2", "Coordinates of the second handle");
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
- RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_stroke_curve_update");
+ // RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "radius");
@@ -2184,7 +2210,7 @@ static void rna_def_gpencil_data(BlenderRNA *brna)
prop = RNA_def_property(srna, "use_curve_edit", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_CURVE_EDIT_MODE);
RNA_def_property_ui_text(prop, "Curve Edit", "Edit strokes using curve handles");
- RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_curve_edit_update");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_curve_edit_mode_update");
prop = RNA_def_property(srna, "use_autolock_layers", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_AUTOLOCK_LAYERS);
More information about the Bf-blender-cvs
mailing list