[Bf-blender-cvs] [874ecabc910] temp-lineart-contained: Lineart: Chnage modifier to use new default system

Antonio Vazquez noreply at git.blender.org
Sat Feb 20 16:23:15 CET 2021


Commit: 874ecabc9102fb80eaa5f197db8c305ea672d0ce
Author: Antonio Vazquez
Date:   Sat Feb 20 16:23:09 2021 +0100
Branches: temp-lineart-contained
https://developer.blender.org/rB874ecabc9102fb80eaa5f197db8c305ea672d0ce

Lineart: Chnage modifier to use new default system

Now all defaults are defined in `DNA_gpencil_modifier_defaults.h`

===================================================================

M	source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
M	source/blender/makesdna/DNA_gpencil_modifier_defaults.h
M	source/blender/makesdna/intern/dna_defaults.c
M	source/blender/makesrna/intern/rna_gpencil_modifier.c

===================================================================

diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
index 6249e385c9d..c2ebbe42e19 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
@@ -31,6 +31,7 @@
 #include "BLT_translation.h"
 
 #include "DNA_collection_types.h"
+#include "DNA_defaults.h"
 #include "DNA_gpencil_modifier_types.h"
 #include "DNA_gpencil_types.h"
 #include "DNA_lineart_types.h"
@@ -70,16 +71,11 @@
 
 static void initData(GpencilModifierData *md)
 {
-  LineartGpencilModifierData *lmd = (LineartGpencilModifierData *)md;
-  lmd->line_types = LRT_EDGE_FLAG_ALL_TYPE;
-  lmd->thickness = 25;
-  lmd->opacity = 1.0f;
-  lmd->flags |= LRT_GPENCIL_MATCH_OUTPUT_VGROUP;
-  lmd->crease_threshold = DEG2RAD(140.0f);
-  lmd->calculation_flags |= (LRT_ALLOW_DUPLI_OBJECTS | LRT_REMOVE_DOUBLES);
-  lmd->angle_splitting_threshold = DEG2RAD(60.0f);
-  lmd->chaining_geometry_threshold = 0.001f;
-  lmd->chaining_image_threshold = 0.001f;
+  LineartGpencilModifierData *gpmd = (LineartGpencilModifierData *)md;
+
+  BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(gpmd, modifier));
+
+  MEMCPY_STRUCT_AFTER(gpmd, DNA_struct_default_get(LineartGpencilModifierData), modifier);
 }
 
 static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
diff --git a/source/blender/makesdna/DNA_gpencil_modifier_defaults.h b/source/blender/makesdna/DNA_gpencil_modifier_defaults.h
index 11d4ee1b2cd..baf2b2414fa 100644
--- a/source/blender/makesdna/DNA_gpencil_modifier_defaults.h
+++ b/source/blender/makesdna/DNA_gpencil_modifier_defaults.h
@@ -283,4 +283,17 @@
     .colorband = NULL, \
   }
 
+#define _DNA_DEFAULT_LineartGpencilModifierData \
+  { \
+    .line_types = LRT_EDGE_FLAG_ALL_TYPE, \
+    .thickness = 25, \
+    .opacity = 1.0f, \
+    .flags = LRT_GPENCIL_MATCH_OUTPUT_VGROUP | LRT_GPENCIL_SOFT_SELECTION, \
+    .crease_threshold = DEG2RAD(140.0f), \
+    .calculation_flags = LRT_ALLOW_DUPLI_OBJECTS | LRT_REMOVE_DOUBLES | LRT_ALLOW_OVERLAPPING_EDGES | LRT_ALLOW_CLIPPING_BOUNDARIES, \
+    .angle_splitting_threshold = DEG2RAD(60.0f), \
+    .chaining_geometry_threshold = 0.001f, \
+    .chaining_image_threshold = 0.001f, \
+  }
+
 /* clang-format off */
