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