Blender V4.3
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
9#include <cstdlib>
10
11#include "BLT_translation.hh"
12
13#include "DNA_cloth_types.h"
15#include "DNA_fluid_types.h"
17#include "DNA_object_types.h"
18#include "DNA_particle_types.h"
20#include "DNA_rigidbody_types.h"
21#include "DNA_scene_types.h"
22
23#include "RNA_define.hh"
24#include "RNA_enum_types.hh"
25
26#include "rna_internal.hh"
27
28#include "WM_api.hh"
29#include "WM_types.hh"
30
32 {PFIELD_SHAPE_POINT, "POINT", 0, "Point", "Field originates from the object center"},
33 {PFIELD_SHAPE_LINE, "LINE", 0, "Line", "Field originates from the local Z axis of the object"},
35 "PLANE",
36 0,
37 "Plane",
38 "Field originates from the local XY plane of the object"},
40 "SURFACE",
41 0,
42 "Surface",
43 "Field originates from the surface of the object"},
45 "POINTS",
46 0,
47 "Every Point",
48 "Field originates from all of the vertices of the object"},
49 {0, nullptr, 0, nullptr, nullptr},
50};
51
52#ifdef RNA_RUNTIME
53
54# include <fmt/format.h>
55
56# include "BLI_math_base.h"
57
58# include "RNA_access.hh"
59
60/* type specific return values only used from functions */
61static const EnumPropertyItem curve_shape_items[] = {
62 {PFIELD_SHAPE_POINT, "POINT", 0, "Point", "Field originates from the object center"},
63 {PFIELD_SHAPE_LINE, "LINE", 0, "Line", "Field originates from the local Z axis of the object"},
65 "PLANE",
66 0,
67 "Plane",
68 "Field originates from the local XY plane of the object"},
69 {PFIELD_SHAPE_SURFACE, "SURFACE", 0, "Curve", "Field originates from the curve itself"},
70 {0, nullptr, 0, nullptr, nullptr},
71};
72
73static const EnumPropertyItem empty_shape_items[] = {
74 {PFIELD_SHAPE_POINT, "POINT", 0, "Point", "Field originates from the object center"},
75 {PFIELD_SHAPE_LINE, "LINE", 0, "Line", "Field originates from the local Z axis of the object"},
77 "PLANE",
78 0,
79 "Plane",
80 "Field originates from the local XY plane of the object"},
81 {0, nullptr, 0, nullptr, nullptr},
82};
83
84static const EnumPropertyItem vortex_shape_items[] = {
85 {PFIELD_SHAPE_POINT, "POINT", 0, "Point", ""},
86 {PFIELD_SHAPE_PLANE, "PLANE", 0, "Plane", ""},
87 {PFIELD_SHAPE_SURFACE, "SURFACE", 0, "Surface", ""},
88 {PFIELD_SHAPE_POINTS, "POINTS", 0, "Every Point", ""},
89 {0, nullptr, 0, nullptr, nullptr},
90};
91
92static const EnumPropertyItem curve_vortex_shape_items[] = {
93 {PFIELD_SHAPE_POINT, "POINT", 0, "Point", ""},
94 {PFIELD_SHAPE_PLANE, "PLANE", 0, "Plane", ""},
95 {PFIELD_SHAPE_SURFACE, "SURFACE", 0, "Curve", ""},
96 {0, nullptr, 0, nullptr, nullptr},
97};
98
99static const EnumPropertyItem empty_vortex_shape_items[] = {
100 {PFIELD_SHAPE_POINT, "POINT", 0, "Point", ""},
101 {PFIELD_SHAPE_PLANE, "PLANE", 0, "Plane", ""},
102 {0, nullptr, 0, nullptr, nullptr},
103};
104
105# include <fmt/format.h>
106
107# include "MEM_guardedalloc.h"
108
109# include "DNA_modifier_types.h"
110# include "DNA_texture_types.h"
111
112# include "BKE_collection.hh"
113# include "BKE_context.hh"
114# include "BKE_modifier.hh"
115# include "BKE_pointcache.h"
116
117# include "DEG_depsgraph.hh"
118# include "DEG_depsgraph_build.hh"
119
120# include "ED_object.hh"
121
122static bool rna_Cache_get_valid_owner_ID(PointerRNA *ptr, Object **ob, Scene **scene)
123{
124 switch (GS(ptr->owner_id->name)) {
125 case ID_OB:
126 *ob = (Object *)ptr->owner_id;
127 break;
128 case ID_SCE:
129 *scene = (Scene *)ptr->owner_id;
130 break;
131 default:
133 "Trying to get PTCacheID from an invalid ID type "
134 "(Only scenes and objects are supported).");
135 break;
136 }
137
138 return (*ob != nullptr || *scene != nullptr);
139}
140
141static std::optional<std::string> rna_PointCache_path(const PointerRNA *ptr)
142{
143 ModifierData *md;
144 Object *ob = (Object *)ptr->owner_id;
145 PointCache *cache = static_cast<PointCache *>(ptr->data);
146
147 for (md = static_cast<ModifierData *>(ob->modifiers.first); md; md = md->next) {
149
151 continue;
152 }
153
154 char name_esc[sizeof(md->name) * 2];
155 BLI_str_escape(name_esc, md->name, sizeof(name_esc));
156
157 switch (md->type) {
160 if (psmd->psys->pointcache == cache) {
161 return fmt::format("modifiers[\"{}\"].particle_system.point_cache", name_esc);
162 }
163 break;
164 }
167 if (pmd->canvas) {
168 DynamicPaintSurface *surface = static_cast<DynamicPaintSurface *>(
169 pmd->canvas->surfaces.first);
170 for (; surface; surface = surface->next) {
171 if (surface->pointcache == cache) {
172 char name_surface_esc[sizeof(surface->name) * 2];
173 BLI_str_escape(name_surface_esc, surface->name, sizeof(name_surface_esc));
174 return fmt::format(
175 "modifiers[\"{}\"].canvas_settings.canvas_surfaces[\"{}\"].point_cache",
176 name_esc,
177 name_surface_esc);
178 }
179 }
180 }
181 break;
182 }
183 case eModifierType_Cloth: {
185 if (clmd->point_cache == cache) {
186 return fmt::format("modifiers[\"{}\"].point_cache", name_esc);
187 }
188 break;
189 }
191 SoftBody *sb = ob->soft;
192 if (sb && sb->shared->pointcache == cache) {
193 return fmt::format("modifiers[\"{}\"].point_cache", name_esc);
194 }
195 break;
196 }
197 default: {
198 return fmt::format("modifiers[\"{}\"].point_cache", name_esc);
199 }
200 }
201 }
202 return std::nullopt;
203}
204
205static void rna_Cache_change(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
206{
207 Object *ob = nullptr;
208 Scene *scene = nullptr;
209
210 if (!rna_Cache_get_valid_owner_ID(ptr, &ob, &scene)) {
211 return;
212 }
213
214 PointCache *cache = (PointCache *)ptr->data;
215
216 cache->flag |= PTCACHE_OUTDATED;
217
218 PTCacheID pid = BKE_ptcache_id_find(ob, scene, cache);
219
221
222 if (pid.cache) {
223 /* Just make sure this wasn't changed. */
224 if (pid.type == PTCACHE_TYPE_SMOKE_DOMAIN) {
225 cache->step = 1;
226 }
228 }
229}
230
231static void rna_Cache_toggle_disk_cache(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
232{
233 Object *ob = nullptr;
234 Scene *scene = nullptr;
235
236 if (!rna_Cache_get_valid_owner_ID(ptr, &ob, &scene)) {
237 return;
238 }
239
240 PointCache *cache = (PointCache *)ptr->data;
241
242 PTCacheID pid = BKE_ptcache_id_find(ob, scene, cache);
243
244 /* smoke can only use disk cache */
245 if (pid.cache && pid.type != PTCACHE_TYPE_SMOKE_DOMAIN) {
247 }
248 else {
249 cache->flag ^= PTCACHE_DISK_CACHE;
250 }
251}
252
253bool rna_Cache_use_disk_cache_override_apply(Main * /*bmain*/,
255{
256 PointerRNA *ptr_dst = &rnaapply_ctx.ptr_dst;
257 PointerRNA *ptr_src = &rnaapply_ctx.ptr_src;
258 PropertyRNA *prop_dst = rnaapply_ctx.prop_dst;
259 PropertyRNA *prop_src = rnaapply_ctx.prop_src;
261
264 UNUSED_VARS_NDEBUG(opop);
265
266 RNA_property_boolean_set(ptr_dst, prop_dst, RNA_property_boolean_get(ptr_src, prop_src));
267
268 /* DO NOT call `RNA_property_update_main(bmain, nullptr, ptr_dst, prop_dst);`, that would trigger
269 * the whole 'update from mem point cache' process, ending up in the complete deletion of an
270 * existing disk-cache if any. */
271 return true;
272}
273
274static void rna_Cache_idname_change(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
275{
276 Object *ob = nullptr;
277 Scene *scene = nullptr;
278
279 if (!rna_Cache_get_valid_owner_ID(ptr, &ob, &scene)) {
280 return;
281 }
282
283 PointCache *cache = (PointCache *)ptr->data;
284 bool use_new_name = true;
285
286 /* TODO: check for proper characters */
287
288 if (cache->flag & PTCACHE_EXTERNAL) {
289 PTCacheID pid = BKE_ptcache_id_find(ob, scene, cache);
290
291 if (pid.cache) {
293 }
294
297 }
298 else {
299 PTCacheID *pid = nullptr, *pid2 = nullptr;
300 ListBase pidlist;
301
302 BKE_ptcache_ids_from_object(&pidlist, ob, scene, 0);
303
304 for (pid = static_cast<PTCacheID *>(pidlist.first); pid; pid = pid->next) {
305 if (pid->cache == cache) {
306 pid2 = pid;
307 }
308 else if (cache->name[0] != '\0' && STREQ(cache->name, pid->cache->name)) {
309 /* TODO: report "name exists" to user. */
310 STRNCPY(cache->name, cache->prev_name);
311 use_new_name = false;
312 }
313 }
314
315 if (use_new_name) {
317
318 if (pid2 && cache->flag & PTCACHE_DISK_CACHE) {
319 char old_name[80];
320 char new_name[80];
321
322 STRNCPY(old_name, cache->prev_name);
323 STRNCPY(new_name, cache->name);
324
325 BKE_ptcache_disk_cache_rename(pid2, old_name, new_name);
326 }
327
328 STRNCPY(cache->prev_name, cache->name);
329 }
330
331 BLI_freelistN(&pidlist);
332 }
333}
334
335static void rna_Cache_list_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
336{
337 PointCache *cache = static_cast<PointCache *>(ptr->data);
338 ListBase lb;
339
340 while (cache->prev) {
341 cache = cache->prev;
342 }
343
344 lb.first = cache;
345 lb.last = nullptr; /* not used by listbase_begin */
346
347 rna_iterator_listbase_begin(iter, &lb, nullptr);
348}
349static void rna_Cache_active_point_cache_index_range(
350 PointerRNA *ptr, int *min, int *max, int * /*softmin*/, int * /*softmax*/)
351{
352 *min = 0;
353 *max = 0;
354
355 Object *ob = nullptr;
356 Scene *scene = nullptr;
357
358 if (!rna_Cache_get_valid_owner_ID(ptr, &ob, &scene)) {
359 return;
360 }
361
362 PointCache *cache = static_cast<PointCache *>(ptr->data);
363 PTCacheID pid = BKE_ptcache_id_find(ob, scene, cache);
364
365 if (pid.cache) {
366 *max = max_ii(0, BLI_listbase_count(pid.ptcaches) - 1);
367 }
368}
369
370static int rna_Cache_active_point_cache_index_get(PointerRNA *ptr)
371{
372 int num = 0;
373
374 Object *ob = nullptr;
375 Scene *scene = nullptr;
376
377 if (!rna_Cache_get_valid_owner_ID(ptr, &ob, &scene)) {
378 return num;
379 }
380
381 PointCache *cache = static_cast<PointCache *>(ptr->data);
382 PTCacheID pid = BKE_ptcache_id_find(ob, scene, cache);
383
384 if (pid.cache) {
385 num = BLI_findindex(pid.ptcaches, cache);
386 }
387
388 return num;
389}
390
391static void rna_Cache_active_point_cache_index_set(PointerRNA *ptr, int value)
392{
393 Object *ob = nullptr;
394 Scene *scene = nullptr;
395
396 if (!rna_Cache_get_valid_owner_ID(ptr, &ob, &scene)) {
397 return;
398 }
399
400 PointCache *cache = static_cast<PointCache *>(ptr->data);
401 PTCacheID pid = BKE_ptcache_id_find(ob, scene, cache);
402
403 if (pid.cache) {
404 *(pid.cache_ptr) = static_cast<PointCache *>(BLI_findlink(pid.ptcaches, value));
405 }
406}
407
408static void rna_PointCache_frame_step_range(
409 PointerRNA *ptr, int *min, int *max, int * /*softmin*/, int * /*softmax*/)
410{
411 *min = 1;
412 *max = 20;
413
414 Object *ob = nullptr;
415 Scene *scene = nullptr;
416
417 if (!rna_Cache_get_valid_owner_ID(ptr, &ob, &scene)) {
418 return;
419 }
420
421 PointCache *cache = static_cast<PointCache *>(ptr->data);
422 PTCacheID pid = BKE_ptcache_id_find(ob, scene, cache);
423
424 if (pid.cache) {
425 *max = pid.max_step;
426 }
427}
428
429int rna_Cache_info_length(PointerRNA *ptr)
430{
431 Object *ob = nullptr;
432 Scene *scene = nullptr;
433
434 if (!rna_Cache_get_valid_owner_ID(ptr, &ob, &scene)) {
435 return 0;
436 }
437
438 PointCache *cache = (PointCache *)ptr->data;
439
440 PTCacheID pid = BKE_ptcache_id_find(ob, scene, cache);
441
442 if (pid.cache != nullptr && pid.cache->flag & PTCACHE_FLAG_INFO_DIRTY) {
444 }
445
446 return int(strlen(cache->info));
447}
448
449static std::optional<std::string> rna_CollisionSettings_path(const PointerRNA * /*ptr*/)
450{
451 /* both methods work ok, but return the shorter path */
452# if 0
453 Object *ob = (Object *)ptr->owner_id;
455
456 if (md) {
457 char name_esc[sizeof(md->name) * 2];
458
459 BLI_str_escape(name_esc, md->name, sizeof(name_esc));
460 return fmt::format("modifiers[\"{}\"].settings", name_esc);
461 }
462 else {
463 return "";
464 }
465# else
466 /* more reliable */
467 return "collision";
468# endif
469}
470
471static bool rna_SoftBodySettings_use_edges_get(PointerRNA *ptr)
472{
473 Object *data = (Object *)(ptr->owner_id);
474 return (((data->softflag) & OB_SB_EDGES) != 0);
475}
476
477static void rna_SoftBodySettings_use_edges_set(PointerRNA *ptr, bool value)
478{
479 Object *data = (Object *)(ptr->owner_id);
480 if (value) {
481 data->softflag |= OB_SB_EDGES;
482 }
483 else {
484 data->softflag &= ~OB_SB_EDGES;
485 }
486}
487
488static bool rna_SoftBodySettings_use_goal_get(PointerRNA *ptr)
489{
490 Object *data = (Object *)(ptr->owner_id);
491 return (((data->softflag) & OB_SB_GOAL) != 0);
492}
493
494static void rna_SoftBodySettings_use_goal_set(PointerRNA *ptr, bool value)
495{
496 Object *data = (Object *)(ptr->owner_id);
497 if (value) {
498 data->softflag |= OB_SB_GOAL;
499 }
500 else {
501 data->softflag &= ~OB_SB_GOAL;
502 }
503}
504
505static bool rna_SoftBodySettings_stiff_quads_get(PointerRNA *ptr)
506{
507 Object *data = (Object *)(ptr->owner_id);
508 return (((data->softflag) & OB_SB_QUADS) != 0);
509}
510
511static void rna_SoftBodySettings_stiff_quads_set(PointerRNA *ptr, bool value)
512{
513 Object *data = (Object *)(ptr->owner_id);
514 if (value) {
515 data->softflag |= OB_SB_QUADS;
516 }
517 else {
518 data->softflag &= ~OB_SB_QUADS;
519 }
520}
521
522static bool rna_SoftBodySettings_self_collision_get(PointerRNA *ptr)
523{
524 Object *data = (Object *)(ptr->owner_id);
525 return (((data->softflag) & OB_SB_SELF) != 0);
526}
527
528static void rna_SoftBodySettings_self_collision_set(PointerRNA *ptr, bool value)
529{
530 Object *data = (Object *)(ptr->owner_id);
531 if (value) {
532 data->softflag |= OB_SB_SELF;
533 }
534 else {
535 data->softflag &= ~OB_SB_SELF;
536 }
537}
538
539static int rna_SoftBodySettings_new_aero_get(PointerRNA *ptr)
540{
541 Object *data = (Object *)(ptr->owner_id);
542 if (data->softflag & OB_SB_AERO_ANGLE) {
543 return 1;
544 }
545 else {
546 return 0;
547 }
548}
549
550static void rna_SoftBodySettings_new_aero_set(PointerRNA *ptr, int value)
551{
552 Object *data = (Object *)(ptr->owner_id);
553 if (value == 1) {
554 data->softflag |= OB_SB_AERO_ANGLE;
555 }
556 else { /* value == 0 */
557 data->softflag &= ~OB_SB_AERO_ANGLE;
558 }
559}
560
561static bool rna_SoftBodySettings_face_collision_get(PointerRNA *ptr)
562{
563 Object *data = (Object *)(ptr->owner_id);
564 return (((data->softflag) & OB_SB_FACECOLL) != 0);
565}
566
567static void rna_SoftBodySettings_face_collision_set(PointerRNA *ptr, bool value)
568{
569 Object *data = (Object *)(ptr->owner_id);
570 if (value) {
571 data->softflag |= OB_SB_FACECOLL;
572 }
573 else {
574 data->softflag &= ~OB_SB_FACECOLL;
575 }
576}
577
578static bool rna_SoftBodySettings_edge_collision_get(PointerRNA *ptr)
579{
580 Object *data = (Object *)(ptr->owner_id);
581 return (((data->softflag) & OB_SB_EDGECOLL) != 0);
582}
583
584static void rna_SoftBodySettings_edge_collision_set(PointerRNA *ptr, bool value)
585{
586 Object *data = (Object *)(ptr->owner_id);
587 if (value) {
588 data->softflag |= OB_SB_EDGECOLL;
589 }
590 else {
591 data->softflag &= ~OB_SB_EDGECOLL;
592 }
593}
594
595static void rna_SoftBodySettings_goal_vgroup_get(PointerRNA *ptr, char *value)
596{
597 SoftBody *sb = (SoftBody *)ptr->data;
598 rna_object_vgroup_name_index_get(ptr, value, sb->vertgroup);
599}
600
601static int rna_SoftBodySettings_goal_vgroup_length(PointerRNA *ptr)
602{
603 SoftBody *sb = (SoftBody *)ptr->data;
604 return rna_object_vgroup_name_index_length(ptr, sb->vertgroup);
605}
606
607static void rna_SoftBodySettings_goal_vgroup_set(PointerRNA *ptr, const char *value)
608{
609 SoftBody *sb = (SoftBody *)ptr->data;
610 rna_object_vgroup_name_index_set(ptr, value, &sb->vertgroup);
611}
612
613static void rna_SoftBodySettings_mass_vgroup_set(PointerRNA *ptr, const char *value)
614{
615 SoftBody *sb = (SoftBody *)ptr->data;
616 rna_object_vgroup_name_set(ptr, value, sb->namedVG_Mass, sizeof(sb->namedVG_Mass));
617}
618
619static void rna_SoftBodySettings_spring_vgroup_set(PointerRNA *ptr, const char *value)
620{
621 SoftBody *sb = (SoftBody *)ptr->data;
622 rna_object_vgroup_name_set(ptr, value, sb->namedVG_Spring_K, sizeof(sb->namedVG_Spring_K));
623}
624
625static std::optional<std::string> rna_SoftBodySettings_path(const PointerRNA *ptr)
626{
627 const Object *ob = (Object *)ptr->owner_id;
629 char name_esc[sizeof(md->name) * 2];
630
631 BLI_str_escape(name_esc, md->name, sizeof(name_esc));
632 return fmt::format("modifiers[\"{}\"].settings", name_esc);
633}
634
635static int particle_id_check(const PointerRNA *ptr)
636{
637 ID *id = ptr->owner_id;
638
639 return (GS(id->name) == ID_PA);
640}
641
642static void rna_FieldSettings_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
643{
644 if (particle_id_check(ptr)) {
646
647 if (part->pd->forcefield != PFIELD_TEXTURE && part->pd->tex) {
648 id_us_min(&part->pd->tex->id);
649 part->pd->tex = nullptr;
650 }
651
652 if (part->pd2 && part->pd2->forcefield != PFIELD_TEXTURE && part->pd2->tex) {
653 id_us_min(&part->pd2->tex->id);
654 part->pd2->tex = nullptr;
655 }
656
657 DEG_id_tag_update(&part->id,
661 }
662 else {
663 Object *ob = (Object *)ptr->owner_id;
664
665 if (ob->pd->forcefield != PFIELD_TEXTURE && ob->pd->tex) {
666 id_us_min(&ob->pd->tex->id);
667 ob->pd->tex = nullptr;
668 }
669
670 /* In the case of specific force-fields that are using the #EffectorData's normal, we need to
671 * rebuild mesh and BVH-tree for #SurfaceModifier to work correctly. */
673 ob->pd->forcefield == PFIELD_GUIDE)
674 {
676 }
677
680 }
681}
682
683static void rna_FieldSettings_shape_update(Main *bmain, Scene *scene, PointerRNA *ptr)
684{
685 if (!particle_id_check(ptr)) {
686 Object *ob = (Object *)ptr->owner_id;
688
692 }
693}
694
695static void rna_FieldSettings_type_set(PointerRNA *ptr, int value)
696{
697 PartDeflect *part_deflect = (PartDeflect *)ptr->data;
698
699 part_deflect->forcefield = value;
700
701 if (!particle_id_check(ptr)) {
702 Object *ob = (Object *)ptr->owner_id;
703 ob->pd->forcefield = value;
704 if (ELEM(value, PFIELD_WIND, PFIELD_VORTEX)) {
706 }
707 else {
709 }
710 }
711}
712
713static void rna_FieldSettings_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr)
714{
716
717 if (particle_id_check(ptr)) {
721 }
722 else {
723 Object *ob = (Object *)ptr->owner_id;
724
725 rna_FieldSettings_shape_update(bmain, scene, ptr);
726
727 if (ob->type == OB_CURVES_LEGACY && ob->pd->forcefield == PFIELD_GUIDE) {
729 }
730 else {
732 }
733
735 }
736}
737
738static std::optional<std::string> rna_FieldSettings_path(const PointerRNA *ptr)
739{
741
742 /* Check through all possible places the settings can be to find the right one */
743
744 if (particle_id_check(ptr)) {
745 /* particle system force field */
747
748 if (part->pd == pd) {
749 return "force_field_1";
750 }
751 else if (part->pd2 == pd) {
752 return "force_field_2";
753 }
754 }
755 else {
756 /* object force field */
757 Object *ob = (Object *)ptr->owner_id;
758
759 if (ob->pd == pd) {
760 return "field";
761 }
762 }
763 return std::nullopt;
764}
765
766static void rna_EffectorWeight_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
767{
768 ID *id = ptr->owner_id;
769
770 if (id && GS(id->name) == ID_SCE) {
771 Scene *scene = (Scene *)id;
772 FOREACH_SCENE_OBJECT_BEGIN (scene, ob) {
774 }
776 }
777 else {
780 }
781}
782
783static void rna_EffectorWeight_dependency_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
784{
786
788
790}
791
792static std::optional<std::string> rna_EffectorWeight_path(const PointerRNA *ptr)
793{
795 /* Check through all possible places the settings can be to find the right one */
796
797 if (particle_id_check(ptr)) {
798 /* particle effector weights */
800
801 if (part->effector_weights == ew) {
802 return "effector_weights";
803 }
804 }
805 else {
806 ID *id = ptr->owner_id;
807
808 if (id && GS(id->name) == ID_SCE) {
809 const Scene *scene = (Scene *)id;
810 const RigidBodyWorld *rbw = scene->rigidbody_world;
811
812 if (rbw->effector_weights == ew) {
813 return "rigidbody_world.effector_weights";
814 }
815 }
816
817 Object *ob = (Object *)id;
818 ModifierData *md;
819
820 /* check softbody modifier */
822 if (md) {
823 /* no pointer from modifier data to actual softbody storage, would be good to add */
824 if (ob->soft->effector_weights == ew) {
825 char name_esc[sizeof(md->name) * 2];
826 BLI_str_escape(name_esc, md->name, sizeof(name_esc));
827 return fmt::format("modifiers[\"{}\"].settings.effector_weights", name_esc);
828 }
829 }
830
831 /* check cloth modifier */
833 if (md) {
835 if (cmd->sim_parms->effector_weights == ew) {
836 char name_esc[sizeof(md->name) * 2];
837 BLI_str_escape(name_esc, md->name, sizeof(name_esc));
838 return fmt::format("modifiers[\"{}\"].settings.effector_weights", name_esc);
839 }
840 }
841
842 /* check fluid modifier */
844 if (md) {
846 if (fmd->type == MOD_FLUID_TYPE_DOMAIN && fmd->domain && fmd->domain->effector_weights == ew)
847 {
848 char name_esc[sizeof(md->name) * 2];
849 BLI_str_escape(name_esc, md->name, sizeof(name_esc));
850 return fmt::format("modifiers[\"{}\"].domain_settings.effector_weights", name_esc);
851 }
852 }
853
854 /* check dynamic paint modifier */
856 if (md) {
858
859 if (pmd->canvas) {
860 DynamicPaintSurface *surface = static_cast<DynamicPaintSurface *>(
861 pmd->canvas->surfaces.first);
862
863 for (; surface; surface = surface->next) {
864 if (surface->effector_weights == ew) {
865 char name_esc[sizeof(md->name) * 2];
866 char name_esc_surface[sizeof(surface->name) * 2];
867
868 BLI_str_escape(name_esc, md->name, sizeof(name_esc));
869 BLI_str_escape(name_esc_surface, surface->name, sizeof(name_esc_surface));
870 return fmt::format(
871 "modifiers[\"{}\"].canvas_settings.canvas_surfaces[\"{}\"]"
872 ".effector_weights",
873 name_esc,
874 name_esc_surface);
875 }
876 }
877 }
878 }
879 }
880 return std::nullopt;
881}
882
883static void rna_CollisionSettings_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr)
884{
885 Object *ob = (Object *)ptr->owner_id;
887
888 /* add the modifier if needed */
889 if (ob->pd->deflect && !md) {
890 blender::ed::object::modifier_add(nullptr, bmain, scene, ob, nullptr, eModifierType_Collision);
891 }
892
895}
896
897static void rna_CollisionSettings_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
898{
899 Object *ob = (Object *)ptr->owner_id;
900
903}
904
905static void rna_softbody_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
906{
907 Object *ob = (Object *)ptr->owner_id;
908
911}
912
913static void rna_softbody_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr)
914{
916 rna_softbody_update(bmain, scene, ptr);
917}
918
919static const EnumPropertyItem *rna_Effector_shape_itemf(bContext * /*C*/,
921 PropertyRNA * /*prop*/,
922 bool * /*r_free*/)
923{
924 Object *ob = nullptr;
925
926 if (particle_id_check(ptr)) {
927 return empty_shape_items;
928 }
929
930 ob = (Object *)ptr->owner_id;
931
932 if (ob->type == OB_CURVES_LEGACY) {
933 if (ob->pd->forcefield == PFIELD_VORTEX) {
934 return curve_vortex_shape_items;
935 }
936
937 return curve_shape_items;
938 }
939 else if (ELEM(ob->type, OB_MESH, OB_SURF, OB_FONT)) {
940 if (ob->pd->forcefield == PFIELD_VORTEX) {
941 return vortex_shape_items;
942 }
943
945 }
946 else {
947 if (ob->pd->forcefield == PFIELD_VORTEX) {
948 return empty_vortex_shape_items;
949 }
950
951 return empty_shape_items;
952 }
953}
954
955#else
956
958{
959 PropertyRNA *prop;
960
961 static const EnumPropertyItem point_cache_compress_items[] = {
962 {PTCACHE_COMPRESS_NO, "NO", 0, "None", "No compression"},
963 {PTCACHE_COMPRESS_LZO, "LIGHT", 0, "Lite", "Fast but not so effective compression"},
964 {PTCACHE_COMPRESS_LZMA, "HEAVY", 0, "Heavy", "Effective but slow compression"},
965 {0, nullptr, 0, nullptr, nullptr},
966 };
967
968 RNA_def_struct_path_func(srna, "rna_PointCache_path");
969
971
972 prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);
973 RNA_def_property_int_sdna(prop, nullptr, "startframe");
975 RNA_def_property_ui_range(prop, 0, MAXFRAME, 1, 1);
976 RNA_def_property_ui_text(prop, "Start", "Frame on which the simulation starts");
977
978 prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_TIME);
979 RNA_def_property_int_sdna(prop, nullptr, "endframe");
981 RNA_def_property_ui_text(prop, "End", "Frame on which the simulation stops");
982
983 prop = RNA_def_property(srna, "frame_step", PROP_INT, PROP_NONE);
984 RNA_def_property_int_sdna(prop, nullptr, "step");
985 RNA_def_property_range(prop, 1, 20);
986 RNA_def_property_int_funcs(prop, nullptr, nullptr, "rna_PointCache_frame_step_range");
987 RNA_def_property_ui_text(prop, "Cache Step", "Number of frames between cached frames");
988 RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_change");
989
990 prop = RNA_def_property(srna, "index", PROP_INT, PROP_NONE);
991 RNA_def_property_int_sdna(prop, nullptr, "index");
992 RNA_def_property_range(prop, -1, 100);
993 RNA_def_property_ui_text(prop, "Cache Index", "Index number of cache files");
994 RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change");
995
996 prop = RNA_def_property(srna, "compression", PROP_ENUM, PROP_NONE);
997 RNA_def_property_enum_items(prop, point_cache_compress_items);
998 RNA_def_property_ui_text(prop, "Cache Compression", "Compression method to be used");
999
1000 /* flags */
1001 prop = RNA_def_property(srna, "is_baked", PROP_BOOLEAN, PROP_NONE);
1002 RNA_def_property_boolean_sdna(prop, nullptr, "flag", PTCACHE_BAKED);
1004 RNA_def_property_ui_text(prop, "", "The cache is baked");
1005
1006 prop = RNA_def_property(srna, "is_baking", PROP_BOOLEAN, PROP_NONE);
1007 RNA_def_property_boolean_sdna(prop, nullptr, "flag", PTCACHE_BAKING);
1009 RNA_def_property_ui_text(prop, "", "The cache is being baked");
1010
1011 prop = RNA_def_property(srna, "use_disk_cache", PROP_BOOLEAN, PROP_NONE);
1012 RNA_def_property_boolean_sdna(prop, nullptr, "flag", PTCACHE_DISK_CACHE);
1014 prop, "Disk Cache", "Save cache files to disk (.blend file must be saved first)");
1015 RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_toggle_disk_cache");
1017 prop, nullptr, nullptr, "rna_Cache_use_disk_cache_override_apply");
1018
1019 prop = RNA_def_property(srna, "is_outdated", PROP_BOOLEAN, PROP_NONE);
1020 RNA_def_property_boolean_sdna(prop, nullptr, "flag", PTCACHE_OUTDATED);
1022 RNA_def_property_ui_text(prop, "Cache Is Outdated", "");
1023
1024 prop = RNA_def_property(srna, "is_frame_skip", PROP_BOOLEAN, PROP_NONE);
1027 RNA_def_property_ui_text(prop, "", "Some frames were skipped while baking/saving that cache");
1028
1029 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1030 RNA_def_property_string_sdna(prop, nullptr, "name");
1031 RNA_def_property_ui_text(prop, "Name", "Cache name");
1032 RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change");
1033 RNA_def_struct_name_property(srna, prop);
1034
1035 prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_DIRPATH);
1036 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:359
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:50
#define BLI_assert_msg(a, msg)
Definition BLI_assert.h:57
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
Definition listbase.cc:496
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE int max_ii(int a, int b)
bool BLI_path_make_safe_filename(char *filename) ATTR_NONNULL(1)
#define STRNCPY(dst, src)
Definition BLI_string.h:593
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:1021
@ ID_RECALC_PSYS_RESET
Definition DNA_ID.h:1050
@ ID_RECALC_ANIMATION
Definition DNA_ID.h:1044
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1041
@ LIBOVERRIDE_OP_REPLACE
Definition DNA_ID.h:229
@ ID_SCE
@ ID_OB
@ ID_PA
@ MOD_FLUID_TYPE_DOMAIN
@ eModifierType_ParticleSystem
@ eModifierType_Cloth
@ eModifierType_Fluid
@ eModifierType_Collision
@ eModifierType_DynamicPaint
@ eModifierType_Softbody
@ 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_FLUIDFLOW
@ PFIELD_HARMONIC
@ PFIELD_TURBULENCE
@ PFIELD_LENNARDJ
@ EFF_WEIGHT_DO_HAIR
@ SBC_MODE_AVGMINMAX
@ PFIELD_SHAPE_LINE
@ PFIELD_SHAPE_PLANE
@ PFIELD_SHAPE_SURFACE
@ PFIELD_SHAPE_POINTS
@ PFIELD_SHAPE_POINT
@ PFIELD_FALL_SPHERE
Object is a sort of wrapper for general info.
@ OB_SURF
@ OB_FONT
@ OB_MESH
@ OB_CURVES_LEGACY
@ OB_SINGLE_ARROW
@ OB_PLAINAXES
@ 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:67
@ PROP_BOOLEAN
Definition RNA_types.hh:65
@ PROP_ENUM
Definition RNA_types.hh:69
@ PROP_INT
Definition RNA_types.hh:66
@ PROP_STRING
Definition RNA_types.hh:68
@ PROP_POINTER
Definition RNA_types.hh:70
@ PROP_COLLECTION
Definition RNA_types.hh:71
@ PROP_UNIT_MASS
Definition RNA_types.hh:80
#define RNA_TRANSLATION_PREC_DEFAULT
Definition RNA_types.hh:127
@ PROPOVERRIDE_OVERRIDABLE_LIBRARY
Definition RNA_types.hh:355
@ PROPOVERRIDE_NO_COMPARISON
Definition RNA_types.hh:363
@ PROP_ANIMATABLE
Definition RNA_types.hh:220
@ PROP_EDITABLE
Definition RNA_types.hh:207
@ PROP_ID_REFCOUNT
Definition RNA_types.hh:253
@ PROP_TIME
Definition RNA_types.hh:156
@ PROP_MATRIX
Definition RNA_types.hh:168
@ PROP_DISTANCE
Definition RNA_types.hh:159
@ PROP_ACCELERATION
Definition RNA_types.hh:167
@ PROP_NONE
Definition RNA_types.hh:136
@ PROP_DIRPATH
Definition RNA_types.hh:140
@ PROP_FACTOR
Definition RNA_types.hh:154
@ PROP_TRANSLATION
Definition RNA_types.hh:164
@ PROP_UNSIGNED
Definition RNA_types.hh:152
#define ND_DRAW
Definition WM_types.hh:428
#define ND_MODIFIER
Definition WM_types.hh:429
#define ND_POINTCACHE
Definition WM_types.hh:433
#define NC_OBJECT
Definition WM_types.hh:346
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
#define GS(x)
Definition iris.cc:202
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)
void rna_iterator_listbase_begin(CollectionPropertyIterator *iter, ListBase *lb, IteratorSkipFunc skip)
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, bool value)
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_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t bit)
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.c:32
#define FLT_MAX
Definition stdcycles.h:14
struct PointCache * point_cache
struct ClothSimSettings * sim_parms
struct EffectorWeights * effector_weights
struct DynamicPaintCanvasSettings * canvas
struct EffectorWeights * effector_weights
struct FluidDomainSettings * domain
Definition DNA_ID.h:413
char name[66]
Definition DNA_ID.h:425
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
ID * owner_id
Definition RNA_types.hh:40
void * data
Definition RNA_types.hh:42
IDOverrideLibraryPropertyOperation * liboverride_operation
struct EffectorWeights * effector_weights
struct PointCache * pointcache
struct SoftBody_Shared * shared
struct EffectorWeights * effector_weights
void WM_main_add_notifier(uint type, void *reference)
PointerRNA * ptr
Definition wm_files.cc:4126