diff --git a/source/blender/makesdna/intern/dna_defaults.c b/source/blender/makesdna/intern/dna_defaults.c
index 3e4d5d87fb0..5fb3811720b 100644
--- a/source/blender/makesdna/intern/dna_defaults.c
+++ b/source/blender/makesdna/intern/dna_defaults.c
@@ -315,6 +315,7 @@ SDNA_DEFAULT_DECL_STRUCT(TextureGpencilModifierData);
 SDNA_DEFAULT_DECL_STRUCT(ThickGpencilModifierData);
 SDNA_DEFAULT_DECL_STRUCT(TimeGpencilModifierData);
 SDNA_DEFAULT_DECL_STRUCT(TintGpencilModifierData);
+SDNA_DEFAULT_DECL_STRUCT(LineartGpencilModifierData);
 
 #undef SDNA_DEFAULT_DECL_STRUCT
 
@@ -538,6 +539,7 @@ const void *DNA_default_table[SDNA_TYPE_MAX] = {
     SDNA_DEFAULT_DECL(ThickGpencilModifierData),
     SDNA_DEFAULT_DECL(TimeGpencilModifierData),
     SDNA_DEFAULT_DECL(TintGpencilModifierData),
+    SDNA_DEFAULT_DECL(LineartGpencilModifierData),
 };
 #undef SDNA_DEFAULT_DECL
 #undef SDNA_DEFAULT_DECL_EX
diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c
index ff3a1e7c55c..78a3b0a691f 100644
--- a/source/blender/makesrna/intern/rna_gpencil_modifier.c
+++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c
@@ -2333,7 +2333,6 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna)
 
   prop = RNA_def_property(srna, "fuzzy_intersections", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "calculation_flags", LRT_INTERSECTION_AS_CONTOUR);
-  RNA_def_property_boolean_default(prop, 0);
   RNA_def_property_ui_text(
       prop,
       "Intersection As Contour",
@@ -2342,7 +2341,6 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna)
 
   prop = RNA_def_property(srna, "fuzzy_everything", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "calculation_flags", LRT_EVERYTHING_AS_CONTOUR);
-  RNA_def_property_boolean_default(prop, 0);
   RNA_def_property_ui_text(prop,
                            "All Lines As Contour",
                            "Treat all lines as contour so those lines can be chained together");
@@ -2350,7 +2348,6 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna)
 
   prop = RNA_def_property(srna, "allow_duplication", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "calculation_flags", LRT_ALLOW_DUPLI_OBJECTS);
-  RNA_def_property_boolean_default(prop, 1);
   RNA_def_property_ui_text(
       prop,
       "Instanced Objects",
@@ -2359,7 +2356,6 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna)
 
   prop = RNA_def_property(srna, "allow_overlapping_edges", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "calculation_flags", LRT_ALLOW_OVERLAPPING_EDGES);
-  RNA_def_property_boolean_default(prop, 1);
   RNA_def_property_ui_text(prop,
                            "Handle Overlapping Edges",
                            "Allow lines from edge split to show properly, may run slower");
@@ -2367,7 +2363,6 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna)
 
   prop = RNA_def_property(srna, "allow_clipping_boundaries", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "calculation_flags", LRT_ALLOW_CLIPPING_BOUNDARIES);
-  RNA_def_property_boolean_default(prop, 1);
   RNA_def_property_ui_text(
       prop, "Clipping Boundaries", "Allow lines on near/far clipping plane to be shown");
   RNA_def_property_update(prop, NC_SCENE, "rna_GpencilModifier_update");
@@ -2380,7 +2375,6 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna)
   RNA_def_property_update(prop, NC_SCENE, "rna_GpencilModifier_update");
 
   prop = RNA_def_property(srna, "angle_splitting_threshold", PROP_FLOAT, PROP_ANGLE);
-  RNA_def_property_float_default(prop, DEG2RAD(60.0f));
   RNA_def_property_ui_text(
       prop, "Angle Splitting", "Angle in screen space below which a stroke is split in two");
   /*  Don't allow value very close to PI, or we get a lot of small segments.*/
