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