[Bf-blender-cvs] [83980506957] master: Use DNA defaults system for modifiers

Hans Goudey noreply at git.blender.org
Thu Oct 1 16:38:16 CEST 2020


Commit: 83980506957cd4e31e8dc7041672efb256b5c28c
Author: Hans Goudey
Date:   Thu Oct 1 09:38:00 2020 -0500
Branches: master
https://developer.blender.org/rB83980506957cd4e31e8dc7041672efb256b5c28c

Use DNA defaults system for modifiers

As noted in T80164, there are quite a few area of Blender where the
"Reset to Default Value" operator in button context menus doesn't work.
Modifiers are one of them, because the DNA defaults system was never
set up for them.

Additionally, this should make modifier versioning easier. Whenever a
new field is added it should be automatically initialized to the
default value.

I had to make some ordering changes in the following modifiers to work
around an error with `-Wsign-conversion` in the macros:
 - Solidify Modifier
 - Corrective Smooth Modifier
 - Screw Modifier

Some modifiers are special cases and are skipped in this commit:
 - Data Transfer Modifier
 - Cloth Modifier
 - Fluid Modifier
 - Softbody Modifier

Differential Revision: https://developer.blender.org/D8747

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

A	source/blender/makesdna/DNA_modifier_defaults.h
M	source/blender/makesdna/intern/CMakeLists.txt
M	source/blender/makesdna/intern/dna_defaults.c
M	source/blender/makesrna/intern/rna_modifier.c
M	source/blender/modifiers/CMakeLists.txt
M	source/blender/modifiers/intern/MOD_armature.c
M	source/blender/modifiers/intern/MOD_array.c
M	source/blender/modifiers/intern/MOD_bevel.c
M	source/blender/modifiers/intern/MOD_boolean.c
M	source/blender/modifiers/intern/MOD_build.c
M	source/blender/modifiers/intern/MOD_cast.c
M	source/blender/modifiers/intern/MOD_collision.c
M	source/blender/modifiers/intern/MOD_correctivesmooth.c
M	source/blender/modifiers/intern/MOD_curve.c
M	source/blender/modifiers/intern/MOD_decimate.c
M	source/blender/modifiers/intern/MOD_displace.c
M	source/blender/modifiers/intern/MOD_dynamicpaint.c
M	source/blender/modifiers/intern/MOD_edgesplit.c
M	source/blender/modifiers/intern/MOD_explode.c
M	source/blender/modifiers/intern/MOD_hook.c
M	source/blender/modifiers/intern/MOD_laplaciandeform.c
M	source/blender/modifiers/intern/MOD_laplaciansmooth.c
M	source/blender/modifiers/intern/MOD_lattice.c
M	source/blender/modifiers/intern/MOD_mask.cc
M	source/blender/modifiers/intern/MOD_meshcache.c
M	source/blender/modifiers/intern/MOD_meshdeform.c
M	source/blender/modifiers/intern/MOD_meshsequencecache.c
M	source/blender/modifiers/intern/MOD_mirror.c
M	source/blender/modifiers/intern/MOD_multires.c
M	source/blender/modifiers/intern/MOD_normal_edit.c
M	source/blender/modifiers/intern/MOD_ocean.c
M	source/blender/modifiers/intern/MOD_particleinstance.c
M	source/blender/modifiers/intern/MOD_particlesystem.c
M	source/blender/modifiers/intern/MOD_remesh.c
M	source/blender/modifiers/intern/MOD_screw.c
M	source/blender/modifiers/intern/MOD_shrinkwrap.c
M	source/blender/modifiers/intern/MOD_simpledeform.c
M	source/blender/modifiers/intern/MOD_simulation.cc
M	source/blender/modifiers/intern/MOD_skin.c
M	source/blender/modifiers/intern/MOD_smooth.c
M	source/blender/modifiers/intern/MOD_solidify.c
M	source/blender/modifiers/intern/MOD_subsurf.c
M	source/blender/modifiers/intern/MOD_surface.c
M	source/blender/modifiers/intern/MOD_surfacedeform.c
M	source/blender/modifiers/intern/MOD_triangulate.c
M	source/blender/modifiers/intern/MOD_uvproject.c
M	source/blender/modifiers/intern/MOD_uvwarp.c
M	source/blender/modifiers/intern/MOD_warp.c
M	source/blender/modifiers/intern/MOD_wave.c
M	source/blender/modifiers/intern/MOD_weighted_normal.c
M	source/blender/modifiers/intern/MOD_weightvgedit.c
M	source/blender/modifiers/intern/MOD_weightvgmix.c
M	source/blender/modifiers/intern/MOD_weightvgproximity.c
M	source/blender/modifiers/intern/MOD_weld.c
M	source/blender/modifiers/intern/MOD_wireframe.c

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