@@ -2390,13 +2384,11 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna)
 
   prop = RNA_def_property(srna, "remove_doubles", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "calculation_flags", LRT_REMOVE_DOUBLES);
-  RNA_def_property_boolean_default(prop, 0);
   RNA_def_property_ui_text(
       prop, "Remove Doubles", "Remove doubles when line art is loading geometries");
   RNA_def_property_update(prop, NC_SCENE, "rna_GpencilModifier_update");
 
   prop = RNA_def_property(srna, "chaining_geometry_threshold", PROP_FLOAT, PROP_DISTANCE);
-  RNA_def_property_float_default(prop, 0.01f);
   RNA_def_property_ui_text(prop,
                            "Geometry Threshold",
                            "Segments where their geometric distance between them lower than this "
@@ -2406,7 +2398,6 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna)
   RNA_def_property_update(prop, NC_SCENE, "rna_GpencilModifier_update");
 
   prop = RNA_def_property(srna, "chaining_image_threshold", PROP_FLOAT, PROP_DISTANCE);
-  RNA_def_property_float_default(prop, 0.01f);
   RNA_def_property_ui_text(
       prop,
       "Image Threshold",
@@ -2470,14 +2461,12 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna)
   RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
 
   prop = RNA_def_property(srna, "level_start", PROP_INT, PROP_NONE);
-  RNA_def_property_int_default(prop, 0);
   RNA_def_property_ui_text(
       prop, "Level Start", "Minimum level of occlusion level that gets selected");
   RNA_def_property_range(prop, 0, 128);
   RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
 
   prop = RNA_def_property(srna, "level_end", PROP_INT, PROP_NONE);
-  RNA_def_property_int_default(prop, 0);
   RNA_def_property_ui_text(
       prop, "Level End", "Maximum level of occlusion level that gets selected");
   RNA_def_property_range(prop, 0, 128);
@@ -2510,40 +2499,34 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna)
   RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
 
   prop = RNA_def_property(srna, "invert_source_vertex_group", PROP_BOOLEAN, PROP_NONE);
-  RNA_def_property_boolean_default(prop, 0);
   RNA_def_property_boolean_sdna(prop, NULL, "flags", LRT_GPENCIL_INVERT_SOURCE_VGROUP);
   RNA_def_property_ui_text(prop, "Invert Source", "Invert source vertex group values");
   RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
 
   prop = RNA_def_property(srna, "match_output_vertex_group", PROP_BOOLEAN, PROP_NONE);
-  RNA_def_property_boolean_default(prop, 1);
   RNA_def_property_boolean_sdna(prop, NULL, "flags", LRT_GPENCIL_MATCH_OUTPUT_VGROUP);
   RNA_def_property_ui_text(prop, "Match Output", "Match output vertex group");
   RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
 
   prop = RNA_def_property(srna, "soft_selection", PROP_BOOLEAN, PROP_NONE);
-  RNA_def_property_boolean_default(prop, 1);
   RNA_def_property_boolean_sdna(prop, NULL, "flags", LRT_GPENCIL_SOFT_SELECTION);
   RNA_def_property_ui_text(
       prop, "Soft selection", "Preserve original vertex weight instead of clipping to 0/1");
   RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
 
   prop = RNA_def_property(srna, "thickness", PROP_INT, PROP_NONE);
-  RNA_def_property_int_default(prop, 20);
   RNA_def_property_ui_text(prop, "Thickness", "The thickness that used to generate strokes");
   RNA_def_property_ui_range(prop, 1, 100, 1, 1);
   RNA_def_property_range(prop, 1, 200);
   RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
 
   prop = RNA_def_property(srna, "opacity", PROP_FLOAT, PROP_FACTOR);
-  RNA_def_property_float_default(prop, 0.1f);
   RNA_def_property_ui_text(prop, "Opacity", "The strength value used to generate strokes");
   RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.01f, 2);
   RNA_def_property_range(prop, 0.0f, 1.0f);
   RNA_def_property_update(prop, 0, "rna_GpencilModifier_update")

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list