Blender  V3.3
object_modifier.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 
8 #include <cmath>
9 #include <cstdio>
10 #include <cstdlib>
11 
12 #include "MEM_guardedalloc.h"
13 
14 #include "DNA_anim_types.h"
15 #include "DNA_armature_types.h"
16 #include "DNA_curve_types.h"
17 #include "DNA_dynamicpaint_types.h"
18 #include "DNA_fluid_types.h"
19 #include "DNA_key_types.h"
20 #include "DNA_lattice_types.h"
21 #include "DNA_mesh_types.h"
22 #include "DNA_meshdata_types.h"
23 #include "DNA_object_force_types.h"
24 #include "DNA_scene_types.h"
25 #include "DNA_space_types.h"
26 
27 #include "BLI_bitmap.h"
28 #include "BLI_listbase.h"
29 #include "BLI_math.h"
30 #include "BLI_path_util.h"
31 #include "BLI_string.h"
32 #include "BLI_string_utf8.h"
33 #include "BLI_utildefines.h"
34 
35 #include "BKE_DerivedMesh.h"
36 #include "BKE_animsys.h"
37 #include "BKE_armature.h"
38 #include "BKE_context.h"
39 #include "BKE_curve.h"
40 #include "BKE_curves.h"
41 #include "BKE_curves.hh"
42 #include "BKE_displist.h"
43 #include "BKE_editmesh.h"
44 #include "BKE_effect.h"
45 #include "BKE_geometry_set.hh"
46 #include "BKE_global.h"
47 #include "BKE_gpencil_modifier.h"
48 #include "BKE_key.h"
49 #include "BKE_lattice.h"
50 #include "BKE_lib_id.h"
51 #include "BKE_main.h"
52 #include "BKE_material.h"
53 #include "BKE_mesh.h"
54 #include "BKE_mesh_mapping.h"
55 #include "BKE_mesh_runtime.h"
56 #include "BKE_modifier.h"
57 #include "BKE_multires.h"
58 #include "BKE_object.h"
59 #include "BKE_object_deform.h"
60 #include "BKE_ocean.h"
61 #include "BKE_paint.h"
62 #include "BKE_particle.h"
63 #include "BKE_pointcloud.h"
64 #include "BKE_report.h"
65 #include "BKE_scene.h"
66 #include "BKE_softbody.h"
67 #include "BKE_volume.h"
68 
69 #include "DEG_depsgraph.h"
70 #include "DEG_depsgraph_build.h"
71 #include "DEG_depsgraph_query.h"
72 
73 #include "BLT_translation.h"
74 
75 #include "RNA_access.h"
76 #include "RNA_define.h"
77 #include "RNA_enum_types.h"
78 #include "RNA_prototypes.h"
79 
80 #include "ED_armature.h"
81 #include "ED_mesh.h"
82 #include "ED_object.h"
83 #include "ED_screen.h"
84 #include "ED_sculpt.h"
85 
86 #include "MOD_nodes.h"
87 
88 #include "UI_interface.h"
89 
90 #include "WM_api.h"
91 #include "WM_types.h"
92 
93 #include "object_intern.h"
94 
95 static void modifier_skin_customdata_delete(struct Object *ob);
96 
97 /* ------------------------------------------------------------------- */
102 {
103  Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
104  Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
105  BKE_object_eval_reset(ob_eval);
106  if (ob->type == OB_MESH) {
107  Mesh *me_eval = mesh_create_eval_final(depsgraph, scene_eval, ob_eval, &CD_MASK_BAREMESH);
108  BKE_mesh_eval_delete(me_eval);
109  }
110  else if (ob->type == OB_LATTICE) {
111  BKE_lattice_modifiers_calc(depsgraph, scene_eval, ob_eval);
112  }
113  else if (ob->type == OB_MBALL) {
114  BKE_displist_make_mball(depsgraph, scene_eval, ob_eval);
115  }
116  else if (ELEM(ob->type, OB_CURVES_LEGACY, OB_SURF, OB_FONT)) {
117  BKE_displist_make_curveTypes(depsgraph, scene_eval, ob_eval, false);
118  }
119  else if (ob->type == OB_GPENCIL) {
120  BKE_gpencil_modifiers_calc(depsgraph, scene_eval, ob_eval);
121  }
122  else if (ob->type == OB_CURVES) {
123  BKE_curves_data_update(depsgraph, scene_eval, ob);
124  }
125  else if (ob->type == OB_POINTCLOUD) {
126  BKE_pointcloud_data_update(depsgraph, scene_eval, ob);
127  }
128  else if (ob->type == OB_VOLUME) {
129  BKE_volume_data_update(depsgraph, scene_eval, ob);
130  }
131 }
132 
134  Object *object,
135  ModifierData *md)
136 {
138  const int mode = md_eval->mode;
139  md_eval->mode |= eModifierMode_Realtime;
141  md_eval->mode = mode;
142 }
143 
145  ReportList *reports, Main *bmain, Scene *scene, Object *ob, const char *name, int type)
146 {
147  ModifierData *md = nullptr, *new_md = nullptr;
149 
150  /* Check compatibility of modifier [T25291, T50373]. */
152  BKE_reportf(reports, RPT_WARNING, "Modifiers cannot be added to object '%s'", ob->id.name + 2);
153  return nullptr;
154  }
155 
156  if (mti->flags & eModifierTypeFlag_Single) {
158  BKE_report(reports, RPT_WARNING, "Only one modifier of this type is allowed");
159  return nullptr;
160  }
161  }
162 
164  /* don't need to worry about the new modifier's name, since that is set to the number
165  * of particle systems which shouldn't have too many duplicates
166  */
167  new_md = object_add_particle_system(bmain, scene, ob, name);
168  }
169  else {
170  /* get new modifier data to add */
171  new_md = BKE_modifier_new(type);
172 
174  md = static_cast<ModifierData *>(ob->modifiers.first);
175 
176  while (md &&
178  md = md->next;
179  }
180 
181  BLI_insertlinkbefore(&ob->modifiers, md, new_md);
182  }
183  else {
184  BLI_addtail(&ob->modifiers, new_md);
185  }
186 
187  if (name) {
188  BLI_strncpy_utf8(new_md->name, name, sizeof(new_md->name));
189  }
190 
191  /* make sure modifier data has unique name */
192 
193  BKE_modifier_unique_name(&ob->modifiers, new_md);
194 
195  /* special cases */
196  if (type == eModifierType_Softbody) {
197  if (!ob->soft) {
198  ob->soft = sbNew();
200  }
201  }
202  else if (type == eModifierType_Collision) {
203  if (!ob->pd) {
204  ob->pd = BKE_partdeflect_new(0);
205  }
206 
207  ob->pd->deflect = 1;
208  }
209  else if (type == eModifierType_Surface) {
210  /* pass */
211  }
212  else if (type == eModifierType_Multires) {
213  /* set totlvl from existing MDISPS layer if object already had it */
215 
216  if (ob->mode & OB_MODE_SCULPT) {
217  /* ensure that grid paint mask layer is created */
219  }
220  }
221  else if (type == eModifierType_Skin) {
222  /* ensure skin-node customdata exists */
223  BKE_mesh_ensure_skin_customdata(static_cast<Mesh *>(ob->data));
224  }
225  }
226 
227  BKE_object_modifier_set_active(ob, new_md);
228 
231 
232  return new_md;
233 }
234 
235 /* Return true if the object has a modifier of type 'type' other than
236  * the modifier pointed to be 'exclude', otherwise returns false. */
237 static bool object_has_modifier(const Object *ob, const ModifierData *exclude, ModifierType type)
238 {
239  LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
240  if ((md != exclude) && (md->type == type)) {
241  return true;
242  }
243  }
244 
245  return false;
246 }
247 
249  Object *orig_ob,
250  const bool include_orig,
251  bool (*callback)(Object *ob, void *callback_data),
252  void *callback_data)
253 {
254  ID *ob_data_id = static_cast<ID *>(orig_ob->data);
255  int users = ob_data_id->us;
256 
257  if (ob_data_id->flag & LIB_FAKEUSER) {
258  users--;
259  }
260 
261  /* First check that the object's data has multiple users */
262  if (users > 1) {
263  Object *ob;
264  int totfound = include_orig ? 0 : 1;
265 
266  for (ob = static_cast<Object *>(bmain->objects.first); ob && totfound < users;
267  ob = reinterpret_cast<Object *>(ob->id.next)) {
268  if (((ob != orig_ob) || include_orig) && (ob->data == orig_ob->data)) {
269  if (callback(ob, callback_data)) {
270  return true;
271  }
272 
273  totfound++;
274  }
275  }
276  }
277  else if (include_orig) {
278  return callback(orig_ob, callback_data);
279  }
280 
281  return false;
282 }
283 
284 static bool object_has_modifier_cb(Object *ob, void *data)
285 {
287 
288  return object_has_modifier(ob, nullptr, type);
289 }
290 
292 {
293  int totlevel = *((char *)totlevel_v);
294 
295  LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
296  if (md->type == eModifierType_Multires) {
297  multires_set_tot_level(ob, (MultiresModifierData *)md, totlevel);
299  }
300  }
301  return false;
302 }
303 
304 /* Return true if no modifier of type 'type' other than 'exclude' */
306  Object *ob,
307  ModifierData *exclude,
309 {
310  return (!object_has_modifier(ob, exclude, type) &&
311  !ED_object_iter_other(bmain, ob, false, object_has_modifier_cb, &type));
312 }
313 
315  Main *bmain, Scene *scene, Object *ob, ModifierData *md, bool *r_sort_depsgraph)
316 {
317  /* It seems on rapid delete it is possible to
318  * get called twice on same modifier, so make
319  * sure it is in list. */
320  if (BLI_findindex(&ob->modifiers, md) == -1) {
321  return false;
322  }
323 
324  /* special cases */
325  if (md->type == eModifierType_ParticleSystem) {
327  return true;
328  }
329 
330  if (md->type == eModifierType_Softbody) {
331  if (ob->soft) {
332  sbFree(ob);
333  ob->softflag = 0; /* TODO(Sybren): this should probably be moved into sbFree() */
334  }
335  }
336  else if (md->type == eModifierType_Collision) {
337  if (ob->pd) {
338  ob->pd->deflect = 0;
339  }
340 
341  *r_sort_depsgraph = true;
342  }
343  else if (md->type == eModifierType_Surface) {
344  *r_sort_depsgraph = true;
345  }
346  else if (md->type == eModifierType_Multires) {
347  /* Delete MDisps layer if not used by another multires modifier */
349  multires_customdata_delete(static_cast<Mesh *>(ob->data));
350  }
351  }
352  else if (md->type == eModifierType_Skin) {
353  /* Delete MVertSkin layer if not used by another skin modifier */
356  }
357  }
358 
361  ob->mode &= ~OB_MODE_PARTICLE_EDIT;
362  }
363 
365  BKE_modifier_free(md);
367 
368  return true;
369 }
370 
372  ReportList *reports, Main *bmain, Scene *scene, Object *ob, ModifierData *md)
373 {
374  bool sort_depsgraph = false;
375 
376  bool ok = object_modifier_remove(bmain, scene, ob, md, &sort_depsgraph);
377 
378  if (!ok) {
379  BKE_reportf(reports, RPT_ERROR, "Modifier '%s' not in object '%s'", md->name, ob->id.name);
380  return false;
381  }
382 
385 
386  return true;
387 }
388 
390 {
391  ModifierData *md = static_cast<ModifierData *>(ob->modifiers.first);
392  bool sort_depsgraph = false;
393 
394  if (!md) {
395  return;
396  }
397 
398  while (md) {
399  ModifierData *next_md = md->next;
400 
401  object_modifier_remove(bmain, scene, ob, md, &sort_depsgraph);
402 
403  md = next_md;
404  }
405 
408 }
409 
411 {
412  if (md->prev) {
414 
415  if (mti->type != eModifierTypeType_OnlyDeform) {
417 
419  BKE_report(reports, RPT_WARNING, "Cannot move above a modifier requiring original data");
420  return false;
421  }
422  }
423 
424  BLI_listbase_swaplinks(&ob->modifiers, md, md->prev);
425  }
426  else {
427  BKE_report(reports, RPT_WARNING, "Cannot move modifier beyond the start of the list");
428  return false;
429  }
430 
431  return true;
432 }
433 
435 {
436  if (md->next) {
438 
441 
442  if (nmti->type != eModifierTypeType_OnlyDeform) {
443  BKE_report(reports, RPT_WARNING, "Cannot move beyond a non-deforming modifier");
444  return false;
445  }
446  }
447 
448  BLI_listbase_swaplinks(&ob->modifiers, md, md->next);
449  }
450  else {
451  BKE_report(reports, RPT_WARNING, "Cannot move modifier beyond the end of the list");
452  return false;
453  }
454 
455  return true;
456 }
457 
459  Object *ob,
460  ModifierData *md,
461  const int index)
462 {
463  BLI_assert(md != nullptr);
464  BLI_assert(index >= 0);
465  if (index >= BLI_listbase_count(&ob->modifiers)) {
466  BKE_report(reports, RPT_WARNING, "Cannot move modifier beyond the end of the stack");
467  return false;
468  }
469 
470  int md_index = BLI_findindex(&ob->modifiers, md);
471  BLI_assert(md_index != -1);
472  if (md_index < index) {
473  /* Move modifier down in list. */
474  for (; md_index < index; md_index++) {
475  if (!ED_object_modifier_move_down(reports, ob, md)) {
476  break;
477  }
478  }
479  }
480  else {
481  /* Move modifier up in list. */
482  for (; md_index > index; md_index--) {
483  if (!ED_object_modifier_move_up(reports, ob, md)) {
484  break;
485  }
486  }
487  }
488 
491 
492  return true;
493 }
494 
496 {
497  BKE_object_link_modifiers(ob_dst, ob_src);
500 
501  Main *bmain = CTX_data_main(C);
503 }
504 
506  Object *ob_dst,
507  Object *ob_src,
508  ModifierData *md)
509 {
510  BKE_object_copy_modifier(CTX_data_main(C), CTX_data_scene(C), ob_dst, ob_src, md);
513 
514  Main *bmain = CTX_data_main(C);
516 }
517 
519  Main *bmain,
521  ViewLayer *view_layer,
522  Object *ob,
523  ModifierData *md)
524 {
525  int cvert = 0;
526 
527  if (md->type != eModifierType_ParticleSystem) {
528  return false;
529  }
530  if (ob && ob->mode & OB_MODE_PARTICLE_EDIT) {
531  return false;
532  }
533 
534  ParticleSystem *psys_orig = ((ParticleSystemModifierData *)md)->psys;
535  ParticleSettings *part = psys_orig->part;
536 
537  if (part->ren_as != PART_DRAW_PATH) {
538  return false;
539  }
540  ParticleSystem *psys_eval = psys_eval_get(depsgraph, ob, psys_orig);
541  if (psys_eval->pathcache == nullptr) {
542  return false;
543  }
544 
545  int part_num = psys_eval->totcached;
546  int child_num = psys_eval->totchildcache;
547 
548  if (child_num && (part->draw & PART_DRAW_PARENT) == 0) {
549  part_num = 0;
550  }
551 
552  /* count */
553  int verts_num = 0, edges_num = 0;
554  ParticleCacheKey **cache = psys_eval->pathcache;
555  for (int a = 0; a < part_num; a++) {
556  ParticleCacheKey *key = cache[a];
557 
558  if (key->segments > 0) {
559  verts_num += key->segments + 1;
560  edges_num += key->segments;
561  }
562  }
563 
564  cache = psys_eval->childcache;
565  for (int a = 0; a < child_num; a++) {
566  ParticleCacheKey *key = cache[a];
567 
568  if (key->segments > 0) {
569  verts_num += key->segments + 1;
570  edges_num += key->segments;
571  }
572  }
573 
574  if (verts_num == 0) {
575  return false;
576  }
577 
578  /* add new mesh */
579  Object *obn = BKE_object_add(bmain, view_layer, OB_MESH, nullptr);
580  Mesh *me = static_cast<Mesh *>(obn->data);
581 
582  me->totvert = verts_num;
583  me->totedge = edges_num;
584 
585  me->mvert = (MVert *)CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, nullptr, verts_num);
586  me->medge = (MEdge *)CustomData_add_layer(&me->edata, CD_MEDGE, CD_CALLOC, nullptr, edges_num);
587  me->mface = (MFace *)CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, nullptr, 0);
588 
589  MVert *mvert = me->mvert;
590  MEdge *medge = me->medge;
591 
592  /* copy coordinates */
593  cache = psys_eval->pathcache;
594  for (int a = 0; a < part_num; a++) {
595  ParticleCacheKey *key = cache[a];
596  int kmax = key->segments;
597  for (int k = 0; k <= kmax; k++, key++, cvert++, mvert++) {
598  copy_v3_v3(mvert->co, key->co);
599  if (k) {
600  medge->v1 = cvert - 1;
601  medge->v2 = cvert;
603  medge++;
604  }
605  else {
606  /* cheap trick to select the roots */
607  mvert->flag |= SELECT;
608  }
609  }
610  }
611 
612  cache = psys_eval->childcache;
613  for (int a = 0; a < child_num; a++) {
614  ParticleCacheKey *key = cache[a];
615  int kmax = key->segments;
616  for (int k = 0; k <= kmax; k++, key++, cvert++, mvert++) {
617  copy_v3_v3(mvert->co, key->co);
618  if (k) {
619  medge->v1 = cvert - 1;
620  medge->v2 = cvert;
622  medge++;
623  }
624  else {
625  /* cheap trick to select the roots */
626  mvert->flag |= SELECT;
627  }
628  }
629  }
630 
632 
633  return true;
634 }
635 
636 /* Gets mesh for the modifier which corresponds to an evaluated state. */
638  Object *object,
639  ModifierData *md_eval,
640  bool use_virtual_modifiers,
641  bool build_shapekey_layers)
642 {
643  Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
644  Object *object_eval = DEG_get_evaluated_object(depsgraph, object);
646  depsgraph, scene_eval, object_eval, md_eval, use_virtual_modifiers, build_shapekey_layers);
647  return mesh_applied;
648 }
649 
650 static bool modifier_apply_shape(Main *bmain,
651  ReportList *reports,
653  Scene *scene,
654  Object *ob,
655  ModifierData *md_eval)
656 {
658 
659  if (mti->isDisabled && mti->isDisabled(scene, md_eval, false)) {
660  BKE_report(reports, RPT_ERROR, "Modifier is disabled, skipping apply");
661  return false;
662  }
663 
664  /* We could investigate using the #CD_ORIGINDEX layer
665  * to support other kinds of modifiers besides deforming modifiers.
666  * as this is done in many other places, see: #BKE_mesh_foreach_mapped_vert_coords_get.
667  *
668  * This isn't high priority in practice since most modifiers users
669  * want to apply as a shape are deforming modifiers.
670  *
671  * If a compelling use-case comes up where we want to support other kinds of modifiers
672  * we can look into supporting them. */
673 
674  if (ob->type == OB_MESH) {
675  Mesh *me = static_cast<Mesh *>(ob->data);
676  Key *key = me->key;
677 
679  BKE_report(reports, RPT_ERROR, "Only deforming modifiers can be applied to shapes");
680  return false;
681  }
682 
684  depsgraph, ob, md_eval, true, false);
685  if (!mesh_applied) {
686  BKE_report(reports, RPT_ERROR, "Modifier is disabled or returned error, skipping apply");
687  return false;
688  }
689 
690  if (key == nullptr) {
691  key = me->key = BKE_key_add(bmain, (ID *)me);
692  key->type = KEY_RELATIVE;
693  /* if that was the first key block added, then it was the basis.
694  * Initialize it with the mesh, and add another for the modifier */
695  KeyBlock *kb = BKE_keyblock_add(key, nullptr);
696  BKE_keyblock_convert_from_mesh(me, key, kb);
697  }
698 
699  KeyBlock *kb = BKE_keyblock_add(key, md_eval->name);
700  BKE_mesh_nomain_to_meshkey(mesh_applied, me, kb);
701 
702  BKE_id_free(nullptr, mesh_applied);
703  }
704  else {
705  BKE_report(reports, RPT_ERROR, "Cannot apply modifier for this object type");
706  return false;
707  }
708  return true;
709 }
710 
712  ReportList *reports, Depsgraph *depsgraph, Scene *scene, Object *ob, ModifierData *md_eval)
713 {
715 
716  if (mti->isDisabled && mti->isDisabled(scene, md_eval, false)) {
717  BKE_report(reports, RPT_ERROR, "Modifier is disabled, skipping apply");
718  return false;
719  }
720 
721  if (ob->type == OB_MESH) {
722  Mesh *me = static_cast<Mesh *>(ob->data);
724 
725  if (me->key && mti->type != eModifierTypeType_NonGeometrical) {
726  BKE_report(reports, RPT_ERROR, "Modifier cannot be applied to a mesh with shape keys");
727  return false;
728  }
729 
730  /* Multires: ensure that recent sculpting is applied */
731  if (md_eval->type == eModifierType_Multires) {
733  }
734 
735  if (mmd && mmd->totlvl && mti->type == eModifierTypeType_OnlyDeform) {
736  if (!multiresModifier_reshapeFromDeformModifier(depsgraph, ob, mmd, md_eval)) {
737  BKE_report(reports, RPT_ERROR, "Multires modifier returned error, skipping apply");
738  return false;
739  }
740  }
741  else {
743  depsgraph,
744  ob,
745  md_eval,
746  /* It's important not to apply virtual modifiers (e.g. shape-keys) because they're kept,
747  * causing them to be applied twice, see: T97758. */
748  false,
749  true);
750  if (!mesh_applied) {
751  BKE_report(reports, RPT_ERROR, "Modifier returned error, skipping apply");
752  return false;
753  }
754 
755  Main *bmain = DEG_get_bmain(depsgraph);
756  BKE_object_material_from_eval_data(bmain, ob, &mesh_applied->id);
757  BKE_mesh_nomain_to_mesh(mesh_applied, me, ob, &CD_MASK_MESH, true);
758 
759  /* Anonymous attributes shouldn't be available on the applied geometry. */
761 
762  if (md_eval->type == eModifierType_Multires) {
764  }
765  }
766  }
767  else if (ELEM(ob->type, OB_CURVES_LEGACY, OB_SURF)) {
768  Object *object_eval = DEG_get_evaluated_object(depsgraph, ob);
769  Curve *curve = static_cast<Curve *>(ob->data);
770  Curve *curve_eval = static_cast<Curve *>(object_eval->data);
771  ModifierEvalContext mectx = {depsgraph, object_eval, (ModifierApplyFlag)0};
772 
774  BKE_report(
775  reports, RPT_ERROR, "Transform curve to mesh in order to apply constructive modifiers");
776  return false;
777  }
778 
779  BKE_report(reports,
780  RPT_INFO,
781  "Applied modifier only changed CV points, not tessellated/bevel vertices");
782 
783  int verts_num;
784  float(*vertexCos)[3] = BKE_curve_nurbs_vert_coords_alloc(&curve_eval->nurb, &verts_num);
785  mti->deformVerts(md_eval, &mectx, nullptr, vertexCos, verts_num);
786  BKE_curve_nurbs_vert_coords_apply(&curve->nurb, vertexCos, false);
787 
788  MEM_freeN(vertexCos);
789 
791  }
792  else if (ob->type == OB_LATTICE) {
793  Object *object_eval = DEG_get_evaluated_object(depsgraph, ob);
794  Lattice *lattice = static_cast<Lattice *>(ob->data);
795  ModifierEvalContext mectx = {depsgraph, object_eval, (ModifierApplyFlag)0};
796 
798  BKE_report(reports, RPT_ERROR, "Constructive modifiers cannot be applied");
799  return false;
800  }
801 
802  int verts_num;
803  float(*vertexCos)[3] = BKE_lattice_vert_coords_alloc(lattice, &verts_num);
804  mti->deformVerts(md_eval, &mectx, nullptr, vertexCos, verts_num);
806 
807  MEM_freeN(vertexCos);
808 
810  }
811  else if (ob->type == OB_CURVES) {
812  Curves &curves = *static_cast<Curves *>(ob->data);
813  if (mti->modifyGeometrySet == nullptr) {
815  return false;
816  }
817 
818  /* Create a temporary geometry set and component. */
819  GeometrySet geometry_set;
820  geometry_set.get_component_for_write<CurveComponent>().replace(
822 
824  mti->modifyGeometrySet(md_eval, &mectx, &geometry_set);
825  if (!geometry_set.has_curves()) {
826  BKE_report(reports, RPT_ERROR, "Evaluated geometry from modifier does not contain curves");
827  return false;
828  }
829  Curves &curves_eval = *geometry_set.get_curves_for_write();
830 
831  /* Anonymous attributes shouldn't be available on the applied geometry. */
834  .remove_anonymous();
835 
836  /* Copy the relevant information to the original. */
837  blender::bke::CurvesGeometry::wrap(curves.geometry) = std::move(
839  Main *bmain = DEG_get_bmain(depsgraph);
840  BKE_object_material_from_eval_data(bmain, ob, &curves_eval.id);
841  }
842  else {
843  /* TODO: implement for point clouds and volumes. */
844  BKE_report(reports, RPT_ERROR, "Cannot apply modifier for this object type");
845  return false;
846  }
847 
848  /* lattice modifier can be applied to particle system too */
849  if (ob->particlesystem.first) {
851  if (psys->part->type != PART_HAIR) {
852  continue;
853  }
854 
856  }
857  }
858 
859  return true;
860 }
861 
863  ReportList *reports,
865  Scene *scene,
866  Object *ob,
867  ModifierData *md,
868  int mode,
869  bool keep_modifier)
870 {
871  if (BKE_object_is_in_editmode(ob)) {
872  BKE_report(reports, RPT_ERROR, "Modifiers cannot be applied in edit mode");
873  return false;
874  }
875  if (mode != MODIFIER_APPLY_SHAPE && ID_REAL_USERS(ob->data) > 1) {
876  BKE_report(reports, RPT_ERROR, "Modifiers cannot be applied to multi-user data");
877  return false;
878  }
879  if ((ob->mode & OB_MODE_SCULPT) && (find_multires_modifier_before(scene, md)) &&
880  (BKE_modifier_is_same_topology(md) == false)) {
881  BKE_report(reports,
882  RPT_ERROR,
883  "Constructive modifier cannot be applied to multi-res data in sculpt mode");
884  return false;
885  }
886 
887  if (md != ob->modifiers.first) {
888  BKE_report(reports, RPT_INFO, "Applied modifier was not first, result may not be as expected");
889  }
890 
891  /* Get evaluated modifier, so object links pointer to evaluated data,
892  * but still use original object it is applied to the original mesh. */
893  Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
894  ModifierData *md_eval = (ob_eval) ? BKE_modifiers_findby_name(ob_eval, md->name) : md;
895 
896  /* Allow apply of a non-real-time modifier, by first re-enabling real-time. */
897  int prev_mode = md_eval->mode;
898  md_eval->mode |= eModifierMode_Realtime;
899 
900  if (mode == MODIFIER_APPLY_SHAPE) {
901  if (!modifier_apply_shape(bmain, reports, depsgraph, scene, ob, md_eval)) {
902  md_eval->mode = prev_mode;
903  return false;
904  }
905  }
906  else {
907  if (!modifier_apply_obdata(reports, depsgraph, scene, ob, md_eval)) {
908  md_eval->mode = prev_mode;
909  return false;
910  }
911  }
912 
913  md_eval->mode = prev_mode;
914 
915  if (!keep_modifier) {
917  BKE_modifier_free(md);
918  }
919 
921 
922  return true;
923 }
924 
926  ReportList *UNUSED(reports), Main *bmain, Scene *scene, Object *ob, ModifierData *md)
927 {
928  if (md->type == eModifierType_ParticleSystem) {
930  bmain, scene, ob, ((ParticleSystemModifierData *)md)->psys);
931  BLI_remlink(&ob->modifiers, nmd);
932  BLI_insertlinkafter(&ob->modifiers, md, nmd);
934  return true;
935  }
936 
937  ModifierData *nmd = BKE_modifier_new(md->type);
938  BKE_modifier_copydata(md, nmd);
939  BLI_insertlinkafter(&ob->modifiers, md, nmd);
942 
944 
945  return true;
946 }
947 
950 /* ------------------------------------------------------------------- */
955 {
956  Main *bmain = CTX_data_main(C);
959  int type = RNA_enum_get(op->ptr, "type");
960 
961  if (!ED_object_modifier_add(op->reports, bmain, scene, ob, nullptr, type)) {
962  return OPERATOR_CANCELLED;
963  }
964 
966 
967  return OPERATOR_FINISHED;
968 }
969 
972  PropertyRNA *UNUSED(prop),
973  bool *r_free)
974 {
976 
977  if (!ob) {
979  }
980 
981  EnumPropertyItem *items = nullptr;
982  int totitem = 0;
983 
984  const EnumPropertyItem *group_item = nullptr;
985  for (int a = 0; rna_enum_object_modifier_type_items[a].identifier; a++) {
987 
988  if (md_item->identifier[0]) {
990 
991  if (mti->flags & eModifierTypeFlag_NoUserAdd) {
992  continue;
993  }
994 
995  if (!BKE_object_support_modifier_type_check(ob, md_item->value)) {
996  continue;
997  }
998  }
999  else {
1000  group_item = md_item;
1001  continue;
1002  }
1003 
1004  if (group_item) {
1005  RNA_enum_item_add(&items, &totitem, group_item);
1006  group_item = nullptr;
1007  }
1008 
1009  RNA_enum_item_add(&items, &totitem, md_item);
1010  }
1011 
1012  RNA_enum_item_end(&items, &totitem);
1013  *r_free = true;
1014 
1015  return items;
1016 }
1017 
1019 {
1020  PropertyRNA *prop;
1021 
1022  /* identifiers */
1023  ot->name = "Add Modifier";
1024  ot->description = "Add a procedural operation/effect to the active object";
1025  ot->idname = "OBJECT_OT_modifier_add";
1026 
1027  /* api callbacks */
1031 
1032  /* flags */
1034 
1035  /* properties */
1036  prop = RNA_def_enum(
1039  ot->prop = prop;
1040 }
1041 
1044 /* ------------------------------------------------------------------- */
1051  StructRNA *rna_type,
1052  int obtype_flag,
1053  const bool is_editmode_allowed,
1054  const bool is_liboverride_allowed)
1055 {
1056  Main *bmain = CTX_data_main(C);
1057  PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", rna_type);
1059  ModifierData *mod = static_cast<ModifierData *>(ptr.data); /* May be nullptr. */
1060 
1061  if (mod == nullptr && ob != nullptr) {
1063  }
1064 
1065  if (!ob || !BKE_id_is_editable(bmain, &ob->id)) {
1066  return false;
1067  }
1068  if (obtype_flag && ((1 << ob->type) & obtype_flag) == 0) {
1069  return false;
1070  }
1071  if (ptr.owner_id && !BKE_id_is_editable(bmain, ptr.owner_id)) {
1072  return false;
1073  }
1074 
1077  C, "Cannot edit modifiers coming from linked data in a library override");
1078  return false;
1079  }
1080 
1081  if (!is_editmode_allowed && CTX_data_edit_object(C) != nullptr) {
1082  CTX_wm_operator_poll_msg_set(C, "This modifier operation is not allowed from Edit mode");
1083  return false;
1084  }
1085 
1086  return true;
1087 }
1088 
1090 {
1091  return edit_modifier_poll_generic(C, &RNA_Modifier, 0, true, false);
1092 }
1093 
1094 /* Used by operators performing actions allowed also on modifiers from the overridden linked object
1095  * (not only from added 'local' ones). */
1097 {
1098  return edit_modifier_poll_generic(C, &RNA_Modifier, 0, true, true);
1099 }
1100 
1102 {
1103  PropertyRNA *prop = RNA_def_string(
1104  ot->srna, "modifier", nullptr, MAX_NAME, "Modifier", "Name of the modifier to edit");
1106 }
1107 
1109 {
1110  PropertyRNA *prop = RNA_def_boolean(
1111  ot->srna, "report", false, "Report", "Create a notification after the operation");
1113 }
1114 
1117 /* ------------------------------------------------------------------- */
1124 {
1125  if (RNA_struct_property_is_set(op->ptr, "modifier")) {
1126  return true;
1127  }
1128 
1129  PointerRNA ctx_ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier);
1130  if (ctx_ptr.data != nullptr) {
1131  ModifierData *md = static_cast<ModifierData *>(ctx_ptr.data);
1132  RNA_string_set(op->ptr, "modifier", md->name);
1133  return true;
1134  }
1135 
1136  return false;
1137 }
1138 
1145  wmOperator *op,
1146  const wmEvent *event,
1147  int *r_retval)
1148 {
1149  if (RNA_struct_property_is_set(op->ptr, "modifier")) {
1150  return true;
1151  }
1152 
1153  /* Note that the context pointer is *not* the active modifier, it is set in UI layouts. */
1154  PointerRNA ctx_ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier);
1155  if (ctx_ptr.data != nullptr) {
1156  ModifierData *md = static_cast<ModifierData *>(ctx_ptr.data);
1157  RNA_string_set(op->ptr, "modifier", md->name);
1158  return true;
1159  }
1160 
1162  if (panel_ptr == nullptr || RNA_pointer_is_null(panel_ptr)) {
1163  *r_retval = OPERATOR_CANCELLED;
1164  return false;
1165  }
1166 
1167  if (!RNA_struct_is_a(panel_ptr->type, &RNA_Modifier)) {
1168  /* Work around multiple operators using the same shortcut. The operators for the other
1169  * stacks in the property editor use the same key, and will not run after these return
1170  * OPERATOR_CANCELLED. */
1171  *r_retval = (OPERATOR_PASS_THROUGH | OPERATOR_CANCELLED);
1172  return false;
1173  }
1174 
1175  const ModifierData *md = static_cast<const ModifierData *>(panel_ptr->data);
1176  RNA_string_set(op->ptr, "modifier", md->name);
1177  return true;
1178 }
1179 
1181 {
1182  char modifier_name[MAX_NAME];
1183  RNA_string_get(op->ptr, "modifier", modifier_name);
1184 
1186 
1187  if (md && type != 0 && md->type != type) {
1188  md = nullptr;
1189  }
1190 
1191  return md;
1192 }
1193 
1196 /* ------------------------------------------------------------------- */
1201 {
1202  Main *bmain = CTX_data_main(C);
1204  ViewLayer *view_layer = CTX_data_view_layer(C);
1206  ModifierData *md = edit_modifier_property_get(op, ob, 0);
1207  int mode_orig = ob->mode;
1208 
1209  if (md == nullptr) {
1210  return OPERATOR_CANCELLED;
1211  }
1212 
1213  /* Store name temporarily for report. */
1214  char name[MAX_NAME];
1215  strcpy(name, md->name);
1216 
1217  if (!ED_object_modifier_remove(op->reports, bmain, scene, ob, md)) {
1218  return OPERATOR_CANCELLED;
1219  }
1220 
1222 
1223  /* if cloth/softbody was removed, particle mode could be cleared */
1224  if (mode_orig & OB_MODE_PARTICLE_EDIT) {
1225  if ((ob->mode & OB_MODE_PARTICLE_EDIT) == 0) {
1226  if (ob == OBACT(view_layer)) {
1228  }
1229  }
1230  }
1231 
1232  if (RNA_boolean_get(op->ptr, "report")) {
1233  BKE_reportf(op->reports, RPT_INFO, "Removed modifier: %s", name);
1234  }
1235 
1236  return OPERATOR_FINISHED;
1237 }
1238 
1239 static int modifier_remove_invoke(bContext *C, wmOperator *op, const wmEvent *event)
1240 {
1241  int retval;
1242  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
1243  return modifier_remove_exec(C, op);
1244  }
1245  return retval;
1246 }
1247 
1249 {
1250  ot->name = "Remove Modifier";
1251  ot->description = "Remove a modifier from the active object";
1252  ot->idname = "OBJECT_OT_modifier_remove";
1253 
1257 
1258  /* flags */
1262 }
1263 
1266 /* ------------------------------------------------------------------- */
1271 {
1273  ModifierData *md = edit_modifier_property_get(op, ob, 0);
1274 
1275  if (!md || !ED_object_modifier_move_up(op->reports, ob, md)) {
1276  return OPERATOR_CANCELLED;
1277  }
1278 
1281 
1282  return OPERATOR_FINISHED;
1283 }
1284 
1285 static int modifier_move_up_invoke(bContext *C, wmOperator *op, const wmEvent *event)
1286 {
1287  int retval;
1288  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
1289  return modifier_move_up_exec(C, op);
1290  }
1291  return retval;
1292 }
1293 
1295 {
1296  ot->name = "Move Up Modifier";
1297  ot->description = "Move modifier up in the stack";
1298  ot->idname = "OBJECT_OT_modifier_move_up";
1299 
1303 
1304  /* flags */
1307 }
1308 
1311 /* ------------------------------------------------------------------- */
1316 {
1318  ModifierData *md = edit_modifier_property_get(op, ob, 0);
1319 
1320  if (!md || !ED_object_modifier_move_down(op->reports, ob, md)) {
1321  return OPERATOR_CANCELLED;
1322  }
1323 
1326 
1327  return OPERATOR_FINISHED;
1328 }
1329 
1330 static int modifier_move_down_invoke(bContext *C, wmOperator *op, const wmEvent *event)
1331 {
1332  int retval;
1333  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
1334  return modifier_move_down_exec(C, op);
1335  }
1336  return retval;
1337 }
1338 
1340 {
1341  ot->name = "Move Down Modifier";
1342  ot->description = "Move modifier down in the stack";
1343  ot->idname = "OBJECT_OT_modifier_move_down";
1344 
1348 
1349  /* flags */
1352 }
1353 
1356 /* ------------------------------------------------------------------- */
1361 {
1363  ModifierData *md = edit_modifier_property_get(op, ob, 0);
1364  int index = RNA_int_get(op->ptr, "index");
1365 
1366  if (!(md && ED_object_modifier_move_to_index(op->reports, ob, md, index))) {
1367  return OPERATOR_CANCELLED;
1368  }
1369 
1370  return OPERATOR_FINISHED;
1371 }
1372 
1374 {
1375  int retval;
1376  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
1377  return modifier_move_to_index_exec(C, op);
1378  }
1379  return retval;
1380 }
1381 
1383 {
1384  ot->name = "Move Active Modifier to Index";
1385  ot->description =
1386  "Change the modifier's index in the stack so it evaluates after the set number of others";
1387  ot->idname = "OBJECT_OT_modifier_move_to_index";
1388 
1392 
1393  /* flags */
1396  RNA_def_int(
1397  ot->srna, "index", 0, 0, INT_MAX, "Index", "The index to move the modifier to", 0, INT_MAX);
1398 }
1399 
1402 /* ------------------------------------------------------------------- */
1407 {
1408  if (!edit_modifier_poll_generic(C, &RNA_Modifier, 0, false, false)) {
1409  return false;
1410  }
1411 
1413  PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier);
1414  Object *ob = (ptr.owner_id != nullptr) ? (Object *)ptr.owner_id : ED_object_active_context(C);
1415  ModifierData *md = static_cast<ModifierData *>(ptr.data); /* May be nullptr. */
1416 
1417  if (ID_IS_OVERRIDE_LIBRARY(ob) || ((ob->data != nullptr) && ID_IS_OVERRIDE_LIBRARY(ob->data))) {
1418  CTX_wm_operator_poll_msg_set(C, "Modifiers cannot be applied on override data");
1419  return false;
1420  }
1421  if (md != nullptr) {
1422  if ((ob->mode & OB_MODE_SCULPT) && (find_multires_modifier_before(scene, md)) &&
1423  (BKE_modifier_is_same_topology(md) == false)) {
1425  C, "Constructive modifier cannot be applied to multi-res data in sculpt mode");
1426  return false;
1427  }
1428  }
1429  return true;
1430 }
1431 
1432 static int modifier_apply_exec_ex(bContext *C, wmOperator *op, int apply_as, bool keep_modifier)
1433 {
1434  Main *bmain = CTX_data_main(C);
1438  ModifierData *md = edit_modifier_property_get(op, ob, 0);
1439  const bool do_report = RNA_boolean_get(op->ptr, "report");
1440  const bool do_single_user = RNA_boolean_get(op->ptr, "single_user");
1441  const bool do_merge_customdata = RNA_boolean_get(op->ptr, "merge_customdata");
1442 
1443  if (md == nullptr) {
1444  return OPERATOR_CANCELLED;
1445  }
1446 
1448 
1449  if (do_single_user && ID_REAL_USERS(ob->data) > 1) {
1450  ED_object_single_obdata_user(bmain, scene, ob);
1452  WM_event_add_notifier(C, NC_WINDOW, nullptr);
1453  DEG_relations_tag_update(bmain);
1454  }
1455 
1456  int reports_len;
1457  char name[MAX_NAME];
1458  if (do_report) {
1459  reports_len = BLI_listbase_count(&op->reports->list);
1460  strcpy(name, md->name); /* Store name temporarily since the modifier is removed. */
1461  }
1462 
1464  bmain, op->reports, depsgraph, scene, ob, md, apply_as, keep_modifier)) {
1465  return OPERATOR_CANCELLED;
1466  }
1467 
1468  if (ob->type == OB_MESH && do_merge_customdata &&
1471  }
1472 
1474  DEG_relations_tag_update(bmain);
1476 
1477  if (do_report) {
1478  /* Only add this report if the operator didn't cause another one. The purpose here is
1479  * to alert that something happened, and the previous report will do that anyway. */
1480  if (BLI_listbase_count(&op->reports->list) == reports_len) {
1481  BKE_reportf(op->reports, RPT_INFO, "Applied modifier: %s", name);
1482  }
1483  }
1484 
1485  return OPERATOR_FINISHED;
1486 }
1487 
1489 {
1490  return modifier_apply_exec_ex(C, op, MODIFIER_APPLY_DATA, false);
1491 }
1492 
1493 static int modifier_apply_invoke(bContext *C, wmOperator *op, const wmEvent *event)
1494 {
1495  int retval;
1496  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
1497  PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier);
1498  Object *ob = (ptr.owner_id != nullptr) ? (Object *)ptr.owner_id : ED_object_active_context(C);
1499 
1500  if ((ob->data != nullptr) && ID_REAL_USERS(ob->data) > 1) {
1501  PropertyRNA *prop = RNA_struct_find_property(op->ptr, "single_user");
1502  if (!RNA_property_is_set(op->ptr, prop)) {
1503  RNA_property_boolean_set(op->ptr, prop, true);
1504  }
1505  if (RNA_property_boolean_get(op->ptr, prop)) {
1507  C, op, "Make object data single-user and apply modifier");
1508  }
1509  }
1510  return modifier_apply_exec(C, op);
1511  }
1512  return retval;
1513 }
1514 
1516 {
1517  ot->name = "Apply Modifier";
1518  ot->description = "Apply modifier and remove from the stack";
1519  ot->idname = "OBJECT_OT_modifier_apply";
1520 
1524 
1525  /* flags */
1527 
1530 
1532  "merge_customdata",
1533  true,
1534  "Merge UV's",
1535  "For mesh objects, merge UV coordinates that share a vertex to account for "
1536  "imprecision in some modifiers");
1538  "single_user",
1539  false,
1540  "Make Data Single User",
1541  "Make the object's data single user if needed");
1543 }
1544 
1547 /* ------------------------------------------------------------------- */
1552 {
1553  return modifier_apply_poll(C);
1554 }
1555 
1557 {
1558  bool keep = RNA_boolean_get(op->ptr, "keep_modifier");
1559 
1560  return modifier_apply_exec_ex(C, op, MODIFIER_APPLY_SHAPE, keep);
1561 }
1562 
1564 {
1565  int retval;
1566  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
1567  return modifier_apply_as_shapekey_exec(C, op);
1568  }
1569  return retval;
1570 }
1571 
1573  struct wmOperatorType *UNUSED(op),
1574  struct PointerRNA *values)
1575 {
1576  bool keep = RNA_boolean_get(values, "keep_modifier");
1577 
1578  if (keep) {
1579  return BLI_strdup(TIP_("Apply modifier as a new shapekey and keep it in the stack"));
1580  }
1581 
1582  return nullptr;
1583 }
1584 
1586 {
1587  ot->name = "Apply Modifier as Shape Key";
1588  ot->description = "Apply modifier as a new shape key and remove from the stack";
1589  ot->idname = "OBJECT_OT_modifier_apply_as_shapekey";
1590 
1595 
1596  /* flags */
1598 
1600  ot->srna, "keep_modifier", false, "Keep Modifier", "Do not remove the modifier from stack");
1603 }
1604 
1607 /* ------------------------------------------------------------------- */
1612 {
1613  Main *bmain = CTX_data_main(C);
1615  ViewLayer *view_layer = CTX_data_view_layer(C);
1617  ModifierData *md = edit_modifier_property_get(op, ob, 0);
1618 
1620  op->reports, bmain, depsgraph, view_layer, ob, md)) {
1621  return OPERATOR_CANCELLED;
1622  }
1623 
1626 
1627  return OPERATOR_FINISHED;
1628 }
1629 
1630 static int modifier_convert_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
1631 {
1633  return modifier_convert_exec(C, op);
1634  }
1635  return OPERATOR_CANCELLED;
1636 }
1637 
1639 {
1640  ot->name = "Convert Particles to Mesh";
1641  ot->description = "Convert particles to a mesh object";
1642  ot->idname = "OBJECT_OT_modifier_convert";
1643 
1647 
1648  /* flags */
1651 }
1652 
1655 /* ------------------------------------------------------------------- */
1660 {
1661  Main *bmain = CTX_data_main(C);
1664  ModifierData *md = edit_modifier_property_get(op, ob, 0);
1665 
1666  if (!md || !ED_object_modifier_copy(op->reports, bmain, scene, ob, md)) {
1667  return OPERATOR_CANCELLED;
1668  }
1669 
1672 
1673  return OPERATOR_FINISHED;
1674 }
1675 
1676 static int modifier_copy_invoke(bContext *C, wmOperator *op, const wmEvent *event)
1677 {
1678  int retval;
1679  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
1680  return modifier_copy_exec(C, op);
1681  }
1682  return retval;
1683 }
1684 
1686 {
1687  ot->name = "Copy Modifier";
1688  ot->description = "Duplicate modifier at the same position in the stack";
1689  ot->idname = "OBJECT_OT_modifier_copy";
1690 
1694 
1695  /* flags */
1698 }
1699 
1702 /* ------------------------------------------------------------------- */
1707 {
1709  ModifierData *md = edit_modifier_property_get(op, ob, 0);
1710 
1711  /* If there is no modifier set for this operator, clear the active modifier field. */
1713 
1715 
1716  return OPERATOR_FINISHED;
1717 }
1718 
1719 static int modifier_set_active_invoke(bContext *C, wmOperator *op, const wmEvent *event)
1720 {
1721  int retval;
1722  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
1723  return modifier_set_active_exec(C, op);
1724  }
1725  return retval;
1726 }
1727 
1729 {
1730  ot->name = "Set Active Modifier";
1731  ot->description = "Activate the modifier to use as the context";
1732  ot->idname = "OBJECT_OT_modifier_set_active";
1733 
1737 
1738  /* flags */
1741 }
1742 
1745 /* ------------------------------------------------------------------- */
1750 {
1751  Main *bmain = CTX_data_main(C);
1753  Object *obact = ED_object_active_context(C);
1754  ModifierData *md = edit_modifier_property_get(op, obact, 0);
1755 
1756  if (!md) {
1757  return OPERATOR_CANCELLED;
1758  }
1759 
1760  int num_copied = 0;
1762 
1763  CTX_DATA_BEGIN (C, Object *, ob, selected_objects) {
1764  if (ob == obact) {
1765  continue;
1766  }
1767 
1768  /* Checked in #BKE_object_copy_modifier, but check here too so we can give a better message. */
1770  BKE_reportf(op->reports,
1771  RPT_WARNING,
1772  "Object '%s' does not support %s modifiers",
1773  ob->id.name + 2,
1774  mti->name);
1775  continue;
1776  }
1777 
1778  if (mti->flags & eModifierTypeFlag_Single) {
1780  BKE_reportf(op->reports,
1781  RPT_WARNING,
1782  "Modifier can only be added once to object '%s'",
1783  ob->id.name + 2);
1784  continue;
1785  }
1786  }
1787 
1788  if (!BKE_object_copy_modifier(bmain, scene, ob, obact, md)) {
1789  BKE_reportf(op->reports,
1790  RPT_ERROR,
1791  "Copying modifier '%s' to object '%s' failed",
1792  md->name,
1793  ob->id.name + 2);
1794  }
1795 
1796  num_copied++;
1799  }
1800  CTX_DATA_END;
1801 
1802  if (num_copied > 0) {
1803  DEG_relations_tag_update(bmain);
1804  }
1805  else {
1806  BKE_reportf(op->reports, RPT_ERROR, "Modifier '%s' was not copied to any objects", md->name);
1807  return OPERATOR_CANCELLED;
1808  }
1809 
1810  return OPERATOR_FINISHED;
1811 }
1812 
1814 {
1815  int retval;
1816  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
1817  return modifier_copy_to_selected_exec(C, op);
1818  }
1819  return retval;
1820 }
1821 
1823 {
1824  PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier);
1826  ModifierData *md = static_cast<ModifierData *>(ptr.data);
1827 
1828  /* This just mirrors the check in #BKE_object_copy_modifier,
1829  * but there is no reasoning for it there. */
1831  CTX_wm_operator_poll_msg_set(C, R"(Not supported for "Collision" or "Hook" modifiers)");
1832  return false;
1833  }
1834 
1835  if (!obact) {
1836  CTX_wm_operator_poll_msg_set(C, "No selected object is active");
1837  return false;
1838  }
1839 
1840  if (!BKE_object_supports_modifiers(obact)) {
1841  CTX_wm_operator_poll_msg_set(C, "Object type of source object is not supported");
1842  return false;
1843  }
1844 
1845  /* This could have a performance impact in the worst case, where there are many objects selected
1846  * and none of them pass either of the checks. But that should be uncommon, and this operator is
1847  * only exposed in a drop-down menu anyway. */
1848  bool found_supported_objects = false;
1849  CTX_DATA_BEGIN (C, Object *, ob, selected_objects) {
1850  if (ob == obact) {
1851  continue;
1852  }
1853 
1854  if (!md && BKE_object_supports_modifiers(ob)) {
1855  /* Skip type check if modifier could not be found ("modifier" context variable not set). */
1856  found_supported_objects = true;
1857  break;
1858  }
1860  found_supported_objects = true;
1861  break;
1862  }
1863  }
1864  CTX_DATA_END;
1865 
1866  if (!found_supported_objects) {
1867  CTX_wm_operator_poll_msg_set(C, "No supported objects were selected");
1868  return false;
1869  }
1870  return true;
1871 }
1872 
1874 {
1875  ot->name = "Copy Modifier to Selected";
1876  ot->description = "Copy the modifier from the active object to all selected objects";
1877  ot->idname = "OBJECT_OT_modifier_copy_to_selected";
1878 
1882 
1883  /* flags */
1886 }
1887 
1890 /* ------------------------------------------------------------------- */
1894 static bool multires_poll(bContext *C)
1895 {
1896  return edit_modifier_poll_generic(C, &RNA_MultiresModifier, (1 << OB_MESH), true, false);
1897 }
1898 
1900 {
1904  op, ob, eModifierType_Multires);
1905 
1906  if (!mmd) {
1907  return OPERATOR_CANCELLED;
1908  }
1909 
1910  multiresModifier_del_levels(mmd, scene, ob, 1);
1911 
1914 
1916 
1917  return OPERATOR_FINISHED;
1918 }
1919 
1921  wmOperator *op,
1922  const wmEvent *UNUSED(event))
1923 {
1926  }
1927  return OPERATOR_CANCELLED;
1928 }
1929 
1931 {
1932  ot->name = "Delete Higher Levels";
1933  ot->description = "Deletes the higher resolution mesh, potential loss of detail";
1934  ot->idname = "OBJECT_OT_multires_higher_levels_delete";
1935 
1936  ot->poll = multires_poll;
1939 
1940  /* flags */
1943 }
1944 
1947 /* ------------------------------------------------------------------- */
1953  "CATMULL_CLARK",
1954  0,
1955  "Catmull-Clark",
1956  "Create a new level using Catmull-Clark subdivisions"},
1958  "SIMPLE",
1959  0,
1960  "Simple",
1961  "Create a new level using simple subdivisions"},
1963  "LINEAR",
1964  0,
1965  "Linear",
1966  "Create a new level using linear interpolation of the sculpted displacement"},
1967  {0, nullptr, 0, nullptr, nullptr},
1968 };
1969 
1971 {
1972  Object *object = ED_object_active_context(C);
1974  op, object, eModifierType_Multires);
1975 
1976  if (!mmd) {
1977  return OPERATOR_CANCELLED;
1978  }
1979 
1981  op->ptr, "mode"));
1982  multiresModifier_subdivide(object, mmd, subdivide_mode);
1983 
1986 
1989 
1990  if (object->mode & OB_MODE_SCULPT) {
1991  /* ensure that grid paint mask layer is created */
1992  BKE_sculpt_mask_layers_ensure(object, mmd);
1993  }
1994 
1995  return OPERATOR_FINISHED;
1996 }
1997 
1999 {
2001  return multires_subdivide_exec(C, op);
2002  }
2003  return OPERATOR_CANCELLED;
2004 }
2005 
2007 {
2008  ot->name = "Multires Subdivide";
2009  ot->description = "Add a new level of subdivision";
2010  ot->idname = "OBJECT_OT_multires_subdivide";
2011 
2012  ot->poll = multires_poll;
2015 
2016  /* flags */
2019  RNA_def_enum(ot->srna,
2020  "mode",
2023  "Subdivision Mode",
2024  "How the mesh is going to be subdivided to create a new level");
2025 }
2026 
2029 /* ------------------------------------------------------------------- */
2034 {
2036  Object *ob = ED_object_active_context(C), *secondob = nullptr;
2038  op, ob, eModifierType_Multires);
2039 
2040  if (!mmd) {
2041  return OPERATOR_CANCELLED;
2042  }
2043 
2044  if (mmd->lvl == 0) {
2045  BKE_report(op->reports, RPT_ERROR, "Reshape can work only with higher levels of subdivisions");
2046  return OPERATOR_CANCELLED;
2047  }
2048 
2049  CTX_DATA_BEGIN (C, Object *, selob, selected_editable_objects) {
2050  if (selob->type == OB_MESH && selob != ob) {
2051  secondob = selob;
2052  break;
2053  }
2054  }
2055  CTX_DATA_END;
2056 
2057  if (!secondob) {
2058  BKE_report(op->reports, RPT_ERROR, "Second selected mesh object required to copy shape from");
2059  return OPERATOR_CANCELLED;
2060  }
2061 
2062  if (!multiresModifier_reshapeFromObject(depsgraph, mmd, ob, secondob)) {
2063  BKE_report(op->reports, RPT_ERROR, "Objects do not have the same number of vertices");
2064  return OPERATOR_CANCELLED;
2065  }
2066 
2069 
2070  return OPERATOR_FINISHED;
2071 }
2072 
2073 static int multires_reshape_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
2074 {
2076  return multires_reshape_exec(C, op);
2077  }
2078  return OPERATOR_CANCELLED;
2079 }
2080 
2082 {
2083  ot->name = "Multires Reshape";
2084  ot->description = "Copy vertex coordinates from other object";
2085  ot->idname = "OBJECT_OT_multires_reshape";
2086 
2087  ot->poll = multires_poll;
2090 
2091  /* flags */
2094 }
2095 
2098 /* ------------------------------------------------------------------- */
2103 {
2104  Main *bmain = CTX_data_main(C);
2106  Mesh *me = (ob) ? static_cast<Mesh *>(ob->data) : static_cast<Mesh *>(op->customdata);
2107  char path[FILE_MAX];
2108  const bool relative = RNA_boolean_get(op->ptr, "relative_path");
2109 
2110  if (!me) {
2111  return OPERATOR_CANCELLED;
2112  }
2113 
2115  return OPERATOR_CANCELLED;
2116  }
2117 
2118  RNA_string_get(op->ptr, "filepath", path);
2119 
2120  if (relative) {
2121  BLI_path_rel(path, BKE_main_blendfile_path(bmain));
2122  }
2123 
2124  CustomData_external_add(&me->ldata, &me->id, CD_MDISPS, me->totloop, path);
2126 
2127  return OPERATOR_FINISHED;
2128 }
2129 
2131 {
2133  Mesh *me = static_cast<Mesh *>(ob->data);
2134  char path[FILE_MAX];
2135 
2136  if (!edit_modifier_invoke_properties(C, op)) {
2137  return OPERATOR_CANCELLED;
2138  }
2139 
2141  op, ob, eModifierType_Multires);
2142 
2143  if (!mmd) {
2144  return OPERATOR_CANCELLED;
2145  }
2146 
2148  return OPERATOR_CANCELLED;
2149  }
2150 
2151  if (RNA_struct_property_is_set(op->ptr, "filepath")) {
2152  return multires_external_save_exec(C, op);
2153  }
2154 
2155  op->customdata = me;
2156 
2157  BLI_snprintf(path, sizeof(path), "//%s.btx", me->id.name + 2);
2158  RNA_string_set(op->ptr, "filepath", path);
2159 
2161 
2162  return OPERATOR_RUNNING_MODAL;
2163 }
2164 
2166 {
2167  ot->name = "Multires Save External";
2168  ot->description = "Save displacements to an external file";
2169  ot->idname = "OBJECT_OT_multires_external_save";
2170 
2171  /* XXX modifier no longer in context after file browser .. ot->poll = multires_poll; */
2174  ot->poll = multires_poll;
2175 
2176  /* flags */
2178 
2181  FILE_SPECIAL,
2182  FILE_SAVE,
2187 }
2188 
2191 /* ------------------------------------------------------------------- */
2196 {
2198  Mesh *me = static_cast<Mesh *>(ob->data);
2199 
2201  return OPERATOR_CANCELLED;
2202  }
2203 
2204  /* XXX don't remove. */
2206 
2207  return OPERATOR_FINISHED;
2208 }
2209 
2211 {
2212  ot->name = "Multires Pack External";
2213  ot->description = "Pack displacements from an external file";
2214  ot->idname = "OBJECT_OT_multires_external_pack";
2215 
2216  ot->poll = multires_poll;
2218 
2219  /* flags */
2221 }
2222 
2225 /* ------------------------------------------------------------------- */
2230 {
2232  Object *object = ED_object_active_context(C);
2234  op, object, eModifierType_Multires);
2235 
2236  if (!mmd) {
2237  return OPERATOR_CANCELLED;
2238  }
2239 
2241 
2242  multiresModifier_base_apply(depsgraph, object, mmd);
2243 
2245 
2248 
2249  return OPERATOR_FINISHED;
2250 }
2251 
2253 {
2255  return multires_base_apply_exec(C, op);
2256  }
2257  return OPERATOR_CANCELLED;
2258 }
2259 
2261 {
2262  ot->name = "Multires Apply Base";
2263  ot->description = "Modify the base mesh to conform to the displaced mesh";
2264  ot->idname = "OBJECT_OT_multires_base_apply";
2265 
2266  ot->poll = multires_poll;
2269 
2270  /* flags */
2273 }
2274 
2277 /* ------------------------------------------------------------------- */
2282 {
2284  Object *object = ED_object_active_context(C);
2286  op, object, eModifierType_Multires);
2287 
2288  if (!mmd) {
2289  return OPERATOR_CANCELLED;
2290  }
2291 
2292  int new_levels = multiresModifier_rebuild_subdiv(depsgraph, object, mmd, 1, true);
2293  if (new_levels == 0) {
2294  BKE_report(op->reports, RPT_ERROR, "No valid subdivisions found to rebuild a lower level");
2295  return OPERATOR_CANCELLED;
2296  }
2297 
2300 
2301  return OPERATOR_FINISHED;
2302 }
2303 
2305 {
2307  return multires_unsubdivide_exec(C, op);
2308  }
2309  return OPERATOR_CANCELLED;
2310 }
2311 
2313 {
2314  ot->name = "Unsubdivide";
2315  ot->description = "Rebuild a lower subdivision level of the current base mesh";
2316  ot->idname = "OBJECT_OT_multires_unsubdivide";
2317 
2318  ot->poll = multires_poll;
2321 
2322  /* flags */
2325 }
2326 
2329 /* ------------------------------------------------------------------- */
2334 {
2336  Object *object = ED_object_active_context(C);
2338  op, object, eModifierType_Multires);
2339 
2340  if (!mmd) {
2341  return OPERATOR_CANCELLED;
2342  }
2343 
2344  int new_levels = multiresModifier_rebuild_subdiv(depsgraph, object, mmd, INT_MAX, false);
2345  if (new_levels == 0) {
2346  BKE_report(op->reports, RPT_ERROR, "Not valid subdivisions found to rebuild lower levels");
2347  return OPERATOR_CANCELLED;
2348  }
2349 
2350  BKE_reportf(op->reports, RPT_INFO, "%d new levels rebuilt", new_levels);
2351 
2354 
2355  return OPERATOR_FINISHED;
2356 }
2357 
2359  wmOperator *op,
2360  const wmEvent *UNUSED(event))
2361 {
2363  return multires_rebuild_subdiv_exec(C, op);
2364  }
2365  return OPERATOR_CANCELLED;
2366 }
2367 
2369 {
2370  ot->name = "Rebuild Lower Subdivisions";
2371  ot->description =
2372  "Rebuilds all possible subdivisions levels to generate a lower resolution base mesh";
2373  ot->idname = "OBJECT_OT_multires_rebuild_subdiv";
2374 
2375  ot->poll = multires_poll;
2378 
2379  /* flags */
2382 }
2383 
2386 /* ------------------------------------------------------------------- */
2391 {
2392  Mesh *me = static_cast<Mesh *>(ob->data);
2393  BMEditMesh *em = me->edit_mesh;
2394 
2395  if (em) {
2397  }
2398  else {
2400  }
2401 }
2402 
2403 static bool skin_poll(bContext *C)
2404 {
2405  return (edit_modifier_poll_generic(C, &RNA_SkinModifier, (1 << OB_MESH), false, false));
2406 }
2407 
2409 {
2410  Object *ob = CTX_data_edit_object(C);
2411  return (ob != nullptr &&
2412  edit_modifier_poll_generic(C, &RNA_SkinModifier, (1 << OB_MESH), true, false) &&
2414 }
2415 
2416 static void skin_root_clear(BMVert *bm_vert, GSet *visited, const int cd_vert_skin_offset)
2417 {
2418  BMEdge *bm_edge;
2419  BMIter bm_iter;
2420 
2421  BM_ITER_ELEM (bm_edge, &bm_iter, bm_vert, BM_EDGES_OF_VERT) {
2422  BMVert *v2 = BM_edge_other_vert(bm_edge, bm_vert);
2423 
2424  if (BLI_gset_add(visited, v2)) {
2425  MVertSkin *vs = static_cast<MVertSkin *>(BM_ELEM_CD_GET_VOID_P(v2, cd_vert_skin_offset));
2426 
2427  /* clear vertex root flag and add to visited set */
2428  vs->flag &= ~MVERT_SKIN_ROOT;
2429 
2430  skin_root_clear(v2, visited, cd_vert_skin_offset);
2431  }
2432  }
2433 }
2434 
2436 {
2437  Object *ob = CTX_data_edit_object(C);
2439  BMesh *bm = em->bm;
2440 
2441  GSet *visited = BLI_gset_ptr_new(__func__);
2442 
2443  BKE_mesh_ensure_skin_customdata(static_cast<Mesh *>(ob->data));
2444 
2445  const int cd_vert_skin_offset = CustomData_get_offset(&bm->vdata, CD_MVERT_SKIN);
2446 
2447  BMVert *bm_vert;
2448  BMIter bm_iter;
2449  BM_ITER_MESH (bm_vert, &bm_iter, bm, BM_VERTS_OF_MESH) {
2450  if (BM_elem_flag_test(bm_vert, BM_ELEM_SELECT) && BLI_gset_add(visited, bm_vert)) {
2451  MVertSkin *vs = static_cast<MVertSkin *>(
2452  BM_ELEM_CD_GET_VOID_P(bm_vert, cd_vert_skin_offset));
2453 
2454  /* mark vertex as root and add to visited set */
2455  vs->flag |= MVERT_SKIN_ROOT;
2456 
2457  /* clear root flag from all connected vertices (recursively) */
2458  skin_root_clear(bm_vert, visited, cd_vert_skin_offset);
2459  }
2460  }
2461 
2462  BLI_gset_free(visited, nullptr);
2463 
2466 
2467  return OPERATOR_FINISHED;
2468 }
2469 
2471 {
2472  ot->name = "Skin Root Mark";
2473  ot->description = "Mark selected vertices as roots";
2474  ot->idname = "OBJECT_OT_skin_root_mark";
2475 
2476  ot->poll = skin_edit_poll;
2478 
2479  /* flags */
2481 }
2482 
2486 };
2487 
2489 {
2490  Object *ob = CTX_data_edit_object(C);
2492  BMesh *bm = em->bm;
2493  SkinLooseAction action = static_cast<SkinLooseAction>(RNA_enum_get(op->ptr, "action"));
2494 
2496  return OPERATOR_CANCELLED;
2497  }
2498 
2499  BMVert *bm_vert;
2500  BMIter bm_iter;
2501  BM_ITER_MESH (bm_vert, &bm_iter, bm, BM_VERTS_OF_MESH) {
2502  if (BM_elem_flag_test(bm_vert, BM_ELEM_SELECT)) {
2503  MVertSkin *vs = static_cast<MVertSkin *>(
2505 
2506  switch (action) {
2507  case SKIN_LOOSE_MARK:
2508  vs->flag |= MVERT_SKIN_LOOSE;
2509  break;
2510  case SKIN_LOOSE_CLEAR:
2511  vs->flag &= ~MVERT_SKIN_LOOSE;
2512  break;
2513  }
2514  }
2515  }
2516 
2519 
2520  return OPERATOR_FINISHED;
2521 }
2522 
2524 {
2525  static const EnumPropertyItem action_items[] = {
2526  {SKIN_LOOSE_MARK, "MARK", 0, "Mark", "Mark selected vertices as loose"},
2527  {SKIN_LOOSE_CLEAR, "CLEAR", 0, "Clear", "Set selected vertices as not loose"},
2528  {0, nullptr, 0, nullptr, nullptr},
2529  };
2530 
2531  ot->name = "Skin Mark/Clear Loose";
2532  ot->description = "Mark/clear selected vertices as loose";
2533  ot->idname = "OBJECT_OT_skin_loose_mark_clear";
2534 
2535  ot->poll = skin_edit_poll;
2537 
2538  /* flags */
2540 
2541  RNA_def_enum(ot->srna, "action", action_items, SKIN_LOOSE_MARK, "Action", nullptr);
2542 }
2543 
2545 {
2546  Object *ob = CTX_data_edit_object(C);
2548  BMesh *bm = em->bm;
2549 
2551  return OPERATOR_CANCELLED;
2552  }
2553 
2554  BMVert *bm_vert;
2555  BMIter bm_iter;
2556  BM_ITER_MESH (bm_vert, &bm_iter, bm, BM_VERTS_OF_MESH) {
2557  if (BM_elem_flag_test(bm_vert, BM_ELEM_SELECT)) {
2558  MVertSkin *vs = static_cast<MVertSkin *>(
2560  float avg = (vs->radius[0] + vs->radius[1]) * 0.5f;
2561 
2562  vs->radius[0] = vs->radius[1] = avg;
2563  }
2564  }
2565 
2568 
2569  return OPERATOR_FINISHED;
2570 }
2571 
2573 {
2574  ot->name = "Skin Radii Equalize";
2575  ot->description = "Make skin radii of selected vertices equal on each axis";
2576  ot->idname = "OBJECT_OT_skin_radii_equalize";
2577 
2578  ot->poll = skin_edit_poll;
2580 
2581  /* flags */
2583 }
2584 
2585 static void skin_armature_bone_create(Object *skin_ob,
2586  MVert *mvert,
2587  MEdge *medge,
2588  bArmature *arm,
2589  BLI_bitmap *edges_visited,
2590  const MeshElemMap *emap,
2591  EditBone *parent_bone,
2592  int parent_v)
2593 {
2594  for (int i = 0; i < emap[parent_v].count; i++) {
2595  int endx = emap[parent_v].indices[i];
2596  const MEdge *e = &medge[endx];
2597 
2598  /* ignore edge if already visited */
2599  if (BLI_BITMAP_TEST(edges_visited, endx)) {
2600  continue;
2601  }
2602  BLI_BITMAP_ENABLE(edges_visited, endx);
2603 
2604  int v = (e->v1 == parent_v ? e->v2 : e->v1);
2605 
2606  EditBone *bone = ED_armature_ebone_add(arm, "Bone");
2607 
2608  bone->parent = parent_bone;
2609  if (parent_bone != nullptr) {
2610  bone->flag |= BONE_CONNECTED;
2611  }
2612 
2613  copy_v3_v3(bone->head, mvert[parent_v].co);
2614  copy_v3_v3(bone->tail, mvert[v].co);
2615  bone->rad_head = bone->rad_tail = 0.25;
2616  BLI_snprintf(bone->name, sizeof(bone->name), "Bone.%.2d", endx);
2617 
2618  /* add bDeformGroup */
2619  bDeformGroup *dg = BKE_object_defgroup_add_name(skin_ob, bone->name);
2620  if (dg != nullptr) {
2621  ED_vgroup_vert_add(skin_ob, dg, parent_v, 1, WEIGHT_REPLACE);
2622  ED_vgroup_vert_add(skin_ob, dg, v, 1, WEIGHT_REPLACE);
2623  }
2624 
2625  skin_armature_bone_create(skin_ob, mvert, medge, arm, edges_visited, emap, bone, v);
2626  }
2627 }
2628 
2630 {
2631  Mesh *me = static_cast<Mesh *>(skin_ob->data);
2632 
2633  Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
2634  Object *ob_eval = DEG_get_evaluated_object(depsgraph, skin_ob);
2635 
2636  Mesh *me_eval_deform = mesh_get_eval_deform(depsgraph, scene_eval, ob_eval, &CD_MASK_BAREMESH);
2637  MVert *mvert = me_eval_deform->mvert;
2638 
2639  /* add vertex weights to original mesh */
2641 
2643  Object *arm_ob = BKE_object_add(bmain, view_layer, OB_ARMATURE, nullptr);
2644  BKE_object_transform_copy(arm_ob, skin_ob);
2645  bArmature *arm = static_cast<bArmature *>(arm_ob->data);
2646  arm->layer = 1;
2647  arm_ob->dtx |= OB_DRAW_IN_FRONT;
2648  arm->drawtype = ARM_LINE;
2649  arm->edbo = MEM_cnew<ListBase>("edbo armature");
2650 
2651  MVertSkin *mvert_skin = static_cast<MVertSkin *>(
2653  int *emap_mem;
2654  MeshElemMap *emap;
2655  BKE_mesh_vert_edge_map_create(&emap, &emap_mem, me->medge, me->totvert, me->totedge);
2656 
2657  BLI_bitmap *edges_visited = BLI_BITMAP_NEW(me->totedge, "edge_visited");
2658 
2659  /* NOTE: we use EditBones here, easier to set them up and use
2660  * edit-armature functions to convert back to regular bones */
2661  for (int v = 0; v < me->totvert; v++) {
2662  if (mvert_skin[v].flag & MVERT_SKIN_ROOT) {
2663  EditBone *bone = nullptr;
2664 
2665  /* Unless the skin root has just one adjacent edge, create
2666  * a fake root bone (have it going off in the Y direction
2667  * (arbitrary) */
2668  if (emap[v].count > 1) {
2669  bone = ED_armature_ebone_add(arm, "Bone");
2670 
2671  copy_v3_v3(bone->head, me->mvert[v].co);
2672  copy_v3_v3(bone->tail, me->mvert[v].co);
2673 
2674  bone->head[1] = 1.0f;
2675  bone->rad_head = bone->rad_tail = 0.25;
2676  }
2677 
2678  if (emap[v].count >= 1) {
2679  skin_armature_bone_create(skin_ob, mvert, me->medge, arm, edges_visited, emap, bone, v);
2680  }
2681  }
2682  }
2683 
2684  MEM_freeN(edges_visited);
2685  MEM_freeN(emap);
2686  MEM_freeN(emap_mem);
2687 
2688  ED_armature_from_edit(bmain, arm);
2689  ED_armature_edit_free(arm);
2690 
2691  return arm_ob;
2692 }
2693 
2695 {
2696  Main *bmain = CTX_data_main(C);
2699  Mesh *me = static_cast<Mesh *>(ob->data);
2700  ModifierData *skin_md;
2701 
2703  BKE_reportf(op->reports, RPT_WARNING, "Mesh '%s' has no skin vertex data", me->id.name + 2);
2704  return OPERATOR_CANCELLED;
2705  }
2706 
2707  /* create new armature */
2708  Object *arm_ob = modifier_skin_armature_create(depsgraph, bmain, ob);
2709 
2710  /* add a modifier to connect the new armature to the mesh */
2712  if (arm_md) {
2714  BLI_insertlinkafter(&ob->modifiers, skin_md, arm_md);
2715 
2716  arm_md->object = arm_ob;
2718  DEG_relations_tag_update(bmain);
2720  }
2721 
2723 
2724  return OPERATOR_FINISHED;
2725 }
2726 
2728 {
2730  return skin_armature_create_exec(C, op);
2731  }
2732  return OPERATOR_CANCELLED;
2733 }
2734 
2736 {
2737  ot->name = "Skin Armature Create";
2738  ot->description = "Create an armature that parallels the skin layout";
2739  ot->idname = "OBJECT_OT_skin_armature_create";
2740 
2741  ot->poll = skin_poll;
2744 
2745  /* flags */
2748 }
2749 
2752 /* ------------------------------------------------------------------- */
2757 {
2758  return edit_modifier_poll_generic(C, &RNA_CorrectiveSmoothModifier, 0, true, false);
2759 }
2760 
2762 {
2768 
2769  if (!csmd) {
2770  return OPERATOR_CANCELLED;
2771  }
2772 
2774  BKE_report(op->reports, RPT_ERROR, "Modifier is disabled");
2775  return OPERATOR_CANCELLED;
2776  }
2777 
2778  const bool is_bind = (csmd->bind_coords != nullptr);
2779 
2780  MEM_SAFE_FREE(csmd->bind_coords);
2782 
2783  if (is_bind) {
2784  /* toggle off */
2785  csmd->bind_coords_num = 0;
2786  }
2787  else {
2788  /* Signal to modifier to recalculate. */
2791  csmd_eval->bind_coords_num = (uint)-1;
2792 
2793  /* Force modifier to run, it will call binding routine
2794  * (this has to happen outside of depsgraph evaluation). */
2796  }
2797 
2800 
2801  return OPERATOR_FINISHED;
2802 }
2803 
2805 {
2807  return correctivesmooth_bind_exec(C, op);
2808  }
2809  return OPERATOR_CANCELLED;
2810 }
2811 
2813 {
2814  /* identifiers */
2815  ot->name = "Corrective Smooth Bind";
2816  ot->description = "Bind base pose in Corrective Smooth modifier";
2817  ot->idname = "OBJECT_OT_correctivesmooth_bind";
2818 
2819  /* api callbacks */
2823 
2824  /* flags */
2827 }
2828 
2831 /* ------------------------------------------------------------------- */
2836 {
2837  return edit_modifier_poll_generic(C, &RNA_MeshDeformModifier, 0, true, false);
2838 }
2839 
2841 {
2845  op, ob, eModifierType_MeshDeform);
2846 
2847  if (mmd == nullptr) {
2848  return OPERATOR_CANCELLED;
2849  }
2850 
2851  if (mmd->bindcagecos != nullptr) {
2852  MEM_SAFE_FREE(mmd->bindcagecos);
2853  MEM_SAFE_FREE(mmd->dyngrid);
2856  MEM_SAFE_FREE(mmd->bindoffsets);
2857  MEM_SAFE_FREE(mmd->dynverts);
2858  MEM_SAFE_FREE(mmd->bindweights); /* Deprecated */
2859  MEM_SAFE_FREE(mmd->bindcos); /* Deprecated */
2860  mmd->verts_num = 0;
2861  mmd->cage_verts_num = 0;
2862  mmd->influences_num = 0;
2863  }
2864  else {
2865  /* Force modifier to run, it will call binding routine
2866  * (this has to happen outside of depsgraph evaluation). */
2868  depsgraph, ob, &mmd->modifier);
2871  mmd_eval->bindfunc = nullptr;
2872  }
2873 
2876  return OPERATOR_FINISHED;
2877 }
2878 
2879 static int meshdeform_bind_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
2880 {
2882  return meshdeform_bind_exec(C, op);
2883  }
2884  return OPERATOR_CANCELLED;
2885 }
2886 
2888 {
2889  /* identifiers */
2890  ot->name = "Mesh Deform Bind";
2891  ot->description = "Bind mesh to cage in mesh deform modifier";
2892  ot->idname = "OBJECT_OT_meshdeform_bind";
2893 
2894  /* api callbacks */
2895  ot->poll = meshdeform_poll;
2898 
2899  /* flags */
2902 }
2903 
2906 /* ------------------------------------------------------------------- */
2910 static bool explode_poll(bContext *C)
2911 {
2912  return edit_modifier_poll_generic(C, &RNA_ExplodeModifier, 0, true, false);
2913 }
2914 
2916 {
2919  op, ob, eModifierType_Explode);
2920 
2921  if (!emd) {
2922  return OPERATOR_CANCELLED;
2923  }
2924 
2925  emd->flag |= eExplodeFlag_CalcFaces;
2926 
2929 
2930  return OPERATOR_FINISHED;
2931 }
2932 
2933 static int explode_refresh_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
2934 {
2936  return explode_refresh_exec(C, op);
2937  }
2938  return OPERATOR_CANCELLED;
2939 }
2940 
2942 {
2943  ot->name = "Explode Refresh";
2944  ot->description = "Refresh data in the Explode modifier";
2945  ot->idname = "OBJECT_OT_explode_refresh";
2946 
2947  ot->poll = explode_poll;
2950 
2951  /* flags */
2954 }
2955 
2958 /* ------------------------------------------------------------------- */
2963 {
2964  return edit_modifier_poll_generic(C, &RNA_OceanModifier, 0, true, false);
2965 }
2966 
2968  /* from wmJob */
2969  struct Object *owner;
2970  short *stop, *do_update;
2971  float *progress;
2973  struct OceanCache *och;
2974  struct Ocean *ocean;
2976 };
2977 
2978 static void oceanbake_free(void *customdata)
2979 {
2980  OceanBakeJob *oj = static_cast<OceanBakeJob *>(customdata);
2981  MEM_delete(oj);
2982 }
2983 
2984 /* called by oceanbake, only to check job 'stop' value */
2985 static int oceanbake_breakjob(void *UNUSED(customdata))
2986 {
2987  // OceanBakeJob *ob = (OceanBakeJob *)customdata;
2988  // return *(ob->stop);
2989 
2990  /* this is not nice yet, need to make the jobs list template better
2991  * for identifying/acting upon various different jobs */
2992  /* but for now we'll reuse the render break... */
2993  return (G.is_break);
2994 }
2995 
2996 /* called by oceanbake, wmJob sends notifier */
2997 static void oceanbake_update(void *customdata, float progress, int *cancel)
2998 {
2999  OceanBakeJob *oj = static_cast<OceanBakeJob *>(customdata);
3000 
3001  if (oceanbake_breakjob(oj)) {
3002  *cancel = 1;
3003  }
3004 
3005  *(oj->do_update) = true;
3006  *(oj->progress) = progress;
3007 }
3008 
3009 static void oceanbake_startjob(void *customdata, short *stop, short *do_update, float *progress)
3010 {
3011  OceanBakeJob *oj = static_cast<OceanBakeJob *>(customdata);
3012 
3013  oj->stop = stop;
3014  oj->do_update = do_update;
3015  oj->progress = progress;
3016 
3017  G.is_break = false; /* XXX shared with render - replace with job 'stop' switch */
3018 
3019  BKE_ocean_bake(oj->ocean, oj->och, oceanbake_update, (void *)oj);
3020 
3021  *do_update = true;
3022  *stop = 0;
3023 }
3024 
3025 static void oceanbake_endjob(void *customdata)
3026 {
3027  OceanBakeJob *oj = static_cast<OceanBakeJob *>(customdata);
3028 
3029  if (oj->ocean) {
3030  BKE_ocean_free(oj->ocean);
3031  oj->ocean = nullptr;
3032  }
3033 
3034  oj->omd->oceancache = oj->och;
3035  oj->omd->cached = true;
3036 
3037  Object *ob = oj->owner;
3039 }
3040 
3042 {
3043  Main *bmain = CTX_data_main(C);
3046  op, ob, eModifierType_Ocean);
3048  const bool free = RNA_boolean_get(op->ptr, "free");
3049 
3050  if (!omd) {
3051  return OPERATOR_CANCELLED;
3052  }
3053 
3054  if (free) {
3058  return OPERATOR_FINISHED;
3059  }
3060 
3062  BKE_modifier_path_relbase(bmain, ob),
3063  omd->bakestart,
3064  omd->bakeend,
3065  omd->wave_scale,
3066  omd->chop_amount,
3067  omd->foam_coverage,
3068  omd->foam_fade,
3069  omd->resolution);
3070 
3071  och->time = static_cast<float *>(MEM_mallocN(och->duration * sizeof(float), "foam bake time"));
3072 
3073  int cfra = scene->r.cfra;
3074 
3075  /* precalculate time variable before baking */
3076  int i = 0;
3078  for (int f = omd->bakestart; f <= omd->bakeend; f++) {
3079  /* For now only simple animation of time value is supported, nothing else.
3080  * No drivers or other modifier parameters. */
3081  /* TODO(sergey): This operates on an original data, so no flush is needed. However, baking
3082  * usually should happen on an evaluated objects, so this seems to be deeper issue here. */
3083 
3085  f);
3086  BKE_animsys_evaluate_animdata((ID *)ob, ob->adt, &anim_eval_context, ADT_RECALC_ANIM, false);
3087 
3088  och->time[i] = omd->time;
3089  i++;
3090  }
3091 
3092  /* Make a copy of ocean to use for baking - thread-safety. */
3093  struct Ocean *ocean = BKE_ocean_add();
3094  BKE_ocean_init_from_modifier(ocean, omd, omd->resolution);
3095 
3096 #if 0
3097  BKE_ocean_bake(ocean, och);
3098 
3099  omd->oceancache = och;
3100  omd->cached = true;
3101 
3102  scene->r.cfra = cfra;
3103 
3106 #endif
3107 
3108  /* job stuff */
3109 
3110  scene->r.cfra = cfra;
3111 
3112  /* setup job */
3113  wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C),
3114  CTX_wm_window(C),
3115  scene,
3116  "Ocean Simulation",
3119  OceanBakeJob *oj = MEM_cnew<OceanBakeJob>("ocean bake job");
3120  oj->owner = ob;
3121  oj->ocean = ocean;
3122  oj->och = och;
3123  oj->omd = omd;
3124 
3127  WM_jobs_callbacks(wm_job, oceanbake_startjob, nullptr, nullptr, oceanbake_endjob);
3128 
3129  WM_jobs_start(CTX_wm_manager(C), wm_job);
3130 
3131  return OPERATOR_FINISHED;
3132 }
3133 
3134 static int ocean_bake_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
3135 {
3137  return ocean_bake_exec(C, op);
3138  }
3139  return OPERATOR_CANCELLED;
3140 }
3141 
3143 {
3144  ot->name = "Bake Ocean";
3145  ot->description = "Bake an image sequence of ocean data";
3146  ot->idname = "OBJECT_OT_ocean_bake";
3147 
3148  ot->poll = ocean_bake_poll;
3150  ot->exec = ocean_bake_exec;
3151 
3152  /* flags */
3155 
3156  RNA_def_boolean(ot->srna, "free", false, "Free", "Free the bake, rather than generating it");
3157 }
3158 
3161 /* ------------------------------------------------------------------- */
3166 {
3167  return edit_modifier_poll_generic(C, &RNA_LaplacianDeformModifier, 0, false, false);
3168 }
3169 
3171 {
3176 
3177  if (lmd == nullptr) {
3178  return OPERATOR_CANCELLED;
3179  }
3180 
3181  if (lmd->flag & MOD_LAPLACIANDEFORM_BIND) {
3182  lmd->flag &= ~MOD_LAPLACIANDEFORM_BIND;
3183  }
3184  else {
3186  }
3187 
3190  lmd_eval->flag = lmd->flag;
3191 
3192  /* Force modifier to run, it will call binding routine
3193  * (this has to happen outside of depsgraph evaluation). */
3195 
3196  /* This is hard to know from the modifier itself whether the evaluation is
3197  * happening for binding or not. So we copy all the required data here. */
3198  lmd->verts_num = lmd_eval->verts_num;
3199  if (lmd_eval->vertexco == nullptr) {
3200  MEM_SAFE_FREE(lmd->vertexco);
3201  }
3202  else {
3203  lmd->vertexco = static_cast<float *>(MEM_dupallocN(lmd_eval->vertexco));
3204  }
3205 
3208  return OPERATOR_FINISHED;
3209 }
3210 
3212 {
3214  return laplaciandeform_bind_exec(C, op);
3215  }
3216  return OPERATOR_CANCELLED;
3217 }
3218 
3220 {
3221  /* identifiers */
3222  ot->name = "Laplacian Deform Bind";
3223  ot->description = "Bind mesh to system in laplacian deform modifier";
3224  ot->idname = "OBJECT_OT_laplaciandeform_bind";
3225 
3226  /* api callbacks */
3230 
3231  /* flags */
3234 }
3235 
3238 /* ------------------------------------------------------------------- */
3243 {
3244  return edit_modifier_poll_generic(C, &RNA_SurfaceDeformModifier, 0, true, false);
3245 }
3246 
3248 {
3252  op, ob, eModifierType_SurfaceDeform);
3253 
3254  if (smd == nullptr) {
3255  return OPERATOR_CANCELLED;
3256  }
3257 
3258  if (smd->flags & MOD_SDEF_BIND) {
3259  smd->flags &= ~MOD_SDEF_BIND;
3260  }
3261  else if (smd->target) {
3262  smd->flags |= MOD_SDEF_BIND;
3263  }
3264 
3266  depsgraph, ob, &smd->modifier);
3267  smd_eval->flags = smd->flags;
3268 
3269  /* Force modifier to run, it will call binding routine
3270  * (this has to happen outside of depsgraph evaluation). */
3272 
3275  return OPERATOR_FINISHED;
3276 }
3277 
3279 {
3281  return surfacedeform_bind_exec(C, op);
3282  }
3283  return OPERATOR_CANCELLED;
3284 }
3285 
3287 {
3288  /* identifiers */
3289  ot->name = "Surface Deform Bind";
3290  ot->description = "Bind mesh to target in surface deform modifier";
3291  ot->idname = "OBJECT_OT_surfacedeform_bind";
3292 
3293  /* api callbacks */
3297 
3298  /* flags */
3301 }
3302 
3305 /* ------------------------------------------------------------------- */
3314 {
3316 
3317  char modifier_name[MAX_NAME];
3318  RNA_string_get(op->ptr, "modifier_name", modifier_name);
3320  if (nmd == nullptr) {
3321  return OPERATOR_CANCELLED;
3322  }
3323 
3324  char prop_path[MAX_NAME];
3325  RNA_string_get(op->ptr, "prop_path", prop_path);
3326 
3327  PointerRNA mod_ptr;
3328  RNA_pointer_create(&ob->id, &RNA_Modifier, nmd, &mod_ptr);
3329 
3330  const int old_value = RNA_int_get(&mod_ptr, prop_path);
3331  const int new_value = !old_value;
3332  RNA_int_set(&mod_ptr, prop_path, new_value);
3333 
3336  return OPERATOR_FINISHED;
3337 }
3338 
3340 {
3341  ot->name = "Input Attribute Toggle";
3342  ot->description =
3343  "Switch between an attribute and a single value to define the data for every element";
3344  ot->idname = "OBJECT_OT_geometry_nodes_input_attribute_toggle";
3345 
3348 
3350 
3351  RNA_def_string(ot->srna, "prop_path", nullptr, 0, "Prop Path", "");
3352  RNA_def_string(ot->srna, "modifier_name", nullptr, MAX_NAME, "Modifier Name", "");
3353 }
3354 
3357 /* ------------------------------------------------------------------- */
3362 {
3363  Main *bmain = CTX_data_main(C);
3366  if (!(md && md->type == eModifierType_Nodes)) {
3367  return OPERATOR_CANCELLED;
3368  }
3369 
3370  NodesModifierData *nmd = (NodesModifierData *)md;
3371  bNodeTree *tree = nmd->node_group;
3372  if (tree == nullptr) {
3373  return OPERATOR_CANCELLED;
3374  }
3375 
3376  bNodeTree *new_tree = (bNodeTree *)BKE_id_copy_ex(
3377  bmain, &tree->id, nullptr, LIB_ID_COPY_ACTIONS | LIB_ID_COPY_DEFAULT);
3378 
3379  if (new_tree == nullptr) {
3380  return OPERATOR_CANCELLED;
3381  }
3382 
3383  nmd->node_group = new_tree;
3384  id_us_min(&tree->id);
3385 
3386  DEG_relations_tag_update(bmain);
3388  return OPERATOR_FINISHED;
3389 }
3390 
3392 {
3393  ot->name = "Copy Geometry Node Group";
3394  ot->description = "Copy the active geometry node group and assign it to the active modifier";
3395  ot->idname = "OBJECT_OT_geometry_node_tree_copy_assign";
3396 
3399 
3401 }
3402 
typedef float(TangentPoint)[2]
AnimationEvalContext BKE_animsys_eval_context_construct(struct Depsgraph *depsgraph, float eval_time)
Definition: anim_sys.c:761
@ ADT_RECALC_ANIM
Definition: BKE_animsys.h:290
void BKE_animsys_evaluate_animdata(struct ID *id, struct AnimData *adt, const struct AnimationEvalContext *anim_eval_context, eAnimData_Recalc recalc, bool flush_to_original)
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1090
struct Object * CTX_data_edit_object(const bContext *C)
Definition: context.c:1370
struct wmWindowManager * CTX_wm_manager(const bContext *C)
Definition: context.c:713
#define CTX_DATA_BEGIN(C, Type, instance, member)
Definition: BKE_context.h:269
PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type)
Definition: context.c:473
struct ViewLayer * CTX_data_view_layer(const bContext *C)
Definition: context.c:1100
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
Definition: context.c:1528
struct Object * CTX_data_active_object(const bContext *C)
Definition: context.c:1353
struct Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
Definition: context.c:1505
void CTX_wm_operator_poll_msg_set(struct bContext *C, const char *msg)
Definition: context.c:1042
struct Main * CTX_data_main(const bContext *C)
Definition: context.c:1074
#define CTX_DATA_END
Definition: BKE_context.h:278
struct wmWindow * CTX_wm_window(const bContext *C)
Definition: context.c:723
float(* BKE_curve_nurbs_vert_coords_alloc(const struct ListBase *lb, int *r_vert_len))[3]
void BKE_curve_nurbs_vert_coords_apply(struct ListBase *lb, const float(*vert_coords)[3], bool constrain_2d)
Definition: curve.cc:4617
Low-level operations for curves that cannot be defined in the C++ header yet.
void BKE_curves_data_update(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *object)
Definition: curves.cc:315
Low-level operations for curves.
bool CustomData_free_layer_active(struct CustomData *data, int type, int totelem)
Definition: customdata.cc:2895
@ CD_CALLOC
void CustomData_external_write(struct CustomData *data, struct ID *id, eCustomDataMask mask, int totelem, int free)
Definition: customdata.cc:4620
void CustomData_external_add(struct CustomData *data, struct ID *id, int type, int totelem, const char *filepath)
bool CustomData_has_layer(const struct CustomData *data, int type)
const CustomData_MeshMasks CD_MASK_BAREMESH
Definition: customdata.cc:2051
void * CustomData_get_layer(const struct CustomData *data, int type)
bool CustomData_external_test(struct CustomData *data, int type)
Definition: customdata.cc:4772
void * CustomData_bmesh_get(const struct CustomData *data, void *block, int type)
void * CustomData_add_layer(struct CustomData *data, int type, eCDAllocType alloctype, void *layer, int totelem)
Definition: customdata.cc:2776
void CustomData_external_remove(struct CustomData *data, struct ID *id, int type, int totelem)
Definition: customdata.cc:4748
int CustomData_get_offset(const struct CustomData *data, int type)
const CustomData_MeshMasks CD_MASK_MESH
Definition: customdata.cc:2065
display list (or rather multi purpose list) stuff.
void BKE_displist_make_curveTypes(struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *ob, bool for_render)
void BKE_displist_make_mball(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob)
Definition: displist.cc:641
BMEditMesh * BKE_editmesh_from_object(struct Object *ob)
Return the BMEditMesh for a given object.
Definition: editmesh.c:58
struct PartDeflect * BKE_partdeflect_new(int type)
Definition: effect.c:71
void BKE_gpencil_modifiers_calc(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob)
void BKE_keyblock_convert_from_mesh(const struct Mesh *me, const struct Key *key, struct KeyBlock *kb)
struct KeyBlock * BKE_keyblock_add(struct Key *key, const char *name)
Definition: key.c:1814
struct Key * BKE_key_add(struct Main *bmain, struct ID *id)
Definition: key.c:252
void BKE_lattice_modifiers_calc(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob)
Definition: lattice.c:533
float(* BKE_lattice_vert_coords_alloc(const struct Lattice *lt, int *r_vert_len))[3]
void BKE_lattice_vert_coords_apply(struct Lattice *lt, const float(*vert_coords)[3])
Definition: lattice.c:525
@ LIB_ID_COPY_ACTIONS
Definition: BKE_lib_id.h:166
@ LIB_ID_COPY_DEFAULT
Definition: BKE_lib_id.h:181
void BKE_main_id_newptr_and_tag_clear(struct Main *bmain)
Definition: lib_id.c:1465
struct ID * BKE_id_copy_ex(struct Main *bmain, const struct ID *id, struct ID **r_newid, int flag)
bool BKE_id_is_editable(const struct Main *bmain, const struct ID *id)
void id_us_min(struct ID *id)
Definition: lib_id.c:313
void BKE_id_free(struct Main *bmain, void *idv)
const char * BKE_main_blendfile_path(const struct Main *bmain) ATTR_NONNULL()
General operations, lookup, etc. for materials.
void BKE_object_material_from_eval_data(struct Main *bmain, struct Object *ob_orig, const struct ID *data_eval)
void BKE_mesh_ensure_skin_customdata(struct Mesh *me)
Definition: mesh.cc:786
void BKE_mesh_nomain_to_mesh(struct Mesh *mesh_src, struct Mesh *mesh_dst, struct Object *ob, const struct CustomData_MeshMasks *mask, bool take_ownership)
void BKE_mesh_nomain_to_meshkey(struct Mesh *mesh_src, struct Mesh *mesh_dst, struct KeyBlock *kb)
void BKE_mesh_merge_customdata_for_apply_modifier(struct Mesh *me)
void BKE_mesh_eval_delete(struct Mesh *mesh_eval)
Definition: mesh.cc:1117
struct Mesh * BKE_mesh_create_derived_for_modifier(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob_eval, struct ModifierData *md_eval, bool use_virtual_modifiers, bool build_shapekey_layers)
void BKE_mesh_vert_edge_map_create(MeshElemMap **r_map, int **r_mem, const struct MEdge *medge, int totvert, int totedge)
struct Mesh * mesh_get_eval_deform(struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *ob, const struct CustomData_MeshMasks *dataMask)
struct Mesh * mesh_create_eval_final(struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *ob, const struct CustomData_MeshMasks *dataMask)
const ModifierTypeInfo * BKE_modifier_get_info(ModifierType type)
bool BKE_modifier_is_enabled(const struct Scene *scene, struct ModifierData *md, int required_mode)
bool BKE_modifier_is_nonlocal_in_liboverride(const struct Object *ob, const struct ModifierData *md)
@ eModifierTypeFlag_Single
Definition: BKE_modifier.h:93
@ eModifierTypeFlag_NoUserAdd
Definition: BKE_modifier.h:96
@ eModifierTypeFlag_RequiresOriginalData
Definition: BKE_modifier.h:84
void BKE_modifier_free(struct ModifierData *md)
const char * BKE_modifier_path_relbase(struct Main *bmain, struct Object *ob)
void BKE_modifier_copydata(const struct ModifierData *md, struct ModifierData *target)
struct ModifierData * BKE_modifier_get_evaluated(struct Depsgraph *depsgraph, struct Object *object, struct ModifierData *md)
struct ModifierData * BKE_modifiers_findby_type(const struct Object *ob, ModifierType type)
bool BKE_modifier_is_same_topology(ModifierData *md)
void BKE_modifier_remove_from_list(struct Object *ob, struct ModifierData *md)
struct ModifierData * BKE_modifier_new(int type)
@ eModifierTypeType_OnlyDeform
Definition: BKE_modifier.h:44
@ eModifierTypeType_NonGeometrical
Definition: BKE_modifier.h:62
@ eModifierTypeType_Constructive
Definition: BKE_modifier.h:47
@ eModifierTypeType_Nonconstructive
Definition: BKE_modifier.h:49
struct ModifierData * BKE_modifiers_findby_name(const struct Object *ob, const char *name)
ModifierApplyFlag
Definition: BKE_modifier.h:113
bool BKE_modifier_unique_name(struct ListBase *modifiers, struct ModifierData *md)
void multires_set_tot_level(struct Object *ob, struct MultiresModifierData *mmd, int lvl)
Definition: multires.c:365
void multiresModifier_del_levels(struct MultiresModifierData *mmd, struct Scene *scene, struct Object *object, int direction)
Definition: multires.c:695
void multires_force_sculpt_rebuild(struct Object *object)
Definition: multires.c:437
struct MultiresModifierData * find_multires_modifier_before(struct Scene *scene, struct ModifierData *lastmd)
Definition: multires.c:302
void multiresModifier_set_levels_from_disps(struct MultiresModifierData *mmd, struct Object *ob)
Definition: multires.c:503
void multiresModifier_base_apply(struct Depsgraph *depsgraph, struct Object *object, struct MultiresModifierData *mmd)
void multires_customdata_delete(struct Mesh *me)
Definition: multires.c:67
bool multiresModifier_reshapeFromObject(struct Depsgraph *depsgraph, struct MultiresModifierData *mmd, struct Object *dst, struct Object *src)
int multiresModifier_rebuild_subdiv(struct Depsgraph *depsgraph, struct Object *object, struct MultiresModifierData *mmd, int rebuild_limit, bool switch_view_to_lower_level)
eMultiresSubdivideModeType
Definition: BKE_multires.h:195
@ MULTIRES_SUBDIVIDE_LINEAR
Definition: BKE_multires.h:198
@ MULTIRES_SUBDIVIDE_CATMULL_CLARK
Definition: BKE_multires.h:196
@ MULTIRES_SUBDIVIDE_SIMPLE
Definition: BKE_multires.h:197
bool multiresModifier_reshapeFromDeformModifier(struct Depsgraph *depsgraph, struct Object *ob, struct MultiresModifierData *mmd, struct ModifierData *deform_md)
void multiresModifier_subdivide(struct Object *object, struct MultiresModifierData *mmd, eMultiresSubdivideModeType mode)
General operations, lookup, etc. for blender objects.
bool BKE_object_support_modifier_type_check(const struct Object *ob, int modifier_type)
void BKE_object_modifier_set_active(struct Object *ob, struct ModifierData *md)
Definition: object.cc:1367
void BKE_object_link_modifiers(struct Object *ob_dst, const struct Object *ob_src)
struct Object * BKE_object_add(struct Main *bmain, struct ViewLayer *view_layer, int type, const char *name) ATTR_NONNULL(1
void BKE_object_transform_copy(struct Object *ob_tar, const struct Object *ob_src)
void BKE_object_free_derived_caches(struct Object *ob)
Definition: object.cc:1774
bool BKE_object_supports_modifiers(const struct Object *ob)
bool BKE_object_copy_modifier(struct Main *bmain, struct Scene *scene, struct Object *ob_dst, const struct Object *ob_src, struct ModifierData *md)
struct ModifierData * BKE_object_active_modifier(const struct Object *ob)
bool BKE_object_is_in_editmode(const struct Object *ob)
void BKE_object_eval_reset(struct Object *ob_eval)
Definition: object_update.c:54
Functions for dealing with objects and deform verts, used by painting and tools.
struct bDeformGroup * BKE_object_defgroup_add_name(struct Object *ob, const char *name)
Definition: object_deform.c:95
void BKE_ocean_bake(struct Ocean *o, struct OceanCache *och, void(*update_cb)(void *, float progress, int *cancel), void *update_cb_data)
struct OceanCache * BKE_ocean_init_cache(const char *bakepath, const char *relbase, int start, int end, float wave_scale, float chop_amount, float foam_coverage, float foam_fade, int resolution)
void BKE_ocean_free_modifier_cache(struct OceanModifierData *omd)
Definition: ocean.c:1717
struct Ocean * BKE_ocean_add(void)
Definition: ocean.c:1608
bool BKE_ocean_init_from_modifier(struct Ocean *ocean, struct OceanModifierData const *omd, int resolution)
void BKE_ocean_free(struct Ocean *oc)
Definition: ocean.c:1645
int BKE_sculpt_mask_layers_ensure(struct Object *ob, struct MultiresModifierData *mmd)
Definition: paint.c:1926
struct ParticleSystem * psys_eval_get(struct Depsgraph *depsgraph, struct Object *object, struct ParticleSystem *psys)
Definition: particle.c:761
void object_remove_particle_system(struct Main *bmain, struct Scene *scene, struct Object *ob, struct ParticleSystem *psys)
struct ModifierData * object_add_particle_system(struct Main *bmain, struct Scene *scene, struct Object *ob, const char *name)
Definition: particle.c:4002
void psys_apply_hair_lattice(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct ParticleSystem *psys)
Definition: particle.c:5233
struct ModifierData * object_copy_particle_system(struct Main *bmain, struct Scene *scene, struct Object *ob, const struct ParticleSystem *psys_orig)
General operations for point clouds.
void BKE_pointcloud_data_update(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *object)
Definition: pointcloud.cc:407
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition: report.c:83
struct SoftBody * sbNew(void)
Definition: softbody.c:3099
void sbFree(struct Object *ob)
Definition: softbody.c:3148
Volume data-block.
void BKE_volume_data_update(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *object)
Definition: volume.cc:1159
#define BLI_assert_unreachable()
Definition: BLI_assert.h:93
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define BLI_BITMAP_NEW(_num, _alloc_string)
Definition: BLI_bitmap.h:40
#define BLI_BITMAP_TEST(_bitmap, _index)
Definition: BLI_bitmap.h:64
#define BLI_BITMAP_ENABLE(_bitmap, _index)
Definition: BLI_bitmap.h:81
unsigned int BLI_bitmap
Definition: BLI_bitmap.h:16
struct GSet GSet
Definition: BLI_ghash.h:340
GSet * BLI_gset_ptr_new(const char *info)
void BLI_gset_free(GSet *gs, GSetKeyFreeFP keyfreefp)
Definition: BLI_ghash.c:1037
bool BLI_gset_add(GSet *gs, void *key)
Definition: BLI_ghash.c:969
void BLI_kdtree_nd_() free(KDTree *tree)
Definition: kdtree_impl.h:102
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
Definition: BLI_listbase.h:269
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:336
void BLI_insertlinkafter(struct ListBase *listbase, void *vprevlink, void *vnewlink) ATTR_NONNULL(1)
Definition: listbase.c:301
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:80
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:100
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLI_insertlinkbefore(struct ListBase *listbase, void *vnextlink, void *vnewlink) ATTR_NONNULL(1)
Definition: listbase.c:340
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLI_listbase_swaplinks(struct ListBase *listbase, void *vlinka, void *vlinkb) ATTR_NONNULL(1
MINLINE void copy_v3_v3(float r[3], const float a[3])
#define FILE_MAX
void BLI_path_rel(char *file, const char *relfile) ATTR_NONNULL()
Definition: path_util.c:450
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC
Definition: string.c:42
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
char * BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL(1
unsigned int uint
Definition: BLI_sys_types.h:67
#define UNUSED(x)
#define ELEM(...)
#define TIP_(msgid)
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
void DEG_id_tag_update(struct ID *id, int flag)
void DEG_relations_tag_update(struct Main *bmain)
struct Main * DEG_get_bmain(const Depsgraph *graph)
struct ViewLayer * DEG_get_input_view_layer(const Depsgraph *graph)
struct Object * DEG_get_evaluated_object(const struct Depsgraph *depsgraph, struct Object *object)
struct Scene * DEG_get_evaluated_scene(const struct Depsgraph *graph)
@ ID_RECALC_TRANSFORM
Definition: DNA_ID.h:771
@ ID_RECALC_COPY_ON_WRITE
Definition: DNA_ID.h:834
@ ID_RECALC_ANIMATION
Definition: DNA_ID.h:794
@ ID_RECALC_GEOMETRY
Definition: DNA_ID.h:791
@ LIB_FAKEUSER
Definition: DNA_ID.h:630
#define ID_REAL_USERS(id)
Definition: DNA_ID.h:553
#define ID_IS_OVERRIDE_LIBRARY(_id)
Definition: DNA_ID.h:588
@ ARM_DEF_VGROUP
@ ARM_DEF_QUATERNION
@ BONE_CONNECTED
@ ARM_LINE
@ CD_MVERT_SKIN
@ CD_MFACE
@ CD_MDEFORMVERT
@ CD_MEDGE
@ CD_MVERT
#define MAX_NAME
Definition: DNA_defs.h:48
@ KEY_RELATIVE
@ MVERT_SKIN_LOOSE
@ MVERT_SKIN_ROOT
@ ME_EDGEDRAW
@ ME_EDGERENDER
@ ME_LOOSEEDGE
@ MOD_SDEF_BIND
@ eModifierFlag_OverrideLibrary_Local
@ eModifierMode_Realtime
@ MOD_LAPLACIANDEFORM_BIND
ModifierType
@ eModifierType_ParticleSystem
@ eModifierType_MeshDeform
@ eModifierType_Explode
@ eModifierType_Subsurf
@ eModifierType_Surface
@ eModifierType_Skin
@ eModifierType_Cloth
@ eModifierType_Hook
@ eModifierType_Ocean
@ eModifierType_LaplacianDeform
@ eModifierType_Armature
@ eModifierType_SurfaceDeform
@ eModifierType_CorrectiveSmooth
@ eModifierType_Nodes
@ eModifierType_Collision
@ eModifierType_Softbody
@ eModifierType_Multires
@ eExplodeFlag_CalcFaces
@ OB_MODE_PARTICLE_EDIT
@ OB_MODE_SCULPT
#define OB_SB_EDGES
#define OB_SB_GOAL
@ OB_LATTICE
@ OB_MBALL
@ OB_SURF
@ OB_FONT
@ OB_ARMATURE
@ OB_MESH
@ OB_POINTCLOUD
@ OB_VOLUME
@ OB_CURVES_LEGACY
@ OB_CURVES
@ OB_GPENCIL
@ OB_DRAW_IN_FRONT
#define PART_DRAW_PATH
@ PART_DRAW_PARENT
@ PART_HAIR
#define OBACT(_view_layer)
@ FILE_SORT_DEFAULT
@ FILE_SPECIAL
@ FILE_TYPE_BTX
@ FILE_TYPE_FOLDER
@ FILE_DEFAULTDISPLAY
@ OPERATOR_CANCELLED
@ OPERATOR_FINISHED
@ OPERATOR_RUNNING_MODAL
@ OPERATOR_PASS_THROUGH
void ED_vgroup_vert_add(struct Object *ob, struct bDeformGroup *dg, int vertnum, float weight, int assignmode)
#define WEIGHT_REPLACE
Definition: ED_mesh.h:449
void ED_object_single_obdata_user(struct Main *bmain, struct Scene *scene, struct Object *ob)
@ MODIFIER_APPLY_DATA
Definition: ED_object.h:506
@ MODIFIER_APPLY_SHAPE
Definition: ED_object.h:507
struct Object * ED_object_active_context(const struct bContext *C)
bool ED_operator_object_active_editable(struct bContext *C)
Definition: screen_ops.c:396
bool ED_operator_object_active(struct bContext *C)
Definition: screen_ops.c:370
void ED_sculpt_undo_push_multires_mesh_begin(struct bContext *C, const char *str)
Definition: sculpt_undo.c:1940
void ED_sculpt_undo_push_multires_mesh_end(struct bContext *C, const char *str)
Definition: sculpt_undo.c:1956
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
Read Guarded memory(de)allocation.
#define MEM_SAFE_FREE(v)
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to curves
PropertyFlag
Definition: RNA_types.h:183
@ PROP_SKIP_SAVE
Definition: RNA_types.h:218
@ PROP_HIDDEN
Definition: RNA_types.h:216
#define C
Definition: RandGen.cpp:25
struct PointerRNA * UI_region_panel_custom_data_under_cursor(const struct bContext *C, const struct wmEvent *event)
@ WM_FILESEL_RELPATH
Definition: WM_api.h:752
@ WM_FILESEL_FILEPATH
Definition: WM_api.h:755
@ WM_JOB_PROGRESS
Definition: WM_api.h:1339
@ FILE_SAVE
Definition: WM_api.h:765
@ WM_JOB_TYPE_OBJECT_SIM_OCEAN
Definition: WM_api.h:1353
@ OPTYPE_INTERNAL
Definition: WM_types.h:168
@ OPTYPE_UNDO
Definition: WM_types.h:148
@ OPTYPE_REGISTER
Definition: WM_types.h:146
#define NC_WINDOW
Definition: WM_types.h:325
#define ND_MODE
Definition: WM_types.h:393
#define NC_SCENE
Definition: WM_types.h:328
#define ND_MODIFIER
Definition: WM_types.h:411
#define NS_MODE_OBJECT
Definition: WM_types.h:501
#define NC_OBJECT
Definition: WM_types.h:329
EditBone * ED_armature_ebone_add(bArmature *arm, const char *name)
Definition: armature_add.c:51
void ED_armature_edit_free(struct bArmature *arm)
void ED_armature_from_edit(Main *bmain, bArmature *arm)
@ BM_ELEM_SELECT
Definition: bmesh_class.h:471
#define BM_ELEM_CD_GET_VOID_P(ele, offset)
Definition: bmesh_class.h:541
#define BM_elem_flag_test(ele, hflag)
Definition: bmesh_inline.h:12
void BM_data_layer_free(BMesh *bm, CustomData *data, int type)
Definition: bmesh_interp.c:875
#define BM_ITER_ELEM(ele, iter, data, itype)
#define BM_ITER_MESH(ele, iter, bm, itype)
@ BM_VERTS_OF_MESH
@ BM_EDGES_OF_VERT
ATTR_WARN_UNUSED_RESULT BMesh * bm
BLI_INLINE BMVert * BM_edge_other_vert(BMEdge *e, const BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ATTR_WARN_UNUSED_RESULT const BMVert * v
MutableAttributeAccessor attributes_for_write()
static CurvesGeometry & wrap(::CurvesGeometry &dna_struct)
Definition: BKE_curves.hh:138
#define SELECT
Scene scene
Curve curve
const Depsgraph * depsgraph
Lattice lattice
Set< ComponentNode * > visited
DEGForeachIDComponentCallback callback
int users
Definition: editfont_undo.c:76
void * tree
int count
static const char * modifier_name[LS_MODIFIER_NUM]
Definition: linestyle.c:763
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_dupallocN)(const void *vmemh)
Definition: mallocn.c:28
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:33
#define G(x, y, z)
void ED_mesh_deform_bind_callback(Object *object, MeshDeformModifierData *mmd, Mesh *cagemesh, float *vertexcos, int verts_num, float cagemat[4][4])
static unsigned a[3]
Definition: RandGen.cpp:78
MutableAttributeAccessor mesh_attributes_for_write(Mesh &mesh)
static int laplaciandeform_bind_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static Mesh * modifier_apply_create_mesh_for_modifier(Depsgraph *depsgraph, Object *object, ModifierData *md_eval, bool use_virtual_modifiers, bool build_shapekey_layers)
void OBJECT_OT_multires_higher_levels_delete(wmOperatorType *ot)
static int modifier_convert_exec(bContext *C, wmOperator *op)
void OBJECT_OT_modifier_move_to_index(wmOperatorType *ot)
void OBJECT_OT_multires_unsubdivide(wmOperatorType *ot)
static int multires_external_save_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
void OBJECT_OT_skin_armature_create(wmOperatorType *ot)
static int modifier_remove_exec(bContext *C, wmOperator *op)
static int ocean_bake_exec(bContext *C, wmOperator *op)
static int multires_unsubdivide_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int meshdeform_bind_exec(bContext *C, wmOperator *op)
void OBJECT_OT_modifier_set_active(wmOperatorType *ot)
bool ED_object_multires_update_totlevels_cb(Object *ob, void *totlevel_v)
void OBJECT_OT_ocean_bake(wmOperatorType *ot)
void OBJECT_OT_multires_rebuild_subdiv(wmOperatorType *ot)
static int correctivesmooth_bind_exec(bContext *C, wmOperator *op)
static int modifier_add_exec(bContext *C, wmOperator *op)
void OBJECT_OT_modifier_remove(wmOperatorType *ot)
void OBJECT_OT_modifier_convert(wmOperatorType *ot)
bool ED_object_modifier_copy(ReportList *UNUSED(reports), Main *bmain, Scene *scene, Object *ob, ModifierData *md)
static int modifier_remove_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void oceanbake_startjob(void *customdata, short *stop, short *do_update, float *progress)
static bool modifier_apply_obdata(ReportList *reports, Depsgraph *depsgraph, Scene *scene, Object *ob, ModifierData *md_eval)
static int multires_base_apply_exec(bContext *C, wmOperator *op)
void OBJECT_OT_meshdeform_bind(wmOperatorType *ot)
void OBJECT_OT_explode_refresh(wmOperatorType *ot)
static int modifier_apply_as_shapekey_exec(bContext *C, wmOperator *op)
static bool modifier_apply_shape(Main *bmain, ReportList *reports, Depsgraph *depsgraph, Scene *scene, Object *ob, ModifierData *md_eval)
static int multires_higher_levels_delete_exec(bContext *C, wmOperator *op)
static bool modifier_apply_as_shapekey_poll(bContext *C)
void OBJECT_OT_skin_loose_mark_clear(wmOperatorType *ot)
static int modifier_set_active_exec(bContext *C, wmOperator *op)
static int multires_subdivide_exec(bContext *C, wmOperator *op)
static int multires_rebuild_subdiv_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static EnumPropertyItem prop_multires_subdivide_mode_type[]
void OBJECT_OT_multires_base_apply(wmOperatorType *ot)
void OBJECT_OT_modifier_move_up(wmOperatorType *ot)
static int modifier_move_up_exec(bContext *C, wmOperator *op)
static bool object_modifier_safe_to_delete(Main *bmain, Object *ob, ModifierData *exclude, ModifierType type)
void ED_object_modifier_clear(Main *bmain, Scene *scene, Object *ob)
void OBJECT_OT_modifier_copy(wmOperatorType *ot)
ModifierData * edit_modifier_property_get(wmOperator *op, Object *ob, int type)
static int meshdeform_bind_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static bool object_modifier_remove(Main *bmain, Scene *scene, Object *ob, ModifierData *md, bool *r_sort_depsgraph)
SkinLooseAction
@ SKIN_LOOSE_CLEAR
@ SKIN_LOOSE_MARK
bool ED_object_iter_other(Main *bmain, Object *orig_ob, const bool include_orig, bool(*callback)(Object *ob, void *callback_data), void *callback_data)
void OBJECT_OT_geometry_nodes_input_attribute_toggle(wmOperatorType *ot)
void OBJECT_OT_skin_root_mark(wmOperatorType *ot)
void OBJECT_OT_laplaciandeform_bind(wmOperatorType *ot)
void OBJECT_OT_multires_external_pack(wmOperatorType *ot)
static bool multires_poll(bContext *C)
static int ocean_bake_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int modifier_set_active_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int modifier_move_up_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void OBJECT_OT_modifier_apply_as_shapekey(wmOperatorType *ot)
static int modifier_apply_exec_ex(bContext *C, wmOperator *op, int apply_as, bool keep_modifier)
static int multires_rebuild_subdiv_exec(bContext *C, wmOperator *op)
static int multires_reshape_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
void edit_modifier_properties(wmOperatorType *ot)
static int explode_refresh_exec(bContext *C, wmOperator *op)
static int skin_armature_create_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int modifier_apply_exec(bContext *C, wmOperator *op)
void OBJECT_OT_modifier_apply(wmOperatorType *ot)
static Object * modifier_skin_armature_create(Depsgraph *depsgraph, Main *bmain, Object *skin_ob)
static int multires_base_apply_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static bool explode_poll(bContext *C)
static void edit_modifier_report_property(wmOperatorType *ot)
static int multires_subdivide_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static bool surfacedeform_bind_poll(bContext *C)
void OBJECT_OT_multires_reshape(wmOperatorType *ot)
void OBJECT_OT_modifier_copy_to_selected(wmOperatorType *ot)
static int oceanbake_breakjob(void *UNUSED(customdata))
void OBJECT_OT_skin_radii_equalize(wmOperatorType *ot)
static bool ocean_bake_poll(bContext *C)
static int geometry_nodes_input_attribute_toggle_exec(bContext *C, wmOperator *op)
static int skin_loose_mark_clear_exec(bContext *C, wmOperator *op)
static bool laplaciandeform_poll(bContext *C)
static int modifier_move_to_index_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int modifier_convert_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
void ED_object_modifier_link(bContext *C, Object *ob_dst, Object *ob_src)
bool ED_object_modifier_apply(Main *bmain, ReportList *reports, Depsgraph *depsgraph, Scene *scene, Object *ob, ModifierData *md, int mode, bool keep_modifier)
static int skin_armature_create_exec(bContext *C, wmOperator *op)
static int surfacedeform_bind_exec(bContext *C, wmOperator *op)
static bool skin_poll(bContext *C)
static int geometry_node_tree_copy_assign_exec(bContext *C, wmOperator *UNUSED(op))
bool ED_object_modifier_move_to_index(ReportList *reports, Object *ob, ModifierData *md, const int index)
static bool skin_edit_poll(bContext *C)
static int skin_radii_equalize_exec(bContext *C, wmOperator *UNUSED(op))
static bool correctivesmooth_poll(bContext *C)
static int skin_root_mark_exec(bContext *C, wmOperator *UNUSED(op))
static int explode_refresh_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
void OBJECT_OT_geometry_node_tree_copy_assign(wmOperatorType *ot)
static bool edit_modifier_invoke_properties_with_hover(bContext *C, wmOperator *op, const wmEvent *event, int *r_retval)
bool ED_object_modifier_move_down(ReportList *reports, Object *ob, ModifierData *md)
static int multires_external_pack_exec(bContext *C, wmOperator *UNUSED(op))
static bool modifier_apply_poll(bContext *C)
static int modifier_apply_as_shapekey_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int modifier_copy_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void OBJECT_OT_modifier_move_down(wmOperatorType *ot)
static bool object_has_modifier(const Object *ob, const ModifierData *exclude, ModifierType type)
static void oceanbake_endjob(void *customdata)
static int multires_reshape_exec(bContext *C, wmOperator *op)
static bool object_has_modifier_cb(Object *ob, void *data)
bool ED_object_modifier_convert_psys_to_mesh(ReportList *UNUSED(reports), Main *bmain, Depsgraph *depsgraph, ViewLayer *view_layer, Object *ob, ModifierData *md)
bool edit_modifier_invoke_properties(bContext *C, wmOperator *op)
static int multires_unsubdivide_exec(bContext *C, wmOperator *op)
void OBJECT_OT_correctivesmooth_bind(wmOperatorType *ot)
void OBJECT_OT_modifier_add(wmOperatorType *ot)
static const EnumPropertyItem * modifier_add_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free)
static void object_force_modifier_bind_simple_options(Depsgraph *depsgraph, Object *object, ModifierData *md)
bool ED_object_modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Object *ob, ModifierData *md)
static int multires_higher_levels_delete_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static void oceanbake_free(void *customdata)
bool edit_modifier_poll_generic(bContext *C, StructRNA *rna_type, int obtype_flag, const bool is_editmode_allowed, const bool is_liboverride_allowed)
static int modifier_copy_to_selected_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static bool modifier_copy_to_selected_poll(bContext *C)
static int multires_external_save_exec(bContext *C, wmOperator *op)
static int modifier_move_to_index_exec(bContext *C, wmOperator *op)
static void object_force_modifier_update_for_bind(Depsgraph *depsgraph, Object *ob)
static int modifier_apply_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int modifier_move_down_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int correctivesmooth_bind_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int modifier_copy_to_selected_exec(bContext *C, wmOperator *op)
void ED_object_modifier_copy_to_object(bContext *C, Object *ob_dst, Object *ob_src, ModifierData *md)
void OBJECT_OT_multires_subdivide(wmOperatorType *ot)
static int surfacedeform_bind_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static bool meshdeform_poll(bContext *C)
static bool edit_modifier_poll(bContext *C)
void OBJECT_OT_surfacedeform_bind(wmOperatorType *ot)
static int laplaciandeform_bind_exec(bContext *C, wmOperator *op)
static void skin_root_clear(BMVert *bm_vert, GSet *visited, const int cd_vert_skin_offset)
static void skin_armature_bone_create(Object *skin_ob, MVert *mvert, MEdge *medge, bArmature *arm, BLI_bitmap *edges_visited, const MeshElemMap *emap, EditBone *parent_bone, int parent_v)
static void oceanbake_update(void *customdata, float progress, int *cancel)
static int modifier_copy_exec(bContext *C, wmOperator *op)
static bool edit_modifier_liboverride_allowed_poll(bContext *C)
ModifierData * ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *scene, Object *ob, const char *name, int type)
bool ED_object_modifier_move_up(ReportList *reports, Object *ob, ModifierData *md)
void OBJECT_OT_multires_external_save(wmOperatorType *ot)
static void modifier_skin_customdata_delete(struct Object *ob)
static int modifier_move_down_exec(bContext *C, wmOperator *op)
static char * modifier_apply_as_shapekey_get_description(struct bContext *UNUSED(C), struct wmOperatorType *UNUSED(op), struct PointerRNA *values)
bool is_liboverride_allowed
bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
Definition: rna_access.c:695
void RNA_pointer_create(ID *id, StructRNA *type, void *data, PointerRNA *r_ptr)
Definition: rna_access.c:136
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
Definition: rna_access.c:5155
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:5271
void RNA_int_set(PointerRNA *ptr, const char *name, int value)
Definition: rna_access.c:4921
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
Definition: rna_access.c:717
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:2153
void RNA_string_get(PointerRNA *ptr, const char *name, char *value)
Definition: rna_access.c:5116
int RNA_int_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:4910
void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, bool value)
Definition: rna_access.c:2180
bool RNA_pointer_is_null(const PointerRNA *ptr)
Definition: rna_access.c:164
bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier)
Definition: rna_access.c:5301
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:4863
int RNA_enum_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:5004
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3493
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
Definition: rna_define.c:4487
void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
Definition: rna_define.c:4436
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3687
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1490
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
Definition: rna_define.c:3597
void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc)
Definition: rna_define.c:3830
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3783
const EnumPropertyItem rna_enum_object_modifier_type_items[]
Definition: rna_modifier.c:49
struct BMesh * bm
Definition: BKE_editmesh.h:40
void * data
Definition: bmesh_class.h:51
BMHeader head
Definition: bmesh_class.h:85
CustomData vdata
Definition: bmesh_class.h:337
CorrectiveSmoothDeltaCache delta_cache
ListBase nurb
CurvesGeometry geometry
char name[64]
Definition: BKE_armature.h:43
float tail[3]
Definition: BKE_armature.h:54
struct EditBone * parent
Definition: BKE_armature.h:41
float rad_tail
Definition: BKE_armature.h:68
float rad_head
Definition: BKE_armature.h:68
float head[3]
Definition: BKE_armature.h:53
const char * identifier
Definition: RNA_types.h:461
GeometryComponent & get_component_for_write(GeometryComponentType component_type)
Curves * get_curves_for_write()
bool has_curves() const
Definition: DNA_ID.h:368
int us
Definition: DNA_ID.h:388
short flag
Definition: DNA_ID.h:383
void * next
Definition: DNA_ID.h:369
char name[66]
Definition: DNA_ID.h:378
char type
Definition: DNA_key_types.h:94
void * first
Definition: DNA_listBase.h:31
unsigned int v1
unsigned int v2
float co[3]
Definition: BKE_main.h:121
ListBase objects
Definition: BKE_main.h:170
void(* bindfunc)(struct Object *object, struct MeshDeformModifierData *mmd, struct Mesh *cagemesh, float *vertexcos, int verts_num, float cagemat[4][4])
MDefInfluence * bindinfluences
MDefInfluence * dyninfluences
struct MEdge * medge
struct BMEditMesh * edit_mesh
CustomData vdata
struct MVert * mvert
int totedge
int totvert
CustomData fdata
CustomData edata
int totloop
struct Key * key
struct MFace * mface
CustomData ldata
struct ModifierData * next
struct ModifierData * prev
bool(* isDisabled)(const struct Scene *scene, struct ModifierData *md, bool userRenderParams)
Definition: BKE_modifier.h:291
void(* modifyGeometrySet)(struct ModifierData *md, const struct ModifierEvalContext *ctx, struct GeometrySet *geometry_set)
Definition: BKE_modifier.h:240
ModifierTypeFlag flags
Definition: BKE_modifier.h:161
ModifierTypeType type
Definition: BKE_modifier.h:160
void(* deformVerts)(struct ModifierData *md, const struct ModifierEvalContext *ctx, struct Mesh *mesh, float(*vertexCos)[3], int numVerts)
Definition: BKE_modifier.h:184
struct bNodeTree * node_group
ListBase particlesystem
ListBase modifiers
struct PartDeflect * pd
struct SoftBody * soft
short softflag
void * data
struct OceanCache * och
struct OceanModifierData * omd
struct Ocean * ocean
struct Object * owner
float * time
Definition: BKE_ocean.h:42
int duration
Definition: BKE_ocean.h:52
struct OceanCache * oceancache
ParticleSettings * part
struct ParticleCacheKey ** childcache
struct ParticleCacheKey ** pathcache
struct StructRNA * type
Definition: RNA_types.h:37
void * data
Definition: RNA_types.h:38
struct ID * owner_id
Definition: RNA_types.h:36
struct RenderData r
unsigned int layer
ListBase * edbo
Definition: wm_jobs.c:57
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:919
const char * name
Definition: WM_types.h:888
const char * idname
Definition: WM_types.h:890
char *(* get_description)(struct bContext *C, struct wmOperatorType *, struct PointerRNA *)
Definition: WM_types.h:966
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:943
struct StructRNA * srna
Definition: WM_types.h:969
const char * description
Definition: WM_types.h:893
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:903
PropertyRNA * prop
Definition: WM_types.h:981
struct ReportList * reports
struct wmOperatorType * type
struct PointerRNA * ptr
ccl_device_inline int mod(int x, int m)
Definition: util/math.h:490
void WM_main_add_notifier(unsigned int type, void *reference)
void WM_event_add_fileselect(bContext *C, wmOperator *op)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
PointerRNA * ptr
Definition: wm_files.c:3480
wmOperatorType * ot
Definition: wm_files.c:3479
void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job)
Definition: wm_jobs.c:437
void WM_jobs_callbacks(wmJob *wm_job, wm_jobs_start_callback startjob, void(*initjob)(void *), void(*update)(void *), void(*endjob)(void *))
Definition: wm_jobs.c:351
void WM_jobs_customdata_set(wmJob *wm_job, void *customdata, void(*free)(void *))
Definition: wm_jobs.c:323
void WM_jobs_timer(wmJob *wm_job, double timestep, unsigned int note, unsigned int endnote)
Definition: wm_jobs.c:339
wmJob * WM_jobs_get(wmWindowManager *wm, wmWindow *win, const void *owner, const char *name, int flag, int job_type)
Definition: wm_jobs.c:184
void WM_operator_properties_filesel(wmOperatorType *ot, const int filter, const short type, const eFileSel_Action action, const eFileSel_Flag flag, const short display, const short sort)
int WM_operator_confirm_message(bContext *C, wmOperator *op, const char *message)
int WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))