1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
17 /** \file
18  * \ingroup RNA
19  */
20 
21 #include <float.h>
22 #include <limits.h>
23 #include <stdlib.h>
24 
25 #include "DNA_armature_types.h"
26 #include "DNA_cachefile_types.h"
27 #include "DNA_mesh_types.h"
28 #include "DNA_modifier_types.h"
29 #include "DNA_object_force_types.h"
30 #include "DNA_object_types.h"
31 #include "DNA_scene_types.h"
32 #include "DNA_simulation_types.h"
33 
34 #include "MEM_guardedalloc.h"
35 
36 #include "BLI_math.h"
37 
38 #include "BLT_translation.h"
39 
40 #include "BKE_animsys.h"
41 #include "BKE_curveprofile.h"
42 #include "BKE_data_transfer.h"
43 #include "BKE_dynamicpaint.h"
44 #include "BKE_effect.h"
45 #include "BKE_fluid.h" /* For BKE_fluid_modifier_free & BKE_fluid_modifier_create_type_data */
46 #include "BKE_mesh_mapping.h"
47 #include "BKE_mesh_remap.h"
48 #include "BKE_multires.h"
49 #include "BKE_ocean.h"
50 
51 #include "RNA_access.h"
52 #include "RNA_define.h"
53 #include "RNA_enum_types.h"
54 
55 #include "rna_internal.h"
56 
57 #include "WM_api.h"
58 #include "WM_types.h"
59 
60 const EnumPropertyItem rna_enum_object_modifier_type_items[] = {
61     {0, "", 0, N_("Modify"), ""},
62     {eModifierType_DataTransfer,
63      "DATA_TRANSFER",
64      ICON_MOD_DATA_TRANSFER,
65      "Data Transfer",
66      "Transfer several types of data (vertex groups, UV maps, vertex colors, custom normals) from "
67      "one mesh to another"},
68     {eModifierType_MeshCache,
69      "MESH_CACHE",
70      ICON_MOD_MESHDEFORM,
71      "Mesh Cache",
72      "Deform the mesh using an external frame-by-frame vertex transform cache"},
73     {eModifierType_MeshSequenceCache,
74      "MESH_SEQUENCE_CACHE",
75      ICON_MOD_MESHDEFORM,
76      "Mesh Sequence Cache",
77      "Deform the mesh or curve using an external mesh cache in Alembic format"},
78     {eModifierType_NormalEdit,
79      "NORMAL_EDIT",
80      ICON_MOD_NORMALEDIT,
81      "Normal Edit",
82      "Modify the direction of the surface normals"},
83     {eModifierType_WeightedNormal,
84      "WEIGHTED_NORMAL",
85      ICON_MOD_NORMALEDIT,
86      "Weighted Normal",
87      "Modify the direction of the surface normals using a weighting method"},
88     {eModifierType_UVProject,
89      "UV_PROJECT",
90      ICON_MOD_UVPROJECT,
91      "UV Project",
92      "Project the UV map coordinates from the negative Z axis of another object"},
93     {eModifierType_UVWarp,
94      "UV_WARP",
95      ICON_MOD_UVPROJECT,
96      "UV Warp",
97      "Transform the UV map using the difference between two objects"},
98     {eModifierType_WeightVGEdit,
99      "VERTEX_WEIGHT_EDIT",
100      ICON_MOD_VERTEX_WEIGHT,
101      "Vertex Weight Edit",
102      "Modify of the weights of a vertex group"},
103     {eModifierType_WeightVGMix,
104      "VERTEX_WEIGHT_MIX",
105      ICON_MOD_VERTEX_WEIGHT,
106      "Vertex Weight Mix",
107      "Mix the weights of two vertex groups"},
108     {eModifierType_WeightVGProximity,
109      "VERTEX_WEIGHT_PROXIMITY",
110      ICON_MOD_VERTEX_WEIGHT,
111      "Vertex Weight Proximity",
112      "Set the vertex group weights based on the distance to another target object"},
113     {0, "", 0, N_("Generate"), ""},
114     {eModifierType_Array,
115      "ARRAY",
116      ICON_MOD_ARRAY,
117      "Array",
118      "Create copies of the shape with offsets"},
119     {eModifierType_Bevel,
120      "BEVEL",
121      ICON_MOD_BEVEL,
122      "Bevel",
123      "Generate sloped corners by adding geometry to the mesh's edges or vertices"},
124     {eModifierType_Boolean,
125      "BOOLEAN",
126      ICON_MOD_BOOLEAN,
127      "Boolean",
128      "Use another shape to cut, combine or perform a difference operation"},
129     {eModifierType_Build,
130      "BUILD",
131      ICON_MOD_BUILD,
132      "Build",
133      "Cause the faces of the mesh object to appear or disappear one after the other over time"},
134     {eModifierType_Decimate,
135      "DECIMATE",
136      ICON_MOD_DECIM,
137      "Decimate",
138      "Reduce the geometry density"},
139     {eModifierType_EdgeSplit,
140      "EDGE_SPLIT",
141      ICON_MOD_EDGESPLIT,
142      "Edge Split",
143      "Split away joined faces at the edges"},
144     {eModifierType_Mask,
145      "MASK",
146      ICON_MOD_MASK,
147      "Mask",
148      "Dynamically hide vertices based on a vertex group or armature"},
149     {eModifierType_Mirror,
150      "MIRROR",
151      ICON_MOD_MIRROR,
152      "Mirror",
153      "Mirror along the local X, Y and/or Z axes, over the object origin"},
154     {eModifierType_MeshToVolume,
155      "MESH_TO_VOLUME",
156      ICON_VOLUME_DATA,
157      "Mesh to Volume",
158      ""}, /* TODO: Use correct icon. */
159     {eModifierType_Multires,
160      "MULTIRES",
161      ICON_MOD_MULTIRES,
162      "Multiresolution",
163      "Subdivide the mesh in a way that allows editing the higher subdivision levels"},
164     {eModifierType_Remesh,
165      "REMESH",
166      ICON_MOD_REMESH,
167      "Remesh",
168      "Generate new mesh topology based on the current shape"},
169     {eModifierType_Screw,
170      "SCREW",
171      ICON_MOD_SCREW,
172      "Screw",
173      "Lathe around an axis, treating the input mesh as a profile"},
174     {eModifierType_Skin,
175      "SKIN",
176      ICON_MOD_SKIN,
177      "Skin",
178      "Create a solid shape from vertices and edges, using the vertex radius to define the "
179      "thickness"},
180     {eModifierType_Solidify, "SOLIDIFY", ICON_MOD_SOLIDIFY, "Solidify", " Make the surface thick"},
181     {eModifierType_Subsurf,
182      "SUBSURF",
183      ICON_MOD_SUBSURF,
184      "Subdivision Surface",
185      "Split the faces into smaller parts, giving it a smoother appearance"},
186     {eModifierType_Triangulate,
187      "TRIANGULATE",
188      ICON_MOD_TRIANGULATE,
189      "Triangulate",
190      "Convert all polygons to triangles"},
191     {eModifierType_VolumeToMesh,
192      "VOLUME_TO_MESH",
193      ICON_VOLUME_DATA,
194      "Volume to Mesh",
195      ""}, /* TODO: Use correct icon. */
196     {eModifierType_Weld,
197      "WELD",
198      ICON_AUTOMERGE_OFF,
199      "Weld",
200      "Find groups of vertices closer than dist and merges them together"},
201     {eModifierType_Wireframe,
202      "WIREFRAME",
203      ICON_MOD_WIREFRAME,
204      "Wireframe",
205      "Convert faces into thickened edges"},
206     {0, "", 0, N_("Deform"), ""},
207     {eModifierType_Armature,
208      "ARMATURE",
209      ICON_MOD_ARMATURE,
210      "Armature",
211      "Deform the shape using an armature object"},
212     {eModifierType_Cast,
213      "CAST",
214      ICON_MOD_CAST,
215      "Cast",
216      "Shift the shape towards a predefined primitive"},
217     {eModifierType_Curve, "CURVE", ICON_MOD_CURVE, "Curve", "Bend the mesh using a curve object"},
218     {eModifierType_Displace,
219      "DISPLACE",
220      ICON_MOD_DISPLACE,
221      "Displace",
222      "Offset vertices based on a texture"},
223     {eModifierType_Hook, "HOOK", ICON_HOOK, "Hook", "Deform specific points using another object"},
224     {eModifierType_LaplacianDeform,
225      "LAPLACIANDEFORM",
226      ICON_MOD_MESHDEFORM,
227      "Laplacian Deform",
228      "Deform based a series of anchor points"},
229     {eModifierType_Lattice,
230      "LATTICE",
231      ICON_MOD_LATTICE,
232      "Lattice",
233      "Deform using the shape of a lattice object"},
234     {eModifierType_MeshDeform,
235      "MESH_DEFORM",
236      ICON_MOD_MESHDEFORM,
237      "Mesh Deform",
238      "Deform using a different mesh, which acts as a deformation cage"},
239     {eModifierType_Shrinkwrap,
240      "SHRINKWRAP",
241      ICON_MOD_SHRINKWRAP,
242      "Shrinkwrap",
243      "Project the shape onto another object"},
244     {eModifierType_SimpleDeform,
245      "SIMPLE_DEFORM",
246      ICON_MOD_SIMPLEDEFORM,
247      "Simple Deform",
248      "Deform the shape by twisting, bending, tapering or stretching"},
249     {eModifierType_Smooth,
250      "SMOOTH",
251      ICON_MOD_SMOOTH,
252      "Smooth",
253      "Smooth the mesh by flattening the angles between adjacent faces"},
254     {eModifierType_CorrectiveSmooth,
255      "CORRECTIVE_SMOOTH",
256      ICON_MOD_SMOOTH,
257      "Smooth Corrective",
258      "Smooth the mesh while still preserving the volume"},
259     {eModifierType_LaplacianSmooth,
260      "LAPLACIANSMOOTH",
261      ICON_MOD_SMOOTH,
262      "Smooth Laplacian",
263      "Reduce the noise on a mesh surface with minimal changes to its shape"},
264     {eModifierType_SurfaceDeform,
265      "SURFACE_DEFORM",
266      ICON_MOD_MESHDEFORM,
267      "Surface Deform",
268      "Transfer motion from another mesh"},
269     {eModifierType_Warp,
270      "WARP",
271      ICON_MOD_WARP,
272      "Warp",
273      "Warp parts of a mesh to a new location in a very flexible way thanks to 2 specified "
274      "objects"},
275     {eModifierType_Wave,
276      "WAVE",
277      ICON_MOD_WAVE,
278      "Wave",
279      "Adds a ripple-like motion to an object’s geometry"},
280     {eModifierType_VolumeDisplace,
281      "VOLUME_DISPLACE",
282      ICON_VOLUME_DATA,
283      "Volume Displace",
284      "Deform volume based on noise or other vector fields"}, /* TODO: Use correct icon. */
285     {0, "", 0, N_("Physics"), ""},
286     {eModifierType_Cloth, "CLOTH", ICON_MOD_CLOTH, "Cloth", ""},
287     {eModifierType_Collision, "COLLISION", ICON_MOD_PHYSICS, "Collision", ""},
288     {eModifierType_DynamicPaint, "DYNAMIC_PAINT", ICON_MOD_DYNAMICPAINT, "Dynamic Paint", ""},
289     {eModifierType_Explode,
290      "EXPLODE",
291      ICON_MOD_EXPLODE,
292      "Explode",
293      "Break apart the mesh faces and let them follow particles"},
294     {eModifierType_Fluid, "FLUID", ICON_MOD_FLUIDSIM, "Fluid", ""},
295     {eModifierType_Ocean, "OCEAN", ICON_MOD_OCEAN, "Ocean", "Generate a moving ocean surface"},
296     {eModifierType_ParticleInstance,
297      "PARTICLE_INSTANCE",
298      ICON_MOD_PARTICLE_INSTANCE,
299      "Particle Instance",
300      ""},
301     {eModifierType_ParticleSystem,
302      "PARTICLE_SYSTEM",
303      ICON_MOD_PARTICLES,
304      "Particle System",
305      "Spawn particles from the shape"},
306     {eModifierType_Softbody, "SOFT_BODY", ICON_MOD_SOFT, "Soft Body", ""},
307     {eModifierType_Surface, "SURFACE", ICON_MODIFIER, "Surface", ""},
308     {eModifierType_Simulation,
309      "SIMULATION",
310      ICON_PHYSICS,
311      "Simulation",
312      ""}, /* TODO: Use correct icon. */
313     {0, NULL, 0, NULL, NULL},
314 };
315 
316 const EnumPropertyItem rna_enum_modifier_triangulate_quad_method_items[] = {
317     {MOD_TRIANGULATE_QUAD_BEAUTY,
318      "BEAUTY",
319      0,
320      "Beauty",
321      "Split the quads in nice triangles, slower method"},
322     {MOD_TRIANGULATE_QUAD_FIXED,
323      "FIXED",
324      0,
325      "Fixed",
326      "Split the quads on the first and third vertices"},
327     {MOD_TRIANGULATE_QUAD_ALTERNATE,
328      "FIXED_ALTERNATE",
329      0,
330      "Fixed Alternate",
331      "Split the quads on the 2nd and 4th vertices"},
332     {MOD_TRIANGULATE_QUAD_SHORTEDGE,
333      "SHORTEST_DIAGONAL",
334      0,
335      "Shortest Diagonal",
336      "Split the quads based on the distance between the vertices"},
337     {0, NULL, 0, NULL, NULL},
338 };
339 
340 const EnumPropertyItem rna_enum_modifier_triangulate_ngon_method_items[] = {
341     {MOD_TRIANGULATE_NGON_BEAUTY,
342      "BEAUTY",
343      0,
344      "Beauty",
345      "Arrange the new triangles evenly (slow)"},
346     {MOD_TRIANGULATE_NGON_EARCLIP,
347      "CLIP",
348      0,
349      "Clip",
350      "Split the polygons with an ear clipping algorithm"},
351     {0, NULL, 0, NULL, NULL},
352 };
353 
354 const EnumPropertyItem rna_enum_modifier_shrinkwrap_mode_items[] = {
355     {MOD_SHRINKWRAP_ON_SURFACE,
356      "ON_SURFACE",
357      0,
358      "On Surface",
359      "The point is constrained to the surface of the target object, "
360      "with distance offset towards the original point location"},
361     {MOD_SHRINKWRAP_INSIDE,
362      "INSIDE",
363      0,
364      "Inside",
365      "The point is constrained to be inside the target object"},
366     {MOD_SHRINKWRAP_OUTSIDE,
367      "OUTSIDE",
368      0,
369      "Outside",
370      "The point is constrained to be outside the target object"},
371     {MOD_SHRINKWRAP_OUTSIDE_SURFACE,
372      "OUTSIDE_SURFACE",
373      0,
374      "Outside Surface",
375      "The point is constrained to the surface of the target object, "
376      "with distance offset always to the outside, towards or away from the original location"},
377     {MOD_SHRINKWRAP_ABOVE_SURFACE,
378      "ABOVE_SURFACE",
379      0,
380      "Above Surface",
381      "The point is constrained to the surface of the target object, "
382      "with distance offset applied exactly along the target normal"},
383     {0, NULL, 0, NULL, NULL},
384 };
385 
386 #ifndef RNA_RUNTIME
387 /* use eWarp_Falloff_*** & eHook_Falloff_***, they're in sync */
388 static const EnumPropertyItem modifier_warp_falloff_items[] = {
389     {eWarp_Falloff_None, "NONE", 0, "No Falloff", ""},
390     {eWarp_Falloff_Curve, "CURVE", 0, "Curve", ""},
391     {eWarp_Falloff_Smooth, "SMOOTH", ICON_SMOOTHCURVE, "Smooth", ""},
392     {eWarp_Falloff_Sphere, "SPHERE", ICON_SPHERECURVE, "Sphere", ""},
393     {eWarp_Falloff_Root, "ROOT", ICON_ROOTCURVE, "Root", ""},
394     {eWarp_Falloff_InvSquare, "INVERSE_SQUARE", ICON_ROOTCURVE, "Inverse Square", ""},
395     {eWarp_Falloff_Sharp, "SHARP", ICON_SHARPCURVE, "Sharp", ""},
396     {eWarp_Falloff_Linear, "LINEAR", ICON_LINCURVE, "Linear", ""},
397     {eWarp_Falloff_Const, "CONSTANT", ICON_NOCURVE, "Constant", ""},
398     {0, NULL, 0, NULL, NULL},
399 };
400 #endif
401 
402 /* ***** Data Transfer ***** */
403 
404 const EnumPropertyItem rna_enum_dt_method_vertex_items[] = {
405     {MREMAP_MODE_TOPOLOGY, "TOPOLOGY", 0, "Topology", "Copy from identical topology meshes"},
406     {MREMAP_MODE_VERT_NEAREST, "NEAREST", 0, "Nearest Vertex", "Copy from closest vertex"},
407     {MREMAP_MODE_VERT_EDGE_NEAREST,
408      "EDGE_NEAREST",
409      0,
410      "Nearest Edge Vertex",
411      "Copy from closest vertex of closest edge"},
412     {MREMAP_MODE_VERT_EDGEINTERP_NEAREST,
413      "EDGEINTERP_NEAREST",
414      0,
415      "Nearest Edge Interpolated",
416      "Copy from interpolated values of vertices from closest point on closest edge"},
417     {MREMAP_MODE_VERT_POLY_NEAREST,
418      "POLY_NEAREST",
419      0,
420      "Nearest Face Vertex",
421      "Copy from closest vertex of closest face"},
422     {MREMAP_MODE_VERT_POLYINTERP_NEAREST,
423      "POLYINTERP_NEAREST",
424      0,
425      "Nearest Face Interpolated",
426      "Copy from interpolated values of vertices from closest point on closest face"},
427     {MREMAP_MODE_VERT_POLYINTERP_VNORPROJ,
428      "POLYINTERP_VNORPROJ",
429      0,
430      "Projected Face Interpolated",
431      "Copy from interpolated values of vertices from point on closest face hit by "
432      "normal-projection"},
433     {0, NULL, 0, NULL, NULL},
434 };
435 
436 const EnumPropertyItem rna_enum_dt_method_edge_items[] = {
437     {MREMAP_MODE_TOPOLOGY, "TOPOLOGY", 0, "Topology", "Copy from identical topology meshes"},
438     {MREMAP_MODE_EDGE_VERT_NEAREST,
439      "VERT_NEAREST",
440      0,
441      "Nearest Vertices",
442      "Copy from most similar edge (edge which vertices are the closest of destination edge's "
443      "ones)"},
444     {MREMAP_MODE_EDGE_NEAREST,
445      "NEAREST",
446      0,
447      "Nearest Edge",
448      "Copy from closest edge (using midpoints)"},
449     {MREMAP_MODE_EDGE_POLY_NEAREST,
450      "POLY_NEAREST",
451      0,
452      "Nearest Face Edge",
453      "Copy from closest edge of closest face (using midpoints)"},
454     {MREMAP_MODE_EDGE_EDGEINTERP_VNORPROJ,
455      "EDGEINTERP_VNORPROJ",
456      0,
457      "Projected Edge Interpolated",
458      "Interpolate all source edges hit by the projection of destination one along its own normal "
459      "(from vertices)"},
460     {0, NULL, 0, NULL, NULL},
461 };
462 
463 const EnumPropertyItem rna_enum_dt_method_loop_items[] = {
464     {MREMAP_MODE_TOPOLOGY, "TOPOLOGY", 0, "Topology", "Copy from identical topology meshes"},
465     {MREMAP_MODE_LOOP_NEAREST_LOOPNOR,
466      "NEAREST_NORMAL",
467      0,
468      "Nearest Corner And Best Matching Normal",
469      "Copy from nearest corner which has the best matching normal"},
470     {MREMAP_MODE_LOOP_NEAREST_POLYNOR,
471      "NEAREST_POLYNOR",
472      0,
473      "Nearest Corner And Best Matching Face Normal",
474      "Copy from nearest corner which has the face with the best matching normal to destination "
475      "corner's face one"},
476     {MREMAP_MODE_LOOP_POLY_NEAREST,
477      "NEAREST_POLY",
478      0,
479      "Nearest Corner Of Nearest Face",
480      "Copy from nearest corner of nearest polygon"},
481     {MREMAP_MODE_LOOP_POLYINTERP_NEAREST,
482      "POLYINTERP_NEAREST",
483      0,
484      "Nearest Face Interpolated",
485      "Copy from interpolated corners of the nearest source polygon"},
486     {MREMAP_MODE_LOOP_POLYINTERP_LNORPROJ,
487      "POLYINTERP_LNORPROJ",
488      0,
489      "Projected Face Interpolated",
490      "Copy from interpolated corners of the source polygon hit by corner normal projection"},
491     {0, NULL, 0, NULL, NULL},
492 };
493 
494 const EnumPropertyItem rna_enum_dt_method_poly_items[] = {
495     {MREMAP_MODE_TOPOLOGY, "TOPOLOGY", 0, "Topology", "Copy from identical topology meshes"},
496     {MREMAP_MODE_POLY_NEAREST,
497      "NEAREST",
498      0,
499      "Nearest Face",
500      "Copy from nearest polygon (using center points)"},
501     {MREMAP_MODE_POLY_NOR,
502      "NORMAL",
503      0,
504      "Best Normal-Matching",
505      "Copy from source polygon which normal is the closest to destination one"},
506     {MREMAP_MODE_POLY_POLYINTERP_PNORPROJ,
507      "POLYINTERP_PNORPROJ",
508      0,
509      "Projected Face Interpolated",
510      "Interpolate all source polygons intersected by the projection of destination one along its "
511      "own normal"},
512     {0, NULL, 0, NULL, NULL},
513 };
514 
515 const EnumPropertyItem rna_enum_dt_mix_mode_items[] = {
516     {CDT_MIX_TRANSFER, "REPLACE", 0, "Replace", "Overwrite all elements' data"},
517     {CDT_MIX_REPLACE_ABOVE_THRESHOLD,
518      "ABOVE_THRESHOLD",
519      0,
520      "Above Threshold",
521      "Only replace destination elements where data is above given threshold (exact behavior "
522      "depends on data type)"},
523     {CDT_MIX_REPLACE_BELOW_THRESHOLD,
524      "BELOW_THRESHOLD",
525      0,
526      "Below Threshold",
527      "Only replace destination elements where data is below given threshold (exact behavior "
528      "depends on data type)"},
529     {CDT_MIX_MIX,
530      "MIX",
531      0,
532      "Mix",
533      "Mix source value into destination one, using given threshold as factor"},
534     {CDT_MIX_ADD,
535      "ADD",
536      0,
537      "Add",
538      "Add source value to destination one, using given threshold as factor"},
539     {CDT_MIX_SUB,
540      "SUB",
541      0,
542      "Subtract",
543      "Subtract source value to destination one, using given threshold as factor"},
544     {CDT_MIX_MUL,
545      "MUL",
546      0,
547      "Multiply",
548      "Multiply source value to destination one, using given threshold as factor"},
549     /* etc. etc. */
550     {0, NULL, 0, NULL, NULL},
551 };
552 
553 const EnumPropertyItem rna_enum_dt_layers_select_src_items[] = {
554     {DT_LAYERS_ACTIVE_SRC, "ACTIVE", 0, "Active Layer", "Only transfer active data layer"},
555     {DT_LAYERS_ALL_SRC, "ALL", 0, "All Layers", "Transfer all data layers"},
556     {DT_LAYERS_VGROUP_SRC_BONE_SELECT,
557      "BONE_SELECT",
558      0,
559      "Selected Pose Bones",
560      "Transfer all vertex groups used by selected pose bones"},
561     {DT_LAYERS_VGROUP_SRC_BONE_DEFORM,
562      "BONE_DEFORM",
563      0,
564      "Deform Pose Bones",
565      "Transfer all vertex groups used by deform bones"},
566     {0, NULL, 0, NULL, NULL},
567 };
568 
569 const EnumPropertyItem rna_enum_dt_layers_select_dst_items[] = {
570     {DT_LAYERS_ACTIVE_DST, "ACTIVE", 0, "Active Layer", "Affect active data layer of all targets"},
571     {DT_LAYERS_NAME_DST, "NAME", 0, "By Name", "Match target data layers to affect by name"},
572     {DT_LAYERS_INDEX_DST,
573      "INDEX",
574      0,
575      "By Order",
576      "Match target data layers to affect by order (indices)"},
577     {0, NULL, 0, NULL, NULL},
578 };
579 
580 const EnumPropertyItem rna_enum_axis_xy_items[] = {
581     {0, "X", 0, "X", ""},
582     {1, "Y", 0, "Y", ""},
583     {0, NULL, 0, NULL, NULL},
584 };
585 
586 const EnumPropertyItem rna_enum_axis_xyz_items[] = {
587     {0, "X", 0, "X", ""},
588     {1, "Y", 0, "Y", ""},
589     {2, "Z", 0, "Z", ""},
590     {0, NULL, 0, NULL, NULL},
591 };
592 
593 const EnumPropertyItem rna_enum_axis_flag_xyz_items[] = {
594     {(1 << 0), "X", 0, "X", ""},
595     {(1 << 1), "Y", 0, "Y", ""},
596     {(1 << 2), "Z", 0, "Z", ""},
597     {0, NULL, 0, NULL, NULL},
598 };
599 
600 #ifdef RNA_RUNTIME
601 #  include "DNA_curve_types.h"
602 #  include "DNA_fluid_types.h"
603 #  include "DNA_particle_types.h"
604 
605 #  include "BKE_cachefile.h"
606 #  include "BKE_context.h"
607 #  include "BKE_mesh_runtime.h"
608 #  include "BKE_modifier.h"
609 #  include "BKE_object.h"
610 #  include "BKE_particle.h"
611 
612 #  include "BLI_sort_utils.h"
613 
614 #  include "DEG_depsgraph.h"
615 #  include "DEG_depsgraph_build.h"
616 #  include "DEG_depsgraph_query.h"
617 
618 #  ifdef WITH_ALEMBIC
619 #    include "ABC_alembic.h"
620 #  endif
621 
rna_UVProject_projectors_begin(CollectionPropertyIterator * iter,PointerRNA * ptr)622 static void rna_UVProject_projectors_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
623 {
624   UVProjectModifierData *uvp = (UVProjectModifierData *)ptr->data;
625   rna_iterator_array_begin(
626       iter, (void *)uvp->projectors, sizeof(Object *), uvp->num_projectors, 0, NULL);
627 }
628 
rna_Modifier_refine(struct PointerRNA * ptr)629 static StructRNA *rna_Modifier_refine(struct PointerRNA *ptr)
630 {
631   ModifierData *md = (ModifierData *)ptr->data;
632   const ModifierTypeInfo *modifier_type = BKE_modifier_get_info(md->type);
633   if (modifier_type != NULL) {
634     return modifier_type->srna;
635   }
636   return &RNA_Modifier;
637 }
638 
rna_Modifier_name_set(PointerRNA * ptr,const char * value)639 static void rna_Modifier_name_set(PointerRNA *ptr, const char *value)
640 {
641   ModifierData *md = ptr->data;
642   char oldname[sizeof(md->name)];
643 
644   /* make a copy of the old name first */
645   BLI_strncpy(oldname, md->name, sizeof(md->name));
646 
647   /* copy the new name into the name slot */
648   BLI_strncpy_utf8(md->name, value, sizeof(md->name));
649 
650   /* make sure the name is truly unique */
651   if (ptr->owner_id) {
652     Object *ob = (Object *)ptr->owner_id;
653     BKE_modifier_unique_name(&ob->modifiers, md);
654   }
655 
656   /* fix all the animation data which may link to this */
657   BKE_animdata_fix_paths_rename_all(NULL, "modifiers", oldname, md->name);
658 }
659 
rna_Modifier_path(PointerRNA * ptr)660 static char *rna_Modifier_path(PointerRNA *ptr)
661 {
662   ModifierData *md = ptr->data;
663   char name_esc[sizeof(md->name) * 2];
664 
665   BLI_strescape(name_esc, md->name, sizeof(name_esc));
666   return BLI_sprintfN("modifiers[\"%s\"]", name_esc);
667 }
668 
rna_Modifier_update(Main * UNUSED (bmain),Scene * UNUSED (scene),PointerRNA * ptr)669 static void rna_Modifier_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
670 {
671   DEG_id_tag_update(ptr->owner_id, ID_RECALC_GEOMETRY);
672   WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ptr->owner_id);
673 }
674 
rna_Modifier_dependency_update(Main * bmain,Scene * scene,PointerRNA * ptr)675 static void rna_Modifier_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr)
676 {
677   rna_Modifier_update(bmain, scene, ptr);
678   DEG_relations_tag_update(bmain);
679 }
680 
681 /* Vertex Groups */
682 
683 #  define RNA_MOD_VGROUP_NAME_SET(_type, _prop) \
684     static void rna_##_type##Modifier_##_prop##_set(PointerRNA *ptr, const char *value) \
685     { \
686       _type##ModifierData *tmd = (_type##ModifierData *)ptr->data; \
687       rna_object_vgroup_name_set(ptr, value, tmd->_prop, sizeof(tmd->_prop)); \
688     }
689 
690 RNA_MOD_VGROUP_NAME_SET(Armature, defgrp_name);
691 RNA_MOD_VGROUP_NAME_SET(Bevel, defgrp_name);
692 RNA_MOD_VGROUP_NAME_SET(Cast, defgrp_name);
693 RNA_MOD_VGROUP_NAME_SET(Curve, name);
694 RNA_MOD_VGROUP_NAME_SET(DataTransfer, defgrp_name);
695 RNA_MOD_VGROUP_NAME_SET(Decimate, defgrp_name);
696 RNA_MOD_VGROUP_NAME_SET(CorrectiveSmooth, defgrp_name);
697 RNA_MOD_VGROUP_NAME_SET(Displace, defgrp_name);
698 RNA_MOD_VGROUP_NAME_SET(Hook, name);
699 RNA_MOD_VGROUP_NAME_SET(LaplacianDeform, anchor_grp_name);
700 RNA_MOD_VGROUP_NAME_SET(LaplacianSmooth, defgrp_name);
701 RNA_MOD_VGROUP_NAME_SET(Lattice, name);
702 RNA_MOD_VGROUP_NAME_SET(Mask, vgroup);
703 RNA_MOD_VGROUP_NAME_SET(MeshDeform, defgrp_name);
704 RNA_MOD_VGROUP_NAME_SET(NormalEdit, defgrp_name);
705 RNA_MOD_VGROUP_NAME_SET(Shrinkwrap, vgroup_name);
706 RNA_MOD_VGROUP_NAME_SET(SimpleDeform, vgroup_name);
707 RNA_MOD_VGROUP_NAME_SET(Smooth, defgrp_name);
708 RNA_MOD_VGROUP_NAME_SET(Solidify, defgrp_name);
709 RNA_MOD_VGROUP_NAME_SET(Solidify, shell_defgrp_name);
710 RNA_MOD_VGROUP_NAME_SET(Solidify, rim_defgrp_name);
711 RNA_MOD_VGROUP_NAME_SET(SurfaceDeform, defgrp_name);
712 RNA_MOD_VGROUP_NAME_SET(UVWarp, vgroup_name);
713 RNA_MOD_VGROUP_NAME_SET(Warp, defgrp_name);
714 RNA_MOD_VGROUP_NAME_SET(Wave, defgrp_name);
715 RNA_MOD_VGROUP_NAME_SET(WeightVGEdit, defgrp_name);
716 RNA_MOD_VGROUP_NAME_SET(WeightVGEdit, mask_defgrp_name);
717 RNA_MOD_VGROUP_NAME_SET(WeightVGMix, defgrp_name_a);
718 RNA_MOD_VGROUP_NAME_SET(WeightVGMix, defgrp_name_b);
719 RNA_MOD_VGROUP_NAME_SET(WeightVGMix, mask_defgrp_name);
720 RNA_MOD_VGROUP_NAME_SET(WeightVGProximity, defgrp_name);
721 RNA_MOD_VGROUP_NAME_SET(WeightVGProximity, mask_defgrp_name);
722 RNA_MOD_VGROUP_NAME_SET(WeightedNormal, defgrp_name);
723 RNA_MOD_VGROUP_NAME_SET(Weld, defgrp_name);
724 RNA_MOD_VGROUP_NAME_SET(Wireframe, defgrp_name);
725 
rna_ExplodeModifier_vgroup_get(PointerRNA * ptr,char * value)726 static void rna_ExplodeModifier_vgroup_get(PointerRNA *ptr, char *value)
727 {
728   ExplodeModifierData *emd = (ExplodeModifierData *)ptr->data;
729   rna_object_vgroup_name_index_get(ptr, value, emd->vgroup);
730 }
731 
rna_ExplodeModifier_vgroup_length(PointerRNA * ptr)732 static int rna_ExplodeModifier_vgroup_length(PointerRNA *ptr)
733 {
734   ExplodeModifierData *emd = (ExplodeModifierData *)ptr->data;
735   return rna_object_vgroup_name_index_length(ptr, emd->vgroup);
736 }
737 
rna_ExplodeModifier_vgroup_set(PointerRNA * ptr,const char * value)738 static void rna_ExplodeModifier_vgroup_set(PointerRNA *ptr, const char *value)
739 {
740   ExplodeModifierData *emd = (ExplodeModifierData *)ptr->data;
741   rna_object_vgroup_name_index_set(ptr, value, &emd->vgroup);
742 }
743 
744 #  undef RNA_MOD_VGROUP_NAME_SET
745 
746 /* UV layers */
747 
748 #  define RNA_MOD_UVLAYER_NAME_SET(_type, _prop) \
749     static void rna_##_type##Modifier_##_prop##_set(PointerRNA *ptr, const char *value) \
750     { \
751       _type##ModifierData *tmd = (_type##ModifierData *)ptr->data; \
752       rna_object_uvlayer_name_set(ptr, value, tmd->_prop, sizeof(tmd->_prop)); \
753     }
754 
755 RNA_MOD_UVLAYER_NAME_SET(MappingInfo, uvlayer_name);
756 RNA_MOD_UVLAYER_NAME_SET(UVProject, uvlayer_name);
757 RNA_MOD_UVLAYER_NAME_SET(UVWarp, uvlayer_name);
758 RNA_MOD_UVLAYER_NAME_SET(WeightVGEdit, mask_tex_uvlayer_name);
759 RNA_MOD_UVLAYER_NAME_SET(WeightVGMix, mask_tex_uvlayer_name);
760 RNA_MOD_UVLAYER_NAME_SET(WeightVGProximity, mask_tex_uvlayer_name);
761 
762 #  undef RNA_MOD_UVLAYER_NAME_SET
763 
764 /* Objects */
765 
modifier_object_set(Object * self,Object ** ob_p,int type,PointerRNA value)766 static void modifier_object_set(Object *self, Object **ob_p, int type, PointerRNA value)
767 {
768   Object *ob = value.data;
769 
770   if (!self || ob != self) {
771     if (!ob || type == OB_EMPTY || ob->type == type) {
772       id_lib_extern((ID *)ob);
773       *ob_p = ob;
774     }
775   }
776 }
777 
778 #  define RNA_MOD_OBJECT_SET(_type, _prop, _obtype) \
779     static void rna_##_type##Modifier_##_prop##_set( \
780         PointerRNA *ptr, PointerRNA value, struct ReportList *UNUSED(reports)) \
781     { \
782       _type##ModifierData *tmd = (_type##ModifierData *)ptr->data; \
783       modifier_object_set((Object *)ptr->owner_id, &tmd->_prop, _obtype, value); \
784     }
785 
786 RNA_MOD_OBJECT_SET(Armature, object, OB_ARMATURE);
787 RNA_MOD_OBJECT_SET(Array, start_cap, OB_MESH);
788 RNA_MOD_OBJECT_SET(Array, end_cap, OB_MESH);
789 RNA_MOD_OBJECT_SET(Array, curve_ob, OB_CURVE);
790 RNA_MOD_OBJECT_SET(Boolean, object, OB_MESH);
791 RNA_MOD_OBJECT_SET(Cast, object, OB_EMPTY);
792 RNA_MOD_OBJECT_SET(Curve, object, OB_CURVE);
793 RNA_MOD_OBJECT_SET(DataTransfer, ob_source, OB_MESH);
794 RNA_MOD_OBJECT_SET(Lattice, object, OB_LATTICE);
795 RNA_MOD_OBJECT_SET(Mask, ob_arm, OB_ARMATURE);
796 RNA_MOD_OBJECT_SET(MeshDeform, object, OB_MESH);
797 RNA_MOD_OBJECT_SET(NormalEdit, target, OB_EMPTY);
798 RNA_MOD_OBJECT_SET(Shrinkwrap, target, OB_MESH);
799 RNA_MOD_OBJECT_SET(Shrinkwrap, auxTarget, OB_MESH);
800 RNA_MOD_OBJECT_SET(SurfaceDeform, target, OB_MESH);
801 
rna_HookModifier_object_set(PointerRNA * ptr,PointerRNA value,struct ReportList * UNUSED (reports))802 static void rna_HookModifier_object_set(PointerRNA *ptr,
803                                         PointerRNA value,
804                                         struct ReportList *UNUSED(reports))
805 {
806   Object *owner = (Object *)ptr->owner_id;
807   HookModifierData *hmd = ptr->data;
808   Object *ob = (Object *)value.data;
809 
810   hmd->object = ob;
811   id_lib_extern((ID *)ob);
812   BKE_object_modifier_hook_reset(owner, hmd);
813 }
814 
rna_HookModifier_object_override_apply(Main * UNUSED (bmain),PointerRNA * ptr_dst,PointerRNA * ptr_src,PointerRNA * ptr_storage,PropertyRNA * prop_dst,PropertyRNA * prop_src,PropertyRNA * UNUSED (prop_storage),const int len_dst,const int len_src,const int len_storage,PointerRNA * UNUSED (ptr_item_dst),PointerRNA * UNUSED (ptr_item_src),PointerRNA * UNUSED (ptr_item_storage),IDOverrideLibraryPropertyOperation * opop)815 static bool rna_HookModifier_object_override_apply(Main *UNUSED(bmain),
816                                                    PointerRNA *ptr_dst,
817                                                    PointerRNA *ptr_src,
818                                                    PointerRNA *ptr_storage,
819                                                    PropertyRNA *prop_dst,
820                                                    PropertyRNA *prop_src,
821                                                    PropertyRNA *UNUSED(prop_storage),
822                                                    const int len_dst,
823                                                    const int len_src,
824                                                    const int len_storage,
825                                                    PointerRNA *UNUSED(ptr_item_dst),
826                                                    PointerRNA *UNUSED(ptr_item_src),
827                                                    PointerRNA *UNUSED(ptr_item_storage),
828                                                    IDOverrideLibraryPropertyOperation *opop)
829 {
830   BLI_assert(len_dst == len_src && (!ptr_storage || len_dst == len_storage) && len_dst == 0);
831   BLI_assert(opop->operation == IDOVERRIDE_LIBRARY_OP_REPLACE &&
832              "Unsupported RNA override operation on Hook modifier target object pointer");
833   UNUSED_VARS_NDEBUG(ptr_storage, len_dst, len_src, len_storage, opop);
834 
835   /* We need a special handling here because setting hook target resets invert parent matrix,
836    * which is evil in our case. */
837   HookModifierData *hmd = ptr_dst->data;
838   Object *owner = (Object *)ptr_dst->owner_id;
839   Object *target_dst = RNA_property_pointer_get(ptr_dst, prop_dst).data;
840   Object *target_src = RNA_property_pointer_get(ptr_src, prop_src).data;
841 
842   BLI_assert(target_dst == hmd->object);
843 
844   if (target_src == target_dst) {
845     return false;
846   }
847 
848   hmd->object = target_src;
849   if (target_src == NULL) {
850     /* The only case where we do want default behavior (with matrix reset). */
851     BKE_object_modifier_hook_reset(owner, hmd);
852   }
853   return true;
854 }
855 
rna_HookModifier_subtarget_set(PointerRNA * ptr,const char * value)856 static void rna_HookModifier_subtarget_set(PointerRNA *ptr, const char *value)
857 {
858   Object *owner = (Object *)ptr->owner_id;
859   HookModifierData *hmd = ptr->data;
860 
861   BLI_strncpy(hmd->subtarget, value, sizeof(hmd->subtarget));
862   BKE_object_modifier_hook_reset(owner, hmd);
863 }
864 
rna_HookModifier_vertex_indices_get_length(PointerRNA * ptr,int length[RNA_MAX_ARRAY_DIMENSION])865 static int rna_HookModifier_vertex_indices_get_length(PointerRNA *ptr,
866                                                       int length[RNA_MAX_ARRAY_DIMENSION])
867 {
868   HookModifierData *hmd = ptr->data;
869   int totindex = hmd->indexar ? hmd->totindex : 0;
870   return (length[0] = totindex);
871 }
872 
rna_HookModifier_vertex_indices_get(PointerRNA * ptr,int * values)873 static void rna_HookModifier_vertex_indices_get(PointerRNA *ptr, int *values)
874 {
875   HookModifierData *hmd = ptr->data;
876   if (hmd->indexar != NULL) {
877     memcpy(values, hmd->indexar, sizeof(int) * hmd->totindex);
878   }
879 }
880 
rna_HookModifier_vertex_indices_set(HookModifierData * hmd,ReportList * reports,int indices_len,int * indices)881 static void rna_HookModifier_vertex_indices_set(HookModifierData *hmd,
882                                                 ReportList *reports,
883                                                 int indices_len,
884                                                 int *indices)
885 {
886   if (indices_len == 0) {
887     MEM_SAFE_FREE(hmd->indexar);
888     hmd->totindex = 0;
889   }
890   else {
891     /* Reject negative indices. */
892     for (int i = 0; i < indices_len; i++) {
893       if (indices[i] < 0) {
894         BKE_reportf(reports, RPT_ERROR, "Negative vertex index in vertex_indices_set");
895         return;
896       }
897     }
898 
899     /* Copy and sort the index array. */
900     size_t size = sizeof(int) * indices_len;
901     int *buffer = MEM_mallocN(size, "hook indexar");
902     memcpy(buffer, indices, size);
903 
904     qsort(buffer, indices_len, sizeof(int), BLI_sortutil_cmp_int);
905 
906     /* Reject duplicate indices. */
907     for (int i = 1; i < indices_len; i++) {
908       if (buffer[i] == buffer[i - 1]) {
909         BKE_reportf(reports, RPT_ERROR, "Duplicate index %d in vertex_indices_set", buffer[i]);
910         MEM_freeN(buffer);
911         return;
912       }
913     }
914 
915     /* Success - save the new array. */
916     MEM_SAFE_FREE(hmd->indexar);
917     hmd->indexar = buffer;
918     hmd->totindex = indices_len;
919   }
920 }
921 
rna_UVProjector_object_get(PointerRNA * ptr)922 static PointerRNA rna_UVProjector_object_get(PointerRNA *ptr)
923 {
924   Object **ob = (Object **)ptr->data;
925   return rna_pointer_inherit_refine(ptr, &RNA_Object, *ob);
926 }
927 
rna_UVProjector_object_set(PointerRNA * ptr,PointerRNA value,struct ReportList * UNUSED (reports))928 static void rna_UVProjector_object_set(PointerRNA *ptr,
929                                        PointerRNA value,
930                                        struct ReportList *UNUSED(reports))
931 {
932   Object **ob_p = (Object **)ptr->data;
933   Object *ob = (Object *)value.data;
934   id_lib_extern((ID *)ob);
935   *ob_p = ob;
936 }
937 
938 #  undef RNA_MOD_OBJECT_SET
939 
940 /* Other rna callbacks */
941 
rna_fluid_set_type(Main * bmain,Scene * scene,PointerRNA * ptr)942 static void rna_fluid_set_type(Main *bmain, Scene *scene, PointerRNA *ptr)
943 {
944   FluidModifierData *fmd = (FluidModifierData *)ptr->data;
945   Object *ob = (Object *)ptr->owner_id;
946 
947   /* nothing changed */
948   if ((fmd->type & MOD_FLUID_TYPE_DOMAIN) && fmd->domain) {
949     return;
950   }
951 
952 #  ifdef WITH_FLUID
953   BKE_fluid_modifier_free(fmd);             /* XXX TODO: completely free all 3 pointers */
954   BKE_fluid_modifier_create_type_data(fmd); /* create regarding of selected type */
955 #  endif
956 
957   switch (fmd->type) {
958     case MOD_FLUID_TYPE_DOMAIN:
959       ob->dt = OB_WIRE;
960       break;
961     case MOD_FLUID_TYPE_FLOW:
962     case MOD_FLUID_TYPE_EFFEC:
963     case 0:
964     default:
965       break;
966   }
967 
968   /* update dependency since a domain - other type switch could have happened */
969   rna_Modifier_dependency_update(bmain, scene, ptr);
970 }
971 
rna_MultiresModifier_type_set(PointerRNA * ptr,int value)972 static void rna_MultiresModifier_type_set(PointerRNA *ptr, int value)
973 {
974   Object *ob = (Object *)ptr->owner_id;
975   MultiresModifierData *mmd = (MultiresModifierData *)ptr->data;
976 
977   multires_force_sculpt_rebuild(ob);
978   mmd->simple = value;
979 }
980 
rna_MultiresModifier_level_range(PointerRNA * ptr,int * min,int * max,int * UNUSED (softmin),int * UNUSED (softmax))981 static void rna_MultiresModifier_level_range(
982     PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax))
983 {
984   MultiresModifierData *mmd = (MultiresModifierData *)ptr->data;
985 
986   *min = 0;
987   *max = max_ii(0, mmd->totlvl); /* intentionally _not_ -1 */
988 }
989 
rna_MultiresModifier_external_get(PointerRNA * ptr)990 static bool rna_MultiresModifier_external_get(PointerRNA *ptr)
991 {
992   Object *ob = (Object *)ptr->owner_id;
993   Mesh *me = ob->data;
994 
995   return CustomData_external_test(&me->ldata, CD_MDISPS);
996 }
997 
rna_MultiresModifier_filepath_get(PointerRNA * ptr,char * value)998 static void rna_MultiresModifier_filepath_get(PointerRNA *ptr, char *value)
999 {
1000   Object *ob = (Object *)ptr->owner_id;
1001   CustomDataExternal *external = ((Mesh *)ob->data)->ldata.external;
1002 
1003   BLI_strncpy(value, (external) ? external->filename : "", sizeof(external->filename));
1004 }
1005 
rna_MultiresModifier_filepath_set(PointerRNA * ptr,const char * value)1006 static void rna_MultiresModifier_filepath_set(PointerRNA *ptr, const char *value)
1007 {
1008   Object *ob = (Object *)ptr->owner_id;
1009   CustomDataExternal *external = ((Mesh *)ob->data)->ldata.external;
1010 
1011   if (external && !STREQ(external->filename, value)) {
1012     BLI_strncpy(external->filename, value, sizeof(external->filename));
1013     multires_force_external_reload(ob);
1014   }
1015 }
1016 
rna_MultiresModifier_filepath_length(PointerRNA * ptr)1017 static int rna_MultiresModifier_filepath_length(PointerRNA *ptr)
1018 {
1019   Object *ob = (Object *)ptr->owner_id;
1020   CustomDataExternal *external = ((Mesh *)ob->data)->ldata.external;
1021 
1022   return strlen((external) ? external->filename : "");
1023 }
1024 
rna_ShrinkwrapModifier_face_cull_get(PointerRNA * ptr)1025 static int rna_ShrinkwrapModifier_face_cull_get(PointerRNA *ptr)
1026 {
1027   ShrinkwrapModifierData *swm = (ShrinkwrapModifierData *)ptr->data;
1028   return swm->shrinkOpts & MOD_SHRINKWRAP_CULL_TARGET_MASK;
1029 }
1030 
rna_ShrinkwrapModifier_face_cull_set(struct PointerRNA * ptr,int value)1031 static void rna_ShrinkwrapModifier_face_cull_set(struct PointerRNA *ptr, int value)
1032 {
1033   ShrinkwrapModifierData *swm = (ShrinkwrapModifierData *)ptr->data;
1034   swm->shrinkOpts = (swm->shrinkOpts & ~MOD_SHRINKWRAP_CULL_TARGET_MASK) | value;
1035 }
1036 
rna_MeshDeformModifier_is_bound_get(PointerRNA * ptr)1037 static bool rna_MeshDeformModifier_is_bound_get(PointerRNA *ptr)
1038 {
1039   return (((MeshDeformModifierData *)ptr->data)->bindcagecos != NULL);
1040 }
1041 
rna_SoftBodyModifier_settings_get(PointerRNA * ptr)1042 static PointerRNA rna_SoftBodyModifier_settings_get(PointerRNA *ptr)
1043 {
1044   Object *ob = (Object *)ptr->owner_id;
1045   return rna_pointer_inherit_refine(ptr, &RNA_SoftBodySettings, ob->soft);
1046 }
1047 
rna_SoftBodyModifier_point_cache_get(PointerRNA * ptr)1048 static PointerRNA rna_SoftBodyModifier_point_cache_get(PointerRNA *ptr)
1049 {
1050   Object *ob = (Object *)ptr->owner_id;
1051   return rna_pointer_inherit_refine(ptr, &RNA_PointCache, ob->soft->shared->pointcache);
1052 }
1053 
rna_CollisionModifier_settings_get(PointerRNA * ptr)1054 static PointerRNA rna_CollisionModifier_settings_get(PointerRNA *ptr)
1055 {
1056   Object *ob = (Object *)ptr->owner_id;
1057   return rna_pointer_inherit_refine(ptr, &RNA_CollisionSettings, ob->pd);
1058 }
1059 
1060 /* Special update function for setting the number of segments of the modifier that also resamples
1061  * the segments in the custom profile. */
rna_BevelModifier_update_segments(Main * bmain,Scene * scene,PointerRNA * ptr)1062 static void rna_BevelModifier_update_segments(Main *bmain, Scene *scene, PointerRNA *ptr)
1063 {
1064   BevelModifierData *bmd = (BevelModifierData *)ptr->data;
1065   if (RNA_enum_get(ptr, "profile_type") == MOD_BEVEL_PROFILE_CUSTOM) {
1066     short segments = (short)RNA_int_get(ptr, "segments");
1067     BKE_curveprofile_init(bmd->custom_profile, segments);
1068   }
1069   rna_Modifier_update(bmain, scene, ptr);
1070 }
1071 
rna_UVProjectModifier_num_projectors_set(PointerRNA * ptr,int value)1072 static void rna_UVProjectModifier_num_projectors_set(PointerRNA *ptr, int value)
1073 {
1074   UVProjectModifierData *md = (UVProjectModifierData *)ptr->data;
1075   int a;
1076 
1077   md->num_projectors = CLAMPIS(value, 1, MOD_UVPROJECT_MAXPROJECTORS);
1078   for (a = md->num_projectors; a < MOD_UVPROJECT_MAXPROJECTORS; a++) {
1079     md->projectors[a] = NULL;
1080   }
1081 }
1082 
rna_OceanModifier_init_update(Main * bmain,Scene * scene,PointerRNA * ptr)1083 static void rna_OceanModifier_init_update(Main *bmain, Scene *scene, PointerRNA *ptr)
1084 {
1085   OceanModifierData *omd = (OceanModifierData *)ptr->data;
1086 
1087   BKE_ocean_free_modifier_cache(omd);
1088   rna_Modifier_update(bmain, scene, ptr);
1089 }
1090 
rna_OceanModifier_ocean_chop_set(PointerRNA * ptr,float value)1091 static void rna_OceanModifier_ocean_chop_set(PointerRNA *ptr, float value)
1092 {
1093   OceanModifierData *omd = (OceanModifierData *)ptr->data;
1094   float old_value = omd->chop_amount;
1095 
1096   omd->chop_amount = value;
1097 
1098   if ((old_value == 0.0f && value > 0.0f) || (old_value > 0.0f && value == 0.0f)) {
1099     BKE_ocean_free_modifier_cache(omd);
1100   }
1101 }
1102 
rna_LaplacianDeformModifier_is_bind_get(PointerRNA * ptr)1103 static bool rna_LaplacianDeformModifier_is_bind_get(PointerRNA *ptr)
1104 {
1105   LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)ptr->data;
1106   return ((lmd->flag & MOD_LAPLACIANDEFORM_BIND) && (lmd->vertexco != NULL));
1107 }
1108 
1109 /* NOTE: Curve and array modifiers requires curve path to be evaluated,
1110  * dependency graph will make sure that curve eval would create such a path,
1111  * but if curve was already evaluated we might miss path.
1112  *
1113  * So what we do here is: if path was not calculated for target curve we
1114  * tag it for update.
1115  */
1116 
rna_CurveModifier_dependency_update(Main * bmain,Scene * scene,PointerRNA * ptr)1117 static void rna_CurveModifier_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr)
1118 {
1119   CurveModifierData *cmd = (CurveModifierData *)ptr->data;
1120   rna_Modifier_update(bmain, scene, ptr);
1121   DEG_relations_tag_update(bmain);
1122   if (cmd->object != NULL) {
1123     Curve *curve = cmd->object->data;
1124     if ((curve->flag & CU_PATH) == 0) {
1125       DEG_id_tag_update(&curve->id, ID_RECALC_GEOMETRY);
1126     }
1127   }
1128 }
1129 
rna_ArrayModifier_dependency_update(Main * bmain,Scene * scene,PointerRNA * ptr)1130 static void rna_ArrayModifier_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr)
1131 {
1132   ArrayModifierData *amd = (ArrayModifierData *)ptr->data;
1133   rna_Modifier_update(bmain, scene, ptr);
1134   DEG_relations_tag_update(bmain);
1135   if (amd->curve_ob != NULL) {
1136     Curve *curve = amd->curve_ob->data;
1137     if ((curve->flag & CU_PATH) == 0) {
1138       DEG_id_tag_update(&curve->id, ID_RECALC_GEOMETRY);
1139     }
1140   }
1141 }
1142 
rna_DataTransferModifier_use_data_update(Main * bmain,Scene * scene,PointerRNA * ptr)1143 static void rna_DataTransferModifier_use_data_update(Main *bmain, Scene *scene, PointerRNA *ptr)
1144 {
1145   DataTransferModifierData *dtmd = (DataTransferModifierData *)ptr->data;
1146 
1147   if (!(dtmd->flags & MOD_DATATRANSFER_USE_VERT)) {
1148     dtmd->data_types &= ~DT_TYPE_VERT_ALL;
1149   }
1150   if (!(dtmd->flags & MOD_DATATRANSFER_USE_EDGE)) {
1151     dtmd->data_types &= ~DT_TYPE_EDGE_ALL;
1152   }
1153   if (!(dtmd->flags & MOD_DATATRANSFER_USE_LOOP)) {
1154     dtmd->data_types &= ~DT_TYPE_LOOP_ALL;
1155   }
1156   if (!(dtmd->flags & MOD_DATATRANSFER_USE_POLY)) {
1157     dtmd->data_types &= ~DT_TYPE_POLY_ALL;
1158   }
1159 
1160   rna_Modifier_dependency_update(bmain, scene, ptr);
1161 }
1162 
rna_DataTransferModifier_data_types_update(Main * bmain,Scene * scene,PointerRNA * ptr)1163 static void rna_DataTransferModifier_data_types_update(Main *bmain, Scene *scene, PointerRNA *ptr)
1164 {
1165   DataTransferModifierData *dtmd = (DataTransferModifierData *)ptr->data;
1166   const int item_types = BKE_object_data_transfer_get_dttypes_item_types(dtmd->data_types);
1167 
1168   if (item_types & ME_VERT) {
1169     dtmd->flags |= MOD_DATATRANSFER_USE_VERT;
1170   }
1171   if (item_types & ME_EDGE) {
1172     dtmd->flags |= MOD_DATATRANSFER_USE_EDGE;
1173   }
1174   if (item_types & ME_LOOP) {
1175     dtmd->flags |= MOD_DATATRANSFER_USE_LOOP;
1176   }
1177   if (item_types & ME_POLY) {
1178     dtmd->flags |= MOD_DATATRANSFER_USE_POLY;
1179   }
1180 
1181   rna_Modifier_dependency_update(bmain, scene, ptr);
1182 }
1183 
rna_DataTransferModifier_verts_data_types_set(struct PointerRNA * ptr,int value)1184 static void rna_DataTransferModifier_verts_data_types_set(struct PointerRNA *ptr, int value)
1185 {
1186   DataTransferModifierData *dtmd = (DataTransferModifierData *)ptr->data;
1187 
1188   dtmd->data_types &= ~DT_TYPE_VERT_ALL;
1189   dtmd->data_types |= value;
1190 }
1191 
rna_DataTransferModifier_edges_data_types_set(struct PointerRNA * ptr,int value)1192 static void rna_DataTransferModifier_edges_data_types_set(struct PointerRNA *ptr, int value)
1193 {
1194   DataTransferModifierData *dtmd = (DataTransferModifierData *)ptr->data;
1195 
1196   dtmd->data_types &= ~DT_TYPE_EDGE_ALL;
1197   dtmd->data_types |= value;
1198 }
1199 
rna_DataTransferModifier_loops_data_types_set(struct PointerRNA * ptr,int value)1200 static void rna_DataTransferModifier_loops_data_types_set(struct PointerRNA *ptr, int value)
1201 {
1202   DataTransferModifierData *dtmd = (DataTransferModifierData *)ptr->data;
1203 
1204   dtmd->data_types &= ~DT_TYPE_LOOP_ALL;
1205   dtmd->data_types |= value;
1206 }
1207 
rna_DataTransferModifier_polys_data_types_set(struct PointerRNA * ptr,int value)1208 static void rna_DataTransferModifier_polys_data_types_set(struct PointerRNA *ptr, int value)
1209 {
1210   DataTransferModifierData *dtmd = (DataTransferModifierData *)ptr->data;
1211 
1212   dtmd->data_types &= ~DT_TYPE_POLY_ALL;
1213   dtmd->data_types |= value;
1214 }
1215 
rna_DataTransferModifier_layers_select_src_itemf(bContext * C,PointerRNA * ptr,PropertyRNA * prop,bool * r_free)1216 static const EnumPropertyItem *rna_DataTransferModifier_layers_select_src_itemf(bContext *C,
1217                                                                                 PointerRNA *ptr,
1218                                                                                 PropertyRNA *prop,
1219                                                                                 bool *r_free)
1220 {
1221   DataTransferModifierData *dtmd = (DataTransferModifierData *)ptr->data;
1222   EnumPropertyItem *item = NULL, tmp_item = {0};
1223   int totitem = 0;
1224 
1225   if (!C) { /* needed for docs and i18n tools */
1226     return rna_enum_dt_layers_select_src_items;
1227   }
1228 
1229   /* No active here! */
1230   RNA_enum_items_add_value(
1231       &item, &totitem, rna_enum_dt_layers_select_src_items, DT_LAYERS_ALL_SRC);
1232 
1233   if (STREQ(RNA_property_identifier(prop), "layers_vgroup_select_src")) {
1234     Object *ob_src = dtmd->ob_source;
1235 
1236 #  if 0 /* XXX Don't think we want this in modifier version... */
1237     if (BKE_object_pose_armature_get(ob_src)) {
1238       RNA_enum_items_add_value(
1239           &item, &totitem, rna_enum_dt_layers_select_src_items, DT_LAYERS_VGROUP_SRC_BONE_SELECT);
1240       RNA_enum_items_add_value(
1241           &item, &totitem, rna_enum_dt_layers_select_src_items, DT_LAYERS_VGROUP_SRC_BONE_DEFORM);
1242     }
1243 #  endif
1244 
1245     if (ob_src) {
1246       bDeformGroup *dg;
1247       int i;
1248 
1249       RNA_enum_item_add_separator(&item, &totitem);
1250 
1251       for (i = 0, dg = ob_src->defbase.first; dg; i++, dg = dg->next) {
1252         tmp_item.value = i;
1253         tmp_item.identifier = tmp_item.name = dg->name;
1254         RNA_enum_item_add(&item, &totitem, &tmp_item);
1255       }
1256     }
1257   }
1258   else if (STREQ(RNA_property_identifier(prop), "layers_shapekey_select_src")) {
1259     /* TODO */
1260   }
1261   else if (STREQ(RNA_property_identifier(prop), "layers_uv_select_src")) {
1262     Object *ob_src = dtmd->ob_source;
1263 
1264     if (ob_src) {
1265       Mesh *me_eval;
1266       int num_data, i;
1267 
1268       Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
1269       Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
1270       Object *ob_src_eval = DEG_get_evaluated_object(depsgraph, ob_src);
1271 
1272       CustomData_MeshMasks cddata_masks = CD_MASK_BAREMESH;
1273       cddata_masks.lmask |= CD_MASK_MLOOPUV;
1274       me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_src_eval, &cddata_masks);
1275       num_data = CustomData_number_of_layers(&me_eval->ldata, CD_MLOOPUV);
1276 
1277       RNA_enum_item_add_separator(&item, &totitem);
1278 
1279       for (i = 0; i < num_data; i++) {
1280         tmp_item.value = i;
1281         tmp_item.identifier = tmp_item.name = CustomData_get_layer_name(
1282             &me_eval->ldata, CD_MLOOPUV, i);
1283         RNA_enum_item_add(&item, &totitem, &tmp_item);
1284       }
1285     }
1286   }
1287   else if (STREQ(RNA_property_identifier(prop), "layers_vcol_select_src")) {
1288     Object *ob_src = dtmd->ob_source;
1289 
1290     if (ob_src) {
1291       Mesh *me_eval;
1292       int num_data, i;
1293 
1294       Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
1295       Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
1296       Object *ob_src_eval = DEG_get_evaluated_object(depsgraph, ob_src);
1297 
1298       CustomData_MeshMasks cddata_masks = CD_MASK_BAREMESH;
1299       cddata_masks.lmask |= CD_MASK_MLOOPCOL;
1300       me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_src_eval, &cddata_masks);
1301       num_data = CustomData_number_of_layers(&me_eval->ldata, CD_MLOOPCOL);
1302 
1303       RNA_enum_item_add_separator(&item, &totitem);
1304 
1305       for (i = 0; i < num_data; i++) {
1306         tmp_item.value = i;
1307         tmp_item.identifier = tmp_item.name = CustomData_get_layer_name(
1308             &me_eval->ldata, CD_MLOOPCOL, i);
1309         RNA_enum_item_add(&item, &totitem, &tmp_item);
1310       }
1311     }
1312   }
1313 
1314   RNA_enum_item_end(&item, &totitem);
1315   *r_free = true;
1316 
1317   return item;
1318 }
1319 
rna_DataTransferModifier_layers_select_dst_itemf(bContext * C,PointerRNA * ptr,PropertyRNA * prop,bool * r_free)1320 static const EnumPropertyItem *rna_DataTransferModifier_layers_select_dst_itemf(bContext *C,
1321                                                                                 PointerRNA *ptr,
1322                                                                                 PropertyRNA *prop,
1323                                                                                 bool *r_free)
1324 {
1325   DataTransferModifierData *dtmd = (DataTransferModifierData *)ptr->data;
1326   EnumPropertyItem *item = NULL, tmp_item = {0};
1327   int totitem = 0;
1328 
1329   if (!C) { /* needed for docs and i18n tools */
1330     return rna_enum_dt_layers_select_dst_items;
1331   }
1332 
1333   /* No active here! */
1334   RNA_enum_items_add_value(
1335       &item, &totitem, rna_enum_dt_layers_select_dst_items, DT_LAYERS_NAME_DST);
1336   RNA_enum_items_add_value(
1337       &item, &totitem, rna_enum_dt_layers_select_dst_items, DT_LAYERS_INDEX_DST);
1338 
1339   if (STREQ(RNA_property_identifier(prop), "layers_vgroup_select_dst")) {
1340     /* Only list destination layers if we have a single source! */
1341     if (dtmd->layers_select_src[DT_MULTILAYER_INDEX_MDEFORMVERT] >= 0) {
1342       Object *ob_dst = CTX_data_active_object(C); /* XXX Is this OK? */
1343 
1344       if (ob_dst) {
1345         bDeformGroup *dg;
1346         int i;
1347 
1348         RNA_enum_item_add_separator(&item, &totitem);
1349 
1350         for (i = 0, dg = ob_dst->defbase.first; dg; i++, dg = dg->next) {
1351           tmp_item.value = i;
1352           tmp_item.identifier = tmp_item.name = dg->name;
1353           RNA_enum_item_add(&item, &totitem, &tmp_item);
1354         }
1355       }
1356     }
1357   }
1358   else if (STREQ(RNA_property_identifier(prop), "layers_shapekey_select_dst")) {
1359     /* TODO */
1360   }
1361   else if (STREQ(RNA_property_identifier(prop), "layers_uv_select_dst")) {
1362     /* Only list destination layers if we have a single source! */
1363     if (dtmd->layers_select_src[DT_MULTILAYER_INDEX_UV] >= 0) {
1364       Object *ob_dst = CTX_data_active_object(C); /* XXX Is this OK? */
1365 
1366       if (ob_dst && ob_dst->data) {
1367         Mesh *me_dst;
1368         CustomData *ldata;
1369         int num_data, i;
1370 
1371         me_dst = ob_dst->data;
1372         ldata = &me_dst->ldata;
1373         num_data = CustomData_number_of_layers(ldata, CD_MLOOPUV);
1374 
1375         RNA_enum_item_add_separator(&item, &totitem);
1376 
1377         for (i = 0; i < num_data; i++) {
1378           tmp_item.value = i;
1379           tmp_item.identifier = tmp_item.name = CustomData_get_layer_name(ldata, CD_MLOOPUV, i);
1380           RNA_enum_item_add(&item, &totitem, &tmp_item);
1381         }
1382       }
1383     }
1384   }
1385   else if (STREQ(RNA_property_identifier(prop), "layers_vcol_select_dst")) {
1386     /* Only list destination layers if we have a single source! */
1387     if (dtmd->layers_select_src[DT_MULTILAYER_INDEX_VCOL] >= 0) {
1388       Object *ob_dst = CTX_data_active_object(C); /* XXX Is this OK? */
1389 
1390       if (ob_dst && ob_dst->data) {
1391         Mesh *me_dst;
1392         CustomData *ldata;
1393         int num_data, i;
1394 
1395         me_dst = ob_dst->data;
1396         ldata = &me_dst->ldata;
1397         num_data = CustomData_number_of_layers(ldata, CD_MLOOPCOL);
1398 
1399         RNA_enum_item_add_separator(&item, &totitem);
1400 
1401         for (i = 0; i < num_data; i++) {
1402           tmp_item.value = i;
1403           tmp_item.identifier = tmp_item.name = CustomData_get_layer_name(ldata, CD_MLOOPCOL, i);
1404           RNA_enum_item_add(&item, &totitem, &tmp_item);
1405         }
1406       }
1407     }
1408   }
1409 
1410   RNA_enum_item_end(&item, &totitem);
1411   *r_free = true;
1412 
1413   return item;
1414 }
1415 
rna_DataTransferModifier_mix_mode_itemf(bContext * C,PointerRNA * ptr,PropertyRNA * UNUSED (prop),bool * r_free)1416 static const EnumPropertyItem *rna_DataTransferModifier_mix_mode_itemf(bContext *C,
1417                                                                        PointerRNA *ptr,
1418                                                                        PropertyRNA *UNUSED(prop),
1419                                                                        bool *r_free)
1420 {
1421   DataTransferModifierData *dtmd = (DataTransferModifierData *)ptr->data;
1422   EnumPropertyItem *item = NULL;
1423   int totitem = 0;
1424 
1425   bool support_advanced_mixing, support_threshold;
1426 
1427   if (!C) { /* needed for docs and i18n tools */
1428     return rna_enum_dt_mix_mode_items;
1429   }
1430 
1431   RNA_enum_items_add_value(&item, &totitem, rna_enum_dt_mix_mode_items, CDT_MIX_TRANSFER);
1432 
1433   BKE_object_data_transfer_get_dttypes_capacity(
1434       dtmd->data_types, &support_advanced_mixing, &support_threshold);
1435 
1436   if (support_threshold) {
1437     RNA_enum_items_add_value(
1438         &item, &totitem, rna_enum_dt_mix_mode_items, CDT_MIX_REPLACE_ABOVE_THRESHOLD);
1439     RNA_enum_items_add_value(
1440         &item, &totitem, rna_enum_dt_mix_mode_items, CDT_MIX_REPLACE_BELOW_THRESHOLD);
1441   }
1442 
1443   if (support_advanced_mixing) {
1444     RNA_enum_item_add_separator(&item, &totitem);
1445     RNA_enum_items_add_value(&item, &totitem, rna_enum_dt_mix_mode_items, CDT_MIX_MIX);
1446     RNA_enum_items_add_value(&item, &totitem, rna_enum_dt_mix_mode_items, CDT_MIX_ADD);
1447     RNA_enum_items_add_value(&item, &totitem, rna_enum_dt_mix_mode_items, CDT_MIX_SUB);
1448     RNA_enum_items_add_value(&item, &totitem, rna_enum_dt_mix_mode_items, CDT_MIX_MUL);
1449   }
1450 
1451   RNA_enum_item_end(&item, &totitem);
1452   *r_free = true;
1453 
1454   return item;
1455 }
1456 
rna_CorrectiveSmoothModifier_update(Main * bmain,Scene * scene,PointerRNA * ptr)1457 static void rna_CorrectiveSmoothModifier_update(Main *bmain, Scene *scene, PointerRNA *ptr)
1458 {
1459   CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)ptr->data;
1460 
1461   MEM_SAFE_FREE(csmd->delta_cache.deltas);
1462 
1463   rna_Modifier_update(bmain, scene, ptr);
1464 }
1465 
rna_CorrectiveSmoothModifier_rest_source_update(Main * bmain,Scene * scene,PointerRNA * ptr)1466 static void rna_CorrectiveSmoothModifier_rest_source_update(Main *bmain,
1467                                                             Scene *scene,
1468                                                             PointerRNA *ptr)
1469 {
1470   CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)ptr->data;
1471 
1472   if (csmd->rest_source != MOD_CORRECTIVESMOOTH_RESTSOURCE_BIND) {
1473     MEM_SAFE_FREE(csmd->bind_coords);
1474     csmd->bind_coords_num = 0;
1475   }
1476 
1477   rna_CorrectiveSmoothModifier_update(bmain, scene, ptr);
1478 }
1479 
rna_CorrectiveSmoothModifier_is_bind_get(PointerRNA * ptr)1480 static bool rna_CorrectiveSmoothModifier_is_bind_get(PointerRNA *ptr)
1481 {
1482   CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)ptr->data;
1483   return (csmd->bind_coords != NULL);
1484 }
1485 
rna_SurfaceDeformModifier_is_bound_get(PointerRNA * ptr)1486 static bool rna_SurfaceDeformModifier_is_bound_get(PointerRNA *ptr)
1487 {
1488   return (((SurfaceDeformModifierData *)ptr->data)->verts != NULL);
1489 }
1490 
rna_ParticleInstanceModifier_particle_system_poll(PointerRNA * ptr,const PointerRNA value)1491 static bool rna_ParticleInstanceModifier_particle_system_poll(PointerRNA *ptr,
1492                                                               const PointerRNA value)
1493 {
1494   ParticleInstanceModifierData *psmd = ptr->data;
1495   ParticleSystem *psys = value.data;
1496 
1497   if (!psmd->ob) {
1498     return false;
1499   }
1500 
1501   /* make sure psys is in the object */
1502   return BLI_findindex(&psmd->ob->particlesystem, psys) != -1;
1503 }
1504 
rna_ParticleInstanceModifier_particle_system_get(PointerRNA * ptr)1505 static PointerRNA rna_ParticleInstanceModifier_particle_system_get(PointerRNA *ptr)
1506 {
1507   ParticleInstanceModifierData *psmd = ptr->data;
1508   ParticleSystem *psys;
1509   PointerRNA rptr;
1510 
1511   if (!psmd->ob) {
1512     return PointerRNA_NULL;
1513   }
1514 
1515   psys = BLI_findlink(&psmd->ob->particlesystem, psmd->psys - 1);
1516   RNA_pointer_create((ID *)psmd->ob, &RNA_ParticleSystem, psys, &rptr);
1517   return rptr;
1518 }
1519 
rna_ParticleInstanceModifier_particle_system_set(PointerRNA * ptr,const PointerRNA value,struct ReportList * UNUSED (reports))1520 static void rna_ParticleInstanceModifier_particle_system_set(PointerRNA *ptr,
1521                                                              const PointerRNA value,
1522                                                              struct ReportList *UNUSED(reports))
1523 {
1524   ParticleInstanceModifierData *psmd = ptr->data;
1525 
1526   if (!psmd->ob) {
1527     return;
1528   }
1529 
1530   psmd->psys = BLI_findindex(&psmd->ob->particlesystem, value.data) + 1;
1531   CLAMP_MIN(psmd->psys, 1);
1532 }
1533 
1534 /**
1535  * Special set callback that just changes the first bit of the expansion flag.
1536  * This way the expansion state of all the sub-panels is not changed by RNA.
1537  */
rna_Modifier_show_expanded_set(PointerRNA * ptr,bool value)1538 static void rna_Modifier_show_expanded_set(PointerRNA *ptr, bool value)
1539 {
1540   ModifierData *md = ptr->data;
1541   if (value) {
1542     md->ui_expand_flag |= (1 << 0);
1543   }
1544   else {
1545     md->ui_expand_flag &= ~(1 << 0);
1546   }
1547 }
1548 
1549 /**
1550  * Only check the first bit of the expansion flag for the main panel's expansion,
1551  * maintaining compatibility with older versions where there was only one expansion
1552  * value.
1553  */
rna_Modifier_show_expanded_get(PointerRNA * ptr)1554 static bool rna_Modifier_show_expanded_get(PointerRNA *ptr)
1555 {
1556   ModifierData *md = ptr->data;
1557   return md->ui_expand_flag & (1 << 0);
1558 }
1559 
rna_MeshSequenceCacheModifier_has_velocity_get(PointerRNA * ptr)1560 static int rna_MeshSequenceCacheModifier_has_velocity_get(PointerRNA *ptr)
1561 {
1562 #  ifdef WITH_ALEMBIC
1563   MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *)ptr->data;
1564   return ABC_has_vec3_array_property_named(mcmd->reader, mcmd->cache_file->velocity_name);
1565 #  else
1566   return false;
1567   UNUSED_VARS(ptr);
1568 #  endif
1569 }
1570 
rna_MeshSequenceCacheModifier_read_velocity_get(PointerRNA * ptr)1571 static int rna_MeshSequenceCacheModifier_read_velocity_get(PointerRNA *ptr)
1572 {
1573 #  ifdef WITH_ALEMBIC
1574   MeshSeqCacheModifierData *mcmd = (MeshSeqCacheModifierData *)ptr->data;
1575 
1576   if (mcmd->num_vertices == 0) {
1577     return 0;
1578   }
1579 
1580   if (mcmd->vertex_velocities) {
1581     MEM_freeN(mcmd->vertex_velocities);
1582   }
1583 
1584   mcmd->vertex_velocities = MEM_mallocN(sizeof(MeshCacheVertexVelocity) * mcmd->num_vertices,
1585                                         "Mesh Cache Velocities");
1586 
1587   int num_read = ABC_read_velocity_cache(mcmd->reader,
1588                                          mcmd->cache_file->velocity_name,
1589                                          mcmd->last_lookup_time,
1590                                          mcmd->velocity_scale * mcmd->velocity_delta,
1591                                          mcmd->num_vertices,
1592                                          (float *)mcmd->vertex_velocities);
1593 
1594   if (num_read == -1 || num_read != mcmd->num_vertices) {
1595     return false;
1596   }
1597 
1598   return true;
1599 #  else
1600   return false;
1601   UNUSED_VARS(ptr);
1602 #  endif
1603 }
1604 
1605 #else
1606 
1607 /* NOTE: *MUST* return subdivision_type property. */
rna_def_property_subdivision_common(StructRNA * srna,const char type[])1608 static PropertyRNA *rna_def_property_subdivision_common(StructRNA *srna, const char type[])
1609 {
1610   static const EnumPropertyItem prop_subdivision_type_items[] = {
1611       {SUBSURF_TYPE_CATMULL_CLARK, "CATMULL_CLARK", 0, "Catmull-Clark", ""},
1612       {SUBSURF_TYPE_SIMPLE, "SIMPLE", 0, "Simple", ""},
1613       {0, NULL, 0, NULL, NULL},
1614   };
1615 
1616   static const EnumPropertyItem prop_uv_smooth_items[] = {
1617     {SUBSURF_UV_SMOOTH_NONE, "NONE", 0, "None", "UVs are not smoothed, boundaries are kept sharp"},
1618     {SUBSURF_UV_SMOOTH_PRESERVE_CORNERS,
1619      "PRESERVE_CORNERS",
1620      0,
1621      "Keep Corners",
1622      "UVs are smoothed, corners on discontinuous boundary are kept sharp"},
1623 #  if 0
1624     {SUBSURF_UV_SMOOTH_PRESERVE_CORNERS_AND_JUNCTIONS,
1625      "PRESERVE_CORNERS_AND_JUNCTIONS",
1626      0,
1627      "Smooth, keep corners+junctions",
1628      "UVs are smoothed, corners on discontinuous boundary and "
1629      "junctions of 3 or more regions are kept sharp"},
1630     {SUBSURF_UV_SMOOTH_PRESERVE_CORNERS_JUNCTIONS_AND_CONCAVE,
1631      "PRESERVE_CORNERS_JUNCTIONS_AND_CONCAVE",
1632      0,
1633      "Smooth, keep corners+junctions+concave",
1634      "UVs are smoothed, corners on discontinuous boundary, "
1635      "junctions of 3 or more regions and darts and concave corners are kept sharp"},
1636     {SUBSURF_UV_SMOOTH_PRESERVE_BOUNDARIES,
1637      "PRESERVE_BOUNDARIES",
1638      0,
1639      "Smooth, keep corners",
1640      "UVs are smoothed, boundaries are kept sharp"},
1641 #  endif
1642     {SUBSURF_UV_SMOOTH_ALL, "PRESERVE_BOUNDARIES", 0, "All", "UVs and boundaries are smoothed"},
1643     {0, NULL, 0, NULL, NULL},
1644   };
1645 
1646   static const EnumPropertyItem prop_boundary_smooth_items[] = {
1647       {SUBSURF_BOUNDARY_SMOOTH_PRESERVE_CORNERS,
1648        "PRESERVE_CORNERS",
1649        0,
1650        "Keep Corners",
1651        "Smooth boundaries, but corners are kept sharp"},
1652       {SUBSURF_BOUNDARY_SMOOTH_ALL, "ALL", 0, "All", "Smooth boundaries, including corners"},
1653       {0, NULL, 0, NULL, NULL},
1654   };
1655 
1656   PropertyRNA *prop;
1657 
1658   RNA_define_lib_overridable(true);
1659 
1660   prop = RNA_def_property(srna, "uv_smooth", PROP_ENUM, PROP_NONE);
1661   RNA_def_property_enum_sdna(prop, NULL, "uv_smooth");
1662   RNA_def_property_enum_items(prop, prop_uv_smooth_items);
1663   RNA_def_property_ui_text(prop, "UV Smooth", "Controls how smoothing is applied to UVs");
1664   RNA_def_property_update(prop, 0, "rna_Modifier_update");
1665 
1666   prop = RNA_def_property(srna, "quality", PROP_INT, PROP_UNSIGNED);
1667   RNA_def_property_int_sdna(prop, NULL, "quality");
1668   RNA_def_property_range(prop, 1, 10);
1669   RNA_def_property_ui_range(prop, 1, 6, 1, -1);
1670   RNA_def_property_ui_text(
1671       prop, "Quality", "Accuracy of vertex positions, lower value is faster but less precise");
1672   RNA_def_property_update(prop, 0, "rna_Modifier_update");
1673 
1674   prop = RNA_def_property(srna, "boundary_smooth", PROP_ENUM, PROP_NONE);
1675   RNA_def_property_enum_sdna(prop, NULL, "boundary_smooth");
1676   RNA_def_property_enum_items(prop, prop_boundary_smooth_items);
1677   RNA_def_property_ui_text(prop, "Boundary Smooth", "Controls how open boundaries are smoothed");
1678   RNA_def_property_update(prop, 0, "rna_Modifier_update");
1679 
1680   prop = RNA_def_property(srna, "subdivision_type", PROP_ENUM, PROP_NONE);
1681   RNA_def_property_enum_sdna(prop, NULL, type);
1682   RNA_def_property_enum_items(prop, prop_subdivision_type_items);
1683   RNA_def_property_ui_text(prop, "Subdivision Type", "Select type of subdivision algorithm");
1684   RNA_def_property_update(prop, 0, "rna_Modifier_update");
1685 
1686   RNA_define_lib_overridable(false);
1687 
1688   return prop;
1689 }
1690 
rna_def_modifier_subsurf(BlenderRNA * brna)1691 static void rna_def_modifier_subsurf(BlenderRNA *brna)
1692 {
1693   StructRNA *srna;
1694   PropertyRNA *prop;
1695 
1696   srna = RNA_def_struct(brna, "SubsurfModifier", "Modifier");
1697   RNA_def_struct_ui_text(srna, "Subdivision Surface Modifier", "Subdivision surface modifier");
1698   RNA_def_struct_sdna(srna, "SubsurfModifierData");
1699   RNA_def_struct_ui_icon(srna, ICON_MOD_SUBSURF);
1700 
1701   rna_def_property_subdivision_common(srna, "subdivType");
1702 
1703   RNA_define_lib_overridable(true);
1704 
1705   /* see CCGSUBSURF_LEVEL_MAX for max limit */
1706   prop = RNA_def_property(srna, "levels", PROP_INT, PROP_UNSIGNED);
1707   RNA_def_property_int_sdna(prop, NULL, "levels");
1708   RNA_def_property_range(prop, 0, 11);
1709   RNA_def_property_ui_range(prop, 0, 6, 1, -1);
1710   RNA_def_property_ui_text(prop, "Levels", "Number of subdivisions to perform");
1711   RNA_def_property_update(prop, 0, "rna_Modifier_update");
1712 
1713   prop = RNA_def_property(srna, "render_levels", PROP_INT, PROP_UNSIGNED);
1714   RNA_def_property_int_sdna(prop, NULL, "renderLevels");
1715   RNA_def_property_range(prop, 0, 11);
1716   RNA_def_property_ui_range(prop, 0, 6, 1, -1);
1717   RNA_def_property_ui_text(
1718       prop, "Render Levels", "Number of subdivisions to perform when rendering");
1719 
1720   prop = RNA_def_property(srna, "show_only_control_edges", PROP_BOOLEAN, PROP_NONE);
1721   RNA_def_property_boolean_sdna(prop, NULL, "flags", eSubsurfModifierFlag_ControlEdges);
1722   RNA_def_property_ui_text(
1723       prop, "Optimal Display", "Skip drawing/rendering of interior subdivided edges");
1724   RNA_def_property_update(prop, 0, "rna_Modifier_update");
1725 
1726   prop = RNA_def_property(srna, "use_creases", PROP_BOOLEAN, PROP_NONE);
1727   RNA_def_property_boolean_sdna(prop, NULL, "flags", eSubsurfModifierFlag_UseCrease);
1728   RNA_def_property_ui_text(
1729       prop, "Use Creases", "Use mesh edge crease information to sharpen edges");
1730   RNA_def_property_update(prop, 0, "rna_Modifier_update");
1731 
1732   prop = RNA_def_property(srna, "use_custom_normals", PROP_BOOLEAN, PROP_NONE);
1733   RNA_def_property_boolean_sdna(prop, NULL, "flags", eSubsurfModifierFlag_UseCustomNormals);
1734   RNA_def_property_ui_text(
1735       prop, "Use Custom Normals", "Interpolates existing custom normals to resulting mesh");
1736   RNA_def_property_update(prop, 0, "rna_Modifier_update");
1737 
1738   prop = RNA_def_property(srna, "use_limit_surface", PROP_BOOLEAN, PROP_NONE);
1739   RNA_def_property_boolean_negative_sdna(
1740       prop, NULL, "flags", eSubsurfModifierFlag_UseRecursiveSubdivision);
1741   RNA_def_property_ui_text(prop,
1742                            "Use Limit Surface",
1743                            "Place vertices at the surface that would be produced with infinite "
1744                            "levels of subdivision (smoothest possible shape)");
1745   RNA_def_property_update(prop, 0, "rna_Modifier_update");
1746 
1747   RNA_define_lib_overridable(false);
1748 }
1749 
rna_def_modifier_generic_map_info(StructRNA * srna)1750 static void rna_def_modifier_generic_map_info(StructRNA *srna)
1751 {
1752   static const EnumPropertyItem prop_texture_coordinates_items[] = {
1753       {MOD_DISP_MAP_LOCAL,
1754        "LOCAL",
1755        0,
1756        "Local",
1757        "Use the local coordinate system for the texture coordinates"},
1758       {MOD_DISP_MAP_GLOBAL,
1759        "GLOBAL",
1760        0,
1761        "Global",
1762        "Use the global coordinate system for the texture coordinates"},
1763       {MOD_DISP_MAP_OBJECT,
1764        "OBJECT",
1765        0,
1766        "Object",
1767        "Use the linked object's local coordinate system for the texture coordinates"},
1768       {MOD_DISP_MAP_UV, "UV", 0, "UV", "Use UV coordinates for the texture coordinates"},
1769       {0, NULL, 0, NULL, NULL},
1770   };
1771 
1772   PropertyRNA *prop;
1773 
1774   RNA_define_lib_overridable(true);
1775 
1776   prop = RNA_def_property(srna, "texture", PROP_POINTER, PROP_NONE);
1777   RNA_def_property_ui_text(prop, "Texture", "");
1778   RNA_def_property_flag(prop, PROP_EDITABLE);
1779   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
1780 
1781   prop = RNA_def_property(srna, "texture_coords", PROP_ENUM, PROP_NONE);
1782   RNA_def_property_enum_sdna(prop, NULL, "texmapping");
1783   RNA_def_property_enum_items(prop, prop_texture_coordinates_items);
1784   RNA_def_property_ui_text(prop, "Texture Coordinates", "");
1785   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
1786 
1787   prop = RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE);
1788   RNA_def_property_string_sdna(prop, NULL, "uvlayer_name");
1789   RNA_def_property_ui_text(prop, "UV Map", "UV map name");
1790   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MappingInfoModifier_uvlayer_name_set");
1791   RNA_def_property_update(prop, 0, "rna_Modifier_update");
1792 
1793   prop = RNA_def_property(srna, "texture_coords_object", PROP_POINTER, PROP_NONE);
1794   RNA_def_property_pointer_sdna(prop, NULL, "map_object");
1795   RNA_def_property_ui_text(
1796       prop, "Texture Coordinate Object", "Object to set the texture coordinates");
1797   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
1798   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
1799 
1800   prop = RNA_def_property(srna, "texture_coords_bone", PROP_STRING, PROP_NONE);
1801   RNA_def_property_string_sdna(prop, NULL, "map_bone");
1802   RNA_def_property_ui_text(prop, "Texture Coordinate Bone", "Bone to set the texture coordinates");
1803   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
1804 
1805   RNA_define_lib_overridable(false);
1806 }
1807 
rna_def_modifier_warp(BlenderRNA * brna)1808 static void rna_def_modifier_warp(BlenderRNA *brna)
1809 {
1810   StructRNA *srna;
1811   PropertyRNA *prop;
1812 
1813   srna = RNA_def_struct(brna, "WarpModifier", "Modifier");
1814   RNA_def_struct_ui_text(srna, "Warp Modifier", "Warp modifier");
1815   RNA_def_struct_sdna(srna, "WarpModifierData");
1816   RNA_def_struct_ui_icon(srna, ICON_MOD_WARP);
1817 
1818   RNA_define_lib_overridable(true);
1819 
1820   prop = RNA_def_property(srna, "object_from", PROP_POINTER, PROP_NONE);
1821   RNA_def_property_pointer_sdna(prop, NULL, "object_from");
1822   RNA_def_property_ui_text(prop, "Object From", "Object to transform from");
1823   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
1824   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
1825 
1826   prop = RNA_def_property(srna, "bone_from", PROP_STRING, PROP_NONE);
1827   RNA_def_property_string_sdna(prop, NULL, "bone_from");
1828   RNA_def_property_ui_text(prop, "Bone From", "Bone to transform from");
1829   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
1830 
1831   prop = RNA_def_property(srna, "object_to", PROP_POINTER, PROP_NONE);
1832   RNA_def_property_pointer_sdna(prop, NULL, "object_to");
1833   RNA_def_property_ui_text(prop, "Object To", "Object to transform to");
1834   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
1835   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
1836 
1837   prop = RNA_def_property(srna, "bone_to", PROP_STRING, PROP_NONE);
1838   RNA_def_property_string_sdna(prop, NULL, "bone_to");
1839   RNA_def_property_ui_text(prop, "Bone To", "Bone defining offset");
1840   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
1841 
1842   prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE);
1843   RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
1844   RNA_def_property_ui_range(prop, -100, 100, 10, 2);
1845   RNA_def_property_ui_text(prop, "Strength", "");
1846   RNA_def_property_update(prop, 0, "rna_Modifier_update");
1847 
1848   prop = RNA_def_property(srna, "falloff_type", PROP_ENUM, PROP_NONE);
1849   RNA_def_property_enum_items(prop, modifier_warp_falloff_items);
1850   RNA_def_property_ui_text(prop, "Falloff Type", "");
1851   RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_CURVE); /* Abusing id_curve :/ */
1852   RNA_def_property_update(prop, 0, "rna_Modifier_update");
1853 
1854   prop = RNA_def_property(srna, "falloff_radius", PROP_FLOAT, PROP_UNSIGNED | PROP_DISTANCE);
1855   RNA_def_property_ui_text(prop, "Radius", "Radius to apply");
1856   RNA_def_property_update(prop, 0, "rna_Modifier_update");
1857 
1858   prop = RNA_def_property(srna, "falloff_curve", PROP_POINTER, PROP_NONE);
1859   RNA_def_property_pointer_sdna(prop, NULL, "curfalloff");
1860   RNA_def_property_ui_text(prop, "Falloff Curve", "Custom falloff curve");
1861   RNA_def_property_update(prop, 0, "rna_Modifier_update");
1862 
1863   prop = RNA_def_property(srna, "use_volume_preserve", PROP_BOOLEAN, PROP_NONE);
1864   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WARP_VOLUME_PRESERVE);
1865   RNA_def_property_ui_text(prop, "Preserve Volume", "Preserve volume when rotations are used");
1866   RNA_def_property_update(prop, 0, "rna_Modifier_update");
1867 
1868   prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
1869   RNA_def_property_string_sdna(prop, NULL, "defgrp_name");
1870   RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name for modulating the deform");
1871   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_WarpModifier_defgrp_name_set");
1872   RNA_def_property_update(prop, 0, "rna_Modifier_update");
1873 
1874   prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
1875   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WARP_INVERT_VGROUP);
1876   RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
1877   RNA_def_property_update(prop, 0, "rna_Modifier_update");
1878 
1879   RNA_define_lib_overridable(false);
1880 
1881   rna_def_modifier_generic_map_info(srna);
1882 }
1883 
rna_def_modifier_multires(BlenderRNA * brna)1884 static void rna_def_modifier_multires(BlenderRNA *brna)
1885 {
1886   StructRNA *srna;
1887   PropertyRNA *prop;
1888 
1889   srna = RNA_def_struct(brna, "MultiresModifier", "Modifier");
1890   RNA_def_struct_ui_text(srna, "Multires Modifier", "Multiresolution mesh modifier");
1891   RNA_def_struct_sdna(srna, "MultiresModifierData");
1892   RNA_def_struct_ui_icon(srna, ICON_MOD_MULTIRES);
1893 
1894   RNA_define_lib_overridable(true);
1895 
1896   prop = rna_def_property_subdivision_common(srna, "simple");
1897   RNA_def_property_enum_funcs(prop, NULL, "rna_MultiresModifier_type_set", NULL);
1898 
1899   prop = RNA_def_property(srna, "levels", PROP_INT, PROP_UNSIGNED);
1900   RNA_def_property_int_sdna(prop, NULL, "lvl");
1901   RNA_def_property_ui_text(prop, "Levels", "Number of subdivisions to use in the viewport");
1902   RNA_def_property_int_funcs(prop, NULL, NULL, "rna_MultiresModifier_level_range");
1903   RNA_def_property_update(prop, 0, "rna_Modifier_update");
1904 
1905   prop = RNA_def_property(srna, "sculpt_levels", PROP_INT, PROP_UNSIGNED);
1906   RNA_def_property_int_sdna(prop, NULL, "sculptlvl");
1907   RNA_def_property_ui_text(prop, "Sculpt Levels", "Number of subdivisions to use in sculpt mode");
1908   RNA_def_property_int_funcs(prop, NULL, NULL, "rna_MultiresModifier_level_range");
1909   RNA_def_property_update(prop, 0, "rna_Modifier_update");
1910 
1911   prop = RNA_def_property(srna, "render_levels", PROP_INT, PROP_UNSIGNED);
1912   RNA_def_property_int_sdna(prop, NULL, "renderlvl");
1913   RNA_def_property_ui_text(prop, "Render Levels", "The subdivision level visible at render time");
1914   RNA_def_property_int_funcs(prop, NULL, NULL, "rna_MultiresModifier_level_range");
1915 
1916   prop = RNA_def_property(srna, "total_levels", PROP_INT, PROP_UNSIGNED);
1917   RNA_def_property_int_sdna(prop, NULL, "totlvl");
1918   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1919   RNA_def_property_ui_text(
1920       prop, "Total Levels", "Number of subdivisions for which displacements are stored");
1921 
1922   prop = RNA_def_property(srna, "is_external", PROP_BOOLEAN, PROP_NONE);
1923   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1924   RNA_def_property_boolean_funcs(prop, "rna_MultiresModifier_external_get", NULL);
1925   RNA_def_property_ui_text(
1926       prop, "External", "Store multires displacements outside the .blend file, to save memory");
1927 
1928   prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
1929   RNA_def_property_string_funcs(prop,
1930                                 "rna_MultiresModifier_filepath_get",
1931                                 "rna_MultiresModifier_filepath_length",
1932                                 "rna_MultiresModifier_filepath_set");
1933   RNA_def_property_ui_text(prop, "File Path", "Path to external displacements file");
1934   RNA_def_property_update(prop, 0, "rna_Modifier_update");
1935 
1936   prop = RNA_def_property(srna, "show_only_control_edges", PROP_BOOLEAN, PROP_NONE);
1937   RNA_def_property_boolean_sdna(prop, NULL, "flags", eMultiresModifierFlag_ControlEdges);
1938   RNA_def_property_ui_text(
1939       prop, "Optimal Display", "Skip drawing/rendering of interior subdivided edges");
1940   RNA_def_property_update(prop, 0, "rna_Modifier_update");
1941 
1942   prop = RNA_def_property(srna, "use_creases", PROP_BOOLEAN, PROP_NONE);
1943   RNA_def_property_boolean_sdna(prop, NULL, "flags", eMultiresModifierFlag_UseCrease);
1944   RNA_def_property_ui_text(
1945       prop, "Use Creases", "Use mesh edge crease information to sharpen edges");
1946   RNA_def_property_update(prop, 0, "rna_Modifier_update");
1947 
1948   prop = RNA_def_property(srna, "use_custom_normals", PROP_BOOLEAN, PROP_NONE);
1949   RNA_def_property_boolean_sdna(prop, NULL, "flags", eMultiresModifierFlag_UseCustomNormals);
1950   RNA_def_property_ui_text(
1951       prop, "Use Custom Normals", "Interpolates existing custom normals to resulting mesh");
1952   RNA_def_property_update(prop, 0, "rna_Modifier_update");
1953 
1954   prop = RNA_def_property(srna, "use_sculpt_base_mesh", PROP_BOOLEAN, PROP_NONE);
1955   RNA_def_property_boolean_sdna(prop, NULL, "flags", eMultiresModifierFlag_UseSculptBaseMesh);
1956   RNA_def_property_ui_text(prop,
1957                            "Sculpt Base Mesh",
1958                            "Make Sculpt Mode tools deform the base mesh while previewing the "
1959                            "displacement of higher subdivision levels");
1960   RNA_def_property_update(prop, 0, "rna_Modifier_update");
1961 
1962   RNA_define_lib_overridable(false);
1963 }
1964 
rna_def_modifier_lattice(BlenderRNA * brna)1965 static void rna_def_modifier_lattice(BlenderRNA *brna)
1966 {
1967   StructRNA *srna;
1968   PropertyRNA *prop;
1969 
1970   srna = RNA_def_struct(brna, "LatticeModifier", "Modifier");
1971   RNA_def_struct_ui_text(srna, "Lattice Modifier", "Lattice deformation modifier");
1972   RNA_def_struct_sdna(srna, "LatticeModifierData");
1973   RNA_def_struct_ui_icon(srna, ICON_MOD_LATTICE);
1974 
1975   RNA_define_lib_overridable(true);
1976 
1977   prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
1978   RNA_def_property_ui_text(prop, "Object", "Lattice object to deform with");
1979   RNA_def_property_pointer_funcs(
1980       prop, NULL, "rna_LatticeModifier_object_set", NULL, "rna_Lattice_object_poll");
1981   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
1982   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
1983 
1984   prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
1985   RNA_def_property_string_sdna(prop, NULL, "name");
1986   RNA_def_property_ui_text(
1987       prop,
1988       "Vertex Group",
1989       "Name of Vertex Group which determines influence of modifier per point");
1990   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_LatticeModifier_name_set");
1991   RNA_def_property_update(prop, 0, "rna_Modifier_update");
1992 
1993   prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
1994   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_LATTICE_INVERT_VGROUP);
1995   RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
1996   RNA_def_property_update(prop, 0, "rna_Modifier_update");
1997 
1998   prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE);
1999   RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
2000   RNA_def_property_ui_range(prop, 0, 1, 10, 2);
2001   RNA_def_property_ui_text(prop, "Strength", "Strength of modifier effect");
2002   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2003 
2004   RNA_define_lib_overridable(false);
2005 }
2006 
rna_def_modifier_curve(BlenderRNA * brna)2007 static void rna_def_modifier_curve(BlenderRNA *brna)
2008 {
2009   StructRNA *srna;
2010   PropertyRNA *prop;
2011 
2012   static const EnumPropertyItem prop_deform_axis_items[] = {
2013       {MOD_CURVE_POSX, "POS_X", 0, "X", ""},
2014       {MOD_CURVE_POSY, "POS_Y", 0, "Y", ""},
2015       {MOD_CURVE_POSZ, "POS_Z", 0, "Z", ""},
2016       {MOD_CURVE_NEGX, "NEG_X", 0, "-X", ""},
2017       {MOD_CURVE_NEGY, "NEG_Y", 0, "-Y", ""},
2018       {MOD_CURVE_NEGZ, "NEG_Z", 0, "-Z", ""},
2019       {0, NULL, 0, NULL, NULL},
2020   };
2021 
2022   srna = RNA_def_struct(brna, "CurveModifier", "Modifier");
2023   RNA_def_struct_ui_text(srna, "Curve Modifier", "Curve deformation modifier");
2024   RNA_def_struct_sdna(srna, "CurveModifierData");
2025   RNA_def_struct_ui_icon(srna, ICON_MOD_CURVE);
2026 
2027   RNA_define_lib_overridable(true);
2028 
2029   prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
2030   RNA_def_property_ui_text(prop, "Object", "Curve object to deform with");
2031   RNA_def_property_pointer_funcs(
2032       prop, NULL, "rna_CurveModifier_object_set", NULL, "rna_Curve_object_poll");
2033   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
2034   RNA_def_property_update(prop, 0, "rna_CurveModifier_dependency_update");
2035 
2036   prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
2037   RNA_def_property_string_sdna(prop, NULL, "name");
2038   RNA_def_property_ui_text(
2039       prop,
2040       "Vertex Group",
2041       "Name of Vertex Group which determines influence of modifier per point");
2042   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_CurveModifier_name_set");
2043   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2044 
2045   prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
2046   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_CURVE_INVERT_VGROUP);
2047   RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
2048   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2049 
2050   prop = RNA_def_property(srna, "deform_axis", PROP_ENUM, PROP_NONE);
2051   RNA_def_property_enum_sdna(prop, NULL, "defaxis");
2052   RNA_def_property_enum_items(prop, prop_deform_axis_items);
2053   RNA_def_property_ui_text(prop, "Deform Axis", "The axis that the curve deforms along");
2054   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2055 
2056   RNA_define_lib_overridable(false);
2057 }
2058 
rna_def_modifier_build(BlenderRNA * brna)2059 static void rna_def_modifier_build(BlenderRNA *brna)
2060 {
2061   StructRNA *srna;
2062   PropertyRNA *prop;
2063 
2064   srna = RNA_def_struct(brna, "BuildModifier", "Modifier");
2065   RNA_def_struct_ui_text(srna, "Build Modifier", "Build effect modifier");
2066   RNA_def_struct_sdna(srna, "BuildModifierData");
2067   RNA_def_struct_ui_icon(srna, ICON_MOD_BUILD);
2068 
2069   RNA_define_lib_overridable(true);
2070 
2071   prop = RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_TIME);
2072   RNA_def_property_float_sdna(prop, NULL, "start");
2073   RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF);
2074   RNA_def_property_ui_text(prop, "Start Frame", "Start frame of the effect");
2075   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2076 
2077   prop = RNA_def_property(srna, "frame_duration", PROP_FLOAT, PROP_TIME);
2078   RNA_def_property_float_sdna(prop, NULL, "length");
2079   RNA_def_property_range(prop, 1, MAXFRAMEF);
2080   RNA_def_property_ui_text(prop, "Length", "Total time the build effect requires");
2081   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2082 
2083   prop = RNA_def_property(srna, "use_reverse", PROP_BOOLEAN, PROP_NONE);
2084   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_BUILD_FLAG_REVERSE);
2085   RNA_def_property_ui_text(prop, "Reversed", "Deconstruct the mesh instead of building it");
2086   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2087 
2088   prop = RNA_def_property(srna, "use_random_order", PROP_BOOLEAN, PROP_NONE);
2089   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_BUILD_FLAG_RANDOMIZE);
2090   RNA_def_property_ui_text(prop, "Randomize", "Randomize the faces or edges during build");
2091   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2092 
2093   prop = RNA_def_property(srna, "seed", PROP_INT, PROP_NONE);
2094   RNA_def_property_range(prop, 1, MAXFRAMEF);
2095   RNA_def_property_ui_text(prop, "Seed", "Seed for random if used");
2096   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2097 
2098   RNA_define_lib_overridable(false);
2099 }
2100 
rna_def_modifier_mirror(BlenderRNA * brna)2101 static void rna_def_modifier_mirror(BlenderRNA *brna)
2102 {
2103   StructRNA *srna;
2104   PropertyRNA *prop;
2105 
2106   srna = RNA_def_struct(brna, "MirrorModifier", "Modifier");
2107   RNA_def_struct_ui_text(srna, "Mirror Modifier", "Mirroring modifier");
2108   RNA_def_struct_sdna(srna, "MirrorModifierData");
2109   RNA_def_struct_ui_icon(srna, ICON_MOD_MIRROR);
2110 
2111   RNA_define_lib_overridable(true);
2112 
2113   prop = RNA_def_property(srna, "use_axis", PROP_BOOLEAN, PROP_NONE);
2114   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_MIR_AXIS_X);
2115   RNA_def_property_array(prop, 3);
2116   RNA_def_property_ui_text(prop, "Mirror Axis", "Enable axis mirror");
2117   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2118 
2119   prop = RNA_def_property(srna, "use_bisect_axis", PROP_BOOLEAN, PROP_NONE);
2120   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_MIR_BISECT_AXIS_X);
2121   RNA_def_property_array(prop, 3);
2122   RNA_def_property_ui_text(prop, "Bisect Axis", "Cuts the mesh across the mirror plane");
2123   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2124 
2125   prop = RNA_def_property(srna, "use_bisect_flip_axis", PROP_BOOLEAN, PROP_NONE);
2126   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_MIR_BISECT_FLIP_AXIS_X);
2127   RNA_def_property_array(prop, 3);
2128   RNA_def_property_ui_text(prop, "Bisect Flip Axis", "Flips the direction of the slice");
2129   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2130 
2131   prop = RNA_def_property(srna, "use_clip", PROP_BOOLEAN, PROP_NONE);
2132   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_MIR_CLIPPING);
2133   RNA_def_property_ui_text(
2134       prop, "Clip", "Prevent vertices from going through the mirror during transform");
2135   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2136 
2137   prop = RNA_def_property(srna, "use_mirror_vertex_groups", PROP_BOOLEAN, PROP_NONE);
2138   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_MIR_VGROUP);
2139   RNA_def_property_ui_text(prop, "Mirror Vertex Groups", "Mirror vertex groups (e.g. .R->.L)");
2140   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2141 
2142   prop = RNA_def_property(srna, "use_mirror_merge", PROP_BOOLEAN, PROP_NONE);
2143   RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", MOD_MIR_NO_MERGE);
2144   RNA_def_property_ui_text(prop, "Merge Vertices", "Merge vertices within the merge threshold");
2145   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2146 
2147   prop = RNA_def_property(srna, "use_mirror_u", PROP_BOOLEAN, PROP_NONE);
2148   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_MIR_MIRROR_U);
2149   RNA_def_property_ui_text(
2150       prop, "Mirror U", "Mirror the U texture coordinate around the flip offset point");
2151   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2152 
2153   prop = RNA_def_property(srna, "use_mirror_v", PROP_BOOLEAN, PROP_NONE);
2154   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_MIR_MIRROR_V);
2155   RNA_def_property_ui_text(
2156       prop, "Mirror V", "Mirror the V texture coordinate around the flip offset point");
2157   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2158 
2159   prop = RNA_def_property(srna, "use_mirror_udim", PROP_BOOLEAN, PROP_NONE);
2160   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_MIR_MIRROR_UDIM);
2161   RNA_def_property_ui_text(
2162       prop, "Mirror UDIM", "Mirror the texture coordinate around each tile center");
2163   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2164 
2165   prop = RNA_def_property(srna, "mirror_offset_u", PROP_FLOAT, PROP_FACTOR);
2166   RNA_def_property_float_sdna(prop, NULL, "uv_offset[0]");
2167   RNA_def_property_range(prop, -1, 1);
2168   RNA_def_property_ui_range(prop, -1, 1, 2, 4);
2169   RNA_def_property_ui_text(
2170       prop,
2171       "Flip U Offset",
2172       "Amount to offset mirrored UVs flipping point from the 0.5 on the U axis");
2173   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2174 
2175   prop = RNA_def_property(srna, "mirror_offset_v", PROP_FLOAT, PROP_FACTOR);
2176   RNA_def_property_float_sdna(prop, NULL, "uv_offset[1]");
2177   RNA_def_property_range(prop, -1, 1);
2178   RNA_def_property_ui_range(prop, -1, 1, 2, 4);
2179   RNA_def_property_ui_text(
2180       prop,
2181       "Flip V Offset",
2182       "Amount to offset mirrored UVs flipping point from the 0.5 point on the V axis");
2183   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2184 
2185   prop = RNA_def_property(srna, "offset_u", PROP_FLOAT, PROP_FACTOR);
2186   RNA_def_property_float_sdna(prop, NULL, "uv_offset_copy[0]");
2187   RNA_def_property_range(prop, -10000.0f, 10000.0f);
2188   RNA_def_property_ui_range(prop, -1, 1, 2, 4);
2189   RNA_def_property_ui_text(prop, "U Offset", "Mirrored UV offset on the U axis");
2190   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2191 
2192   prop = RNA_def_property(srna, "offset_v", PROP_FLOAT, PROP_FACTOR);
2193   RNA_def_property_float_sdna(prop, NULL, "uv_offset_copy[1]");
2194   RNA_def_property_range(prop, -10000.0f, 10000.0f);
2195   RNA_def_property_ui_range(prop, -1, 1, 2, 4);
2196   RNA_def_property_ui_text(prop, "V Offset", "Mirrored UV offset on the V axis");
2197   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2198 
2199   prop = RNA_def_property(srna, "merge_threshold", PROP_FLOAT, PROP_DISTANCE);
2200   RNA_def_property_float_sdna(prop, NULL, "tolerance");
2201   RNA_def_property_range(prop, 0, FLT_MAX);
2202   RNA_def_property_ui_range(prop, 0, 1, 0.01, 6);
2203   RNA_def_property_ui_text(
2204       prop, "Merge Distance", "Distance within which mirrored vertices are merged");
2205   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2206 
2207   prop = RNA_def_property(srna, "mirror_object", PROP_POINTER, PROP_NONE);
2208   RNA_def_property_pointer_sdna(prop, NULL, "mirror_ob");
2209   RNA_def_property_ui_text(prop, "Mirror Object", "Object to use as mirror");
2210   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
2211   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
2212 
2213   RNA_define_lib_overridable(false);
2214 }
2215 
rna_def_modifier_decimate(BlenderRNA * brna)2216 static void rna_def_modifier_decimate(BlenderRNA *brna)
2217 {
2218   static const EnumPropertyItem modifier_decim_mode_items[] = {
2219       {MOD_DECIM_MODE_COLLAPSE, "COLLAPSE", 0, "Collapse", "Use edge collapsing"},
2220       {MOD_DECIM_MODE_UNSUBDIV, "UNSUBDIV", 0, "Un-Subdivide", "Use un-subdivide face reduction"},
2221       {MOD_DECIM_MODE_DISSOLVE,
2222        "DISSOLVE",
2223        0,
2224        "Planar",
2225        "Dissolve geometry to form planar polygons"},
2226       {0, NULL, 0, NULL, NULL},
2227   };
2228 
2229   /* Note, keep in sync with operator 'MESH_OT_decimate' */
2230 
2231   StructRNA *srna;
2232   PropertyRNA *prop;
2233 
2234   srna = RNA_def_struct(brna, "DecimateModifier", "Modifier");
2235   RNA_def_struct_ui_text(srna, "Decimate Modifier", "Decimation modifier");
2236   RNA_def_struct_sdna(srna, "DecimateModifierData");
2237   RNA_def_struct_ui_icon(srna, ICON_MOD_DECIM);
2238 
2239   RNA_define_lib_overridable(true);
2240 
2241   prop = RNA_def_property(srna, "decimate_type", PROP_ENUM, PROP_NONE);
2242   RNA_def_property_enum_sdna(prop, NULL, "mode");
2243   RNA_def_property_enum_items(prop, modifier_decim_mode_items);
2244   RNA_def_property_ui_text(prop, "Mode", "");
2245   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2246 
2247   /* (mode == MOD_DECIM_MODE_COLLAPSE) */
2248   prop = RNA_def_property(srna, "ratio", PROP_FLOAT, PROP_FACTOR);
2249   RNA_def_property_float_sdna(prop, NULL, "percent");
2250   RNA_def_property_range(prop, 0, 1);
2251   RNA_def_property_ui_range(prop, 0, 1, 1, 4);
2252   RNA_def_property_ui_text(prop, "Ratio", "Ratio of triangles to reduce to (collapse only)");
2253   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2254 
2255   /* (mode == MOD_DECIM_MODE_UNSUBDIV) */
2256   prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_UNSIGNED);
2257   RNA_def_property_int_sdna(prop, NULL, "iter");
2258   RNA_def_property_range(prop, 0, SHRT_MAX);
2259   RNA_def_property_ui_range(prop, 0, 100, 1, -1);
2260   RNA_def_property_ui_text(
2261       prop, "Iterations", "Number of times reduce the geometry (unsubdivide only)");
2262   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2263 
2264   /* (mode == MOD_DECIM_MODE_DISSOLVE) */
2265   prop = RNA_def_property(srna, "angle_limit", PROP_FLOAT, PROP_ANGLE);
2266   RNA_def_property_float_sdna(prop, NULL, "angle");
2267   RNA_def_property_range(prop, 0, DEG2RAD(180));
2268   RNA_def_property_ui_range(prop, 0, DEG2RAD(180), 10, 2);
2269   RNA_def_property_ui_text(prop, "Angle Limit", "Only dissolve angles below this (planar only)");
2270   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2271 
2272   /* (mode == MOD_DECIM_MODE_COLLAPSE) */
2273   prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
2274   RNA_def_property_string_sdna(prop, NULL, "defgrp_name");
2275   RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name (collapse only)");
2276   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_DecimateModifier_defgrp_name_set");
2277   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2278 
2279   prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
2280   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_DECIM_FLAG_INVERT_VGROUP);
2281   RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence (collapse only)");
2282   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2283 
2284   prop = RNA_def_property(srna, "use_collapse_triangulate", PROP_BOOLEAN, PROP_NONE);
2285   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_DECIM_FLAG_TRIANGULATE);
2286   RNA_def_property_ui_text(
2287       prop, "Triangulate", "Keep triangulated faces resulting from decimation (collapse only)");
2288   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2289 
2290   prop = RNA_def_property(srna, "use_symmetry", PROP_BOOLEAN, PROP_NONE);
2291   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_DECIM_FLAG_SYMMETRY);
2292   RNA_def_property_ui_text(prop, "Symmetry", "Maintain symmetry on an axis");
2293   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2294 
2295   prop = RNA_def_property(srna, "symmetry_axis", PROP_ENUM, PROP_NONE);
2296   RNA_def_property_enum_sdna(prop, NULL, "symmetry_axis");
2297   RNA_def_property_enum_items(prop, rna_enum_axis_xyz_items);
2298   RNA_def_property_ui_text(prop, "Axis", "Axis of symmetry");
2299   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2300 
2301   prop = RNA_def_property(srna, "vertex_group_factor", PROP_FLOAT, PROP_FACTOR);
2302   RNA_def_property_float_sdna(prop, NULL, "defgrp_factor");
2303   RNA_def_property_range(prop, 0, 1000);
2304   RNA_def_property_ui_range(prop, 0, 10, 1, 4);
2305   RNA_def_property_ui_text(prop, "Factor", "Vertex group strength");
2306   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2307   /* end collapse-only option */
2308 
2309   /* (mode == MOD_DECIM_MODE_DISSOLVE) */
2310   prop = RNA_def_property(srna, "use_dissolve_boundaries", PROP_BOOLEAN, PROP_NONE);
2311   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_DECIM_FLAG_ALL_BOUNDARY_VERTS);
2312   RNA_def_property_ui_text(
2313       prop, "All Boundaries", "Dissolve all vertices in between face boundaries (planar only)");
2314   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2315 
2316   prop = RNA_def_property(srna, "delimit", PROP_ENUM, PROP_NONE);
2317   RNA_def_property_flag(prop, PROP_ENUM_FLAG); /* important to run before default set */
2318   RNA_def_property_enum_items(prop, rna_enum_mesh_delimit_mode_items);
2319   RNA_def_property_ui_text(prop, "Delimit", "Limit merging geometry");
2320   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2321 
2322   /* end dissolve-only option */
2323 
2324   /* all modes use this */
2325   prop = RNA_def_property(srna, "face_count", PROP_INT, PROP_NONE);
2326   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2327   RNA_def_property_ui_text(
2328       prop, "Face Count", "The current number of faces in the decimated mesh");
2329 
2330   RNA_define_lib_overridable(false);
2331 }
2332 
rna_def_modifier_wave(BlenderRNA * brna)2333 static void rna_def_modifier_wave(BlenderRNA *brna)
2334 {
2335   StructRNA *srna;
2336   PropertyRNA *prop;
2337 
2338   srna = RNA_def_struct(brna, "WaveModifier", "Modifier");
2339   RNA_def_struct_ui_text(srna, "Wave Modifier", "Wave effect modifier");
2340   RNA_def_struct_sdna(srna, "WaveModifierData");
2341   RNA_def_struct_ui_icon(srna, ICON_MOD_WAVE);
2342 
2343   RNA_define_lib_overridable(true);
2344 
2345   prop = RNA_def_property(srna, "use_x", PROP_BOOLEAN, PROP_NONE);
2346   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WAVE_X);
2347   RNA_def_property_ui_text(prop, "X", "X axis motion");
2348   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2349 
2350   prop = RNA_def_property(srna, "use_y", PROP_BOOLEAN, PROP_NONE);
2351   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WAVE_Y);
2352   RNA_def_property_ui_text(prop, "Y", "Y axis motion");
2353   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2354 
2355   prop = RNA_def_property(srna, "use_cyclic", PROP_BOOLEAN, PROP_NONE);
2356   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WAVE_CYCL);
2357   RNA_def_property_ui_text(prop, "Cyclic", "Cyclic wave effect");
2358   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2359 
2360   prop = RNA_def_property(srna, "use_normal", PROP_BOOLEAN, PROP_NONE);
2361   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WAVE_NORM);
2362   RNA_def_property_ui_text(prop, "Normals", "Displace along normals");
2363   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2364 
2365   prop = RNA_def_property(srna, "use_normal_x", PROP_BOOLEAN, PROP_NONE);
2366   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WAVE_NORM_X);
2367   RNA_def_property_ui_text(prop, "X Normal", "Enable displacement along the X normal");
2368   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2369 
2370   prop = RNA_def_property(srna, "use_normal_y", PROP_BOOLEAN, PROP_NONE);
2371   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WAVE_NORM_Y);
2372   RNA_def_property_ui_text(prop, "Y Normal", "Enable displacement along the Y normal");
2373   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2374 
2375   prop = RNA_def_property(srna, "use_normal_z", PROP_BOOLEAN, PROP_NONE);
2376   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WAVE_NORM_Z);
2377   RNA_def_property_ui_text(prop, "Z Normal", "Enable displacement along the Z normal");
2378   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2379 
2380   prop = RNA_def_property(srna, "time_offset", PROP_FLOAT, PROP_TIME);
2381   RNA_def_property_float_sdna(prop, NULL, "timeoffs");
2382   RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF);
2383   RNA_def_property_ui_text(
2384       prop,
2385       "Time Offset",
2386       "Either the starting frame (for positive speed) or ending frame (for negative speed.)");
2387   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2388 
2389   prop = RNA_def_property(srna, "lifetime", PROP_FLOAT, PROP_TIME);
2390   RNA_def_property_float_sdna(prop, NULL, "lifetime");
2391   RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF);
2392   RNA_def_property_ui_text(
2393       prop, "Lifetime", "Lifetime of the wave in frames, zero means infinite");
2394   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2395 
2396   prop = RNA_def_property(srna, "damping_time", PROP_FLOAT, PROP_TIME);
2397   RNA_def_property_float_sdna(prop, NULL, "damp");
2398   RNA_def_property_range(prop, MINAFRAMEF, MAXFRAMEF);
2399   RNA_def_property_ui_text(
2400       prop, "Damping Time", "Number of frames in which the wave damps out after it dies");
2401   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2402 
2403   prop = RNA_def_property(srna, "falloff_radius", PROP_FLOAT, PROP_DISTANCE);
2404   RNA_def_property_float_sdna(prop, NULL, "falloff");
2405   RNA_def_property_range(prop, 0, FLT_MAX);
2406   RNA_def_property_ui_range(prop, 0, 100, 100, 2);
2407   RNA_def_property_ui_text(prop, "Falloff Radius", "Distance after which it fades out");
2408   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2409 
2410   prop = RNA_def_property(srna, "start_position_x", PROP_FLOAT, PROP_DISTANCE);
2411   RNA_def_property_float_sdna(prop, NULL, "startx");
2412   RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
2413   RNA_def_property_ui_range(prop, -100, 100, 100, 2);
2414   RNA_def_property_ui_text(prop, "Start Position X", "X coordinate of the start position");
2415   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2416 
2417   prop = RNA_def_property(srna, "start_position_y", PROP_FLOAT, PROP_DISTANCE);
2418   RNA_def_property_float_sdna(prop, NULL, "starty");
2419   RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
2420   RNA_def_property_ui_range(prop, -100, 100, 100, 2);
2421   RNA_def_property_ui_text(prop, "Start Position Y", "Y coordinate of the start position");
2422   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2423 
2424   prop = RNA_def_property(srna, "start_position_object", PROP_POINTER, PROP_NONE);
2425   RNA_def_property_pointer_sdna(prop, NULL, "objectcenter");
2426   RNA_def_property_ui_text(prop, "Start Position Object", "Object which defines the wave center");
2427   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
2428   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
2429 
2430   prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
2431   RNA_def_property_string_sdna(prop, NULL, "defgrp_name");
2432   RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name for modulating the wave");
2433   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_WaveModifier_defgrp_name_set");
2434   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2435 
2436   prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
2437   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WAVE_INVERT_VGROUP);
2438   RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
2439   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2440 
2441   prop = RNA_def_property(srna, "speed", PROP_FLOAT, PROP_NONE);
2442   RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
2443   RNA_def_property_ui_range(prop, -1, 1, 10, 2);
2444   RNA_def_property_ui_text(
2445       prop, "Speed", "Speed of the wave, towards the starting point when negative");
2446   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2447 
2448   prop = RNA_def_property(srna, "height", PROP_FLOAT, PROP_DISTANCE);
2449   RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
2450   RNA_def_property_ui_range(prop, -2, 2, 10, 2);
2451   RNA_def_property_ui_text(prop, "Height", "Height of the wave");
2452   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2453 
2454   prop = RNA_def_property(srna, "width", PROP_FLOAT, PROP_DISTANCE);
2455   RNA_def_property_range(prop, 0, FLT_MAX);
2456   RNA_def_property_ui_range(prop, 0, 5, 10, 2);
2457   RNA_def_property_ui_text(prop, "Width", "Distance between the waves");
2458   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2459 
2460   prop = RNA_def_property(srna, "narrowness", PROP_FLOAT, PROP_DISTANCE);
2461   RNA_def_property_float_sdna(prop, NULL, "narrow");
2462   RNA_def_property_range(prop, 0, FLT_MAX);
2463   RNA_def_property_ui_range(prop, 0, 10, 10, 2);
2464   RNA_def_property_ui_text(
2465       prop,
2466       "Narrowness",
2467       "Distance between the top and the base of a wave, the higher the value, "
2468       "the more narrow the wave");
2469   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2470 
2471   RNA_define_lib_overridable(false);
2472 
2473   rna_def_modifier_generic_map_info(srna);
2474 }
2475 
rna_def_modifier_armature(BlenderRNA * brna)2476 static void rna_def_modifier_armature(BlenderRNA *brna)
2477 {
2478   StructRNA *srna;
2479   PropertyRNA *prop;
2480 
2481   srna = RNA_def_struct(brna, "ArmatureModifier", "Modifier");
2482   RNA_def_struct_ui_text(srna, "Armature Modifier", "Armature deformation modifier");
2483   RNA_def_struct_sdna(srna, "ArmatureModifierData");
2484   RNA_def_struct_ui_icon(srna, ICON_MOD_ARMATURE);
2485 
2486   RNA_define_lib_overridable(true);
2487 
2488   prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
2489   RNA_def_property_ui_text(prop, "Object", "Armature object to deform with");
2490   RNA_def_property_pointer_funcs(
2491       prop, NULL, "rna_ArmatureModifier_object_set", NULL, "rna_Armature_object_poll");
2492   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
2493   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
2494 
2495   prop = RNA_def_property(srna, "use_bone_envelopes", PROP_BOOLEAN, PROP_NONE);
2496   RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_ENVELOPE);
2497   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2498   RNA_def_property_ui_text(prop, "Use Bone Envelopes", "Bind Bone envelopes to armature modifier");
2499   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
2500 
2501   prop = RNA_def_property(srna, "use_vertex_groups", PROP_BOOLEAN, PROP_NONE);
2502   RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_VGROUP);
2503   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
2504   RNA_def_property_ui_text(prop, "Use Vertex Groups", "Bind vertex groups to armature modifier");
2505   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
2506 
2507   prop = RNA_def_property(srna, "use_deform_preserve_volume", PROP_BOOLEAN, PROP_NONE);
2508   RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_QUATERNION);
2509   RNA_def_property_ui_text(
2510       prop, "Preserve Volume", "Deform rotation interpolation with quaternions");
2511   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2512 
2513   prop = RNA_def_property(srna, "use_multi_modifier", PROP_BOOLEAN, PROP_NONE);
2514   RNA_def_property_boolean_sdna(prop, NULL, "multi", 0);
2515   RNA_def_property_ui_text(
2516       prop,
2517       "Multi Modifier",
2518       "Use same input as previous modifier, and mix results using overall vgroup");
2519   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2520 
2521   prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
2522   RNA_def_property_string_sdna(prop, NULL, "defgrp_name");
2523   RNA_def_property_ui_text(
2524       prop,
2525       "Vertex Group",
2526       "Name of Vertex Group which determines influence of modifier per point");
2527   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_ArmatureModifier_defgrp_name_set");
2528   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2529 
2530   prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
2531   RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_INVERT_VGROUP);
2532   RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
2533   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2534 
2535   RNA_define_lib_overridable(false);
2536 }
2537 
rna_def_modifier_hook(BlenderRNA * brna)2538 static void rna_def_modifier_hook(BlenderRNA *brna)
2539 {
2540   StructRNA *srna;
2541   PropertyRNA *prop;
2542   FunctionRNA *func;
2543   PropertyRNA *parm;
2544 
2545   srna = RNA_def_struct(brna, "HookModifier", "Modifier");
2546   RNA_def_struct_ui_text(
2547       srna, "Hook Modifier", "Hook modifier to modify the location of vertices");
2548   RNA_def_struct_sdna(srna, "HookModifierData");
2549   RNA_def_struct_ui_icon(srna, ICON_HOOK);
2550 
2551   RNA_define_lib_overridable(true);
2552 
2553   prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_FACTOR);
2554   RNA_def_property_float_sdna(prop, NULL, "force");
2555   RNA_def_property_range(prop, 0, 1);
2556   RNA_def_property_ui_text(prop, "Strength", "Relative force of the hook");
2557   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2558 
2559   prop = RNA_def_property(srna, "falloff_type", PROP_ENUM, PROP_NONE);
2560   RNA_def_property_enum_items(prop, modifier_warp_falloff_items); /* share the enum */
2561   RNA_def_property_ui_text(prop, "Falloff Type", "");
2562   RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_CURVE); /* Abusing id_curve :/ */
2563   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2564 
2565   prop = RNA_def_property(srna, "falloff_radius", PROP_FLOAT, PROP_DISTANCE);
2566   RNA_def_property_float_sdna(prop, NULL, "falloff");
2567   RNA_def_property_range(prop, 0, FLT_MAX);
2568   RNA_def_property_ui_range(prop, 0, 100, 100, 2);
2569   RNA_def_property_ui_text(
2570       prop, "Radius", "If not zero, the distance from the hook where influence ends");
2571   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2572 
2573   prop = RNA_def_property(srna, "falloff_curve", PROP_POINTER, PROP_NONE);
2574   RNA_def_property_pointer_sdna(prop, NULL, "curfalloff");
2575   RNA_def_property_ui_text(prop, "Falloff Curve", "Custom falloff curve");
2576   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2577 
2578   prop = RNA_def_property(srna, "center", PROP_FLOAT, PROP_TRANSLATION);
2579   RNA_def_property_float_sdna(prop, NULL, "cent");
2580   RNA_def_property_ui_text(
2581       prop, "Hook Center", "Center of the hook, used for falloff and display");
2582   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2583 
2584   prop = RNA_def_property(srna, "matrix_inverse", PROP_FLOAT, PROP_MATRIX);
2585   RNA_def_property_float_sdna(prop, NULL, "parentinv");
2586   RNA_def_property_multi_array(prop, 2, rna_matrix_dimsize_4x4);
2587   RNA_def_property_ui_text(
2588       prop, "Matrix", "Reverse the transformation between this object and its target");
2589   RNA_def_property_update(prop, NC_OBJECT | ND_TRANSFORM, "rna_Modifier_update");
2590 
2591   prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
2592   RNA_def_property_ui_text(
2593       prop, "Object", "Parent Object for hook, also recalculates and clears offset");
2594   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
2595   RNA_def_property_override_funcs(prop, NULL, NULL, "rna_HookModifier_object_override_apply");
2596   RNA_def_property_pointer_funcs(prop, NULL, "rna_HookModifier_object_set", NULL, NULL);
2597   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
2598 
2599   prop = RNA_def_property(srna, "subtarget", PROP_STRING, PROP_NONE);
2600   RNA_def_property_string_sdna(prop, NULL, "subtarget");
2601   RNA_def_property_ui_text(
2602       prop,
2603       "Sub-Target",
2604       "Name of Parent Bone for hook (if applicable), also recalculates and clears offset");
2605   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_HookModifier_subtarget_set");
2606   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
2607 
2608   prop = RNA_def_property(srna, "use_falloff_uniform", PROP_BOOLEAN, PROP_NONE);
2609   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_HOOK_UNIFORM_SPACE);
2610   RNA_def_property_ui_text(prop, "Uniform Falloff", "Compensate for non-uniform object scale");
2611   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2612 
2613   prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
2614   RNA_def_property_string_sdna(prop, NULL, "name");
2615   RNA_def_property_ui_text(
2616       prop,
2617       "Vertex Group",
2618       "Name of Vertex Group which determines influence of modifier per point");
2619   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_HookModifier_name_set");
2620   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2621 
2622   prop = RNA_def_property(srna, "vertex_indices", PROP_INT, PROP_UNSIGNED);
2623   RNA_def_property_array(prop, RNA_MAX_ARRAY_LENGTH);
2624   RNA_def_property_flag(prop, PROP_DYNAMIC);
2625   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
2626   RNA_def_property_dynamic_array_funcs(prop, "rna_HookModifier_vertex_indices_get_length");
2627   RNA_def_property_int_funcs(prop, "rna_HookModifier_vertex_indices_get", NULL, NULL);
2628   RNA_def_property_ui_text(prop,
2629                            "Vertex Indices",
2630                            "Indices of vertices bound to the modifier. For bezier curves, "
2631                            "handles count as additional vertices");
2632 
2633   func = RNA_def_function(srna, "vertex_indices_set", "rna_HookModifier_vertex_indices_set");
2634   RNA_def_function_ui_description(
2635       func, "Validates and assigns the array of vertex indices bound to the modifier");
2636   RNA_def_function_flag(func, FUNC_USE_REPORTS);
2637   parm = RNA_def_int_array(
2638       func, "indices", 1, NULL, INT_MIN, INT_MAX, "", "Vertex Indices", 0, INT_MAX);
2639   RNA_def_property_array(parm, RNA_MAX_ARRAY_LENGTH);
2640   RNA_def_parameter_flags(parm, PROP_DYNAMIC, PARM_REQUIRED);
2641 
2642   prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
2643   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_HOOK_INVERT_VGROUP);
2644   RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
2645   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2646 
2647   RNA_define_lib_overridable(false);
2648 }
2649 
rna_def_modifier_softbody(BlenderRNA * brna)2650 static void rna_def_modifier_softbody(BlenderRNA *brna)
2651 {
2652   StructRNA *srna;
2653   PropertyRNA *prop;
2654 
2655   srna = RNA_def_struct(brna, "SoftBodyModifier", "Modifier");
2656   RNA_def_struct_ui_text(srna, "Soft Body Modifier", "Soft body simulation modifier");
2657   RNA_def_struct_sdna(srna, "SoftbodyModifierData");
2658   RNA_def_struct_ui_icon(srna, ICON_MOD_SOFT);
2659 
2660   prop = RNA_def_property(srna, "settings", PROP_POINTER, PROP_NONE);
2661   RNA_def_property_flag(prop, PROP_NEVER_NULL);
2662   RNA_def_property_struct_type(prop, "SoftBodySettings");
2663   RNA_def_property_pointer_funcs(prop, "rna_SoftBodyModifier_settings_get", NULL, NULL, NULL);
2664   RNA_def_property_ui_text(prop, "Soft Body Settings", "");
2665 
2666   prop = RNA_def_property(srna, "point_cache", PROP_POINTER, PROP_NONE);
2667   RNA_def_property_flag(prop, PROP_NEVER_NULL);
2668   RNA_def_property_struct_type(prop, "PointCache");
2669   RNA_def_property_pointer_funcs(prop, "rna_SoftBodyModifier_point_cache_get", NULL, NULL, NULL);
2670   RNA_def_property_ui_text(prop, "Soft Body Point Cache", "");
2671 }
2672 
rna_def_modifier_boolean(BlenderRNA * brna)2673 static void rna_def_modifier_boolean(BlenderRNA *brna)
2674 {
2675   StructRNA *srna;
2676   PropertyRNA *prop;
2677 
2678   static const EnumPropertyItem prop_operand_items[] = {
2679       {eBooleanModifierFlag_Object,
2680        "OBJECT",
2681        0,
2682        "Object",
2683        "Use a mesh object as the operand for the Boolean operation"},
2684       {eBooleanModifierFlag_Collection,
2685        "COLLECTION",
2686        0,
2687        "Collection",
2688        "Use a collection of mesh objects as the operand for the Boolean operation"},
2689       {0, NULL, 0, NULL, NULL},
2690   };
2691 
2692   static const EnumPropertyItem prop_operation_items[] = {
2693       {eBooleanModifierOp_Intersect,
2694        "INTERSECT",
2695        0,
2696        "Intersect",
2697        "Keep the part of the mesh that is common between all operands"},
2698       {eBooleanModifierOp_Union, "UNION", 0, "Union", "Combine meshes in an additive way"},
2699       {eBooleanModifierOp_Difference,
2700        "DIFFERENCE",
2701        0,
2702        "Difference",
2703        "Combine meshes in a subtractive way"},
2704       {0, NULL, 0, NULL, NULL},
2705   };
2706 
2707   static const EnumPropertyItem prop_solver_items[] = {
2708       {eBooleanModifierSolver_Fast,
2709        "FAST",
2710        0,
2711        "Fast",
2712        "Simple solver for the best performance, without support for overlapping geometry"},
2713       {eBooleanModifierSolver_Exact, "EXACT", 0, "Exact", "Advanced solver for the best result"},
2714       {0, NULL, 0, NULL, NULL},
2715   };
2716 
2717   srna = RNA_def_struct(brna, "BooleanModifier", "Modifier");
2718   RNA_def_struct_ui_text(srna, "Boolean Modifier", "Boolean operations modifier");
2719   RNA_def_struct_sdna(srna, "BooleanModifierData");
2720   RNA_def_struct_ui_icon(srna, ICON_MOD_BOOLEAN);
2721 
2722   RNA_define_lib_overridable(true);
2723 
2724   prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
2725   RNA_def_property_ui_text(prop, "Object", "Mesh object to use for Boolean operation");
2726   RNA_def_property_pointer_funcs(
2727       prop, NULL, "rna_BooleanModifier_object_set", NULL, "rna_Mesh_object_poll");
2728   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
2729   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
2730 
2731   prop = RNA_def_property(srna, "collection", PROP_POINTER, PROP_NONE);
2732   RNA_def_property_pointer_sdna(prop, NULL, "collection");
2733   RNA_def_property_struct_type(prop, "Collection");
2734   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_REFCOUNT);
2735   RNA_def_property_ui_text(
2736       prop, "Collection", "Use mesh objects in this collection for Boolean operation");
2737   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
2738 
2739   prop = RNA_def_property(srna, "operation", PROP_ENUM, PROP_NONE);
2740   RNA_def_property_enum_items(prop, prop_operation_items);
2741   RNA_def_property_enum_default(prop, eBooleanModifierOp_Difference);
2742   RNA_def_property_ui_text(prop, "Operation", "");
2743   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2744 
2745   prop = RNA_def_property(srna, "operand_type", PROP_ENUM, PROP_NONE);
2746   RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
2747   RNA_def_property_enum_items(prop, prop_operand_items);
2748   RNA_def_property_ui_text(prop, "Operand Type", "");
2749   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2750 
2751   prop = RNA_def_property(srna, "double_threshold", PROP_FLOAT, PROP_DISTANCE);
2752   RNA_def_property_float_sdna(prop, NULL, "double_threshold");
2753   RNA_def_property_range(prop, 0, 1.0f);
2754   RNA_def_property_ui_range(prop, 0, 1, 0.0001, 6);
2755   RNA_def_property_ui_text(
2756       prop, "Overlap Threshold", "Threshold for checking overlapping geometry");
2757   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2758 
2759   prop = RNA_def_property(srna, "solver", PROP_ENUM, PROP_NONE);
2760   RNA_def_property_enum_items(prop, prop_solver_items);
2761   RNA_def_property_enum_default(prop, eBooleanModifierSolver_Exact);
2762   RNA_def_property_ui_text(prop, "Solver", "Method for calculating booleans");
2763   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2764 
2765   prop = RNA_def_property(srna, "use_self", PROP_BOOLEAN, PROP_NONE);
2766   RNA_def_property_boolean_sdna(prop, NULL, "flag", eBooleanModifierFlag_Self);
2767   RNA_def_property_ui_text(prop, "Self", "Allow self-intersection in operands");
2768   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2769 
2770   /* BMesh debugging options, only used when G_DEBUG is set */
2771 
2772   /* BMesh intersection options */
2773   static const EnumPropertyItem debug_items[] = {
2774       {eBooleanModifierBMeshFlag_BMesh_Separate, "SEPARATE", 0, "Separate", ""},
2775       {eBooleanModifierBMeshFlag_BMesh_NoDissolve, "NO_DISSOLVE", 0, "No Dissolve", ""},
2776       {eBooleanModifierBMeshFlag_BMesh_NoConnectRegions,
2777        "NO_CONNECT_REGIONS",
2778        0,
2779        "No Connect Regions",
2780        ""},
2781       {0, NULL, 0, NULL, NULL},
2782   };
2783 
2784   prop = RNA_def_property(srna, "debug_options", PROP_ENUM, PROP_NONE);
2785   RNA_def_property_enum_items(prop, debug_items);
2786   RNA_def_property_enum_sdna(prop, NULL, "bm_flag");
2787   RNA_def_property_flag(prop, PROP_ENUM_FLAG);
2788   RNA_def_property_ui_text(prop, "Debug", "Debugging options, only when started with '-d'");
2789   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2790 
2791   RNA_define_lib_overridable(false);
2792 }
2793 
rna_def_modifier_array(BlenderRNA * brna)2794 static void rna_def_modifier_array(BlenderRNA *brna)
2795 {
2796   StructRNA *srna;
2797   PropertyRNA *prop;
2798 
2799   static const EnumPropertyItem prop_fit_type_items[] = {
2800       {MOD_ARR_FIXEDCOUNT,
2801        "FIXED_COUNT",
2802        0,
2803        "Fixed Count",
2804        "Duplicate the object a certain number of times"},
2805       {MOD_ARR_FITLENGTH,
2806        "FIT_LENGTH",
2807        0,
2808        "Fit Length",
2809        "Duplicate the object as many times as fits in a certain length"},
2810       {MOD_ARR_FITCURVE, "FIT_CURVE", 0, "Fit Curve", "Fit the duplicated objects to a curve"},
2811       {0, NULL, 0, NULL, NULL},
2812   };
2813 
2814   srna = RNA_def_struct(brna, "ArrayModifier", "Modifier");
2815   RNA_def_struct_ui_text(srna, "Array Modifier", "Array duplication modifier");
2816   RNA_def_struct_sdna(srna, "ArrayModifierData");
2817   RNA_def_struct_ui_icon(srna, ICON_MOD_ARRAY);
2818 
2819   RNA_define_lib_overridable(true);
2820 
2821   /* Length parameters */
2822   prop = RNA_def_property(srna, "fit_type", PROP_ENUM, PROP_NONE);
2823   RNA_def_property_enum_items(prop, prop_fit_type_items);
2824   RNA_def_property_ui_text(prop, "Fit Type", "Array length calculation method");
2825   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2826 
2827   prop = RNA_def_property(srna, "count", PROP_INT, PROP_NONE);
2828   RNA_def_property_range(prop, 1, INT_MAX);
2829   RNA_def_property_ui_range(prop, 1, 1000, 1, -1);
2830   RNA_def_property_ui_text(prop, "Count", "Number of duplicates to make");
2831   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2832 
2833   prop = RNA_def_property(srna, "fit_length", PROP_FLOAT, PROP_DISTANCE);
2834   RNA_def_property_float_sdna(prop, NULL, "length");
2835   RNA_def_property_range(prop, 0, INT_MAX);
2836   RNA_def_property_ui_range(prop, 0, 10000, 10, 2);
2837   RNA_def_property_ui_text(prop, "Length", "Length to fit array within");
2838   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2839 
2840   prop = RNA_def_property(srna, "curve", PROP_POINTER, PROP_NONE);
2841   RNA_def_property_pointer_sdna(prop, NULL, "curve_ob");
2842   RNA_def_property_ui_text(prop, "Curve", "Curve object to fit array length to");
2843   RNA_def_property_pointer_funcs(
2844       prop, NULL, "rna_ArrayModifier_curve_ob_set", NULL, "rna_Curve_object_poll");
2845   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
2846   RNA_def_property_update(prop, 0, "rna_ArrayModifier_dependency_update");
2847 
2848   /* Offset parameters */
2849   prop = RNA_def_property(srna, "use_constant_offset", PROP_BOOLEAN, PROP_NONE);
2850   RNA_def_property_boolean_sdna(prop, NULL, "offset_type", MOD_ARR_OFF_CONST);
2851   RNA_def_property_ui_text(prop, "Constant Offset", "Add a constant offset");
2852   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2853 
2854   prop = RNA_def_property(srna, "constant_offset_displace", PROP_FLOAT, PROP_TRANSLATION);
2855   RNA_def_property_float_sdna(prop, NULL, "offset");
2856   RNA_def_property_ui_text(
2857       prop, "Constant Offset Displacement", "Value for the distance between arrayed items");
2858   RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
2859   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2860 
2861   prop = RNA_def_property(srna, "use_relative_offset", PROP_BOOLEAN, PROP_NONE);
2862   RNA_def_property_boolean_sdna(prop, NULL, "offset_type", MOD_ARR_OFF_RELATIVE);
2863   RNA_def_property_ui_text(
2864       prop, "Relative Offset", "Add an offset relative to the object's bounding box");
2865   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2866 
2867   /* PROP_TRANSLATION causes units to be used which we don't want */
2868   prop = RNA_def_property(srna, "relative_offset_displace", PROP_FLOAT, PROP_XYZ);
2869   RNA_def_property_float_sdna(prop, NULL, "scale");
2870   RNA_def_property_ui_text(
2871       prop,
2872       "Relative Offset Displacement",
2873       "The size of the geometry will determine the distance between arrayed items");
2874   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2875 
2876   /* Vertex merging parameters */
2877   prop = RNA_def_property(srna, "use_merge_vertices", PROP_BOOLEAN, PROP_NONE);
2878   RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_ARR_MERGE);
2879   RNA_def_property_ui_text(prop, "Merge Vertices", "Merge vertices in adjacent duplicates");
2880   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2881 
2882   prop = RNA_def_property(srna, "use_merge_vertices_cap", PROP_BOOLEAN, PROP_NONE);
2883   RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_ARR_MERGEFINAL);
2884   RNA_def_property_ui_text(
2885       prop, "Merge End Vertices", "Merge vertices in first and last duplicates");
2886   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2887 
2888   prop = RNA_def_property(srna, "merge_threshold", PROP_FLOAT, PROP_DISTANCE);
2889   RNA_def_property_float_sdna(prop, NULL, "merge_dist");
2890   RNA_def_property_range(prop, 0, FLT_MAX);
2891   RNA_def_property_ui_range(prop, 0, 1, 1, 4);
2892   RNA_def_property_ui_text(prop, "Merge Distance", "Limit below which to merge vertices");
2893   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2894 
2895   /* Offset object */
2896   prop = RNA_def_property(srna, "use_object_offset", PROP_BOOLEAN, PROP_NONE);
2897   RNA_def_property_boolean_sdna(prop, NULL, "offset_type", MOD_ARR_OFF_OBJ);
2898   RNA_def_property_ui_text(
2899       prop, "Object Offset", "Add another object's transformation to the total offset");
2900   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2901 
2902   prop = RNA_def_property(srna, "offset_object", PROP_POINTER, PROP_NONE);
2903   RNA_def_property_pointer_sdna(prop, NULL, "offset_ob");
2904   RNA_def_property_ui_text(
2905       prop,
2906       "Object Offset",
2907       "Use the location and rotation of another object to determine the distance and "
2908       "rotational change between arrayed items");
2909   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
2910   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
2911 
2912   /* Caps */
2913   prop = RNA_def_property(srna, "start_cap", PROP_POINTER, PROP_NONE);
2914   RNA_def_property_ui_text(prop, "Start Cap", "Mesh object to use as a start cap");
2915   RNA_def_property_pointer_funcs(
2916       prop, NULL, "rna_ArrayModifier_start_cap_set", NULL, "rna_Mesh_object_poll");
2917   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
2918   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
2919 
2920   prop = RNA_def_property(srna, "end_cap", PROP_POINTER, PROP_NONE);
2921   RNA_def_property_ui_text(prop, "End Cap", "Mesh object to use as an end cap");
2922   RNA_def_property_pointer_funcs(
2923       prop, NULL, "rna_ArrayModifier_end_cap_set", NULL, "rna_Mesh_object_poll");
2924   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
2925   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
2926 
2927   prop = RNA_def_property(srna, "offset_u", PROP_FLOAT, PROP_FACTOR);
2928   RNA_def_property_float_sdna(prop, NULL, "uv_offset[0]");
2929   RNA_def_property_range(prop, -1, 1);
2930   RNA_def_property_ui_range(prop, -1, 1, 2, 4);
2931   RNA_def_property_ui_text(prop, "U Offset", "Amount to offset array UVs on the U axis");
2932   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2933 
2934   prop = RNA_def_property(srna, "offset_v", PROP_FLOAT, PROP_FACTOR);
2935   RNA_def_property_float_sdna(prop, NULL, "uv_offset[1]");
2936   RNA_def_property_range(prop, -1, 1);
2937   RNA_def_property_ui_range(prop, -1, 1, 2, 4);
2938   RNA_def_property_ui_text(prop, "V Offset", "Amount to offset array UVs on the V axis");
2939   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2940 
2941   RNA_define_lib_overridable(false);
2942 }
2943 
rna_def_modifier_edgesplit(BlenderRNA * brna)2944 static void rna_def_modifier_edgesplit(BlenderRNA *brna)
2945 {
2946   StructRNA *srna;
2947   PropertyRNA *prop;
2948 
2949   srna = RNA_def_struct(brna, "EdgeSplitModifier", "Modifier");
2950   RNA_def_struct_ui_text(
2951       srna, "EdgeSplit Modifier", "Edge splitting modifier to create sharp edges");
2952   RNA_def_struct_sdna(srna, "EdgeSplitModifierData");
2953   RNA_def_struct_ui_icon(srna, ICON_MOD_EDGESPLIT);
2954 
2955   RNA_define_lib_overridable(true);
2956 
2957   prop = RNA_def_property(srna, "split_angle", PROP_FLOAT, PROP_ANGLE);
2958   RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f));
2959   RNA_def_property_ui_range(prop, 0.0f, DEG2RADF(180.0f), 10, 2);
2960   RNA_def_property_ui_text(prop, "Split Angle", "Angle above which to split edges");
2961   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2962 
2963   prop = RNA_def_property(srna, "use_edge_angle", PROP_BOOLEAN, PROP_NONE);
2964   RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_EDGESPLIT_FROMANGLE);
2965   RNA_def_property_ui_text(prop, "Use Edge Angle", "Split edges with high angle between faces");
2966   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2967 
2968   prop = RNA_def_property(srna, "use_edge_sharp", PROP_BOOLEAN, PROP_NONE);
2969   RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_EDGESPLIT_FROMFLAG);
2970   RNA_def_property_ui_text(prop, "Use Sharp Edges", "Split edges that are marked as sharp");
2971   RNA_def_property_update(prop, 0, "rna_Modifier_update");
2972 
2973   RNA_define_lib_overridable(false);
2974 }
2975 
rna_def_modifier_displace(BlenderRNA * brna)2976 static void rna_def_modifier_displace(BlenderRNA *brna)
2977 {
2978   StructRNA *srna;
2979   PropertyRNA *prop;
2980 
2981   static const EnumPropertyItem prop_direction_items[] = {
2982       {MOD_DISP_DIR_X,
2983        "X",
2984        0,
2985        "X",
2986        "Use the texture's intensity value to displace in the X direction"},
2987       {MOD_DISP_DIR_Y,
2988        "Y",
2989        0,
2990        "Y",
2991        "Use the texture's intensity value to displace in the Y direction"},
2992       {MOD_DISP_DIR_Z,
2993        "Z",
2994        0,
2995        "Z",
2996        "Use the texture's intensity value to displace in the Z direction"},
2997       {MOD_DISP_DIR_NOR,
2998        "NORMAL",
2999        0,
3000        "Normal",
3001        "Use the texture's intensity value to displace along the vertex normal"},
3002       {MOD_DISP_DIR_CLNOR,
3003        "CUSTOM_NORMAL",
3004        0,
3005        "Custom Normal",
3006        "Use the texture's intensity value to displace along the (averaged) custom normal (falls "
3007        "back to vertex)"},
3008       {MOD_DISP_DIR_RGB_XYZ,
3009        "RGB_TO_XYZ",
3010        0,
3011        "RGB to XYZ",
3012        "Use the texture's RGB values to displace the mesh in the XYZ direction"},
3013       {0, NULL, 0, NULL, NULL},
3014   };
3015 
3016   static const EnumPropertyItem prop_space_items[] = {
3017       {MOD_DISP_SPACE_LOCAL, "LOCAL", 0, "Local", "Direction is defined in local coordinates"},
3018       {MOD_DISP_SPACE_GLOBAL, "GLOBAL", 0, "Global", "Direction is defined in global coordinates"},
3019       {0, NULL, 0, NULL, NULL},
3020   };
3021 
3022   srna = RNA_def_struct(brna, "DisplaceModifier", "Modifier");
3023   RNA_def_struct_ui_text(srna, "Displace Modifier", "Displacement modifier");
3024   RNA_def_struct_sdna(srna, "DisplaceModifierData");
3025   RNA_def_struct_ui_icon(srna, ICON_MOD_DISPLACE);
3026 
3027   RNA_define_lib_overridable(true);
3028 
3029   prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
3030   RNA_def_property_string_sdna(prop, NULL, "defgrp_name");
3031   RNA_def_property_ui_text(
3032       prop,
3033       "Vertex Group",
3034       "Name of Vertex Group which determines influence of modifier per point");
3035   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_DisplaceModifier_defgrp_name_set");
3036   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3037 
3038   prop = RNA_def_property(srna, "mid_level", PROP_FLOAT, PROP_FACTOR);
3039   RNA_def_property_float_sdna(prop, NULL, "midlevel");
3040   RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
3041   RNA_def_property_ui_range(prop, 0, 1, 10, 3);
3042   RNA_def_property_ui_text(prop, "Midlevel", "Material value that gives no displacement");
3043   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3044 
3045   prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE);
3046   RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
3047   RNA_def_property_ui_range(prop, -100, 100, 10, 3);
3048   RNA_def_property_ui_text(prop, "Strength", "Amount to displace geometry");
3049   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3050 
3051   prop = RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE);
3052   RNA_def_property_enum_items(prop, prop_direction_items);
3053   RNA_def_property_ui_text(prop, "Direction", "");
3054   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3055 
3056   prop = RNA_def_property(srna, "space", PROP_ENUM, PROP_NONE);
3057   RNA_def_property_enum_items(prop, prop_space_items);
3058   RNA_def_property_ui_text(prop, "Space", "");
3059   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
3060 
3061   prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
3062   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_DISP_INVERT_VGROUP);
3063   RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
3064   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3065 
3066   RNA_define_lib_overridable(false);
3067 
3068   rna_def_modifier_generic_map_info(srna);
3069 }
3070 
rna_def_modifier_uvproject(BlenderRNA * brna)3071 static void rna_def_modifier_uvproject(BlenderRNA *brna)
3072 {
3073   StructRNA *srna;
3074   PropertyRNA *prop;
3075 
3076   srna = RNA_def_struct(brna, "UVProjectModifier", "Modifier");
3077   RNA_def_struct_ui_text(
3078       srna, "UV Project Modifier", "UV projection modifier to set UVs from a projector");
3079   RNA_def_struct_sdna(srna, "UVProjectModifierData");
3080   RNA_def_struct_ui_icon(srna, ICON_MOD_UVPROJECT);
3081 
3082   RNA_define_lib_overridable(true);
3083 
3084   prop = RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE);
3085   RNA_def_property_string_sdna(prop, NULL, "uvlayer_name");
3086   RNA_def_property_ui_text(prop, "UV Map", "UV map name");
3087   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_UVProjectModifier_uvlayer_name_set");
3088   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3089 
3090   prop = RNA_def_property(srna, "projector_count", PROP_INT, PROP_NONE);
3091   RNA_def_property_int_sdna(prop, NULL, "num_projectors");
3092   RNA_def_property_ui_text(prop, "Number of Projectors", "Number of projectors to use");
3093   RNA_def_property_int_funcs(prop, NULL, "rna_UVProjectModifier_num_projectors_set", NULL);
3094   RNA_def_property_range(prop, 1, MOD_UVPROJECT_MAXPROJECTORS);
3095   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3096 
3097   prop = RNA_def_property(srna, "projectors", PROP_COLLECTION, PROP_NONE);
3098   RNA_def_property_struct_type(prop, "UVProjector");
3099   RNA_def_property_collection_funcs(prop,
3100                                     "rna_UVProject_projectors_begin",
3101                                     "rna_iterator_array_next",
3102                                     "rna_iterator_array_end",
3103                                     "rna_iterator_array_get",
3104                                     NULL,
3105                                     NULL,
3106                                     NULL,
3107                                     NULL);
3108   RNA_def_property_ui_text(prop, "Projectors", "");
3109 
3110   prop = RNA_def_property(srna, "aspect_x", PROP_FLOAT, PROP_NONE);
3111   RNA_def_property_float_sdna(prop, NULL, "aspectx");
3112   RNA_def_property_flag(prop, PROP_PROPORTIONAL);
3113   RNA_def_property_range(prop, 1, FLT_MAX);
3114   RNA_def_property_ui_range(prop, 1, 1000, 1, 3);
3115   RNA_def_property_ui_text(prop, "Horizontal Aspect Ratio", "");
3116   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3117 
3118   prop = RNA_def_property(srna, "aspect_y", PROP_FLOAT, PROP_NONE);
3119   RNA_def_property_float_sdna(prop, NULL, "aspecty");
3120   RNA_def_property_flag(prop, PROP_PROPORTIONAL);
3121   RNA_def_property_range(prop, 1, FLT_MAX);
3122   RNA_def_property_ui_range(prop, 1, 1000, 1, 3);
3123   RNA_def_property_ui_text(prop, "Vertical Aspect Ratio", "");
3124   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3125 
3126   prop = RNA_def_property(srna, "scale_x", PROP_FLOAT, PROP_NONE);
3127   RNA_def_property_float_sdna(prop, NULL, "scalex");
3128   RNA_def_property_flag(prop, PROP_PROPORTIONAL);
3129   RNA_def_property_range(prop, 0, FLT_MAX);
3130   RNA_def_property_ui_range(prop, 0, 1000, 1, 3);
3131   RNA_def_property_ui_text(prop, "Horizontal Scale", "");
3132   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3133 
3134   prop = RNA_def_property(srna, "scale_y", PROP_FLOAT, PROP_NONE);
3135   RNA_def_property_float_sdna(prop, NULL, "scaley");
3136   RNA_def_property_flag(prop, PROP_PROPORTIONAL);
3137   RNA_def_property_range(prop, 0, FLT_MAX);
3138   RNA_def_property_ui_range(prop, 0, 1000, 1, 3);
3139   RNA_def_property_ui_text(prop, "Vertical Scale", "");
3140   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3141 
3142   srna = RNA_def_struct(brna, "UVProjector", NULL);
3143   RNA_def_struct_ui_text(srna, "UVProjector", "UV projector used by the UV project modifier");
3144 
3145   prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
3146   RNA_def_property_struct_type(prop, "Object");
3147   RNA_def_property_pointer_funcs(
3148       prop, "rna_UVProjector_object_get", "rna_UVProjector_object_set", NULL, NULL);
3149   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
3150   RNA_def_property_ui_text(prop, "Object", "Object to use as projector transform");
3151   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
3152 
3153   RNA_define_lib_overridable(false);
3154 }
3155 
rna_def_modifier_smooth(BlenderRNA * brna)3156 static void rna_def_modifier_smooth(BlenderRNA *brna)
3157 {
3158   StructRNA *srna;
3159   PropertyRNA *prop;
3160 
3161   srna = RNA_def_struct(brna, "SmoothModifier", "Modifier");
3162   RNA_def_struct_ui_text(srna, "Smooth Modifier", "Smoothing effect modifier");
3163   RNA_def_struct_sdna(srna, "SmoothModifierData");
3164   RNA_def_struct_ui_icon(srna, ICON_MOD_SMOOTH);
3165 
3166   RNA_define_lib_overridable(true);
3167 
3168   prop = RNA_def_property(srna, "use_x", PROP_BOOLEAN, PROP_NONE);
3169   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SMOOTH_X);
3170   RNA_def_property_ui_text(prop, "X", "Smooth object along X axis");
3171   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3172 
3173   prop = RNA_def_property(srna, "use_y", PROP_BOOLEAN, PROP_NONE);
3174   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SMOOTH_Y);
3175   RNA_def_property_ui_text(prop, "Y", "Smooth object along Y axis");
3176   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3177 
3178   prop = RNA_def_property(srna, "use_z", PROP_BOOLEAN, PROP_NONE);
3179   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SMOOTH_Z);
3180   RNA_def_property_ui_text(prop, "Z", "Smooth object along Z axis");
3181   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3182 
3183   prop = RNA_def_property(srna, "factor", PROP_FLOAT, PROP_FACTOR);
3184   RNA_def_property_float_sdna(prop, NULL, "fac");
3185   RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
3186   RNA_def_property_ui_range(prop, -10, 10, 1, 3);
3187   RNA_def_property_ui_text(prop, "Factor", "Strength of modifier effect");
3188   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3189 
3190   prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE);
3191   RNA_def_property_int_sdna(prop, NULL, "repeat");
3192   RNA_def_property_ui_range(prop, 0, 30, 1, -1);
3193   RNA_def_property_ui_text(prop, "Repeat", "");
3194   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3195 
3196   prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
3197   RNA_def_property_string_sdna(prop, NULL, "defgrp_name");
3198   RNA_def_property_ui_text(
3199       prop,
3200       "Vertex Group",
3201       "Name of Vertex Group which determines influence of modifier per point");
3202   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SmoothModifier_defgrp_name_set");
3203   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3204 
3205   prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
3206   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SMOOTH_INVERT_VGROUP);
3207   RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
3208   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3209 
3210   RNA_define_lib_overridable(false);
3211 }
3212 
rna_def_modifier_correctivesmooth(BlenderRNA * brna)3213 static void rna_def_modifier_correctivesmooth(BlenderRNA *brna)
3214 {
3215   StructRNA *srna;
3216   PropertyRNA *prop;
3217 
3218   static const EnumPropertyItem modifier_smooth_type_items[] = {
3219       {MOD_CORRECTIVESMOOTH_SMOOTH_SIMPLE,
3220        "SIMPLE",
3221        0,
3222        "Simple",
3223        "Use the average of adjacent edge-vertices"},
3224       {MOD_CORRECTIVESMOOTH_SMOOTH_LENGTH_WEIGHT,
3225        "LENGTH_WEIGHTED",
3226        0,
3227        "Length Weight",
3228        "Use the average of adjacent edge-vertices weighted by their length"},
3229       {0, NULL, 0, NULL, NULL},
3230   };
3231 
3232   static const EnumPropertyItem modifier_rest_source_items[] = {
3233       {MOD_CORRECTIVESMOOTH_RESTSOURCE_ORCO,
3234        "ORCO",
3235        0,
3236        "Original Coords",
3237        "Use base mesh vertex coords as the rest position"},
3238       {MOD_CORRECTIVESMOOTH_RESTSOURCE_BIND,
3239        "BIND",
3240        0,
3241        "Bind Coords",
3242        "Use bind vertex coords for rest position"},
3243       {0, NULL, 0, NULL, NULL},
3244   };
3245 
3246   srna = RNA_def_struct(brna, "CorrectiveSmoothModifier", "Modifier");
3247   RNA_def_struct_ui_text(
3248       srna, "Corrective Smooth Modifier", "Correct distortion caused by deformation");
3249   RNA_def_struct_sdna(srna, "CorrectiveSmoothModifierData");
3250   RNA_def_struct_ui_icon(srna, ICON_MOD_SMOOTH);
3251 
3252   RNA_define_lib_overridable(true);
3253 
3254   prop = RNA_def_property(srna, "factor", PROP_FLOAT, PROP_FACTOR);
3255   RNA_def_property_float_sdna(prop, NULL, "lambda");
3256   RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
3257   RNA_def_property_ui_range(prop, 0.0, 1.0, 5, 3);
3258   RNA_def_property_ui_text(prop, "Lambda Factor", "Smooth factor effect");
3259   RNA_def_property_update(prop, 0, "rna_CorrectiveSmoothModifier_update");
3260 
3261   prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE);
3262   RNA_def_property_int_sdna(prop, NULL, "repeat");
3263   RNA_def_property_ui_range(prop, 0, 200, 1, -1);
3264   RNA_def_property_ui_text(prop, "Repeat", "");
3265   RNA_def_property_update(prop, 0, "rna_CorrectiveSmoothModifier_update");
3266 
3267   prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_FACTOR);
3268   RNA_def_property_float_sdna(prop, NULL, "scale");
3269   RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
3270   RNA_def_property_ui_range(prop, 0.0, 10.0, 5, 3);
3271   RNA_def_property_ui_text(prop, "Scale", "Compensate for scale applied by other modifiers");
3272   RNA_def_property_update(prop, 0, "rna_CorrectiveSmoothModifier_update");
3273 
3274   prop = RNA_def_property(srna, "rest_source", PROP_ENUM, PROP_NONE);
3275   RNA_def_property_enum_sdna(prop, NULL, "rest_source");
3276   RNA_def_property_enum_items(prop, modifier_rest_source_items);
3277   RNA_def_property_ui_text(prop, "Rest Source", "Select the source of rest positions");
3278   RNA_def_property_update(prop, 0, "rna_CorrectiveSmoothModifier_rest_source_update");
3279 
3280   prop = RNA_def_property(srna, "smooth_type", PROP_ENUM, PROP_NONE);
3281   RNA_def_property_enum_sdna(prop, NULL, "smooth_type");
3282   RNA_def_property_enum_items(prop, modifier_smooth_type_items);
3283   RNA_def_property_ui_text(prop, "Smooth Type", "Method used for smoothing");
3284   RNA_def_property_update(prop, 0, "rna_CorrectiveSmoothModifier_update");
3285 
3286   prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
3287   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_CORRECTIVESMOOTH_INVERT_VGROUP);
3288   RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
3289   RNA_def_property_update(prop, 0, "rna_CorrectiveSmoothModifier_update");
3290 
3291   prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
3292   RNA_def_property_string_sdna(prop, NULL, "defgrp_name");
3293   RNA_def_property_ui_text(
3294       prop,
3295       "Vertex Group",
3296       "Name of Vertex Group which determines influence of modifier per point");
3297   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_CorrectiveSmoothModifier_defgrp_name_set");
3298   RNA_def_property_update(prop, 0, "rna_CorrectiveSmoothModifier_update");
3299 
3300   prop = RNA_def_property(srna, "is_bind", PROP_BOOLEAN, PROP_NONE);
3301   RNA_def_property_ui_text(prop, "Bind current shape", "");
3302   RNA_def_property_boolean_funcs(prop, "rna_CorrectiveSmoothModifier_is_bind_get", NULL);
3303   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
3304   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3305 
3306   prop = RNA_def_property(srna, "use_only_smooth", PROP_BOOLEAN, PROP_NONE);
3307   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_CORRECTIVESMOOTH_ONLY_SMOOTH);
3308   RNA_def_property_ui_text(
3309       prop, "Only Smooth", "Apply smoothing without reconstructing the surface");
3310   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3311 
3312   prop = RNA_def_property(srna, "use_pin_boundary", PROP_BOOLEAN, PROP_NONE);
3313   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_CORRECTIVESMOOTH_PIN_BOUNDARY);
3314   RNA_def_property_ui_text(
3315       prop, "Pin Boundaries", "Excludes boundary vertices from being smoothed");
3316   RNA_def_property_update(prop, 0, "rna_CorrectiveSmoothModifier_update");
3317 
3318   RNA_define_lib_overridable(false);
3319 }
3320 
rna_def_modifier_laplaciansmooth(BlenderRNA * brna)3321 static void rna_def_modifier_laplaciansmooth(BlenderRNA *brna)
3322 {
3323   StructRNA *srna;
3324   PropertyRNA *prop;
3325 
3326   srna = RNA_def_struct(brna, "LaplacianSmoothModifier", "Modifier");
3327   RNA_def_struct_ui_text(srna, "Laplacian Smooth Modifier", "Smoothing effect modifier");
3328   RNA_def_struct_sdna(srna, "LaplacianSmoothModifierData");
3329   RNA_def_struct_ui_icon(srna, ICON_MOD_SMOOTH);
3330 
3331   RNA_define_lib_overridable(true);
3332 
3333   prop = RNA_def_property(srna, "use_x", PROP_BOOLEAN, PROP_NONE);
3334   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_LAPLACIANSMOOTH_X);
3335   RNA_def_property_ui_text(prop, "X", "Smooth object along X axis");
3336   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3337 
3338   prop = RNA_def_property(srna, "use_y", PROP_BOOLEAN, PROP_NONE);
3339   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_LAPLACIANSMOOTH_Y);
3340   RNA_def_property_ui_text(prop, "Y", "Smooth object along Y axis");
3341   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3342 
3343   prop = RNA_def_property(srna, "use_z", PROP_BOOLEAN, PROP_NONE);
3344   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_LAPLACIANSMOOTH_Z);
3345   RNA_def_property_ui_text(prop, "Z", "Smooth object along Z axis");
3346   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3347 
3348   prop = RNA_def_property(srna, "use_volume_preserve", PROP_BOOLEAN, PROP_NONE);
3349   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_LAPLACIANSMOOTH_PRESERVE_VOLUME);
3350   RNA_def_property_ui_text(prop, "Preserve Volume", "Apply volume preservation after smooth");
3351   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3352 
3353   prop = RNA_def_property(srna, "use_normalized", PROP_BOOLEAN, PROP_NONE);
3354   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_LAPLACIANSMOOTH_NORMALIZED);
3355   RNA_def_property_ui_text(prop, "Normalized", "Improve and stabilize the enhanced shape");
3356   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3357 
3358   prop = RNA_def_property(srna, "lambda_factor", PROP_FLOAT, PROP_NONE);
3359   RNA_def_property_float_sdna(prop, NULL, "lambda");
3360   RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
3361   RNA_def_property_ui_range(prop, -1000.0, 1000.0, 5, 3);
3362   RNA_def_property_ui_text(prop, "Lambda Factor", "Smooth factor effect");
3363   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3364 
3365   prop = RNA_def_property(srna, "lambda_border", PROP_FLOAT, PROP_NONE);
3366   RNA_def_property_float_sdna(prop, NULL, "lambda_border");
3367   RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
3368   RNA_def_property_ui_range(prop, -1000.0, 1000.0, 5, 3);
3369   RNA_def_property_ui_text(prop, "Lambda Border", "Lambda factor in border");
3370   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3371 
3372   prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE);
3373   RNA_def_property_int_sdna(prop, NULL, "repeat");
3374   RNA_def_property_ui_range(prop, 0, 200, 1, -1);
3375   RNA_def_property_ui_text(prop, "Repeat", "");
3376   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3377 
3378   prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
3379   RNA_def_property_string_sdna(prop, NULL, "defgrp_name");
3380   RNA_def_property_ui_text(
3381       prop,
3382       "Vertex Group",
3383       "Name of Vertex Group which determines influence of modifier per point");
3384   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_LaplacianSmoothModifier_defgrp_name_set");
3385   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3386 
3387   prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
3388   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_LAPLACIANSMOOTH_INVERT_VGROUP);
3389   RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
3390   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3391 
3392   RNA_define_lib_overridable(false);
3393 }
3394 
rna_def_modifier_cast(BlenderRNA * brna)3395 static void rna_def_modifier_cast(BlenderRNA *brna)
3396 {
3397   StructRNA *srna;
3398   PropertyRNA *prop;
3399 
3400   static const EnumPropertyItem prop_cast_type_items[] = {
3401       {MOD_CAST_TYPE_SPHERE, "SPHERE", 0, "Sphere", ""},
3402       {MOD_CAST_TYPE_CYLINDER, "CYLINDER", 0, "Cylinder", ""},
3403       {MOD_CAST_TYPE_CUBOID, "CUBOID", 0, "Cuboid", ""},
3404       {0, NULL, 0, NULL, NULL},
3405   };
3406 
3407   srna = RNA_def_struct(brna, "CastModifier", "Modifier");
3408   RNA_def_struct_ui_text(srna, "Cast Modifier", "Modifier to cast to other shapes");
3409   RNA_def_struct_sdna(srna, "CastModifierData");
3410   RNA_def_struct_ui_icon(srna, ICON_MOD_CAST);
3411 
3412   RNA_define_lib_overridable(true);
3413 
3414   prop = RNA_def_property(srna, "cast_type", PROP_ENUM, PROP_NONE);
3415   RNA_def_property_enum_sdna(prop, NULL, "type");
3416   RNA_def_property_enum_items(prop, prop_cast_type_items);
3417   RNA_def_property_ui_text(prop, "Shape", "Target object shape");
3418   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3419 
3420   prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
3421   RNA_def_property_ui_text(
3422       prop,
3423       "Object",
3424       "Control object: if available, its location determines the center of the effect");
3425   RNA_def_property_pointer_funcs(prop, NULL, "rna_CastModifier_object_set", NULL, NULL);
3426   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
3427   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
3428 
3429   prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
3430   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_CAST_INVERT_VGROUP);
3431   RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
3432   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3433 
3434   prop = RNA_def_property(srna, "use_x", PROP_BOOLEAN, PROP_NONE);
3435   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_CAST_X);
3436   RNA_def_property_ui_text(prop, "X", "");
3437   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3438 
3439   prop = RNA_def_property(srna, "use_y", PROP_BOOLEAN, PROP_NONE);
3440   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_CAST_Y);
3441   RNA_def_property_ui_text(prop, "Y", "");
3442   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3443 
3444   prop = RNA_def_property(srna, "use_z", PROP_BOOLEAN, PROP_NONE);
3445   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_CAST_Z);
3446   RNA_def_property_ui_text(prop, "Z", "");
3447   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3448 
3449   prop = RNA_def_property(srna, "use_radius_as_size", PROP_BOOLEAN, PROP_NONE);
3450   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_CAST_SIZE_FROM_RADIUS);
3451   RNA_def_property_ui_text(
3452       prop, "Size from Radius", "Use radius as size of projection shape (0 = auto)");
3453   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3454 
3455   prop = RNA_def_property(srna, "use_transform", PROP_BOOLEAN, PROP_NONE);
3456   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_CAST_USE_OB_TRANSFORM);
3457   RNA_def_property_ui_text(
3458       prop, "Use Transform", "Use object transform to control projection shape");
3459   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3460 
3461   prop = RNA_def_property(srna, "factor", PROP_FLOAT, PROP_FACTOR);
3462   RNA_def_property_float_sdna(prop, NULL, "fac");
3463   RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
3464   RNA_def_property_ui_range(prop, -10, 10, 5, 2);
3465   RNA_def_property_ui_text(prop, "Factor", "");
3466   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3467 
3468   prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_DISTANCE);
3469   RNA_def_property_range(prop, 0, FLT_MAX);
3470   RNA_def_property_ui_range(prop, 0, 100, 5, 2);
3471   RNA_def_property_ui_text(
3472       prop,
3473       "Radius",
3474       "Only deform vertices within this distance from the center of the effect "
3475       "(leave as 0 for infinite.)");
3476   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3477 
3478   prop = RNA_def_property(srna, "size", PROP_FLOAT, PROP_NONE);
3479   RNA_def_property_range(prop, 0, FLT_MAX);
3480   RNA_def_property_ui_range(prop, 0, 100, 5, 2);
3481   RNA_def_property_ui_text(prop, "Size", "Size of projection shape (leave as 0 for auto)");
3482   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3483 
3484   prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
3485   RNA_def_property_string_sdna(prop, NULL, "defgrp_name");
3486   RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name");
3487   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_CastModifier_defgrp_name_set");
3488   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3489 
3490   RNA_define_lib_overridable(false);
3491 }
3492 
rna_def_modifier_meshdeform(BlenderRNA * brna)3493 static void rna_def_modifier_meshdeform(BlenderRNA *brna)
3494 {
3495   StructRNA *srna;
3496   PropertyRNA *prop;
3497 #  if 0
3498   static const EnumPropertyItem prop_mode_items[] = {
3499       {0, "VOLUME", 0, "Volume", "Bind to volume inside cage mesh"},
3500       {1, "SURFACE", 0, "Surface", "Bind to surface of cage mesh"},
3501       {0, NULL, 0, NULL, NULL},
3502   };
3503 #  endif
3504 
3505   srna = RNA_def_struct(brna, "MeshDeformModifier", "Modifier");
3506   RNA_def_struct_ui_text(
3507       srna, "MeshDeform Modifier", "Mesh deformation modifier to deform with other meshes");
3508   RNA_def_struct_sdna(srna, "MeshDeformModifierData");
3509   RNA_def_struct_ui_icon(srna, ICON_MOD_MESHDEFORM);
3510 
3511   RNA_define_lib_overridable(true);
3512 
3513   prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
3514   RNA_def_property_ui_text(prop, "Object", "Mesh object to deform with");
3515   RNA_def_property_pointer_funcs(
3516       prop, NULL, "rna_MeshDeformModifier_object_set", NULL, "rna_Mesh_object_poll");
3517   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
3518   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
3519 
3520   prop = RNA_def_property(srna, "is_bound", PROP_BOOLEAN, PROP_NONE);
3521   RNA_def_property_boolean_funcs(prop, "rna_MeshDeformModifier_is_bound_get", NULL);
3522   RNA_def_property_ui_text(prop, "Bound", "Whether geometry has been bound to control cage");
3523   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
3524 
3525   prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
3526   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_MDEF_INVERT_VGROUP);
3527   RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
3528   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3529 
3530   prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
3531   RNA_def_property_string_sdna(prop, NULL, "defgrp_name");
3532   RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name");
3533   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MeshDeformModifier_defgrp_name_set");
3534   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3535 
3536   prop = RNA_def_property(srna, "precision", PROP_INT, PROP_NONE);
3537   RNA_def_property_int_sdna(prop, NULL, "gridsize");
3538   RNA_def_property_range(prop, 2, 10);
3539   RNA_def_property_ui_text(prop, "Precision", "The grid size for binding");
3540   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3541 
3542   prop = RNA_def_property(srna, "use_dynamic_bind", PROP_BOOLEAN, PROP_NONE);
3543   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_MDEF_DYNAMIC_BIND);
3544   RNA_def_property_ui_text(prop,
3545                            "Dynamic",
3546                            "Recompute binding dynamically on top of other deformers "
3547                            "(slower and more memory consuming)");
3548   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3549 
3550 #  if 0
3551   prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
3552   RNA_def_property_enum_items(prop, prop_mode_items);
3553   RNA_def_property_ui_text(prop, "Mode", "Method of binding vertices are bound to cage mesh");
3554   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3555 #  endif
3556 
3557   RNA_define_lib_overridable(false);
3558 }
3559 
rna_def_modifier_particlesystem(BlenderRNA * brna)3560 static void rna_def_modifier_particlesystem(BlenderRNA *brna)
3561 {
3562   StructRNA *srna;
3563   PropertyRNA *prop;
3564 
3565   srna = RNA_def_struct(brna, "ParticleSystemModifier", "Modifier");
3566   RNA_def_struct_ui_text(srna, "ParticleSystem Modifier", "Particle system simulation modifier");
3567   RNA_def_struct_sdna(srna, "ParticleSystemModifierData");
3568   RNA_def_struct_ui_icon(srna, ICON_MOD_PARTICLES);
3569 
3570   RNA_define_lib_overridable(true);
3571 
3572   prop = RNA_def_property(srna, "particle_system", PROP_POINTER, PROP_NONE);
3573   RNA_def_property_flag(prop, PROP_NEVER_NULL);
3574   RNA_def_property_pointer_sdna(prop, NULL, "psys");
3575   RNA_def_property_ui_text(prop, "Particle System", "Particle System that this modifier controls");
3576 
3577   RNA_define_lib_overridable(false);
3578 }
3579 
rna_def_modifier_particleinstance(BlenderRNA * brna)3580 static void rna_def_modifier_particleinstance(BlenderRNA *brna)
3581 {
3582   StructRNA *srna;
3583   PropertyRNA *prop;
3584 
3585   static EnumPropertyItem particleinstance_space[] = {
3586       {eParticleInstanceSpace_Local,
3587        "LOCAL",
3588        0,
3589        "Local",
3590        "Use offset from the particle object in the instance object"},
3591       {eParticleInstanceSpace_World,
3592        "WORLD",
3593        0,
3594        "World",
3595        "Use world space offset in the instance object"},
3596       {0, NULL, 0, NULL, NULL},
3597   };
3598 
3599   srna = RNA_def_struct(brna, "ParticleInstanceModifier", "Modifier");
3600   RNA_def_struct_ui_text(srna, "ParticleInstance Modifier", "Particle system instancing modifier");
3601   RNA_def_struct_sdna(srna, "ParticleInstanceModifierData");
3602   RNA_def_struct_ui_icon(srna, ICON_MOD_PARTICLES);
3603 
3604   RNA_define_lib_overridable(true);
3605 
3606   prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
3607   RNA_def_property_pointer_sdna(prop, NULL, "ob");
3608   RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Mesh_object_poll");
3609   RNA_def_property_ui_text(prop, "Object", "Object that has the particle system");
3610   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
3611   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
3612 
3613   prop = RNA_def_property(srna, "particle_system_index", PROP_INT, PROP_NONE);
3614   RNA_def_property_int_sdna(prop, NULL, "psys");
3615   RNA_def_property_range(prop, 1, SHRT_MAX);
3616   RNA_def_property_ui_text(prop, "Particle System Number", "");
3617   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3618 
3619   prop = RNA_def_property(srna, "particle_system", PROP_POINTER, PROP_NONE);
3620   RNA_def_property_struct_type(prop, "ParticleSystem");
3621   RNA_def_property_pointer_funcs(prop,
3622                                  "rna_ParticleInstanceModifier_particle_system_get",
3623                                  "rna_ParticleInstanceModifier_particle_system_set",
3624                                  NULL,
3625                                  "rna_ParticleInstanceModifier_particle_system_poll");
3626   RNA_def_property_flag(prop, PROP_EDITABLE);
3627   RNA_def_property_ui_text(prop, "Particle System", "");
3628   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3629 
3630   prop = RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE);
3631   RNA_def_property_enum_sdna(prop, NULL, "axis");
3632   RNA_def_property_enum_items(prop, rna_enum_axis_xyz_items);
3633   RNA_def_property_ui_text(prop, "Axis", "Pole axis for rotation");
3634   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3635 
3636   prop = RNA_def_property(srna, "space", PROP_ENUM, PROP_NONE);
3637   RNA_def_property_enum_sdna(prop, NULL, "space");
3638   RNA_def_property_enum_items(prop, particleinstance_space);
3639   RNA_def_property_ui_text(prop, "Space", "Space to use for copying mesh data");
3640   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3641 
3642   prop = RNA_def_property(srna, "use_normal", PROP_BOOLEAN, PROP_NONE);
3643   RNA_def_property_boolean_sdna(prop, NULL, "flag", eParticleInstanceFlag_Parents);
3644   RNA_def_property_ui_text(prop, "Regular", "Create instances from normal particles");
3645   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3646 
3647   prop = RNA_def_property(srna, "use_children", PROP_BOOLEAN, PROP_NONE);
3648   RNA_def_property_boolean_sdna(prop, NULL, "flag", eParticleInstanceFlag_Children);
3649   RNA_def_property_ui_text(prop, "Children", "Create instances from child particles");
3650   RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_PARTICLESETTINGS);
3651   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3652 
3653   prop = RNA_def_property(srna, "use_path", PROP_BOOLEAN, PROP_NONE);
3654   RNA_def_property_boolean_sdna(prop, NULL, "flag", eParticleInstanceFlag_Path);
3655   RNA_def_property_ui_text(prop, "Path", "Create instances along particle paths");
3656   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3657 
3658   prop = RNA_def_property(srna, "show_unborn", PROP_BOOLEAN, PROP_NONE);
3659   RNA_def_property_boolean_sdna(prop, NULL, "flag", eParticleInstanceFlag_Unborn);
3660   RNA_def_property_ui_text(prop, "Unborn", "Show instances when particles are unborn");
3661   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3662 
3663   prop = RNA_def_property(srna, "show_alive", PROP_BOOLEAN, PROP_NONE);
3664   RNA_def_property_boolean_sdna(prop, NULL, "flag", eParticleInstanceFlag_Alive);
3665   RNA_def_property_ui_text(prop, "Alive", "Show instances when particles are alive");
3666   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3667 
3668   prop = RNA_def_property(srna, "show_dead", PROP_BOOLEAN, PROP_NONE);
3669   RNA_def_property_boolean_sdna(prop, NULL, "flag", eParticleInstanceFlag_Dead);
3670   RNA_def_property_ui_text(prop, "Dead", "Show instances when particles are dead");
3671   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3672 
3673   prop = RNA_def_property(srna, "use_preserve_shape", PROP_BOOLEAN, PROP_NONE);
3674   RNA_def_property_boolean_sdna(prop, NULL, "flag", eParticleInstanceFlag_KeepShape);
3675   RNA_def_property_ui_text(prop, "Keep Shape", "Don't stretch the object");
3676   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3677 
3678   prop = RNA_def_property(srna, "use_size", PROP_BOOLEAN, PROP_NONE);
3679   RNA_def_property_boolean_sdna(prop, NULL, "flag", eParticleInstanceFlag_UseSize);
3680   RNA_def_property_ui_text(prop, "Size", "Use particle size to scale the instances");
3681   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3682 
3683   prop = RNA_def_property(srna, "position", PROP_FLOAT, PROP_NONE);
3684   RNA_def_property_float_sdna(prop, NULL, "position");
3685   RNA_def_property_range(prop, 0.0, 1.0);
3686   RNA_def_property_ui_text(prop, "Position", "Position along path");
3687   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3688 
3689   prop = RNA_def_property(srna, "random_position", PROP_FLOAT, PROP_NONE);
3690   RNA_def_property_float_sdna(prop, NULL, "random_position");
3691   RNA_def_property_range(prop, 0.0, 1.0);
3692   RNA_def_property_ui_text(prop, "Random Position", "Randomize position along path");
3693   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3694 
3695   prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_FACTOR);
3696   RNA_def_property_float_sdna(prop, NULL, "rotation");
3697   RNA_def_property_range(prop, 0.0, 1.0);
3698   RNA_def_property_ui_text(prop, "Rotation", "Rotation around path");
3699   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3700 
3701   prop = RNA_def_property(srna, "random_rotation", PROP_FLOAT, PROP_FACTOR);
3702   RNA_def_property_float_sdna(prop, NULL, "random_rotation");
3703   RNA_def_property_range(prop, 0.0, 1.0);
3704   RNA_def_property_ui_text(prop, "Random Rotation", "Randomize rotation around path");
3705   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3706 
3707   prop = RNA_def_property(srna, "particle_amount", PROP_FLOAT, PROP_FACTOR);
3708   RNA_def_property_range(prop, 0.0, 1.0);
3709   RNA_def_property_ui_text(prop, "Particle Amount", "Amount of particles to use for instancing");
3710   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3711 
3712   prop = RNA_def_property(srna, "particle_offset", PROP_FLOAT, PROP_FACTOR);
3713   RNA_def_property_range(prop, 0.0, 1.0);
3714   RNA_def_property_ui_text(prop,
3715                            "Particle Offset",
3716                            "Relative offset of particles to use for instancing, to avoid overlap "
3717                            "of multiple instances");
3718   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3719 
3720   prop = RNA_def_property(srna, "index_layer_name", PROP_STRING, PROP_NONE);
3721   RNA_def_property_string_sdna(prop, NULL, "index_layer_name");
3722   RNA_def_property_ui_text(prop, "Index Layer Name", "Custom data layer name for the index");
3723   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3724 
3725   prop = RNA_def_property(srna, "value_layer_name", PROP_STRING, PROP_NONE);
3726   RNA_def_property_string_sdna(prop, NULL, "value_layer_name");
3727   RNA_def_property_ui_text(
3728       prop, "Value Layer Name", "Custom data layer name for the randomized value");
3729   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3730 
3731   RNA_define_lib_overridable(false);
3732 }
3733 
rna_def_modifier_explode(BlenderRNA * brna)3734 static void rna_def_modifier_explode(BlenderRNA *brna)
3735 {
3736   StructRNA *srna;
3737   PropertyRNA *prop;
3738 
3739   srna = RNA_def_struct(brna, "ExplodeModifier", "Modifier");
3740   RNA_def_struct_ui_text(
3741       srna, "Explode Modifier", "Explosion effect modifier based on a particle system");
3742   RNA_def_struct_sdna(srna, "ExplodeModifierData");
3743   RNA_def_struct_ui_icon(srna, ICON_MOD_EXPLODE);
3744 
3745   RNA_define_lib_overridable(true);
3746 
3747   prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
3748   RNA_def_property_string_funcs(prop,
3749                                 "rna_ExplodeModifier_vgroup_get",
3750                                 "rna_ExplodeModifier_vgroup_length",
3751                                 "rna_ExplodeModifier_vgroup_set");
3752   RNA_def_property_ui_text(prop, "Vertex Group", "");
3753 
3754   prop = RNA_def_property(srna, "protect", PROP_FLOAT, PROP_NONE);
3755   RNA_def_property_range(prop, 0, 1);
3756   RNA_def_property_ui_text(prop, "Protect", "Clean vertex group edges");
3757   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3758 
3759   prop = RNA_def_property(srna, "use_edge_cut", PROP_BOOLEAN, PROP_NONE);
3760   RNA_def_property_boolean_sdna(prop, NULL, "flag", eExplodeFlag_EdgeCut);
3761   RNA_def_property_ui_text(prop, "Cut Edges", "Cut face edges for nicer shrapnel");
3762   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3763 
3764   prop = RNA_def_property(srna, "show_unborn", PROP_BOOLEAN, PROP_NONE);
3765   RNA_def_property_boolean_sdna(prop, NULL, "flag", eExplodeFlag_Unborn);
3766   RNA_def_property_ui_text(prop, "Unborn", "Show mesh when particles are unborn");
3767   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3768 
3769   prop = RNA_def_property(srna, "show_alive", PROP_BOOLEAN, PROP_NONE);
3770   RNA_def_property_boolean_sdna(prop, NULL, "flag", eExplodeFlag_Alive);
3771   RNA_def_property_ui_text(prop, "Alive", "Show mesh when particles are alive");
3772   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3773 
3774   prop = RNA_def_property(srna, "show_dead", PROP_BOOLEAN, PROP_NONE);
3775   RNA_def_property_boolean_sdna(prop, NULL, "flag", eExplodeFlag_Dead);
3776   RNA_def_property_ui_text(prop, "Dead", "Show mesh when particles are dead");
3777   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3778 
3779   prop = RNA_def_property(srna, "use_size", PROP_BOOLEAN, PROP_NONE);
3780   RNA_def_property_boolean_sdna(prop, NULL, "flag", eExplodeFlag_PaSize);
3781   RNA_def_property_ui_text(prop, "Size", "Use particle size for the shrapnel");
3782   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3783 
3784   prop = RNA_def_property(srna, "particle_uv", PROP_STRING, PROP_NONE);
3785   RNA_def_property_string_sdna(prop, NULL, "uvname");
3786   RNA_def_property_string_maxlength(prop, MAX_CUSTOMDATA_LAYER_NAME);
3787   RNA_def_property_ui_text(prop, "Particle UV", "UV map to change with particle age");
3788   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3789 
3790   prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
3791   RNA_def_property_boolean_sdna(prop, NULL, "flag", eExplodeFlag_INVERT_VGROUP);
3792   RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
3793   RNA_def_property_update(prop, 0, "rna_Modifier_update");
3794 
3795   RNA_define_lib_overridable(false);
3796 }
3797 
rna_def_modifier_cloth(BlenderRNA * brna)3798 static void rna_def_modifier_cloth(BlenderRNA *brna)
3799 {
3800   StructRNA *srna;
3801   PropertyRNA *prop;
3802 
3803   srna = RNA_def_struct(brna, "ClothModifier", "Modifier");
3804   RNA_def_struct_ui_text(srna, "Cloth Modifier", "Cloth simulation modifier");
3805   RNA_def_struct_sdna(srna, "ClothModifierData");
3806   RNA_def_struct_ui_icon(srna, ICON_MOD_CLOTH);
3807 
3808   RNA_define_lib_overridable(true);
3809 
3810   prop = RNA_def_property(srna, "settings", PROP_POINTER, PROP_NONE);
3811   RNA_def_property_flag(prop, PROP_NEVER_NULL);
3812   RNA_def_property_pointer_sdna(prop, NULL, "sim_parms");
3813   RNA_def_property_ui_text(prop, "Cloth Settings", "");
3814 
3815   prop = RNA_def_property(srna, "collision_settings", PROP_POINTER, PROP_NONE);
3816   RNA_def_property_flag(prop, PROP_NEVER_NULL);
3817   RNA_def_property_pointer_sdna(prop, NULL, "coll_parms");
3818   RNA_def_property_ui_text(prop, "Cloth Collision Settings", "");
3819 
3820   prop = RNA_def_property(srna, "solver_result", PROP_POINTER, PROP_NONE);
3821   RNA_def_property_struct_type(prop, "ClothSolverResult");
3822   RNA_def_property_pointer_sdna(prop, NULL, "solver_result");
3823   RNA_def_property_ui_text(prop, "Solver Result", "");
3824 
3825   prop = RNA_def_property(srna, "point_cache", PROP_POINTER, PROP_NONE);
3826   RNA_def_property_flag(prop, PROP_NEVER_NULL);
3827   RNA_def_property_ui_text(prop, "Point Cache", "");
3828 
3829   prop = RNA_def_property(srna, "hair_grid_min", PROP_FLOAT, PROP_NONE);
3830   RNA_def_property_float_sdna(prop, NULL, "hair_grid_min");
3831   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
3832   RNA_def_property_ui_text(prop, "Hair Grid Minimum", "");
3833 
3834   prop = RNA_def_property(srna, "hair_grid_max", PROP_FLOAT, PROP_NONE);
3835   RNA_def_property_float_sdna(prop, NULL, "hair_grid_max");
3836   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
3837   RNA_def_property_ui_text(prop, "Hair Grid Maximum", "");
3838 
3839   prop = RNA_def_property(srna, "hair_grid_resolution", PROP_INT, PROP_NONE);
3840   RNA_def_property_int_sdna(prop, NULL, "hair_grid_res");
3841   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
3842   RNA_def_property_ui_text(prop, "Hair Grid Resolution", "");
3843 
3844   RNA_define_lib_overridable(false);
3845 }
3846 
rna_def_modifier_fluid(BlenderRNA * brna)3847 static void rna_def_modifier_fluid(BlenderRNA *brna)
3848 {
3849   StructRNA *srna;
3850   PropertyRNA *prop;
3851 
3852   static const EnumPropertyItem prop_fluid_type_items[] = {
3853       {0, "NONE", 0, "None", ""},
3854       {MOD_FLUID_TYPE_DOMAIN, "DOMAIN", 0, "Domain", ""},
3855       {MOD_FLUID_TYPE_FLOW, "FLOW", 0, "Flow", "Inflow/Outflow"},
3856       {MOD_FLUID_TYPE_EFFEC, "EFFECTOR", 0, "Effector", ""},
3857       {0, NULL, 0, NULL, NULL},
3858   };
3859 
3860   srna = RNA_def_struct(brna, "FluidModifier", "Modifier");
3861   RNA_def_struct_ui_text(srna, "Fluid Modifier", "Fluid simulation modifier");
3862   RNA_def_struct_sdna(srna, "FluidModifierData");
3863   RNA_def_struct_ui_icon(srna, ICON_MOD_FLUIDSIM);
3864 
3865   RNA_define_lib_overridable(true);
3866 
3867   prop = RNA_def_property(srna, "domain_settings", PROP_POINTER, PROP_NONE);
3868   RNA_def_property_pointer_sdna(prop, NULL, "domain");
3869   RNA_def_property_ui_text(prop, "Domain Settings", "");
3870 
3871   prop = RNA_def_property(srna, "flow_settings", PROP_POINTER, PROP_NONE);
3872   RNA_def_property_pointer_sdna(prop, NULL, "flow");
3873   RNA_def_property_ui_text(prop, "Flow Settings", "");
3874 
3875   prop = RNA_def_property(srna, "effector_settings", PROP_POINTER, PROP_NONE);
3876   RNA_def_property_pointer_sdna(prop, NULL, "effector");
3877   RNA_def_property_ui_text(prop, "Effector Settings", "");
3878 
3879   prop = RNA_def_property(srna, "fluid_type", PROP_ENUM, PROP_NONE);
3880   RNA_def_property_enum_sdna(prop, NULL, "type");
3881   RNA_def_property_enum_items(prop, prop_fluid_type_items);
3882   RNA_def_property_ui_text(prop, "Type", "");
3883   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
3884   RNA_def_property_update(prop, 0, "rna_fluid_set_type");
3885 
3886   RNA_define_lib_overridable(false);
3887 }
3888 
rna_def_modifier_dynamic_paint(BlenderRNA * brna)3889 static void rna_def_modifier_dynamic_paint(BlenderRNA *brna)
3890 {
3891   StructRNA *srna;
3892   PropertyRNA *prop;
3893 
3894   srna = RNA_def_struct(brna, "DynamicPaintModifier", "Modifier");
3895   RNA_def_struct_ui_text(srna, "Dynamic Paint Modifier", "Dynamic Paint modifier");
3896   RNA_def_struct_sdna(srna, "DynamicPaintModifierData");
3897   RNA_def_struct_ui_icon(srna, ICON_MOD_DYNAMICPAINT);
3898 
3899   RNA_define_lib_overridable(true);
3900 
3901   prop = RNA_def_property(srna, "canvas_settings", PROP_POINTER, PROP_NONE);
3902   RNA_def_property_pointer_sdna(prop, NULL, "canvas");
3903   RNA_def_property_ui_text(prop, "Canvas Settings", "");
3904 
3905   prop = RNA_def_property(srna, "brush_settings", PROP_POINTER, PROP_NONE);
3906   RNA_def_property_pointer_sdna(prop, NULL, "brush");
3907   RNA_def_property_ui_text(prop, "Brush Settings", "");
3908 
3909   prop = RNA_def_property(srna, "ui_type", PROP_ENUM, PROP_NONE);
3910   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
3911   RNA_def_property_enum_sdna(prop, NULL, "type");
3912   RNA_def_property_enum_items(prop, rna_enum_prop_dynamicpaint_type_items);
3913   RNA_def_property_ui_text(prop, "Type", "");
3914 
3915   RNA_define_lib_overridable(false);
3916 }
3917 
rna_def_modifier_collision(BlenderRNA * brna)3918 static void rna_def_modifier_collision(BlenderRNA *brna)
3919 {
3920   StructRNA *srna;
3921   PropertyRNA *prop;
3922 
3923   srna = RNA_def_struct(brna, "CollisionModifier", "Modifier");
3924   RNA_def_struct_ui_text(srna,
3925                          "Collision Modifier",
3926                          "Collision modifier defining modifier stack position used for collision");
3927   RNA_def_struct_sdna(srna, "CollisionModifierData");
3928   RNA_def_struct_ui_icon(srna, ICON_MOD_PHYSICS);
3929 
3930   RNA_define_lib_overridable(true);
3931 
3932   prop = RNA_def_property(srna, "settings", PROP_POINTER, PROP_NONE);
3933   RNA_def_property_flag(prop, PROP_NEVER_NULL);
3934   RNA_def_property_struct_type(prop, "CollisionSettings");
3935   RNA_def_property_pointer_funcs(prop, "rna_CollisionModifier_settings_get", NULL, NULL, NULL);
3936   RNA_def_property_ui_text(prop, "Settings", "");
3937 
3938   RNA_define_lib_overridable(false);
3939 }
3940 
rna_def_modifier_bevel(BlenderRNA * brna)3941 static void rna_def_modifier_bevel(BlenderRNA *brna)
3942 {
3943   StructRNA *srna;
3944   PropertyRNA *prop;
3945 
3946   static const EnumPropertyItem prop_limit_method_items[] = {
3947       {0, "NONE", 0, "None", "Bevel the entire mesh by a constant amount"},
3948       {MOD_BEVEL_ANGLE,
3949        "ANGLE",
3950        0,
3951        "Angle",
3952        "Only bevel edges with sharp enough angles between faces"},
3953       {MOD_BEVEL_WEIGHT,
3954        "WEIGHT",
3955        0,
3956        "Weight",
3957        "Use bevel weights to determine how much bevel is applied in edge mode"},
3958       {MOD_BEVEL_VGROUP,
3959        "VGROUP",
3960        0,
3961        "Vertex Group",
3962        "Use vertex group weights to select whether vertex or edge is beveled"},
3963       {0, NULL, 0, NULL, NULL},
3964   };
3965 
3966   static const EnumPropertyItem prop_val_type_items[] = {
3967       {MOD_BEVEL_AMT_OFFSET, "OFFSET", 0, "Offset", "Amount is offset of new edges from original"},
3968       {MOD_BEVEL_AMT_WIDTH, "WIDTH", 0, "Width", "Amount is width of new face"},
3969       {MOD_BEVEL_AMT_DEPTH,
3970        "DEPTH",
3971        0,
3972        "Depth",
3973        "Amount is perpendicular distance from original edge to bevel face"},
3974       {MOD_BEVEL_AMT_PERCENT,
3975        "PERCENT",
3976        0,
3977        "Percent",
3978        "Amount is percent of adjacent edge length"},
3979       {MOD_BEVEL_AMT_ABSOLUTE,
3980        "ABSOLUTE",
3981        0,
3982        "Absolute",
3983        "Amount is absolute distance along adjacent edge"},
3984       {0, NULL, 0, NULL, NULL},
3985   };
3986 
3987   static const EnumPropertyItem prop_profile_type_items[] = {
3988       {MOD_BEVEL_PROFILE_SUPERELLIPSE,
3989        "SUPERELLIPSE",
3990        0,
3991        "Superellipse",
3992        "The profile can be a concave or convex curve"},
3993       {MOD_BEVEL_PROFILE_CUSTOM,
3994        "CUSTOM",
3995        0,
3996        "Custom",
3997        "The profile can be any arbitrary path between its endpoints"},
3998       {0, NULL, 0, NULL, NULL},
3999   };
4000 
4001   static EnumPropertyItem prop_harden_normals_items[] = {
4002       {MOD_BEVEL_FACE_STRENGTH_NONE, "FSTR_NONE", 0, "None", "Do not set face strength"},
4003       {MOD_BEVEL_FACE_STRENGTH_NEW, "FSTR_NEW", 0, "New", "Set face strength on new faces only"},
4004       {MOD_BEVEL_FACE_STRENGTH_AFFECTED,
4005        "FSTR_AFFECTED",
4006        0,
4007        "Affected",
4008        "Set face strength on new and affected faces only"},
4009       {MOD_BEVEL_FACE_STRENGTH_ALL, "FSTR_ALL", 0, "All", "Set face strength on all faces"},
4010       {0, NULL, 0, NULL, NULL},
4011   };
4012 
4013   static const EnumPropertyItem prop_miter_outer_items[] = {
4014       {MOD_BEVEL_MITER_SHARP, "MITER_SHARP", 0, "Sharp", "Outside of miter is sharp"},
4015       {MOD_BEVEL_MITER_PATCH, "MITER_PATCH", 0, "Patch", "Outside of miter is squared-off patch"},
4016       {MOD_BEVEL_MITER_ARC, "MITER_ARC", 0, "Arc", "Outside of miter is arc"},
4017       {0, NULL, 0, NULL, NULL},
4018   };
4019 
4020   static const EnumPropertyItem prop_miter_inner_items[] = {
4021       {MOD_BEVEL_MITER_SHARP, "MITER_SHARP", 0, "Sharp", "Inside of miter is sharp"},
4022       {MOD_BEVEL_MITER_ARC, "MITER_ARC", 0, "Arc", "Inside of miter is arc"},
4023       {0, NULL, 0, NULL, NULL},
4024   };
4025 
4026   static EnumPropertyItem prop_vmesh_method_items[] = {
4027       {MOD_BEVEL_VMESH_ADJ, "ADJ", 0, "Grid Fill", "Default patterned fill"},
4028       {MOD_BEVEL_VMESH_CUTOFF,
4029        "CUTOFF",
4030        0,
4031        "Cutoff",
4032        "A cut-off at the end of each profile before the intersection"},
4033       {0, NULL, 0, NULL, NULL},
4034   };
4035 
4036   static const EnumPropertyItem prop_affect_items[] = {
4037       {MOD_BEVEL_AFFECT_VERTICES, "VERTICES", 0, "Vertices", "Affect only vertices"},
4038       {MOD_BEVEL_AFFECT_EDGES, "EDGES", 0, "Edges", "Affect only edges"},
4039       {0, NULL, 0, NULL, NULL},
4040   };
4041 
4042   srna = RNA_def_struct(brna, "BevelModifier", "Modifier");
4043   RNA_def_struct_ui_text(
4044       srna, "Bevel Modifier", "Bevel modifier to make edges and vertices more rounded");
4045   RNA_def_struct_sdna(srna, "BevelModifierData");
4046   RNA_def_struct_ui_icon(srna, ICON_MOD_BEVEL);
4047 
4048   RNA_define_lib_overridable(true);
4049 
4050   prop = RNA_def_property(srna, "width", PROP_FLOAT, PROP_DISTANCE);
4051   RNA_def_property_float_sdna(prop, NULL, "value");
4052   RNA_def_property_range(prop, 0, FLT_MAX);
4053   RNA_def_property_ui_range(prop, 0.0f, 100.0f, 0.1, 4);
4054   RNA_def_property_ui_text(prop, "Width", "Bevel amount");
4055   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4056 
4057   prop = RNA_def_property(srna, "width_pct", PROP_FLOAT, PROP_PERCENTAGE);
4058   RNA_def_property_float_sdna(prop, NULL, "value");
4059   RNA_def_property_range(prop, 0, FLT_MAX);
4060   RNA_def_property_ui_range(prop, 0.0f, 100.0f, 5.0, 2);
4061   RNA_def_property_ui_text(prop, "Width Percent", "Bevel amount for percentage method");
4062   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4063 
4064   prop = RNA_def_property(srna, "segments", PROP_INT, PROP_NONE);
4065   RNA_def_property_int_sdna(prop, NULL, "res");
4066   RNA_def_property_range(prop, 1, 100);
4067   RNA_def_property_ui_text(prop, "Segments", "Number of segments for round edges/verts");
4068   RNA_def_property_update(prop, 0, "rna_BevelModifier_update_segments");
4069 
4070   prop = RNA_def_property(srna, "affect", PROP_ENUM, PROP_NONE); /* as an enum */
4071   RNA_def_property_enum_sdna(prop, NULL, "affect_type");
4072   RNA_def_property_enum_items(prop, prop_affect_items);
4073   RNA_def_property_ui_text(prop, "Affect", "Affect edges or vertices");
4074   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4075 
4076   prop = RNA_def_property(srna, "limit_method", PROP_ENUM, PROP_NONE);
4077   RNA_def_property_enum_sdna(prop, NULL, "lim_flags");
4078   RNA_def_property_enum_items(prop, prop_limit_method_items);
4079   RNA_def_property_ui_text(prop, "Limit Method", "");
4080   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4081 
4082   prop = RNA_def_property(srna, "angle_limit", PROP_FLOAT, PROP_ANGLE);
4083   RNA_def_property_float_sdna(prop, NULL, "bevel_angle");
4084   RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f));
4085   RNA_def_property_ui_range(prop, 0.0f, DEG2RADF(180.0f), 10, 2);
4086   RNA_def_property_ui_text(prop, "Angle", "Angle above which to bevel edges");
4087   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4088 
4089   prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
4090   RNA_def_property_string_sdna(prop, NULL, "defgrp_name");
4091   RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name");
4092   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_BevelModifier_defgrp_name_set");
4093   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4094 
4095   prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
4096   RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_BEVEL_INVERT_VGROUP);
4097   RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
4098   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4099 
4100   prop = RNA_def_property(srna, "use_clamp_overlap", PROP_BOOLEAN, PROP_NONE);
4101   RNA_def_property_boolean_negative_sdna(prop, NULL, "flags", MOD_BEVEL_OVERLAP_OK);
4102   RNA_def_property_ui_text(prop, "Clamp Overlap", "Clamp the width to avoid overlap");
4103   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4104 
4105   prop = RNA_def_property(srna, "offset_type", PROP_ENUM, PROP_NONE);
4106   RNA_def_property_enum_sdna(prop, NULL, "val_flags");
4107   RNA_def_property_enum_items(prop, prop_val_type_items);
4108   RNA_def_property_ui_text(prop, "Width Type", "What distance Width measures");
4109   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4110 
4111   prop = RNA_def_property(srna, "profile_type", PROP_ENUM, PROP_NONE);
4112   RNA_def_property_enum_sdna(prop, NULL, "profile_type");
4113   RNA_def_property_enum_items(prop, prop_profile_type_items);
4114   RNA_def_property_ui_text(
4115       prop, "Profile Type", "The type of shape used to rebuild a beveled section");
4116   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4117 
4118   prop = RNA_def_property(srna, "profile", PROP_FLOAT, PROP_FACTOR);
4119   RNA_def_property_range(prop, 0.0f, 1.0f);
4120   RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.05, 2);
4121   RNA_def_property_ui_text(prop, "Profile", "The profile shape (0.5 = round)");
4122   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4123 
4124   prop = RNA_def_property(srna, "material", PROP_INT, PROP_NONE);
4125   RNA_def_property_int_sdna(prop, NULL, "mat");
4126   RNA_def_property_range(prop, -1, SHRT_MAX);
4127   RNA_def_property_ui_text(
4128       prop, "Material Index", "Material index of generated faces, -1 for automatic");
4129   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4130 
4131   prop = RNA_def_property(srna, "loop_slide", PROP_BOOLEAN, PROP_NONE);
4132   RNA_def_property_boolean_negative_sdna(prop, NULL, "flags", MOD_BEVEL_EVEN_WIDTHS);
4133   RNA_def_property_ui_text(prop, "Loop Slide", "Prefer sliding along edges to having even widths");
4134   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4135 
4136   prop = RNA_def_property(srna, "mark_seam", PROP_BOOLEAN, PROP_NONE);
4137   RNA_def_property_boolean_sdna(prop, NULL, "edge_flags", MOD_BEVEL_MARK_SEAM);
4138   RNA_def_property_ui_text(prop, "Mark Seams", "Mark Seams along beveled edges");
4139   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4140 
4141   prop = RNA_def_property(srna, "mark_sharp", PROP_BOOLEAN, PROP_NONE);
4142   RNA_def_property_boolean_sdna(prop, NULL, "edge_flags", MOD_BEVEL_MARK_SHARP);
4143   RNA_def_property_ui_text(prop, "Mark Sharp", "Mark beveled edges as sharp");
4144   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4145 
4146   prop = RNA_def_property(srna, "harden_normals", PROP_BOOLEAN, PROP_NONE);
4147   RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_BEVEL_HARDEN_NORMALS);
4148   RNA_def_property_ui_text(prop, "Harden Normals", "Match normals of new faces to adjacent faces");
4149   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4150 
4151   prop = RNA_def_property(srna, "face_strength_mode", PROP_ENUM, PROP_NONE);
4152   RNA_def_property_enum_sdna(prop, NULL, "face_str_mode");
4153   RNA_def_property_enum_items(prop, prop_harden_normals_items);
4154   RNA_def_property_ui_text(
4155       prop, "Face Strength", "Whether to set face strength, and which faces to set it on");
4156   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4157 
4158   prop = RNA_def_property(srna, "miter_outer", PROP_ENUM, PROP_NONE);
4159   RNA_def_property_enum_sdna(prop, NULL, "miter_outer");
4160   RNA_def_property_enum_items(prop, prop_miter_outer_items);
4161   RNA_def_property_ui_text(prop, "Outer Miter", "Pattern to use for outside of miters");
4162   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4163 
4164   prop = RNA_def_property(srna, "miter_inner", PROP_ENUM, PROP_NONE);
4165   RNA_def_property_enum_sdna(prop, NULL, "miter_inner");
4166   RNA_def_property_enum_items(prop, prop_miter_inner_items);
4167   RNA_def_property_ui_text(prop, "Inner Miter", "Pattern to use for inside of miters");
4168   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4169 
4170   prop = RNA_def_property(srna, "spread", PROP_FLOAT, PROP_DISTANCE);
4171   RNA_def_property_float_sdna(prop, NULL, "spread");
4172   RNA_def_property_range(prop, 0, FLT_MAX);
4173   RNA_def_property_ui_range(prop, 0.0f, 100.0f, 0.1, 4);
4174   RNA_def_property_ui_text(prop, "Spread", "Spread distance for inner miter arcs");
4175   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4176 
4177   prop = RNA_def_property(srna, "custom_profile", PROP_POINTER, PROP_NONE);
4178   RNA_def_property_struct_type(prop, "CurveProfile");
4179   RNA_def_property_pointer_sdna(prop, NULL, "custom_profile");
4180   RNA_def_property_ui_text(prop, "Custom Profile Path", "The path for the custom profile");
4181   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4182 
4183   prop = RNA_def_property(srna, "vmesh_method", PROP_ENUM, PROP_NONE);
4184   RNA_def_property_enum_sdna(prop, NULL, "vmesh_method");
4185   RNA_def_property_enum_items(prop, prop_vmesh_method_items);
4186   RNA_def_property_ui_text(
4187       prop, "Vertex Mesh Method", "The method to use to create the mesh at intersections");
4188   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4189 
4190   RNA_define_lib_overridable(false);
4191 }
4192 
rna_def_modifier_shrinkwrap(BlenderRNA * brna)4193 static void rna_def_modifier_shrinkwrap(BlenderRNA *brna)
4194 {
4195   StructRNA *srna;
4196   PropertyRNA *prop;
4197 
4198   static const EnumPropertyItem shrink_type_items[] = {
4199       {MOD_SHRINKWRAP_NEAREST_SURFACE,
4200        "NEAREST_SURFACEPOINT",
4201        0,
4202        "Nearest Surface Point",
4203        "Shrink the mesh to the nearest target surface"},
4204       {MOD_SHRINKWRAP_PROJECT,
4205        "PROJECT",
4206        0,
4207        "Project",
4208        "Shrink the mesh to the nearest target surface along a given axis"},
4209       {MOD_SHRINKWRAP_NEAREST_VERTEX,
4210        "NEAREST_VERTEX",
4211        0,
4212        "Nearest Vertex",
4213        "Shrink the mesh to the nearest target vertex"},
4214       {MOD_SHRINKWRAP_TARGET_PROJECT,
4215        "TARGET_PROJECT",
4216        0,
4217        "Target Normal Project",
4218        "Shrink the mesh to the nearest target surface "
4219        "along the interpolated vertex normals of the target"},
4220       {0, NULL, 0, NULL, NULL},
4221   };
4222 
4223   static const EnumPropertyItem shrink_face_cull_items[] = {
4224       {0, "OFF", 0, "Off", "No culling"},
4225       {MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE,
4226        "FRONT",
4227        0,
4228        "Front",
4229        "No projection when in front of the face"},
4230       {MOD_SHRINKWRAP_CULL_TARGET_BACKFACE,
4231        "BACK",
4232        0,
4233        "Back",
4234        "No projection when behind the face"},
4235       {0, NULL, 0, NULL, NULL},
4236   };
4237 
4238   srna = RNA_def_struct(brna, "ShrinkwrapModifier", "Modifier");
4239   RNA_def_struct_ui_text(srna,
4240                          "Shrinkwrap Modifier",
4241                          "Shrink wrapping modifier to shrink wrap and object to a target");
4242   RNA_def_struct_sdna(srna, "ShrinkwrapModifierData");
4243   RNA_def_struct_ui_icon(srna, ICON_MOD_SHRINKWRAP);
4244 
4245   RNA_define_lib_overridable(true);
4246 
4247   prop = RNA_def_property(srna, "wrap_method", PROP_ENUM, PROP_NONE);
4248   RNA_def_property_enum_sdna(prop, NULL, "shrinkType");
4249   RNA_def_property_enum_items(prop, shrink_type_items);
4250   RNA_def_property_ui_text(prop, "Wrap Method", "");
4251   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
4252 
4253   prop = RNA_def_property(srna, "wrap_mode", PROP_ENUM, PROP_NONE);
4254   RNA_def_property_enum_sdna(prop, NULL, "shrinkMode");
4255   RNA_def_property_enum_items(prop, rna_enum_modifier_shrinkwrap_mode_items);
4256   RNA_def_property_ui_text(
4257       prop, "Snap Mode", "Select how vertices are constrained to the target surface");
4258   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
4259 
4260   prop = RNA_def_property(srna, "cull_face", PROP_ENUM, PROP_NONE);
4261   RNA_def_property_enum_sdna(prop, NULL, "shrinkOpts");
4262   RNA_def_property_enum_items(prop, shrink_face_cull_items);
4263   RNA_def_property_enum_funcs(
4264       prop, "rna_ShrinkwrapModifier_face_cull_get", "rna_ShrinkwrapModifier_face_cull_set", NULL);
4265   RNA_def_property_ui_text(
4266       prop,
4267       "Face Cull",
4268       "Stop vertices from projecting to a face on the target when facing towards/away");
4269   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4270 
4271   prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
4272   RNA_def_property_ui_text(prop, "Target", "Mesh target to shrink to");
4273   RNA_def_property_pointer_funcs(
4274       prop, NULL, "rna_ShrinkwrapModifier_target_set", NULL, "rna_Mesh_object_poll");
4275   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
4276   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
4277 
4278   prop = RNA_def_property(srna, "auxiliary_target", PROP_POINTER, PROP_NONE);
4279   RNA_def_property_pointer_sdna(prop, NULL, "auxTarget");
4280   RNA_def_property_ui_text(prop, "Auxiliary Target", "Additional mesh target to shrink to");
4281   RNA_def_property_pointer_funcs(
4282       prop, NULL, "rna_ShrinkwrapModifier_auxTarget_set", NULL, "rna_Mesh_object_poll");
4283   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
4284   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
4285 
4286   prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
4287   RNA_def_property_string_sdna(prop, NULL, "vgroup_name");
4288   RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name");
4289   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_ShrinkwrapModifier_vgroup_name_set");
4290   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4291 
4292   prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_UNIT_LENGTH);
4293   RNA_def_property_float_sdna(prop, NULL, "keepDist");
4294   RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
4295   RNA_def_property_ui_range(prop, -100, 100, 1, 2);
4296   RNA_def_property_ui_text(prop, "Offset", "Distance to keep from the target");
4297   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4298 
4299   prop = RNA_def_property(srna, "project_limit", PROP_FLOAT, PROP_UNIT_LENGTH);
4300   RNA_def_property_float_sdna(prop, NULL, "projLimit");
4301   RNA_def_property_range(prop, 0.0, FLT_MAX);
4302   RNA_def_property_ui_range(prop, 0, 100, 1, 2);
4303   RNA_def_property_ui_text(
4304       prop, "Project Limit", "Limit the distance used for projection (zero disables)");
4305   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4306 
4307   prop = RNA_def_property(srna, "use_project_x", PROP_BOOLEAN, PROP_NONE);
4308   RNA_def_property_boolean_sdna(prop, NULL, "projAxis", MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS);
4309   RNA_def_property_ui_text(prop, "X", "");
4310   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4311 
4312   prop = RNA_def_property(srna, "use_project_y", PROP_BOOLEAN, PROP_NONE);
4313   RNA_def_property_boolean_sdna(prop, NULL, "projAxis", MOD_SHRINKWRAP_PROJECT_OVER_Y_AXIS);
4314   RNA_def_property_ui_text(prop, "Y", "");
4315   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4316 
4317   prop = RNA_def_property(srna, "use_project_z", PROP_BOOLEAN, PROP_NONE);
4318   RNA_def_property_boolean_sdna(prop, NULL, "projAxis", MOD_SHRINKWRAP_PROJECT_OVER_Z_AXIS);
4319   RNA_def_property_ui_text(prop, "Z", "");
4320   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4321 
4322   prop = RNA_def_property(srna, "subsurf_levels", PROP_INT, PROP_NONE);
4323   RNA_def_property_int_sdna(prop, NULL, "subsurfLevels");
4324   RNA_def_property_range(prop, 0, 6);
4325   RNA_def_property_ui_range(prop, 0, 6, 1, -1);
4326   RNA_def_property_ui_text(
4327       prop,
4328       "Subdivision Levels",
4329       "Number of subdivisions that must be performed before extracting vertices' "
4330       "positions and normals");
4331   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4332 
4333   prop = RNA_def_property(srna, "use_negative_direction", PROP_BOOLEAN, PROP_NONE);
4334   RNA_def_property_boolean_sdna(prop, NULL, "shrinkOpts", MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR);
4335   RNA_def_property_ui_text(
4336       prop, "Negative", "Allow vertices to move in the negative direction of axis");
4337   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4338 
4339   prop = RNA_def_property(srna, "use_positive_direction", PROP_BOOLEAN, PROP_NONE);
4340   RNA_def_property_boolean_sdna(prop, NULL, "shrinkOpts", MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR);
4341   RNA_def_property_ui_text(
4342       prop, "Positive", "Allow vertices to move in the positive direction of axis");
4343   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4344 
4345   prop = RNA_def_property(srna, "use_invert_cull", PROP_BOOLEAN, PROP_NONE);
4346   RNA_def_property_boolean_sdna(prop, NULL, "shrinkOpts", MOD_SHRINKWRAP_INVERT_CULL_TARGET);
4347   RNA_def_property_ui_text(
4348       prop, "Invert Cull", "When projecting in the negative direction invert the face cull mode");
4349   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4350 
4351   prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
4352   RNA_def_property_boolean_sdna(prop, NULL, "shrinkOpts", MOD_SHRINKWRAP_INVERT_VGROUP);
4353   RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
4354   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4355 
4356   RNA_define_lib_overridable(false);
4357 }
4358 
rna_def_modifier_mask(BlenderRNA * brna)4359 static void rna_def_modifier_mask(BlenderRNA *brna)
4360 {
4361   StructRNA *srna;
4362   PropertyRNA *prop;
4363 
4364   static const EnumPropertyItem modifier_mask_mode_items[] = {
4365       {MOD_MASK_MODE_VGROUP, "VERTEX_GROUP", 0, "Vertex Group", ""},
4366       {MOD_MASK_MODE_ARM, "ARMATURE", 0, "Armature", ""},
4367       {0, NULL, 0, NULL, NULL},
4368   };
4369 
4370   srna = RNA_def_struct(brna, "MaskModifier", "Modifier");
4371   RNA_def_struct_ui_text(srna, "Mask Modifier", "Mask modifier to hide parts of the mesh");
4372   RNA_def_struct_sdna(srna, "MaskModifierData");
4373   RNA_def_struct_ui_icon(srna, ICON_MOD_MASK);
4374 
4375   RNA_define_lib_overridable(true);
4376 
4377   prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
4378   RNA_def_property_enum_items(prop, modifier_mask_mode_items);
4379   RNA_def_property_ui_text(prop, "Mode", "");
4380   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4381 
4382   prop = RNA_def_property(srna, "armature", PROP_POINTER, PROP_NONE);
4383   RNA_def_property_pointer_sdna(prop, NULL, "ob_arm");
4384   RNA_def_property_ui_text(prop, "Armature", "Armature to use as source of bones to mask");
4385   RNA_def_property_pointer_funcs(
4386       prop, NULL, "rna_MaskModifier_ob_arm_set", NULL, "rna_Armature_object_poll");
4387   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
4388   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
4389 
4390   prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
4391   RNA_def_property_string_sdna(prop, NULL, "vgroup");
4392   RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name");
4393   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_MaskModifier_vgroup_set");
4394   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4395 
4396   prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
4397   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_MASK_INV);
4398   RNA_def_property_ui_text(prop, "Invert", "Use vertices that are not part of region defined");
4399   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4400 
4401   prop = RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_FACTOR);
4402   RNA_def_property_float_sdna(prop, NULL, "threshold");
4403   RNA_def_property_range(prop, 0.0, 1.0);
4404   RNA_def_property_ui_range(prop, 0, 1, 0.1, 3);
4405   RNA_def_property_ui_text(prop, "Threshold", "Weights over this threshold remain");
4406   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4407 
4408   RNA_define_lib_overridable(false);
4409 }
4410 
rna_def_modifier_simpledeform(BlenderRNA * brna)4411 static void rna_def_modifier_simpledeform(BlenderRNA *brna)
4412 {
4413   StructRNA *srna;
4414   PropertyRNA *prop;
4415 
4416   static const EnumPropertyItem simple_deform_mode_items[] = {
4417       {MOD_SIMPLEDEFORM_MODE_TWIST,
4418        "TWIST",
4419        0,
4420        "Twist",
4421        "Rotate around the Z axis of the modifier space"},
4422       {MOD_SIMPLEDEFORM_MODE_BEND,
4423        "BEND",
4424        0,
4425        "Bend",
4426        "Bend the mesh over the Z axis of the modifier space"},
4427       {MOD_SIMPLEDEFORM_MODE_TAPER,
4428        "TAPER",
4429        0,
4430        "Taper",
4431        "Linearly scale along Z axis of the modifier space"},
4432       {MOD_SIMPLEDEFORM_MODE_STRETCH,
4433        "STRETCH",
4434        0,
4435        "Stretch",
4436        "Stretch the object along the Z axis of the modifier space"},
4437       {0, NULL, 0, NULL, NULL},
4438   };
4439 
4440   srna = RNA_def_struct(brna, "SimpleDeformModifier", "Modifier");
4441   RNA_def_struct_ui_text(
4442       srna,
4443       "SimpleDeform Modifier",
4444       "Simple deformation modifier to apply effects such as twisting and bending");
4445   RNA_def_struct_sdna(srna, "SimpleDeformModifierData");
4446   RNA_def_struct_ui_icon(srna, ICON_MOD_SIMPLEDEFORM);
4447 
4448   RNA_define_lib_overridable(true);
4449 
4450   prop = RNA_def_property(srna, "deform_method", PROP_ENUM, PROP_NONE);
4451   RNA_def_property_enum_sdna(prop, NULL, "mode");
4452   RNA_def_property_enum_items(prop, simple_deform_mode_items);
4453   RNA_def_property_ui_text(prop, "Mode", "");
4454   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4455 
4456   prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
4457   RNA_def_property_string_sdna(prop, NULL, "vgroup_name");
4458   RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name");
4459   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SimpleDeformModifier_vgroup_name_set");
4460   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4461 
4462   prop = RNA_def_property(srna, "deform_axis", PROP_ENUM, PROP_NONE);
4463   RNA_def_property_enum_items(prop, rna_enum_axis_xyz_items);
4464   RNA_def_property_ui_text(prop, "Axis", "Deform around local axis");
4465   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4466 
4467   prop = RNA_def_property(srna, "origin", PROP_POINTER, PROP_NONE);
4468   RNA_def_property_ui_text(prop, "Origin", "Offset the origin and orientation of the deformation");
4469   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
4470   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
4471 
4472   prop = RNA_def_property(srna, "factor", PROP_FLOAT, PROP_NONE);
4473   RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
4474   RNA_def_property_ui_range(prop, -10.0, 10.0, 1.0, 3);
4475   RNA_def_property_ui_text(prop, "Factor", "Amount to deform object");
4476   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4477 
4478   prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE);
4479   RNA_def_property_float_sdna(prop, NULL, "factor");
4480   RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
4481   RNA_def_property_ui_range(prop, DEG2RAD(-360.0), DEG2RAD(360.0), 10.0, 3);
4482   RNA_def_property_ui_text(prop, "Angle", "Angle of deformation");
4483   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4484 
4485   prop = RNA_def_property(srna, "limits", PROP_FLOAT, PROP_NONE);
4486   RNA_def_property_float_sdna(prop, NULL, "limit");
4487   RNA_def_property_array(prop, 2);
4488   RNA_def_property_range(prop, 0, 1);
4489   RNA_def_property_ui_range(prop, 0, 1, 5, 2);
4490   RNA_def_property_ui_text(prop, "Limits", "Lower/Upper limits for deform");
4491   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4492 
4493   prop = RNA_def_property(srna, "lock_x", PROP_BOOLEAN, PROP_NONE);
4494   RNA_def_property_boolean_sdna(prop, NULL, "axis", MOD_SIMPLEDEFORM_LOCK_AXIS_X);
4495   RNA_def_property_ui_text(prop, "X", "Do not allow deformation along the X axis");
4496   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4497 
4498   prop = RNA_def_property(srna, "lock_y", PROP_BOOLEAN, PROP_NONE);
4499   RNA_def_property_boolean_sdna(prop, NULL, "axis", MOD_SIMPLEDEFORM_LOCK_AXIS_Y);
4500   RNA_def_property_ui_text(prop, "Y", "Do not allow deformation along the Y axis");
4501   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4502 
4503   prop = RNA_def_property(srna, "lock_z", PROP_BOOLEAN, PROP_NONE);
4504   RNA_def_property_boolean_sdna(prop, NULL, "axis", MOD_SIMPLEDEFORM_LOCK_AXIS_Z);
4505   RNA_def_property_ui_text(prop, "Z", "Do not allow deformation along the Z axis");
4506   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4507 
4508   prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
4509   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SIMPLEDEFORM_FLAG_INVERT_VGROUP);
4510   RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
4511   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4512 
4513   RNA_define_lib_overridable(false);
4514 }
4515 
rna_def_modifier_surface(BlenderRNA * brna)4516 static void rna_def_modifier_surface(BlenderRNA *brna)
4517 {
4518   StructRNA *srna;
4519 
4520   srna = RNA_def_struct(brna, "SurfaceModifier", "Modifier");
4521   RNA_def_struct_ui_text(
4522       srna,
4523       "Surface Modifier",
4524       "Surface modifier defining modifier stack position used for surface fields");
4525   RNA_def_struct_sdna(srna, "SurfaceModifierData");
4526   RNA_def_struct_ui_icon(srna, ICON_MOD_PHYSICS);
4527 }
4528 
rna_def_modifier_solidify(BlenderRNA * brna)4529 static void rna_def_modifier_solidify(BlenderRNA *brna)
4530 {
4531   static const EnumPropertyItem mode_items[] = {
4532       {MOD_SOLIDIFY_MODE_EXTRUDE,
4533        "EXTRUDE",
4534        0,
4535        "Simple",
4536        "Output a solidified version of a mesh by simple extrusion"},
4537       {MOD_SOLIDIFY_MODE_NONMANIFOLD,
4538        "NON_MANIFOLD",
4539        0,
4540        "Complex",
4541        "Output a manifold mesh even if the base mesh is non-manifold, "
4542        "where edges have 3 or more connecting faces."
4543        "This method is slower"},
4544       {0, NULL, 0, NULL, NULL},
4545   };
4546 
4547   static const EnumPropertyItem nonmanifold_thickness_mode_items[] = {
4548       {MOD_SOLIDIFY_NONMANIFOLD_OFFSET_MODE_FIXED,
4549        "FIXED",
4550        0,
4551        "Fixed",
4552        "Most basic thickness calculation"},
4553       {MOD_SOLIDIFY_NONMANIFOLD_OFFSET_MODE_EVEN,
4554        "EVEN",
4555        0,
4556        "Even",
4557        "Even thickness calculation which takes the angle between faces into account"},
4558       {MOD_SOLIDIFY_NONMANIFOLD_OFFSET_MODE_CONSTRAINTS,
4559        "CONSTRAINTS",
4560        0,
4561        "Constraints",
4562        "Thickness calculation using constraints, most advanced"},
4563       {0, NULL, 0, NULL, NULL},
4564   };
4565 
4566   static const EnumPropertyItem nonmanifold_boundary_mode_items[] = {
4567       {MOD_SOLIDIFY_NONMANIFOLD_BOUNDARY_MODE_NONE, "NONE", 0, "None", "No shape correction"},
4568       {MOD_SOLIDIFY_NONMANIFOLD_BOUNDARY_MODE_ROUND,
4569        "ROUND",
4570        0,
4571        "Round",
4572        "Round open perimeter shape"},
4573       {MOD_SOLIDIFY_NONMANIFOLD_BOUNDARY_MODE_FLAT,
4574        "FLAT",
4575        0,
4576        "Flat",
4577        "Flat open perimeter shape"},
4578       {0, NULL, 0, NULL, NULL},
4579   };
4580 
4581   StructRNA *srna;
4582   PropertyRNA *prop;
4583 
4584   srna = RNA_def_struct(brna, "SolidifyModifier", "Modifier");
4585   RNA_def_struct_ui_text(
4586       srna, "Solidify Modifier", "Create a solid skin, compensating for sharp angles");
4587   RNA_def_struct_sdna(srna, "SolidifyModifierData");
4588   RNA_def_struct_ui_icon(srna, ICON_MOD_SOLIDIFY);
4589 
4590   RNA_define_lib_overridable(true);
4591 
4592   prop = RNA_def_property(srna, "solidify_mode", PROP_ENUM, PROP_NONE);
4593   RNA_def_property_enum_sdna(prop, NULL, "mode");
4594   RNA_def_property_enum_items(prop, mode_items);
4595   RNA_def_property_ui_text(prop, "Mode", "Selects the used algorithm");
4596   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4597 
4598   prop = RNA_def_property(srna, "thickness", PROP_FLOAT, PROP_DISTANCE);
4599   RNA_def_property_float_sdna(prop, NULL, "offset");
4600   RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
4601   RNA_def_property_ui_range(prop, -10, 10, 0.1, 4);
4602   RNA_def_property_ui_text(prop, "Thickness", "Thickness of the shell");
4603   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4604 
4605   prop = RNA_def_property(srna, "thickness_clamp", PROP_FLOAT, PROP_FACTOR);
4606   RNA_def_property_float_sdna(prop, NULL, "offset_clamp");
4607   RNA_def_property_range(prop, 0, 100.0);
4608   RNA_def_property_ui_range(prop, 0, 2.0, 0.1, 4);
4609   RNA_def_property_ui_text(prop, "Clamp", "Offset clamp based on geometry scale");
4610   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4611 
4612   prop = RNA_def_property(srna, "use_thickness_angle_clamp", PROP_BOOLEAN, PROP_NONE);
4613   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SOLIDIFY_OFFSET_ANGLE_CLAMP);
4614   RNA_def_property_ui_text(prop, "Angle Clamp", "Clamp thickness based on angles");
4615   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4616 
4617   prop = RNA_def_property(srna, "thickness_vertex_group", PROP_FLOAT, PROP_FACTOR);
4618   RNA_def_property_float_sdna(prop, NULL, "offset_fac_vg");
4619   RNA_def_property_range(prop, 0.0, 1.0);
4620   RNA_def_property_ui_range(prop, 0, 1, 0.1, 3);
4621   RNA_def_property_ui_text(
4622       prop, "Vertex Group Factor", "Thickness factor to use for zero vertex group influence");
4623   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4624 
4625   prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_FACTOR);
4626   RNA_def_property_float_sdna(prop, NULL, "offset_fac");
4627   RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
4628   RNA_def_property_ui_range(prop, -1, 1, 0.1, 4);
4629   RNA_def_property_ui_text(prop, "Offset", "Offset the thickness from the center");
4630   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4631 
4632   prop = RNA_def_property(srna, "edge_crease_inner", PROP_FLOAT, PROP_FACTOR);
4633   RNA_def_property_float_sdna(prop, NULL, "crease_inner");
4634   RNA_def_property_range(prop, 0, 1);
4635   RNA_def_property_ui_range(prop, 0, 1, 0.1, 3);
4636   RNA_def_property_ui_text(prop, "Inner Crease", "Assign a crease to inner edges");
4637   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4638 
4639   prop = RNA_def_property(srna, "edge_crease_outer", PROP_FLOAT, PROP_FACTOR);
4640   RNA_def_property_float_sdna(prop, NULL, "crease_outer");
4641   RNA_def_property_range(prop, 0, 1);
4642   RNA_def_property_ui_range(prop, 0, 1, 0.1, 3);
4643   RNA_def_property_ui_text(prop, "Outer Crease", "Assign a crease to outer edges");
4644   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4645 
4646   prop = RNA_def_property(srna, "edge_crease_rim", PROP_FLOAT, PROP_FACTOR);
4647   RNA_def_property_float_sdna(prop, NULL, "crease_rim");
4648   RNA_def_property_range(prop, 0, 1);
4649   RNA_def_property_ui_range(prop, 0, 1, 0.1, 3);
4650   RNA_def_property_ui_text(prop, "Rim Crease", "Assign a crease to the edges making up the rim");
4651   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4652 
4653   prop = RNA_def_property(srna, "material_offset", PROP_INT, PROP_NONE);
4654   RNA_def_property_int_sdna(prop, NULL, "mat_ofs");
4655   RNA_def_property_range(prop, SHRT_MIN, SHRT_MAX);
4656   RNA_def_property_ui_text(prop, "Material Offset", "Offset material index of generated faces");
4657   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4658 
4659   prop = RNA_def_property(srna, "material_offset_rim", PROP_INT, PROP_NONE);
4660   RNA_def_property_int_sdna(prop, NULL, "mat_ofs_rim");
4661   RNA_def_property_range(prop, SHRT_MIN, SHRT_MAX);
4662   RNA_def_property_ui_text(
4663       prop, "Rim Material Offset", "Offset material index of generated rim faces");
4664   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4665 
4666   prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
4667   RNA_def_property_string_sdna(prop, NULL, "defgrp_name");
4668   RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name");
4669   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SolidifyModifier_defgrp_name_set");
4670   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4671 
4672   prop = RNA_def_property(srna, "shell_vertex_group", PROP_STRING, PROP_NONE);
4673   RNA_def_property_string_sdna(prop, NULL, "shell_defgrp_name");
4674   RNA_def_property_ui_text(prop,
4675                            "Shell Vertex Group",
4676                            "Vertex group that the generated shell geometry will be weighted to");
4677   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SolidifyModifier_shell_defgrp_name_set");
4678   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4679 
4680   prop = RNA_def_property(srna, "rim_vertex_group", PROP_STRING, PROP_NONE);
4681   RNA_def_property_string_sdna(prop, NULL, "rim_defgrp_name");
4682   RNA_def_property_ui_text(prop,
4683                            "Rim Vertex Group",
4684                            "Vertex group that the generated rim geometry will be weighted to");
4685   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SolidifyModifier_rim_defgrp_name_set");
4686   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4687 
4688   prop = RNA_def_property(srna, "use_rim", PROP_BOOLEAN, PROP_NONE);
4689   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SOLIDIFY_RIM);
4690   RNA_def_property_ui_text(prop,
4691                            "Fill Rim",
4692                            "Create edge loops between the inner and outer surfaces on face edges "
4693                            "(slow, disable when not needed)");
4694   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4695 
4696   prop = RNA_def_property(srna, "use_even_offset", PROP_BOOLEAN, PROP_NONE);
4697   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SOLIDIFY_EVEN);
4698   RNA_def_property_ui_text(
4699       prop,
4700       "Even Thickness",
4701       "Maintain thickness by adjusting for sharp corners (slow, disable when not needed)");
4702   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4703 
4704   prop = RNA_def_property(srna, "use_quality_normals", PROP_BOOLEAN, PROP_NONE);
4705   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SOLIDIFY_NORMAL_CALC);
4706   RNA_def_property_ui_text(
4707       prop,
4708       "High Quality Normals",
4709       "Calculate normals which result in more even thickness (slow, disable when not needed)");
4710   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4711 
4712   prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
4713   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SOLIDIFY_VGROUP_INV);
4714   RNA_def_property_ui_text(prop, "Vertex Group Invert", "Invert the vertex group influence");
4715   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4716 
4717   prop = RNA_def_property(srna, "use_flat_faces", PROP_BOOLEAN, PROP_NONE);
4718   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SOLIDIFY_NONMANIFOLD_FLAT_FACES);
4719   RNA_def_property_ui_text(prop,
4720                            "Flat Faces",
4721                            "Make faces use the minimal vertex weight assigned to their vertices"
4722                            "(ensures new faces remain parallel to their original ones, slow, "
4723                            "disable when not needed)");
4724   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4725 
4726   prop = RNA_def_property(srna, "use_flip_normals", PROP_BOOLEAN, PROP_NONE);
4727   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SOLIDIFY_FLIP);
4728   RNA_def_property_ui_text(prop, "Flip Normals", "Invert the face direction");
4729   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4730 
4731   prop = RNA_def_property(srna, "use_rim_only", PROP_BOOLEAN, PROP_NONE);
4732   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SOLIDIFY_NOSHELL);
4733   RNA_def_property_ui_text(prop, "Only Rim", "Only add the rim to the original data");
4734   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4735 
4736   /* Settings for #MOD_SOLIDIFY_MODE_NONMANIFOLD */
4737   prop = RNA_def_property(srna, "nonmanifold_thickness_mode", PROP_ENUM, PROP_NONE);
4738   RNA_def_property_enum_sdna(prop, NULL, "nonmanifold_offset_mode");
4739   RNA_def_property_enum_items(prop, nonmanifold_thickness_mode_items);
4740   RNA_def_property_ui_text(prop, "Thickness Mode", "Selects the used thickness algorithm");
4741   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4742 
4743   prop = RNA_def_property(srna, "nonmanifold_boundary_mode", PROP_ENUM, PROP_NONE);
4744   RNA_def_property_enum_items(prop, nonmanifold_boundary_mode_items);
4745   RNA_def_property_ui_text(prop, "Boundary Shape", "Selects the boundary adjustment algorithm");
4746   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4747 
4748   prop = RNA_def_property(srna, "nonmanifold_merge_threshold", PROP_FLOAT, PROP_DISTANCE);
4749   RNA_def_property_float_sdna(prop, NULL, "merge_tolerance");
4750   RNA_def_property_range(prop, 0.0, 1.0);
4751   RNA_def_property_ui_range(prop, 0.0, 1.0, 0.01, 4);
4752   RNA_def_property_ui_text(
4753       prop, "Merge Threshold", "Distance within which degenerated geometry is merged");
4754   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4755 
4756   prop = RNA_def_property(srna, "bevel_convex", PROP_FLOAT, PROP_NONE);
4757   RNA_def_property_float_sdna(prop, NULL, "bevel_convex");
4758   RNA_def_property_range(prop, -1.0, 1.0);
4759   RNA_def_property_ui_range(prop, -1.0, 1.0, 0.1, 3);
4760   RNA_def_property_ui_text(prop, "Bevel Convex", "Edge bevel weight to be added to outside edges");
4761   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4762 
4763   RNA_define_lib_overridable(false);
4764 }
4765 
rna_def_modifier_screw(BlenderRNA * brna)4766 static void rna_def_modifier_screw(BlenderRNA *brna)
4767 {
4768   StructRNA *srna;
4769   PropertyRNA *prop;
4770 
4771   srna = RNA_def_struct(brna, "ScrewModifier", "Modifier");
4772   RNA_def_struct_ui_text(srna, "Screw Modifier", "Revolve edges");
4773   RNA_def_struct_sdna(srna, "ScrewModifierData");
4774   RNA_def_struct_ui_icon(srna, ICON_MOD_SCREW);
4775 
4776   RNA_define_lib_overridable(true);
4777 
4778   prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
4779   RNA_def_property_pointer_sdna(prop, NULL, "ob_axis");
4780   RNA_def_property_ui_text(prop, "Object", "Object to define the screw axis");
4781   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
4782   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
4783 
4784   prop = RNA_def_property(srna, "steps", PROP_INT, PROP_UNSIGNED);
4785   RNA_def_property_range(prop, 1, 10000);
4786   RNA_def_property_ui_range(prop, 1, 512, 1, -1);
4787   RNA_def_property_ui_text(prop, "Steps", "Number of steps in the revolution");
4788   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4789 
4790   prop = RNA_def_property(srna, "render_steps", PROP_INT, PROP_UNSIGNED);
4791   RNA_def_property_range(prop, 1, 10000);
4792   RNA_def_property_ui_range(prop, 1, 512, 1, -1);
4793   RNA_def_property_ui_text(prop, "Render Steps", "Number of steps in the revolution");
4794   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4795 
4796   prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_UNSIGNED);
4797   RNA_def_property_int_sdna(prop, NULL, "iter");
4798   RNA_def_property_range(prop, 1, 10000);
4799   RNA_def_property_ui_range(prop, 1, 100, 1, -1);
4800   RNA_def_property_ui_text(prop, "Iterations", "Number of times to apply the screw operation");
4801   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4802 
4803   prop = RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE);
4804   RNA_def_property_enum_items(prop, rna_enum_axis_xyz_items);
4805   RNA_def_property_ui_text(prop, "Axis", "Screw axis");
4806   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4807 
4808   prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE);
4809   RNA_def_property_ui_range(prop, -M_PI * 2, M_PI * 2, 10, -1);
4810   RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
4811   RNA_def_property_ui_text(prop, "Angle", "Angle of revolution");
4812   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4813 
4814   prop = RNA_def_property(srna, "screw_offset", PROP_FLOAT, PROP_DISTANCE);
4815   RNA_def_property_float_sdna(prop, NULL, "screw_ofs");
4816   RNA_def_property_ui_text(prop, "Screw", "Offset the revolution along its axis");
4817   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4818 
4819   prop = RNA_def_property(srna, "merge_threshold", PROP_FLOAT, PROP_DISTANCE);
4820   RNA_def_property_float_sdna(prop, NULL, "merge_dist");
4821   RNA_def_property_range(prop, 0, FLT_MAX);
4822   RNA_def_property_ui_range(prop, 0, 1, 1, 4);
4823   RNA_def_property_ui_text(prop, "Merge Distance", "Limit below which to merge vertices");
4824   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4825 
4826   prop = RNA_def_property(srna, "use_normal_flip", PROP_BOOLEAN, PROP_NONE);
4827   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SCREW_NORMAL_FLIP);
4828   RNA_def_property_ui_text(prop, "Flip", "Flip normals of lathed faces");
4829   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4830 
4831   prop = RNA_def_property(srna, "use_normal_calculate", PROP_BOOLEAN, PROP_NONE);
4832   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SCREW_NORMAL_CALC);
4833   RNA_def_property_ui_text(
4834       prop, "Calculate Order", "Calculate the order of edges (needed for meshes, but not curves)");
4835   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4836 
4837   prop = RNA_def_property(srna, "use_object_screw_offset", PROP_BOOLEAN, PROP_NONE);
4838   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SCREW_OBJECT_OFFSET);
4839   RNA_def_property_ui_text(
4840       prop, "Object Screw", "Use the distance between the objects to make a screw");
4841   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4842 
4843   /* Vertex merging parameters */
4844   prop = RNA_def_property(srna, "use_merge_vertices", PROP_BOOLEAN, PROP_NONE);
4845   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SCREW_MERGE);
4846   RNA_def_property_ui_text(
4847       prop, "Merge Vertices", "Merge adjacent vertices (screw offset must be zero)");
4848   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4849 
4850   prop = RNA_def_property(srna, "use_smooth_shade", PROP_BOOLEAN, PROP_NONE);
4851   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SCREW_SMOOTH_SHADING);
4852   RNA_def_property_ui_text(
4853       prop, "Smooth Shading", "Output faces with smooth shading rather than flat shaded");
4854   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4855 
4856   prop = RNA_def_property(srna, "use_stretch_u", PROP_BOOLEAN, PROP_NONE);
4857   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SCREW_UV_STRETCH_U);
4858   RNA_def_property_ui_text(
4859       prop, "Stretch U", "Stretch the U coordinates between 0-1 when UV's are present");
4860   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4861 
4862   prop = RNA_def_property(srna, "use_stretch_v", PROP_BOOLEAN, PROP_NONE);
4863   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SCREW_UV_STRETCH_V);
4864   RNA_def_property_ui_text(
4865       prop, "Stretch V", "Stretch the V coordinates between 0-1 when UV's are present");
4866   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4867 
4868 #  if 0
4869   prop = RNA_def_property(srna, "use_angle_object", PROP_BOOLEAN, PROP_NONE);
4870   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SCREW_OBJECT_ANGLE);
4871   RNA_def_property_ui_text(
4872       prop, "Object Angle", "Use the angle between the objects rather than the fixed angle");
4873   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4874 #  endif
4875 
4876   RNA_define_lib_overridable(false);
4877 }
4878 
rna_def_modifier_uvwarp(BlenderRNA * brna)4879 static void rna_def_modifier_uvwarp(BlenderRNA *brna)
4880 {
4881   StructRNA *srna;
4882   PropertyRNA *prop;
4883 
4884   srna = RNA_def_struct(brna, "UVWarpModifier", "Modifier");
4885   RNA_def_struct_ui_text(srna, "UVWarp Modifier", "Add target position to uv coordinates");
4886   RNA_def_struct_sdna(srna, "UVWarpModifierData");
4887   RNA_def_struct_ui_icon(srna, ICON_MOD_UVPROJECT);
4888 
4889   RNA_define_lib_overridable(true);
4890 
4891   prop = RNA_def_property(srna, "axis_u", PROP_ENUM, PROP_NONE);
4892   RNA_def_property_enum_sdna(prop, NULL, "axis_u");
4893   RNA_def_property_enum_items(prop, rna_enum_axis_xyz_items);
4894   RNA_def_property_ui_text(prop, "U-Axis", "Pole axis for rotation");
4895   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4896 
4897   prop = RNA_def_property(srna, "axis_v", PROP_ENUM, PROP_NONE);
4898   RNA_def_property_enum_sdna(prop, NULL, "axis_v");
4899   RNA_def_property_enum_items(prop, rna_enum_axis_xyz_items);
4900   RNA_def_property_ui_text(prop, "V-Axis", "Pole axis for rotation");
4901   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4902 
4903   prop = RNA_def_property(srna, "center", PROP_FLOAT, PROP_NONE);
4904   RNA_def_property_float_sdna(prop, NULL, "center");
4905   RNA_def_property_ui_text(prop, "UV Center", "Center point for rotate/scale");
4906   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4907 
4908   prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE);
4909   RNA_def_property_float_sdna(prop, NULL, "offset");
4910   RNA_def_property_ui_text(prop, "Offset", "2D Offset for the warp");
4911   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4912 
4913   prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_NONE);
4914   RNA_def_property_float_sdna(prop, NULL, "scale");
4915   RNA_def_property_ui_text(prop, "Scale", "2D Scale for the warp");
4916   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4917 
4918   prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_ANGLE);
4919   RNA_def_property_float_sdna(prop, NULL, "rotation");
4920   RNA_def_property_ui_text(prop, "Rotation", "2D Rotation for the warp");
4921   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4922 
4923   prop = RNA_def_property(srna, "object_from", PROP_POINTER, PROP_NONE);
4924   RNA_def_property_pointer_sdna(prop, NULL, "object_src");
4925   RNA_def_property_ui_text(prop, "Object From", "Object defining offset");
4926   RNA_def_property_flag(prop, PROP_EDITABLE);
4927   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
4928 
4929   prop = RNA_def_property(srna, "bone_from", PROP_STRING, PROP_NONE);
4930   RNA_def_property_string_sdna(prop, NULL, "bone_src");
4931   RNA_def_property_ui_text(prop, "Bone From", "Bone defining offset");
4932   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
4933 
4934   prop = RNA_def_property(srna, "object_to", PROP_POINTER, PROP_NONE);
4935   RNA_def_property_pointer_sdna(prop, NULL, "object_dst");
4936   RNA_def_property_ui_text(prop, "Object To", "Object defining offset");
4937   RNA_def_property_flag(prop, PROP_EDITABLE);
4938   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
4939 
4940   prop = RNA_def_property(srna, "bone_to", PROP_STRING, PROP_NONE);
4941   RNA_def_property_string_sdna(prop, NULL, "bone_dst");
4942   RNA_def_property_ui_text(prop, "Bone To", "Bone defining offset");
4943   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
4944 
4945   prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
4946   RNA_def_property_string_sdna(prop, NULL, "vgroup_name");
4947   RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name");
4948   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_UVWarpModifier_vgroup_name_set");
4949   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4950 
4951   prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
4952   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_UVWARP_INVERT_VGROUP);
4953   RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
4954   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4955 
4956   prop = RNA_def_property(srna, "uv_layer", PROP_STRING, PROP_NONE);
4957   RNA_def_property_string_sdna(prop, NULL, "uvlayer_name");
4958   RNA_def_property_ui_text(prop, "UV Layer", "UV Layer name");
4959   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_UVWarpModifier_uvlayer_name_set");
4960   RNA_def_property_update(prop, 0, "rna_Modifier_update");
4961 
4962   RNA_define_lib_overridable(false);
4963 }
4964 
rna_def_modifier_weightvg_mask(BlenderRNA * UNUSED (brna),StructRNA * srna,const char * mask_flags,const char * mask_vgroup_setter,const char * mask_uvlayer_setter)4965 static void rna_def_modifier_weightvg_mask(BlenderRNA *UNUSED(brna),
4966                                            StructRNA *srna,
4967                                            const char *mask_flags,
4968                                            const char *mask_vgroup_setter,
4969                                            const char *mask_uvlayer_setter)
4970 {
4971   static const EnumPropertyItem weightvg_mask_tex_map_items[] = {
4972       {MOD_DISP_MAP_LOCAL, "LOCAL", 0, "Local", "Use local generated coordinates"},
4973       {MOD_DISP_MAP_GLOBAL, "GLOBAL", 0, "Global", "Use global coordinates"},
4974       {MOD_DISP_MAP_OBJECT,
4975        "OBJECT",
4976        0,
4977        "Object",
4978        "Use local generated coordinates of another object"},
4979       {MOD_DISP_MAP_UV, "UV", 0, "UV", "Use coordinates from an UV layer"},
4980       {0, NULL, 0, NULL, NULL},
4981   };
4982 
4983   static const EnumPropertyItem weightvg_mask_tex_used_items[] = {
4984       {MOD_WVG_MASK_TEX_USE_INT, "INT", 0, "Intensity", ""},
4985       {MOD_WVG_MASK_TEX_USE_RED, "RED", 0, "Red", ""},
4986       {MOD_WVG_MASK_TEX_USE_GREEN, "GREEN", 0, "Green", ""},
4987       {MOD_WVG_MASK_TEX_USE_BLUE, "BLUE", 0, "Blue", ""},
4988       {MOD_WVG_MASK_TEX_USE_HUE, "HUE", 0, "Hue", ""},
4989       {MOD_WVG_MASK_TEX_USE_SAT, "SAT", 0, "Saturation", ""},
4990       {MOD_WVG_MASK_TEX_USE_VAL, "VAL", 0, "Value", ""},
4991       {MOD_WVG_MASK_TEX_USE_ALPHA, "ALPHA", 0, "Alpha", ""},
4992       {0, NULL, 0, NULL, NULL},
4993   };
4994 
4995   PropertyRNA *prop;
4996 
4997   RNA_define_lib_overridable(true);
4998 
4999   prop = RNA_def_property(srna, "mask_constant", PROP_FLOAT, PROP_FACTOR);
5000   RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
5001   RNA_def_property_ui_range(prop, 0.0, 1.0, 1, -1);
5002   RNA_def_property_ui_text(
5003       prop, "Influence", "Global influence of current modifications on vgroup");
5004   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5005 
5006   prop = RNA_def_property(srna, "mask_vertex_group", PROP_STRING, PROP_NONE);
5007   RNA_def_property_string_sdna(prop, NULL, "mask_defgrp_name");
5008   RNA_def_property_ui_text(prop, "Mask Vertex Group", "Masking vertex group name");
5009   RNA_def_property_string_funcs(prop, NULL, NULL, mask_vgroup_setter);
5010   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5011 
5012   prop = RNA_def_property(srna, "invert_mask_vertex_group", PROP_BOOLEAN, PROP_NONE);
5013   RNA_def_property_boolean_sdna(prop, NULL, mask_flags, MOD_WVG_EDIT_INVERT_VGROUP_MASK);
5014   RNA_def_property_ui_text(prop, "Invert", "Invert vertex group mask influence");
5015   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5016 
5017   prop = RNA_def_property(srna, "mask_texture", PROP_POINTER, PROP_NONE);
5018   RNA_def_property_ui_text(prop, "Masking Tex", "Masking texture");
5019   RNA_def_property_flag(prop, PROP_EDITABLE);
5020   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
5021 
5022   prop = RNA_def_property(srna, "mask_tex_use_channel", PROP_ENUM, PROP_NONE);
5023   RNA_def_property_enum_items(prop, weightvg_mask_tex_used_items);
5024   RNA_def_property_ui_text(prop, "Use Channel", "Which texture channel to use for masking");
5025   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5026 
5027   prop = RNA_def_property(srna, "mask_tex_mapping", PROP_ENUM, PROP_NONE);
5028   RNA_def_property_enum_items(prop, weightvg_mask_tex_map_items);
5029   RNA_def_property_ui_text(prop,
5030                            "Texture Coordinates",
5031                            "Which texture coordinates "
5032                            "to use for mapping");
5033   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
5034 
5035   prop = RNA_def_property(srna, "mask_tex_uv_layer", PROP_STRING, PROP_NONE);
5036   RNA_def_property_string_sdna(prop, NULL, "mask_tex_uvlayer_name");
5037   RNA_def_property_ui_text(prop, "UV Map", "UV map name");
5038   RNA_def_property_string_funcs(prop, NULL, NULL, mask_uvlayer_setter);
5039   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5040 
5041   prop = RNA_def_property(srna, "mask_tex_map_object", PROP_POINTER, PROP_NONE);
5042   RNA_def_property_pointer_sdna(prop, NULL, "mask_tex_map_obj");
5043   RNA_def_property_ui_text(prop,
5044                            "Texture Coordinate Object",
5045                            "Which object to take texture "
5046                            "coordinates from");
5047   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
5048   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
5049 
5050   prop = RNA_def_property(srna, "mask_tex_map_bone", PROP_STRING, PROP_NONE);
5051   RNA_def_property_string_sdna(prop, NULL, "mask_tex_map_bone");
5052   RNA_def_property_ui_text(
5053       prop, "Texture Coordinate Bone", "Which bone to take texture coordinates from");
5054   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
5055 
5056   RNA_define_lib_overridable(false);
5057 }
5058 
rna_def_modifier_weightvgedit(BlenderRNA * brna)5059 static void rna_def_modifier_weightvgedit(BlenderRNA *brna)
5060 {
5061   static const EnumPropertyItem weightvg_edit_falloff_type_items[] = {
5062       {MOD_WVG_MAPPING_NONE, "LINEAR", ICON_LINCURVE, "Linear", "Null action"},
5063       {MOD_WVG_MAPPING_CURVE, "CURVE", ICON_RNDCURVE, "Custom Curve", ""},
5064       {MOD_WVG_MAPPING_SHARP, "SHARP", ICON_SHARPCURVE, "Sharp", ""},
5065       {MOD_WVG_MAPPING_SMOOTH, "SMOOTH", ICON_SMOOTHCURVE, "Smooth", ""},
5066       {MOD_WVG_MAPPING_ROOT, "ROOT", ICON_ROOTCURVE, "Root", ""},
5067       {MOD_WVG_MAPPING_SPHERE, "ICON_SPHERECURVE", ICON_SPHERECURVE, "Sphere", ""},
5068       {MOD_WVG_MAPPING_RANDOM, "RANDOM", ICON_RNDCURVE, "Random", ""},
5069       {MOD_WVG_MAPPING_STEP,
5070        "STEP",
5071        ICON_IPO_CONSTANT,
5072        "Median Step",
5073        "Map all values below 0.5 to 0.0, and all others to 1.0"},
5074       {0, NULL, 0, NULL, NULL},
5075   };
5076 
5077   StructRNA *srna;
5078   PropertyRNA *prop;
5079 
5080   srna = RNA_def_struct(brna, "VertexWeightEditModifier", "Modifier");
5081   RNA_def_struct_ui_text(
5082       srna, "WeightVG Edit Modifier", "Edit the weights of vertices in a group");
5083   RNA_def_struct_sdna(srna, "WeightVGEditModifierData");
5084   RNA_def_struct_ui_icon(srna, ICON_MOD_VERTEX_WEIGHT);
5085 
5086   RNA_define_lib_overridable(true);
5087 
5088   prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
5089   RNA_def_property_string_sdna(prop, NULL, "defgrp_name");
5090   RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name");
5091   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_WeightVGEditModifier_defgrp_name_set");
5092   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5093 
5094   prop = RNA_def_property(srna, "falloff_type", PROP_ENUM, PROP_NONE);
5095   RNA_def_property_enum_items(prop, weightvg_edit_falloff_type_items);
5096   RNA_def_property_ui_text(prop, "Falloff Type", "How weights are mapped to their new values");
5097   RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_CURVE); /* Abusing id_curve :/ */
5098   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5099 
5100   prop = RNA_def_property(srna, "invert_falloff", PROP_BOOLEAN, PROP_NONE);
5101   RNA_def_property_boolean_sdna(prop, NULL, "edit_flags", MOD_WVG_INVERT_FALLOFF);
5102   RNA_def_property_ui_text(prop, "Invert Falloff", "Invert the resulting falloff weight");
5103   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5104 
5105   prop = RNA_def_property(srna, "normalize", PROP_BOOLEAN, PROP_NONE);
5106   RNA_def_property_boolean_sdna(prop, NULL, "edit_flags", MOD_WVG_EDIT_WEIGHTS_NORMALIZE);
5107   RNA_def_property_ui_text(
5108       prop,
5109       "Normalize Weights",
5110       "Normalize the resulting weights (otherwise they are only clamped within [0.0, 1.0] range)");
5111   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5112 
5113   prop = RNA_def_property(srna, "map_curve", PROP_POINTER, PROP_NONE);
5114   RNA_def_property_pointer_sdna(prop, NULL, "cmap_curve");
5115   RNA_def_property_ui_text(prop, "Mapping Curve", "Custom mapping curve");
5116   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5117 
5118   prop = RNA_def_property(srna, "use_add", PROP_BOOLEAN, PROP_NONE);
5119   RNA_def_property_boolean_sdna(prop, NULL, "edit_flags", MOD_WVG_EDIT_ADD2VG);
5120   RNA_def_property_ui_text(prop,
5121                            "Group Add",
5122                            "Add vertices with weight over threshold "
5123                            "to vgroup");
5124   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5125 
5126   prop = RNA_def_property(srna, "use_remove", PROP_BOOLEAN, PROP_NONE);
5127   RNA_def_property_boolean_sdna(prop, NULL, "edit_flags", MOD_WVG_EDIT_REMFVG);
5128   RNA_def_property_ui_text(prop,
5129                            "Group Remove",
5130                            "Remove vertices with weight below threshold "
5131                            "from vgroup");
5132   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5133 
5134   prop = RNA_def_property(srna, "default_weight", PROP_FLOAT, PROP_FACTOR);
5135   RNA_def_property_range(prop, 0.0, 1.0f);
5136   RNA_def_property_ui_range(prop, 0.0, 1.0, 1, -1);
5137   RNA_def_property_ui_text(prop,
5138                            "Default Weight",
5139                            "Default weight a vertex will have if "
5140                            "it is not in the vgroup");
5141   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5142 
5143   prop = RNA_def_property(srna, "add_threshold", PROP_FLOAT, PROP_NONE);
5144   RNA_def_property_float_sdna(prop, NULL, "add_threshold");
5145   RNA_def_property_range(prop, 0.0, 1.0);
5146   RNA_def_property_ui_range(prop, 0.0, 1.0, 1, -1);
5147   RNA_def_property_ui_text(prop,
5148                            "Add Threshold",
5149                            "Lower bound for a vertex's weight "
5150                            "to be added to the vgroup");
5151   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5152 
5153   prop = RNA_def_property(srna, "remove_threshold", PROP_FLOAT, PROP_NONE);
5154   RNA_def_property_float_sdna(prop, NULL, "rem_threshold");
5155   RNA_def_property_range(prop, 0.0, 1.0);
5156   RNA_def_property_ui_range(prop, 0.0, 1.0, 1, -1);
5157   RNA_def_property_ui_text(prop,
5158                            "Remove Threshold",
5159                            "Upper bound for a vertex's weight "
5160                            "to be removed from the vgroup");
5161   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5162 
5163   RNA_define_lib_overridable(false);
5164 
5165   /* Common masking properties. */
5166   rna_def_modifier_weightvg_mask(brna,
5167                                  srna,
5168                                  "edit_flags",
5169                                  "rna_WeightVGEditModifier_mask_defgrp_name_set",
5170                                  "rna_WeightVGEditModifier_mask_tex_uvlayer_name_set");
5171 }
5172 
rna_def_modifier_weightvgmix(BlenderRNA * brna)5173 static void rna_def_modifier_weightvgmix(BlenderRNA *brna)
5174 {
5175   static const EnumPropertyItem weightvg_mix_modes_items[] = {
5176       {MOD_WVG_MIX_SET, "SET", 0, "Replace", "Replace VGroup A's weights by VGroup B's ones"},
5177       {MOD_WVG_MIX_ADD, "ADD", 0, "Add", "Add VGroup B's weights to VGroup A's ones"},
5178       {MOD_WVG_MIX_SUB, "SUB", 0, "Subtract", "Subtract VGroup B's weights from VGroup A's ones"},
5179       {MOD_WVG_MIX_MUL, "MUL", 0, "Multiply", "Multiply VGroup A's weights by VGroup B's ones"},
5180       {MOD_WVG_MIX_DIV, "DIV", 0, "Divide", "Divide VGroup A's weights by VGroup B's ones"},
5181       {MOD_WVG_MIX_DIF,
5182        "DIF",
5183        0,
5184        "Difference",
5185        "Difference between VGroup A's and VGroup B's weights"},
5186       {MOD_WVG_MIX_AVG, "AVG", 0, "Average", "Average value of VGroup A's and VGroup B's weights"},
5187       {0, NULL, 0, NULL, NULL},
5188   };
5189 
5190   static const EnumPropertyItem weightvg_mix_set_items[] = {
5191       {MOD_WVG_SET_ALL, "ALL", 0, "All", "Affect all vertices (might add some to VGroup A)"},
5192       {MOD_WVG_SET_A, "A", 0, "VGroup A", "Affect vertices in VGroup A"},
5193       {MOD_WVG_SET_B,
5194        "B",
5195        0,
5196        "VGroup B",
5197        "Affect vertices in VGroup B (might add some to VGroup A)"},
5198       {MOD_WVG_SET_OR,
5199        "OR",
5200        0,
5201        "VGroup A or B",
5202        "Affect vertices in at least one of both VGroups (might add some to VGroup A)"},
5203       {MOD_WVG_SET_AND, "AND", 0, "VGroup A and B", "Affect vertices in both groups"},
5204       {0, NULL, 0, NULL, NULL},
5205   };
5206 
5207   StructRNA *srna;
5208   PropertyRNA *prop;
5209 
5210   srna = RNA_def_struct(brna, "VertexWeightMixModifier", "Modifier");
5211   RNA_def_struct_ui_text(srna, "WeightVG Mix Modifier", "Mix the weights of two vertex groups");
5212   RNA_def_struct_sdna(srna, "WeightVGMixModifierData");
5213   RNA_def_struct_ui_icon(srna, ICON_MOD_VERTEX_WEIGHT);
5214 
5215   RNA_define_lib_overridable(true);
5216 
5217   prop = RNA_def_property(srna, "vertex_group_a", PROP_STRING, PROP_NONE);
5218   RNA_def_property_string_sdna(prop, NULL, "defgrp_name_a");
5219   RNA_def_property_ui_text(prop, "Vertex Group A", "First vertex group name");
5220   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_WeightVGMixModifier_defgrp_name_a_set");
5221   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5222 
5223   prop = RNA_def_property(srna, "vertex_group_b", PROP_STRING, PROP_NONE);
5224   RNA_def_property_string_sdna(prop, NULL, "defgrp_name_b");
5225   RNA_def_property_ui_text(prop, "Vertex Group B", "Second vertex group name");
5226   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_WeightVGMixModifier_defgrp_name_b_set");
5227   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5228 
5229   prop = RNA_def_property(srna, "invert_vertex_group_a", PROP_BOOLEAN, PROP_NONE);
5230   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WVG_MIX_INVERT_VGROUP_A);
5231   RNA_def_property_ui_text(prop, "Invert Weights A", "Invert the influence of vertex group A");
5232   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5233 
5234   prop = RNA_def_property(srna, "invert_vertex_group_b", PROP_BOOLEAN, PROP_NONE);
5235   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WVG_MIX_INVERT_VGROUP_B);
5236   RNA_def_property_ui_text(prop, "Invert Weights B", "Invert the influence of vertex group B");
5237   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5238 
5239   prop = RNA_def_property(srna, "default_weight_a", PROP_FLOAT, PROP_FACTOR);
5240   RNA_def_property_range(prop, 0.0, 1.0f);
5241   RNA_def_property_ui_range(prop, 0.0, 1.0, 1, -1);
5242   RNA_def_property_ui_text(prop,
5243                            "Default Weight A",
5244                            "Default weight a vertex will have if "
5245                            "it is not in the first A vgroup");
5246   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5247 
5248   prop = RNA_def_property(srna, "default_weight_b", PROP_FLOAT, PROP_FACTOR);
5249   RNA_def_property_range(prop, 0.0, 1.0f);
5250   RNA_def_property_ui_range(prop, 0.0, 1.0, 1, -1);
5251   RNA_def_property_ui_text(prop,
5252                            "Default Weight B",
5253                            "Default weight a vertex will have if "
5254                            "it is not in the second B vgroup");
5255   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5256 
5257   prop = RNA_def_property(srna, "mix_mode", PROP_ENUM, PROP_NONE);
5258   RNA_def_property_enum_items(prop, weightvg_mix_modes_items);
5259   RNA_def_property_ui_text(prop,
5260                            "Mix Mode",
5261                            "How weights from vgroup B affect weights "
5262                            "of vgroup A");
5263   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5264 
5265   prop = RNA_def_property(srna, "mix_set", PROP_ENUM, PROP_NONE);
5266   RNA_def_property_enum_items(prop, weightvg_mix_set_items);
5267   RNA_def_property_ui_text(prop, "Vertex Set", "Which vertices should be affected");
5268   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5269 
5270   prop = RNA_def_property(srna, "normalize", PROP_BOOLEAN, PROP_NONE);
5271   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WVG_MIX_WEIGHTS_NORMALIZE);
5272   RNA_def_property_ui_text(
5273       prop,
5274       "Normalize Weights",
5275       "Normalize the resulting weights (otherwise they are only clamped within [0.0, 1.0] range)");
5276   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5277 
5278   RNA_define_lib_overridable(false);
5279 
5280   /* Common masking properties. */
5281   rna_def_modifier_weightvg_mask(brna,
5282                                  srna,
5283                                  "flag",
5284                                  "rna_WeightVGMixModifier_mask_defgrp_name_set",
5285                                  "rna_WeightVGMixModifier_mask_tex_uvlayer_name_set");
5286 }
5287 
rna_def_modifier_weightvgproximity(BlenderRNA * brna)5288 static void rna_def_modifier_weightvgproximity(BlenderRNA *brna)
5289 {
5290   static const EnumPropertyItem weightvg_proximity_modes_items[] = {
5291       {MOD_WVG_PROXIMITY_OBJECT,
5292        "OBJECT",
5293        0,
5294        "Object",
5295        "Use distance between affected and target objects"},
5296       {MOD_WVG_PROXIMITY_GEOMETRY,
5297        "GEOMETRY",
5298        0,
5299        "Geometry",
5300        "Use distance between affected object's vertices and target "
5301        "object, or target object's geometry"},
5302       {0, NULL, 0, NULL, NULL},
5303   };
5304 
5305   static const EnumPropertyItem proximity_geometry_items[] = {
5306       {MOD_WVG_PROXIMITY_GEOM_VERTS, "VERTEX", 0, "Vertex", "Compute distance to nearest vertex"},
5307       {MOD_WVG_PROXIMITY_GEOM_EDGES, "EDGE", 0, "Edge", "Compute distance to nearest edge"},
5308       {MOD_WVG_PROXIMITY_GEOM_FACES, "FACE", 0, "Face", "Compute distance to nearest face"},
5309       {0, NULL, 0, NULL, NULL},
5310   };
5311 
5312   static const EnumPropertyItem weightvg_proximity_falloff_type_items[] = {
5313       {MOD_WVG_MAPPING_NONE, "LINEAR", ICON_LINCURVE, "Linear", "Null action"},
5314       /* No curve mapping here! */
5315       {MOD_WVG_MAPPING_SHARP, "SHARP", ICON_SHARPCURVE, "Sharp", ""},
5316       {MOD_WVG_MAPPING_SMOOTH, "SMOOTH", ICON_SMOOTHCURVE, "Smooth", ""},
5317       {MOD_WVG_MAPPING_ROOT, "ROOT", ICON_ROOTCURVE, "Root", ""},
5318       {MOD_WVG_MAPPING_SPHERE, "ICON_SPHERECURVE", ICON_SPHERECURVE, "Sphere", ""},
5319       {MOD_WVG_MAPPING_RANDOM, "RANDOM", ICON_RNDCURVE, "Random", ""},
5320       {MOD_WVG_MAPPING_STEP,
5321        "STEP",
5322        ICON_IPO_CONSTANT,
5323        "Median Step",
5324        "Map all values below 0.5 to 0.0, and all others to 1.0"},
5325       {0, NULL, 0, NULL, NULL},
5326   };
5327 
5328   StructRNA *srna;
5329   PropertyRNA *prop;
5330 
5331   srna = RNA_def_struct(brna, "VertexWeightProximityModifier", "Modifier");
5332   RNA_def_struct_ui_text(srna,
5333                          "WeightVG Proximity Modifier",
5334                          "Set the weights of vertices in a group from a target object's "
5335                          "distance");
5336   RNA_def_struct_sdna(srna, "WeightVGProximityModifierData");
5337   RNA_def_struct_ui_icon(srna, ICON_MOD_VERTEX_WEIGHT);
5338 
5339   RNA_define_lib_overridable(true);
5340 
5341   prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
5342   RNA_def_property_string_sdna(prop, NULL, "defgrp_name");
5343   RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name");
5344   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_WeightVGProximityModifier_defgrp_name_set");
5345   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5346 
5347   prop = RNA_def_property(srna, "proximity_mode", PROP_ENUM, PROP_NONE);
5348   RNA_def_property_enum_items(prop, weightvg_proximity_modes_items);
5349   RNA_def_property_enum_default(prop, MOD_WVG_PROXIMITY_GEOMETRY);
5350   RNA_def_property_ui_text(prop, "Proximity Mode", "Which distances to target object to use");
5351   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5352 
5353   prop = RNA_def_property(srna, "proximity_geometry", PROP_ENUM, PROP_NONE);
5354   RNA_def_property_enum_sdna(prop, NULL, "proximity_flags");
5355   RNA_def_property_enum_items(prop, proximity_geometry_items);
5356   RNA_def_property_flag(prop, PROP_ENUM_FLAG); /* important to run before default set */
5357   RNA_def_property_enum_default(prop, MOD_WVG_PROXIMITY_GEOM_FACES);
5358   RNA_def_property_ui_text(prop,
5359                            "Proximity Geometry",
5360                            "Use the shortest computed distance to target object's geometry "
5361                            "as weight");
5362   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5363 
5364   prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
5365   RNA_def_property_pointer_sdna(prop, NULL, "proximity_ob_target");
5366   RNA_def_property_ui_text(prop, "Target Object", "Object to calculate vertices distances from");
5367   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
5368   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
5369 
5370   prop = RNA_def_property(srna, "min_dist", PROP_FLOAT, PROP_DISTANCE);
5371   RNA_def_property_range(prop, 0.0, FLT_MAX);
5372   RNA_def_property_ui_range(prop, 0.0, 1000.0, 10, -1);
5373   RNA_def_property_ui_text(prop, "Lowest", "Distance mapping to weight 0.0");
5374   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5375 
5376   prop = RNA_def_property(srna, "max_dist", PROP_FLOAT, PROP_DISTANCE);
5377   RNA_def_property_range(prop, 0.0, FLT_MAX);
5378   RNA_def_property_ui_range(prop, 0.0, 1000.0, 10, -1);
5379   RNA_def_property_ui_text(prop, "Highest", "Distance mapping to weight 1.0");
5380   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5381 
5382   prop = RNA_def_property(srna, "falloff_type", PROP_ENUM, PROP_NONE);
5383   RNA_def_property_enum_items(prop, weightvg_proximity_falloff_type_items);
5384   RNA_def_property_ui_text(prop, "Falloff Type", "How weights are mapped to their new values");
5385   RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_CURVE); /* Abusing id_curve :/ */
5386   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5387 
5388   prop = RNA_def_property(srna, "invert_falloff", PROP_BOOLEAN, PROP_NONE);
5389   RNA_def_property_boolean_sdna(prop, NULL, "proximity_flags", MOD_WVG_PROXIMITY_INVERT_FALLOFF);
5390   RNA_def_property_ui_text(prop, "Invert Falloff", "Invert the resulting falloff weight");
5391   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5392 
5393   prop = RNA_def_property(srna, "normalize", PROP_BOOLEAN, PROP_NONE);
5394   RNA_def_property_boolean_sdna(
5395       prop, NULL, "proximity_flags", MOD_WVG_PROXIMITY_WEIGHTS_NORMALIZE);
5396   RNA_def_property_ui_text(
5397       prop,
5398       "Normalize Weights",
5399       "Normalize the resulting weights (otherwise they are only clamped within [0.0, 1.0] range)");
5400   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5401 
5402   RNA_define_lib_overridable(false);
5403 
5404   /* Common masking properties. */
5405   rna_def_modifier_weightvg_mask(brna,
5406                                  srna,
5407                                  "proximity_flags",
5408                                  "rna_WeightVGProximityModifier_mask_defgrp_name_set",
5409                                  "rna_WeightVGProximityModifier_mask_tex_uvlayer_name_set");
5410 }
5411 
rna_def_modifier_remesh(BlenderRNA * brna)5412 static void rna_def_modifier_remesh(BlenderRNA *brna)
5413 {
5414   static const EnumPropertyItem mode_items[] = {
5415       {MOD_REMESH_CENTROID, "BLOCKS", 0, "Blocks", "Output a blocky surface with no smoothing"},
5416       {MOD_REMESH_MASS_POINT,
5417        "SMOOTH",
5418        0,
5419        "Smooth",
5420        "Output a smooth surface with no sharp-features detection"},
5421       {MOD_REMESH_SHARP_FEATURES,
5422        "SHARP",
5423        0,
5424        "Sharp",
5425        "Output a surface that reproduces sharp edges and corners from the input mesh"},
5426       {MOD_REMESH_VOXEL,
5427        "VOXEL",
5428        0,
5429        "Voxel",
5430        "Output a mesh corresponding to the volume of the original mesh"},
5431       {0, NULL, 0, NULL, NULL},
5432   };
5433 
5434   StructRNA *srna;
5435   PropertyRNA *prop;
5436 
5437   srna = RNA_def_struct(brna, "RemeshModifier", "Modifier");
5438   RNA_def_struct_ui_text(
5439       srna,
5440       "Remesh Modifier",
5441       "Generate a new surface with regular topology that follows the shape of the input mesh");
5442   RNA_def_struct_sdna(srna, "RemeshModifierData");
5443   RNA_def_struct_ui_icon(srna, ICON_MOD_REMESH);
5444 
5445   RNA_define_lib_overridable(true);
5446 
5447   prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
5448   RNA_def_property_enum_items(prop, mode_items);
5449   RNA_def_property_ui_text(prop, "Mode", "");
5450   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5451 
5452   prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_NONE);
5453   RNA_def_property_ui_range(prop, 0, 0.99, 0.01, 3);
5454   RNA_def_property_range(prop, 0, 0.99);
5455   RNA_def_property_ui_text(
5456       prop, "Scale", "The ratio of the largest dimension of the model over the size of the grid");
5457   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5458 
5459   prop = RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_NONE);
5460   RNA_def_property_ui_range(prop, 0, 1, 0.1, 3);
5461   RNA_def_property_range(prop, 0, 1);
5462   RNA_def_property_ui_text(
5463       prop,
5464       "Threshold",
5465       "If removing disconnected pieces, minimum size of components to preserve as a ratio "
5466       "of the number of polygons in the largest component");
5467   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5468 
5469   prop = RNA_def_property(srna, "octree_depth", PROP_INT, PROP_NONE);
5470   RNA_def_property_int_sdna(prop, NULL, "depth");
5471   RNA_def_property_range(prop, 1, 24);
5472   RNA_def_property_ui_range(prop, 1, 12, 1, 3);
5473   RNA_def_property_ui_text(
5474       prop, "Octree Depth", "Resolution of the octree; higher values give finer details");
5475   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5476 
5477   prop = RNA_def_property(srna, "sharpness", PROP_FLOAT, PROP_NONE);
5478   RNA_def_property_float_sdna(prop, NULL, "hermite_num");
5479   RNA_def_property_ui_range(prop, 0, 2, 0.1, 3);
5480   RNA_def_property_ui_text(
5481       prop,
5482       "Sharpness",
5483       "Tolerance for outliers; lower values filter noise while higher values will reproduce "
5484       "edges closer to the input");
5485   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5486 
5487   prop = RNA_def_property(srna, "voxel_size", PROP_FLOAT, PROP_DISTANCE);
5488   RNA_def_property_float_sdna(prop, NULL, "voxel_size");
5489   RNA_def_property_range(prop, 0.0001f, FLT_MAX);
5490   RNA_def_property_ui_range(prop, 0.0001, 2, 0.1, 3);
5491   RNA_def_property_ui_text(prop,
5492                            "Voxel Size",
5493                            "Size of the voxel in object space used for volume evaluation. Lower "
5494                            "values preserve finer details");
5495   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5496 
5497   prop = RNA_def_property(srna, "adaptivity", PROP_FLOAT, PROP_DISTANCE);
5498   RNA_def_property_float_sdna(prop, NULL, "adaptivity");
5499   RNA_def_property_ui_range(prop, 0, 1, 0.1, 3);
5500   RNA_def_property_ui_text(
5501       prop,
5502       "Adaptivity",
5503       "Reduces the final face count by simplifying geometry where detail is not needed, "
5504       "generating triangles. A value greater than 0 disables Fix Poles");
5505   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5506 
5507   prop = RNA_def_property(srna, "use_remove_disconnected", PROP_BOOLEAN, PROP_NONE);
5508   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_REMESH_FLOOD_FILL);
5509   RNA_def_property_ui_text(prop, "Remove Disconnected", "");
5510   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5511 
5512   prop = RNA_def_property(srna, "use_smooth_shade", PROP_BOOLEAN, PROP_NONE);
5513   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_REMESH_SMOOTH_SHADING);
5514   RNA_def_property_ui_text(
5515       prop, "Smooth Shading", "Output faces with smooth shading rather than flat shaded");
5516   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5517 
5518   RNA_define_lib_overridable(false);
5519 }
5520 
rna_def_modifier_ocean(BlenderRNA * brna)5521 static void rna_def_modifier_ocean(BlenderRNA *brna)
5522 {
5523   StructRNA *srna;
5524   PropertyRNA *prop;
5525 
5526   static const EnumPropertyItem geometry_items[] = {
5527     {MOD_OCEAN_GEOM_GENERATE,
5528      "GENERATE",
5529      0,
5530      "Generate",
5531      "Generate ocean surface geometry at the specified resolution"},
5532     {MOD_OCEAN_GEOM_DISPLACE,
5533      "DISPLACE",
5534      0,
5535      "Displace",
5536      "Displace existing geometry according to simulation"},
5537 #  if 0
5538     {MOD_OCEAN_GEOM_SIM_ONLY,
5539      "SIM_ONLY",
5540      0,
5541      "Sim Only",
5542      "Leaves geometry unchanged, but still runs simulation (to be used from texture)"},
5543 #  endif
5544     {0, NULL, 0, NULL, NULL},
5545   };
5546 
5547   static const EnumPropertyItem spectrum_items[] = {
5548       {MOD_OCEAN_SPECTRUM_PHILLIPS,
5549        "PHILLIPS",
5550        0,
5551        "Turbulent Ocean",
5552        "Use for turbulent seas with foam"},
5553       {MOD_OCEAN_SPECTRUM_PIERSON_MOSKOWITZ,
5554        "PIERSON_MOSKOWITZ",
5555        0,
5556        "Established Ocean",
5557        "Use for a large area, established ocean (Pierson-Moskowitz method)"},
5558       {MOD_OCEAN_SPECTRUM_JONSWAP,
5559        "JONSWAP",
5560        0,
5561        "Established Ocean (Sharp Peaks)",
5562        "Use for sharp peaks ('JONSWAP', Pierson-Moskowitz method) with peak sharpening"},
5563       {MOD_OCEAN_SPECTRUM_TEXEL_MARSEN_ARSLOE,
5564        "TEXEL_MARSEN_ARSLOE",
5565        0,
5566        "Shallow Water",
5567        "Use for shallow water ('JONSWAP', 'TMA' - Texel-Marsen-Arsloe method)"},
5568       {0, NULL, 0, NULL, NULL},
5569   };
5570 
5571   srna = RNA_def_struct(brna, "OceanModifier", "Modifier");
5572   RNA_def_struct_ui_text(srna, "Ocean Modifier", "Simulate an ocean surface");
5573   RNA_def_struct_sdna(srna, "OceanModifierData");
5574   RNA_def_struct_ui_icon(srna, ICON_MOD_OCEAN);
5575 
5576   RNA_define_lib_overridable(true);
5577 
5578   prop = RNA_def_property(srna, "geometry_mode", PROP_ENUM, PROP_NONE);
5579   RNA_def_property_enum_sdna(prop, NULL, "geometry_mode");
5580   RNA_def_property_enum_items(prop, geometry_items);
5581   RNA_def_property_ui_text(prop, "Geometry", "Method of modifying geometry");
5582   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5583 
5584   prop = RNA_def_property(srna, "size", PROP_FLOAT, PROP_UNSIGNED);
5585   RNA_def_property_float_sdna(prop, NULL, "size");
5586   RNA_def_property_ui_text(
5587       prop, "Size", "Surface scale factor (does not affect the height of the waves)");
5588   RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, -1);
5589   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5590 
5591   prop = RNA_def_property(srna, "repeat_x", PROP_INT, PROP_UNSIGNED);
5592   RNA_def_property_int_sdna(prop, NULL, "repeat_x");
5593   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
5594   RNA_def_property_range(prop, 1, 1024);
5595   RNA_def_property_ui_range(prop, 1, 100, 1, -1);
5596   RNA_def_property_ui_text(prop, "Repeat X", "Repetitions of the generated surface in X");
5597   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5598 
5599   prop = RNA_def_property(srna, "repeat_y", PROP_INT, PROP_UNSIGNED);
5600   RNA_def_property_int_sdna(prop, NULL, "repeat_y");
5601   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
5602   RNA_def_property_range(prop, 1, 1024);
5603   RNA_def_property_ui_range(prop, 1, 100, 1, -1);
5604   RNA_def_property_ui_text(prop, "Repeat Y", "Repetitions of the generated surface in Y");
5605   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5606 
5607   prop = RNA_def_property(srna, "use_normals", PROP_BOOLEAN, PROP_NONE);
5608   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_OCEAN_GENERATE_NORMALS);
5609   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
5610   RNA_def_property_ui_text(
5611       prop,
5612       "Generate Normals",
5613       "Output normals for bump mapping - disabling can speed up performance if its not needed");
5614   RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
5615 
5616   prop = RNA_def_property(srna, "use_foam", PROP_BOOLEAN, PROP_NONE);
5617   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_OCEAN_GENERATE_FOAM);
5618   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
5619   RNA_def_property_ui_text(prop, "Generate Foam", "Generate foam mask as a vertex color channel");
5620   RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
5621 
5622   prop = RNA_def_property(srna, "use_spray", PROP_BOOLEAN, PROP_NONE);
5623   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_OCEAN_GENERATE_SPRAY);
5624   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
5625   RNA_def_property_ui_text(
5626       prop, "Generate Spray Map", "Generate map of spray direction as a vertex color channel");
5627   RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
5628 
5629   prop = RNA_def_property(srna, "invert_spray", PROP_BOOLEAN, PROP_NONE);
5630   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_OCEAN_INVERT_SPRAY);
5631   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
5632   RNA_def_property_ui_text(prop, "Invert Spray", "Invert the spray direction map");
5633   RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
5634 
5635   prop = RNA_def_property(srna, "spray_layer_name", PROP_STRING, PROP_NONE);
5636   RNA_def_property_string_sdna(prop, NULL, "spraylayername");
5637   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
5638   RNA_def_property_ui_text(
5639       prop, "Spray Map", "Name of the vertex color layer used for the spray direction map");
5640   RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
5641 
5642   prop = RNA_def_property(srna, "resolution", PROP_INT, PROP_UNSIGNED);
5643   RNA_def_property_int_sdna(prop, NULL, "resolution");
5644   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
5645   RNA_def_property_range(prop, 1, 1024);
5646   RNA_def_property_ui_range(prop, 1, 32, 1, -1);
5647   RNA_def_property_ui_text(
5648       prop, "Render Resolution", "Resolution of the generated surface for rendering and baking");
5649   RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
5650 
5651   prop = RNA_def_property(srna, "viewport_resolution", PROP_INT, PROP_UNSIGNED);
5652   RNA_def_property_int_sdna(prop, NULL, "viewport_resolution");
5653   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
5654   RNA_def_property_range(prop, 1, 1024);
5655   RNA_def_property_ui_range(prop, 1, 32, 1, -1);
5656   RNA_def_property_ui_text(
5657       prop, "Viewport Resolution", "Viewport resolution of the generated surface");
5658   RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
5659 
5660   prop = RNA_def_property(srna, "spatial_size", PROP_INT, PROP_NONE);
5661   RNA_def_property_int_sdna(prop, NULL, "spatial_size");
5662   RNA_def_property_ui_range(prop, 1, 512, 2, -1);
5663   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
5664   RNA_def_property_ui_text(
5665       prop,
5666       "Spatial Size",
5667       "Size of the simulation domain (in meters), and of the generated geometry (in BU)");
5668   RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
5669 
5670   prop = RNA_def_property(srna, "wind_velocity", PROP_FLOAT, PROP_VELOCITY);
5671   RNA_def_property_float_sdna(prop, NULL, "wind_velocity");
5672   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
5673   RNA_def_property_ui_text(prop, "Wind Velocity", "Wind speed");
5674   RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
5675 
5676   prop = RNA_def_property(srna, "damping", PROP_FLOAT, PROP_FACTOR);
5677   RNA_def_property_float_sdna(prop, NULL, "damp");
5678   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
5679   RNA_def_property_ui_text(
5680       prop, "Damping", "Damp reflected waves going in opposite direction to the wind");
5681   RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
5682 
5683   prop = RNA_def_property(srna, "wave_scale_min", PROP_FLOAT, PROP_DISTANCE);
5684   RNA_def_property_float_sdna(prop, NULL, "smallest_wave");
5685   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
5686   RNA_def_property_range(prop, 0.0, FLT_MAX);
5687   RNA_def_property_ui_text(prop, "Smallest Wave", "Shortest allowed wavelength");
5688   RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
5689 
5690   prop = RNA_def_property(srna, "wave_alignment", PROP_FLOAT, PROP_UNSIGNED);
5691   RNA_def_property_float_sdna(prop, NULL, "wave_alignment");
5692   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
5693   RNA_def_property_range(prop, 0.0, 1.0);
5694   RNA_def_property_ui_text(prop, "Wave Alignment", "How much the waves are aligned to each other");
5695   RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
5696 
5697   prop = RNA_def_property(srna, "wave_direction", PROP_FLOAT, PROP_ANGLE);
5698   RNA_def_property_float_sdna(prop, NULL, "wave_direction");
5699   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
5700   RNA_def_property_ui_text(
5701       prop, "Wave Direction", "Main direction of the waves when they are (partially) aligned");
5702   RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
5703 
5704   prop = RNA_def_property(srna, "wave_scale", PROP_FLOAT, PROP_UNSIGNED);
5705   RNA_def_property_float_sdna(prop, NULL, "wave_scale");
5706   RNA_def_property_ui_text(prop, "Wave Scale", "Scale of the displacement effect");
5707   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5708 
5709   prop = RNA_def_property(srna, "depth", PROP_FLOAT, PROP_DISTANCE);
5710   RNA_def_property_float_sdna(prop, NULL, "depth");
5711   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
5712   RNA_def_property_ui_text(prop, "Depth", "Depth of the solid ground below the water surface");
5713   RNA_def_property_ui_range(prop, 0, 250, 1, -1);
5714   RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
5715 
5716   prop = RNA_def_property(srna, "foam_coverage", PROP_FLOAT, PROP_NONE);
5717   RNA_def_property_float_sdna(prop, NULL, "foam_coverage");
5718   RNA_def_property_ui_text(prop, "Foam Coverage", "Amount of generated foam");
5719   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5720 
5721   prop = RNA_def_property(srna, "bake_foam_fade", PROP_FLOAT, PROP_UNSIGNED);
5722   RNA_def_property_float_sdna(prop, NULL, "foam_fade");
5723   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
5724   RNA_def_property_ui_text(
5725       prop, "Foam Fade", "How much foam accumulates over time (baked ocean only)");
5726   RNA_def_property_ui_range(prop, 0.0, 10.0, 1, -1);
5727   RNA_def_property_update(prop, 0, NULL);
5728 
5729   prop = RNA_def_property(srna, "foam_layer_name", PROP_STRING, PROP_NONE);
5730   RNA_def_property_string_sdna(prop, NULL, "foamlayername");
5731   RNA_def_property_ui_text(
5732       prop, "Foam Layer Name", "Name of the vertex color layer used for foam");
5733   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5734 
5735   prop = RNA_def_property(srna, "choppiness", PROP_FLOAT, PROP_UNSIGNED);
5736   RNA_def_property_float_sdna(prop, NULL, "chop_amount");
5737   RNA_def_property_ui_text(
5738       prop,
5739       "Choppiness",
5740       "Choppiness of the wave's crest (adds some horizontal component to the displacement)");
5741   RNA_def_property_ui_range(prop, 0.0, 4.0, 3, -1);
5742   RNA_def_property_float_funcs(prop, NULL, "rna_OceanModifier_ocean_chop_set", NULL);
5743   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5744 
5745   prop = RNA_def_property(srna, "time", PROP_FLOAT, PROP_UNSIGNED);
5746   RNA_def_property_float_sdna(prop, NULL, "time");
5747   RNA_def_property_ui_text(prop, "Time", "Current time of the simulation");
5748   RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, -1);
5749   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5750 
5751   prop = RNA_def_property(srna, "spectrum", PROP_ENUM, PROP_NONE);
5752   RNA_def_property_enum_sdna(prop, NULL, "spectrum");
5753   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
5754   RNA_def_property_enum_items(prop, spectrum_items);
5755   RNA_def_property_ui_text(prop, "Spectrum", "Spectrum to use");
5756   RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
5757 
5758   prop = RNA_def_property(srna, "fetch_jonswap", PROP_FLOAT, PROP_UNSIGNED);
5759   RNA_def_property_float_sdna(prop, NULL, "fetch_jonswap");
5760   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
5761   RNA_def_property_range(prop, 0.0, FLT_MAX);
5762   RNA_def_property_ui_text(
5763       prop,
5764       "Fetch",
5765       "This is the distance from a lee shore, "
5766       "called the fetch, or the distance over which the wind blows with constant velocity. "
5767       "Used by 'JONSWAP' and 'TMA' models");
5768   RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
5769 
5770   prop = RNA_def_property(srna, "sharpen_peak_jonswap", PROP_FLOAT, PROP_UNSIGNED);
5771   RNA_def_property_float_sdna(prop, NULL, "sharpen_peak_jonswap");
5772   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
5773   RNA_def_property_range(prop, 0.0, 1.0);
5774   RNA_def_property_ui_text(prop, "Sharpen peak", "Peak sharpening for 'JONSWAP' and 'TMA' models");
5775   RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
5776 
5777   prop = RNA_def_property(srna, "random_seed", PROP_INT, PROP_UNSIGNED);
5778   RNA_def_property_int_sdna(prop, NULL, "seed");
5779   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
5780   RNA_def_property_ui_text(prop, "Random Seed", "Seed of the random generator");
5781   RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
5782 
5783   prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);
5784   RNA_def_property_int_sdna(prop, NULL, "bakestart");
5785   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
5786   RNA_def_property_ui_text(prop, "Bake Start", "Start frame of the ocean baking");
5787   RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
5788 
5789   prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_TIME);
5790   RNA_def_property_int_sdna(prop, NULL, "bakeend");
5791   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
5792   RNA_def_property_ui_text(prop, "Bake End", "End frame of the ocean baking");
5793   RNA_def_property_update(prop, 0, "rna_OceanModifier_init_update");
5794 
5795   prop = RNA_def_property(srna, "is_cached", PROP_BOOLEAN, PROP_NONE);
5796   RNA_def_property_boolean_sdna(prop, NULL, "cached", 1);
5797   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
5798   RNA_def_property_ui_text(
5799       prop, "Ocean is Cached", "Whether the ocean is using cached data or simulating");
5800 
5801   prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_DIRPATH);
5802   RNA_def_property_string_sdna(prop, NULL, "cachepath");
5803   RNA_def_property_ui_text(prop, "Cache Path", "Path to a folder to store external baked images");
5804   /*RNA_def_property_update(prop, 0, "rna_Modifier_update"); */
5805   /* XXX how to update? */
5806 
5807   RNA_define_lib_overridable(false);
5808 }
5809 
rna_def_modifier_skin(BlenderRNA * brna)5810 static void rna_def_modifier_skin(BlenderRNA *brna)
5811 {
5812   StructRNA *srna;
5813   PropertyRNA *prop;
5814 
5815   srna = RNA_def_struct(brna, "SkinModifier", "Modifier");
5816   RNA_def_struct_ui_text(srna, "Skin Modifier", "Generate Skin");
5817   RNA_def_struct_sdna(srna, "SkinModifierData");
5818   RNA_def_struct_ui_icon(srna, ICON_MOD_SKIN);
5819 
5820   RNA_define_lib_overridable(true);
5821 
5822   prop = RNA_def_property(srna, "branch_smoothing", PROP_FLOAT, PROP_FACTOR);
5823   RNA_def_property_ui_text(prop, "Branch Smoothing", "Smooth complex geometry around branches");
5824   RNA_def_property_ui_range(prop, 0, 1, 1, -1);
5825   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5826 
5827   prop = RNA_def_property(srna, "use_smooth_shade", PROP_BOOLEAN, PROP_NONE);
5828   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SKIN_SMOOTH_SHADING);
5829   RNA_def_property_ui_text(
5830       prop, "Smooth Shading", "Output faces with smooth shading rather than flat shaded");
5831   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5832 
5833   prop = RNA_def_property(srna, "use_x_symmetry", PROP_BOOLEAN, PROP_NONE);
5834   RNA_def_property_boolean_sdna(prop, NULL, "symmetry_axes", MOD_SKIN_SYMM_X);
5835   RNA_def_property_ui_text(prop, "X", "Avoid making unsymmetrical quads across the X axis");
5836   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5837 
5838   prop = RNA_def_property(srna, "use_y_symmetry", PROP_BOOLEAN, PROP_NONE);
5839   RNA_def_property_boolean_sdna(prop, NULL, "symmetry_axes", MOD_SKIN_SYMM_Y);
5840   RNA_def_property_ui_text(prop, "Y", "Avoid making unsymmetrical quads across the Y axis");
5841   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5842 
5843   prop = RNA_def_property(srna, "use_z_symmetry", PROP_BOOLEAN, PROP_NONE);
5844   RNA_def_property_boolean_sdna(prop, NULL, "symmetry_axes", MOD_SKIN_SYMM_Z);
5845   RNA_def_property_ui_text(prop, "Z", "Avoid making unsymmetrical quads across the Z axis");
5846   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5847 
5848   RNA_define_lib_overridable(false);
5849 }
5850 
rna_def_modifier_triangulate(BlenderRNA * brna)5851 static void rna_def_modifier_triangulate(BlenderRNA *brna)
5852 {
5853   StructRNA *srna;
5854   PropertyRNA *prop;
5855 
5856   srna = RNA_def_struct(brna, "TriangulateModifier", "Modifier");
5857   RNA_def_struct_ui_text(srna, "Triangulate Modifier", "Triangulate Mesh");
5858   RNA_def_struct_sdna(srna, "TriangulateModifierData");
5859   RNA_def_struct_ui_icon(srna, ICON_MOD_TRIANGULATE);
5860 
5861   RNA_define_lib_overridable(true);
5862 
5863   prop = RNA_def_property(srna, "quad_method", PROP_ENUM, PROP_NONE);
5864   RNA_def_property_enum_sdna(prop, NULL, "quad_method");
5865   RNA_def_property_enum_items(prop, rna_enum_modifier_triangulate_quad_method_items);
5866   RNA_def_property_ui_text(prop, "Quad Method", "Method for splitting the quads into triangles");
5867   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5868 
5869   prop = RNA_def_property(srna, "ngon_method", PROP_ENUM, PROP_NONE);
5870   RNA_def_property_enum_sdna(prop, NULL, "ngon_method");
5871   RNA_def_property_enum_items(prop, rna_enum_modifier_triangulate_ngon_method_items);
5872   RNA_def_property_ui_text(
5873       prop, "Polygon Method", "Method for splitting the polygons into triangles");
5874   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5875 
5876   prop = RNA_def_property(srna, "min_vertices", PROP_INT, PROP_UNSIGNED);
5877   RNA_def_property_int_sdna(prop, NULL, "min_vertices");
5878   RNA_def_property_range(prop, 4, INT_MAX);
5879   RNA_def_property_ui_text(
5880       prop,
5881       "Minimum Vertices",
5882       "Triangulate only polygons with vertex count greater than or equal to this number");
5883   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5884 
5885   prop = RNA_def_property(srna, "keep_custom_normals", PROP_BOOLEAN, PROP_NONE);
5886   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_TRIANGULATE_KEEP_CUSTOMLOOP_NORMALS);
5887   RNA_def_property_ui_text(
5888       prop,
5889       "Keep Normals",
5890       "Try to preserve custom normals (WARNING: depending on chosen triangulation method, "
5891       "shading may not be fully preserved, 'Fixed' method usually gives the best result here)");
5892   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5893 
5894   RNA_define_lib_overridable(false);
5895 }
5896 
rna_def_modifier_meshcache(BlenderRNA * brna)5897 static void rna_def_modifier_meshcache(BlenderRNA *brna)
5898 {
5899   static const EnumPropertyItem prop_format_type_items[] = {
5900       {MOD_MESHCACHE_TYPE_MDD, "MDD", 0, "MDD", ""},
5901       {MOD_MESHCACHE_TYPE_PC2, "PC2", 0, "PC2", ""},
5902       {0, NULL, 0, NULL, NULL},
5903   };
5904 
5905   static const EnumPropertyItem prop_deform_mode_items[] = {
5906       {MOD_MESHCACHE_DEFORM_OVERWRITE,
5907        "OVERWRITE",
5908        0,
5909        "Overwrite",
5910        "Replace vertex coords with cached values"},
5911       {MOD_MESHCACHE_DEFORM_INTEGRATE,
5912        "INTEGRATE",
5913        0,
5914        "Integrate",
5915        "Integrate deformation from this modifiers input with the mesh-cache coords (useful for "
5916        "shape keys)"},
5917       {0, NULL, 0, NULL, NULL},
5918   };
5919 
5920   static const EnumPropertyItem prop_interpolation_type_items[] = {
5921       {MOD_MESHCACHE_INTERP_NONE, "NONE", 0, "None", ""},
5922       {MOD_MESHCACHE_INTERP_LINEAR, "LINEAR", 0, "Linear", ""},
5923       /* for cardinal we'd need to read 4x cache's */
5924       // {MOD_MESHCACHE_INTERP_CARDINAL, "CARDINAL", 0, "Cardinal", ""},
5925       {0, NULL, 0, NULL, NULL},
5926   };
5927 
5928   static const EnumPropertyItem prop_time_type_items[] = {
5929       /* use 'eval_frame' */
5930       {MOD_MESHCACHE_TIME_FRAME,
5931        "FRAME",
5932        0,
5933        "Frame",
5934        "Control playback using a frame-number "
5935        "(ignoring time FPS and start frame from the file)"},
5936       /* use 'eval_time' */
5937       {MOD_MESHCACHE_TIME_SECONDS, "TIME", 0, "Time", "Control playback using time in seconds"},
5938       /* use 'eval_factor' */
5939       {MOD_MESHCACHE_TIME_FACTOR,
5940        "FACTOR",
5941        0,
5942        "Factor",
5943        "Control playback using a value between [0, 1]"},
5944       {0, NULL, 0, NULL, NULL},
5945   };
5946 
5947   static const EnumPropertyItem prop_time_play_items[] = {
5948       {MOD_MESHCACHE_PLAY_CFEA, "SCENE", 0, "Scene", "Use the time from the scene"},
5949       {MOD_MESHCACHE_PLAY_EVAL, "CUSTOM", 0, "Custom", "Use the modifier's own time evaluation"},
5950       {0, NULL, 0, NULL, NULL},
5951   };
5952 
5953   StructRNA *srna;
5954   PropertyRNA *prop;
5955 
5956   srna = RNA_def_struct(brna, "MeshCacheModifier", "Modifier");
5957   RNA_def_struct_ui_text(srna, "Cache Modifier", "Cache Mesh");
5958   RNA_def_struct_sdna(srna, "MeshCacheModifierData");
5959   RNA_def_struct_ui_icon(srna, ICON_MOD_MESHDEFORM); /* XXX, needs own icon */
5960 
5961   RNA_define_lib_overridable(true);
5962 
5963   prop = RNA_def_property(srna, "cache_format", PROP_ENUM, PROP_NONE);
5964   RNA_def_property_enum_sdna(prop, NULL, "type");
5965   RNA_def_property_enum_items(prop, prop_format_type_items);
5966   RNA_def_property_ui_text(prop, "Format", "");
5967   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5968 
5969   prop = RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE);
5970   RNA_def_property_enum_sdna(prop, NULL, "interp");
5971   RNA_def_property_enum_items(prop, prop_interpolation_type_items);
5972   RNA_def_property_ui_text(prop, "Interpolation", "");
5973   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5974 
5975   prop = RNA_def_property(srna, "time_mode", PROP_ENUM, PROP_NONE);
5976   RNA_def_property_enum_sdna(prop, NULL, "time_mode");
5977   RNA_def_property_enum_items(prop, prop_time_type_items);
5978   RNA_def_property_ui_text(prop, "Time Mode", "Method to control playback time");
5979   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5980 
5981   prop = RNA_def_property(srna, "play_mode", PROP_ENUM, PROP_NONE);
5982   RNA_def_property_enum_sdna(prop, NULL, "play_mode");
5983   RNA_def_property_enum_items(prop, prop_time_play_items);
5984   RNA_def_property_ui_text(prop, "Play Mode", "");
5985   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5986 
5987   prop = RNA_def_property(srna, "deform_mode", PROP_ENUM, PROP_NONE);
5988   RNA_def_property_enum_sdna(prop, NULL, "deform_mode");
5989   RNA_def_property_enum_items(prop, prop_deform_mode_items);
5990   RNA_def_property_ui_text(prop, "Deform Mode", "");
5991   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5992 
5993   prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH);
5994   RNA_def_property_ui_text(prop, "File Path", "Path to external displacements file");
5995   RNA_def_property_update(prop, 0, "rna_Modifier_update");
5996 
5997   prop = RNA_def_property(srna, "factor", PROP_FLOAT, PROP_NONE);
5998   RNA_def_property_float_sdna(prop, NULL, "factor");
5999   RNA_def_property_range(prop, 0.0f, 1.0f);
6000   RNA_def_property_ui_text(prop, "Influence", "Influence of the deformation");
6001   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6002 
6003   /* -------------------------------------------------------------------- */
6004   /* Axis Conversion */
6005   prop = RNA_def_property(srna, "forward_axis", PROP_ENUM, PROP_NONE);
6006   RNA_def_property_enum_sdna(prop, NULL, "forward_axis");
6007   RNA_def_property_enum_items(prop, rna_enum_object_axis_items);
6008   RNA_def_property_ui_text(prop, "Forward", "");
6009   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6010 
6011   prop = RNA_def_property(srna, "up_axis", PROP_ENUM, PROP_NONE);
6012   RNA_def_property_enum_sdna(prop, NULL, "up_axis");
6013   RNA_def_property_enum_items(prop, rna_enum_object_axis_items);
6014   RNA_def_property_ui_text(prop, "Up", "");
6015   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6016 
6017   prop = RNA_def_property(srna, "flip_axis", PROP_ENUM, PROP_NONE);
6018   RNA_def_property_enum_sdna(prop, NULL, "flip_axis");
6019   RNA_def_property_enum_items(prop, rna_enum_axis_flag_xyz_items);
6020   RNA_def_property_flag(prop, PROP_ENUM_FLAG);
6021   RNA_def_property_ui_text(prop, "Flip Axis", "");
6022   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6023 
6024   /* -------------------------------------------------------------------- */
6025   /* For Scene time */
6026   prop = RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_TIME);
6027   RNA_def_property_float_sdna(prop, NULL, "frame_start");
6028   RNA_def_property_range(prop, -MAXFRAME, MAXFRAME);
6029   RNA_def_property_ui_text(prop, "Frame Start", "Add this to the start frame");
6030   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6031 
6032   prop = RNA_def_property(srna, "frame_scale", PROP_FLOAT, PROP_NONE);
6033   RNA_def_property_float_sdna(prop, NULL, "frame_scale");
6034   RNA_def_property_range(prop, 0.0f, 100.0f);
6035   RNA_def_property_ui_text(prop, "Frame Scale", "Evaluation time in seconds");
6036   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6037 
6038   /* -------------------------------------------------------------------- */
6039   /* eval values depend on 'time_mode' */
6040   prop = RNA_def_property(srna, "eval_frame", PROP_FLOAT, PROP_NONE);
6041   RNA_def_property_float_sdna(prop, NULL, "eval_frame");
6042   RNA_def_property_range(prop, MINFRAME, MAXFRAME);
6043   RNA_def_property_ui_text(prop, "Evaluation Frame", "The frame to evaluate (starting at 0)");
6044   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6045 
6046   prop = RNA_def_property(srna, "eval_time", PROP_FLOAT, PROP_NONE);
6047   RNA_def_property_float_sdna(prop, NULL, "eval_time");
6048   RNA_def_property_range(prop, 0.0f, FLT_MAX);
6049   RNA_def_property_ui_text(prop, "Evaluation Time", "Evaluation time in seconds");
6050   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6051 
6052   prop = RNA_def_property(srna, "eval_factor", PROP_FLOAT, PROP_FACTOR);
6053   RNA_def_property_float_sdna(prop, NULL, "eval_factor");
6054   RNA_def_property_range(prop, 0.0f, 1.0f);
6055   RNA_def_property_ui_text(prop, "Evaluation Factor", "Evaluation time in seconds");
6056   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6057 
6058   RNA_define_lib_overridable(false);
6059 }
6060 
rna_def_mesh_cache_velocities(BlenderRNA * brna)6061 static void rna_def_mesh_cache_velocities(BlenderRNA *brna)
6062 {
6063   StructRNA *srna;
6064   PropertyRNA *prop;
6065 
6066   srna = RNA_def_struct(brna, "MeshCacheVertexVelocity", NULL);
6067   RNA_def_struct_ui_text(srna, "Mesh Cache Velocity", "Velocity attribute of an Alembic mesh");
6068   RNA_def_struct_ui_icon(srna, ICON_VERTEXSEL);
6069 
6070   prop = RNA_def_property(srna, "velocity", PROP_FLOAT, PROP_VELOCITY);
6071   RNA_def_property_array(prop, 3);
6072   RNA_def_property_float_sdna(prop, NULL, "vel");
6073   RNA_def_property_ui_text(prop, "Velocity", "");
6074   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
6075 }
6076 
rna_def_modifier_meshseqcache(BlenderRNA * brna)6077 static void rna_def_modifier_meshseqcache(BlenderRNA *brna)
6078 {
6079   StructRNA *srna;
6080   PropertyRNA *prop;
6081 
6082   srna = RNA_def_struct(brna, "MeshSequenceCacheModifier", "Modifier");
6083   RNA_def_struct_ui_text(srna, "Cache Modifier", "Cache Mesh");
6084   RNA_def_struct_sdna(srna, "MeshSeqCacheModifierData");
6085   RNA_def_struct_ui_icon(srna, ICON_MOD_MESHDEFORM); /* XXX, needs own icon */
6086 
6087   RNA_define_lib_overridable(true);
6088 
6089   prop = RNA_def_property(srna, "cache_file", PROP_POINTER, PROP_NONE);
6090   RNA_def_property_pointer_sdna(prop, NULL, "cache_file");
6091   RNA_def_property_struct_type(prop, "CacheFile");
6092   RNA_def_property_ui_text(prop, "Cache File", "");
6093   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
6094   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
6095 
6096   prop = RNA_def_property(srna, "object_path", PROP_STRING, PROP_NONE);
6097   RNA_def_property_ui_text(
6098       prop,
6099       "Object Path",
6100       "Path to the object in the Alembic archive used to lookup geometric data");
6101   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6102 
6103   static const EnumPropertyItem read_flag_items[] = {
6104       {MOD_MESHSEQ_READ_VERT, "VERT", 0, "Vertex", ""},
6105       {MOD_MESHSEQ_READ_POLY, "POLY", 0, "Faces", ""},
6106       {MOD_MESHSEQ_READ_UV, "UV", 0, "UV", ""},
6107       {MOD_MESHSEQ_READ_COLOR, "COLOR", 0, "Color", ""},
6108       {0, NULL, 0, NULL, NULL},
6109   };
6110 
6111   prop = RNA_def_property(srna, "read_data", PROP_ENUM, PROP_NONE);
6112   RNA_def_property_flag(prop, PROP_ENUM_FLAG);
6113   RNA_def_property_enum_sdna(prop, NULL, "read_flag");
6114   RNA_def_property_enum_items(prop, read_flag_items);
6115   RNA_def_property_ui_text(prop, "Read Data", "Data to read from the cache");
6116   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6117 
6118   prop = RNA_def_property(srna, "use_vertex_interpolation", PROP_BOOLEAN, PROP_NONE);
6119   RNA_def_property_boolean_sdna(prop, NULL, "read_flag", MOD_MESHSEQ_INTERPOLATE_VERTICES);
6120   RNA_def_property_ui_text(
6121       prop, "Vertex Interpolation", "Allow interpolation of vertex positions");
6122   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6123 
6124   prop = RNA_def_property(srna, "velocity_scale", PROP_FLOAT, PROP_NONE);
6125   RNA_def_property_float_sdna(prop, NULL, "velocity_scale");
6126   RNA_def_property_range(prop, 0.0f, FLT_MAX);
6127   RNA_def_property_ui_text(
6128       prop,
6129       "Velocity Scale",
6130       "Multiplier used to control the magnitude of the velocity vectors for time effects");
6131   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6132 
6133   /* -------------------------- Velocity Vectors -------------------------- */
6134 
6135   prop = RNA_def_property(srna, "vertex_velocities", PROP_COLLECTION, PROP_NONE);
6136   RNA_def_property_collection_sdna(prop, NULL, "vertex_velocities", "num_vertices");
6137   RNA_def_property_struct_type(prop, "MeshCacheVertexVelocity");
6138   RNA_def_property_ui_text(
6139       prop, "Fluid Mesh Vertices", "Vertices of the fluid mesh generated by simulation");
6140 
6141   rna_def_mesh_cache_velocities(brna);
6142 
6143   prop = RNA_def_property(srna, "has_velocity", PROP_BOOLEAN, PROP_NONE);
6144   RNA_def_property_ui_text(prop, "Has Velocity Cache", "");
6145   RNA_def_property_boolean_funcs(prop, "rna_MeshSequenceCacheModifier_has_velocity_get", NULL);
6146   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
6147 
6148   prop = RNA_def_property(srna, "read_velocity", PROP_BOOLEAN, PROP_NONE);
6149   RNA_def_property_ui_text(prop, "Read Velocity Cache", "");
6150   RNA_def_property_boolean_funcs(prop, "rna_MeshSequenceCacheModifier_read_velocity_get", NULL);
6151   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
6152 
6153   RNA_define_lib_overridable(false);
6154 }
6155 
rna_def_modifier_laplaciandeform(BlenderRNA * brna)6156 static void rna_def_modifier_laplaciandeform(BlenderRNA *brna)
6157 {
6158   StructRNA *srna;
6159   PropertyRNA *prop;
6160 
6161   srna = RNA_def_struct(brna, "LaplacianDeformModifier", "Modifier");
6162   RNA_def_struct_ui_text(srna, "Laplacian Deform Modifier", "Mesh deform modifier");
6163   RNA_def_struct_sdna(srna, "LaplacianDeformModifierData");
6164   RNA_def_struct_ui_icon(srna, ICON_MOD_MESHDEFORM);
6165 
6166   RNA_define_lib_overridable(true);
6167 
6168   prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
6169   RNA_def_property_string_sdna(prop, NULL, "anchor_grp_name");
6170   RNA_def_property_ui_text(
6171       prop, "Anchor Weights", "Name of Vertex Group which determines Anchors");
6172   RNA_def_property_string_funcs(
6173       prop, NULL, NULL, "rna_LaplacianDeformModifier_anchor_grp_name_set");
6174 
6175   prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE);
6176   RNA_def_property_int_sdna(prop, NULL, "repeat");
6177   RNA_def_property_ui_range(prop, 1, 50, 1, -1);
6178   RNA_def_property_ui_text(prop, "Repeat", "");
6179   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6180 
6181   prop = RNA_def_property(srna, "is_bind", PROP_BOOLEAN, PROP_NONE);
6182   RNA_def_property_boolean_funcs(prop, "rna_LaplacianDeformModifier_is_bind_get", NULL);
6183   RNA_def_property_ui_text(prop, "Bound", "Whether geometry has been bound to anchors");
6184   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
6185 
6186   prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
6187   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_LAPLACIANDEFORM_INVERT_VGROUP);
6188   RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
6189   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6190 
6191   RNA_define_lib_overridable(false);
6192 
6193   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6194 }
6195 
rna_def_modifier_weld(BlenderRNA * brna)6196 static void rna_def_modifier_weld(BlenderRNA *brna)
6197 {
6198   StructRNA *srna;
6199   PropertyRNA *prop;
6200 
6201   srna = RNA_def_struct(brna, "WeldModifier", "Modifier");
6202   RNA_def_struct_ui_text(srna, "Weld Modifier", "Weld modifier");
6203   RNA_def_struct_sdna(srna, "WeldModifierData");
6204   RNA_def_struct_ui_icon(srna, ICON_AUTOMERGE_OFF);
6205 
6206   RNA_define_lib_overridable(true);
6207 
6208   prop = RNA_def_property(srna, "merge_threshold", PROP_FLOAT, PROP_DISTANCE);
6209   RNA_def_property_float_sdna(prop, NULL, "merge_dist");
6210   RNA_def_property_range(prop, 0, FLT_MAX);
6211   RNA_def_property_ui_range(prop, 0, 1, 0.001, 6);
6212   RNA_def_property_ui_text(prop, "Merge Distance", "Limit below which to merge vertices");
6213   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6214 
6215   prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
6216   RNA_def_property_string_sdna(prop, NULL, "defgrp_name");
6217   RNA_def_property_ui_text(
6218       prop, "Vertex Group", "Vertex group name for selecting the affected areas");
6219   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_WeldModifier_defgrp_name_set");
6220   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6221 
6222   prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
6223   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WELD_INVERT_VGROUP);
6224   RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
6225   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6226 
6227   RNA_define_lib_overridable(false);
6228 }
6229 
rna_def_modifier_wireframe(BlenderRNA * brna)6230 static void rna_def_modifier_wireframe(BlenderRNA *brna)
6231 {
6232   StructRNA *srna;
6233   PropertyRNA *prop;
6234 
6235   srna = RNA_def_struct(brna, "WireframeModifier", "Modifier");
6236   RNA_def_struct_ui_text(srna, "Wireframe Modifier", "Wireframe effect modifier");
6237   RNA_def_struct_sdna(srna, "WireframeModifierData");
6238   RNA_def_struct_ui_icon(srna, ICON_MOD_WIREFRAME);
6239 
6240   RNA_define_lib_overridable(true);
6241 
6242   prop = RNA_def_property(srna, "thickness", PROP_FLOAT, PROP_DISTANCE);
6243   RNA_def_property_float_sdna(prop, NULL, "offset");
6244   RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
6245   RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.01, 4);
6246   RNA_def_property_ui_text(prop, "Thickness", "Thickness factor");
6247   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6248 
6249   prop = RNA_def_property(srna, "thickness_vertex_group", PROP_FLOAT, PROP_FACTOR);
6250   RNA_def_property_float_sdna(prop, NULL, "offset_fac_vg");
6251   RNA_def_property_range(prop, 0.0, 1.0);
6252   RNA_def_property_ui_range(prop, 0, 1, 0.1, 3);
6253   RNA_def_property_ui_text(
6254       prop, "Vertex Group Factor", "Thickness factor to use for zero vertex group influence");
6255   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6256 
6257   prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_FACTOR);
6258   RNA_def_property_float_sdna(prop, NULL, "offset_fac");
6259   RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
6260   RNA_def_property_ui_range(prop, -1, 1, 0.1, 4);
6261   RNA_def_property_ui_text(prop, "Offset", "Offset the thickness from the center");
6262   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6263 
6264   prop = RNA_def_property(srna, "use_replace", PROP_BOOLEAN, PROP_NONE);
6265   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WIREFRAME_REPLACE);
6266   RNA_def_property_ui_text(prop, "Replace", "Remove original geometry");
6267   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6268 
6269   prop = RNA_def_property(srna, "use_boundary", PROP_BOOLEAN, PROP_NONE);
6270   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WIREFRAME_BOUNDARY);
6271   RNA_def_property_ui_text(prop, "Boundary", "Support face boundaries");
6272   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6273 
6274   prop = RNA_def_property(srna, "use_even_offset", PROP_BOOLEAN, PROP_NONE);
6275   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WIREFRAME_OFS_EVEN);
6276   RNA_def_property_ui_text(prop, "Offset Even", "Scale the offset to give more even thickness");
6277   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6278 
6279   prop = RNA_def_property(srna, "use_relative_offset", PROP_BOOLEAN, PROP_NONE);
6280   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WIREFRAME_OFS_RELATIVE);
6281   RNA_def_property_ui_text(prop, "Offset Relative", "Scale the offset by surrounding geometry");
6282   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6283 
6284   prop = RNA_def_property(srna, "use_crease", PROP_BOOLEAN, PROP_NONE);
6285   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WIREFRAME_CREASE);
6286   RNA_def_property_ui_text(
6287       prop, "Offset Relative", "Crease hub edges for improved subdivision surface");
6288   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6289 
6290   prop = RNA_def_property(srna, "crease_weight", PROP_FLOAT, PROP_NONE);
6291   RNA_def_property_float_sdna(prop, NULL, "crease_weight");
6292   RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
6293   RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 1);
6294   RNA_def_property_ui_text(prop, "Weight", "Crease weight (if active)");
6295   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6296 
6297   prop = RNA_def_property(srna, "material_offset", PROP_INT, PROP_NONE);
6298   RNA_def_property_int_sdna(prop, NULL, "mat_ofs");
6299   RNA_def_property_range(prop, SHRT_MIN, SHRT_MAX);
6300   RNA_def_property_ui_text(prop, "Material Offset", "Offset material index of generated faces");
6301   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6302 
6303   prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
6304   RNA_def_property_string_sdna(prop, NULL, "defgrp_name");
6305   RNA_def_property_ui_text(
6306       prop, "Vertex Group", "Vertex group name for selecting the affected areas");
6307   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_WireframeModifier_defgrp_name_set");
6308   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6309 
6310   prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
6311   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WIREFRAME_INVERT_VGROUP);
6312   RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
6313   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6314 
6315   RNA_define_lib_overridable(false);
6316 }
6317 
rna_def_modifier_datatransfer(BlenderRNA * brna)6318 static void rna_def_modifier_datatransfer(BlenderRNA *brna)
6319 {
6320   StructRNA *srna;
6321   PropertyRNA *prop;
6322 
6323   static const EnumPropertyItem DT_layer_vert_items[] = {
6324     {DT_TYPE_MDEFORMVERT,
6325      "VGROUP_WEIGHTS",
6326      0,
6327      "Vertex Groups",
6328      "Transfer active or all vertex groups"},
6329 #  if 0 /* TODO */
6330     {DT_TYPE_SHAPEKEY, "SHAPEKEYS", 0, "Shapekey(s)", "Transfer active or all shape keys"},
6331 #  endif
6332   /* XXX When SkinModifier is enabled,
6333    * it seems to erase its own CD_MVERT_SKIN layer from final DM :( */
6334 #  if 0
6335     {DT_TYPE_SKIN, "SKIN", 0, "Skin Weight", "Transfer skin weights"},
6336 #  endif
6337     {DT_TYPE_BWEIGHT_VERT, "BEVEL_WEIGHT_VERT", 0, "Bevel Weight", "Transfer bevel weights"},
6338     {0, NULL, 0, NULL, NULL},
6339   };
6340 
6341   static const EnumPropertyItem DT_layer_edge_items[] = {
6342       {DT_TYPE_SHARP_EDGE, "SHARP_EDGE", 0, "Sharp", "Transfer sharp mark"},
6343       {DT_TYPE_SEAM, "SEAM", 0, "UV Seam", "Transfer UV seam mark"},
6344       {DT_TYPE_CREASE, "CREASE", 0, "Crease", "Transfer subdivision crease values"},
6345       {DT_TYPE_BWEIGHT_EDGE, "BEVEL_WEIGHT_EDGE", 0, "Bevel Weight", "Transfer bevel weights"},
6346       {DT_TYPE_FREESTYLE_EDGE, "FREESTYLE_EDGE", 0, "Freestyle", "Transfer Freestyle edge mark"},
6347       {0, NULL, 0, NULL, NULL},
6348   };
6349 
6350   static const EnumPropertyItem DT_layer_loop_items[] = {
6351       {DT_TYPE_LNOR, "CUSTOM_NORMAL", 0, "Custom Normals", "Transfer custom normals"},
6352       {DT_TYPE_VCOL, "VCOL", 0, "Vertex Colors", "Vertex (face corners) colors"},
6353       {DT_TYPE_UV, "UV", 0, "UVs", "Transfer UV layers"},
6354       {0, NULL, 0, NULL, NULL},
6355   };
6356 
6357   static const EnumPropertyItem DT_layer_poly_items[] = {
6358       {DT_TYPE_SHARP_FACE, "SMOOTH", 0, "Smooth", "Transfer flat/smooth mark"},
6359       {DT_TYPE_FREESTYLE_FACE,
6360        "FREESTYLE_FACE",
6361        0,
6362        "Freestyle Mark",
6363        "Transfer Freestyle face mark"},
6364       {0, NULL, 0, NULL, NULL},
6365   };
6366 
6367   srna = RNA_def_struct(brna, "DataTransferModifier", "Modifier");
6368   RNA_def_struct_ui_text(
6369       srna, "Data Transfer Modifier", "Modifier transferring some data from a source mesh");
6370   RNA_def_struct_sdna(srna, "DataTransferModifierData");
6371   RNA_def_struct_ui_icon(srna, ICON_MOD_DATA_TRANSFER);
6372 
6373   RNA_define_lib_overridable(true);
6374 
6375   prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
6376   RNA_def_property_pointer_sdna(prop, NULL, "ob_source");
6377   RNA_def_property_ui_text(prop, "Source Object", "Object to transfer data from");
6378   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
6379   RNA_def_property_pointer_funcs(
6380       prop, NULL, "rna_DataTransferModifier_ob_source_set", NULL, "rna_Mesh_object_poll");
6381   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
6382 
6383   prop = RNA_def_boolean(srna,
6384                          "use_object_transform",
6385                          true,
6386                          "Object Transform",
6387                          "Evaluate source and destination meshes in global space");
6388   RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DATATRANSFER_OBSRC_TRANSFORM);
6389   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6390 
6391   /* Generic, UI-only data types toggles. */
6392   prop = RNA_def_boolean(
6393       srna, "use_vert_data", false, "Vertex Data", "Enable vertex data transfer");
6394   RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DATATRANSFER_USE_VERT);
6395   RNA_def_property_update(prop, 0, "rna_DataTransferModifier_use_data_update");
6396 
6397   prop = RNA_def_boolean(srna, "use_edge_data", false, "Edge Data", "Enable edge data transfer");
6398   RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DATATRANSFER_USE_EDGE);
6399   RNA_def_property_update(prop, 0, "rna_DataTransferModifier_use_data_update");
6400 
6401   prop = RNA_def_boolean(
6402       srna, "use_loop_data", false, "Face Corner Data", "Enable face corner data transfer");
6403   RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DATATRANSFER_USE_LOOP);
6404   RNA_def_property_update(prop, 0, "rna_DataTransferModifier_use_data_update");
6405 
6406   prop = RNA_def_boolean(srna, "use_poly_data", false, "Face Data", "Enable face data transfer");
6407   RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DATATRANSFER_USE_POLY);
6408   RNA_def_property_update(prop, 0, "rna_DataTransferModifier_use_data_update");
6409 
6410   /* Actual data types selection. */
6411   prop = RNA_def_enum(srna,
6412                       "data_types_verts",
6413                       DT_layer_vert_items,
6414                       0,
6415                       "Vertex Data Types",
6416                       "Which vertex data layers to transfer");
6417   RNA_def_property_flag(prop, PROP_ENUM_FLAG);
6418   RNA_def_property_enum_sdna(prop, NULL, "data_types");
6419   RNA_def_property_enum_funcs(prop, NULL, "rna_DataTransferModifier_verts_data_types_set", NULL);
6420   RNA_def_property_update(prop, 0, "rna_DataTransferModifier_data_types_update");
6421 
6422   prop = RNA_def_enum(srna,
6423                       "data_types_edges",
6424                       DT_layer_edge_items,
6425                       0,
6426                       "Edge Data Types",
6427                       "Which edge data layers to transfer");
6428   RNA_def_property_flag(prop, PROP_ENUM_FLAG);
6429   RNA_def_property_enum_sdna(prop, NULL, "data_types");
6430   RNA_def_property_enum_funcs(prop, NULL, "rna_DataTransferModifier_edges_data_types_set", NULL);
6431   RNA_def_property_update(prop, 0, "rna_DataTransferModifier_data_types_update");
6432 
6433   prop = RNA_def_enum(srna,
6434                       "data_types_loops",
6435                       DT_layer_loop_items,
6436                       0,
6437                       "Face Corner Data Types",
6438                       "Which face corner data layers to transfer");
6439   RNA_def_property_flag(prop, PROP_ENUM_FLAG);
6440   RNA_def_property_enum_sdna(prop, NULL, "data_types");
6441   RNA_def_property_enum_funcs(prop, NULL, "rna_DataTransferModifier_loops_data_types_set", NULL);
6442   RNA_def_property_update(prop, 0, "rna_DataTransferModifier_data_types_update");
6443 
6444   prop = RNA_def_enum(srna,
6445                       "data_types_polys",
6446                       DT_layer_poly_items,
6447                       0,
6448                       "Poly Data Types",
6449                       "Which poly data layers to transfer");
6450   RNA_def_property_flag(prop, PROP_ENUM_FLAG);
6451   RNA_def_property_enum_sdna(prop, NULL, "data_types");
6452   RNA_def_property_enum_funcs(prop, NULL, "rna_DataTransferModifier_polys_data_types_set", NULL);
6453   RNA_def_property_update(prop, 0, "rna_DataTransferModifier_data_types_update");
6454 
6455   /* Mapping methods. */
6456   prop = RNA_def_enum(srna,
6457                       "vert_mapping",
6458                       rna_enum_dt_method_vertex_items,
6459                       MREMAP_MODE_VERT_NEAREST,
6460                       "Vertex Mapping",
6461                       "Method used to map source vertices to destination ones");
6462   RNA_def_property_enum_sdna(prop, NULL, "vmap_mode");
6463   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6464 
6465   prop = RNA_def_enum(srna,
6466                       "edge_mapping",
6467                       rna_enum_dt_method_edge_items,
6468                       MREMAP_MODE_EDGE_NEAREST,
6469                       "Edge Mapping",
6470                       "Method used to map source edges to destination ones");
6471   RNA_def_property_enum_sdna(prop, NULL, "emap_mode");
6472   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6473 
6474   prop = RNA_def_enum(srna,
6475                       "loop_mapping",
6476                       rna_enum_dt_method_loop_items,
6477                       MREMAP_MODE_LOOP_NEAREST_POLYNOR,
6478                       "Face Corner Mapping",
6479                       "Method used to map source faces' corners to destination ones");
6480   RNA_def_property_enum_sdna(prop, NULL, "lmap_mode");
6481   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6482 
6483   prop = RNA_def_enum(srna,
6484                       "poly_mapping",
6485                       rna_enum_dt_method_poly_items,
6486                       MREMAP_MODE_POLY_NEAREST,
6487                       "Face Mapping",
6488                       "Method used to map source faces to destination ones");
6489   RNA_def_property_enum_sdna(prop, NULL, "pmap_mode");
6490   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6491 
6492   /* Mapping options and filtering. */
6493   prop = RNA_def_boolean(
6494       srna,
6495       "use_max_distance",
6496       false,
6497       "Only Neighbor Geometry",
6498       "Source elements must be closer than given distance from destination one");
6499   RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DATATRANSFER_MAP_MAXDIST);
6500   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6501 
6502   prop = RNA_def_float(
6503       srna,
6504       "max_distance",
6505       1.0f,
6506       0.0f,
6507       FLT_MAX,
6508       "Max Distance",
6509       "Maximum allowed distance between source and destination element, for non-topology mappings",
6510       0.0f,
6511       100.0f);
6512   RNA_def_property_float_sdna(prop, NULL, "map_max_distance");
6513   RNA_def_property_subtype(prop, PROP_DISTANCE);
6514   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6515 
6516   prop = RNA_def_float(
6517       srna,
6518       "ray_radius",
6519       0.0f,
6520       0.0f,
6521       FLT_MAX,
6522       "Ray Radius",
6523       "'Width' of rays (especially useful when raycasting against vertices or edges)",
6524       0.0f,
6525       10.0f);
6526   RNA_def_property_float_sdna(prop, NULL, "map_ray_radius");
6527   RNA_def_property_subtype(prop, PROP_DISTANCE);
6528   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6529 
6530   prop = RNA_def_float(
6531       srna,
6532       "islands_precision",
6533       0.0f,
6534       0.0f,
6535       1.0f,
6536       "Islands Precision",
6537       "Factor controlling precision of islands handling "
6538       "(typically, 0.1 should be enough, higher values can make things really slow)",
6539       0.0f,
6540       1.0f);
6541   RNA_def_property_subtype(prop, PROP_DISTANCE);
6542   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6543 
6544   /* How to handle multi-layers types of data. */
6545   prop = RNA_def_enum(srna,
6546                       "layers_vgroup_select_src",
6547                       rna_enum_dt_layers_select_src_items,
6548                       DT_LAYERS_ALL_SRC,
6549                       "Source Layers Selection",
6550                       "Which layers to transfer, in case of multi-layers types");
6551   RNA_def_property_enum_sdna(prop, NULL, "layers_select_src[DT_MULTILAYER_INDEX_MDEFORMVERT]");
6552   RNA_def_property_enum_funcs(
6553       prop, NULL, NULL, "rna_DataTransferModifier_layers_select_src_itemf");
6554   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6555 
6556 #  if 0
6557   prop = RNA_def_enum(srna,
6558                       "layers_shapekey_select_src",
6559                       rna_enum_dt_layers_select_src_items,
6560                       DT_LAYERS_ALL_SRC,
6561                       "Source Layers Selection",
6562                       "Which layers to transfer, in case of multi-layers types");
6563   RNA_def_property_enum_sdna(prop, NULL, "layers_select_src[DT_MULTILAYER_INDEX_SHAPEKEY]");
6564   RNA_def_property_enum_funcs(
6565       prop, NULL, NULL, "rna_DataTransferModifier_layers_select_src_itemf");
6566   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6567 #  endif
6568 
6569   prop = RNA_def_enum(srna,
6570                       "layers_vcol_select_src",
6571                       rna_enum_dt_layers_select_src_items,
6572                       DT_LAYERS_ALL_SRC,
6573                       "Source Layers Selection",
6574                       "Which layers to transfer, in case of multi-layers types");
6575   RNA_def_property_enum_sdna(prop, NULL, "layers_select_src[DT_MULTILAYER_INDEX_VCOL]");
6576   RNA_def_property_enum_funcs(
6577       prop, NULL, NULL, "rna_DataTransferModifier_layers_select_src_itemf");
6578   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6579 
6580   prop = RNA_def_enum(srna,
6581                       "layers_uv_select_src",
6582                       rna_enum_dt_layers_select_src_items,
6583                       DT_LAYERS_ALL_SRC,
6584                       "Source Layers Selection",
6585                       "Which layers to transfer, in case of multi-layers types");
6586   RNA_def_property_enum_sdna(prop, NULL, "layers_select_src[DT_MULTILAYER_INDEX_UV]");
6587   RNA_def_property_enum_funcs(
6588       prop, NULL, NULL, "rna_DataTransferModifier_layers_select_src_itemf");
6589   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6590 
6591   prop = RNA_def_enum(srna,
6592                       "layers_vgroup_select_dst",
6593                       rna_enum_dt_layers_select_dst_items,
6594                       DT_LAYERS_NAME_DST,
6595                       "Destination Layers Matching",
6596                       "How to match source and destination layers");
6597   RNA_def_property_enum_sdna(prop, NULL, "layers_select_dst[DT_MULTILAYER_INDEX_MDEFORMVERT]");
6598   RNA_def_property_enum_funcs(
6599       prop, NULL, NULL, "rna_DataTransferModifier_layers_select_dst_itemf");
6600   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6601 
6602 #  if 0
6603   prop = RNA_def_enum(srna,
6604                       "layers_shapekey_select_dst",
6605                       rna_enum_dt_layers_select_dst_items,
6606                       DT_LAYERS_NAME_DST,
6607                       "Destination Layers Matching",
6608                       "How to match source and destination layers");
6609   RNA_def_property_enum_sdna(prop, NULL, "layers_select_dst[DT_MULTILAYER_INDEX_SHAPEKEY]");
6610   RNA_def_property_enum_funcs(
6611       prop, NULL, NULL, "rna_DataTransferModifier_layers_select_dst_itemf");
6612   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6613 #  endif
6614 
6615   prop = RNA_def_enum(srna,
6616                       "layers_vcol_select_dst",
6617                       rna_enum_dt_layers_select_dst_items,
6618                       DT_LAYERS_NAME_DST,
6619                       "Destination Layers Matching",
6620                       "How to match source and destination layers");
6621   RNA_def_property_enum_sdna(prop, NULL, "layers_select_dst[DT_MULTILAYER_INDEX_VCOL]");
6622   RNA_def_property_enum_funcs(
6623       prop, NULL, NULL, "rna_DataTransferModifier_layers_select_dst_itemf");
6624   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6625 
6626   prop = RNA_def_enum(srna,
6627                       "layers_uv_select_dst",
6628                       rna_enum_dt_layers_select_dst_items,
6629                       DT_LAYERS_NAME_DST,
6630                       "Destination Layers Matching",
6631                       "How to match source and destination layers");
6632   RNA_def_property_enum_sdna(prop, NULL, "layers_select_dst[DT_MULTILAYER_INDEX_UV]");
6633   RNA_def_property_enum_funcs(
6634       prop, NULL, NULL, "rna_DataTransferModifier_layers_select_dst_itemf");
6635   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6636 
6637   /* Mix stuff */
6638   prop = RNA_def_enum(srna,
6639                       "mix_mode",
6640                       rna_enum_dt_mix_mode_items,
6641                       CDT_MIX_TRANSFER,
6642                       "Mix Mode",
6643                       "How to affect destination elements with source values");
6644   RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_DataTransferModifier_mix_mode_itemf");
6645   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6646 
6647   prop = RNA_def_float_factor(
6648       srna,
6649       "mix_factor",
6650       0.0f,
6651       0.0f,
6652       1.0f,
6653       "Mix Factor",
6654       "Factor to use when applying data to destination (exact behavior depends on mix mode, "
6655       "multiplied with weights from vertex group when defined)",
6656       0.0f,
6657       1.0f);
6658   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6659 
6660   prop = RNA_def_string(srna,
6661                         "vertex_group",
6662                         NULL,
6663                         MAX_VGROUP_NAME,
6664                         "Vertex Group",
6665                         "Vertex group name for selecting the affected areas");
6666   RNA_def_property_string_sdna(prop, NULL, "defgrp_name");
6667   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_DataTransferModifier_defgrp_name_set");
6668   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6669 
6670   prop = RNA_def_boolean(
6671       srna, "invert_vertex_group", false, "Invert", "Invert vertex group influence");
6672   RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_DATATRANSFER_INVERT_VGROUP);
6673   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6674 
6675   RNA_define_lib_overridable(false);
6676 }
6677 
rna_def_modifier_normaledit(BlenderRNA * brna)6678 static void rna_def_modifier_normaledit(BlenderRNA *brna)
6679 {
6680   StructRNA *srna;
6681   PropertyRNA *prop;
6682 
6683   static const EnumPropertyItem prop_mode_items[] = {
6684       {MOD_NORMALEDIT_MODE_RADIAL,
6685        "RADIAL",
6686        0,
6687        "Radial",
6688        "From an ellipsoid (shape defined by the boundbox's dimensions, target is optional)"},
6689       {MOD_NORMALEDIT_MODE_DIRECTIONAL,
6690        "DIRECTIONAL",
6691        0,
6692        "Directional",
6693        "Normals 'track' (point to) the target object"},
6694       {0, NULL, 0, NULL, NULL},
6695   };
6696 
6697   static const EnumPropertyItem prop_mix_mode_items[] = {
6698       {MOD_NORMALEDIT_MIX_COPY, "COPY", 0, "Copy", "Copy new normals (overwrite existing)"},
6699       {MOD_NORMALEDIT_MIX_ADD, "ADD", 0, "Add", "Copy sum of new and old normals"},
6700       {MOD_NORMALEDIT_MIX_SUB, "SUB", 0, "Subtract", "Copy new normals minus old normals"},
6701       {MOD_NORMALEDIT_MIX_MUL,
6702        "MUL",
6703        0,
6704        "Multiply",
6705        "Copy product of old and new normals (*not* cross product)"},
6706       {0, NULL, 0, NULL, NULL},
6707   };
6708 
6709   srna = RNA_def_struct(brna, "NormalEditModifier", "Modifier");
6710   RNA_def_struct_ui_text(
6711       srna, "Normal Edit Modifier", "Modifier affecting/generating custom normals");
6712   RNA_def_struct_sdna(srna, "NormalEditModifierData");
6713   RNA_def_struct_ui_icon(srna, ICON_MOD_NORMALEDIT);
6714 
6715   RNA_define_lib_overridable(true);
6716 
6717   prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
6718   RNA_def_property_enum_items(prop, prop_mode_items);
6719   RNA_def_property_ui_text(prop, "Mode", "How to affect (generate) normals");
6720   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6721 
6722   prop = RNA_def_float_array(srna,
6723                              "offset",
6724                              3,
6725                              NULL,
6726                              -FLT_MAX,
6727                              FLT_MAX,
6728                              "Offset",
6729                              "Offset from object's center",
6730                              -100.0f,
6731                              100.0f);
6732   RNA_def_property_subtype(prop, PROP_COORDS);
6733   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6734 
6735   prop = RNA_def_property(srna, "mix_mode", PROP_ENUM, PROP_NONE);
6736   RNA_def_property_enum_items(prop, prop_mix_mode_items);
6737   RNA_def_property_ui_text(prop, "Mix Mode", "How to mix generated normals with existing ones");
6738   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6739 
6740   prop = RNA_def_property(srna, "mix_factor", PROP_FLOAT, PROP_FACTOR);
6741   RNA_def_property_range(prop, 0.0, 1.0);
6742   RNA_def_property_ui_text(
6743       prop, "Mix Factor", "How much of generated normals to mix with exiting ones");
6744   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6745 
6746   prop = RNA_def_property(srna, "mix_limit", PROP_FLOAT, PROP_ANGLE);
6747   RNA_def_property_range(prop, 0.0, DEG2RADF(180.0f));
6748   RNA_def_property_ui_text(prop, "Max Angle", "Maximum angle between old and new normals");
6749   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6750 
6751   prop = RNA_def_property(srna, "no_polynors_fix", PROP_BOOLEAN, PROP_NONE);
6752   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_NORMALEDIT_NO_POLYNORS_FIX);
6753   RNA_def_property_boolean_default(prop, false);
6754   RNA_def_property_ui_text(prop,
6755                            "Lock Polygon Normals",
6756                            "Do not flip polygons when their normals are not consistent "
6757                            "with their newly computed custom vertex normals");
6758   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6759 
6760   prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
6761   RNA_def_property_string_sdna(prop, NULL, "defgrp_name");
6762   RNA_def_property_ui_text(
6763       prop, "Vertex Group", "Vertex group name for selecting/weighting the affected areas");
6764   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_NormalEditModifier_defgrp_name_set");
6765   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6766 
6767   prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
6768   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_NORMALEDIT_INVERT_VGROUP);
6769   RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
6770   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6771 
6772   prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
6773   RNA_def_property_ui_text(prop, "Target", "Target object used to affect normals");
6774   RNA_def_property_pointer_funcs(prop, NULL, "rna_NormalEditModifier_target_set", NULL, NULL);
6775   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
6776   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
6777 
6778   prop = RNA_def_property(srna, "use_direction_parallel", PROP_BOOLEAN, PROP_NONE);
6779   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_NORMALEDIT_USE_DIRECTION_PARALLEL);
6780   RNA_def_property_boolean_default(prop, true);
6781   RNA_def_property_ui_text(prop,
6782                            "Parallel Normals",
6783                            "Use same direction for all normals, from origin to target's center "
6784                            "(Directional mode only)");
6785   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6786 
6787   RNA_define_lib_overridable(false);
6788 }
6789 
rna_def_modifier_surfacedeform(BlenderRNA * brna)6790 static void rna_def_modifier_surfacedeform(BlenderRNA *brna)
6791 {
6792   StructRNA *srna;
6793   PropertyRNA *prop;
6794 
6795   srna = RNA_def_struct(brna, "SurfaceDeformModifier", "Modifier");
6796   RNA_def_struct_ui_text(srna, "SurfaceDeform Modifier", "");
6797   RNA_def_struct_sdna(srna, "SurfaceDeformModifierData");
6798   RNA_def_struct_ui_icon(srna, ICON_MOD_MESHDEFORM);
6799 
6800   RNA_define_lib_overridable(true);
6801 
6802   prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE);
6803   RNA_def_property_ui_text(prop, "Target", "Mesh object to deform with");
6804   RNA_def_property_pointer_funcs(
6805       prop, NULL, "rna_SurfaceDeformModifier_target_set", NULL, "rna_Mesh_object_poll");
6806   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
6807   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
6808 
6809   prop = RNA_def_property(srna, "falloff", PROP_FLOAT, PROP_NONE);
6810   RNA_def_property_range(prop, 2.0f, 16.0f);
6811   RNA_def_property_ui_text(
6812       prop, "Interpolation Falloff", "Controls how much nearby polygons influence deformation");
6813   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6814 
6815   prop = RNA_def_property(srna, "is_bound", PROP_BOOLEAN, PROP_NONE);
6816   RNA_def_property_boolean_funcs(prop, "rna_SurfaceDeformModifier_is_bound_get", NULL);
6817   RNA_def_property_ui_text(prop, "Bound", "Whether geometry has been bound to target mesh");
6818   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
6819 
6820   prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
6821   RNA_def_property_string_sdna(prop, NULL, "defgrp_name");
6822   RNA_def_property_ui_text(
6823       prop, "Vertex Group", "Vertex group name for selecting/weighting the affected areas");
6824   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SurfaceDeformModifier_defgrp_name_set");
6825   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6826 
6827   prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
6828   RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SDEF_INVERT_VGROUP);
6829   RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
6830   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6831 
6832   prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE);
6833   RNA_def_property_range(prop, -100, 100);
6834   RNA_def_property_ui_range(prop, -100, 100, 10, 2);
6835   RNA_def_property_ui_text(prop, "Strength", "Strength of modifier deformations");
6836   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6837 
6838   RNA_define_lib_overridable(false);
6839 }
6840 
rna_def_modifier_weightednormal(BlenderRNA * brna)6841 static void rna_def_modifier_weightednormal(BlenderRNA *brna)
6842 {
6843   StructRNA *srna;
6844   PropertyRNA *prop;
6845 
6846   static EnumPropertyItem prop_weighting_mode_items[] = {
6847       {MOD_WEIGHTEDNORMAL_MODE_FACE,
6848        "FACE_AREA",
6849        0,
6850        "Face Area",
6851        "Generate face area weighted normals"},
6852       {MOD_WEIGHTEDNORMAL_MODE_ANGLE,
6853        "CORNER_ANGLE",
6854        0,
6855        "Corner Angle",
6856        "Generate corner angle weighted normals"},
6857       {MOD_WEIGHTEDNORMAL_MODE_FACE_ANGLE,
6858        "FACE_AREA_WITH_ANGLE",
6859        0,
6860        "Face Area And Angle",
6861        "Generated normals weighted by both face area and angle"},
6862       {0, NULL, 0, NULL, NULL},
6863   };
6864 
6865   srna = RNA_def_struct(brna, "WeightedNormalModifier", "Modifier");
6866   RNA_def_struct_ui_text(srna, "WeightedNormal Modifier", "");
6867   RNA_def_struct_sdna(srna, "WeightedNormalModifierData");
6868   RNA_def_struct_ui_icon(srna, ICON_MOD_NORMALEDIT);
6869 
6870   RNA_define_lib_overridable(true);
6871 
6872   prop = RNA_def_property(srna, "weight", PROP_INT, PROP_NONE);
6873   RNA_def_property_range(prop, 1, 100);
6874   RNA_def_property_ui_range(prop, 1, 100, 1, -1);
6875   RNA_def_property_ui_text(prop,
6876                            "Weight",
6877                            "Corrective factor applied to faces' weights, 50 is neutral, "
6878                            "lower values increase weight of weak faces, "
6879                            "higher values increase weight of strong faces");
6880   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6881 
6882   prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
6883   RNA_def_property_enum_items(prop, prop_weighting_mode_items);
6884   RNA_def_property_ui_text(prop, "Weighting Mode", "Weighted vertex normal mode to use");
6885   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6886 
6887   prop = RNA_def_property(srna, "thresh", PROP_FLOAT, PROP_NONE);
6888   RNA_def_property_range(prop, 0, 10);
6889   RNA_def_property_ui_range(prop, 0, 10, 1, 2);
6890   RNA_def_property_ui_text(
6891       prop, "Threshold", "Threshold value for different weights to be considered equal");
6892   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6893 
6894   prop = RNA_def_property(srna, "keep_sharp", PROP_BOOLEAN, PROP_NONE);
6895   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WEIGHTEDNORMAL_KEEP_SHARP);
6896   RNA_def_property_ui_text(prop,
6897                            "Keep Sharp",
6898                            "Keep sharp edges as computed for default split normals, "
6899                            "instead of setting a single weighted normal for each vertex");
6900   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6901 
6902   prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE);
6903   RNA_def_property_string_sdna(prop, NULL, "defgrp_name");
6904   RNA_def_property_ui_text(
6905       prop, "Vertex Group", "Vertex group name for modifying the selected areas");
6906   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_WeightedNormalModifier_defgrp_name_set");
6907   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6908 
6909   prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE);
6910   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WEIGHTEDNORMAL_INVERT_VGROUP);
6911   RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
6912   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6913 
6914   prop = RNA_def_property(srna, "use_face_influence", PROP_BOOLEAN, PROP_NONE);
6915   RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_WEIGHTEDNORMAL_FACE_INFLUENCE);
6916   RNA_def_property_ui_text(prop, "Face Influence", "Use influence of face for weighting");
6917   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6918 
6919   RNA_define_lib_overridable(false);
6920 }
6921 
6922 #  ifdef WITH_GEOMETRY_NODES
rna_def_modifier_simulation(BlenderRNA * brna)6923 static void rna_def_modifier_simulation(BlenderRNA *brna)
6924 {
6925   StructRNA *srna;
6926 
6927   srna = RNA_def_struct(brna, "SimulationModifier", "Modifier");
6928   RNA_def_struct_ui_text(srna, "Simulation Modifier", "");
6929   RNA_def_struct_sdna(srna, "SimulationModifierData");
6930   RNA_def_struct_ui_icon(srna, ICON_PHYSICS); /* TODO: Use correct icon. */
6931 
6932   RNA_define_lib_overridable(true);
6933 
6934   RNA_define_lib_overridable(false);
6935 }
6936 #  endif
6937 
rna_def_modifier_mesh_to_volume(BlenderRNA * brna)6938 static void rna_def_modifier_mesh_to_volume(BlenderRNA *brna)
6939 {
6940   StructRNA *srna;
6941   PropertyRNA *prop;
6942 
6943   static EnumPropertyItem resolution_mode_items[] = {
6944       {MESH_TO_VOLUME_RESOLUTION_MODE_VOXEL_AMOUNT,
6945        "VOXEL_AMOUNT",
6946        0,
6947        "Voxel Amount",
6948        "Desired number of voxels along one axis"},
6949       {MESH_TO_VOLUME_RESOLUTION_MODE_VOXEL_SIZE,
6950        "VOXEL_SIZE",
6951        0,
6952        "Voxel Size",
6953        "Desired voxel side length"},
6954       {0, NULL, 0, NULL, NULL},
6955   };
6956 
6957   srna = RNA_def_struct(brna, "MeshToVolumeModifier", "Modifier");
6958   RNA_def_struct_ui_text(srna, "Mesh to Volume Modifier", "");
6959   RNA_def_struct_sdna(srna, "MeshToVolumeModifierData");
6960   RNA_def_struct_ui_icon(srna, ICON_VOLUME_DATA); /* TODO: Use correct icon. */
6961 
6962   RNA_define_lib_overridable(true);
6963 
6964   prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
6965   RNA_def_property_ui_text(prop, "Object", "Object");
6966   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
6967   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
6968 
6969   prop = RNA_def_property(srna, "resolution_mode", PROP_ENUM, PROP_NONE);
6970   RNA_def_property_enum_items(prop, resolution_mode_items);
6971   RNA_def_property_ui_text(
6972       prop, "Resolution Mode", "Mode for how the desired voxel size is specified");
6973   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6974 
6975   prop = RNA_def_property(srna, "voxel_size", PROP_FLOAT, PROP_NONE);
6976   RNA_def_property_ui_text(
6977       prop, "Voxel Size", "Smaller values result in a higher resolution output");
6978   RNA_def_property_range(prop, 0.0, FLT_MAX);
6979   RNA_def_property_ui_range(prop, 0.0, FLT_MAX, 0.01, 4);
6980   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6981 
6982   prop = RNA_def_property(srna, "voxel_amount", PROP_INT, PROP_NONE);
6983   RNA_def_property_ui_text(prop, "Voxel Amount", "Approximate number of voxels along one axis");
6984   RNA_def_property_range(prop, 0, INT_MAX);
6985   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6986 
6987   prop = RNA_def_property(srna, "use_fill_volume", PROP_BOOLEAN, PROP_NONE);
6988   RNA_def_property_boolean_sdna(prop, NULL, "fill_volume", 1);
6989   RNA_def_property_ui_text(
6990       prop, "Fill Volume", "Initialize the density grid in every cell inside the enclosed volume");
6991   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6992 
6993   prop = RNA_def_property(srna, "interior_band_width", PROP_FLOAT, PROP_NONE);
6994   RNA_def_property_ui_text(prop, "Interior Band Width", "Width of the volume inside of the mesh");
6995   RNA_def_property_range(prop, 0.0, FLT_MAX);
6996   RNA_def_property_update(prop, 0, "rna_Modifier_update");
6997 
6998   prop = RNA_def_property(srna, "exterior_band_width", PROP_FLOAT, PROP_NONE);
6999   RNA_def_property_ui_text(prop, "Exterior Band Width", "Width of the volume outside of the mesh");
7000   RNA_def_property_range(prop, 0.0, FLT_MAX);
7001   RNA_def_property_update(prop, 0, "rna_Modifier_update");
7002 
7003   prop = RNA_def_property(srna, "density", PROP_FLOAT, PROP_NONE);
7004   RNA_def_property_ui_text(prop, "Density", "Density of the new volume");
7005   RNA_def_property_range(prop, 0.0, FLT_MAX);
7006   RNA_def_property_update(prop, 0, "rna_Modifier_update");
7007 
7008   RNA_define_lib_overridable(false);
7009 }
7010 
rna_def_modifier_volume_displace(BlenderRNA * brna)7011 static void rna_def_modifier_volume_displace(BlenderRNA *brna)
7012 {
7013   static const EnumPropertyItem prop_texture_map_mode_items[] = {
7014       {MOD_VOLUME_DISPLACE_MAP_LOCAL,
7015        "LOCAL",
7016        0,
7017        "Local",
7018        "Use the local coordinate system for the texture coordinates"},
7019       {MOD_VOLUME_DISPLACE_MAP_GLOBAL,
7020        "GLOBAL",
7021        0,
7022        "Global",
7023        "Use the global coordinate system for the texture coordinates"},
7024       {MOD_VOLUME_DISPLACE_MAP_OBJECT,
7025        "OBJECT",
7026        0,
7027        "Object",
7028        "Use the linked object's local coordinate system for the texture coordinates"},
7029       {0, NULL, 0, NULL, NULL},
7030   };
7031 
7032   StructRNA *srna;
7033   PropertyRNA *prop;
7034 
7035   srna = RNA_def_struct(brna, "VolumeDisplaceModifier", "Modifier");
7036   RNA_def_struct_ui_text(srna, "Volume Displace Modifier", "");
7037   RNA_def_struct_sdna(srna, "VolumeDisplaceModifierData");
7038   RNA_def_struct_ui_icon(srna, ICON_VOLUME_DATA); /* TODO: Use correct icon. */
7039 
7040   RNA_define_lib_overridable(true);
7041 
7042   prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE);
7043   RNA_def_property_ui_text(prop, "Strength", "Strength of the displacement");
7044   RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 0.1, 4);
7045   RNA_def_property_update(prop, 0, "rna_Modifier_update");
7046 
7047   prop = RNA_def_property(srna, "texture", PROP_POINTER, PROP_NONE);
7048   RNA_def_property_ui_text(prop, "Texture", "");
7049   RNA_def_property_flag(prop, PROP_EDITABLE);
7050   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
7051 
7052   prop = RNA_def_property(srna, "texture_map_mode", PROP_ENUM, PROP_NONE);
7053   RNA_def_property_enum_items(prop, prop_texture_map_mode_items);
7054   RNA_def_property_ui_text(prop, "Texture Mapping Mode", "");
7055   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
7056 
7057   prop = RNA_def_property(srna, "texture_map_object", PROP_POINTER, PROP_NONE);
7058   RNA_def_property_ui_text(prop, "Object", "Object to use for texture mapping");
7059   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
7060   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
7061 
7062   prop = RNA_def_property(srna, "texture_mid_level", PROP_FLOAT, PROP_XYZ);
7063   RNA_def_property_ui_text(
7064       prop, "Texture Mid Level", "Subtracted from the texture color to get a displacement vector");
7065   RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
7066   RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1f, 5);
7067   RNA_def_property_update(prop, 0, "rna_Modifier_update");
7068 
7069   prop = RNA_def_property(srna, "texture_sample_radius", PROP_FLOAT, PROP_FACTOR);
7070   RNA_def_property_ui_text(
7071       prop,
7072       "Texture Sample Radius",
7073       "Smaller values result in better performance but might cut off the volume");
7074   RNA_def_property_range(prop, 0.0f, FLT_MAX);
7075   RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1f, 5);
7076   RNA_def_property_update(prop, 0, "rna_Modifier_update");
7077 
7078   RNA_define_lib_overridable(false);
7079 }
7080 
rna_def_modifier_volume_to_mesh(BlenderRNA * brna)7081 static void rna_def_modifier_volume_to_mesh(BlenderRNA *brna)
7082 {
7083   StructRNA *srna;
7084   PropertyRNA *prop;
7085 
7086   static EnumPropertyItem resolution_mode_items[] = {
7087       {VOLUME_TO_MESH_RESOLUTION_MODE_GRID,
7088        "GRID",
7089        0,
7090        "Grid",
7091        "Use resolution of the volume grid"},
7092       {VOLUME_TO_MESH_RESOLUTION_MODE_VOXEL_AMOUNT,
7093        "VOXEL_AMOUNT",
7094        0,
7095        "Voxel Amount",
7096        "Desired number of voxels along one axis"},
7097       {VOLUME_TO_MESH_RESOLUTION_MODE_VOXEL_SIZE,
7098        "VOXEL_SIZE",
7099        0,
7100        "Voxel Size",
7101        "Desired voxel side length"},
7102       {0, NULL, 0, NULL, NULL},
7103   };
7104 
7105   srna = RNA_def_struct(brna, "VolumeToMeshModifier", "Modifier");
7106   RNA_def_struct_ui_text(srna, "Volume to Mesh Modifier", "");
7107   RNA_def_struct_sdna(srna, "VolumeToMeshModifierData");
7108   RNA_def_struct_ui_icon(srna, ICON_VOLUME_DATA); /* TODO: Use correct icon. */
7109 
7110   RNA_define_lib_overridable(true);
7111 
7112   prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
7113   RNA_def_property_ui_text(prop, "Object", "Object");
7114   RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
7115   RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update");
7116 
7117   prop = RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_NONE);
7118   RNA_def_property_ui_text(
7119       prop, "Threshold", "Voxels with a larger value are inside the generated mesh");
7120   RNA_def_property_range(prop, 0.0f, FLT_MAX);
7121   RNA_def_property_ui_range(prop, 0.001f, 1.0f, 0.1f, 5);
7122   RNA_def_property_update(prop, 0, "rna_Modifier_update");
7123 
7124   prop = RNA_def_property(srna, "adaptivity", PROP_FLOAT, PROP_NONE);
7125   RNA_def_property_ui_text(
7126       prop,
7127       "Adaptivity",
7128       "Reduces the final face count by simplifying geometry where detail is not needed");
7129   RNA_def_property_range(prop, 0.0f, 1.0f);
7130   RNA_def_property_update(prop, 0, "rna_Modifier_update");
7131 
7132   prop = RNA_def_property(srna, "use_smooth_shade", PROP_BOOLEAN, PROP_NONE);
7133   RNA_def_property_boolean_sdna(prop, NULL, "flag", VOLUME_TO_MESH_USE_SMOOTH_SHADE);
7134   RNA_def_property_ui_text(
7135       prop, "Smooth Shading", "Output faces with smooth shading rather than flat shaded");
7136   RNA_def_property_update(prop, 0, "rna_Modifier_update");
7137 
7138   prop = RNA_def_property(srna, "grid_name", PROP_STRING, PROP_NONE);
7139   RNA_def_property_ui_text(
7140       prop, "Grid Name", "Grid in the volume object that is converted to a mesh");
7141   RNA_def_property_update(prop, 0, "rna_Modifier_update");
7142 
7143   prop = RNA_def_property(srna, "resolution_mode", PROP_ENUM, PROP_NONE);
7144   RNA_def_property_enum_items(prop, resolution_mode_items);
7145   RNA_def_property_ui_text(
7146       prop, "Resolution Mode", "Mode for how the desired voxel size is specified");
7147   RNA_def_property_update(prop, 0, "rna_Modifier_update");
7148 
7149   prop = RNA_def_property(srna, "voxel_size", PROP_FLOAT, PROP_NONE);
7150   RNA_def_property_ui_text(
7151       prop, "Voxel Size", "Smaller values result in a higher resolution output");
7152   RNA_def_property_range(prop, 0.0, FLT_MAX);
7153   RNA_def_property_ui_range(prop, 0.0, FLT_MAX, 0.01, 4);
7154   RNA_def_property_update(prop, 0, "rna_Modifier_update");
7155 
7156   prop = RNA_def_property(srna, "voxel_amount", PROP_INT, PROP_NONE);
7157   RNA_def_property_ui_text(prop, "Voxel Amount", "Approximate number of voxels along one axis");
7158   RNA_def_property_range(prop, 0, INT_MAX);
7159   RNA_def_property_update(prop, 0, "rna_Modifier_update");
7160 
7161   RNA_define_lib_overridable(false);
7162 }
7163 
RNA_def_modifier(BlenderRNA * brna)7164 void RNA_def_modifier(BlenderRNA *brna)
7165 {
7166   StructRNA *srna;
7167   PropertyRNA *prop;
7168 
7169   /* data */
7170   srna = RNA_def_struct(brna, "Modifier", NULL);
7171   RNA_def_struct_ui_text(srna, "Modifier", "Modifier affecting the geometry data of an object");
7172   RNA_def_struct_refine_func(srna, "rna_Modifier_refine");
7173   RNA_def_struct_path_func(srna, "rna_Modifier_path");
7174   RNA_def_struct_sdna(srna, "ModifierData");
7175 
7176   /* strings */
7177   prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
7178   RNA_def_property_string_funcs(prop, NULL, NULL, "rna_Modifier_name_set");
7179   RNA_def_property_ui_text(prop, "Name", "Modifier name");
7180   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER | NA_RENAME, NULL);
7181   RNA_def_struct_name_property(srna, prop);
7182 
7183   /* enums */
7184   prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
7185   RNA_def_property_clear_flag(prop, PROP_EDITABLE);
7186   RNA_def_property_enum_sdna(prop, NULL, "type");
7187   RNA_def_property_enum_items(prop, rna_enum_object_modifier_type_items);
7188   RNA_def_property_ui_text(prop, "Type", "");
7189 
7190   /* flags */
7191   prop = RNA_def_property(srna, "show_viewport", PROP_BOOLEAN, PROP_NONE);
7192   RNA_def_property_boolean_sdna(prop, NULL, "mode", eModifierMode_Realtime);
7193   RNA_def_property_ui_text(prop, "Realtime", "Display modifier in viewport");
7194   RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
7195   RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
7196   RNA_def_property_update(prop, 0, "rna_Modifier_update");
7197   RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_ON, 1);
7198 
7199   prop = RNA_def_property(srna, "show_render", PROP_BOOLEAN, PROP_NONE);
7200   RNA_def_property_boolean_sdna(prop, NULL, "mode", eModifierMode_Render);
7201   RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
7202   RNA_def_property_ui_text(prop, "Render", "Use modifier during render");
7203   RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_ON, 1);
7204   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL);
7205 
7206   prop = RNA_def_property(srna, "show_in_editmode", PROP_BOOLEAN, PROP_NONE);
7207   RNA_def_property_boolean_sdna(prop, NULL, "mode", eModifierMode_Editmode);
7208   RNA_def_property_ui_text(prop, "Edit Mode", "Display modifier in Edit mode");
7209   RNA_def_property_update(prop, 0, "rna_Modifier_update");
7210   RNA_def_property_ui_icon(prop, ICON_EDITMODE_HLT, 0);
7211 
7212   prop = RNA_def_property(srna, "show_on_cage", PROP_BOOLEAN, PROP_NONE);
7213   RNA_def_property_boolean_sdna(prop, NULL, "mode", eModifierMode_OnCage);
7214   RNA_def_property_ui_text(prop, "On Cage", "Adjust edit cage to modifier result");
7215   RNA_def_property_ui_icon(prop, ICON_MESH_DATA, 0);
7216   RNA_def_property_update(prop, 0, "rna_Modifier_update");
7217 
7218   prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
7219   RNA_def_property_boolean_funcs(
7220       prop, "rna_Modifier_show_expanded_get", "rna_Modifier_show_expanded_set");
7221   RNA_def_property_flag(prop, PROP_NO_DEG_UPDATE);
7222   RNA_def_property_boolean_sdna(prop, NULL, "ui_expand_flag", 0);
7223   RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
7224   RNA_def_property_ui_text(prop, "Expanded", "Set modifier expanded in the user interface");
7225   RNA_def_property_ui_icon(prop, ICON_DISCLOSURE_TRI_RIGHT, 1);
7226   RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL);
7227 
7228   prop = RNA_def_property(srna, "use_apply_on_spline", PROP_BOOLEAN, PROP_NONE);
7229   RNA_def_property_boolean_sdna(prop, NULL, "mode", eModifierMode_ApplyOnSpline);
7230   RNA_def_property_ui_text(
7231       prop,
7232       "Apply on Spline",
7233       "Apply this and all preceding deformation modifiers on splines' points rather than "
7234       "on filled curve/surface");
7235   RNA_def_property_ui_icon(prop, ICON_SURFACE_DATA, 0);
7236   RNA_def_property_update(prop, 0, "rna_Modifier_update");
7237 
7238   /* types */
7239   rna_def_modifier_subsurf(brna);
7240   rna_def_modifier_lattice(brna);
7241   rna_def_modifier_curve(brna);
7242   rna_def_modifier_build(brna);
7243   rna_def_modifier_mirror(brna);
7244   rna_def_modifier_decimate(brna);
7245   rna_def_modifier_wave(brna);
7246   rna_def_modifier_armature(brna);
7247   rna_def_modifier_hook(brna);
7248   rna_def_modifier_softbody(brna);
7249   rna_def_modifier_boolean(brna);
7250   rna_def_modifier_array(brna);
7251   rna_def_modifier_edgesplit(brna);
7252   rna_def_modifier_displace(brna);
7253   rna_def_modifier_uvproject(brna);
7254   rna_def_modifier_smooth(brna);
7255   rna_def_modifier_correctivesmooth(brna);
7256   rna_def_modifier_cast(brna);
7257   rna_def_modifier_meshdeform(brna);
7258   rna_def_modifier_particlesystem(brna);
7259   rna_def_modifier_particleinstance(brna);
7260   rna_def_modifier_explode(brna);
7261   rna_def_modifier_cloth(brna);
7262   rna_def_modifier_collision(brna);
7263   rna_def_modifier_bevel(brna);
7264   rna_def_modifier_shrinkwrap(brna);
7265   rna_def_modifier_mask(brna);
7266   rna_def_modifier_simpledeform(brna);
7267   rna_def_modifier_warp(brna);
7268   rna_def_modifier_multires(brna);
7269   rna_def_modifier_surface(brna);
7270   rna_def_modifier_fluid(brna);
7271   rna_def_modifier_solidify(brna);
7272   rna_def_modifier_screw(brna);
7273   rna_def_modifier_uvwarp(brna);
7274   rna_def_modifier_weightvgedit(brna);
7275   rna_def_modifier_weightvgmix(brna);
7276   rna_def_modifier_weightvgproximity(brna);
7277   rna_def_modifier_dynamic_paint(brna);
7278   rna_def_modifier_ocean(brna);
7279   rna_def_modifier_remesh(brna);
7280   rna_def_modifier_skin(brna);
7281   rna_def_modifier_laplaciansmooth(brna);
7282   rna_def_modifier_triangulate(brna);
7283   rna_def_modifier_meshcache(brna);
7284   rna_def_modifier_laplaciandeform(brna);
7285   rna_def_modifier_weld(brna);
7286   rna_def_modifier_wireframe(brna);
7287   rna_def_modifier_datatransfer(brna);
7288   rna_def_modifier_normaledit(brna);
7289   rna_def_modifier_meshseqcache(brna);
7290   rna_def_modifier_surfacedeform(brna);
7291   rna_def_modifier_weightednormal(brna);
7292 #  ifdef WITH_GEOMETRY_NODES
7293   rna_def_modifier_simulation(brna);
7294 #  endif
7295   rna_def_modifier_mesh_to_volume(brna);
7296   rna_def_modifier_volume_displace(brna);
7297   rna_def_modifier_volume_to_mesh(brna);
7298 }
7299 
7300 #endif
7301