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