diff --git a/source/blender/makesdna/DNA_modifier_defaults.h b/source/blender/makesdna/DNA_modifier_defaults.h
new file mode 100644
index 00000000000..400e077e892
--- /dev/null
+++ b/source/blender/makesdna/DNA_modifier_defaults.h
@@ -0,0 +1,728 @@
+/*
+ * 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
+
+/* Struct members on own line. */
+/* clang-format off */
+
+#define _DNA_DEFAULT_ArmatureModifierData \
+  { \
+    .deformflag = ARM_DEF_VGROUP, \
+    .multi = 0.0f, \
+    .object = NULL, \
+    .defgrp_name = "", \
+  }
+
+/* Default to 2 duplicates distributed along the x-axis by an offset of 1 object width. */
+#define _DNA_DEFAULT_ArrayModifierData \
+  { \
+    .start_cap = NULL, \
+    .end_cap = NULL, \
+    .curve_ob = NULL, \
+    .offset_ob = NULL, \
+    .offset = {1.0f, 0.0f, 0.0f}, \
+    .scale = {1.0f, 0.0f, 0.0f}, \
+    .length = 0.0f, \
+    .merge_dist = 0.1f, \
+    .fit_type = MOD_ARR_FIXEDCOUNT, \
+    .offset_type = MOD_ARR_OFF_RELATIVE, \
+    .flags = 0, \
+    .count = 2, \
+    .uv_offset = {0.0f, 0.0f}, \
+  }
+
+#define _DNA_DEFAULT_BevelModifierData \
+  { \
+    .value = 0.1f, \
+    .res = 1, \
+    .flags = 0, \
+    .val_flags = MOD_BEVEL_AMT_OFFSET, \
+    .profile_type = MOD_BEVEL_PROFILE_SUPERELLIPSE, \
+    .lim_flags = 0, \
+    .e_flags = 0, \
+    .mat = -1, \
+    .edge_flags = 0, \
+    .face_str_mode = MOD_BEVEL_FACE_STRENGTH_NONE, \
+    .miter_inner = MOD_BEVEL_MITER_SHARP, \
+    .miter_outer = MOD_BEVEL_MITER_SHARP, \
+    .affect_type = MOD_BEVEL_AFFECT_EDGES, \
+    .profile = 0.5f, \
+    .bevel_angle = DEG2RADF(30.0f), \
+    .spread = 0.1f, \
+    .defgrp_name = "", \
+  }
+
+#define _DNA_DEFAULT_BooleanModifierData \
+  { \
+    .object = NULL, \
+    .collection = NULL, \
+    .double_threshold = 1e-6f, \
+    .operation = eBooleanModifierOp_Difference, \
+    .solver = eBooleanModifierSolver_Exact, \
+    .flag = eBooleanModifierFlag_Object, \
+    .bm_flag = 0, \
+  }
+
+#define _DNA_DEFAULT_BuildModifierData \
+  { \
+    .start = 1.0f, \
+    .length = 100.0f, \
+    .flag = 0, \
+    .randomize = 0, \
+    .seed = 0, \
+  }
+
+#define _DNA_DEFAULT_CastModifierData \
+  { \
+    .object = NULL, \
+    .fac = 0.5f, \
+    .radius = 0.0f, \
+    .size = 0.0f, \
+    .defgrp_name = "", \
+    .flag = MOD_CAST_X | MOD_CAST_Y | MOD_CAST_Z | MOD_CAST_SIZE_FROM_RADIUS, \
+    .type = MOD_CAST_TYPE_SPHERE, \
+  }
+
+/* Cloth modifier skipped for now. */
+
+#define _DNA_DEFAULT_CollisionModifierData \
+  { \
+    .x = NULL, \
+    .xnew = NULL, \
+    .xold = NULL, \
+    .current_xnew = NULL, \
+    .current_x = NULL, \
+    .current_v = NULL, \
+    .current_v = NULL, \
+    .tri = NULL, \
+    .mvert_num = 0, \
+    .tri_num = 0, \
+    .time_x = -1000.0f, \
+    .time_xnew = -1000.0f, \
+    .is_static = false, \
+    .bvhtree = NULL, \
+  }
+
+#define _DNA_DEFAULT_CorrectiveSmoothModifierData \
+  { \
+    .bind_coords = NULL, \
+    .bind_coords_num = 0, \
+    .lambda = 0.5f, \
+    .scale = 1.0f, \
+    .repeat = 5, \
+    .flag = 0, \
+    .smooth_type = MOD_CORRECTIVESMOOTH_SMOOTH_SIMPLE, \
+    .defgrp_name = "", \
+  }
+
+#define _DNA_DEFAULT_CurveModifierData \
+  { \
+    .object = NULL, \
+    .name = "", \
+    .defaxis = MOD_CURVE_POSX, \
+    .flag = 0, \
+  }
+
+/* Defines are scattered accross too many files, they need to be moved to DNA. */
+#if 0
+#define _DNA_DEFAULT_DataTransferModifierData \
+  { \
+    .ob_source = NULL, \
+    .data_types = 0, \
+    .vmap_mode = MREMAP_MODE_VERT_NEAREST, \
+    .emap_mode = MREMAP_MODE_EDGE_NEAREST, \
+    .lmap_mode = MREMAP_MODE_LOOP_NEAREST_POLYNOR, \
+    .pmap_mode = MREMAP_MODE_POLY_NEAREST, \
+    .map_max_distance = 1.0f, \
+    .map_ray_radius = 0.0f, \
+    .islands_precision = 0.0f, \
+    .layers_select_src = {DT_LAYERS_ALL_SRC, DT_LAYERS_ALL_SRC, DT_LAYERS_ALL_SRC, DT_LAYERS_ALL_SRC}, \
+    .layers_select_dst = {DT_LAYERS_NAME_DST, DT_LAYERS_NAME_DST, DT_LAYERS_NAME_DST, DT_LAYERS_NAME_DST}, \
+    .mix_mod = CDT_MIX_TRANSFER, \
+    .mix_factor = 1.0f, \
+    .defgrp_name = "", \
+    .flags = MOD_DATATRANSFER_OBSRC_TRANSFORM, \
+  }
+#endif
+
+#define _DNA_DEFAULT_DecimateModifierData \
+  { \
+    .percent = 1.0f, \
+    .iter = 0, \
+    .delimit = 0, \
+    .symmetry_axis = 0, \
+    .angle = DEG2RADF(5.0f), \
+    .defgrp_name = "", \
+    .defgrp_factor = 1.0f, \
+    .flag = 0, \
+    .mode = 0, \
+    .face_count = 0, \
+  }
+
+#define _DNA_DEFAULT_DisplaceModifierData \
+  { \
+    .texture = NULL, \
+    .map_object = NULL, \
+    .map_bone = "", \
+    .uvlayer_name = "", \
+    .uvlayer_tmp = 0, \
+    .texmapping = 0, \
+    .strength = 1.0f, \
+    .direction = MOD_DISP_DIR_NOR, \
+    .defgrp_name = "", \
+    .midlevel = 0.5f, \
+    .space = MOD_DISP_SPACE_LOCAL, \
+    .flag = 0, \
+  }
+
+#define _DNA_DEFAULT_DynamicPaintModifierData \
+  { \
+    .canvas = NULL, \
+    .brush = NULL, \
+    .type = MOD_DYNAMICPAINT_TYPE_CANVAS, \
+  }
+
+/* Default to 30-degree split angle, sharpness from both angle & flag. */
+#define _DNA_DEFAULT_EdgeSplitModifierData \
+  { \
+    .split_angle = DEG2RADF(30.0f), \
+    .flags = MOD_EDGESPLIT_FROMANGLE | MOD_EDGESPLIT_FROMFLAG, \
+  }
+
+#define _DNA_DEFAULT_ExplodeModifierData \
+  { \
+    .facepa = NULL, \
+    .flag = eExplodeFlag_Unborn | eExplodeFlag_Alive | eExplodeFlag_Dead, \
+    .vgroup = 0, \
+    .protect = 0.0f, \
+    .uvname = "", \
+  }
+
+/* Fluid modifier settings skipped for now. */
+
+#define _DNA_DEFAULT_HookModifierData \
+  { \
+    .subtarget = "", \
+    .flag = 0, \
+    .falloff_type = eHook_Falloff_Smooth, \
+    .parentinv = _DNA_DEFAULT_UNIT_M4, \
+    .cent = {0.0f, 0.0f, 0.0f}, \
+    .falloff = 0.0f, \
+    .curfalloff = NULL, \
+    .indexar = NULL, \
+    .totindex = 0, \
+    .force = 1.0f, \
+    .name = "", \
+  }
+
+#define _DNA_DEFAULT_LaplacianDeformModifierData \
+  { \
+    .anchor_grp_name = "", \
+    .total_verts = 0, \
+    .repeat = 1, \
+    .vertexco = NULL, \
+    .cache_system = NULL, \
+    .flag = 0, \
+  }
+
+#define _DNA_DEFAULT_LaplacianSmoothModifierData \
+  { \
+    .lambda = 0.01f, \
+    .lambda_border = 0.01f, \
+    .defgrp_name = "", \
+    .flag = MOD_LAPLACIANSMOOTH_X | MOD_LAPLACIANSMOOTH_Y | MOD_LAPLACIANSMOOTH_Z | \
+            MOD_LAPLACIANSMOOTH_PRESERVE_VOLUME | MOD_LAPLACIANSMOOTH_NORMALIZED, \
+    .repeat = 1, \
+  }
+
+#define _DNA_DEFAULT_LatticeModifierData \
+  { \
+    .object = NULL, \
+    .name = "", \
+    .strength = 1.0f, \
+    .flag = 0, \
+  }
+
+#define _DNA_DEFAULT_MaskModifierData \
+  { \
+    .ob_arm = NULL, \
+    .vgroup = "", \
+    .mode = 0, \
+    .flag = 0, \
+    .threshold = 0.0f, \
+  }
+
+/* Y and Z forward and up axes, Blender default. */
+#define _DNA_DEFAULT_MeshCacheModifierData \
+  { \
+    .flag = 0, \
+    .type = MOD_MESHCACHE_TYPE_MDD, \
+    .time_mode = 0, \
+    .play_mode = 0, \
+    .forward_axis = 1, \
+    .up_axis = 2, \
+    .flip_axis = 0, \
+    .interp = MOD_MESHCACHE_INTERP_LINEAR, \
+    .factor = 1.0f, \
+    .deform_mode = 0.0f, \
+    .frame_start = 0.0f, \
+    .frame_scale = 1.0f, \
+    .eval_frame = 0.0f, \
+    .eval_time = 0.0f, \
+    .eval_factor = 0.0f, \
+    .filepath = "", \
+  }
+
+#define _DNA_DEFAULT_MeshDeformModifierData \
+  { \
+    .object = 0, \
+    .defgrp_name = "", \
+    .gridsize = 5, \
+    .flag = 0, \
+    .bindinfluences = NULL, \
+    .bindoffsets = NULL, \
+    .bindcagecos = NULL, \
+    .totvert = 0, \
+    .totcagevert = 0, \
+    .dyngrid = NULL, \
+    .dyninfluences = NULL, \
+    .dynverts = NULL, \
+    .dyngridsize = 0, \
+    .totinfluence = 0, \
+    .dyncellmin = {0.0f, 0.0f, 0.0f}, \
+    .dyncellwidth = 0.0f, \
+    .bindmat = _DNA_DEFAULT_UNIT_M4, \
+    .bindweights = NULL, \
+    .bindcos = NULL, \
+    .bindfunc = NULL, \
+  }
+
+#define _DNA_DEFAULT_MeshSeqCacheModifierData \
+  { \
+    .cache_file = NULL, \
+    .object_path = "", \
+    .read_flag = MOD_MESHSEQ_READ_VERT | MOD_MESHSEQ_READ_POLY | MOD_MESHSEQ_READ_UV | MOD_MESHSEQ_READ_COLOR, \
+    .velocity_scale = 1.0f, \
+    .reader = NULL, \
+    .reader_object_path = "", \
+    .vertex_velocities = NULL, \
+    .num_vertices = 0, \
+    .velocity_delta = 0.0f, \
+    .last_lookup_time = 0.0f, \
+  }
+
+#define _DNA_DEFAULT_MirrorModifierData \
+  { \
+    .flag = MOD_MIR_AXIS_X | MOD_MIR_VGROUP, \
+    .tolerance = 0.001f, \
+    .uv_offset = {0.0f, 0.0f}, \
+    .uv_offset_copy = {0.0f, 0.0f}, \
+    .mirror_ob = NULL, \
+  }
+
+#define _DNA_DEFAULT_MultiresModifierData \
+  { \
+    .lvl = 0, \
+    .sculptlvl = 0, \
+    .renderlvl = 0, \
+    .totlvl = 0, \
+    .simple = 0, \
+    .flags = eMultiresModifierFlag_UseCrease | eMultiresModifierFlag_ControlEdges, \
+    .uv_smooth = SUBSURF_UV_SMOOTH_PRESERVE_CORNERS, \
+    .quality = 4, \
+    .boundary_smooth = SUBSURF_BOUNDARY_SMOOTH_ALL, \
+  }
+
+#define _DNA_DEFAULT_NormalEditModifierData \
+  { \
+    .defgrp_name = "", \
+    .target = NULL, \
+    .mode = MOD_NORMALEDIT_MODE_RADIAL, \
+    .flag = 0, \
+    .mix_mode = MOD_NORMALEDIT_MIX_COPY, \
+    .mix_factor = 1.0f, \
+    .mix_limit = M_PI, \
+    .offset = {0.0f, 0.0f, 0.0f}, \
+  }
+
+/* Some fields are initialized in #initData. */
+#define _DNA_DEFAULT_OceanModifierData \
+  { \
+    .ocean = NULL, \
+    .oceancache = NULL, \
+    .resolution = 7, \
+    .viewport_resolution = 7, \
+    .spatial_size = 50, \
+    .wind_velocity = 30.0f, \
+    .damp = 0.5f, \
+    .smallest_wav

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list