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