Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2020-10-15 17:44:39 +0300
committerHans Goudey <h.goudey@me.com>2020-10-15 17:44:39 +0300
commitd1b3439b80fd6e9a0caa653cd55c7a5def18b122 (patch)
treec9d70e6ce66126d436bdb4e1d9307d7f487d064c /source/blender/makesdna
parentbac91956ae9755722b81da4b6a0a394f9f77b2e1 (diff)
Cleanup: Use DNA defaults for grease pencil modifiers
This will make "Reset to Default Value" work properly for grease pencil modifiers. See T80164 for more information.
Diffstat (limited to 'source/blender/makesdna')
-rw-r--r--source/blender/makesdna/DNA_gpencil_modifier_defaults.h286
-rw-r--r--source/blender/makesdna/intern/CMakeLists.txt1
-rw-r--r--source/blender/makesdna/intern/dna_defaults.c42
3 files changed, 329 insertions, 0 deletions
diff --git a/source/blender/makesdna/DNA_gpencil_modifier_defaults.h b/source/blender/makesdna/DNA_gpencil_modifier_defaults.h
new file mode 100644
index 00000000000..44239221df4
--- /dev/null
+++ b/source/blender/makesdna/DNA_gpencil_modifier_defaults.h
@@ -0,0 +1,286 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup DNA
+ */
+
+#pragma once
+
+/* Note that some struct members for colormapping and colorbands are not initialized here. */
+
+/* Struct members on own line. */
+/* clang-format off */
+
+#define _DNA_DEFAULT_ArmatureGpencilModifierData \
+ { \
+ .deformflag = ARM_DEF_VGROUP, \
+ .multi = 0, \
+ .object = NULL, \
+ .vert_coords_prev = NULL, \
+ .vgname = "", \
+ }
+
+#define _DNA_DEFAULT_ArrayGpencilModifierData \
+ { \
+ .object = NULL, \
+ .material = NULL, \
+ .count = 2, \
+ .flag = GP_ARRAY_USE_RELATIVE, \
+ .offset = {0.0f, 0.0f, 0.0f}, \
+ .shift = {1.0f, 0.0f, 0.0f}, \
+ .rnd_offset = {0.0f, 0.0f, 0.0f}, \
+ .rnd_rot = {0.0f, 0.0f, 0.0f}, \
+ .rnd_scale = {0.0f, 0.0f, 0.0f}, \
+ .seed = 1, \
+ .pass_index = 0, \
+ .layername = "", \
+ .mat_rpl = 0, \
+ .layer_pass = 0, \
+ }
+
+/* Deliberately set this range to the half the default frame-range
+ * to have an immediate effect to suggest use-cases. */
+#define _DNA_DEFAULT_BuildGpencilModifierData \
+ { \
+ .material = NULL, \
+ .layername = "", \
+ .pass_index = 0, \
+ .layer_pass = 0, \
+ .start_frame = 1, \
+ .end_frame = 125, \
+ .start_delay = 0.0f, \
+ .length = 100.0f, \
+ .flag = 0, \
+ .mode = 0, \
+ .transition = 0, \
+ .time_alignment = 0, \
+ .percentage_fac = 0.0f, \
+ }
+
+#define _DNA_DEFAULT_ColorGpencilModifierData \
+ { \
+ .material = NULL, \
+ .layername = "", \
+ .pass_index = 0, \
+ .flag = 0, \
+ .hsv = {0.5f, 1.0f, 1.0f}, \
+ .modify_color = GP_MODIFY_COLOR_BOTH, \
+ .layer_pass = 0, \
+ .curve_intensity = NULL, \
+ }
+
+#define _DNA_DEFAULT_HookGpencilModifierData \
+ { \
+ .object = NULL, \
+ .material = NULL, \
+ .subtarget = "", \
+ .layername = "", \
+ .vgname = "", \
+ .pass_index = 0, \
+ .layer_pass = 0, \
+ .flag = 0, \
+ .falloff_type = eGPHook_Falloff_Smooth, \
+ .parentinv = _DNA_DEFAULT_UNIT_M4, \
+ .cent = {0.0f, 0.0f, 0.0f}, \
+ .falloff = 0.0f, \
+ .force = 0.5f, \
+ .curfalloff = NULL, \
+ }
+
+#define _DNA_DEFAULT_LatticeGpencilModifierData \
+ { \
+ .object = NULL, \
+ .material = NULL, \
+ .layername = "", \
+ .vgname = "", \
+ .pass_index = 0, \
+ .flag = 0, \
+ .strength = 1.0f, \
+ .layer_pass = 0, \
+ .cache_data = NULL, \
+ }
+
+#define _DNA_DEFAULT_MirrorGpencilModifierData \
+ { \
+ .object = NULL, \
+ .material = NULL, \
+ .layername = "", \
+ .pass_index = 0, \
+ .flag = GP_MIRROR_AXIS_X, \
+ .layer_pass = 0, \
+ }
+
+#define _DNA_DEFAULT_MultiplyGpencilModifierData \
+ { \
+ .material = NULL, \
+ .layername = "", \
+ .pass_index = 0, \
+ .flag = 0, \
+ .layer_pass = 0, \
+ .flags = 0, \
+ .duplications = 3, \
+ .distance = 0.1f, \
+ .offset = 0.0f, \
+ .fading_center = 0.5f, \
+ .fading_thickness = 0.5f, \
+ .fading_opacity = 0.5f, \
+ .split_angle = DEG2RADF(1.0f), \
+ }
+
+#define _DNA_DEFAULT_NoiseGpencilModifierData \
+ { \
+ .material = NULL, \
+ .layername = "", \
+ .vgname = "", \
+ .pass_index = 0, \
+ .flag = GP_NOISE_FULL_STROKE | GP_NOISE_USE_RANDOM, \
+ .factor = 0.5f, \
+ .factor_strength = 0.0f, \
+ .factor_thickness = 0.0f, \
+ .factor_uvs = 0.0f, \
+ .noise_scale = 0.0f, \
+ .step = 4, \
+ .layer_pass = 0, \
+ .seed = 1, \
+ .curve_intensity = NULL, \
+ }
+
+#define _DNA_DEFAULT_OffsetGpencilModifierData \
+ { \
+ .material = NULL, \
+ .layername = "", \
+ .vgname = "", \
+ .pass_index = 0, \
+ .flag = 0, \
+ .loc = {0.0f, 0.0f, 0.0f}, \
+ .rot = {0.0f, 0.0f, 0.0f}, \
+ .scale = {0.0f, 0.0f, 0.0f}, \
+ .layer_pass = 0, \
+ }
+
+#define _DNA_DEFAULT_OpacityGpencilModifierData \
+ { \
+ .material = NULL, \
+ .layername = "", \
+ .vgname = "", \
+ .pass_index = 0, \
+ .flag = 0, \
+ .factor = 1.0f, \
+ .modify_color = GP_MODIFY_COLOR_BOTH, \
+ .layer_pass = 0, \
+ .hardeness = 1.0f, \
+ .curve_intensity = NULL, \
+ }
+
+#define _DNA_DEFAULT_SimplifyGpencilModifierData \
+ { \
+ .material = NULL, \
+ .layername = "", \
+ .pass_index = 0, \
+ .flag = 0, \
+ .factor = 0.0f, \
+ .mode = 0, \
+ .step = 1, \
+ .layer_pass = 0, \
+ .length = 0.1f, \
+ .distance = 0.1f, \
+ }
+
+#define _DNA_DEFAULT_SmoothGpencilModifierData \
+ { \
+ .material = NULL, \
+ .layername = "", \
+ .vgname = "", \
+ .pass_index = 0, \
+ .flag = GP_SMOOTH_MOD_LOCATION, \
+ .factor = 0.5f, \
+ .step = 1, \
+ .layer_pass = 0, \
+ .curve_intensity = NULL, \
+ }
+
+#define _DNA_DEFAULT_SubdivGpencilModifierData \
+ { \
+ .material = NULL, \
+ .layername = "", \
+ .pass_index = 0, \
+ .flag = 0, \
+ .level = 1, \
+ .layer_pass = 0, \
+ .type = 0, \
+ }
+
+#define _DNA_DEFAULT_TextureGpencilModifierData \
+ { \
+ .material = NULL, \
+ .layername = "", \
+ .vgname = "", \
+ .pass_index = 0, \
+ .flag = 0, \
+ .uv_offset = 0.0f, \
+ .uv_scale = 1.0f, \
+ .fill_rotation = 0.0f, \
+ .fill_offset = {0.0f, 0.0f}, \
+ .fill_scale = 1.0f, \
+ .layer_pass = 0, \
+ .fit_method = GP_TEX_CONSTANT_LENGTH, \
+ .mode = 0, \
+ }
+
+#define _DNA_DEFAULT_ThickGpencilModifierData \
+ { \
+ .material = NULL, \
+ .layername = "", \
+ .vgname = "", \
+ .pass_index = 0, \
+ .flag = 0, \
+ .thickness_fac = 1.0f, \
+ .thickness = 30, \
+ .layer_pass = 0, \
+ }
+
+#define _DNA_DEFAULT_TimeGpencilModifierData \
+ { \
+ .layername = "", \
+ .layer_pass = 0, \
+ .flag = GP_TIME_KEEP_LOOP, \
+ .offset = 1, \
+ .frame_scale = 1.0f, \
+ .mode = 0, \
+ .sfra = 1, \
+ .efra = 250, \
+ }
+
+#define _DNA_DEFAULT_TintGpencilModifierData \
+ { \
+ .object = NULL, \
+ .material = NULL, \
+ .layername = "", \
+ .vgname = "", \
+ .pass_index = 0, \
+ .layer_pass = 0, \
+ .flag = 0, \
+ .mode = GPPAINT_MODE_BOTH, \
+ .factor = 0.5f, \
+ .radius = 1.0f, \
+ .rgb = {1.0f, 1.0f, 1.0f}, \
+ .type = 0, \
+ .curve_intensity = NULL, \
+ .colorband = NULL, \
+ }
+
+/* clang-format off */
diff --git a/source/blender/makesdna/intern/CMakeLists.txt b/source/blender/makesdna/intern/CMakeLists.txt
index 1cb95ea3f83..2051335dd7e 100644
--- a/source/blender/makesdna/intern/CMakeLists.txt
+++ b/source/blender/makesdna/intern/CMakeLists.txt
@@ -144,6 +144,7 @@ set(SRC
../DNA_curve_defaults.h
../DNA_defaults.h
../DNA_fluid_defaults.h
+ ../DNA_gpencil_modifier_defaults.h
../DNA_hair_defaults.h
../DNA_image_defaults.h
../DNA_lattice_defaults.h
diff --git a/source/blender/makesdna/intern/dna_defaults.c b/source/blender/makesdna/intern/dna_defaults.c
index 9aeed636399..8c95a6d2a31 100644
--- a/source/blender/makesdna/intern/dna_defaults.c
+++ b/source/blender/makesdna/intern/dna_defaults.c
@@ -92,6 +92,7 @@
#include "DNA_collection_types.h"
#include "DNA_curve_types.h"
#include "DNA_fluid_types.h"
+#include "DNA_gpencil_modifier_types.h"
#include "DNA_hair_types.h"
#include "DNA_image_types.h"
#include "DNA_key_types.h"
@@ -122,6 +123,7 @@
#include "DNA_collection_defaults.h"
#include "DNA_curve_defaults.h"
#include "DNA_fluid_defaults.h"
+#include "DNA_gpencil_modifier_defaults.h"
#include "DNA_hair_defaults.h"
#include "DNA_image_defaults.h"
#include "DNA_lattice_defaults.h"
@@ -289,6 +291,26 @@ SDNA_DEFAULT_DECL_STRUCT(WeightVGProximityModifierData);
SDNA_DEFAULT_DECL_STRUCT(WeldModifierData);
SDNA_DEFAULT_DECL_STRUCT(WireframeModifierData);
+/* DNA_gpencil_modifier_defaults.h */
+SDNA_DEFAULT_DECL_STRUCT(ArmatureGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(ArrayGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(BuildGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(ColorGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(HookGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(LatticeGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(MirrorGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(MultiplyGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(NoiseGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(OffsetGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(OpacityGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(SimplifyGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(SmoothGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(SubdivGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(TextureGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(ThickGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(TimeGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(TintGpencilModifierData);
+
#undef SDNA_DEFAULT_DECL_STRUCT
/* Reuse existing definitions. */
@@ -488,6 +510,26 @@ const void *DNA_default_table[SDNA_TYPE_MAX] = {
SDNA_DEFAULT_DECL(WeightVGProximityModifierData),
SDNA_DEFAULT_DECL(WeldModifierData),
SDNA_DEFAULT_DECL(WireframeModifierData),
+
+ /* DNA_gpencil_modifier_defaults.h */
+ SDNA_DEFAULT_DECL(ArmatureGpencilModifierData),
+ SDNA_DEFAULT_DECL(ArrayGpencilModifierData),
+ SDNA_DEFAULT_DECL(BuildGpencilModifierData),
+ SDNA_DEFAULT_DECL(ColorGpencilModifierData),
+ SDNA_DEFAULT_DECL(HookGpencilModifierData),
+ SDNA_DEFAULT_DECL(LatticeGpencilModifierData),
+ SDNA_DEFAULT_DECL(MirrorGpencilModifierData),
+ SDNA_DEFAULT_DECL(MultiplyGpencilModifierData),
+ SDNA_DEFAULT_DECL(NoiseGpencilModifierData),
+ SDNA_DEFAULT_DECL(OffsetGpencilModifierData),
+ SDNA_DEFAULT_DECL(OpacityGpencilModifierData),
+ SDNA_DEFAULT_DECL(SimplifyGpencilModifierData),
+ SDNA_DEFAULT_DECL(SmoothGpencilModifierData),
+ SDNA_DEFAULT_DECL(SubdivGpencilModifierData),
+ SDNA_DEFAULT_DECL(TextureGpencilModifierData),
+ SDNA_DEFAULT_DECL(ThickGpencilModifierData),
+ SDNA_DEFAULT_DECL(TimeGpencilModifierData),
+ SDNA_DEFAULT_DECL(TintGpencilModifierData),
};
#undef SDNA_DEFAULT_DECL
#undef SDNA_DEFAULT_DECL_EX