[Bf-blender-cvs] [19fe1f1f75b] temp-gpencil-bezier-stroke-type: GPencil: Move Curve Fit parameters to Toolsettings
Antonio Vazquez
noreply at git.blender.org
Fri Apr 30 17:40:13 CEST 2021
Commit: 19fe1f1f75b04f14da43dfd1faad75fe7e0bb592
Author: Antonio Vazquez
Date: Fri Apr 30 17:39:44 2021 +0200
Branches: temp-gpencil-bezier-stroke-type
https://developer.blender.org/rB19fe1f1f75b04f14da43dfd1faad75fe7e0bb592
GPencil: Move Curve Fit parameters to Toolsettings
UI is provisional.
===================================================================
M release/scripts/startup/bl_app_templates_system/2D_Animation/__init__.py
M release/scripts/startup/bl_ui/space_view3d.py
M source/blender/blenkernel/intern/gpencil.c
M source/blender/blenkernel/intern/gpencil_geom.c
M source/blender/blenloader/intern/versioning_290.c
M source/blender/blenloader/intern/versioning_300.c
M source/blender/makesdna/DNA_gpencil_types.h
M source/blender/makesdna/DNA_scene_defaults.h
M source/blender/makesdna/DNA_scene_types.h
M source/blender/makesdna/intern/dna_defaults.c
M source/blender/makesrna/intern/rna_gpencil.c
M source/blender/makesrna/intern/rna_scene.c
===================================================================
diff --git a/release/scripts/startup/bl_app_templates_system/2D_Animation/__init__.py b/release/scripts/startup/bl_app_templates_system/2D_Animation/__init__.py
index 192ba2cf5b5..9d47dd74887 100644
--- a/release/scripts/startup/bl_app_templates_system/2D_Animation/__init__.py
+++ b/release/scripts/startup/bl_app_templates_system/2D_Animation/__init__.py
@@ -59,6 +59,8 @@ def load_handler(dummy):
scene = bpy.data.scenes[0]
if scene:
scene.tool_settings.use_keyframe_insert_auto = True
+ scene.tool_settings.gpencil_curve_fit_threshold = 0.1
+ scene.tool_settings.gpencil_curve_fit_corner_angle = 1.57079632679489661923
for ob in scene.objects:
if ob.type == 'GPENCIL':
gpd = ob.data
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 3eb202e2c80..529aca5c580 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -660,6 +660,17 @@ class VIEW3D_HT_header(Header):
sub.separator(factor=0.4)
sub.prop(tool_settings, "use_gpencil_draw_additive", text="", icon='FREEZE')
+ # Curve fit
+ row = layout.row(align=True)
+ row.prop(tool_settings, "use_gpencil_curve_fit", text="",
+ icon='IPO_BEZIER')
+ sub = row.row(align=True)
+ sub.active = tool_settings.use_gpencil_curve_fit
+ sub.popover(
+ panel="VIEW3D_PT_gpencil_curve_fit",
+ text="Curve Fit",
+ )
+
# Select mode for Editing
if gpd.use_stroke_edit_mode:
row = layout.row(align=True)
@@ -7021,6 +7032,21 @@ class VIEW3D_PT_gpencil_multi_frame(Panel):
layout.template_curve_mapping(settings, "multiframe_falloff_curve", brush=True)
+# Grease Pencil Object - Curve Editing settings
+class VIEW3D_PT_gpencil_curve_fit(Panel):
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'HEADER'
+ bl_label = "Curve Fit"
+
+ def draw(self, context):
+ layout = self.layout
+
+ tool_settings = context.tool_settings
+ col = layout.column(align=True)
+ col.prop(tool_settings, "gpencil_curve_fit_threshold")
+ col.prop(tool_settings, "gpencil_curve_fit_corner_angle")
+
+
class VIEW3D_MT_gpencil_edit_context_menu(Menu):
bl_label = ""
@@ -7620,6 +7646,7 @@ classes = (
VIEW3D_MT_gpencil_simplify,
VIEW3D_MT_gpencil_copy_layer,
VIEW3D_MT_gpencil_autoweights,
+ VIEW3D_PT_gpencil_curve_fit,
VIEW3D_MT_gpencil_edit_context_menu,
VIEW3D_MT_edit_curve,
VIEW3D_MT_edit_curve_ctrlpoints,
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 7d3a1f7fd18..3a6dd435558 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -772,8 +772,6 @@ bGPdata *BKE_gpencil_data_addnew(Main *bmain, const char name[])
gpd->pixfactor = GP_DEFAULT_PIX_FACTOR;
gpd->curve_edit_resolution = GP_DEFAULT_CURVE_RESOLUTION;
- gpd->curve_edit_threshold = GP_DEFAULT_CURVE_ERROR;
- gpd->curve_edit_corner_angle = GP_DEFAULT_CURVE_EDIT_CORNER_ANGLE;
/* use adaptive curve resolution by default */
gpd->flag |= GP_DATA_CURVE_ADAPTIVE_RESOLUTION;
diff --git a/source/blender/blenkernel/intern/gpencil_geom.c b/source/blender/blenkernel/intern/gpencil_geom.c
index b4fca17be30..2cc2f47625b 100644
--- a/source/blender/blenkernel/intern/gpencil_geom.c
+++ b/source/blender/blenkernel/intern/gpencil_geom.c
@@ -1316,11 +1316,12 @@ void BKE_gpencil_stroke_geometry_update(bGPdata *gpd,
/* Update curve points first if it's a bezier stroke. */
if (GPENCIL_STROKE_TYPE_BEZIER(gps)) {
/* Refit the curve to the polyline points. */
- if (GP_GEO_UPDATE_CURVE_REFIT_ANY(flag)) {
- const float threshold = gpd->curve_edit_threshold;
- const float corner_angle = gpd->curve_edit_corner_angle;
- BKE_gpencil_stroke_editcurve_update(gps, threshold, corner_angle, flag);
- }
+ // TODO GPXX (These lines must be removed and moved to new function)
+ // if (GP_GEO_UPDATE_CURVE_REFIT_ANY(flag)) {
+ // const float threshold = gpd->curve_edit_threshold;
+ // const float corner_angle = gpd->curve_edit_corner_angle;
+ // BKE_gpencil_stroke_editcurve_update(gps, threshold, corner_angle, flag);
+ //}
/* Regenerate the polyline points from the curve data. */
if (GP_GEO_UPDATE_POLYLINE_REGENERATE_ANY(flag)) {
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index 916c4bf0cad..31bc730e777 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -1691,13 +1691,6 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
gpd->flag |= GP_DATA_CURVE_ADAPTIVE_RESOLUTION;
}
}
- /* Init grease pencil curve editing error threshold. */
- if (!DNA_struct_elem_find(fd->filesdna, "bGPdata", "float", "curve_edit_threshold")) {
- LISTBASE_FOREACH (bGPdata *, gpd, &bmain->gpencils) {
- gpd->curve_edit_threshold = GP_DEFAULT_CURVE_ERROR;
- gpd->curve_edit_corner_angle = GP_DEFAULT_CURVE_EDIT_CORNER_ANGLE;
- }
- }
}
if ((!MAIN_VERSION_ATLEAST(bmain, 292, 14)) ||
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index 6b13b21f057..b0f5ccbf0f1 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -21,9 +21,11 @@
#define DNA_DEPRECATED_ALLOW
#include "BLI_listbase.h"
+#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "DNA_genfile.h"
+#include "DNA_gpencil_types.h"
#include "DNA_modifier_types.h"
#include "BKE_main.h"
@@ -76,5 +78,16 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
}
+
+ /* Init grease pencil curve editing error threshold. */
+ if (!DNA_struct_elem_find(
+ fd->filesdna, "ToolSettings", "float", "gpencil_curve_fit_threshold")) {
+ LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
+ if (scene->toolsettings->sequencer_tool_settings == NULL) {
+ scene->toolsettings->gpencil_curve_fit_threshold = GP_DEFAULT_CURVE_ERROR;
+ scene->toolsettings->gpencil_curve_fit_corner_angle = GP_DEFAULT_CURVE_EDIT_CORNER_ANGLE;
+ }
+ }
+ }
}
}
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index b6308283def..5b0c4497d02 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -664,10 +664,6 @@ typedef struct bGPdata {
int flag;
/** Default resolution for generated curves using curve editing method. */
int curve_edit_resolution;
- /** Curve Editing error threshold. */
- float curve_edit_threshold;
- /** Curve Editing corner angle (less or equal is treated as corner). */
- float curve_edit_corner_angle;
/* Palettes */
/** List of bGPDpalette's - Deprecated (2.78 - 2.79 only). */
diff --git a/source/blender/makesdna/DNA_scene_defaults.h b/source/blender/makesdna/DNA_scene_defaults.h
index 1a2a8892e64..cf09c277af5 100644
--- a/source/blender/makesdna/DNA_scene_defaults.h
+++ b/source/blender/makesdna/DNA_scene_defaults.h
@@ -376,6 +376,9 @@
.gpencil_v2d_align = GP_PROJECT_VIEWSPACE, \
.gpencil_seq_align = GP_PROJECT_VIEWSPACE, \
.gpencil_ima_align = GP_PROJECT_VIEWSPACE, \
+ /* GP Curve Fitting */ \
+ .gpencil_curve_fit_threshold = GP_DEFAULT_CURVE_ERROR, \
+ .gpencil_curve_fit_corner_angle = GP_DEFAULT_CURVE_EDIT_CORNER_ANGLE,\
}
/* clang-format off */
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index c7f7e610a1a..9eab03c988e 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -482,7 +482,7 @@ typedef struct ImageFormatData {
#define R_IMF_IMTYPE_INVALID 255
/** #ImageFormatData.flag */
-#define R_IMF_FLAG_ZBUF (1 << 0) /* was R_OPENEXR_ZBUF */
+#define R_IMF_FLAG_ZBUF (1 << 0) /* was R_OPENEXR_ZBUF */
#define R_IMF_FLAG_PREVIEW_JPG (1 << 1) /* was R_PREVIEW_JPG */
/* Return values from #BKE_imtype_valid_depths, note this is depths per channel. */
@@ -524,8 +524,8 @@ typedef enum eImageFormatDepth {
/** #ImageFormatData.jp2_flag */
#define R_IMF_JP2_FLAG_YCC (1 << 0) /* when disabled use RGB */ /* was R_JPEG2K_YCC */
-#define R_IMF_JP2_FLAG_CINE_PRESET (1 << 1) /* was R_JPEG2K_CINE_PRESET */
-#define R_IMF_JP2_FLAG_CINE_48 (1 << 2) /* was R_JPEG2K_CINE_48FPS */
+#define R_IMF_JP2_FLAG_CINE_PRESET (1 << 1) /* was R_JPEG2K_CINE_PRESET */
+#define R_IMF_JP2_FLAG_CINE_48 (1 << 2) /* was R_JPEG2K_CINE_48FPS */
/** #ImageFormatData.jp2_codec */
#define R_IMF_JP2_CODEC_JP2 0
@@ -1428,6 +1428,11 @@ typedef struct ToolSettings {
/* Particle Editing */
struct ParticleEditSettings particle;
+ /** Curve Fit error threshold. */
+ float gpencil_curve_fit_threshold;
+ /** Curve Fit corner angle (less or equal is treated as corner). */
+ float gpencil_curve_fit_corner_angle;
+
/* Transform Proportional Area of Effect */
float proportional_size;
@@ -1832,12 +1837,12 @@ typedef struct Scene {
#define R_MODE_UNUSED_20 (1 << 20) /* cleared */
#define R_MODE_UNUSED_21 (1 << 21) /* cleared */
-#define R_NO_OVERWRITE (1 << 22) /* skip existing files */
-#define R_TOUCH (1 << 23) /* touch files before rendering */
+#define R_NO_OVERWRITE (1 << 22) /* skip existing files */
+#define R_TOUCH (1 << 23) /* touch files before rendering */
#define R_SIMPLIFY (1 << 24)
-#define R_EDGE_FRS (1 << 25) /* R_EDGE reserved for Freestyle */
+#define R_EDGE_FRS (1 << 25) /* R_EDGE reserved for Freestyle */
#define R_PERSISTENT_DATA (1 << 26) /* keep data around for re-render */
-#define R_MODE_UNUSED_27 (1 << 27) /* cleared */
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list