Blender  V2.93
object_modifier.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
24 #include <math.h>
25 #include <stdio.h>
26 #include <stdlib.h>
27 
28 #include "MEM_guardedalloc.h"
29 
30 #include "DNA_anim_types.h"
31 #include "DNA_armature_types.h"
32 #include "DNA_curve_types.h"
33 #include "DNA_dynamicpaint_types.h"
34 #include "DNA_fluid_types.h"
35 #include "DNA_key_types.h"
36 #include "DNA_lattice_types.h"
37 #include "DNA_mesh_types.h"
38 #include "DNA_meshdata_types.h"
39 #include "DNA_object_force_types.h"
40 #include "DNA_scene_types.h"
41 #include "DNA_space_types.h"
42 
43 #include "BLI_bitmap.h"
44 #include "BLI_listbase.h"
45 #include "BLI_math.h"
46 #include "BLI_path_util.h"
47 #include "BLI_string.h"
48 #include "BLI_string_utf8.h"
49 #include "BLI_utildefines.h"
50 
51 #include "BKE_DerivedMesh.h"
52 #include "BKE_animsys.h"
53 #include "BKE_armature.h"
54 #include "BKE_context.h"
55 #include "BKE_curve.h"
56 #include "BKE_displist.h"
57 #include "BKE_editmesh.h"
58 #include "BKE_effect.h"
59 #include "BKE_global.h"
60 #include "BKE_gpencil_modifier.h"
61 #include "BKE_hair.h"
62 #include "BKE_key.h"
63 #include "BKE_lattice.h"
64 #include "BKE_lib_id.h"
65 #include "BKE_main.h"
66 #include "BKE_mesh.h"
67 #include "BKE_mesh_mapping.h"
68 #include "BKE_mesh_runtime.h"
69 #include "BKE_modifier.h"
70 #include "BKE_multires.h"
71 #include "BKE_object.h"
72 #include "BKE_object_deform.h"
73 #include "BKE_ocean.h"
74 #include "BKE_paint.h"
75 #include "BKE_particle.h"
76 #include "BKE_pointcloud.h"
77 #include "BKE_report.h"
78 #include "BKE_scene.h"
79 #include "BKE_softbody.h"
80 #include "BKE_volume.h"
81 
82 #include "DEG_depsgraph.h"
83 #include "DEG_depsgraph_build.h"
84 #include "DEG_depsgraph_query.h"
85 
86 #include "RNA_access.h"
87 #include "RNA_define.h"
88 #include "RNA_enum_types.h"
89 
90 #include "ED_armature.h"
91 #include "ED_mesh.h"
92 #include "ED_object.h"
93 #include "ED_screen.h"
94 #include "ED_sculpt.h"
95 
96 #include "MOD_nodes.h"
97 
98 #include "UI_interface.h"
99 
100 #include "WM_api.h"
101 #include "WM_types.h"
102 
103 #include "object_intern.h"
104 
105 static void modifier_skin_customdata_delete(struct Object *ob);
106 
107 /* ------------------------------------------------------------------- */
112 {
113  Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
114  Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
115  BKE_object_eval_reset(ob_eval);
116  if (ob->type == OB_MESH) {
117  Mesh *me_eval = mesh_create_eval_final(depsgraph, scene_eval, ob_eval, &CD_MASK_BAREMESH);
118  BKE_mesh_eval_delete(me_eval);
119  }
120  else if (ob->type == OB_LATTICE) {
121  BKE_lattice_modifiers_calc(depsgraph, scene_eval, ob_eval);
122  }
123  else if (ob->type == OB_MBALL) {
124  BKE_displist_make_mball(depsgraph, scene_eval, ob_eval);
125  }
126  else if (ELEM(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
127  BKE_displist_make_curveTypes(depsgraph, scene_eval, ob_eval, false, false);
128  }
129  else if (ob->type == OB_GPENCIL) {
130  BKE_gpencil_modifiers_calc(depsgraph, scene_eval, ob_eval);
131  }
132  else if (ob->type == OB_HAIR) {
133  BKE_hair_data_update(depsgraph, scene_eval, ob);
134  }
135  else if (ob->type == OB_POINTCLOUD) {
136  BKE_pointcloud_data_update(depsgraph, scene_eval, ob);
137  }
138  else if (ob->type == OB_VOLUME) {
139  BKE_volume_data_update(depsgraph, scene_eval, ob);
140  }
141 }
142 
144  Object *object,
145  ModifierData *md)
146 {
148  const int mode = md_eval->mode;
149  md_eval->mode |= eModifierMode_Realtime;
151  md_eval->mode = mode;
152 }
153 
161  ReportList *reports, Main *bmain, Scene *scene, Object *ob, const char *name, int type)
162 {
163  ModifierData *md = NULL, *new_md = NULL;
165 
166  /* Check compatibility of modifier [T25291, T50373]. */
168  BKE_reportf(reports, RPT_WARNING, "Modifiers cannot be added to object '%s'", ob->id.name + 2);
169  return NULL;
170  }
171 
172  if (mti->flags & eModifierTypeFlag_Single) {
173  if (BKE_modifiers_findby_type(ob, type)) {
174  BKE_report(reports, RPT_WARNING, "Only one modifier of this type is allowed");
175  return NULL;
176  }
177  }
178 
180  /* don't need to worry about the new modifier's name, since that is set to the number
181  * of particle systems which shouldn't have too many duplicates
182  */
183  new_md = object_add_particle_system(bmain, scene, ob, name);
184  }
185  else {
186  /* get new modifier data to add */
187  new_md = BKE_modifier_new(type);
188 
190  md = ob->modifiers.first;
191 
193  md = md->next;
194  }
195 
196  BLI_insertlinkbefore(&ob->modifiers, md, new_md);
197  }
198  else {
199  BLI_addtail(&ob->modifiers, new_md);
200  }
201 
202  if (name) {
203  BLI_strncpy_utf8(new_md->name, name, sizeof(new_md->name));
204  }
205 
206  /* make sure modifier data has unique name */
207 
208  BKE_modifier_unique_name(&ob->modifiers, new_md);
209 
210  /* special cases */
211  if (type == eModifierType_Softbody) {
212  if (!ob->soft) {
213  ob->soft = sbNew(scene);
215  }
216  }
217  else if (type == eModifierType_Collision) {
218  if (!ob->pd) {
219  ob->pd = BKE_partdeflect_new(0);
220  }
221 
222  ob->pd->deflect = 1;
223  }
224  else if (type == eModifierType_Surface) {
225  /* pass */
226  }
227  else if (type == eModifierType_Multires) {
228  /* set totlvl from existing MDISPS layer if object already had it */
230 
231  if (ob->mode & OB_MODE_SCULPT) {
232  /* ensure that grid paint mask layer is created */
234  }
235  }
236  else if (type == eModifierType_Skin) {
237  /* ensure skin-node customdata exists */
239  }
240  else if (type == eModifierType_Nodes) {
241  MOD_nodes_init(bmain, (NodesModifierData *)new_md);
242  }
243  }
244 
245  BKE_object_modifier_set_active(ob, new_md);
246 
249 
250  return new_md;
251 }
252 
253 /* Return true if the object has a modifier of type 'type' other than
254  * the modifier pointed to be 'exclude', otherwise returns false. */
255 static bool object_has_modifier(const Object *ob, const ModifierData *exclude, ModifierType type)
256 {
257  LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
258  if ((md != exclude) && (md->type == type)) {
259  return true;
260  }
261  }
262 
263  return false;
264 }
265 
266 /* If the object data of 'orig_ob' has other users, run 'callback' on
267  * each of them.
268  *
269  * If include_orig is true, the callback will run on 'orig_ob' too.
270  *
271  * If the callback ever returns true, iteration will stop and the
272  * function value will be true. Otherwise the function returns false.
273  */
275  Object *orig_ob,
276  const bool include_orig,
277  bool (*callback)(Object *ob, void *callback_data),
278  void *callback_data)
279 {
280  ID *ob_data_id = orig_ob->data;
281  int users = ob_data_id->us;
282 
283  if (ob_data_id->flag & LIB_FAKEUSER) {
284  users--;
285  }
286 
287  /* First check that the object's data has multiple users */
288  if (users > 1) {
289  Object *ob;
290  int totfound = include_orig ? 0 : 1;
291 
292  for (ob = bmain->objects.first; ob && totfound < users; ob = ob->id.next) {
293  if (((ob != orig_ob) || include_orig) && (ob->data == orig_ob->data)) {
294  if (callback(ob, callback_data)) {
295  return true;
296  }
297 
298  totfound++;
299  }
300  }
301  }
302  else if (include_orig) {
303  return callback(orig_ob, callback_data);
304  }
305 
306  return false;
307 }
308 
309 static bool object_has_modifier_cb(Object *ob, void *data)
310 {
312 
313  return object_has_modifier(ob, NULL, type);
314 }
315 
316 /* Use with ED_object_iter_other(). Sets the total number of levels
317  * for any multires modifiers on the object to the int pointed to by
318  * callback_data. */
320 {
321  int totlevel = *((char *)totlevel_v);
322 
323  LISTBASE_FOREACH (ModifierData *, md, &ob->modifiers) {
324  if (md->type == eModifierType_Multires) {
325  multires_set_tot_level(ob, (MultiresModifierData *)md, totlevel);
327  }
328  }
329  return false;
330 }
331 
332 /* Return true if no modifier of type 'type' other than 'exclude' */
334  Object *ob,
335  ModifierData *exclude,
337 {
338  return (!object_has_modifier(ob, exclude, type) &&
339  !ED_object_iter_other(bmain, ob, false, object_has_modifier_cb, &type));
340 }
341 
343  Main *bmain, Scene *scene, Object *ob, ModifierData *md, bool *r_sort_depsgraph)
344 {
345  /* It seems on rapid delete it is possible to
346  * get called twice on same modifier, so make
347  * sure it is in list. */
348  if (BLI_findindex(&ob->modifiers, md) == -1) {
349  return false;
350  }
351 
352  /* special cases */
353  if (md->type == eModifierType_ParticleSystem) {
355  return true;
356  }
357 
358  if (md->type == eModifierType_Softbody) {
359  if (ob->soft) {
360  sbFree(ob);
361  ob->softflag = 0; /* TODO(Sybren): this should probably be moved into sbFree() */
362  }
363  }
364  else if (md->type == eModifierType_Collision) {
365  if (ob->pd) {
366  ob->pd->deflect = 0;
367  }
368 
369  *r_sort_depsgraph = true;
370  }
371  else if (md->type == eModifierType_Surface) {
372  *r_sort_depsgraph = true;
373  }
374  else if (md->type == eModifierType_Multires) {
375  /* Delete MDisps layer if not used by another multires modifier */
378  }
379  }
380  else if (md->type == eModifierType_Skin) {
381  /* Delete MVertSkin layer if not used by another skin modifier */
384  }
385  }
386 
389  ob->mode &= ~OB_MODE_PARTICLE_EDIT;
390  }
391 
393  BKE_modifier_free(md);
395 
396  return true;
397 }
398 
400  ReportList *reports, Main *bmain, Scene *scene, Object *ob, ModifierData *md)
401 {
402  bool sort_depsgraph = false;
403 
404  bool ok = object_modifier_remove(bmain, scene, ob, md, &sort_depsgraph);
405 
406  if (!ok) {
407  BKE_reportf(reports, RPT_ERROR, "Modifier '%s' not in object '%s'", md->name, ob->id.name);
408  return false;
409  }
410 
413 
414  return true;
415 }
416 
418 {
419  ModifierData *md = ob->modifiers.first;
420  bool sort_depsgraph = false;
421 
422  if (!md) {
423  return;
424  }
425 
426  while (md) {
427  ModifierData *next_md = md->next;
428 
429  object_modifier_remove(bmain, scene, ob, md, &sort_depsgraph);
430 
431  md = next_md;
432  }
433 
436 }
437 
439 {
440  if (md->prev) {
441  const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
442 
443  if (mti->type != eModifierTypeType_OnlyDeform) {
444  const ModifierTypeInfo *nmti = BKE_modifier_get_info(md->prev->type);
445 
447  BKE_report(reports, RPT_WARNING, "Cannot move above a modifier requiring original data");
448  return false;
449  }
450  }
451 
452  BLI_listbase_swaplinks(&ob->modifiers, md, md->prev);
453  }
454  else {
455  BKE_report(reports, RPT_WARNING, "Cannot move modifier beyond the start of the list");
456  return false;
457  }
458 
459  return true;
460 }
461 
463 {
464  if (md->next) {
465  const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
466 
468  const ModifierTypeInfo *nmti = BKE_modifier_get_info(md->next->type);
469 
470  if (nmti->type != eModifierTypeType_OnlyDeform) {
471  BKE_report(reports, RPT_WARNING, "Cannot move beyond a non-deforming modifier");
472  return false;
473  }
474  }
475 
476  BLI_listbase_swaplinks(&ob->modifiers, md, md->next);
477  }
478  else {
479  BKE_report(reports, RPT_WARNING, "Cannot move modifier beyond the end of the list");
480  return false;
481  }
482 
483  return true;
484 }
485 
487  Object *ob,
488  ModifierData *md,
489  const int index)
490 {
491  BLI_assert(md != NULL);
492  BLI_assert(index >= 0);
493  if (index >= BLI_listbase_count(&ob->modifiers)) {
494  BKE_report(reports, RPT_WARNING, "Cannot move modifier beyond the end of the stack");
495  return false;
496  }
497 
498  int md_index = BLI_findindex(&ob->modifiers, md);
499  BLI_assert(md_index != -1);
500  if (md_index < index) {
501  /* Move modifier down in list. */
502  for (; md_index < index; md_index++) {
503  if (!ED_object_modifier_move_down(reports, ob, md)) {
504  break;
505  }
506  }
507  }
508  else {
509  /* Move modifier up in list. */
510  for (; md_index > index; md_index--) {
511  if (!ED_object_modifier_move_up(reports, ob, md)) {
512  break;
513  }
514  }
515  }
516 
519 
520  return true;
521 }
522 
524 {
525  BKE_object_link_modifiers(ob_dst, ob_src);
528 
529  Main *bmain = CTX_data_main(C);
531 }
532 
534  Object *ob_dst,
535  Object *ob_src,
536  ModifierData *md)
537 {
538  BKE_object_copy_modifier(CTX_data_main(C), CTX_data_scene(C), ob_dst, ob_src, md);
541 
542  Main *bmain = CTX_data_main(C);
544 }
545 
547  Main *bmain,
549  ViewLayer *view_layer,
550  Object *ob,
551  ModifierData *md)
552 {
553  int cvert = 0;
554 
555  if (md->type != eModifierType_ParticleSystem) {
556  return false;
557  }
558  if (ob && ob->mode & OB_MODE_PARTICLE_EDIT) {
559  return false;
560  }
561 
562  ParticleSystem *psys_orig = ((ParticleSystemModifierData *)md)->psys;
563  ParticleSettings *part = psys_orig->part;
564 
565  if (part->ren_as != PART_DRAW_PATH) {
566  return false;
567  }
568  ParticleSystem *psys_eval = psys_eval_get(depsgraph, ob, psys_orig);
569  if (psys_eval->pathcache == NULL) {
570  return false;
571  }
572 
573  int totpart = psys_eval->totcached;
574  int totchild = psys_eval->totchildcache;
575 
576  if (totchild && (part->draw & PART_DRAW_PARENT) == 0) {
577  totpart = 0;
578  }
579 
580  /* count */
581  int totvert = 0, totedge = 0;
582  ParticleCacheKey **cache = psys_eval->pathcache;
583  for (int a = 0; a < totpart; a++) {
584  ParticleCacheKey *key = cache[a];
585 
586  if (key->segments > 0) {
587  totvert += key->segments + 1;
588  totedge += key->segments;
589  }
590  }
591 
592  cache = psys_eval->childcache;
593  for (int a = 0; a < totchild; a++) {
594  ParticleCacheKey *key = cache[a];
595 
596  if (key->segments > 0) {
597  totvert += key->segments + 1;
598  totedge += key->segments;
599  }
600  }
601 
602  if (totvert == 0) {
603  return false;
604  }
605 
606  /* add new mesh */
607  Object *obn = BKE_object_add(bmain, view_layer, OB_MESH, NULL);
608  Mesh *me = obn->data;
609 
610  me->totvert = totvert;
611  me->totedge = totedge;
612 
613  me->mvert = CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, totvert);
614  me->medge = CustomData_add_layer(&me->edata, CD_MEDGE, CD_CALLOC, NULL, totedge);
616 
617  MVert *mvert = me->mvert;
618  MEdge *medge = me->medge;
619 
620  /* copy coordinates */
621  cache = psys_eval->pathcache;
622  for (int a = 0; a < totpart; a++) {
623  ParticleCacheKey *key = cache[a];
624  int kmax = key->segments;
625  for (int k = 0; k <= kmax; k++, key++, cvert++, mvert++) {
626  copy_v3_v3(mvert->co, key->co);
627  if (k) {
628  medge->v1 = cvert - 1;
629  medge->v2 = cvert;
631  medge++;
632  }
633  else {
634  /* cheap trick to select the roots */
635  mvert->flag |= SELECT;
636  }
637  }
638  }
639 
640  cache = psys_eval->childcache;
641  for (int a = 0; a < totchild; a++) {
642  ParticleCacheKey *key = cache[a];
643  int kmax = key->segments;
644  for (int k = 0; k <= kmax; k++, key++, cvert++, mvert++) {
645  copy_v3_v3(mvert->co, key->co);
646  if (k) {
647  medge->v1 = cvert - 1;
648  medge->v2 = cvert;
650  medge++;
651  }
652  else {
653  /* cheap trick to select the roots */
654  mvert->flag |= SELECT;
655  }
656  }
657  }
658 
660 
661  return true;
662 }
663 
664 /* Gets mesh for the modifier which corresponds to an evaluated state. */
666  Object *object,
667  ModifierData *md_eval,
668  bool build_shapekey_layers)
669 {
670  Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
671  Object *object_eval = DEG_get_evaluated_object(depsgraph, object);
673  depsgraph, scene_eval, object_eval, md_eval, build_shapekey_layers);
674  return mesh_applied;
675 }
676 
677 static bool modifier_apply_shape(Main *bmain,
678  ReportList *reports,
680  Scene *scene,
681  Object *ob,
682  ModifierData *md_eval)
683 {
684  const ModifierTypeInfo *mti = BKE_modifier_get_info(md_eval->type);
685 
686  if (mti->isDisabled && mti->isDisabled(scene, md_eval, 0)) {
687  BKE_report(reports, RPT_ERROR, "Modifier is disabled, skipping apply");
688  return false;
689  }
690 
691  /* We could investigate using the #CD_ORIGINDEX layer
692  * to support other kinds of modifiers besides deforming modifiers.
693  * as this is done in many other places, see: #BKE_mesh_foreach_mapped_vert_coords_get.
694  *
695  * This isn't high priority in practice since most modifiers users
696  * want to apply as a shape are deforming modifiers.
697  *
698  * If a compelling use-case comes up where we want to support other kinds of modifiers
699  * we can look into supporting them. */
700 
701  if (ob->type == OB_MESH) {
702  Mesh *me = ob->data;
703  Key *key = me->key;
704 
706  BKE_report(reports, RPT_ERROR, "Only deforming modifiers can be applied to shapes");
707  return false;
708  }
709 
710  Mesh *mesh_applied = modifier_apply_create_mesh_for_modifier(depsgraph, ob, md_eval, false);
711  if (!mesh_applied) {
712  BKE_report(reports, RPT_ERROR, "Modifier is disabled or returned error, skipping apply");
713  return false;
714  }
715 
716  if (key == NULL) {
717  key = me->key = BKE_key_add(bmain, (ID *)me);
718  key->type = KEY_RELATIVE;
719  /* if that was the first key block added, then it was the basis.
720  * Initialize it with the mesh, and add another for the modifier */
721  KeyBlock *kb = BKE_keyblock_add(key, NULL);
722  BKE_keyblock_convert_from_mesh(me, key, kb);
723  }
724 
725  KeyBlock *kb = BKE_keyblock_add(key, md_eval->name);
726  BKE_mesh_nomain_to_meshkey(mesh_applied, me, kb);
727 
728  BKE_id_free(NULL, mesh_applied);
729  }
730  else {
731  /* TODO: implement for hair, point-clouds and volumes. */
732  BKE_report(reports, RPT_ERROR, "Cannot apply modifier for this object type");
733  return false;
734  }
735  return true;
736 }
737 
739  ReportList *reports, Depsgraph *depsgraph, Scene *scene, Object *ob, ModifierData *md_eval)
740 {
741  const ModifierTypeInfo *mti = BKE_modifier_get_info(md_eval->type);
742 
743  if (mti->isDisabled && mti->isDisabled(scene, md_eval, 0)) {
744  BKE_report(reports, RPT_ERROR, "Modifier is disabled, skipping apply");
745  return false;
746  }
747 
748  if (ob->type == OB_MESH) {
749  Mesh *me = ob->data;
751 
752  if (me->key && mti->type != eModifierTypeType_NonGeometrical) {
753  BKE_report(reports, RPT_ERROR, "Modifier cannot be applied to a mesh with shape keys");
754  return false;
755  }
756 
757  /* Multires: ensure that recent sculpting is applied */
758  if (md_eval->type == eModifierType_Multires) {
760  }
761 
762  if (mmd && mmd->totlvl && mti->type == eModifierTypeType_OnlyDeform) {
763  if (!multiresModifier_reshapeFromDeformModifier(depsgraph, ob, mmd, md_eval)) {
764  BKE_report(reports, RPT_ERROR, "Multires modifier returned error, skipping apply");
765  return false;
766  }
767  }
768  else {
769  Mesh *mesh_applied = modifier_apply_create_mesh_for_modifier(depsgraph, ob, md_eval, true);
770  if (!mesh_applied) {
771  BKE_report(reports, RPT_ERROR, "Modifier returned error, skipping apply");
772  return false;
773  }
774 
775  BKE_mesh_nomain_to_mesh(mesh_applied, me, ob, &CD_MASK_MESH, true);
776 
777  if (md_eval->type == eModifierType_Multires) {
779  }
780  }
781  }
782  else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
783  Object *object_eval = DEG_get_evaluated_object(depsgraph, ob);
784  Curve *curve = ob->data;
785  Curve *curve_eval = (Curve *)object_eval->data;
786  ModifierEvalContext mectx = {depsgraph, object_eval, 0};
787 
789  BKE_report(
790  reports, RPT_ERROR, "Transform curve to mesh in order to apply constructive modifiers");
791  return false;
792  }
793 
794  BKE_report(reports,
795  RPT_INFO,
796  "Applied modifier only changed CV points, not tessellated/bevel vertices");
797 
798  int numVerts;
799  float(*vertexCos)[3] = BKE_curve_nurbs_vert_coords_alloc(&curve_eval->nurb, &numVerts);
800  mti->deformVerts(md_eval, &mectx, NULL, vertexCos, numVerts);
801  BKE_curve_nurbs_vert_coords_apply(&curve->nurb, vertexCos, false);
802 
803  MEM_freeN(vertexCos);
804 
806  }
807  else if (ob->type == OB_LATTICE) {
808  Object *object_eval = DEG_get_evaluated_object(depsgraph, ob);
809  Lattice *lattice = ob->data;
810  ModifierEvalContext mectx = {depsgraph, object_eval, 0};
811 
813  BKE_report(reports, RPT_ERROR, "Constructive modifiers cannot be applied");
814  return false;
815  }
816 
817  int numVerts;
818  float(*vertexCos)[3] = BKE_lattice_vert_coords_alloc(lattice, &numVerts);
819  mti->deformVerts(md_eval, &mectx, NULL, vertexCos, numVerts);
821 
822  MEM_freeN(vertexCos);
823 
825  }
826  else {
827  /* TODO: implement for hair, point-clouds and volumes. */
828  BKE_report(reports, RPT_ERROR, "Cannot apply modifier for this object type");
829  return false;
830  }
831 
832  /* lattice modifier can be applied to particle system too */
833  if (ob->particlesystem.first) {
834  LISTBASE_FOREACH (ParticleSystem *, psys, &ob->particlesystem) {
835  if (psys->part->type != PART_HAIR) {
836  continue;
837  }
838 
840  }
841  }
842 
843  return true;
844 }
845 
847  ReportList *reports,
849  Scene *scene,
850  Object *ob,
851  ModifierData *md,
852  int mode,
853  bool keep_modifier)
854 {
855  if (BKE_object_is_in_editmode(ob)) {
856  BKE_report(reports, RPT_ERROR, "Modifiers cannot be applied in edit mode");
857  return false;
858  }
859  if (mode != MODIFIER_APPLY_SHAPE && ID_REAL_USERS(ob->data) > 1) {
860  BKE_report(reports, RPT_ERROR, "Modifiers cannot be applied to multi-user data");
861  return false;
862  }
863  if ((ob->mode & OB_MODE_SCULPT) && (find_multires_modifier_before(scene, md)) &&
864  (BKE_modifier_is_same_topology(md) == false)) {
865  BKE_report(reports,
866  RPT_ERROR,
867  "Constructive modifier cannot be applied to multi-res data in sculpt mode");
868  return false;
869  }
870 
871  if (md != ob->modifiers.first) {
872  BKE_report(reports, RPT_INFO, "Applied modifier was not first, result may not be as expected");
873  }
874 
875  /* Get evaluated modifier, so object links pointer to evaluated data,
876  * but still use original object it is applied to the original mesh. */
877  Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
878  ModifierData *md_eval = (ob_eval) ? BKE_modifiers_findby_name(ob_eval, md->name) : md;
879 
880  /* allow apply of a not-realtime modifier, by first re-enabling realtime. */
881  int prev_mode = md_eval->mode;
882  md_eval->mode |= eModifierMode_Realtime;
883 
884  if (mode == MODIFIER_APPLY_SHAPE) {
885  if (!modifier_apply_shape(bmain, reports, depsgraph, scene, ob, md_eval)) {
886  md_eval->mode = prev_mode;
887  return false;
888  }
889  }
890  else {
891  if (!modifier_apply_obdata(reports, depsgraph, scene, ob, md_eval)) {
892  md_eval->mode = prev_mode;
893  return false;
894  }
895  }
896 
897  md_eval->mode = prev_mode;
898 
899  if (!keep_modifier) {
901  BKE_modifier_free(md);
902  }
903 
905 
906  return true;
907 }
908 
910  ReportList *UNUSED(reports), Main *bmain, Scene *scene, Object *ob, ModifierData *md)
911 {
912  if (md->type == eModifierType_ParticleSystem) {
914  bmain, scene, ob, ((ParticleSystemModifierData *)md)->psys);
915  BLI_remlink(&ob->modifiers, nmd);
916  BLI_insertlinkafter(&ob->modifiers, md, nmd);
918  return true;
919  }
920 
921  ModifierData *nmd = BKE_modifier_new(md->type);
922  BKE_modifier_copydata(md, nmd);
923  BLI_insertlinkafter(&ob->modifiers, md, nmd);
926 
928 
929  return true;
930 }
931 
934 /* ------------------------------------------------------------------- */
939 {
940  Main *bmain = CTX_data_main(C);
943  int type = RNA_enum_get(op->ptr, "type");
944 
945  if (!ED_object_modifier_add(op->reports, bmain, scene, ob, NULL, type)) {
946  return OPERATOR_CANCELLED;
947  }
948 
950 
951  return OPERATOR_FINISHED;
952 }
953 
956  PropertyRNA *UNUSED(prop),
957  bool *r_free)
958 {
960 
961  if (!ob) {
963  }
964 
965  EnumPropertyItem *items = NULL;
966  int totitem = 0;
967 
968  const EnumPropertyItem *group_item = NULL;
969  for (int a = 0; rna_enum_object_modifier_type_items[a].identifier; a++) {
971 
972  if (md_item->identifier[0]) {
973  const ModifierTypeInfo *mti = BKE_modifier_get_info(md_item->value);
974 
975  if (mti->flags & eModifierTypeFlag_NoUserAdd) {
976  continue;
977  }
978 
979  if (!BKE_object_support_modifier_type_check(ob, md_item->value)) {
980  continue;
981  }
982  }
983  else {
984  group_item = md_item;
985  continue;
986  }
987 
988  if (group_item) {
989  RNA_enum_item_add(&items, &totitem, group_item);
990  group_item = NULL;
991  }
992 
993  RNA_enum_item_add(&items, &totitem, md_item);
994  }
995 
996  RNA_enum_item_end(&items, &totitem);
997  *r_free = true;
998 
999  return items;
1000 }
1001 
1003 {
1004  PropertyRNA *prop;
1005 
1006  /* identifiers */
1007  ot->name = "Add Modifier";
1008  ot->description = "Add a procedural operation/effect to the active object";
1009  ot->idname = "OBJECT_OT_modifier_add";
1010 
1011  /* api callbacks */
1015 
1016  /* flags */
1018 
1019  /* properties */
1020  prop = RNA_def_enum(
1023  ot->prop = prop;
1024 }
1025 
1028 /* ------------------------------------------------------------------- */
1035  StructRNA *rna_type,
1036  int obtype_flag,
1037  const bool is_editmode_allowed,
1038  const bool is_liboverride_allowed)
1039 {
1040  PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", rna_type);
1042  ModifierData *mod = ptr.data; /* May be NULL. */
1043 
1044  if (!ob || ID_IS_LINKED(ob)) {
1045  return false;
1046  }
1047  if (obtype_flag && ((1 << ob->type) & obtype_flag) == 0) {
1048  return false;
1049  }
1050  if (ptr.owner_id && ID_IS_LINKED(ptr.owner_id)) {
1051  return false;
1052  }
1053 
1054  if (!is_liboverride_allowed && BKE_modifier_is_nonlocal_in_liboverride(ob, mod)) {
1056  C, "Cannot edit modifiers coming from linked data in a library override");
1057  return false;
1058  }
1059 
1060  if (!is_editmode_allowed && CTX_data_edit_object(C) != NULL) {
1061  CTX_wm_operator_poll_msg_set(C, "This modifier operation is not allowed from Edit mode");
1062  return false;
1063  }
1064 
1065  return true;
1066 }
1067 
1069 {
1070  return edit_modifier_poll_generic(C, &RNA_Modifier, 0, true, false);
1071 }
1072 
1073 /* Used by operators performing actions allowed also on modifiers from the overridden linked object
1074  * (not only from added 'local' ones). */
1076 {
1077  return edit_modifier_poll_generic(C, &RNA_Modifier, 0, true, true);
1078 }
1079 
1081 {
1082  PropertyRNA *prop = RNA_def_string(
1083  ot->srna, "modifier", NULL, MAX_NAME, "Modifier", "Name of the modifier to edit");
1085 }
1086 
1088 {
1089  PropertyRNA *prop = RNA_def_boolean(
1090  ot->srna, "report", false, "Report", "Create a notification after the operation");
1092 }
1093 
1096 /* ------------------------------------------------------------------- */
1103 {
1104  if (RNA_struct_property_is_set(op->ptr, "modifier")) {
1105  return true;
1106  }
1107 
1108  PointerRNA ctx_ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier);
1109  if (ctx_ptr.data != NULL) {
1110  ModifierData *md = ctx_ptr.data;
1111  RNA_string_set(op->ptr, "modifier", md->name);
1112  return true;
1113  }
1114 
1115  return false;
1116 }
1117 
1124  wmOperator *op,
1125  const wmEvent *event,
1126  int *r_retval)
1127 {
1128  if (RNA_struct_property_is_set(op->ptr, "modifier")) {
1129  return true;
1130  }
1131 
1132  /* Note that the context pointer is *not* the active modifier, it is set in UI layouts. */
1133  PointerRNA ctx_ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_Modifier);
1134  if (ctx_ptr.data != NULL) {
1135  ModifierData *md = ctx_ptr.data;
1136  RNA_string_set(op->ptr, "modifier", md->name);
1137  return true;
1138  }
1139 
1141  if (panel_ptr == NULL || RNA_pointer_is_null(panel_ptr)) {
1142  *r_retval = OPERATOR_CANCELLED;
1143  return false;
1144  }
1145 
1146  if (!RNA_struct_is_a(panel_ptr->type, &RNA_Modifier)) {
1147  /* Work around multiple operators using the same shortcut. The operators for the other
1148  * stacks in the property editor use the same key, and will not run after these return
1149  * OPERATOR_CANCELLED. */
1150  *r_retval = (OPERATOR_PASS_THROUGH | OPERATOR_CANCELLED);
1151  return false;
1152  }
1153 
1154  const ModifierData *md = panel_ptr->data;
1155  RNA_string_set(op->ptr, "modifier", md->name);
1156  return true;
1157 }
1158 
1160 {
1161  char modifier_name[MAX_NAME];
1162  RNA_string_get(op->ptr, "modifier", modifier_name);
1163 
1165 
1166  if (md && type != 0 && md->type != type) {
1167  md = NULL;
1168  }
1169 
1170  return md;
1171 }
1172 
1175 /* ------------------------------------------------------------------- */
1180 {
1181  Main *bmain = CTX_data_main(C);
1183  ViewLayer *view_layer = CTX_data_view_layer(C);
1185  ModifierData *md = edit_modifier_property_get(op, ob, 0);
1186  int mode_orig = ob->mode;
1187 
1188  if (md == NULL) {
1189  return OPERATOR_CANCELLED;
1190  }
1191 
1192  /* Store name temporarily for report. */
1193  char name[MAX_NAME];
1194  strcpy(name, md->name);
1195 
1196  if (!ED_object_modifier_remove(op->reports, bmain, scene, ob, md)) {
1197  return OPERATOR_CANCELLED;
1198  }
1199 
1201 
1202  /* if cloth/softbody was removed, particle mode could be cleared */
1203  if (mode_orig & OB_MODE_PARTICLE_EDIT) {
1204  if ((ob->mode & OB_MODE_PARTICLE_EDIT) == 0) {
1205  if (ob == OBACT(view_layer)) {
1207  }
1208  }
1209  }
1210 
1211  if (RNA_boolean_get(op->ptr, "report")) {
1212  BKE_reportf(op->reports, RPT_INFO, "Removed modifier: %s", name);
1213  }
1214 
1215  return OPERATOR_FINISHED;
1216 }
1217 
1218 static int modifier_remove_invoke(bContext *C, wmOperator *op, const wmEvent *event)
1219 {
1220  int retval;
1221  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
1222  return modifier_remove_exec(C, op);
1223  }
1224  return retval;
1225 }
1226 
1228 {
1229  ot->name = "Remove Modifier";
1230  ot->description = "Remove a modifier from the active object";
1231  ot->idname = "OBJECT_OT_modifier_remove";
1232 
1236 
1237  /* flags */
1241 }
1242 
1245 /* ------------------------------------------------------------------- */
1250 {
1252  ModifierData *md = edit_modifier_property_get(op, ob, 0);
1253 
1254  if (!md || !ED_object_modifier_move_up(op->reports, ob, md)) {
1255  return OPERATOR_CANCELLED;
1256  }
1257 
1260 
1261  return OPERATOR_FINISHED;
1262 }
1263 
1264 static int modifier_move_up_invoke(bContext *C, wmOperator *op, const wmEvent *event)
1265 {
1266  int retval;
1267  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
1268  return modifier_move_up_exec(C, op);
1269  }
1270  return retval;
1271 }
1272 
1274 {
1275  ot->name = "Move Up Modifier";
1276  ot->description = "Move modifier up in the stack";
1277  ot->idname = "OBJECT_OT_modifier_move_up";
1278 
1282 
1283  /* flags */
1286 }
1287 
1290 /* ------------------------------------------------------------------- */
1295 {
1297  ModifierData *md = edit_modifier_property_get(op, ob, 0);
1298 
1299  if (!md || !ED_object_modifier_move_down(op->reports, ob, md)) {
1300  return OPERATOR_CANCELLED;
1301  }
1302 
1305 
1306  return OPERATOR_FINISHED;
1307 }
1308 
1309 static int modifier_move_down_invoke(bContext *C, wmOperator *op, const wmEvent *event)
1310 {
1311  int retval;
1312  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
1313  return modifier_move_down_exec(C, op);
1314  }
1315  return retval;
1316 }
1317 
1319 {
1320  ot->name = "Move Down Modifier";
1321  ot->description = "Move modifier down in the stack";
1322  ot->idname = "OBJECT_OT_modifier_move_down";
1323 
1327 
1328  /* flags */
1331 }
1332 
1335 /* ------------------------------------------------------------------- */
1340 {
1342  ModifierData *md = edit_modifier_property_get(op, ob, 0);
1343  int index = RNA_int_get(op->ptr, "index");
1344 
1345  if (!ED_object_modifier_move_to_index(op->reports, ob, md, index)) {
1346  return OPERATOR_CANCELLED;
1347  }
1348 
1349  return OPERATOR_FINISHED;
1350 }
1351 
1353 {
1354  int retval;
1355  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
1356  return modifier_move_to_index_exec(C, op);
1357  }
1358  return retval;
1359 }
1360 
1362 {
1363  ot->name = "Move Active Modifier to Index";
1364  ot->description =
1365  "Change the modifier's index in the stack so it evaluates after the set number of others";
1366  ot->idname = "OBJECT_OT_modifier_move_to_index";
1367 
1371 
1372  /* flags */
1375  RNA_def_int(
1376  ot->srna, "index", 0, 0, INT_MAX, "Index", "The index to move the modifier to", 0, INT_MAX);
1377 }
1378 
1381 /* ------------------------------------------------------------------- */
1385 static bool modifier_apply_poll_ex(bContext *C, bool allow_shared)
1386 {
1387  if (!edit_modifier_poll_generic(C, &RNA_Modifier, 0, false, false)) {
1388  return false;
1389  }
1390 
1394  ModifierData *md = ptr.data; /* May be NULL. */
1395 
1396  if (ID_IS_OVERRIDE_LIBRARY(ob) || ((ob->data != NULL) && ID_IS_OVERRIDE_LIBRARY(ob->data))) {
1397  CTX_wm_operator_poll_msg_set(C, "Modifiers cannot be applied on override data");
1398  return false;
1399  }
1400  if (!allow_shared && (ob->data != NULL) && ID_REAL_USERS(ob->data) > 1) {
1401  CTX_wm_operator_poll_msg_set(C, "Modifiers cannot be applied to multi-user data");
1402  return false;
1403  }
1404  if (md != NULL) {
1405  if ((ob->mode & OB_MODE_SCULPT) && (find_multires_modifier_before(scene, md)) &&
1406  (BKE_modifier_is_same_topology(md) == false)) {
1408  C, "Constructive modifier cannot be applied to multi-res data in sculpt mode");
1409  return false;
1410  }
1411  }
1412  return true;
1413 }
1414 
1416 {
1417  return modifier_apply_poll_ex(C, false);
1418 }
1419 
1420 static int modifier_apply_exec_ex(bContext *C, wmOperator *op, int apply_as, bool keep_modifier)
1421 {
1422  Main *bmain = CTX_data_main(C);
1426  ModifierData *md = edit_modifier_property_get(op, ob, 0);
1427  const bool do_report = RNA_boolean_get(op->ptr, "report");
1428 
1429  if (md == NULL) {
1430  return OPERATOR_CANCELLED;
1431  }
1432 
1433  int reports_len;
1434  char name[MAX_NAME];
1435  if (do_report) {
1436  reports_len = BLI_listbase_count(&op->reports->list);
1437  strcpy(name, md->name); /* Store name temporarily since the modifier is removed. */
1438  }
1439 
1441  bmain, op->reports, depsgraph, scene, ob, md, apply_as, keep_modifier)) {
1442  return OPERATOR_CANCELLED;
1443  }
1444 
1446  DEG_relations_tag_update(bmain);
1448 
1449  if (do_report) {
1450  /* Only add this report if the operator didn't cause another one. The purpose here is
1451  * to alert that something happened, and the previous report will do that anyway. */
1452  if (BLI_listbase_count(&op->reports->list) == reports_len) {
1453  BKE_reportf(op->reports, RPT_INFO, "Applied modifier: %s", name);
1454  }
1455  }
1456 
1457  return OPERATOR_FINISHED;
1458 }
1459 
1461 {
1462  return modifier_apply_exec_ex(C, op, MODIFIER_APPLY_DATA, false);
1463 }
1464 
1465 static int modifier_apply_invoke(bContext *C, wmOperator *op, const wmEvent *event)
1466 {
1467  int retval;
1468  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
1469  return modifier_apply_exec(C, op);
1470  }
1471  return retval;
1472 }
1473 
1475 {
1476  ot->name = "Apply Modifier";
1477  ot->description = "Apply modifier and remove from the stack";
1478  ot->idname = "OBJECT_OT_modifier_apply";
1479 
1483 
1484  /* flags */
1486 
1489 }
1490 
1493 /* ------------------------------------------------------------------- */
1498 {
1499  return modifier_apply_poll_ex(C, true);
1500 }
1501 
1503 {
1504  bool keep = RNA_boolean_get(op->ptr, "keep_modifier");
1505 
1506  return modifier_apply_exec_ex(C, op, MODIFIER_APPLY_SHAPE, keep);
1507 }
1508 
1510 {
1511  int retval;
1512  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
1513  return modifier_apply_as_shapekey_exec(C, op);
1514  }
1515  return retval;
1516 }
1517 
1519  struct wmOperatorType *UNUSED(op),
1520  struct PointerRNA *values)
1521 {
1522  bool keep = RNA_boolean_get(values, "keep_modifier");
1523 
1524  if (keep) {
1525  return BLI_strdup("Apply modifier as a new shapekey and keep it in the stack");
1526  }
1527 
1528  return NULL;
1529 }
1530 
1532 {
1533  ot->name = "Apply Modifier as Shape Key";
1534  ot->description = "Apply modifier as a new shape key and remove from the stack";
1535  ot->idname = "OBJECT_OT_modifier_apply_as_shapekey";
1536 
1541 
1542  /* flags */
1544 
1546  ot->srna, "keep_modifier", false, "Keep Modifier", "Do not remove the modifier from stack");
1549 }
1550 
1553 /* ------------------------------------------------------------------- */
1558 {
1559  Main *bmain = CTX_data_main(C);
1561  ViewLayer *view_layer = CTX_data_view_layer(C);
1563  ModifierData *md = edit_modifier_property_get(op, ob, 0);
1564 
1565  if (!md || !ED_object_modifier_convert(op->reports, bmain, depsgraph, view_layer, ob, md)) {
1566  return OPERATOR_CANCELLED;
1567  }
1568 
1571 
1572  return OPERATOR_FINISHED;
1573 }
1574 
1575 static int modifier_convert_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
1576 {
1578  return modifier_convert_exec(C, op);
1579  }
1580  return OPERATOR_CANCELLED;
1581 }
1582 
1584 {
1585  ot->name = "Convert Modifier";
1586  ot->description = "Convert particles to a mesh object";
1587  ot->idname = "OBJECT_OT_modifier_convert";
1588 
1592 
1593  /* flags */
1596 }
1597 
1600 /* ------------------------------------------------------------------- */
1605 {
1606  Main *bmain = CTX_data_main(C);
1609  ModifierData *md = edit_modifier_property_get(op, ob, 0);
1610 
1611  if (!md || !ED_object_modifier_copy(op->reports, bmain, scene, ob, md)) {
1612  return OPERATOR_CANCELLED;
1613  }
1614 
1617 
1618  return OPERATOR_FINISHED;
1619 }
1620 
1621 static int modifier_copy_invoke(bContext *C, wmOperator *op, const wmEvent *event)
1622 {
1623  int retval;
1624  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
1625  return modifier_copy_exec(C, op);
1626  }
1627  return retval;
1628 }
1629 
1631 {
1632  ot->name = "Copy Modifier";
1633  ot->description = "Duplicate modifier at the same position in the stack";
1634  ot->idname = "OBJECT_OT_modifier_copy";
1635 
1639 
1640  /* flags */
1643 }
1644 
1647 /* ------------------------------------------------------------------- */
1652 {
1654  ModifierData *md = edit_modifier_property_get(op, ob, 0);
1655 
1656  /* If there is no modifier set for this operator, clear the active modifier field. */
1658 
1660 
1661  return OPERATOR_FINISHED;
1662 }
1663 
1664 static int modifier_set_active_invoke(bContext *C, wmOperator *op, const wmEvent *event)
1665 {
1666  int retval;
1667  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
1668  return modifier_set_active_exec(C, op);
1669  }
1670  return retval;
1671 }
1672 
1674 {
1675  ot->name = "Set Active Modifier";
1676  ot->description = "Activate the modifier to use as the context";
1677  ot->idname = "OBJECT_OT_modifier_set_active";
1678 
1682 
1683  /* flags */
1686 }
1687 
1693 {
1694  Main *bmain = CTX_data_main(C);
1696  Object *obact = ED_object_active_context(C);
1697  ModifierData *md = edit_modifier_property_get(op, obact, 0);
1698 
1699  if (!md) {
1700  return OPERATOR_CANCELLED;
1701  }
1702 
1703  int num_copied = 0;
1704  const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
1705 
1706  CTX_DATA_BEGIN (C, Object *, ob, selected_objects) {
1707  if (ob == obact) {
1708  continue;
1709  }
1710 
1711  /* Checked in #BKE_object_copy_modifier, but check here too so we can give a better message. */
1713  BKE_reportf(op->reports,
1714  RPT_WARNING,
1715  "Object '%s' does not support %s modifiers",
1716  ob->id.name + 2,
1717  mti->name);
1718  continue;
1719  }
1720 
1721  if (mti->flags & eModifierTypeFlag_Single) {
1722  if (BKE_modifiers_findby_type(ob, md->type)) {
1723  BKE_reportf(op->reports,
1724  RPT_WARNING,
1725  "Modifier can only be added once to object '%s'",
1726  ob->id.name + 2);
1727  continue;
1728  }
1729  }
1730 
1731  if (!BKE_object_copy_modifier(bmain, scene, ob, obact, md)) {
1732  BKE_reportf(op->reports,
1733  RPT_ERROR,
1734  "Copying modifier '%s' to object '%s' failed",
1735  md->name,
1736  ob->id.name + 2);
1737  }
1738 
1739  num_copied++;
1742  }
1743  CTX_DATA_END;
1744 
1745  if (num_copied > 0) {
1746  DEG_relations_tag_update(bmain);
1747  }
1748  else {
1749  BKE_reportf(op->reports, RPT_ERROR, "Modifier '%s' was not copied to any objects", md->name);
1750  return OPERATOR_CANCELLED;
1751  }
1752 
1753  return OPERATOR_FINISHED;
1754 }
1755 
1757 {
1758  int retval;
1759  if (edit_modifier_invoke_properties_with_hover(C, op, event, &retval)) {
1760  return modifier_copy_to_selected_exec(C, op);
1761  }
1762  return retval;
1763 }
1764 
1766 {
1769  ModifierData *md = ptr.data;
1770 
1771  /* This just mirrors the check in #BKE_object_copy_modifier,
1772  * but there is no reasoning for it there. */
1774  CTX_wm_operator_poll_msg_set(C, "Not supported for \"Collision\" or \"Hook\" modifiers");
1775  return false;
1776  }
1777 
1778  if (!obact) {
1779  CTX_wm_operator_poll_msg_set(C, "No selected object is active");
1780  return false;
1781  }
1782 
1783  if (!BKE_object_supports_modifiers(obact)) {
1784  CTX_wm_operator_poll_msg_set(C, "Object type of source object is not supported");
1785  return false;
1786  }
1787 
1788  /* This could have a performance impact in the worst case, where there are many objects selected
1789  * and none of them pass either of the checks. But that should be uncommon, and this operator is
1790  * only exposed in a drop-down menu anyway. */
1791  bool found_supported_objects = false;
1792  CTX_DATA_BEGIN (C, Object *, ob, selected_objects) {
1793  if (ob == obact) {
1794  continue;
1795  }
1796 
1797  if (!md && BKE_object_supports_modifiers(ob)) {
1798  /* Skip type check if modifier could not be found ("modifier" context variable not set). */
1799  found_supported_objects = true;
1800  break;
1801  }
1803  found_supported_objects = true;
1804  break;
1805  }
1806  }
1807  CTX_DATA_END;
1808 
1809  if (!found_supported_objects) {
1810  CTX_wm_operator_poll_msg_set(C, "No supported objects were selected");
1811  return false;
1812  }
1813  return true;
1814 }
1815 
1817 {
1818  ot->name = "Copy Modifier to Selected";
1819  ot->description = "Copy the modifier from the active object to all selected objects";
1820  ot->idname = "OBJECT_OT_modifier_copy_to_selected";
1821 
1825 
1826  /* flags */
1829 }
1830 
1833 /* ------------------------------------------------------------------- */
1837 static bool multires_poll(bContext *C)
1838 {
1839  return edit_modifier_poll_generic(C, &RNA_MultiresModifier, (1 << OB_MESH), true, false);
1840 }
1841 
1843 {
1847  op, ob, eModifierType_Multires);
1848 
1849  if (!mmd) {
1850  return OPERATOR_CANCELLED;
1851  }
1852 
1853  multiresModifier_del_levels(mmd, scene, ob, 1);
1854 
1857 
1859 
1860  return OPERATOR_FINISHED;
1861 }
1862 
1864  wmOperator *op,
1865  const wmEvent *UNUSED(event))
1866 {
1869  }
1870  return OPERATOR_CANCELLED;
1871 }
1872 
1874 {
1875  ot->name = "Delete Higher Levels";
1876  ot->description = "Deletes the higher resolution mesh, potential loss of detail";
1877  ot->idname = "OBJECT_OT_multires_higher_levels_delete";
1878 
1879  ot->poll = multires_poll;
1882 
1883  /* flags */
1886 }
1887 
1890 /* ------------------------------------------------------------------- */
1896  "CATMULL_CLARK",
1897  0,
1898  "Catmull-Clark",
1899  "Create a new level using Catmull-Clark subdivisions"},
1901  "SIMPLE",
1902  0,
1903  "Simple",
1904  "Create a new level using simple subdivisions"},
1906  "LINEAR",
1907  0,
1908  "Linear",
1909  "Create a new level using linear interpolation of the sculpted displacement"},
1910  {0, NULL, 0, NULL, NULL},
1911 };
1912 
1914 {
1915  Object *object = ED_object_active_context(C);
1917  op, object, eModifierType_Multires);
1918 
1919  if (!mmd) {
1920  return OPERATOR_CANCELLED;
1921  }
1922 
1923  const eMultiresSubdivideModeType subdivide_mode = (eMultiresSubdivideModeType)(
1924  RNA_enum_get(op->ptr, "mode"));
1925  multiresModifier_subdivide(object, mmd, subdivide_mode);
1926 
1929 
1932 
1933  if (object->mode & OB_MODE_SCULPT) {
1934  /* ensure that grid paint mask layer is created */
1935  BKE_sculpt_mask_layers_ensure(object, mmd);
1936  }
1937 
1938  return OPERATOR_FINISHED;
1939 }
1940 
1942 {
1944  return multires_subdivide_exec(C, op);
1945  }
1946  return OPERATOR_CANCELLED;
1947 }
1948 
1950 {
1951  ot->name = "Multires Subdivide";
1952  ot->description = "Add a new level of subdivision";
1953  ot->idname = "OBJECT_OT_multires_subdivide";
1954 
1955  ot->poll = multires_poll;
1958 
1959  /* flags */
1962  RNA_def_enum(ot->srna,
1963  "mode",
1966  "Subdivision Mode",
1967  "How the mesh is going to be subdivided to create a new level");
1968 }
1969 
1972 /* ------------------------------------------------------------------- */
1977 {
1979  Object *ob = ED_object_active_context(C), *secondob = NULL;
1981  op, ob, eModifierType_Multires);
1982 
1983  if (!mmd) {
1984  return OPERATOR_CANCELLED;
1985  }
1986 
1987  if (mmd->lvl == 0) {
1988  BKE_report(op->reports, RPT_ERROR, "Reshape can work only with higher levels of subdivisions");
1989  return OPERATOR_CANCELLED;
1990  }
1991 
1992  CTX_DATA_BEGIN (C, Object *, selob, selected_editable_objects) {
1993  if (selob->type == OB_MESH && selob != ob) {
1994  secondob = selob;
1995  break;
1996  }
1997  }
1998  CTX_DATA_END;
1999 
2000  if (!secondob) {
2001  BKE_report(op->reports, RPT_ERROR, "Second selected mesh object required to copy shape from");
2002  return OPERATOR_CANCELLED;
2003  }
2004 
2005  if (!multiresModifier_reshapeFromObject(depsgraph, mmd, ob, secondob)) {
2006  BKE_report(op->reports, RPT_ERROR, "Objects do not have the same number of vertices");
2007  return OPERATOR_CANCELLED;
2008  }
2009 
2012 
2013  return OPERATOR_FINISHED;
2014 }
2015 
2016 static int multires_reshape_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
2017 {
2019  return multires_reshape_exec(C, op);
2020  }
2021  return OPERATOR_CANCELLED;
2022 }
2023 
2025 {
2026  ot->name = "Multires Reshape";
2027  ot->description = "Copy vertex coordinates from other object";
2028  ot->idname = "OBJECT_OT_multires_reshape";
2029 
2030  ot->poll = multires_poll;
2033 
2034  /* flags */
2037 }
2038 
2041 /* ------------------------------------------------------------------- */
2046 {
2047  Main *bmain = CTX_data_main(C);
2049  Mesh *me = (ob) ? ob->data : op->customdata;
2050  char path[FILE_MAX];
2051  const bool relative = RNA_boolean_get(op->ptr, "relative_path");
2052 
2053  if (!me) {
2054  return OPERATOR_CANCELLED;
2055  }
2056 
2058  return OPERATOR_CANCELLED;
2059  }
2060 
2061  RNA_string_get(op->ptr, "filepath", path);
2062 
2063  if (relative) {
2064  BLI_path_rel(path, BKE_main_blendfile_path(bmain));
2065  }
2066 
2067  CustomData_external_add(&me->ldata, &me->id, CD_MDISPS, me->totloop, path);
2069 
2070  return OPERATOR_FINISHED;
2071 }
2072 
2074 {
2076  Mesh *me = ob->data;
2077  char path[FILE_MAX];
2078 
2079  if (!edit_modifier_invoke_properties(C, op)) {
2080  return OPERATOR_CANCELLED;
2081  }
2082 
2084  op, ob, eModifierType_Multires);
2085 
2086  if (!mmd) {
2087  return OPERATOR_CANCELLED;
2088  }
2089 
2091  return OPERATOR_CANCELLED;
2092  }
2093 
2094  if (RNA_struct_property_is_set(op->ptr, "filepath")) {
2095  return multires_external_save_exec(C, op);
2096  }
2097 
2098  op->customdata = me;
2099 
2100  BLI_snprintf(path, sizeof(path), "//%s.btx", me->id.name + 2);
2101  RNA_string_set(op->ptr, "filepath", path);
2102 
2104 
2105  return OPERATOR_RUNNING_MODAL;
2106 }
2107 
2109 {
2110  ot->name = "Multires Save External";
2111  ot->description = "Save displacements to an external file";
2112  ot->idname = "OBJECT_OT_multires_external_save";
2113 
2114  /* XXX modifier no longer in context after file browser .. ot->poll = multires_poll; */
2117  ot->poll = multires_poll;
2118 
2119  /* flags */
2121 
2124  FILE_SPECIAL,
2125  FILE_SAVE,
2130 }
2131 
2134 /* ------------------------------------------------------------------- */
2139 {
2141  Mesh *me = ob->data;
2142 
2144  return OPERATOR_CANCELLED;
2145  }
2146 
2147  /* XXX don't remove.. */
2149 
2150  return OPERATOR_FINISHED;
2151 }
2152 
2154 {
2155  ot->name = "Multires Pack External";
2156  ot->description = "Pack displacements from an external file";
2157  ot->idname = "OBJECT_OT_multires_external_pack";
2158 
2159  ot->poll = multires_poll;
2161 
2162  /* flags */
2164 }
2165 
2168 /* ------------------------------------------------------------------- */
2173 {
2175  Object *object = ED_object_active_context(C);
2177  op, object, eModifierType_Multires);
2178 
2179  if (!mmd) {
2180  return OPERATOR_CANCELLED;
2181  }
2182 
2184 
2185  multiresModifier_base_apply(depsgraph, object, mmd);
2186 
2188 
2191 
2192  return OPERATOR_FINISHED;
2193 }
2194 
2196 {
2198  return multires_base_apply_exec(C, op);
2199  }
2200  return OPERATOR_CANCELLED;
2201 }
2202 
2204 {
2205  ot->name = "Multires Apply Base";
2206  ot->description = "Modify the base mesh to conform to the displaced mesh";
2207  ot->idname = "OBJECT_OT_multires_base_apply";
2208 
2209  ot->poll = multires_poll;
2212 
2213  /* flags */
2216 }
2217 
2220 /* ------------------------------------------------------------------- */
2225 {
2227  Object *object = ED_object_active_context(C);
2229  op, object, eModifierType_Multires);
2230 
2231  if (!mmd) {
2232  return OPERATOR_CANCELLED;
2233  }
2234 
2235  int new_levels = multiresModifier_rebuild_subdiv(depsgraph, object, mmd, 1, true);
2236  if (new_levels == 0) {
2237  BKE_report(op->reports, RPT_ERROR, "Not valid subdivisions found to rebuild a lower level");
2238  return OPERATOR_CANCELLED;
2239  }
2240 
2243 
2244  return OPERATOR_FINISHED;
2245 }
2246 
2248 {
2250  return multires_unsubdivide_exec(C, op);
2251  }
2252  return OPERATOR_CANCELLED;
2253 }
2254 
2256 {
2257  ot->name = "Unsubdivide";
2258  ot->description = "Rebuild a lower subdivision level of the current base mesh";
2259  ot->idname = "OBJECT_OT_multires_unsubdivide";
2260 
2261  ot->poll = multires_poll;
2264 
2265  /* flags */
2268 }
2269 
2272 /* ------------------------------------------------------------------- */
2277 {
2279  Object *object = ED_object_active_context(C);
2281  op, object, eModifierType_Multires);
2282 
2283  if (!mmd) {
2284  return OPERATOR_CANCELLED;
2285  }
2286 
2287  int new_levels = multiresModifier_rebuild_subdiv(depsgraph, object, mmd, INT_MAX, false);
2288  if (new_levels == 0) {
2289  BKE_report(op->reports, RPT_ERROR, "Not valid subdivisions found to rebuild lower levels");
2290  return OPERATOR_CANCELLED;
2291  }
2292 
2293  BKE_reportf(op->reports, RPT_INFO, "%d new levels rebuilt", new_levels);
2294 
2297 
2298  return OPERATOR_FINISHED;
2299 }
2300 
2302  wmOperator *op,
2303  const wmEvent *UNUSED(event))
2304 {
2306  return multires_rebuild_subdiv_exec(C, op);
2307  }
2308  return OPERATOR_CANCELLED;
2309 }
2310 
2312 {
2313  ot->name = "Rebuild Lower Subdivisions";
2314  ot->description =
2315  "Rebuilds all possible subdivisions levels to generate a lower resolution base mesh";
2316  ot->idname = "OBJECT_OT_multires_rebuild_subdiv";
2317 
2318  ot->poll = multires_poll;
2321 
2322  /* flags */
2325 }
2326 
2329 /* ------------------------------------------------------------------- */
2334 {
2335  Mesh *me = ob->data;
2336  BMEditMesh *em = me->edit_mesh;
2337 
2338  if (em) {
2340  }
2341  else {
2343  }
2344 }
2345 
2346 static bool skin_poll(bContext *C)
2347 {
2348  return (edit_modifier_poll_generic(C, &RNA_SkinModifier, (1 << OB_MESH), false, false));
2349 }
2350 
2352 {
2353  Object *ob = CTX_data_edit_object(C);
2354  return (ob != NULL &&
2355  edit_modifier_poll_generic(C, &RNA_SkinModifier, (1 << OB_MESH), true, false) &&
2357 }
2358 
2359 static void skin_root_clear(BMVert *bm_vert, GSet *visited, const int cd_vert_skin_offset)
2360 {
2361  BMEdge *bm_edge;
2362  BMIter bm_iter;
2363 
2364  BM_ITER_ELEM (bm_edge, &bm_iter, bm_vert, BM_EDGES_OF_VERT) {
2365  BMVert *v2 = BM_edge_other_vert(bm_edge, bm_vert);
2366 
2367  if (BLI_gset_add(visited, v2)) {
2368  MVertSkin *vs = BM_ELEM_CD_GET_VOID_P(v2, cd_vert_skin_offset);
2369 
2370  /* clear vertex root flag and add to visited set */
2371  vs->flag &= ~MVERT_SKIN_ROOT;
2372 
2373  skin_root_clear(v2, visited, cd_vert_skin_offset);
2374  }
2375  }
2376 }
2377 
2379 {
2380  Object *ob = CTX_data_edit_object(C);
2382  BMesh *bm = em->bm;
2383 
2384  GSet *visited = BLI_gset_ptr_new(__func__);
2385 
2387 
2388  const int cd_vert_skin_offset = CustomData_get_offset(&bm->vdata, CD_MVERT_SKIN);
2389 
2390  BMVert *bm_vert;
2391  BMIter bm_iter;
2392  BM_ITER_MESH (bm_vert, &bm_iter, bm, BM_VERTS_OF_MESH) {
2393  if (BM_elem_flag_test(bm_vert, BM_ELEM_SELECT) && BLI_gset_add(visited, bm_vert)) {
2394  MVertSkin *vs = BM_ELEM_CD_GET_VOID_P(bm_vert, cd_vert_skin_offset);
2395 
2396  /* mark vertex as root and add to visited set */
2397  vs->flag |= MVERT_SKIN_ROOT;
2398 
2399  /* clear root flag from all connected vertices (recursively) */
2400  skin_root_clear(bm_vert, visited, cd_vert_skin_offset);
2401  }
2402  }
2403 
2405 
2408 
2409  return OPERATOR_FINISHED;
2410 }
2411 
2413 {
2414  ot->name = "Skin Root Mark";
2415  ot->description = "Mark selected vertices as roots";
2416  ot->idname = "OBJECT_OT_skin_root_mark";
2417 
2418  ot->poll = skin_edit_poll;
2420 
2421  /* flags */
2423 }
2424 
2425 typedef enum {
2428 } SkinLooseAction;
2429 
2431 {
2432  Object *ob = CTX_data_edit_object(C);
2434  BMesh *bm = em->bm;
2435  SkinLooseAction action = RNA_enum_get(op->ptr, "action");
2436 
2438  return OPERATOR_CANCELLED;
2439  }
2440 
2441  BMVert *bm_vert;
2442  BMIter bm_iter;
2443  BM_ITER_MESH (bm_vert, &bm_iter, bm, BM_VERTS_OF_MESH) {
2444  if (BM_elem_flag_test(bm_vert, BM_ELEM_SELECT)) {
2446 
2447  switch (action) {
2448  case SKIN_LOOSE_MARK:
2449  vs->flag |= MVERT_SKIN_LOOSE;
2450  break;
2451  case SKIN_LOOSE_CLEAR:
2452  vs->flag &= ~MVERT_SKIN_LOOSE;
2453  break;
2454  }
2455  }
2456  }
2457 
2460 
2461  return OPERATOR_FINISHED;
2462 }
2463 
2465 {
2466  static const EnumPropertyItem action_items[] = {
2467  {SKIN_LOOSE_MARK, "MARK", 0, "Mark", "Mark selected vertices as loose"},
2468  {SKIN_LOOSE_CLEAR, "CLEAR", 0, "Clear", "Set selected vertices as not loose"},
2469  {0, NULL, 0, NULL, NULL},
2470  };
2471 
2472  ot->name = "Skin Mark/Clear Loose";
2473  ot->description = "Mark/clear selected vertices as loose";
2474  ot->idname = "OBJECT_OT_skin_loose_mark_clear";
2475 
2476  ot->poll = skin_edit_poll;
2478 
2479  /* flags */
2481 
2482  RNA_def_enum(ot->srna, "action", action_items, SKIN_LOOSE_MARK, "Action", NULL);
2483 }
2484 
2486 {
2487  Object *ob = CTX_data_edit_object(C);
2489  BMesh *bm = em->bm;
2490 
2492  return OPERATOR_CANCELLED;
2493  }
2494 
2495  BMVert *bm_vert;
2496  BMIter bm_iter;
2497  BM_ITER_MESH (bm_vert, &bm_iter, bm, BM_VERTS_OF_MESH) {
2498  if (BM_elem_flag_test(bm_vert, BM_ELEM_SELECT)) {
2500  float avg = (vs->radius[0] + vs->radius[1]) * 0.5f;
2501 
2502  vs->radius[0] = vs->radius[1] = avg;
2503  }
2504  }
2505 
2508 
2509  return OPERATOR_FINISHED;
2510 }
2511 
2513 {
2514  ot->name = "Skin Radii Equalize";
2515  ot->description = "Make skin radii of selected vertices equal on each axis";
2516  ot->idname = "OBJECT_OT_skin_radii_equalize";
2517 
2518  ot->poll = skin_edit_poll;
2520 
2521  /* flags */
2523 }
2524 
2525 static void skin_armature_bone_create(Object *skin_ob,
2526  MVert *mvert,
2527  MEdge *medge,
2528  bArmature *arm,
2529  BLI_bitmap *edges_visited,
2530  const MeshElemMap *emap,
2531  EditBone *parent_bone,
2532  int parent_v)
2533 {
2534  for (int i = 0; i < emap[parent_v].count; i++) {
2535  int endx = emap[parent_v].indices[i];
2536  const MEdge *e = &medge[endx];
2537 
2538  /* ignore edge if already visited */
2539  if (BLI_BITMAP_TEST(edges_visited, endx)) {
2540  continue;
2541  }
2542  BLI_BITMAP_ENABLE(edges_visited, endx);
2543 
2544  int v = (e->v1 == parent_v ? e->v2 : e->v1);
2545 
2546  EditBone *bone = ED_armature_ebone_add(arm, "Bone");
2547 
2548  bone->parent = parent_bone;
2549  if (parent_bone != NULL) {
2550  bone->flag |= BONE_CONNECTED;
2551  }
2552 
2553  copy_v3_v3(bone->head, mvert[parent_v].co);
2554  copy_v3_v3(bone->tail, mvert[v].co);
2555  bone->rad_head = bone->rad_tail = 0.25;
2556  BLI_snprintf(bone->name, sizeof(bone->name), "Bone.%.2d", endx);
2557 
2558  /* add bDeformGroup */
2559  bDeformGroup *dg = BKE_object_defgroup_add_name(skin_ob, bone->name);
2560  if (dg != NULL) {
2561  ED_vgroup_vert_add(skin_ob, dg, parent_v, 1, WEIGHT_REPLACE);
2562  ED_vgroup_vert_add(skin_ob, dg, v, 1, WEIGHT_REPLACE);
2563  }
2564 
2565  skin_armature_bone_create(skin_ob, mvert, medge, arm, edges_visited, emap, bone, v);
2566  }
2567 }
2568 
2570 {
2571  Mesh *me = skin_ob->data;
2572 
2573  Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
2574  Object *ob_eval = DEG_get_evaluated_object(depsgraph, skin_ob);
2575 
2576  Mesh *me_eval_deform = mesh_get_eval_deform(depsgraph, scene_eval, ob_eval, &CD_MASK_BAREMESH);
2577  MVert *mvert = me_eval_deform->mvert;
2578 
2579  /* add vertex weights to original mesh */
2581 
2583  Object *arm_ob = BKE_object_add(bmain, view_layer, OB_ARMATURE, NULL);
2584  BKE_object_transform_copy(arm_ob, skin_ob);
2585  bArmature *arm = arm_ob->data;
2586  arm->layer = 1;
2587  arm_ob->dtx |= OB_DRAW_IN_FRONT;
2588  arm->drawtype = ARM_LINE;
2589  arm->edbo = MEM_callocN(sizeof(ListBase), "edbo armature");
2590 
2591  MVertSkin *mvert_skin = CustomData_get_layer(&me->vdata, CD_MVERT_SKIN);
2592  int *emap_mem;
2593  MeshElemMap *emap;
2594  BKE_mesh_vert_edge_map_create(&emap, &emap_mem, me->medge, me->totvert, me->totedge);
2595 
2596  BLI_bitmap *edges_visited = BLI_BITMAP_NEW(me->totedge, "edge_visited");
2597 
2598  /* note: we use EditBones here, easier to set them up and use
2599  * edit-armature functions to convert back to regular bones */
2600  for (int v = 0; v < me->totvert; v++) {
2601  if (mvert_skin[v].flag & MVERT_SKIN_ROOT) {
2602  EditBone *bone = NULL;
2603 
2604  /* Unless the skin root has just one adjacent edge, create
2605  * a fake root bone (have it going off in the Y direction
2606  * (arbitrary) */
2607  if (emap[v].count > 1) {
2608  bone = ED_armature_ebone_add(arm, "Bone");
2609 
2610  copy_v3_v3(bone->head, me->mvert[v].co);
2611  copy_v3_v3(bone->tail, me->mvert[v].co);
2612 
2613  bone->head[1] = 1.0f;
2614  bone->rad_head = bone->rad_tail = 0.25;
2615  }
2616 
2617  if (emap[v].count >= 1) {
2618  skin_armature_bone_create(skin_ob, mvert, me->medge, arm, edges_visited, emap, bone, v);
2619  }
2620  }
2621  }
2622 
2623  MEM_freeN(edges_visited);
2624  MEM_freeN(emap);
2625  MEM_freeN(emap_mem);
2626 
2627  ED_armature_from_edit(bmain, arm);
2628  ED_armature_edit_free(arm);
2629 
2630  return arm_ob;
2631 }
2632 
2634 {
2635  Main *bmain = CTX_data_main(C);
2638  Mesh *me = ob->data;
2639  ModifierData *skin_md;
2640 
2641  if (!CustomData_has_layer(&me->vdata, CD_MVERT_SKIN)) {
2642  BKE_reportf(op->reports, RPT_WARNING, "Mesh '%s' has no skin vertex data", me->id.name + 2);
2643  return OPERATOR_CANCELLED;
2644  }
2645 
2646  /* create new armature */
2647  Object *arm_ob = modifier_skin_armature_create(depsgraph, bmain, ob);
2648 
2649  /* add a modifier to connect the new armature to the mesh */
2651  if (arm_md) {
2653  BLI_insertlinkafter(&ob->modifiers, skin_md, arm_md);
2654 
2655  arm_md->object = arm_ob;
2657  DEG_relations_tag_update(bmain);
2659  }
2660 
2662 
2663  return OPERATOR_FINISHED;
2664 }
2665 
2667 {
2669  return skin_armature_create_exec(C, op);
2670  }
2671  return OPERATOR_CANCELLED;
2672 }
2673 
2675 {
2676  ot->name = "Skin Armature Create";
2677  ot->description = "Create an armature that parallels the skin layout";
2678  ot->idname = "OBJECT_OT_skin_armature_create";
2679 
2680  ot->poll = skin_poll;
2683 
2684  /* flags */
2687 }
2690 /* ------------------------------------------------------------------- */
2695 {
2696  return edit_modifier_poll_generic(C, &RNA_CorrectiveSmoothModifier, 0, true, false);
2697 }
2698 
2700 {
2706 
2707  if (!csmd) {
2708  return OPERATOR_CANCELLED;
2709  }
2710 
2712  BKE_report(op->reports, RPT_ERROR, "Modifier is disabled");
2713  return OPERATOR_CANCELLED;
2714  }
2715 
2716  const bool is_bind = (csmd->bind_coords != NULL);
2717 
2718  MEM_SAFE_FREE(csmd->bind_coords);
2720 
2721  if (is_bind) {
2722  /* toggle off */
2723  csmd->bind_coords_num = 0;
2724  }
2725  else {
2726  /* Signal to modifier to recalculate. */
2729  csmd_eval->bind_coords_num = (uint)-1;
2730 
2731  /* Force modifier to run, it will call binding routine
2732  * (this has to happen outside of depsgraph evaluation). */
2734  }
2735 
2738 
2739  return OPERATOR_FINISHED;
2740 }
2741 
2743 {
2745  return correctivesmooth_bind_exec(C, op);
2746  }
2747  return OPERATOR_CANCELLED;
2748 }
2749 
2751 {
2752  /* identifiers */
2753  ot->name = "Corrective Smooth Bind";
2754  ot->description = "Bind base pose in Corrective Smooth modifier";
2755  ot->idname = "OBJECT_OT_correctivesmooth_bind";
2756 
2757  /* api callbacks */
2761 
2762  /* flags */
2765 }
2766 
2769 /* ------------------------------------------------------------------- */
2774 {
2775  return edit_modifier_poll_generic(C, &RNA_MeshDeformModifier, 0, true, false);
2776 }
2777 
2779 {
2783  op, ob, eModifierType_MeshDeform);
2784 
2785  if (mmd == NULL) {
2786  return OPERATOR_CANCELLED;
2787  }
2788 
2789  if (mmd->bindcagecos != NULL) {
2790  MEM_SAFE_FREE(mmd->bindcagecos);
2791  MEM_SAFE_FREE(mmd->dyngrid);
2794  MEM_SAFE_FREE(mmd->bindoffsets);
2795  MEM_SAFE_FREE(mmd->dynverts);
2796  MEM_SAFE_FREE(mmd->bindweights); /* Deprecated */
2797  MEM_SAFE_FREE(mmd->bindcos); /* Deprecated */
2798  mmd->totvert = 0;
2799  mmd->totcagevert = 0;
2800  mmd->totinfluence = 0;
2801  }
2802  else {
2803  /* Force modifier to run, it will call binding routine
2804  * (this has to happen outside of depsgraph evaluation). */
2806  depsgraph, ob, &mmd->modifier);
2809  mmd_eval->bindfunc = NULL;
2810  }
2811 
2814  return OPERATOR_FINISHED;
2815 }
2816 
2817 static int meshdeform_bind_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
2818 {
2820  return meshdeform_bind_exec(C, op);
2821  }
2822  return OPERATOR_CANCELLED;
2823 }
2824 
2826 {
2827  /* identifiers */
2828  ot->name = "Mesh Deform Bind";
2829  ot->description = "Bind mesh to cage in mesh deform modifier";
2830  ot->idname = "OBJECT_OT_meshdeform_bind";
2831 
2832  /* api callbacks */
2833  ot->poll = meshdeform_poll;
2836 
2837  /* flags */
2840 }
2841 
2844 /* ------------------------------------------------------------------- */
2848 static bool explode_poll(bContext *C)
2849 {
2850  return edit_modifier_poll_generic(C, &RNA_ExplodeModifier, 0, true, false);
2851 }
2852 
2854 {
2857  op, ob, eModifierType_Explode);
2858 
2859  if (!emd) {
2860  return OPERATOR_CANCELLED;
2861  }
2862 
2863  emd->flag |= eExplodeFlag_CalcFaces;
2864 
2867 
2868  return OPERATOR_FINISHED;
2869 }
2870 
2871 static int explode_refresh_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
2872 {
2874  return explode_refresh_exec(C, op);
2875  }
2876  return OPERATOR_CANCELLED;
2877 }
2878 
2880 {
2881  ot->name = "Explode Refresh";
2882  ot->description = "Refresh data in the Explode modifier";
2883  ot->idname = "OBJECT_OT_explode_refresh";
2884 
2885  ot->poll = explode_poll;
2888 
2889  /* flags */
2892 }
2893 
2896 /* ------------------------------------------------------------------- */
2901 {
2902  return edit_modifier_poll_generic(C, &RNA_OceanModifier, 0, true, false);
2903 }
2904 
2905 typedef struct OceanBakeJob {
2906  /* from wmJob */
2907  struct Object *owner;
2908  short *stop, *do_update;
2909  float *progress;
2911  struct OceanCache *och;
2912  struct Ocean *ocean;
2915 
2916 static void oceanbake_free(void *customdata)
2917 {
2918  OceanBakeJob *oj = customdata;
2919  MEM_freeN(oj);
2920 }
2921 
2922 /* called by oceanbake, only to check job 'stop' value */
2923 static int oceanbake_breakjob(void *UNUSED(customdata))
2924 {
2925  // OceanBakeJob *ob = (OceanBakeJob *)customdata;
2926  // return *(ob->stop);
2927 
2928  /* this is not nice yet, need to make the jobs list template better
2929  * for identifying/acting upon various different jobs */
2930  /* but for now we'll reuse the render break... */
2931  return (G.is_break);
2932 }
2933 
2934 /* called by oceanbake, wmJob sends notifier */
2935 static void oceanbake_update(void *customdata, float progress, int *cancel)
2936 {
2937  OceanBakeJob *oj = customdata;
2938 
2939  if (oceanbake_breakjob(oj)) {
2940  *cancel = 1;
2941  }
2942 
2943  *(oj->do_update) = true;
2944  *(oj->progress) = progress;
2945 }
2946 
2947 static void oceanbake_startjob(void *customdata, short *stop, short *do_update, float *progress)
2948 {
2949  OceanBakeJob *oj = customdata;
2950 
2951  oj->stop = stop;
2952  oj->do_update = do_update;
2953  oj->progress = progress;
2954 
2955  G.is_break = false; /* XXX shared with render - replace with job 'stop' switch */
2956 
2957  BKE_ocean_bake(oj->ocean, oj->och, oceanbake_update, (void *)oj);
2958 
2959  *do_update = true;
2960  *stop = 0;
2961 }
2962 
2963 static void oceanbake_endjob(void *customdata)
2964 {
2965  OceanBakeJob *oj = customdata;
2966 
2967  if (oj->ocean) {
2968  BKE_ocean_free(oj->ocean);
2969  oj->ocean = NULL;
2970  }
2971 
2972  oj->omd->oceancache = oj->och;
2973  oj->omd->cached = true;
2974 
2975  Object *ob = oj->owner;
2977 }
2978 
2980 {
2981  Main *bmain = CTX_data_main(C);
2984  op, ob, eModifierType_Ocean);
2986  const bool free = RNA_boolean_get(op->ptr, "free");
2987 
2988  if (!omd) {
2989  return OPERATOR_CANCELLED;
2990  }
2991 
2992  if (free) {
2996  return OPERATOR_FINISHED;
2997  }
2998 
3000  BKE_modifier_path_relbase(bmain, ob),
3001  omd->bakestart,
3002  omd->bakeend,
3003  omd->wave_scale,
3004  omd->chop_amount,
3005  omd->foam_coverage,
3006  omd->foam_fade,
3007  omd->resolution);
3008 
3009  och->time = MEM_mallocN(och->duration * sizeof(float), "foam bake time");
3010 
3011  int cfra = scene->r.cfra;
3012 
3013  /* precalculate time variable before baking */
3014  int i = 0;
3016  for (int f = omd->bakestart; f <= omd->bakeend; f++) {
3017  /* For now only simple animation of time value is supported, nothing else.
3018  * No drivers or other modifier parameters. */
3019  /* TODO(sergey): This operates on an original data, so no flush is needed. However, baking
3020  * usually should happen on an evaluated objects, so this seems to be deeper issue here. */
3021 
3023  f);
3024  BKE_animsys_evaluate_animdata((ID *)ob, ob->adt, &anim_eval_context, ADT_RECALC_ANIM, false);
3025 
3026  och->time[i] = omd->time;
3027  i++;
3028  }
3029 
3030  /* Make a copy of ocean to use for baking - thread-safety. */
3031  struct Ocean *ocean = BKE_ocean_add();
3032  BKE_ocean_init_from_modifier(ocean, omd, omd->resolution);
3033 
3034 #if 0
3035  BKE_ocean_bake(ocean, och);
3036 
3037  omd->oceancache = och;
3038  omd->cached = true;
3039 
3040  scene->r.cfra = cfra;
3041 
3044 #endif
3045 
3046  /* job stuff */
3047 
3048  scene->r.cfra = cfra;
3049 
3050  /* setup job */
3051  wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C),
3052  CTX_wm_window(C),
3053  scene,
3054  "Ocean Simulation",
3057  OceanBakeJob *oj = MEM_callocN(sizeof(OceanBakeJob), "ocean bake job");
3058  oj->owner = ob;
3059  oj->ocean = ocean;
3060  oj->och = och;
3061  oj->omd = omd;
3062 
3066 
3067  WM_jobs_start(CTX_wm_manager(C), wm_job);
3068 
3069  return OPERATOR_FINISHED;
3070 }
3071 
3072 static int ocean_bake_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
3073 {
3075  return ocean_bake_exec(C, op);
3076  }
3077  return OPERATOR_CANCELLED;
3078 }
3079 
3081 {
3082  ot->name = "Bake Ocean";
3083  ot->description = "Bake an image sequence of ocean data";
3084  ot->idname = "OBJECT_OT_ocean_bake";
3085 
3086  ot->poll = ocean_bake_poll;
3088  ot->exec = ocean_bake_exec;
3089 
3090  /* flags */
3093 
3094  RNA_def_boolean(ot->srna, "free", false, "Free", "Free the bake, rather than generating it");
3095 }
3096 
3099 /* ------------------------------------------------------------------- */
3104 {
3105  return edit_modifier_poll_generic(C, &RNA_LaplacianDeformModifier, 0, false, false);
3106 }
3107 
3109 {
3114 
3115  if (lmd == NULL) {
3116  return OPERATOR_CANCELLED;
3117  }
3118 
3119  if (lmd->flag & MOD_LAPLACIANDEFORM_BIND) {
3120  lmd->flag &= ~MOD_LAPLACIANDEFORM_BIND;
3121  }
3122  else {
3124  }
3125 
3128  lmd_eval->flag = lmd->flag;
3129 
3130  /* Force modifier to run, it will call binding routine
3131  * (this has to happen outside of depsgraph evaluation). */
3133 
3134  /* This is hard to know from the modifier itself whether the evaluation is
3135  * happening for binding or not. So we copy all the required data here. */
3136  lmd->total_verts = lmd_eval->total_verts;
3137  if (lmd_eval->vertexco == NULL) {
3138  MEM_SAFE_FREE(lmd->vertexco);
3139  }
3140  else {
3141  lmd->vertexco = MEM_dupallocN(lmd_eval->vertexco);
3142  }
3143 
3146  return OPERATOR_FINISHED;
3147 }
3148 
3150 {
3152  return laplaciandeform_bind_exec(C, op);
3153  }
3154  return OPERATOR_CANCELLED;
3155 }
3156 
3158 {
3159  /* identifiers */
3160  ot->name = "Laplacian Deform Bind";
3161  ot->description = "Bind mesh to system in laplacian deform modifier";
3162  ot->idname = "OBJECT_OT_laplaciandeform_bind";
3163 
3164  /* api callbacks */
3168 
3169  /* flags */
3172 }
3173 
3176 /* ------------------------------------------------------------------- */
3181 {
3182  return edit_modifier_poll_generic(C, &RNA_SurfaceDeformModifier, 0, true, false);
3183 }
3184 
3186 {
3190  op, ob, eModifierType_SurfaceDeform);
3191 
3192  if (smd == NULL) {
3193  return OPERATOR_CANCELLED;
3194  }
3195 
3196  if (smd->flags & MOD_SDEF_BIND) {
3197  smd->flags &= ~MOD_SDEF_BIND;
3198  }
3199  else if (smd->target) {
3200  smd->flags |= MOD_SDEF_BIND;
3201  }
3202 
3204  depsgraph, ob, &smd->modifier);
3205  smd_eval->flags = smd->flags;
3206 
3207  /* Force modifier to run, it will call binding routine
3208  * (this has to happen outside of depsgraph evaluation). */
3210 
3213  return OPERATOR_FINISHED;
3214 }
3215 
3217 {
3219  return surfacedeform_bind_exec(C, op);
3220  }
3221  return OPERATOR_CANCELLED;
3222 }
3223 
3225 {
3226  /* identifiers */
3227  ot->name = "Surface Deform Bind";
3228  ot->description = "Bind mesh to target in surface deform modifier";
3229  ot->idname = "OBJECT_OT_surfacedeform_bind";
3230 
3231  /* api callbacks */
3235 
3236  /* flags */
3239 }
3240 
typedef float(TangentPoint)[2]
AnimationEvalContext BKE_animsys_eval_context_construct(struct Depsgraph *depsgraph, float eval_time)
Definition: anim_sys.c:637
@ ADT_RECALC_ANIM
Definition: BKE_animsys.h:238
void BKE_animsys_evaluate_animdata(struct ID *id, struct AnimData *adt, const struct AnimationEvalContext *anim_eval_context, eAnimData_Recalc recalc, const bool flush_to_original)
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1034
struct Object * CTX_data_edit_object(const bContext *C)
Definition: context.c:1296
struct wmWindowManager * CTX_wm_manager(const bContext *C)
Definition: context.c:689
#define CTX_DATA_BEGIN(C, Type, instance, member)
Definition: BKE_context.h:252
PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type)
Definition: context.c:456
struct ViewLayer * CTX_data_view_layer(const bContext *C)
Definition: context.c:1044
struct Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C)
Definition: context.c:1424
struct Object * CTX_data_active_object(const bContext *C)
Definition: context.c:1279
struct Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
Definition: context.c:1401
void CTX_wm_operator_poll_msg_set(struct bContext *C, const char *msg)
Definition: context.c:1006
struct Main * CTX_data_main(const bContext *C)
Definition: context.c:1018
#define CTX_DATA_END
Definition: BKE_context.h:260
struct wmWindow * CTX_wm_window(const bContext *C)
Definition: context.c:699
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], const bool constrain_2d)
Definition: curve.c:4740
bool CustomData_free_layer_active(struct CustomData *data, int type, int totelem)
Definition: customdata.c:2707
@ CD_CALLOC
bool CustomData_has_layer(const struct CustomData *data, int type)
void CustomData_external_write(struct CustomData *data, struct ID *id, CustomDataMask mask, int totelem, int free)
Definition: customdata.c:4596
const CustomData_MeshMasks CD_MASK_BAREMESH
Definition: customdata.c:1919
void CustomData_external_add(struct CustomData *data, struct ID *id, int type, int totelem, const char *filename)
void * CustomData_get_layer(const struct CustomData *data, int type)
bool CustomData_external_test(struct CustomData *data, int type)
Definition: customdata.c:4748
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.c:2620
void CustomData_external_remove(struct CustomData *data, struct ID *id, int type, int totelem)
Definition: customdata.c:4724
int CustomData_get_offset(const struct CustomData *data, int type)
const CustomData_MeshMasks CD_MASK_MESH
Definition: customdata.c:1933
display list (or rather multi purpose list) stuff.
void BKE_displist_make_curveTypes(struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *ob, const bool for_render, const bool for_orco)
void BKE_displist_make_mball(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob)
Definition: displist.c:685
BMEditMesh * BKE_editmesh_from_object(struct Object *ob)
Return the BMEditMesh for a given object.
Definition: editmesh.c:85
struct PartDeflect * BKE_partdeflect_new(int type)
Definition: effect.c:86
void BKE_gpencil_modifiers_calc(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob)
General operations for hairs.
void BKE_hair_data_update(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *object)
Definition: hair.c:395
void BKE_keyblock_convert_from_mesh(struct Mesh *me, struct Key *key, struct KeyBlock *kb)
Definition: key.c:2208
struct KeyBlock * BKE_keyblock_add(struct Key *key, const char *name)
Definition: key.c:1817
struct Key * BKE_key_add(struct Main *bmain, struct ID *id)
Definition: key.c:259
void BKE_lattice_modifiers_calc(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob)
Definition: lattice.c:542
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:534
void BKE_id_free(struct Main *bmain, void *idv)
const char * BKE_main_blendfile_path(const struct Main *bmain) ATTR_NONNULL()
struct Mesh * BKE_mesh_create_derived_for_modifier(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob_eval, struct ModifierData *md_eval, const bool build_shapekey_layers)
void BKE_mesh_ensure_skin_customdata(struct Mesh *me)
Definition: mesh.c:681
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_eval_delete(struct Mesh *mesh_eval)
Definition: mesh.c:986
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, struct Scene *scene, struct Object *ob, const struct CustomData_MeshMasks *dataMask)
struct Mesh * mesh_create_eval_final(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, const struct CustomData_MeshMasks *dataMask)
void BKE_modifier_copydata(struct ModifierData *md, struct ModifierData *target)
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:107
@ eModifierTypeFlag_NoUserAdd
Definition: BKE_modifier.h:110
@ eModifierTypeFlag_RequiresOriginalData
Definition: BKE_modifier.h:98
void BKE_modifier_free(struct ModifierData *md)
const char * BKE_modifier_path_relbase(struct Main *bmain, struct Object *ob)
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:58
@ eModifierTypeType_NonGeometrical
Definition: BKE_modifier.h:76
@ eModifierTypeType_Constructive
Definition: BKE_modifier.h:61
@ eModifierTypeType_Nonconstructive
Definition: BKE_modifier.h:63
struct ModifierData * BKE_modifiers_findby_name(const struct Object *ob, const char *name)
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:384
void multiresModifier_subdivide(struct Object *object, struct MultiresModifierData *mmd, const eMultiresSubdivideModeType mode)
void multiresModifier_del_levels(struct MultiresModifierData *mmd, struct Scene *scene, struct Object *object, int direction)
Definition: multires.c:722
void multires_force_sculpt_rebuild(struct Object *object)
Definition: multires.c:456
struct MultiresModifierData * find_multires_modifier_before(struct Scene *scene, struct ModifierData *lastmd)
Definition: multires.c:318
void multiresModifier_set_levels_from_disps(struct MultiresModifierData *mmd, struct Object *ob)
Definition: multires.c:529
void multiresModifier_base_apply(struct Depsgraph *depsgraph, struct Object *object, struct MultiresModifierData *mmd)
void multires_customdata_delete(struct Mesh *me)
Definition: multires.c:83
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:171
@ MULTIRES_SUBDIVIDE_LINEAR
Definition: BKE_multires.h:174
@ MULTIRES_SUBDIVIDE_CATMULL_CLARK
Definition: BKE_multires.h:172
@ MULTIRES_SUBDIVIDE_SIMPLE
Definition: BKE_multires.h:173
bool multiresModifier_reshapeFromDeformModifier(struct Depsgraph *depsgraph, struct Object *ob, struct MultiresModifierData *mmd, struct ModifierData *deform_md)
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.c:1284
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.c:1719
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)
bool BKE_object_is_in_editmode(const struct Object *ob)
void BKE_object_eval_reset(struct Object *ob_eval)
Definition: object_update.c:78
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)
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:1711
struct Ocean * BKE_ocean_add(void)
Definition: ocean.c:1604
void BKE_ocean_free(struct Ocean *oc)
Definition: ocean.c:1640
void BKE_ocean_init_from_modifier(struct Ocean *ocean, struct OceanModifierData const *omd, const int resolution)
int BKE_sculpt_mask_layers_ensure(struct Object *ob, struct MultiresModifierData *mmd)
Definition: paint.c:1829
struct ParticleSystem * psys_eval_get(struct Depsgraph *depsgraph, struct Object *object, struct ParticleSystem *psys)
Definition: particle.c:749
void object_remove_particle_system(struct Main *bmain, struct Scene *scene, struct Object *ob)
struct ModifierData * object_add_particle_system(struct Main *bmain, struct Scene *scene, struct Object *ob, const char *name)
Definition: particle.c:3975
void psys_apply_hair_lattice(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct ParticleSystem *psys)
Definition: particle.c:5201
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:396
void BKE_report(ReportList *reports, ReportType type, const char *message)
Definition: report.c:104
void BKE_reportf(ReportList *reports, ReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
struct SoftBody * sbNew(struct Scene *scene)
Definition: softbody.c:3121
void sbFree(struct Object *ob)
Definition: softbody.c:3177
Volume datablock.
void BKE_volume_data_update(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *object)
Definition: volume.cc:1075
#define BLI_assert(a)
Definition: BLI_assert.h:58
#define BLI_BITMAP_TEST(_bitmap, _index)
Definition: BLI_bitmap.h:63
#define BLI_BITMAP_ENABLE(_bitmap, _index)
Definition: BLI_bitmap.h:78
#define BLI_BITMAP_NEW(_tot, _alloc_string)
Definition: BLI_bitmap.h:50
unsigned int BLI_bitmap
Definition: BLI_bitmap.h:32
struct GSet GSet
Definition: BLI_ghash.h:189
GSet * BLI_gset_ptr_new(const char *info)
void BLI_gset_free(GSet *gs, GSetKeyFreeFP keyfreefp)
Definition: BLI_ghash.c:1253
bool BLI_gset_add(GSet *gs, void *key)
Definition: BLI_ghash.c:1160
void BLI_kdtree_nd_() free(KDTree *tree)
Definition: kdtree_impl.h:116
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
Definition: BLI_listbase.h:124
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:172
void BLI_insertlinkafter(struct ListBase *listbase, void *vprevlink, void *vnewlink) ATTR_NONNULL(1)
Definition: listbase.c:352
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:110
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:133
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:395
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:519
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC
Definition: string.c:70
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()
Definition: string_utf8.c:258
unsigned int uint
Definition: BLI_sys_types.h:83
#define UNUSED(x)
#define ELEM(...)
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
void DEG_id_tag_update(struct ID *id, int flag)
void DEG_relations_tag_update(struct Main *bmain)
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:599
@ ID_RECALC_COPY_ON_WRITE
Definition: DNA_ID.h:654
@ ID_RECALC_ANIMATION
Definition: DNA_ID.h:614
@ ID_RECALC_GEOMETRY
Definition: DNA_ID.h:611
#define ID_IS_LINKED(_id)
Definition: DNA_ID.h:426
@ LIB_FAKEUSER
Definition: DNA_ID.h:477
#define ID_REAL_USERS(id)
Definition: DNA_ID.h:413
#define ID_IS_OVERRIDE_LIBRARY(_id)
Definition: DNA_ID.h:445
@ ARM_DEF_VGROUP
@ ARM_DEF_QUATERNION
@ BONE_CONNECTED
@ ARM_LINE
@ CD_MVERT_SKIN
@ CD_MDEFORMVERT
@ CD_MVERT
#define MAX_NAME
Definition: DNA_defs.h:62
@ KEY_RELATIVE
@ ME_EDGEDRAW
@ ME_EDGERENDER
@ ME_LOOSEEDGE
@ MVERT_SKIN_LOOSE
@ MVERT_SKIN_ROOT
@ 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
@ MOD_SDEF_BIND
@ OB_MODE_PARTICLE_EDIT
@ OB_MODE_SCULPT
#define OB_SB_EDGES
#define OB_SB_GOAL
@ OB_DRAW_IN_FRONT
@ OB_LATTICE
@ OB_MBALL
@ OB_SURF
@ OB_FONT
@ OB_ARMATURE
@ OB_MESH
@ OB_POINTCLOUD
@ OB_HAIR
@ OB_VOLUME
@ OB_CURVE
@ OB_GPENCIL
#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_SAVE
@ 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:345
struct Object * ED_object_active_context(const struct bContext *C)
@ MODIFIER_APPLY_DATA
Definition: ED_object.h:399
@ MODIFIER_APPLY_SHAPE
Definition: ED_object.h:400
bool ED_operator_object_active_editable(struct bContext *C)
Definition: screen_ops.c:366
void ED_sculpt_undo_push_multires_mesh_begin(struct bContext *C, const char *str)
Definition: sculpt_undo.c:1699
void ED_sculpt_undo_push_multires_mesh_end(struct bContext *C, const char *str)
Definition: sculpt_undo.c:1715
_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)
void MOD_nodes_init(Main *bmain, NodesModifierData *nmd)
Definition: MOD_nodes.cc:992
StructRNA RNA_SkinModifier
StructRNA RNA_Modifier
StructRNA RNA_MultiresModifier
StructRNA RNA_LaplacianDeformModifier
StructRNA RNA_OceanModifier
StructRNA RNA_SurfaceDeformModifier
StructRNA RNA_CorrectiveSmoothModifier
StructRNA RNA_ExplodeModifier
StructRNA RNA_MeshDeformModifier
@ PROP_HIDDEN
Definition: RNA_types.h:202
#define C
Definition: RandGen.cpp:39
struct PointerRNA * UI_region_panel_custom_data_under_cursor(const struct bContext *C, const struct wmEvent *event)
@ WM_JOB_TYPE_OBJECT_SIM_OCEAN
Definition: WM_api.h:738
#define WM_FILESEL_RELPATH
Definition: WM_api.h:533
#define WM_FILESEL_FILEPATH
Definition: WM_api.h:537
@ WM_JOB_PROGRESS
Definition: WM_api.h:726
@ OPTYPE_INTERNAL
Definition: WM_types.h:175
@ OPTYPE_UNDO
Definition: WM_types.h:155
@ OPTYPE_REGISTER
Definition: WM_types.h:153
#define ND_MODE
Definition: WM_types.h:345
#define NC_SCENE
Definition: WM_types.h:279
#define ND_MODIFIER
Definition: WM_types.h:363
#define NS_MODE_OBJECT
Definition: WM_types.h:441
#define NC_OBJECT
Definition: WM_types.h:280
EditBone * ED_armature_ebone_add(bArmature *arm, const char *name)
Definition: armature_add.c:69
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:530
#define BM_elem_flag_test(ele, hflag)
Definition: bmesh_inline.h:26
void BM_data_layer_free(BMesh *bm, CustomData *data, int type)
Definition: bmesh_interp.c:930
#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
#define SELECT
Scene scene
Curve curve
const Depsgraph * depsgraph
Lattice lattice
Set< ComponentNode * > visited
DEGForeachIDComponentCallback callback
int users
Definition: editfont_undo.c:90
int count
static const char * modifier_name[LS_MODIFIER_NUM]
Definition: linestyle.c:775
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_dupallocN)(const void *vmemh)
Definition: mallocn.c:42
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:47
void ED_mesh_deform_bind_callback(MeshDeformModifierData *mmd, Mesh *cagemesh, float *vertexcos, int totvert, float cagemat[4][4])
static unsigned a[3]
Definition: RandGen.cpp:92
bool edit_modifier_invoke_properties_with_hover(bContext *C, wmOperator *op, const wmEvent *event, int *r_retval)
static int laplaciandeform_bind_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
void OBJECT_OT_multires_higher_levels_delete(wmOperatorType *ot)
static bool modifier_apply_poll_ex(bContext *C, bool allow_shared)
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)
bool ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Depsgraph *depsgraph, ViewLayer *view_layer, Object *ob, ModifierData *md)
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 Mesh * modifier_apply_create_mesh_for_modifier(Depsgraph *depsgraph, Object *object, ModifierData *md_eval, bool build_shapekey_layers)
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_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 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)
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))
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)
struct OceanBakeJob OceanBakeJob
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 RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
Definition: rna_access.c:844
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
Definition: rna_access.c:6550
void RNA_string_get(PointerRNA *ptr, const char *name, char *value)
Definition: rna_access.c:6514
int RNA_int_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6308
bool RNA_pointer_is_null(const PointerRNA *ptr)
Definition: rna_access.c:174
bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier)
Definition: rna_access.c:6685
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6261
int RNA_enum_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6402
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, bool default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3481
void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
Definition: rna_define.c:4470
void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, const EnumPropertyItem *item)
Definition: rna_define.c:4416
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:3675
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1512
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:3585
void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc)
Definition: rna_define.c:3819
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:3771
const EnumPropertyItem rna_enum_object_modifier_type_items[]
Definition: rna_modifier.c:62
struct BMesh * bm
Definition: BKE_editmesh.h:52
void * data
Definition: bmesh_class.h:63
BMHeader head
Definition: bmesh_class.h:97
CustomData vdata
Definition: bmesh_class.h:337
CorrectiveSmoothDeltaCache delta_cache
ListBase nurb
char name[64]
Definition: BKE_armature.h:57
float tail[3]
Definition: BKE_armature.h:66
struct EditBone * parent
Definition: BKE_armature.h:55
float rad_tail
Definition: BKE_armature.h:78
float rad_head
Definition: BKE_armature.h:78
float head[3]
Definition: BKE_armature.h:65
const char * identifier
Definition: RNA_types.h:446
Definition: DNA_ID.h:273
int us
Definition: DNA_ID.h:293
short flag
Definition: DNA_ID.h:288
char name[66]
Definition: DNA_ID.h:283
char type
void * first
Definition: DNA_listBase.h:47
unsigned int v1
unsigned int v2
float co[3]
Definition: BKE_main.h:116
ListBase objects
Definition: BKE_main.h:148
void(* bindfunc)(struct MeshDeformModifierData *mmd, struct Mesh *cagemesh, float *vertexcos, int totvert, float cagemat[4][4])
MDefInfluence * bindinfluences
MDefInfluence * dyninfluences
struct MEdge * medge
struct BMEditMesh * edit_mesh
struct CustomData pdata ldata
struct MVert * mvert
int totedge
int totvert
struct CustomData vdata edata fdata
int totloop
struct Key * key
struct MFace * mface
struct ModifierData * next
struct ModifierData * prev
bool(* isDisabled)(const struct Scene *scene, struct ModifierData *md, bool userRenderParams)
Definition: BKE_modifier.h:312
ModifierTypeFlag flags
Definition: BKE_modifier.h:174
ModifierTypeType type
Definition: BKE_modifier.h:173
void(* deformVerts)(struct ModifierData *md, const struct ModifierEvalContext *ctx, struct Mesh *mesh, float(*vertexCos)[3], int numVerts)
Definition: BKE_modifier.h:197
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:56
int duration
Definition: BKE_ocean.h:66
struct OceanCache * oceancache
ParticleSettings * part
struct ParticleCacheKey ** childcache
struct ParticleCacheKey ** pathcache
struct StructRNA * type
Definition: RNA_types.h:51
void * data
Definition: RNA_types.h:52
struct ID * owner_id
Definition: RNA_types.h:50
struct RenderData r
unsigned int layer
ListBase * edbo
Definition: wm_jobs.c:73
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:752
const char * name
Definition: WM_types.h:721
const char * idname
Definition: WM_types.h:723
char *(* get_description)(struct bContext *C, struct wmOperatorType *, struct PointerRNA *)
Definition: WM_types.h:799
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:776
struct StructRNA * srna
Definition: WM_types.h:802
const char * description
Definition: WM_types.h:726
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:736
PropertyRNA * prop
Definition: WM_types.h:814
struct ReportList * reports
struct wmOperatorType * type
struct PointerRNA * ptr
ccl_device_inline int mod(int x, int m)
Definition: util_math.h:405
#define G(x, y, z)
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:3157
wmOperatorType * ot
Definition: wm_files.c:3156
void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job)
Definition: wm_jobs.c:450
wmJob * WM_jobs_get(wmWindowManager *wm, wmWindow *win, void *owner, const char *name, int flag, int job_type)
Definition: wm_jobs.c:196
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:372
void WM_jobs_customdata_set(wmJob *wm_job, void *customdata, void(*free)(void *))
Definition: wm_jobs.c:344
void WM_jobs_timer(wmJob *wm_job, double timestep, unsigned int note, unsigned int endnote)
Definition: wm_jobs.c:360
void WM_operator_properties_filesel(wmOperatorType *ot, int filter, short type, short action, short flag, short display, short sort)
int WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
Definition: wm_operators.c:982