Blender  V3.3
rna_object_force.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #include <stdlib.h>
8 
9 #include "DNA_cloth_types.h"
10 #include "DNA_dynamicpaint_types.h"
11 #include "DNA_fluid_types.h"
12 #include "DNA_object_force_types.h"
13 #include "DNA_object_types.h"
14 #include "DNA_particle_types.h"
15 #include "DNA_pointcache_types.h"
16 #include "DNA_rigidbody_types.h"
17 #include "DNA_scene_types.h"
18 
19 #include "RNA_define.h"
20 #include "RNA_enum_types.h"
21 
22 #include "rna_internal.h"
23 
24 #include "WM_api.h"
25 #include "WM_types.h"
26 
28  {PFIELD_SHAPE_POINT, "POINT", 0, "Point", "Field originates from the object center"},
29  {PFIELD_SHAPE_LINE, "LINE", 0, "Line", "Field originates from the local Z axis of the object"},
31  "PLANE",
32  0,
33  "Plane",
34  "Field originates from the local XY plane of the object"},
36  "SURFACE",
37  0,
38  "Surface",
39  "Field originates from the surface of the object"},
41  "POINTS",
42  0,
43  "Every Point",
44  "Field originates from all of the vertices of the object"},
45  {0, NULL, 0, NULL, NULL},
46 };
47 
48 #ifdef RNA_RUNTIME
49 
50 # include "BLI_math_base.h"
51 
52 # include "RNA_access.h"
53 
54 /* type specific return values only used from functions */
55 static const EnumPropertyItem curve_shape_items[] = {
56  {PFIELD_SHAPE_POINT, "POINT", 0, "Point", "Field originates from the object center"},
57  {PFIELD_SHAPE_LINE, "LINE", 0, "Line", "Field originates from the local Z axis of the object"},
59  "PLANE",
60  0,
61  "Plane",
62  "Field originates from the local XY plane of the object"},
63  {PFIELD_SHAPE_SURFACE, "SURFACE", 0, "Curve", "Field originates from the curve itself"},
64  {0, NULL, 0, NULL, NULL},
65 };
66 
67 static const EnumPropertyItem empty_shape_items[] = {
68  {PFIELD_SHAPE_POINT, "POINT", 0, "Point", "Field originates from the object center"},
69  {PFIELD_SHAPE_LINE, "LINE", 0, "Line", "Field originates from the local Z axis of the object"},
71  "PLANE",
72  0,
73  "Plane",
74  "Field originates from the local XY plane of the object"},
75  {0, NULL, 0, NULL, NULL},
76 };
77 
78 static const EnumPropertyItem vortex_shape_items[] = {
79  {PFIELD_SHAPE_POINT, "POINT", 0, "Point", ""},
80  {PFIELD_SHAPE_PLANE, "PLANE", 0, "Plane", ""},
81  {PFIELD_SHAPE_SURFACE, "SURFACE", 0, "Surface", ""},
82  {PFIELD_SHAPE_POINTS, "POINTS", 0, "Every Point", ""},
83  {0, NULL, 0, NULL, NULL},
84 };
85 
86 static const EnumPropertyItem curve_vortex_shape_items[] = {
87  {PFIELD_SHAPE_POINT, "POINT", 0, "Point", ""},
88  {PFIELD_SHAPE_PLANE, "PLANE", 0, "Plane", ""},
89  {PFIELD_SHAPE_SURFACE, "SURFACE", 0, "Curve", ""},
90  {0, NULL, 0, NULL, NULL},
91 };
92 
93 static const EnumPropertyItem empty_vortex_shape_items[] = {
94  {PFIELD_SHAPE_POINT, "POINT", 0, "Point", ""},
95  {PFIELD_SHAPE_PLANE, "PLANE", 0, "Plane", ""},
96  {0, NULL, 0, NULL, NULL},
97 };
98 
99 # include "MEM_guardedalloc.h"
100 
101 # include "DNA_modifier_types.h"
102 # include "DNA_texture_types.h"
103 
104 # include "BKE_collection.h"
105 # include "BKE_context.h"
106 # include "BKE_modifier.h"
107 # include "BKE_pointcache.h"
108 
109 # include "DEG_depsgraph.h"
110 # include "DEG_depsgraph_build.h"
111 
112 # include "ED_object.h"
113 
114 static bool rna_Cache_get_valid_owner_ID(PointerRNA *ptr, Object **ob, Scene **scene)
115 {
116  switch (GS(ptr->owner_id->name)) {
117  case ID_OB:
118  *ob = (Object *)ptr->owner_id;
119  break;
120  case ID_SCE:
121  *scene = (Scene *)ptr->owner_id;
122  break;
123  default:
124  BLI_assert_msg(0,
125  "Trying to get PTCacheID from an invalid ID type "
126  "(Only scenes and objects are supported).");
127  break;
128  }
129 
130  return (*ob != NULL || *scene != NULL);
131 }
132 
133 static char *rna_PointCache_path(const PointerRNA *ptr)
134 {
135  ModifierData *md;
136  Object *ob = (Object *)ptr->owner_id;
137  PointCache *cache = ptr->data;
138 
139  for (md = ob->modifiers.first; md; md = md->next) {
140  const ModifierTypeInfo *mti = BKE_modifier_get_info(md->type);
141 
142  if (!(mti->flags & eModifierTypeFlag_UsesPointCache)) {
143  continue;
144  }
145 
146  char name_esc[sizeof(md->name) * 2];
147  BLI_str_escape(name_esc, md->name, sizeof(name_esc));
148 
149  switch (md->type) {
152  if (psmd->psys->pointcache == cache) {
153  return BLI_sprintfN("modifiers[\"%s\"].particle_system.point_cache", name_esc);
154  }
155  break;
156  }
159  if (pmd->canvas) {
161  for (; surface; surface = surface->next) {
162  if (surface->pointcache == cache) {
163  char name_surface_esc[sizeof(surface->name) * 2];
164  BLI_str_escape(name_surface_esc, surface->name, sizeof(name_surface_esc));
165  return BLI_sprintfN(
166  "modifiers[\"%s\"].canvas_settings.canvas_surfaces[\"%s\"].point_cache",
167  name_esc,
168  name_surface_esc);
169  }
170  }
171  }
172  break;
173  }
174  case eModifierType_Cloth: {
175  ClothModifierData *clmd = (ClothModifierData *)md;
176  if (clmd->point_cache == cache) {
177  return BLI_sprintfN("modifiers[\"%s\"].point_cache", name_esc);
178  }
179  break;
180  }
181  case eModifierType_Softbody: {
182  SoftBody *sb = ob->soft;
183  if (sb && sb->shared->pointcache == cache) {
184  return BLI_sprintfN("modifiers[\"%s\"].point_cache", name_esc);
185  }
186  break;
187  }
188  default: {
189  return BLI_sprintfN("modifiers[\"%s\"].point_cache", name_esc);
190  }
191  }
192  }
193  return NULL;
194 }
195 
196 static void rna_Cache_change(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
197 {
198  Object *ob = NULL;
199  Scene *scene = NULL;
200 
201  if (!rna_Cache_get_valid_owner_ID(ptr, &ob, &scene)) {
202  return;
203  }
204 
205  PointCache *cache = (PointCache *)ptr->data;
206 
207  cache->flag |= PTCACHE_OUTDATED;
208 
209  PTCacheID pid = BKE_ptcache_id_find(ob, scene, cache);
210 
212 
213  if (pid.cache) {
214  /* Just make sure this wasn't changed. */
215  if (pid.type == PTCACHE_TYPE_SMOKE_DOMAIN) {
216  cache->step = 1;
217  }
218  cache->flag |= PTCACHE_FLAG_INFO_DIRTY;
219  }
220 }
221 
222 static void rna_Cache_toggle_disk_cache(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
223 {
224  Object *ob = NULL;
225  Scene *scene = NULL;
226 
227  if (!rna_Cache_get_valid_owner_ID(ptr, &ob, &scene)) {
228  return;
229  }
230 
231  PointCache *cache = (PointCache *)ptr->data;
232 
233  PTCacheID pid = BKE_ptcache_id_find(ob, scene, cache);
234 
235  /* smoke can only use disk cache */
236  if (pid.cache && pid.type != PTCACHE_TYPE_SMOKE_DOMAIN) {
238  }
239  else {
240  cache->flag ^= PTCACHE_DISK_CACHE;
241  }
242 }
243 
244 bool rna_Cache_use_disk_cache_override_apply(Main *UNUSED(bmain),
245  PointerRNA *ptr_dst,
246  PointerRNA *ptr_src,
247  PointerRNA *UNUSED(ptr_storage),
248  PropertyRNA *prop_dst,
249  PropertyRNA *prop_src,
250  PropertyRNA *UNUSED(prop_storage),
251  const int UNUSED(len_dst),
252  const int UNUSED(len_src),
253  const int UNUSED(len_storage),
254  PointerRNA *UNUSED(ptr_item_dst),
255  PointerRNA *UNUSED(ptr_item_src),
256  PointerRNA *UNUSED(ptr_item_storage),
258 {
261  UNUSED_VARS_NDEBUG(opop);
262 
263  RNA_property_boolean_set(ptr_dst, prop_dst, RNA_property_boolean_get(ptr_src, prop_src));
264 
265  /* DO NOT call `RNA_property_update_main(bmain, NULL, ptr_dst, prop_dst);`, that would trigger
266  * the whole 'update from mem point cache' process, ending up in the complete deletion of an
267  * existing disk-cache if any. */
268  return true;
269 }
270 
271 static void rna_Cache_idname_change(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
272 {
273  Object *ob = NULL;
274  Scene *scene = NULL;
275 
276  if (!rna_Cache_get_valid_owner_ID(ptr, &ob, &scene)) {
277  return;
278  }
279 
280  PointCache *cache = (PointCache *)ptr->data;
281  bool use_new_name = true;
282 
283  /* TODO: check for proper characters */
284 
285  if (cache->flag & PTCACHE_EXTERNAL) {
286  PTCacheID pid = BKE_ptcache_id_find(ob, scene, cache);
287 
288  if (pid.cache) {
290  }
291 
294  }
295  else {
296  PTCacheID *pid = NULL, *pid2 = NULL;
297  ListBase pidlist;
298 
299  BKE_ptcache_ids_from_object(&pidlist, ob, scene, 0);
300 
301  for (pid = pidlist.first; pid; pid = pid->next) {
302  if (pid->cache == cache) {
303  pid2 = pid;
304  }
305  else if (cache->name[0] != '\0' && STREQ(cache->name, pid->cache->name)) {
306  /* TODO: report "name exists" to user. */
307  BLI_strncpy(cache->name, cache->prev_name, sizeof(cache->name));
308  use_new_name = false;
309  }
310  }
311 
312  if (use_new_name) {
314 
315  if (pid2 && cache->flag & PTCACHE_DISK_CACHE) {
316  char old_name[80];
317  char new_name[80];
318 
319  BLI_strncpy(old_name, cache->prev_name, sizeof(old_name));
320  BLI_strncpy(new_name, cache->name, sizeof(new_name));
321 
322  BKE_ptcache_disk_cache_rename(pid2, old_name, new_name);
323  }
324 
325  BLI_strncpy(cache->prev_name, cache->name, sizeof(cache->prev_name));
326  }
327 
328  BLI_freelistN(&pidlist);
329  }
330 }
331 
332 static void rna_Cache_list_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
333 {
334  PointCache *cache = ptr->data;
335  ListBase lb;
336 
337  while (cache->prev) {
338  cache = cache->prev;
339  }
340 
341  lb.first = cache;
342  lb.last = NULL; /* not used by listbase_begin */
343 
344  rna_iterator_listbase_begin(iter, &lb, NULL);
345 }
346 static void rna_Cache_active_point_cache_index_range(
347  PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax))
348 {
349  *min = 0;
350  *max = 0;
351 
352  Object *ob = NULL;
353  Scene *scene = NULL;
354 
355  if (!rna_Cache_get_valid_owner_ID(ptr, &ob, &scene)) {
356  return;
357  }
358 
359  PointCache *cache = ptr->data;
360  PTCacheID pid = BKE_ptcache_id_find(ob, scene, cache);
361 
362  if (pid.cache) {
363  *max = max_ii(0, BLI_listbase_count(pid.ptcaches) - 1);
364  }
365 }
366 
367 static int rna_Cache_active_point_cache_index_get(PointerRNA *ptr)
368 {
369  int num = 0;
370 
371  Object *ob = NULL;
372  Scene *scene = NULL;
373 
374  if (!rna_Cache_get_valid_owner_ID(ptr, &ob, &scene)) {
375  return num;
376  }
377 
378  PointCache *cache = ptr->data;
379  PTCacheID pid = BKE_ptcache_id_find(ob, scene, cache);
380 
381  if (pid.cache) {
382  num = BLI_findindex(pid.ptcaches, cache);
383  }
384 
385  return num;
386 }
387 
388 static void rna_Cache_active_point_cache_index_set(struct PointerRNA *ptr, int value)
389 {
390  Object *ob = NULL;
391  Scene *scene = NULL;
392 
393  if (!rna_Cache_get_valid_owner_ID(ptr, &ob, &scene)) {
394  return;
395  }
396 
397  PointCache *cache = ptr->data;
398  PTCacheID pid = BKE_ptcache_id_find(ob, scene, cache);
399 
400  if (pid.cache) {
401  *(pid.cache_ptr) = BLI_findlink(pid.ptcaches, value);
402  }
403 }
404 
405 static void rna_PointCache_frame_step_range(
406  PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax))
407 {
408  *min = 1;
409  *max = 20;
410 
411  Object *ob = NULL;
412  Scene *scene = NULL;
413 
414  if (!rna_Cache_get_valid_owner_ID(ptr, &ob, &scene)) {
415  return;
416  }
417 
418  PointCache *cache = ptr->data;
419  PTCacheID pid = BKE_ptcache_id_find(ob, scene, cache);
420 
421  if (pid.cache) {
422  *max = pid.max_step;
423  }
424 }
425 
426 int rna_Cache_info_length(PointerRNA *ptr)
427 {
428  Object *ob = NULL;
429  Scene *scene = NULL;
430 
431  if (!rna_Cache_get_valid_owner_ID(ptr, &ob, &scene)) {
432  return 0;
433  }
434 
435  PointCache *cache = (PointCache *)ptr->data;
436 
437  PTCacheID pid = BKE_ptcache_id_find(ob, scene, cache);
438 
439  if (pid.cache != NULL && pid.cache->flag & PTCACHE_FLAG_INFO_DIRTY) {
441  }
442 
443  return (int)strlen(cache->info);
444 }
445 
446 static char *rna_CollisionSettings_path(const PointerRNA *UNUSED(ptr))
447 {
448  /* both methods work ok, but return the shorter path */
449 # if 0
450  Object *ob = (Object *)ptr->owner_id;
452 
453  if (md) {
454  char name_esc[sizeof(md->name) * 2];
455 
456  BLI_str_escape(name_esc, md->name, sizeof(name_esc));
457  return BLI_sprintfN("modifiers[\"%s\"].settings", name_esc);
458  }
459  else {
460  return BLI_strdup("");
461  }
462 # else
463  /* more reliable */
464  return BLI_strdup("collision");
465 # endif
466 }
467 
468 static bool rna_SoftBodySettings_use_edges_get(PointerRNA *ptr)
469 {
470  Object *data = (Object *)(ptr->owner_id);
471  return (((data->softflag) & OB_SB_EDGES) != 0);
472 }
473 
474 static void rna_SoftBodySettings_use_edges_set(PointerRNA *ptr, bool value)
475 {
476  Object *data = (Object *)(ptr->owner_id);
477  if (value) {
478  data->softflag |= OB_SB_EDGES;
479  }
480  else {
481  data->softflag &= ~OB_SB_EDGES;
482  }
483 }
484 
485 static bool rna_SoftBodySettings_use_goal_get(PointerRNA *ptr)
486 {
487  Object *data = (Object *)(ptr->owner_id);
488  return (((data->softflag) & OB_SB_GOAL) != 0);
489 }
490 
491 static void rna_SoftBodySettings_use_goal_set(PointerRNA *ptr, bool value)
492 {
493  Object *data = (Object *)(ptr->owner_id);
494  if (value) {
495  data->softflag |= OB_SB_GOAL;
496  }
497  else {
498  data->softflag &= ~OB_SB_GOAL;
499  }
500 }
501 
502 static bool rna_SoftBodySettings_stiff_quads_get(PointerRNA *ptr)
503 {
504  Object *data = (Object *)(ptr->owner_id);
505  return (((data->softflag) & OB_SB_QUADS) != 0);
506 }
507 
508 static void rna_SoftBodySettings_stiff_quads_set(PointerRNA *ptr, bool value)
509 {
510  Object *data = (Object *)(ptr->owner_id);
511  if (value) {
512  data->softflag |= OB_SB_QUADS;
513  }
514  else {
515  data->softflag &= ~OB_SB_QUADS;
516  }
517 }
518 
519 static bool rna_SoftBodySettings_self_collision_get(PointerRNA *ptr)
520 {
521  Object *data = (Object *)(ptr->owner_id);
522  return (((data->softflag) & OB_SB_SELF) != 0);
523 }
524 
525 static void rna_SoftBodySettings_self_collision_set(PointerRNA *ptr, bool value)
526 {
527  Object *data = (Object *)(ptr->owner_id);
528  if (value) {
529  data->softflag |= OB_SB_SELF;
530  }
531  else {
532  data->softflag &= ~OB_SB_SELF;
533  }
534 }
535 
536 static int rna_SoftBodySettings_new_aero_get(PointerRNA *ptr)
537 {
538  Object *data = (Object *)(ptr->owner_id);
539  if (data->softflag & OB_SB_AERO_ANGLE) {
540  return 1;
541  }
542  else {
543  return 0;
544  }
545 }
546 
547 static void rna_SoftBodySettings_new_aero_set(PointerRNA *ptr, int value)
548 {
549  Object *data = (Object *)(ptr->owner_id);
550  if (value == 1) {
551  data->softflag |= OB_SB_AERO_ANGLE;
552  }
553  else { /* value == 0 */
554  data->softflag &= ~OB_SB_AERO_ANGLE;
555  }
556 }
557 
558 static bool rna_SoftBodySettings_face_collision_get(PointerRNA *ptr)
559 {
560  Object *data = (Object *)(ptr->owner_id);
561  return (((data->softflag) & OB_SB_FACECOLL) != 0);
562 }
563 
564 static void rna_SoftBodySettings_face_collision_set(PointerRNA *ptr, bool value)
565 {
566  Object *data = (Object *)(ptr->owner_id);
567  if (value) {
568  data->softflag |= OB_SB_FACECOLL;
569  }
570  else {
571  data->softflag &= ~OB_SB_FACECOLL;
572  }
573 }
574 
575 static bool rna_SoftBodySettings_edge_collision_get(PointerRNA *ptr)
576 {
577  Object *data = (Object *)(ptr->owner_id);
578  return (((data->softflag) & OB_SB_EDGECOLL) != 0);
579 }
580 
581 static void rna_SoftBodySettings_edge_collision_set(PointerRNA *ptr, bool value)
582 {
583  Object *data = (Object *)(ptr->owner_id);
584  if (value) {
585  data->softflag |= OB_SB_EDGECOLL;
586  }
587  else {
588  data->softflag &= ~OB_SB_EDGECOLL;
589  }
590 }
591 
592 static void rna_SoftBodySettings_goal_vgroup_get(PointerRNA *ptr, char *value)
593 {
594  SoftBody *sb = (SoftBody *)ptr->data;
596 }
597 
598 static int rna_SoftBodySettings_goal_vgroup_length(PointerRNA *ptr)
599 {
600  SoftBody *sb = (SoftBody *)ptr->data;
602 }
603 
604 static void rna_SoftBodySettings_goal_vgroup_set(PointerRNA *ptr, const char *value)
605 {
606  SoftBody *sb = (SoftBody *)ptr->data;
608 }
609 
610 static void rna_SoftBodySettings_mass_vgroup_set(PointerRNA *ptr, const char *value)
611 {
612  SoftBody *sb = (SoftBody *)ptr->data;
613  rna_object_vgroup_name_set(ptr, value, sb->namedVG_Mass, sizeof(sb->namedVG_Mass));
614 }
615 
616 static void rna_SoftBodySettings_spring_vgroup_set(PointerRNA *ptr, const char *value)
617 {
618  SoftBody *sb = (SoftBody *)ptr->data;
620 }
621 
622 static char *rna_SoftBodySettings_path(const PointerRNA *ptr)
623 {
624  const Object *ob = (Object *)ptr->owner_id;
626  char name_esc[sizeof(md->name) * 2];
627 
628  BLI_str_escape(name_esc, md->name, sizeof(name_esc));
629  return BLI_sprintfN("modifiers[\"%s\"].settings", name_esc);
630 }
631 
632 static int particle_id_check(const PointerRNA *ptr)
633 {
634  ID *id = ptr->owner_id;
635 
636  return (GS(id->name) == ID_PA);
637 }
638 
639 static void rna_FieldSettings_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
640 {
641  if (particle_id_check(ptr)) {
643 
644  if (part->pd->forcefield != PFIELD_TEXTURE && part->pd->tex) {
645  id_us_min(&part->pd->tex->id);
646  part->pd->tex = NULL;
647  }
648 
649  if (part->pd2 && part->pd2->forcefield != PFIELD_TEXTURE && part->pd2->tex) {
650  id_us_min(&part->pd2->tex->id);
651  part->pd2->tex = NULL;
652  }
653 
654  DEG_id_tag_update(&part->id,
658  }
659  else {
660  Object *ob = (Object *)ptr->owner_id;
661 
662  if (ob->pd->forcefield != PFIELD_TEXTURE && ob->pd->tex) {
663  id_us_min(&ob->pd->tex->id);
664  ob->pd->tex = NULL;
665  }
666 
667  /* In the case of specific force-fields that are using the #EffectorData's normal, we need to
668  * rebuild mesh and BVH-tree for #SurfaceModifier to work correctly. */
670  ob->pd->forcefield == PFIELD_GUIDE) {
672  }
673 
676  }
677 }
678 
679 static void rna_FieldSettings_shape_update(Main *bmain, Scene *scene, PointerRNA *ptr)
680 {
681  if (!particle_id_check(ptr)) {
682  Object *ob = (Object *)ptr->owner_id;
684 
688  }
689 }
690 
691 static void rna_FieldSettings_type_set(PointerRNA *ptr, int value)
692 {
693  PartDeflect *part_deflect = (PartDeflect *)ptr->data;
694 
695  part_deflect->forcefield = value;
696 
697  if (!particle_id_check(ptr)) {
698  Object *ob = (Object *)ptr->owner_id;
699  ob->pd->forcefield = value;
700  if (ELEM(value, PFIELD_WIND, PFIELD_VORTEX)) {
702  }
703  else {
705  }
706  }
707 }
708 
709 static void rna_FieldSettings_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr)
710 {
712 
713  if (particle_id_check(ptr)) {
717  }
718  else {
719  Object *ob = (Object *)ptr->owner_id;
720 
721  rna_FieldSettings_shape_update(bmain, scene, ptr);
722 
723  if (ob->type == OB_CURVES_LEGACY && ob->pd->forcefield == PFIELD_GUIDE) {
725  }
726  else {
728  }
729 
731  }
732 }
733 
734 static char *rna_FieldSettings_path(const PointerRNA *ptr)
735 {
736  PartDeflect *pd = (PartDeflect *)ptr->data;
737 
738  /* Check through all possible places the settings can be to find the right one */
739 
740  if (particle_id_check(ptr)) {
741  /* particle system force field */
743 
744  if (part->pd == pd) {
745  return BLI_strdup("force_field_1");
746  }
747  else if (part->pd2 == pd) {
748  return BLI_strdup("force_field_2");
749  }
750  }
751  else {
752  /* object force field */
753  Object *ob = (Object *)ptr->owner_id;
754 
755  if (ob->pd == pd) {
756  return BLI_strdup("field");
757  }
758  }
759  return NULL;
760 }
761 
762 static void rna_EffectorWeight_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
763 {
764  ID *id = ptr->owner_id;
765 
766  if (id && GS(id->name) == ID_SCE) {
767  Scene *scene = (Scene *)id;
770  }
772  }
773  else {
776  }
777 }
778 
779 static void rna_EffectorWeight_dependency_update(Main *bmain,
780  Scene *UNUSED(scene),
781  PointerRNA *ptr)
782 {
784 
786 
788 }
789 
790 static char *rna_EffectorWeight_path(const PointerRNA *ptr)
791 {
793  /* Check through all possible places the settings can be to find the right one */
794 
795  if (particle_id_check(ptr)) {
796  /* particle effector weights */
798 
799  if (part->effector_weights == ew) {
800  return BLI_strdup("effector_weights");
801  }
802  }
803  else {
804  ID *id = ptr->owner_id;
805 
806  if (id && GS(id->name) == ID_SCE) {
807  const Scene *scene = (Scene *)id;
808  const RigidBodyWorld *rbw = scene->rigidbody_world;
809 
810  if (rbw->effector_weights == ew) {
811  return BLI_strdup("rigidbody_world.effector_weights");
812  }
813  }
814 
815  Object *ob = (Object *)id;
816  ModifierData *md;
817 
818  /* check softbody modifier */
820  if (md) {
821  /* no pointer from modifier data to actual softbody storage, would be good to add */
822  if (ob->soft->effector_weights == ew) {
823  char name_esc[sizeof(md->name) * 2];
824  BLI_str_escape(name_esc, md->name, sizeof(name_esc));
825  return BLI_sprintfN("modifiers[\"%s\"].settings.effector_weights", name_esc);
826  }
827  }
828 
829  /* check cloth modifier */
831  if (md) {
833  if (cmd->sim_parms->effector_weights == ew) {
834  char name_esc[sizeof(md->name) * 2];
835  BLI_str_escape(name_esc, md->name, sizeof(name_esc));
836  return BLI_sprintfN("modifiers[\"%s\"].settings.effector_weights", name_esc);
837  }
838  }
839 
840  /* check fluid modifier */
842  if (md) {
844  if (fmd->type == MOD_FLUID_TYPE_DOMAIN && fmd->domain &&
845  fmd->domain->effector_weights == ew) {
846  char name_esc[sizeof(md->name) * 2];
847  BLI_str_escape(name_esc, md->name, sizeof(name_esc));
848  return BLI_sprintfN("modifiers[\"%s\"].domain_settings.effector_weights", name_esc);
849  }
850  }
851 
852  /* check dynamic paint modifier */
854  if (md) {
856 
857  if (pmd->canvas) {
859 
860  for (; surface; surface = surface->next) {
861  if (surface->effector_weights == ew) {
862  char name_esc[sizeof(md->name) * 2];
863  char name_esc_surface[sizeof(surface->name) * 2];
864 
865  BLI_str_escape(name_esc, md->name, sizeof(name_esc));
866  BLI_str_escape(name_esc_surface, surface->name, sizeof(name_esc_surface));
867  return BLI_sprintfN(
868  "modifiers[\"%s\"].canvas_settings.canvas_surfaces[\"%s\"]"
869  ".effector_weights",
870  name_esc,
871  name_esc_surface);
872  }
873  }
874  }
875  }
876  }
877  return NULL;
878 }
879 
880 static void rna_CollisionSettings_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr)
881 {
882  Object *ob = (Object *)ptr->owner_id;
884 
885  /* add the modifier if needed */
886  if (ob->pd->deflect && !md) {
888  }
889 
892 }
893 
894 static void rna_CollisionSettings_update(Main *UNUSED(bmain),
895  Scene *UNUSED(scene),
896  PointerRNA *ptr)
897 {
898  Object *ob = (Object *)ptr->owner_id;
899 
902 }
903 
904 static void rna_softbody_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
905 {
906  Object *ob = (Object *)ptr->owner_id;
907 
910 }
911 
912 static void rna_softbody_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr)
913 {
915  rna_softbody_update(bmain, scene, ptr);
916 }
917 
918 static const EnumPropertyItem *rna_Effector_shape_itemf(bContext *UNUSED(C),
919  PointerRNA *ptr,
920  PropertyRNA *UNUSED(prop),
921  bool *UNUSED(r_free))
922 {
923  Object *ob = NULL;
924 
925  if (particle_id_check(ptr)) {
926  return empty_shape_items;
927  }
928 
929  ob = (Object *)ptr->owner_id;
930 
931  if (ob->type == OB_CURVES_LEGACY) {
932  if (ob->pd->forcefield == PFIELD_VORTEX) {
933  return curve_vortex_shape_items;
934  }
935 
936  return curve_shape_items;
937  }
938  else if (ELEM(ob->type, OB_MESH, OB_SURF, OB_FONT)) {
939  if (ob->pd->forcefield == PFIELD_VORTEX) {
940  return vortex_shape_items;
941  }
942 
943  return effector_shape_items;
944  }
945  else {
946  if (ob->pd->forcefield == PFIELD_VORTEX) {
947  return empty_vortex_shape_items;
948  }
949 
950  return empty_shape_items;
951  }
952 }
953 
954 #else
955 
957 {
958  PropertyRNA *prop;
959 
960  static const EnumPropertyItem point_cache_compress_items[] = {
961  {PTCACHE_COMPRESS_NO, "NO", 0, "None", "No compression"},
962  {PTCACHE_COMPRESS_LZO, "LIGHT", 0, "Lite", "Fast but not so effective compression"},
963  {PTCACHE_COMPRESS_LZMA, "HEAVY", 0, "Heavy", "Effective but slow compression"},
964  {0, NULL, 0, NULL, NULL},
965  };
966 
967  RNA_def_struct_path_func(srna, "rna_PointCache_path");
968 
970 
971  prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);
972  RNA_def_property_int_sdna(prop, NULL, "startframe");
974  RNA_def_property_ui_range(prop, 0, MAXFRAME, 1, 1);
975  RNA_def_property_ui_text(prop, "Start", "Frame on which the simulation starts");
976 
977  prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_TIME);
978  RNA_def_property_int_sdna(prop, NULL, "endframe");
980  RNA_def_property_ui_text(prop, "End", "Frame on which the simulation stops");
981 
982  prop = RNA_def_property(srna, "frame_step", PROP_INT, PROP_NONE);
983  RNA_def_property_int_sdna(prop, NULL, "step");
984  RNA_def_property_range(prop, 1, 20);
985  RNA_def_property_int_funcs(prop, NULL, NULL, "rna_PointCache_frame_step_range");
986  RNA_def_property_ui_text(prop, "Cache Step", "Number of frames between cached frames");
987  RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_change");
988 
989  prop = RNA_def_property(srna, "index", PROP_INT, PROP_NONE);
990  RNA_def_property_int_sdna(prop, NULL, "index");
991  RNA_def_property_range(prop, -1, 100);
992  RNA_def_property_ui_text(prop, "Cache Index", "Index number of cache files");
993  RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change");
994 
995  prop = RNA_def_property(srna, "compression", PROP_ENUM, PROP_NONE);
996  RNA_def_property_enum_items(prop, point_cache_compress_items);
997  RNA_def_property_ui_text(prop, "Cache Compression", "Compression method to be used");
998 
999  /* flags */
1000  prop = RNA_def_property(srna, "is_baked", PROP_BOOLEAN, PROP_NONE);
1003  RNA_def_property_ui_text(prop, "", "The cache is baked");
1004 
1005  prop = RNA_def_property(srna, "is_baking", PROP_BOOLEAN, PROP_NONE);
1008  RNA_def_property_ui_text(prop, "", "The cache is being baked");
1009 
1010  prop = RNA_def_property(srna, "use_disk_cache", PROP_BOOLEAN, PROP_NONE);
1013  prop, "Disk Cache", "Save cache files to disk (.blend file must be saved first)");
1014  RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_toggle_disk_cache");
1015  RNA_def_property_override_funcs(prop, NULL, NULL, "rna_Cache_use_disk_cache_override_apply");
1016 
1017  prop = RNA_def_property(srna, "is_outdated", PROP_BOOLEAN, PROP_NONE);
1020  RNA_def_property_ui_text(prop, "Cache Is Outdated", "");
1021 
1022  prop = RNA_def_property(srna, "is_frame_skip", PROP_BOOLEAN, PROP_NONE);
1025  RNA_def_property_ui_text(prop, "", "Some frames were skipped while baking/saving that cache");
1026 
1027  prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1028  RNA_def_property_string_sdna(prop, NULL, "name");
1029  RNA_def_property_ui_text(prop, "Name", "Cache name");
1030  RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change");
1031  RNA_def_struct_name_property(srna, prop);
1032 
1033  prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_DIRPATH);
1034  RNA_def_property_string_sdna(prop, NULL, "path");
1035  RNA_def_property_ui_text(prop, "File Path", "Cache file path");
1036  RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change");
1037 
1038  /* removed, see PTCACHE_QUICK_CACHE */
1039 # if 0
1040  prop = RNA_def_property(srna, "use_quick_cache", PROP_BOOLEAN, PROP_NONE);
1041  RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_QUICK_CACHE);
1042  RNA_def_property_ui_text(prop, "Quick Cache", "Update simulation with cache steps");
1043  RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_change");
1044 # endif
1045 
1046  prop = RNA_def_property(srna, "info", PROP_STRING, PROP_NONE);
1047  RNA_def_property_string_sdna(prop, NULL, "info");
1050  /* Note that we do not actually need a getter here, `rna_Cache_info_length` will update the info
1051  * string just as well. */
1052  RNA_def_property_string_funcs(prop, NULL, "rna_Cache_info_length", NULL);
1054  prop, sizeof(((PointCache *)0)->info) / sizeof(*(((PointCache *)0)->info)));
1055  RNA_def_property_ui_text(prop, "Cache Info", "Info on current cache status");
1056 
1057  prop = RNA_def_property(srna, "use_external", PROP_BOOLEAN, PROP_NONE);
1059  RNA_def_property_ui_text(prop, "External", "Read cache from an external location");
1060  RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change");
1061 
1062  prop = RNA_def_property(srna, "use_library_path", PROP_BOOLEAN, PROP_NONE);
1065  prop,
1066  "Library Path",
1067  "Use this file's path for the disk cache when library linked into another file "
1068  "(for local bakes per scene file, disable this option)");
1069  RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change");
1070 
1072 }
1073 
1075 {
1076  StructRNA *srna;
1077  PropertyRNA *prop;
1078 
1079  // FunctionRNA *func;
1080  // PropertyRNA *parm;
1081 
1082  RNA_def_property_srna(cprop, "PointCaches");
1083  srna = RNA_def_struct(brna, "PointCaches", NULL);
1084  RNA_def_struct_sdna(srna, "PointCache");
1085  RNA_def_struct_ui_text(srna, "Point Caches", "Collection of point caches");
1086 
1087  prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED);
1089  "rna_Cache_active_point_cache_index_get",
1090  "rna_Cache_active_point_cache_index_set",
1091  "rna_Cache_active_point_cache_index_range");
1092  RNA_def_property_ui_text(prop, "Active Point Cache Index", "");
1093  RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_change");
1094 
1095  /* And define another RNA type for those collection items. */
1096  srna = RNA_def_struct(brna, "PointCacheItem", NULL);
1097  RNA_def_struct_sdna(srna, "PointCache");
1098  RNA_def_struct_ui_text(srna, "Point Cache", "Point cache for physics simulations");
1099  RNA_def_struct_ui_icon(srna, ICON_PHYSICS);
1100 
1102 }
1103 
1105 {
1106  StructRNA *srna;
1107  PropertyRNA *prop;
1108 
1109  srna = RNA_def_struct(brna, "PointCache", NULL);
1110  RNA_def_struct_ui_text(srna, "Active Point Cache", "Active point cache for physics simulations");
1111  RNA_def_struct_ui_icon(srna, ICON_PHYSICS);
1112 
1114 
1115  /* This first-level RNA pointer also has list of all caches from owning ID.
1116  * Those caches items have exact same content as 'active' one, except for that collection,
1117  * to prevent ugly recursive layout pattern.
1118  *
1119  * NOTE: This shall probably be redone from scratch in a proper way at some point,
1120  * but for now that will do, and shall not break anything in the API. */
1121  prop = RNA_def_property(srna, "point_caches", PROP_COLLECTION, PROP_NONE);
1123  "rna_Cache_list_begin",
1124  "rna_iterator_listbase_next",
1125  "rna_iterator_listbase_end",
1126  "rna_iterator_listbase_get",
1127  NULL,
1128  NULL,
1129  NULL,
1130  NULL);
1131  RNA_def_property_struct_type(prop, "PointCacheItem");
1132  RNA_def_property_ui_text(prop, "Point Cache List", "");
1134  rna_def_ptcache_point_caches(brna, prop);
1135 }
1136 
1137 static void rna_def_collision(BlenderRNA *brna)
1138 {
1139  StructRNA *srna;
1140  PropertyRNA *prop;
1141 
1142  srna = RNA_def_struct(brna, "CollisionSettings", NULL);
1143  RNA_def_struct_sdna(srna, "PartDeflect");
1144  RNA_def_struct_path_func(srna, "rna_CollisionSettings_path");
1146  srna, "Collision Settings", "Collision settings for object in physics simulation");
1147 
1149 
1150  prop = RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE);
1151  RNA_def_property_boolean_sdna(prop, NULL, "deflect", 1);
1153  prop, "Enabled", "Enable this objects as a collider for physics systems");
1154  RNA_def_property_update(prop, 0, "rna_CollisionSettings_dependency_update");
1155 
1156  /* Particle Interaction */
1157 
1158  prop = RNA_def_property(srna, "damping_factor", PROP_FLOAT, PROP_FACTOR);
1159  RNA_def_property_float_sdna(prop, NULL, "pdef_damp");
1160  RNA_def_property_range(prop, 0.0f, 1.0f);
1161  RNA_def_property_ui_text(prop, "Damping Factor", "Amount of damping during particle collision");
1162  RNA_def_property_update(prop, 0, "rna_CollisionSettings_update");
1163 
1164  prop = RNA_def_property(srna, "damping_random", PROP_FLOAT, PROP_FACTOR);
1165  RNA_def_property_float_sdna(prop, NULL, "pdef_rdamp");
1166  RNA_def_property_range(prop, 0.0f, 1.0f);
1167  RNA_def_property_ui_text(prop, "Random Damping", "Random variation of damping");
1168  RNA_def_property_update(prop, 0, "rna_CollisionSettings_update");
1169 
1170  prop = RNA_def_property(srna, "friction_factor", PROP_FLOAT, PROP_FACTOR);
1171  RNA_def_property_float_sdna(prop, NULL, "pdef_frict");
1172  RNA_def_property_range(prop, 0.0f, 1.0f);
1174  prop, "Friction Factor", "Amount of friction during particle collision");
1175  RNA_def_property_update(prop, 0, "rna_CollisionSettings_update");
1176 
1177  prop = RNA_def_property(srna, "friction_random", PROP_FLOAT, PROP_FACTOR);
1178  RNA_def_property_float_sdna(prop, NULL, "pdef_rfrict");
1179  RNA_def_property_range(prop, 0.0f, 1.0f);
1180  RNA_def_property_ui_text(prop, "Random Friction", "Random variation of friction");
1181  RNA_def_property_update(prop, 0, "rna_CollisionSettings_update");
1182 
1183  prop = RNA_def_property(srna, "permeability", PROP_FLOAT, PROP_FACTOR);
1184  RNA_def_property_float_sdna(prop, NULL, "pdef_perm");
1185  RNA_def_property_range(prop, 0.0f, 1.0f);
1187  prop, "Permeability", "Chance that the particle will pass through the mesh");
1188  RNA_def_property_update(prop, 0, "rna_CollisionSettings_update");
1189 
1190  prop = RNA_def_property(srna, "use_particle_kill", PROP_BOOLEAN, PROP_NONE);
1192  RNA_def_property_ui_text(prop, "Kill Particles", "Kill collided particles");
1193  RNA_def_property_update(prop, 0, "rna_CollisionSettings_update");
1194 
1195  prop = RNA_def_property(srna, "stickiness", PROP_FLOAT, PROP_NONE);
1196  RNA_def_property_float_sdna(prop, NULL, "pdef_stickness");
1197  RNA_def_property_range(prop, 0.0f, 10.0f);
1198  RNA_def_property_ui_text(prop, "Stickiness", "Amount of stickiness to surface collision");
1199  RNA_def_property_update(prop, 0, "rna_CollisionSettings_update");
1200 
1201  /* Soft Body and Cloth Interaction */
1202 
1203  prop = RNA_def_property(srna, "thickness_inner", PROP_FLOAT, PROP_NONE);
1204  RNA_def_property_float_sdna(prop, NULL, "pdef_sbift");
1205  RNA_def_property_range(prop, 0.001f, 1.0f);
1207  prop, "Inner Thickness", "Inner face thickness (only used by softbodies)");
1208  RNA_def_property_update(prop, 0, "rna_CollisionSettings_update");
1209 
1210  prop = RNA_def_property(srna, "thickness_outer", PROP_FLOAT, PROP_NONE);
1211  RNA_def_property_float_sdna(prop, NULL, "pdef_sboft");
1212  RNA_def_property_range(prop, 0.001f, 1.0f);
1213  RNA_def_property_ui_text(prop, "Outer Thickness", "Outer face thickness");
1214  RNA_def_property_update(prop, 0, "rna_CollisionSettings_update");
1215 
1216  prop = RNA_def_property(srna, "damping", PROP_FLOAT, PROP_FACTOR);
1217  RNA_def_property_float_sdna(prop, NULL, "pdef_sbdamp");
1218  RNA_def_property_range(prop, 0.0f, 1.0f);
1219  RNA_def_property_ui_text(prop, "Damping", "Amount of damping during collision");
1220  RNA_def_property_update(prop, 0, "rna_CollisionSettings_update");
1221 
1222  prop = RNA_def_property(srna, "absorption", PROP_FLOAT, PROP_FACTOR);
1223  RNA_def_property_range(prop, 0.0f, 1.0f);
1224  RNA_def_property_ui_range(prop, 0.0f, 1.0f, 1, 2);
1226  prop,
1227  "Absorption",
1228  "How much of effector force gets lost during collision with this object (in percent)");
1229  RNA_def_property_update(prop, 0, "rna_CollisionSettings_update");
1230 
1231  prop = RNA_def_property(srna, "cloth_friction", PROP_FLOAT, PROP_NONE);
1232  RNA_def_property_float_sdna(prop, NULL, "pdef_cfrict");
1233  RNA_def_property_range(prop, 0.0f, 80.0f);
1234  RNA_def_property_ui_text(prop, "Friction", "Friction for cloth collisions");
1235  RNA_def_property_update(prop, 0, "rna_CollisionSettings_update");
1236 
1237  prop = RNA_def_property(srna, "use_culling", PROP_BOOLEAN, PROP_NONE);
1240  prop,
1241  "Single Sided",
1242  "Cloth collision acts with respect to the collider normals (improves penetration recovery)");
1243  RNA_def_property_update(prop, 0, "rna_CollisionSettings_update");
1244 
1245  prop = RNA_def_property(srna, "use_normal", PROP_BOOLEAN, PROP_NONE);
1248  "Override Normals",
1249  "Cloth collision impulses act in the direction of the collider normals "
1250  "(more reliable in some cases)");
1251  RNA_def_property_update(prop, 0, "rna_CollisionSettings_update");
1252 
1254 }
1255 
1257 {
1258  StructRNA *srna;
1259  PropertyRNA *prop;
1260 
1261  srna = RNA_def_struct(brna, "EffectorWeights", NULL);
1262  RNA_def_struct_sdna(srna, "EffectorWeights");
1263  RNA_def_struct_path_func(srna, "rna_EffectorWeight_path");
1264  RNA_def_struct_ui_text(srna, "Effector Weights", "Effector weights for physics simulation");
1265  RNA_def_struct_ui_icon(srna, ICON_PHYSICS);
1266 
1268 
1269  /* Flags */
1270  prop = RNA_def_property(srna, "apply_to_hair_growing", PROP_BOOLEAN, PROP_NONE);
1272  RNA_def_property_ui_text(prop, "Use For Growing Hair", "Use force fields when growing hair");
1273  RNA_def_property_update(prop, 0, "rna_EffectorWeight_update");
1274 
1275  /* General */
1276  prop = RNA_def_property(srna, "collection", PROP_POINTER, PROP_NONE);
1277  RNA_def_property_struct_type(prop, "Collection");
1278  RNA_def_property_pointer_sdna(prop, NULL, "group");
1280  RNA_def_property_ui_text(prop, "Effector Collection", "Limit effectors to this collection");
1281  RNA_def_property_update(prop, 0, "rna_EffectorWeight_dependency_update");
1282 
1283  prop = RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_NONE);
1284  RNA_def_property_float_sdna(prop, NULL, "global_gravity");
1285  RNA_def_property_range(prop, -200.0f, 200.0f);
1286  RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3);
1287  RNA_def_property_ui_text(prop, "Gravity", "Global gravity weight");
1288  RNA_def_property_update(prop, 0, "rna_EffectorWeight_update");
1289 
1290  /* Effector weights */
1291  prop = RNA_def_property(srna, "all", PROP_FLOAT, PROP_NONE);
1292  RNA_def_property_float_sdna(prop, NULL, "weight[0]");
1293  RNA_def_property_range(prop, -200.0f, 200.0f);
1294  RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3);
1295  RNA_def_property_ui_text(prop, "All", "All effector's weight");
1296  RNA_def_property_update(prop, 0, "rna_EffectorWeight_update");
1297 
1298  prop = RNA_def_property(srna, "force", PROP_FLOAT, PROP_NONE);
1299  RNA_def_property_float_sdna(prop, NULL, "weight[1]");
1300  RNA_def_property_range(prop, -200.0f, 200.0f);
1301  RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3);
1302  RNA_def_property_ui_text(prop, "Force", "Force effector weight");
1303  RNA_def_property_update(prop, 0, "rna_EffectorWeight_update");
1304 
1305  prop = RNA_def_property(srna, "vortex", PROP_FLOAT, PROP_NONE);
1306  RNA_def_property_float_sdna(prop, NULL, "weight[2]");
1307  RNA_def_property_range(prop, -200.0f, 200.0f);
1308  RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3);
1309  RNA_def_property_ui_text(prop, "Vortex", "Vortex effector weight");
1310  RNA_def_property_update(prop, 0, "rna_EffectorWeight_update");
1311 
1312  prop = RNA_def_property(srna, "magnetic", PROP_FLOAT, PROP_NONE);
1313  RNA_def_property_float_sdna(prop, NULL, "weight[3]");
1314  RNA_def_property_range(prop, -200.0f, 200.0f);
1315  RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3);
1316  RNA_def_property_ui_text(prop, "Magnetic", "Magnetic effector weight");
1317  RNA_def_property_update(prop, 0, "rna_EffectorWeight_update");
1318 
1319  prop = RNA_def_property(srna, "wind", PROP_FLOAT, PROP_NONE);
1320  RNA_def_property_float_sdna(prop, NULL, "weight[4]");
1321  RNA_def_property_range(prop, -200.0f, 200.0f);
1322  RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3);
1323  RNA_def_property_ui_text(prop, "Wind", "Wind effector weight");
1324  RNA_def_property_update(prop, 0, "rna_EffectorWeight_update");
1325 
1326  prop = RNA_def_property(srna, "curve_guide", PROP_FLOAT, PROP_NONE);
1327  RNA_def_property_float_sdna(prop, NULL, "weight[5]");
1328  RNA_def_property_range(prop, -200.0f, 200.0f);
1329  RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3);
1330  RNA_def_property_ui_text(prop, "Curve Guide", "Curve guide effector weight");
1331  RNA_def_property_update(prop, 0, "rna_EffectorWeight_update");
1332 
1333  prop = RNA_def_property(srna, "texture", PROP_FLOAT, PROP_NONE);
1334  RNA_def_property_float_sdna(prop, NULL, "weight[6]");
1335  RNA_def_property_range(prop, -200.0f, 200.0f);
1336  RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3);
1337  RNA_def_property_ui_text(prop, "Texture", "Texture effector weight");
1338  RNA_def_property_update(prop, 0, "rna_EffectorWeight_update");
1339 
1340  prop = RNA_def_property(srna, "harmonic", PROP_FLOAT, PROP_NONE);
1341  RNA_def_property_float_sdna(prop, NULL, "weight[7]");
1342  RNA_def_property_range(prop, -200.0f, 200.0f);
1343  RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3);
1344  RNA_def_property_ui_text(prop, "Harmonic", "Harmonic effector weight");
1345  RNA_def_property_update(prop, 0, "rna_EffectorWeight_update");
1346 
1347  prop = RNA_def_property(srna, "charge", PROP_FLOAT, PROP_NONE);
1348  RNA_def_property_float_sdna(prop, NULL, "weight[8]");
1349  RNA_def_property_range(prop, -200.0f, 200.0f);
1350  RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3);
1351  RNA_def_property_ui_text(prop, "Charge", "Charge effector weight");
1352  RNA_def_property_update(prop, 0, "rna_EffectorWeight_update");
1353 
1354  prop = RNA_def_property(srna, "lennardjones", PROP_FLOAT, PROP_NONE);
1355  RNA_def_property_float_sdna(prop, NULL, "weight[9]");
1356  RNA_def_property_range(prop, -200.0f, 200.0f);
1357  RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3);
1358  RNA_def_property_ui_text(prop, "Lennard-Jones", "Lennard-Jones effector weight");
1359  RNA_def_property_update(prop, 0, "rna_EffectorWeight_update");
1360 
1361  prop = RNA_def_property(srna, "boid", PROP_FLOAT, PROP_NONE);
1362  RNA_def_property_float_sdna(prop, NULL, "weight[10]");
1363  RNA_def_property_range(prop, -200.0f, 200.0f);
1364  RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3);
1365  RNA_def_property_ui_text(prop, "Boid", "Boid effector weight");
1366  RNA_def_property_update(prop, 0, "rna_EffectorWeight_update");
1367 
1368  prop = RNA_def_property(srna, "turbulence", PROP_FLOAT, PROP_NONE);
1369  RNA_def_property_float_sdna(prop, NULL, "weight[11]");
1370  RNA_def_property_range(prop, -200.0f, 200.0f);
1371  RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3);
1372  RNA_def_property_ui_text(prop, "Turbulence", "Turbulence effector weight");
1373  RNA_def_property_update(prop, 0, "rna_EffectorWeight_update");
1374 
1375  prop = RNA_def_property(srna, "drag", PROP_FLOAT, PROP_NONE);
1376  RNA_def_property_float_sdna(prop, NULL, "weight[12]");
1377  RNA_def_property_range(prop, -200.0f, 200.0f);
1378  RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3);
1379  RNA_def_property_ui_text(prop, "Drag", "Drag effector weight");
1380  RNA_def_property_update(prop, 0, "rna_EffectorWeight_update");
1381 
1382  prop = RNA_def_property(srna, "smokeflow", PROP_FLOAT, PROP_NONE);
1383  RNA_def_property_float_sdna(prop, NULL, "weight[13]");
1384  RNA_def_property_range(prop, -200.0f, 200.0f);
1385  RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1, 3);
1386  RNA_def_property_ui_text(prop, "Fluid Flow", "Fluid Flow effector weight");
1387  RNA_def_property_update(prop, 0, "rna_EffectorWeight_update");
1388 
1390 }
1391 
1392 static void rna_def_field(BlenderRNA *brna)
1393 {
1394  StructRNA *srna;
1395  PropertyRNA *prop;
1396 
1397  static const EnumPropertyItem field_type_items[] = {
1398  {0, "NONE", ICON_BLANK1, "None", ""},
1399  {PFIELD_BOID,
1400  "BOID",
1401  ICON_FORCE_BOID,
1402  "Boid",
1403  "Create a force that acts as a boid's predators or target"},
1404  {PFIELD_CHARGE,
1405  "CHARGE",
1406  ICON_FORCE_CHARGE,
1407  "Charge",
1408  "Spherical forcefield based on the charge of particles, "
1409  "only influences other charge force fields"},
1410  {PFIELD_GUIDE,
1411  "GUIDE",
1412  ICON_FORCE_CURVE,
1413  "Curve Guide",
1414  "Create a force along a curve object"},
1415  {PFIELD_DRAG, "DRAG", ICON_FORCE_DRAG, "Drag", "Create a force that dampens motion"},
1417  "FLUID_FLOW",
1418  ICON_FORCE_FLUIDFLOW,
1419  "Fluid Flow",
1420  "Create a force based on fluid simulation velocities"},
1421  {PFIELD_FORCE,
1422  "FORCE",
1423  ICON_FORCE_FORCE,
1424  "Force",
1425  "Radial field toward the center of object"},
1426  {PFIELD_HARMONIC,
1427  "HARMONIC",
1428  ICON_FORCE_HARMONIC,
1429  "Harmonic",
1430  "The source of this force field is the zero point of a harmonic oscillator"},
1431  {PFIELD_LENNARDJ,
1432  "LENNARDJ",
1433  ICON_FORCE_LENNARDJONES,
1434  "Lennard-Jones",
1435  "Forcefield based on the Lennard-Jones potential"},
1436  {PFIELD_MAGNET,
1437  "MAGNET",
1438  ICON_FORCE_MAGNETIC,
1439  "Magnetic",
1440  "Forcefield depends on the speed of the particles"},
1441  {PFIELD_TEXTURE, "TEXTURE", ICON_FORCE_TEXTURE, "Texture", "Force field based on a texture"},
1443  "TURBULENCE",
1444  ICON_FORCE_TURBULENCE,
1445  "Turbulence",
1446  "Create turbulence with a noise field"},
1447  {PFIELD_VORTEX,
1448  "VORTEX",
1449  ICON_FORCE_VORTEX,
1450  "Vortex",
1451  "Spiraling force that twists the force object's local Z axis"},
1452  {PFIELD_WIND,
1453  "WIND",
1454  ICON_FORCE_WIND,
1455  "Wind",
1456  "Constant force along the force object's local Z axis"},
1457  {0, NULL, 0, NULL, NULL},
1458  };
1459 
1460  static const EnumPropertyItem falloff_items[] = {
1461  {PFIELD_FALL_CONE, "CONE", 0, "Cone", ""},
1462  {PFIELD_FALL_SPHERE, "SPHERE", 0, "Sphere", ""},
1463  {PFIELD_FALL_TUBE, "TUBE", 0, "Tube", ""},
1464  {0, NULL, 0, NULL, NULL},
1465  };
1466 
1467  static const EnumPropertyItem texture_items[] = {
1468  {PFIELD_TEX_CURL, "CURL", 0, "Curl", ""},
1469  {PFIELD_TEX_GRAD, "GRADIENT", 0, "Gradient", ""},
1470  {PFIELD_TEX_RGB, "RGB", 0, "RGB", ""},
1471  {0, NULL, 0, NULL, NULL},
1472  };
1473 
1474  static const EnumPropertyItem zdirection_items[] = {
1475  {PFIELD_Z_POS, "POSITIVE", 0, "+Z", ""},
1476  {PFIELD_Z_NEG, "NEGATIVE", 0, "-Z", ""},
1477  {PFIELD_Z_BOTH, "BOTH", 0, "Both Z", ""},
1478  {0, NULL, 0, NULL, NULL},
1479  };
1480 
1481  static const EnumPropertyItem guide_kink_items[] = {
1482  {0, "NONE", 0, "None", ""},
1483  {4, "BRAID", 0, "Braid", ""},
1484  {1, "CURL", 0, "Curl", ""},
1485  {2, "RADIAL", 0, "Radial", ""},
1486  {6, "ROLL", 0, "Roll", ""},
1487  {5, "ROTATION", 0, "Rotation", ""},
1488  {3, "WAVE", 0, "Wave", ""},
1489  {0, NULL, 0, NULL, NULL},
1490  };
1491 
1492  srna = RNA_def_struct(brna, "FieldSettings", NULL);
1493  RNA_def_struct_sdna(srna, "PartDeflect");
1494  RNA_def_struct_path_func(srna, "rna_FieldSettings_path");
1496  srna, "Field Settings", "Field settings for an object in physics simulation");
1497  RNA_def_struct_ui_icon(srna, ICON_PHYSICS);
1498 
1500 
1501  /* Enums */
1502 
1503  prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1504  RNA_def_property_enum_sdna(prop, NULL, "forcefield");
1506  RNA_def_property_enum_funcs(prop, NULL, "rna_FieldSettings_type_set", NULL);
1507  RNA_def_property_ui_text(prop, "Type", "Type of field");
1508  RNA_def_property_update(prop, 0, "rna_FieldSettings_dependency_update");
1509 
1510  prop = RNA_def_property(srna, "shape", PROP_ENUM, PROP_NONE);
1512  RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Effector_shape_itemf");
1514  prop, "Shape", "Which direction is used to calculate the effector force");
1515  RNA_def_property_update(prop, 0, "rna_FieldSettings_shape_update");
1516 
1517  prop = RNA_def_property(srna, "falloff_type", PROP_ENUM, PROP_NONE);
1518  RNA_def_property_enum_sdna(prop, NULL, "falloff");
1519  RNA_def_property_enum_items(prop, falloff_items);
1520  RNA_def_property_ui_text(prop, "Fall-Off", "");
1521  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1522 
1523  prop = RNA_def_property(srna, "texture_mode", PROP_ENUM, PROP_NONE);
1524  RNA_def_property_enum_sdna(prop, NULL, "tex_mode");
1525  RNA_def_property_enum_items(prop, texture_items);
1527  prop,
1528  "Texture Mode",
1529  "How the texture effect is calculated (RGB and Curl need a RGB texture, "
1530  "else Gradient will be used instead)");
1531  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1532 
1533  prop = RNA_def_property(srna, "z_direction", PROP_ENUM, PROP_NONE);
1534  RNA_def_property_enum_sdna(prop, NULL, "zdir");
1535  RNA_def_property_enum_items(prop, zdirection_items);
1537  prop, "Z Direction", "Effect in full or only positive/negative Z direction");
1538  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1539 
1540  /* Float */
1541 
1542  prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE);
1543  RNA_def_property_float_sdna(prop, NULL, "f_strength");
1544  RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 10, 3);
1545  RNA_def_property_ui_text(prop, "Strength", "Strength of force field");
1546  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1547 
1548  /* different ui range to above */
1549  prop = RNA_def_property(srna, "linear_drag", PROP_FLOAT, PROP_NONE);
1550  RNA_def_property_float_sdna(prop, NULL, "f_strength");
1551  RNA_def_property_ui_range(prop, -2.0f, 2.0f, 10, 3);
1552  RNA_def_property_ui_text(prop, "Linear Drag", "Drag component proportional to velocity");
1553  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1554 
1555  prop = RNA_def_property(srna, "harmonic_damping", PROP_FLOAT, PROP_NONE);
1556  RNA_def_property_float_sdna(prop, NULL, "f_damp");
1557  RNA_def_property_ui_range(prop, 0.0f, 10.0f, 10, 3);
1558  RNA_def_property_ui_text(prop, "Harmonic Damping", "Damping of the harmonic force");
1559  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1560 
1561  /* different ui range to above */
1562  prop = RNA_def_property(srna, "quadratic_drag", PROP_FLOAT, PROP_NONE);
1563  RNA_def_property_float_sdna(prop, NULL, "f_damp");
1564  RNA_def_property_ui_range(prop, -2.0f, 2.0f, 10, 3);
1566  prop, "Quadratic Drag", "Drag component proportional to the square of velocity");
1567  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1568 
1569  prop = RNA_def_property(srna, "flow", PROP_FLOAT, PROP_NONE);
1570  RNA_def_property_float_sdna(prop, NULL, "f_flow");
1571  RNA_def_property_ui_range(prop, 0.0f, 10.0f, 10, 3);
1572  RNA_def_property_ui_text(prop, "Flow", "Convert effector force into air flow velocity");
1573  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1574 
1575  prop = RNA_def_property(srna, "wind_factor", PROP_FLOAT, PROP_FACTOR);
1576  RNA_def_property_float_sdna(prop, NULL, "f_wind_factor");
1577  RNA_def_property_range(prop, 0.0f, 1.0f);
1579  prop,
1580  "Wind Factor",
1581  "How much the force is reduced when acting parallel to a surface, e.g. cloth");
1582  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1583 
1584  /* different ui range to above */
1585  prop = RNA_def_property(srna, "inflow", PROP_FLOAT, PROP_NONE);
1586  RNA_def_property_float_sdna(prop, NULL, "f_flow");
1587  RNA_def_property_ui_range(prop, -10.0f, 10.0f, 10, 3);
1588  RNA_def_property_ui_text(prop, "Inflow", "Inwards component of the vortex force");
1589  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1590 
1591  prop = RNA_def_property(srna, "size", PROP_FLOAT, PROP_NONE);
1592  RNA_def_property_float_sdna(prop, NULL, "f_size");
1593  RNA_def_property_range(prop, 0.0f, FLT_MAX);
1594  RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1.0f, 3);
1595  RNA_def_property_ui_text(prop, "Size", "Size of the turbulence");
1596  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1597 
1598  prop = RNA_def_property(srna, "rest_length", PROP_FLOAT, PROP_NONE);
1599  RNA_def_property_float_sdna(prop, NULL, "f_size");
1600  RNA_def_property_range(prop, 0.0f, FLT_MAX);
1601  RNA_def_property_ui_range(prop, 0.0f, 1000.0f, 10, 3);
1602  RNA_def_property_ui_text(prop, "Rest Length", "Rest length of the harmonic force");
1603  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1604 
1605  prop = RNA_def_property(srna, "falloff_power", PROP_FLOAT, PROP_NONE);
1606  RNA_def_property_float_sdna(prop, NULL, "f_power");
1607  RNA_def_property_range(prop, 0.0f, 10.0f);
1609  prop, "Falloff Power", "How quickly strength falls off with distance from the force field");
1610  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1611 
1612  prop = RNA_def_property(srna, "distance_min", PROP_FLOAT, PROP_DISTANCE);
1613  RNA_def_property_float_sdna(prop, NULL, "mindist");
1614  RNA_def_property_range(prop, 0.0f, 1000.0f);
1615  RNA_def_property_ui_text(prop, "Minimum Distance", "Minimum distance for the field's fall-off");
1616  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1617 
1618  prop = RNA_def_property(srna, "distance_max", PROP_FLOAT, PROP_DISTANCE);
1619  RNA_def_property_float_sdna(prop, NULL, "maxdist");
1620  RNA_def_property_range(prop, 0.0f, FLT_MAX);
1621  RNA_def_property_ui_range(prop, 0.0f, 1000.0f, 1.0f, 3);
1622  RNA_def_property_ui_text(prop, "Maximum Distance", "Maximum distance for the field to work");
1623  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1624 
1625  prop = RNA_def_property(srna, "radial_min", PROP_FLOAT, PROP_NONE);
1626  RNA_def_property_float_sdna(prop, NULL, "minrad");
1627  RNA_def_property_range(prop, 0.0f, 1000.0f);
1629  prop, "Minimum Radial Distance", "Minimum radial distance for the field's fall-off");
1630  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1631 
1632  prop = RNA_def_property(srna, "radial_max", PROP_FLOAT, PROP_NONE);
1633  RNA_def_property_float_sdna(prop, NULL, "maxrad");
1634  RNA_def_property_range(prop, 0.0f, 1000.0f);
1636  prop, "Maximum Radial Distance", "Maximum radial distance for the field to work");
1637  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1638 
1639  prop = RNA_def_property(srna, "radial_falloff", PROP_FLOAT, PROP_NONE);
1640  RNA_def_property_float_sdna(prop, NULL, "f_power_r");
1641  RNA_def_property_range(prop, 0.0f, 10.0f);
1643  prop, "Radial Falloff Power", "Radial falloff power (real gravitational falloff = 2)");
1644  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1645 
1646  prop = RNA_def_property(srna, "texture_nabla", PROP_FLOAT, PROP_NONE);
1647  RNA_def_property_float_sdna(prop, NULL, "tex_nabla");
1648  RNA_def_property_range(prop, 0.0001f, 1.0f);
1650  prop, "Nabla", "Defines size of derivative offset used for calculating gradient and curl");
1651  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1652 
1653  prop = RNA_def_property(srna, "noise", PROP_FLOAT, PROP_NONE);
1654  RNA_def_property_float_sdna(prop, NULL, "f_noise");
1655  RNA_def_property_range(prop, 0.0f, 10.0f);
1656  RNA_def_property_ui_text(prop, "Noise", "Amount of noise for the force strength");
1657  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1658 
1659  prop = RNA_def_property(srna, "seed", PROP_INT, PROP_UNSIGNED);
1660  RNA_def_property_range(prop, 1, 128);
1661  RNA_def_property_ui_text(prop, "Seed", "Seed of the noise");
1662  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1663 
1664  /* Boolean */
1665 
1666  prop = RNA_def_property(srna, "use_min_distance", PROP_BOOLEAN, PROP_NONE);
1668  RNA_def_property_ui_text(prop, "Use Min", "Use a minimum distance for the field's fall-off");
1669  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1670 
1671  prop = RNA_def_property(srna, "use_max_distance", PROP_BOOLEAN, PROP_NONE);
1673  RNA_def_property_ui_text(prop, "Use Max", "Use a maximum distance for the field to work");
1674  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1675 
1676  prop = RNA_def_property(srna, "use_radial_min", PROP_BOOLEAN, PROP_NONE);
1679  prop, "Use Min", "Use a minimum radial distance for the field's fall-off");
1680  /* "Use a minimum angle for the field's fall-off" */
1681  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1682 
1683  prop = RNA_def_property(srna, "use_radial_max", PROP_BOOLEAN, PROP_NONE);
1685  RNA_def_property_ui_text(prop, "Use Max", "Use a maximum radial distance for the field to work");
1686  /* "Use a maximum angle for the field to work" */
1687  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1688 
1689  prop = RNA_def_property(srna, "use_object_coords", PROP_BOOLEAN, PROP_NONE);
1691  RNA_def_property_ui_text(prop, "Use Coordinates", "Use object/global coordinates for texture");
1692  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1693 
1694  prop = RNA_def_property(srna, "use_global_coords", PROP_BOOLEAN, PROP_NONE);
1697  prop, "Use Global Coordinates", "Use effector/global coordinates for turbulence");
1698  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1699 
1700  prop = RNA_def_property(srna, "use_2d_force", PROP_BOOLEAN, PROP_NONE);
1702  RNA_def_property_ui_text(prop, "2D", "Apply force only in 2D");
1703  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1704 
1705  prop = RNA_def_property(srna, "use_root_coords", PROP_BOOLEAN, PROP_NONE);
1708  prop, "Root Texture Coordinates", "Texture coordinates from root particle locations");
1709  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1710 
1711  prop = RNA_def_property(srna, "apply_to_location", PROP_BOOLEAN, PROP_NONE);
1713  RNA_def_property_ui_text(prop, "Location", "Affect particle's location");
1714  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1715 
1716  prop = RNA_def_property(srna, "apply_to_rotation", PROP_BOOLEAN, PROP_NONE);
1718  RNA_def_property_ui_text(prop, "Rotation", "Affect particle's dynamic rotation");
1719  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1720 
1721  prop = RNA_def_property(srna, "use_absorption", PROP_BOOLEAN, PROP_NONE);
1723  RNA_def_property_ui_text(prop, "Absorption", "Force gets absorbed by collision objects");
1724  RNA_def_property_update(prop, 0, "rna_FieldSettings_dependency_update");
1725 
1726  prop = RNA_def_property(srna, "use_multiple_springs", PROP_BOOLEAN, PROP_NONE);
1729  prop, "Multiple Springs", "Every point is effected by multiple springs");
1730  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1731 
1732  prop = RNA_def_property(srna, "use_smoke_density", PROP_BOOLEAN, PROP_NONE);
1734  RNA_def_property_ui_text(prop, "Apply Density", "Adjust force strength based on smoke density");
1735  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1736  prop = RNA_def_property(srna, "use_gravity_falloff", PROP_BOOLEAN, PROP_NONE);
1738  RNA_def_property_ui_text(prop, "Gravity Falloff", "Multiply force by 1/distance²");
1739  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1740 
1741  /* Pointer */
1742 
1743  prop = RNA_def_property(srna, "texture", PROP_POINTER, PROP_NONE);
1744  RNA_def_property_pointer_sdna(prop, NULL, "tex");
1746  RNA_def_property_ui_text(prop, "Texture", "Texture to use as force");
1747  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1748 
1749  prop = RNA_def_property(srna, "source_object", PROP_POINTER, PROP_NONE);
1750  RNA_def_property_pointer_sdna(prop, NULL, "f_source");
1751  RNA_def_property_ui_text(prop, "Domain Object", "Select domain object of the smoke simulation");
1753  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1754 
1755  /********** Curve Guide Field Settings **********/
1756 
1757  prop = RNA_def_property(srna, "guide_minimum", PROP_FLOAT, PROP_NONE);
1758  RNA_def_property_float_sdna(prop, NULL, "f_strength");
1759  RNA_def_property_ui_range(prop, 0.0f, 1000.0f, 10, 3);
1761  prop, "Minimum Distance", "The distance from which particles are affected fully");
1762  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1763 
1764  prop = RNA_def_property(srna, "guide_free", PROP_FLOAT, PROP_NONE);
1765  RNA_def_property_float_sdna(prop, NULL, "free_end");
1766  RNA_def_property_range(prop, 0.0f, 0.99f);
1767  RNA_def_property_ui_text(prop, "Free", "Guide-free time from particle life's end");
1768  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1769 
1770  prop = RNA_def_property(srna, "use_guide_path_add", PROP_BOOLEAN, PROP_NONE);
1773  prop, "Additive", "Based on distance/falloff it adds a portion of the entire path");
1774  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1775 
1776  prop = RNA_def_property(srna, "use_guide_path_weight", PROP_BOOLEAN, PROP_NONE);
1779  prop, "Weights", "Use curve weights to influence the particle influence along the curve");
1780  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1781 
1782  /* Clump Settings */
1783 
1784  prop = RNA_def_property(srna, "guide_clump_amount", PROP_FLOAT, PROP_NONE);
1785  RNA_def_property_float_sdna(prop, NULL, "clump_fac");
1786  RNA_def_property_range(prop, -1.0f, 1.0f);
1787  RNA_def_property_ui_text(prop, "Amount", "Amount of clumping");
1788  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1789 
1790  prop = RNA_def_property(srna, "guide_clump_shape", PROP_FLOAT, PROP_NONE);
1791  RNA_def_property_float_sdna(prop, NULL, "clump_pow");
1792  RNA_def_property_range(prop, -0.999f, 0.999f);
1793  RNA_def_property_ui_text(prop, "Shape", "Shape of clumping");
1794  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1795 
1796  /* Kink Settings */
1797 
1798  prop = RNA_def_property(srna, "guide_kink_type", PROP_ENUM, PROP_NONE);
1799  RNA_def_property_enum_sdna(prop, NULL, "kink");
1800  RNA_def_property_enum_items(prop, guide_kink_items);
1801  RNA_def_property_ui_text(prop, "Kink", "Type of periodic offset on the curve");
1802  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1803 
1804  prop = RNA_def_property(srna, "guide_kink_axis", PROP_ENUM, PROP_NONE);
1805  RNA_def_property_enum_sdna(prop, NULL, "kink_axis");
1807  RNA_def_property_ui_text(prop, "Axis", "Which axis to use for offset");
1808  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1809 
1810  prop = RNA_def_property(srna, "guide_kink_frequency", PROP_FLOAT, PROP_NONE);
1811  RNA_def_property_float_sdna(prop, NULL, "kink_freq");
1812  RNA_def_property_range(prop, 0.0f, 10.0f);
1813  RNA_def_property_ui_text(prop, "Frequency", "The frequency of the offset (1/total length)");
1814  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1815 
1816  prop = RNA_def_property(srna, "guide_kink_shape", PROP_FLOAT, PROP_NONE);
1817  RNA_def_property_float_sdna(prop, NULL, "kink_shape");
1818  RNA_def_property_range(prop, -0.999f, 0.999f);
1819  RNA_def_property_ui_text(prop, "Shape", "Adjust the offset to the beginning/end");
1820  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1821 
1822  prop = RNA_def_property(srna, "guide_kink_amplitude", PROP_FLOAT, PROP_NONE);
1823  RNA_def_property_float_sdna(prop, NULL, "kink_amp");
1824  RNA_def_property_range(prop, 0.0f, 10.0f);
1825  RNA_def_property_ui_text(prop, "Amplitude", "The amplitude of the offset");
1826  RNA_def_property_update(prop, 0, "rna_FieldSettings_update");
1827 
1828  /* Variables used for Curve Guide, already wrapped, used for other fields too */
1829  /* falloff_power, use_max_distance, maximum_distance */
1830 
1832 }
1833 
1834 static void rna_def_softbody(BlenderRNA *brna)
1835 {
1836  StructRNA *srna;
1837  PropertyRNA *prop;
1838 
1839  static const EnumPropertyItem collision_type_items[] = {
1840  {SBC_MODE_MANUAL, "MANUAL", 0, "Manual", "Manual adjust"},
1841  {SBC_MODE_AVG, "AVERAGE", 0, "Average", "Average Spring length * Ball Size"},
1842  {SBC_MODE_MIN, "MINIMAL", 0, "Minimal", "Minimal Spring length * Ball Size"},
1843  {SBC_MODE_MAX, "MAXIMAL", 0, "Maximal", "Maximal Spring length * Ball Size"},
1844  {SBC_MODE_AVGMINMAX, "MINMAX", 0, "AvMinMax", "(Min+Max)/2 * Ball Size"},
1845  {0, NULL, 0, NULL, NULL},
1846  };
1847 
1848  static const EnumPropertyItem aerodynamics_type[] = {
1849  {0, "SIMPLE", 0, "Simple", "Edges receive a drag force from surrounding media"},
1850  {1,
1851  "LIFT_FORCE",
1852  0,
1853  "Lift Force",
1854  "Edges receive a lift force when passing through surrounding media"},
1855  {0, NULL, 0, NULL, NULL},
1856  };
1857 
1858  srna = RNA_def_struct(brna, "SoftBodySettings", NULL);
1859  RNA_def_struct_sdna(srna, "SoftBody");
1860  RNA_def_struct_path_func(srna, "rna_SoftBodySettings_path");
1862  srna, "Soft Body Settings", "Soft body simulation settings for an object");
1863 
1864  /* General Settings */
1865 
1866  prop = RNA_def_property(srna, "friction", PROP_FLOAT, PROP_NONE);
1867  RNA_def_property_float_sdna(prop, NULL, "mediafrict");
1868  RNA_def_property_range(prop, 0.0f, 50.0f);
1869  RNA_def_property_ui_text(prop, "Friction", "General media friction for point movements");
1870  RNA_def_property_update(prop, 0, "rna_softbody_update");
1871 
1872  prop = RNA_def_property(srna, "mass", PROP_FLOAT, PROP_UNIT_MASS);
1873  RNA_def_property_float_sdna(prop, NULL, "nodemass");
1874  RNA_def_property_range(prop, 0.0f, 50000.0f);
1875  RNA_def_property_ui_text(prop, "Mass", "General Mass value");
1876  RNA_def_property_update(prop, 0, "rna_softbody_update");
1877 
1878  prop = RNA_def_property(srna, "vertex_group_mass", PROP_STRING, PROP_NONE);
1879  RNA_def_property_string_sdna(prop, NULL, "namedVG_Mass");
1880  RNA_def_property_ui_text(prop, "Mass Vertex Group", "Control point mass values");
1881  RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SoftBodySettings_mass_vgroup_set");
1882  RNA_def_property_update(prop, 0, "rna_softbody_update");
1883 
1884  /* no longer used */
1885  prop = RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_ACCELERATION);
1886  RNA_def_property_float_sdna(prop, NULL, "grav");
1887  RNA_def_property_range(prop, -10.0f, 10.0f);
1888  RNA_def_property_ui_text(prop, "Gravitation", "Apply gravitation to point movement");
1889  RNA_def_property_update(prop, 0, "rna_softbody_update");
1890 
1891  prop = RNA_def_property(srna, "speed", PROP_FLOAT, PROP_NONE);
1892  RNA_def_property_float_sdna(prop, NULL, "physics_speed");
1893  RNA_def_property_range(prop, 0.01f, 100.0f);
1895  prop, "Speed", "Tweak timing for physics to control frequency and speed");
1896  RNA_def_property_update(prop, 0, "rna_softbody_update");
1897 
1898  /* Goal */
1899 
1900  prop = RNA_def_property(srna, "vertex_group_goal", PROP_STRING, PROP_NONE);
1901  RNA_def_property_string_sdna(prop, NULL, "vertgroup");
1902  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); /* not impossible .. but not supported yet */
1904  "rna_SoftBodySettings_goal_vgroup_get",
1905  "rna_SoftBodySettings_goal_vgroup_length",
1906  "rna_SoftBodySettings_goal_vgroup_set");
1907  RNA_def_property_ui_text(prop, "Goal Vertex Group", "Control point weight values");
1908 
1909  prop = RNA_def_property(srna, "goal_min", PROP_FLOAT, PROP_FACTOR);
1910  RNA_def_property_float_sdna(prop, NULL, "mingoal");
1911  RNA_def_property_range(prop, 0.0f, 1.0f);
1913  prop, "Goal Minimum", "Goal minimum, vertex weights are scaled to match this range");
1914  RNA_def_property_update(prop, 0, "rna_softbody_update");
1915 
1916  prop = RNA_def_property(srna, "goal_max", PROP_FLOAT, PROP_FACTOR);
1917  RNA_def_property_float_sdna(prop, NULL, "maxgoal");
1918  RNA_def_property_range(prop, 0.0f, 1.0f);
1920  prop, "Goal Maximum", "Goal maximum, vertex weights are scaled to match this range");
1921  RNA_def_property_update(prop, 0, "rna_softbody_update");
1922 
1923  prop = RNA_def_property(srna, "goal_default", PROP_FLOAT, PROP_FACTOR);
1924  RNA_def_property_float_sdna(prop, NULL, "defgoal");
1926  RNA_def_property_range(prop, 0.0f, 1.0f);
1927  RNA_def_property_ui_text(prop, "Goal Default", "Default Goal (vertex target position) value");
1928  RNA_def_property_update(prop, 0, "rna_softbody_update");
1929 
1930  prop = RNA_def_property(srna, "goal_spring", PROP_FLOAT, PROP_NONE);
1931  RNA_def_property_float_sdna(prop, NULL, "goalspring");
1932  RNA_def_property_range(prop, 0.0f, 0.999f);
1934  prop, "Goal Stiffness", "Goal (vertex target position) spring stiffness");
1935  RNA_def_property_update(prop, 0, "rna_softbody_update");
1936 
1937  prop = RNA_def_property(srna, "goal_friction", PROP_FLOAT, PROP_NONE);
1938  RNA_def_property_float_sdna(prop, NULL, "goalfrict");
1939  RNA_def_property_range(prop, 0.0f, 50.0f);
1940  RNA_def_property_ui_text(prop, "Goal Damping", "Goal (vertex target position) friction");
1941  RNA_def_property_update(prop, 0, "rna_softbody_update");
1942 
1943  /* Edge Spring Settings */
1944 
1945  prop = RNA_def_property(srna, "pull", PROP_FLOAT, PROP_NONE);
1946  RNA_def_property_float_sdna(prop, NULL, "inspring");
1947  RNA_def_property_range(prop, 0.0f, 0.999f);
1948  RNA_def_property_ui_text(prop, "Pull", "Edge spring stiffness when longer than rest length");
1949  RNA_def_property_update(prop, 0, "rna_softbody_update");
1950 
1951  prop = RNA_def_property(srna, "push", PROP_FLOAT, PROP_NONE);
1952  RNA_def_property_float_sdna(prop, NULL, "inpush");
1953  RNA_def_property_range(prop, 0.0f, 0.999f);
1954  RNA_def_property_ui_text(prop, "Push", "Edge spring stiffness when shorter than rest length");
1955  RNA_def_property_update(prop, 0, "rna_softbody_update");
1956 
1957  prop = RNA_def_property(srna, "damping", PROP_FLOAT, PROP_NONE);
1958  RNA_def_property_float_sdna(prop, NULL, "infrict");
1959  RNA_def_property_range(prop, 0.0f, 50.0f);
1960  RNA_def_property_ui_text(prop, "Damp", "Edge spring friction");
1961  RNA_def_property_update(prop, 0, "rna_softbody_update");
1962 
1963  prop = RNA_def_property(srna, "spring_length", PROP_INT, PROP_NONE);
1964  RNA_def_property_int_sdna(prop, NULL, "springpreload");
1965  RNA_def_property_range(prop, 0.0f, 200.0f);
1967  prop, "View Layer", "Alter spring length to shrink/blow up (unit %) 0 to disable");
1968  RNA_def_property_update(prop, 0, "rna_softbody_update");
1969 
1970  prop = RNA_def_property(srna, "aero", PROP_INT, PROP_NONE);
1971  RNA_def_property_int_sdna(prop, NULL, "aeroedge");
1972  RNA_def_property_range(prop, 0.0f, 30000.0f);
1973  RNA_def_property_ui_text(prop, "Aero", "Make edges 'sail'");
1974  RNA_def_property_update(prop, 0, "rna_softbody_update");
1975 
1976  prop = RNA_def_property(srna, "plastic", PROP_INT, PROP_NONE);
1977  RNA_def_property_int_sdna(prop, NULL, "plastic");
1978  RNA_def_property_range(prop, 0.0f, 100.0f);
1979  RNA_def_property_ui_text(prop, "Plasticity", "Permanent deform");
1980  RNA_def_property_update(prop, 0, "rna_softbody_update");
1981 
1982  prop = RNA_def_property(srna, "bend", PROP_FLOAT, PROP_NONE);
1983  RNA_def_property_float_sdna(prop, NULL, "secondspring");
1984  RNA_def_property_range(prop, 0.0f, 10.0f);
1985  RNA_def_property_ui_text(prop, "Bending", "Bending Stiffness");
1986  RNA_def_property_update(prop, 0, "rna_softbody_update");
1987 
1988  prop = RNA_def_property(srna, "shear", PROP_FLOAT, PROP_FACTOR);
1989  RNA_def_property_float_sdna(prop, NULL, "shearstiff");
1990  RNA_def_property_range(prop, 0.0f, 1.0f);
1991  RNA_def_property_ui_text(prop, "Shear", "Shear Stiffness");
1992 
1993  prop = RNA_def_property(srna, "vertex_group_spring", PROP_STRING, PROP_NONE);
1994  RNA_def_property_string_sdna(prop, NULL, "namedVG_Spring_K");
1995  RNA_def_property_ui_text(prop, "Spring Vertex Group", "Control point spring strength values");
1996  RNA_def_property_string_funcs(prop, NULL, NULL, "rna_SoftBodySettings_spring_vgroup_set");
1997  RNA_def_property_update(prop, 0, "rna_softbody_update");
1998 
1999  /* Collision */
2000 
2001  prop = RNA_def_property(srna, "collision_type", PROP_ENUM, PROP_NONE);
2002  RNA_def_property_enum_sdna(prop, NULL, "sbc_mode");
2003  RNA_def_property_enum_items(prop, collision_type_items);
2005  RNA_def_property_ui_text(prop, "Collision Type", "Choose Collision Type");
2006  RNA_def_property_update(prop, 0, "rna_softbody_update");
2007 
2008  prop = RNA_def_property(srna, "ball_size", PROP_FLOAT, PROP_DISTANCE);
2009  RNA_def_property_float_sdna(prop, NULL, "colball");
2010  RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); /* code is not ready for that yet */
2011  RNA_def_property_range(prop, -10.0f, 10.0f);
2013  prop, "Ball Size", "Absolute ball size or factor if not manually adjusted");
2014  RNA_def_property_update(prop, 0, "rna_softbody_update");
2015 
2016  prop = RNA_def_property(srna, "ball_stiff", PROP_FLOAT, PROP_NONE);
2017  RNA_def_property_float_sdna(prop, NULL, "ballstiff");
2018  RNA_def_property_range(prop, 0.001f, 100.0f);
2019  RNA_def_property_ui_text(prop, "Ball Size", "Ball inflating pressure");
2020  RNA_def_property_update(prop, 0, "rna_softbody_update");
2021 
2022  prop = RNA_def_property(srna, "ball_damp", PROP_FLOAT, PROP_NONE);
2023  RNA_def_property_float_sdna(prop, NULL, "balldamp");
2024  RNA_def_property_range(prop, 0.001f, 1.0f);
2025  RNA_def_property_ui_text(prop, "Ball Size", "Blending to inelastic collision");
2026  RNA_def_property_update(prop, 0, "rna_softbody_update");
2027 
2028  /* Solver */
2029 
2030  prop = RNA_def_property(srna, "error_threshold", PROP_FLOAT, PROP_NONE);
2031  RNA_def_property_float_sdna(prop, NULL, "rklimit");
2032  RNA_def_property_range(prop, 0.001f, 10.0f);
2034  prop,
2035  "Error Limit",
2036  "The Runge-Kutta ODE solver error limit, low value gives more precision, "
2037  "high values speed");
2038  RNA_def_property_update(prop, 0, "rna_softbody_update");
2039 
2040  prop = RNA_def_property(srna, "step_min", PROP_INT, PROP_NONE);
2041  RNA_def_property_int_sdna(prop, NULL, "minloops");
2042  RNA_def_property_range(prop, 0, 30000);
2043  RNA_def_property_ui_text(prop, "Min Step", "Minimal # solver steps/frame");
2044  RNA_def_property_update(prop, 0, "rna_softbody_update");
2045 
2046  prop = RNA_def_property(srna, "step_max", PROP_INT, PROP_NONE);
2047  RNA_def_property_int_sdna(prop, NULL, "maxloops");
2048  RNA_def_property_range(prop, 0, 30000);
2049  RNA_def_property_ui_text(prop, "Max Step", "Maximal # solver steps/frame");
2050  RNA_def_property_update(prop, 0, "rna_softbody_update");
2051 
2052  prop = RNA_def_property(srna, "choke", PROP_INT, PROP_NONE);
2053  RNA_def_property_int_sdna(prop, NULL, "choke");
2054  RNA_def_property_range(prop, 0, 100);
2055  RNA_def_property_ui_text(prop, "Choke", "'Viscosity' inside collision target");
2056  RNA_def_property_update(prop, 0, "rna_softbody_update");
2057 
2058  prop = RNA_def_property(srna, "fuzzy", PROP_INT, PROP_NONE);
2059  RNA_def_property_int_sdna(prop, NULL, "fuzzyness");
2060  RNA_def_property_range(prop, 1, 100);
2062  prop,
2063  "Fuzzy",
2064  "Fuzziness while on collision, high values make collision handling faster "
2065  "but less stable");
2066  RNA_def_property_update(prop, 0, "rna_softbody_update");
2067 
2068  prop = RNA_def_property(srna, "use_auto_step", PROP_BOOLEAN, PROP_NONE);
2069  RNA_def_property_boolean_sdna(prop, NULL, "solverflags", SBSO_OLDERR);
2070  RNA_def_property_ui_text(prop, "V", "Use velocities for automagic step sizes");
2071  RNA_def_property_update(prop, 0, "rna_softbody_update");
2072 
2073  prop = RNA_def_property(srna, "use_diagnose", PROP_BOOLEAN, PROP_NONE);
2074  RNA_def_property_boolean_sdna(prop, NULL, "solverflags", SBSO_MONITOR);
2076  prop, "Print Performance to Console", "Turn on SB diagnose console prints");
2077 
2078  prop = RNA_def_property(srna, "use_estimate_matrix", PROP_BOOLEAN, PROP_NONE);
2079  RNA_def_property_boolean_sdna(prop, NULL, "solverflags", SBSO_ESTIMATEIPO);
2081  prop, "Estimate Transforms", "Store the estimated transforms in the soft body settings");
2082 
2083  /***********************************************************************************/
2084  /* These are not exactly settings, but reading calculated results
2085  * but i did not want to start a new property struct
2086  * so rather rename this from SoftBodySettings to SoftBody
2087  * translation. */
2088  prop = RNA_def_property(srna, "location_mass_center", PROP_FLOAT, PROP_TRANSLATION);
2089  RNA_def_property_float_sdna(prop, NULL, "lcom");
2090  RNA_def_property_ui_text(prop, "Center of Mass", "Location of center of mass");
2091  RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
2092 
2093  /* matrix */
2094  prop = RNA_def_property(srna, "rotation_estimate", PROP_FLOAT, PROP_MATRIX);
2095  RNA_def_property_float_sdna(prop, NULL, "lrot");
2097  RNA_def_property_ui_text(prop, "Rotation Matrix", "Estimated rotation matrix");
2098 
2099  prop = RNA_def_property(srna, "scale_estimate", PROP_FLOAT, PROP_MATRIX);
2100  RNA_def_property_float_sdna(prop, NULL, "lscale");
2102  RNA_def_property_ui_text(prop, "Scale Matrix", "Estimated scale matrix");
2103  /***********************************************************************************/
2104 
2105  /* Flags */
2106 
2107  prop = RNA_def_property(srna, "use_goal", PROP_BOOLEAN, PROP_NONE);
2109  prop, "rna_SoftBodySettings_use_goal_get", "rna_SoftBodySettings_use_goal_set");
2112  prop, "Use Goal", "Define forces for vertices to stick to animated position");
2113  RNA_def_property_update(prop, 0, "rna_softbody_update");
2114 
2115  prop = RNA_def_property(srna, "use_edges", PROP_BOOLEAN, PROP_NONE);
2117  prop, "rna_SoftBodySettings_use_edges_get", "rna_SoftBodySettings_use_edges_set");
2119  RNA_def_property_ui_text(prop, "Use Edges", "Use Edges as springs");
2120  RNA_def_property_update(prop, 0, "rna_softbody_update");
2121 
2122  prop = RNA_def_property(srna, "use_stiff_quads", PROP_BOOLEAN, PROP_NONE);
2124  prop, "rna_SoftBodySettings_stiff_quads_get", "rna_SoftBodySettings_stiff_quads_set");
2126  RNA_def_property_ui_text(prop, "Stiff Quads", "Add diagonal springs on 4-gons");
2127  RNA_def_property_update(prop, 0, "rna_softbody_update");
2128 
2129  prop = RNA_def_property(srna, "use_edge_collision", PROP_BOOLEAN, PROP_NONE);
2131  prop, "rna_SoftBodySettings_edge_collision_get", "rna_SoftBodySettings_edge_collision_set");
2132  RNA_def_property_ui_text(prop, "Edge Collision", "Edges collide too");
2133  RNA_def_property_update(prop, 0, "rna_softbody_update");
2134 
2135  prop = RNA_def_property(srna, "use_face_collision", PROP_BOOLEAN, PROP_NONE);
2137  prop, "rna_SoftBodySettings_face_collision_get", "rna_SoftBodySettings_face_collision_set");
2138  RNA_def_property_ui_text(prop, "Face Collision", "Faces collide too, can be very slow");
2139  RNA_def_property_update(prop, 0, "rna_softbody_update");
2140 
2141  prop = RNA_def_property(srna, "aerodynamics_type", PROP_ENUM, PROP_NONE);
2142  RNA_def_property_enum_items(prop, aerodynamics_type);
2144  prop, "rna_SoftBodySettings_new_aero_get", "rna_SoftBodySettings_new_aero_set", NULL);
2146  prop, "Aerodynamics Type", "Method of calculating aerodynamic interaction");
2147  RNA_def_property_update(prop, 0, "rna_softbody_update");
2148 
2149  prop = RNA_def_property(srna, "use_self_collision", PROP_BOOLEAN, PROP_NONE);
2151  prop, "rna_SoftBodySettings_self_collision_get", "rna_SoftBodySettings_self_collision_set");
2153  RNA_def_property_ui_text(prop, "Self Collision", "Enable naive vertex ball self collision");
2154  RNA_def_property_update(prop, 0, "rna_softbody_update");
2155 
2156  prop = RNA_def_property(srna, "collision_collection", PROP_POINTER, PROP_NONE);
2157  RNA_def_property_struct_type(prop, "Collection");
2158  RNA_def_property_pointer_sdna(prop, NULL, "collision_group");
2160  RNA_def_property_ui_text(prop, "Collision Collection", "Limit colliders to this collection");
2161  RNA_def_property_update(prop, 0, "rna_softbody_dependency_update");
2162 
2163  prop = RNA_def_property(srna, "effector_weights", PROP_POINTER, PROP_NONE);
2164  RNA_def_property_pointer_sdna(prop, NULL, "effector_weights");
2165  RNA_def_property_struct_type(prop, "EffectorWeights");
2168  RNA_def_property_ui_text(prop, "Effector Weights", "");
2169 }
2170 
2172 {
2174  rna_def_collision(brna);
2176  rna_def_field(brna);
2177  rna_def_softbody(brna);
2178 }
2179 
2180 #endif
#define FOREACH_SCENE_OBJECT_END
#define FOREACH_SCENE_OBJECT_BEGIN(scene, _instance)
void id_us_min(struct ID *id)
Definition: lib_id.c:313
const ModifierTypeInfo * BKE_modifier_get_info(ModifierType type)
@ eModifierTypeFlag_UsesPointCache
Definition: BKE_modifier.h:90
struct ModifierData * BKE_modifiers_findby_type(const struct Object *ob, ModifierType type)
void BKE_ptcache_ids_from_object(struct ListBase *lb, struct Object *ob, struct Scene *scene, int duplis)
Definition: pointcache.c:1250
void BKE_ptcache_update_info(PTCacheID *pid)
Definition: pointcache.c:3687
void BKE_ptcache_toggle_disk_cache(struct PTCacheID *pid)
Definition: pointcache.c:3472
void BKE_ptcache_load_external(struct PTCacheID *pid)
Definition: pointcache.c:3574
PTCacheID BKE_ptcache_id_find(struct Object *ob, struct Scene *scene, struct PointCache *cache)
Definition: pointcache.c:1092
#define PTCACHE_TYPE_SMOKE_DOMAIN
int BKE_ptcache_object_reset(struct Scene *scene, struct Object *ob, int mode)
Definition: pointcache.c:2930
#define PTCACHE_RESET_DEPSGRAPH
void BKE_ptcache_disk_cache_rename(struct PTCacheID *pid, const char *name_src, const char *name_dst)
Definition: pointcache.c:3517
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define BLI_assert_msg(a, msg)
Definition: BLI_assert.h:53
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
Definition: listbase.c:466
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE int max_ii(int a, int b)
bool BLI_filename_make_safe(char *fname) ATTR_NONNULL(1)
Definition: path_util.c:309
size_t size_t char * BLI_sprintfN(const char *__restrict format,...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC
Definition: string.c:42
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
Definition: string.c:64
size_t size_t char size_t BLI_str_escape(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL()
Definition: string.c:250
#define UNUSED_VARS_NDEBUG(...)
#define UNUSED(x)
#define ELEM(...)
#define STREQ(a, b)
void DEG_id_tag_update(struct ID *id, int flag)
void DEG_relations_tag_update(struct Main *bmain)
@ ID_RECALC_TRANSFORM
Definition: DNA_ID.h:771
@ ID_RECALC_PSYS_RESET
Definition: DNA_ID.h:800
@ ID_RECALC_ANIMATION
Definition: DNA_ID.h:794
@ ID_RECALC_GEOMETRY
Definition: DNA_ID.h:791
@ IDOVERRIDE_LIBRARY_OP_REPLACE
Definition: DNA_ID.h:220
@ ID_SCE
Definition: DNA_ID_enums.h:45
@ ID_OB
Definition: DNA_ID_enums.h:47
@ ID_PA
Definition: DNA_ID_enums.h:70
@ eModifierType_ParticleSystem
@ eModifierType_Cloth
@ eModifierType_Fluid
@ eModifierType_Collision
@ eModifierType_DynamicPaint
@ eModifierType_Softbody
@ MOD_FLUID_TYPE_DOMAIN
#define PFIELD_SHAPE_LINE
#define PFIELD_SHAPE_SURFACE
#define OB_SB_FACECOLL
#define OB_SB_EDGECOLL
#define SBC_MODE_MIN
#define EFF_WEIGHT_DO_HAIR
#define OB_SB_EDGES
#define SBC_MODE_MANUAL
#define PFIELD_VISIBILITY
#define OB_SB_SELF
#define PFIELD_USEMINR
#define PFIELD_FALL_CONE
#define PFIELD_USEMIN
#define OB_SB_GOAL
#define PFIELD_SHAPE_POINT
#define SBC_MODE_AVG
@ PFIELD_MAGNET
@ PFIELD_FLUIDFLOW
@ PFIELD_FORCE
@ PFIELD_CHARGE
@ PFIELD_HARMONIC
@ PFIELD_TURBULENCE
@ PFIELD_GUIDE
@ PFIELD_LENNARDJ
@ PFIELD_VORTEX
@ PFIELD_TEXTURE
#define PFIELD_Z_POS
#define PFIELD_SHAPE_PLANE
#define PFIELD_TEX_CURL
#define PFIELD_GUIDE_PATH_ADD
#define PFIELD_SHAPE_POINTS
#define PFIELD_TEX_GRAD
#define PFIELD_CLOTH_USE_NORMAL
#define PFIELD_MULTIPLE_SPRINGS
#define SBSO_ESTIMATEIPO
#define SBC_MODE_AVGMINMAX
#define PFIELD_DO_LOCATION
#define SBC_MODE_MAX
#define PFIELD_TEX_2D
#define PFIELD_GLOBAL_CO
#define PFIELD_Z_BOTH
#define PFIELD_FALL_TUBE
#define PFIELD_TEX_OBJECT
#define PFIELD_Z_NEG
#define PFIELD_DO_ROTATION
#define PFIELD_USEMAXR
#define OB_SB_QUADS
#define PFIELD_CLOTH_USE_CULLING
#define PFIELD_TEX_RGB
#define PFIELD_TEX_ROOTCO
#define PDEFLE_KILL_PART
#define PFIELD_FALL_SPHERE
#define PFIELD_SMOKE_DENSITY
#define SBSO_MONITOR
#define OB_SB_AERO_ANGLE
#define PFIELD_GUIDE_PATH_WEIGHT
#define PFIELD_USEMAX
#define SBSO_OLDERR
#define PFIELD_GRAVITATION
Object is a sort of wrapper for general info.
@ OB_SINGLE_ARROW
@ OB_PLAINAXES
@ OB_SURF
@ OB_FONT
@ OB_MESH
@ OB_CURVES_LEGACY
#define PTCACHE_COMPRESS_NO
@ PTCACHE_EXTERNAL
@ PTCACHE_IGNORE_LIBPATH
@ PTCACHE_BAKED
@ PTCACHE_FRAMES_SKIPPED
@ PTCACHE_FLAG_INFO_DIRTY
@ PTCACHE_BAKING
@ PTCACHE_OUTDATED
@ PTCACHE_DISK_CACHE
#define PTCACHE_COMPRESS_LZO
#define PTCACHE_COMPRESS_LZMA
Types and defines for representing Rigid Body entities.
#define MAXFRAME
struct ModifierData * ED_object_modifier_add(struct ReportList *reports, struct Main *bmain, struct Scene *scene, struct Object *ob, const char *name, int type)
void ED_object_check_force_modifiers(struct Main *bmain, struct Scene *scene, struct Object *object)
Definition: object_edit.c:1024
Read Guarded memory(de)allocation.
@ PROP_FLOAT
Definition: RNA_types.h:61
@ PROP_BOOLEAN
Definition: RNA_types.h:59
@ PROP_ENUM
Definition: RNA_types.h:63
@ PROP_INT
Definition: RNA_types.h:60
@ PROP_STRING
Definition: RNA_types.h:62
@ PROP_POINTER
Definition: RNA_types.h:64
@ PROP_COLLECTION
Definition: RNA_types.h:65
@ PROP_UNIT_MASS
Definition: RNA_types.h:74
#define RNA_TRANSLATION_PREC_DEFAULT
Definition: RNA_types.h:117
@ PROPOVERRIDE_OVERRIDABLE_LIBRARY
Definition: RNA_types.h:312
@ PROPOVERRIDE_NO_COMPARISON
Definition: RNA_types.h:320
@ PROP_ANIMATABLE
Definition: RNA_types.h:202
@ PROP_EDITABLE
Definition: RNA_types.h:189
@ PROP_ID_REFCOUNT
Definition: RNA_types.h:226
@ PROP_TIME
Definition: RNA_types.h:146
@ PROP_MATRIX
Definition: RNA_types.h:158
@ PROP_DISTANCE
Definition: RNA_types.h:149
@ PROP_ACCELERATION
Definition: RNA_types.h:157
@ PROP_NONE
Definition: RNA_types.h:126
@ PROP_DIRPATH
Definition: RNA_types.h:130
@ PROP_FACTOR
Definition: RNA_types.h:144
@ PROP_TRANSLATION
Definition: RNA_types.h:154
@ PROP_UNSIGNED
Definition: RNA_types.h:142
#define C
Definition: RandGen.cpp:25
#define ND_DRAW
Definition: WM_types.h:410
#define ND_MODIFIER
Definition: WM_types.h:411
#define ND_POINTCACHE
Definition: WM_types.h:415
#define NC_OBJECT
Definition: WM_types.h:329
Scene scene
struct @211::@212 surface
#define GS(x)
Definition: iris.c:225
static const EnumPropertyItem field_type_items[]
Definition: object_add.cc:139
PropertyType RNA_property_type(PropertyRNA *prop)
Definition: rna_access.c:1010
void rna_iterator_listbase_begin(CollectionPropertyIterator *iter, ListBase *lb, IteratorSkipFunc skip)
Definition: rna_access.c:4729
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:2153
void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, bool value)
Definition: rna_access.c:2180
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2740
void RNA_define_lib_overridable(const bool make_overridable)
Definition: rna_define.c:742
void RNA_def_struct_path_func(StructRNA *srna, const char *path)
Definition: rna_define.c:1193
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t bit)
Definition: rna_define.c:2236
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
Definition: rna_define.c:3285
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
Definition: rna_define.c:1645
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2695
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
Definition: rna_define.c:3474
void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring, const char *assignint)
Definition: rna_define.c:3420
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
Definition: rna_define.c:1237
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
Definition: rna_define.c:2944
void RNA_def_property_multi_array(PropertyRNA *prop, int dimension, const int length[])
Definition: rna_define.c:1598
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
Definition: rna_define.c:1872
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
Definition: rna_define.c:1048
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
Definition: rna_define.c:1737
void RNA_def_property_string_maxlength(PropertyRNA *prop, int maxlength)
Definition: rna_define.c:1920
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
Definition: rna_define.c:1772
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
Definition: rna_define.c:2900
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item)
Definition: rna_define.c:3224
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
Definition: rna_define.c:1257
void RNA_def_struct_name_property(struct StructRNA *srna, struct PropertyRNA *prop)
Definition: rna_define.c:1103
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1495
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
Definition: rna_define.c:1028
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2601
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
Definition: rna_define.c:3028
const int rna_matrix_dimsize_3x3[]
Definition: rna_define.c:1594
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
Definition: rna_define.c:1245
void RNA_def_property_override_funcs(PropertyRNA *prop, const char *diff, const char *store, const char *apply)
Definition: rna_define.c:2879
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1490
void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2493
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
Definition: rna_define.c:1664
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
Definition: rna_define.c:2343
void RNA_def_property_boolean_negative_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
Definition: rna_define.c:2327
void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
Definition: rna_define.c:1503
void rna_object_vgroup_name_index_set(struct PointerRNA *ptr, const char *value, short *index)
void rna_object_vgroup_name_index_get(struct PointerRNA *ptr, char *value, int index)
int rna_object_vgroup_name_index_length(struct PointerRNA *ptr, int index)
void rna_object_vgroup_name_set(struct PointerRNA *ptr, const char *value, char *result, int maxlen)
const EnumPropertyItem rna_enum_axis_xyz_items[]
Definition: rna_modifier.c:615
static void rna_def_pointcache_common(StructRNA *srna)
static const EnumPropertyItem effector_shape_items[]
static void rna_def_pointcache_active(BlenderRNA *brna)
static void rna_def_collision(BlenderRNA *brna)
static void rna_def_softbody(BlenderRNA *brna)
static void rna_def_ptcache_point_caches(BlenderRNA *brna, PropertyRNA *cprop)
void RNA_def_object_force(BlenderRNA *brna)
static void rna_def_effector_weight(BlenderRNA *brna)
static void rna_def_field(BlenderRNA *brna)
#define min(a, b)
Definition: sort.c:35
struct PointCache * point_cache
struct ClothSimSettings * sim_parms
struct EffectorWeights * effector_weights
struct DynamicPaintCanvasSettings * canvas
struct EffectorWeights * effector_weights
struct FluidDomainSettings * domain
Definition: DNA_ID.h:368
char name[66]
Definition: DNA_ID.h:378
void * last
Definition: DNA_listBase.h:31
void * first
Definition: DNA_listBase.h:31
Definition: BKE_main.h:121
struct ModifierData * next
ModifierTypeFlag flags
Definition: BKE_modifier.h:161
ListBase modifiers
struct PartDeflect * pd
struct SoftBody * soft
char empty_drawtype
struct PointCache ** cache_ptr
struct ListBase * ptcaches
unsigned int max_step
struct PTCacheID * next
struct PointCache * cache
struct PartDeflect * pd2
struct EffectorWeights * effector_weights
struct PartDeflect * pd
struct ParticleSystem * psys
struct PointCache * pointcache
struct PointCache * prev
void * data
Definition: RNA_types.h:38
struct ID * owner_id
Definition: RNA_types.h:36
struct EffectorWeights * effector_weights
struct RigidBodyWorld * rigidbody_world
struct PointCache * pointcache
struct SoftBody_Shared * shared
struct EffectorWeights * effector_weights
char namedVG_Spring_K[64]
float max
void WM_main_add_notifier(unsigned int type, void *reference)
PointerRNA * ptr
Definition: wm_files.c:3480