Blender V5.3
rna_cloth.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 <algorithm>
10#include <climits>
11#include <cstdlib>
12
13#include "DNA_cloth_types.h"
14
15#include "BLI_math_base_c.hh"
16
17#include "RNA_define.hh"
18
19#include "rna_internal.hh"
20
21#include "BKE_modifier.hh"
22
23#include "SIM_mass_spring.h"
24
25#include "WM_api.hh"
26#include "WM_types.hh"
27
28#ifdef RNA_RUNTIME
29
30# include <algorithm>
31
32# include <fmt/format.h>
33
34# include "BLI_string.hh"
35
36# include "BKE_cloth.hh"
37# include "BKE_context.hh"
38# include "BKE_particle.h"
39
40# include "BLT_translation.hh"
41
42# include "DEG_depsgraph.hh"
43# include "DEG_depsgraph_build.hh"
44
45namespace blender {
46
47static void rna_cloth_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
48{
49 Object *ob = id_cast<Object *>(ptr->owner_id);
50
53}
54
55static void rna_cloth_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr)
56{
58 rna_cloth_update(bmain, scene, ptr);
59}
60
61static void rna_cloth_pinning_changed(Main * /*bmain*/, Scene * /*scene*/, PointerRNA *ptr)
62{
63 Object *ob = id_cast<Object *>(ptr->owner_id);
64 // ClothSimSettings *settings = (ClothSimSettings *)ptr->data;
65 ClothModifierData *clmd = reinterpret_cast<ClothModifierData *>(
67
69
72}
73
74static void rna_ClothSettings_bending_set(PointerRNA *ptr, float value)
75{
76 ClothSimSettings *settings = static_cast<ClothSimSettings *>(ptr->data);
77
78 settings->bending = value;
79
80 /* check for max clipping */
81 settings->max_bend = std::max(value, settings->max_bend);
82}
83
84static void rna_ClothSettings_max_bend_set(PointerRNA *ptr, float value)
85{
86 ClothSimSettings *settings = static_cast<ClothSimSettings *>(ptr->data);
87
88 /* check for clipping */
89 value = std::max(value, settings->bending);
90
91 settings->max_bend = value;
92}
93
94static void rna_ClothSettings_tension_set(PointerRNA *ptr, float value)
95{
96 ClothSimSettings *settings = static_cast<ClothSimSettings *>(ptr->data);
97
98 settings->tension = value;
99
100 /* check for max clipping */
101 settings->max_tension = std::max(value, settings->max_tension);
102}
103
104static void rna_ClothSettings_max_tension_set(PointerRNA *ptr, float value)
105{
106 ClothSimSettings *settings = static_cast<ClothSimSettings *>(ptr->data);
107
108 /* check for clipping */
109 value = std::max(value, settings->tension);
110
111 settings->max_tension = value;
112}
113
114static void rna_ClothSettings_compression_set(PointerRNA *ptr, float value)
115{
116 ClothSimSettings *settings = static_cast<ClothSimSettings *>(ptr->data);
117
118 settings->compression = value;
119
120 /* check for max clipping */
121 settings->max_compression = std::max(value, settings->max_compression);
122}
123
124static void rna_ClothSettings_max_compression_set(PointerRNA *ptr, float value)
125{
126 ClothSimSettings *settings = static_cast<ClothSimSettings *>(ptr->data);
127
128 /* check for clipping */
129 value = std::max(value, settings->compression);
130
131 settings->max_compression = value;
132}
133
134static void rna_ClothSettings_shear_set(PointerRNA *ptr, float value)
135{
136 ClothSimSettings *settings = static_cast<ClothSimSettings *>(ptr->data);
137
138 settings->shear = value;
139
140 /* check for max clipping */
141 settings->max_shear = std::max(value, settings->max_shear);
142}
143
144static void rna_ClothSettings_max_shear_set(PointerRNA *ptr, float value)
145{
146 ClothSimSettings *settings = static_cast<ClothSimSettings *>(ptr->data);
147
148 /* check for clipping */
149 value = std::max(value, settings->shear);
150
151 settings->max_shear = value;
152}
153
154static void rna_ClothSettings_max_sewing_set(PointerRNA *ptr, float value)
155{
156 ClothSimSettings *settings = static_cast<ClothSimSettings *>(ptr->data);
157
158 /* check for clipping */
159 value = std::max(value, 0.0f);
160
161 settings->max_sewing = value;
162}
163
164static void rna_ClothSettings_shrink_min_set(PointerRNA *ptr, float value)
165{
166 ClothSimSettings *settings = static_cast<ClothSimSettings *>(ptr->data);
167
168 settings->shrink_min = value;
169
170 /* check for max clipping */
171 settings->shrink_max = std::max(value, settings->shrink_max);
172}
173
174static void rna_ClothSettings_shrink_max_set(PointerRNA *ptr, float value)
175{
176 ClothSimSettings *settings = static_cast<ClothSimSettings *>(ptr->data);
177
178 /* check for clipping */
179 value = std::max(value, settings->shrink_min);
180
181 settings->shrink_max = value;
182}
183
184static void rna_ClothSettings_internal_tension_set(PointerRNA *ptr, float value)
185{
186 ClothSimSettings *settings = static_cast<ClothSimSettings *>(ptr->data);
187
188 settings->internal_tension = value;
189
190 /* check for max clipping */
191 settings->max_internal_tension = std::max(value, settings->max_internal_tension);
192}
193
194static void rna_ClothSettings_max_internal_tension_set(PointerRNA *ptr, float value)
195{
196 ClothSimSettings *settings = static_cast<ClothSimSettings *>(ptr->data);
197
198 /* check for clipping */
199 value = std::max(value, settings->internal_tension);
200
201 settings->max_internal_tension = value;
202}
203
204static void rna_ClothSettings_internal_compression_set(PointerRNA *ptr, float value)
205{
206 ClothSimSettings *settings = static_cast<ClothSimSettings *>(ptr->data);
207
208 settings->internal_compression = value;
209
210 /* check for max clipping */
211 settings->max_internal_compression = std::max(value, settings->max_internal_compression);
212}
213
214static void rna_ClothSettings_max_internal_compression_set(PointerRNA *ptr, float value)
215{
216 ClothSimSettings *settings = static_cast<ClothSimSettings *>(ptr->data);
217
218 /* check for clipping */
219 value = std::max(value, settings->internal_compression);
220
221 settings->max_internal_compression = value;
222}
223
224static void rna_ClothSettings_mass_vgroup_get(PointerRNA *ptr, char *value)
225{
226 ClothSimSettings *sim = static_cast<ClothSimSettings *>(ptr->data);
227 rna_object_vgroup_name_index_get(ptr, value, sim->vgroup_mass);
228}
229
230static int rna_ClothSettings_mass_vgroup_length(PointerRNA *ptr)
231{
232 ClothSimSettings *sim = static_cast<ClothSimSettings *>(ptr->data);
233 return rna_object_vgroup_name_index_length(ptr, sim->vgroup_mass);
234}
235
236static void rna_ClothSettings_mass_vgroup_set(PointerRNA *ptr, const char *value)
237{
238 ClothSimSettings *sim = static_cast<ClothSimSettings *>(ptr->data);
239 rna_object_vgroup_name_index_set(ptr, value, &sim->vgroup_mass);
240}
241
242static void rna_ClothSettings_shrink_vgroup_get(PointerRNA *ptr, char *value)
243{
244 ClothSimSettings *sim = static_cast<ClothSimSettings *>(ptr->data);
245 rna_object_vgroup_name_index_get(ptr, value, sim->vgroup_shrink);
246}
247
248static int rna_ClothSettings_shrink_vgroup_length(PointerRNA *ptr)
249{
250 ClothSimSettings *sim = static_cast<ClothSimSettings *>(ptr->data);
251 return rna_object_vgroup_name_index_length(ptr, sim->vgroup_shrink);
252}
253
254static void rna_ClothSettings_shrink_vgroup_set(PointerRNA *ptr, const char *value)
255{
256 ClothSimSettings *sim = static_cast<ClothSimSettings *>(ptr->data);
257 rna_object_vgroup_name_index_set(ptr, value, &sim->vgroup_shrink);
258}
259
260static void rna_ClothSettings_struct_vgroup_get(PointerRNA *ptr, char *value)
261{
262 ClothSimSettings *sim = static_cast<ClothSimSettings *>(ptr->data);
263 rna_object_vgroup_name_index_get(ptr, value, sim->vgroup_struct);
264}
265
266static int rna_ClothSettings_struct_vgroup_length(PointerRNA *ptr)
267{
268 ClothSimSettings *sim = static_cast<ClothSimSettings *>(ptr->data);
269 return rna_object_vgroup_name_index_length(ptr, sim->vgroup_struct);
270}
271
272static void rna_ClothSettings_struct_vgroup_set(PointerRNA *ptr, const char *value)
273{
274 ClothSimSettings *sim = static_cast<ClothSimSettings *>(ptr->data);
275 rna_object_vgroup_name_index_set(ptr, value, &sim->vgroup_struct);
276}
277
278static void rna_ClothSettings_shear_vgroup_get(PointerRNA *ptr, char *value)
279{
280 ClothSimSettings *sim = static_cast<ClothSimSettings *>(ptr->data);
281 rna_object_vgroup_name_index_get(ptr, value, sim->vgroup_shear);
282}
283
284static int rna_ClothSettings_shear_vgroup_length(PointerRNA *ptr)
285{
286 ClothSimSettings *sim = static_cast<ClothSimSettings *>(ptr->data);
287 return rna_object_vgroup_name_index_length(ptr, sim->vgroup_shear);
288}
289
290static void rna_ClothSettings_shear_vgroup_set(PointerRNA *ptr, const char *value)
291{
292 ClothSimSettings *sim = static_cast<ClothSimSettings *>(ptr->data);
293 rna_object_vgroup_name_index_set(ptr, value, &sim->vgroup_shear);
294}
295
296static void rna_ClothSettings_bend_vgroup_get(PointerRNA *ptr, char *value)
297{
298 ClothSimSettings *sim = static_cast<ClothSimSettings *>(ptr->data);
299 rna_object_vgroup_name_index_get(ptr, value, sim->vgroup_bend);
300}
301
302static int rna_ClothSettings_bend_vgroup_length(PointerRNA *ptr)
303{
304 ClothSimSettings *sim = static_cast<ClothSimSettings *>(ptr->data);
305 return rna_object_vgroup_name_index_length(ptr, sim->vgroup_bend);
306}
307
308static void rna_ClothSettings_bend_vgroup_set(PointerRNA *ptr, const char *value)
309{
310 ClothSimSettings *sim = static_cast<ClothSimSettings *>(ptr->data);
311 rna_object_vgroup_name_index_set(ptr, value, &sim->vgroup_bend);
312}
313
314static void rna_ClothSettings_internal_vgroup_get(PointerRNA *ptr, char *value)
315{
316 ClothSimSettings *sim = static_cast<ClothSimSettings *>(ptr->data);
317 rna_object_vgroup_name_index_get(ptr, value, sim->vgroup_intern);
318}
319
320static int rna_ClothSettings_internal_vgroup_length(PointerRNA *ptr)
321{
322 ClothSimSettings *sim = static_cast<ClothSimSettings *>(ptr->data);
323 return rna_object_vgroup_name_index_length(ptr, sim->vgroup_intern);
324}
325
326static void rna_ClothSettings_internal_vgroup_set(PointerRNA *ptr, const char *value)
327{
328 ClothSimSettings *sim = static_cast<ClothSimSettings *>(ptr->data);
329 rna_object_vgroup_name_index_set(ptr, value, &sim->vgroup_intern);
330}
331
332static void rna_ClothSettings_pressure_vgroup_get(PointerRNA *ptr, char *value)
333{
334 ClothSimSettings *sim = static_cast<ClothSimSettings *>(ptr->data);
335 rna_object_vgroup_name_index_get(ptr, value, sim->vgroup_pressure);
336}
337
338static int rna_ClothSettings_pressure_vgroup_length(PointerRNA *ptr)
339{
340 ClothSimSettings *sim = static_cast<ClothSimSettings *>(ptr->data);
341 return rna_object_vgroup_name_index_length(ptr, sim->vgroup_pressure);
342}
343
344static void rna_ClothSettings_pressure_vgroup_set(PointerRNA *ptr, const char *value)
345{
346 ClothSimSettings *sim = static_cast<ClothSimSettings *>(ptr->data);
347 rna_object_vgroup_name_index_set(ptr, value, &sim->vgroup_pressure);
348}
349
350static void rna_CollSettings_selfcol_vgroup_get(PointerRNA *ptr, char *value)
351{
352 ClothCollSettings *coll = static_cast<ClothCollSettings *>(ptr->data);
353 rna_object_vgroup_name_index_get(ptr, value, coll->vgroup_selfcol);
354}
355
356static int rna_CollSettings_selfcol_vgroup_length(PointerRNA *ptr)
357{
358 ClothCollSettings *coll = static_cast<ClothCollSettings *>(ptr->data);
359 return rna_object_vgroup_name_index_length(ptr, coll->vgroup_selfcol);
360}
361
362static void rna_CollSettings_selfcol_vgroup_set(PointerRNA *ptr, const char *value)
363{
364 ClothCollSettings *coll = static_cast<ClothCollSettings *>(ptr->data);
365 rna_object_vgroup_name_index_set(ptr, value, &coll->vgroup_selfcol);
366}
367
368static void rna_CollSettings_objcol_vgroup_get(PointerRNA *ptr, char *value)
369{
370 ClothCollSettings *coll = static_cast<ClothCollSettings *>(ptr->data);
371 rna_object_vgroup_name_index_get(ptr, value, coll->vgroup_objcol);
372}
373
374static int rna_CollSettings_objcol_vgroup_length(PointerRNA *ptr)
375{
376 ClothCollSettings *coll = static_cast<ClothCollSettings *>(ptr->data);
377 return rna_object_vgroup_name_index_length(ptr, coll->vgroup_objcol);
378}
379
380static void rna_CollSettings_objcol_vgroup_set(PointerRNA *ptr, const char *value)
381{
382 ClothCollSettings *coll = static_cast<ClothCollSettings *>(ptr->data);
383 rna_object_vgroup_name_index_set(ptr, value, &coll->vgroup_objcol);
384}
385
386static PointerRNA rna_ClothSettings_rest_shape_key_get(PointerRNA *ptr)
387{
388 Object *ob = id_cast<Object *>(ptr->owner_id);
389 ClothSimSettings *sim = static_cast<ClothSimSettings *>(ptr->data);
390
391 return rna_object_shapekey_index_get(ob->data, sim->shapekey_rest);
392}
393
394static void rna_ClothSettings_rest_shape_key_set(PointerRNA *ptr,
395 PointerRNA value,
396 ReportList * /*reports*/)
397{
398 Object *ob = id_cast<Object *>(ptr->owner_id);
399 ClothSimSettings *sim = static_cast<ClothSimSettings *>(ptr->data);
400
401 sim->shapekey_rest = rna_object_shapekey_index_set(ob->data, value, sim->shapekey_rest);
402}
403
404static void rna_ClothSettings_gravity_get(PointerRNA *ptr, float *values)
405{
406 ClothSimSettings *sim = static_cast<ClothSimSettings *>(ptr->data);
407
408 values[0] = sim->gravity[0];
409 values[1] = sim->gravity[1];
410 values[2] = sim->gravity[2];
411}
412
413static void rna_ClothSettings_gravity_set(PointerRNA *ptr, const float *values)
414{
415 ClothSimSettings *sim = static_cast<ClothSimSettings *>(ptr->data);
416
417 sim->gravity[0] = values[0];
418 sim->gravity[1] = values[1];
419 sim->gravity[2] = values[2];
420}
421
422static std::optional<std::string> rna_ClothSettings_path(const PointerRNA *ptr)
423{
424 const ClothSimSettings *settings = static_cast<ClothSimSettings *>(ptr->data);
425 const Object *ob = id_cast<Object *>(ptr->owner_id);
426
427 /* ClothSettings can be used in the Cloth modifier... */
429 if (md) {
430 const ClothModifierData *clmd = reinterpret_cast<const ClothModifierData *>(md);
431 if (clmd->sim_parms == settings) {
432 char name_esc[sizeof(md->name) * 2];
433 BLI_str_escape(name_esc, md->name, sizeof(name_esc));
434 return fmt::format("modifiers[\"{}\"].settings", name_esc);
435 }
436 }
437 /* ... but also in Hair dynamics. */
438 for (ParticleSystem &psys : ob->particlesystem) {
439 if (!psys.clmd) {
440 continue;
441 }
442 if (psys.clmd->sim_parms == settings) {
443 char name_esc[sizeof(psys.name) * 2];
444 BLI_str_escape(name_esc, psys.name, sizeof(name_esc));
445 return fmt::format("particle_systems[\"{}\"].cloth.settings", name_esc);
446 }
447 }
448
449 return std::nullopt;
450}
451
452static std::optional<std::string> rna_ClothCollisionSettings_path(const PointerRNA *ptr)
453{
454 const ClothCollSettings *settings = static_cast<ClothCollSettings *>(ptr->data);
455 const Object *ob = id_cast<Object *>(ptr->owner_id);
456
457 /* ClothCollisionSettings can be used in the Cloth modifier... */
459 if (md) {
460 const ClothModifierData *clmd = reinterpret_cast<const ClothModifierData *>(md);
461 if (clmd->coll_parms == settings) {
462 char name_esc[sizeof(md->name) * 2];
463 BLI_str_escape(name_esc, md->name, sizeof(name_esc));
464 return fmt::format("modifiers[\"{}\"].collision_settings", name_esc);
465 }
466 }
467 /* ... but also in Hair dynamics. */
468 for (ParticleSystem &psys : ob->particlesystem) {
469 if (!psys.clmd) {
470 continue;
471 }
472 if (psys.clmd->coll_parms == settings) {
473 char name_esc[sizeof(psys.name) * 2];
474 BLI_str_escape(name_esc, psys.name, sizeof(name_esc));
475 return fmt::format("particle_systems[\"{}\"].cloth.collision_settings", name_esc);
476 }
477 }
478
479 return std::nullopt;
480}
481
482static int rna_ClothSettings_internal_editable(const PointerRNA *ptr, const char **r_info)
483{
484 ClothSimSettings *sim = static_cast<ClothSimSettings *>(ptr->data);
485
486 if (sim && (sim->bending_model == CLOTH_BENDING_LINEAR)) {
487 *r_info = N_("Only available with angular bending springs.");
488 return 0;
489 }
490
491 return sim ? PROP_EDITABLE : PropertyFlag(0);
492}
493
494} // namespace blender
495
496#else
497
498namespace blender {
499
501{
502 StructRNA *srna;
503 PropertyRNA *prop;
504
505 static const EnumPropertyItem status_items[] = {
506 {SIM_SOLVER_SUCCESS, "SUCCESS", 0, "Success", "Computation was successful"},
508 "NUMERICAL_ISSUE",
509 0,
510 "Numerical Issue",
511 "The provided data did not satisfy the prerequisites"},
513 "NO_CONVERGENCE",
514 0,
515 "No Convergence",
516 "Iterative procedure did not converge"},
518 "INVALID_INPUT",
519 0,
520 "Invalid Input",
521 "The inputs are invalid, or the algorithm has been improperly called"},
522 {0, nullptr, 0, nullptr, nullptr},
523 };
524
525 srna = RNA_def_struct(brna, "ClothSolverResult", nullptr);
526 RNA_def_struct_ui_text(srna, "Solver Result", "Result of cloth solver iteration");
527
529
530 prop = RNA_def_property(srna, "status", PROP_ENUM, PROP_NONE);
532 RNA_def_property_enum_items(prop, status_items);
533 RNA_def_property_enum_sdna(prop, nullptr, "status");
535 RNA_def_property_ui_text(prop, "Status", "Status of the solver iteration");
536
537 prop = RNA_def_property(srna, "max_error", PROP_FLOAT, PROP_NONE);
538 RNA_def_property_float_sdna(prop, nullptr, "max_error");
540 RNA_def_property_ui_text(prop, "Maximum Error", "Maximum error during substeps");
541
542 prop = RNA_def_property(srna, "min_error", PROP_FLOAT, PROP_NONE);
543 RNA_def_property_float_sdna(prop, nullptr, "min_error");
545 RNA_def_property_ui_text(prop, "Minimum Error", "Minimum error during substeps");
546
547 prop = RNA_def_property(srna, "avg_error", PROP_FLOAT, PROP_NONE);
548 RNA_def_property_float_sdna(prop, nullptr, "avg_error");
550 RNA_def_property_ui_text(prop, "Average Error", "Average error during substeps");
551
552 prop = RNA_def_property(srna, "max_iterations", PROP_INT, PROP_NONE);
553 RNA_def_property_int_sdna(prop, nullptr, "max_iterations");
555 RNA_def_property_ui_text(prop, "Maximum Iterations", "Maximum iterations during substeps");
556
557 prop = RNA_def_property(srna, "min_iterations", PROP_INT, PROP_NONE);
558 RNA_def_property_int_sdna(prop, nullptr, "min_iterations");
560 RNA_def_property_ui_text(prop, "Minimum Iterations", "Minimum iterations during substeps");
561
562 prop = RNA_def_property(srna, "avg_iterations", PROP_FLOAT, PROP_NONE);
563 RNA_def_property_float_sdna(prop, nullptr, "avg_iterations");
565 RNA_def_property_ui_text(prop, "Average Iterations", "Average iterations during substeps");
566
568}
569
571{
572 StructRNA *srna;
573 PropertyRNA *prop;
574
575 static const EnumPropertyItem prop_bending_model_items[] = {
576 {CLOTH_BENDING_ANGULAR, "ANGULAR", 0, "Angular", "Cloth model with angular bending springs"},
578 "LINEAR",
579 0,
580 "Linear",
581 "Cloth model with linear bending springs (legacy)"},
582 {0, nullptr, 0, nullptr, nullptr},
583 };
584
585 srna = RNA_def_struct(brna, "ClothSettings", nullptr);
586 RNA_def_struct_ui_text(srna, "Cloth Settings", "Cloth simulation settings for an object");
587 RNA_def_struct_sdna(srna, "ClothSimSettings");
588 RNA_def_struct_path_func(srna, "rna_ClothSettings_path");
589
591
592 /* goal */
593
594 prop = RNA_def_property(srna, "goal_min", PROP_FLOAT, PROP_FACTOR);
595 RNA_def_property_float_sdna(prop, nullptr, "mingoal");
596 RNA_def_property_range(prop, 0.0f, 1.0f);
598 prop, "Goal Minimum", "Goal minimum, vertex group weights are scaled to match this range");
599 RNA_def_property_update(prop, 0, "rna_cloth_update");
600
601 prop = RNA_def_property(srna, "goal_max", PROP_FLOAT, PROP_FACTOR);
602 RNA_def_property_float_sdna(prop, nullptr, "maxgoal");
603 RNA_def_property_range(prop, 0.0f, 1.0f);
605 prop, "Goal Maximum", "Goal maximum, vertex group weights are scaled to match this range");
606 RNA_def_property_update(prop, 0, "rna_cloth_update");
607
608 prop = RNA_def_property(srna, "goal_default", PROP_FLOAT, PROP_FACTOR);
609 RNA_def_property_float_sdna(prop, nullptr, "defgoal");
610 RNA_def_property_range(prop, 0.0f, 1.0f);
612 prop,
613 "Goal Default",
614 "Default Goal (vertex target position) value, when no Vertex Group used");
615 RNA_def_property_update(prop, 0, "rna_cloth_update");
616
617 prop = RNA_def_property(srna, "goal_spring", PROP_FLOAT, PROP_NONE);
618 RNA_def_property_float_sdna(prop, nullptr, "goalspring");
619 RNA_def_property_range(prop, 0.0f, 0.999f);
621 prop, "Goal Stiffness", "Goal (vertex target position) spring stiffness");
622 RNA_def_property_update(prop, 0, "rna_cloth_update");
623
624 prop = RNA_def_property(srna, "goal_friction", PROP_FLOAT, PROP_NONE);
625 RNA_def_property_float_sdna(prop, nullptr, "goalfrict");
626 RNA_def_property_range(prop, 0.0f, 50.0f);
627 RNA_def_property_ui_text(prop, "Goal Damping", "Goal (vertex target position) friction");
628 RNA_def_property_update(prop, 0, "rna_cloth_update");
629
630 prop = RNA_def_property(srna, "internal_friction", PROP_FLOAT, PROP_FACTOR);
631 RNA_def_property_float_sdna(prop, nullptr, "velocity_smooth");
632 RNA_def_property_range(prop, 0.0f, 1.0f);
633 RNA_def_property_ui_text(prop, "Internal Friction", "");
634 RNA_def_property_update(prop, 0, "rna_cloth_update");
635
636 prop = RNA_def_property(srna, "collider_friction", PROP_FLOAT, PROP_FACTOR);
637 RNA_def_property_float_sdna(prop, nullptr, "collider_friction");
638 RNA_def_property_range(prop, 0.0f, 1.0f);
639 RNA_def_property_ui_text(prop, "Collider Friction", "");
640 RNA_def_property_update(prop, 0, "rna_cloth_update");
641
642 prop = RNA_def_property(srna, "density_target", PROP_FLOAT, PROP_NONE);
643 RNA_def_property_float_sdna(prop, nullptr, "density_target");
644 RNA_def_property_range(prop, 0.0f, 10000.0f);
645 RNA_def_property_ui_text(prop, "Target Density", "Maximum density of hair");
646 RNA_def_property_update(prop, 0, "rna_cloth_update");
647
648 prop = RNA_def_property(srna, "density_strength", PROP_FLOAT, PROP_FACTOR);
649 RNA_def_property_float_sdna(prop, nullptr, "density_strength");
650 RNA_def_property_range(prop, 0.0f, 1.0f);
652 prop, "Target Density Strength", "Influence of target density on the simulation");
653 RNA_def_property_update(prop, 0, "rna_cloth_update");
654
655 /* mass */
656
657 prop = RNA_def_property(srna, "mass", PROP_FLOAT, PROP_MASS);
658 RNA_def_property_range(prop, 0.0f, FLT_MAX);
659 RNA_def_property_ui_text(prop, "Vertex Mass", "The mass of each vertex on the cloth material");
660 RNA_def_property_update(prop, 0, "rna_cloth_update");
661
662 prop = RNA_def_property(srna, "vertex_group_mass", PROP_STRING, PROP_NONE);
664 "rna_ClothSettings_mass_vgroup_get",
665 "rna_ClothSettings_mass_vgroup_length",
666 "rna_ClothSettings_mass_vgroup_set");
668 RNA_def_property_ui_text(prop, "Pin Vertex Group", "Vertex Group for pinning of vertices");
669 RNA_def_property_update(prop, 0, "rna_cloth_pinning_changed");
670
671 prop = RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_ACCELERATION);
672 RNA_def_property_array(prop, 3);
673 RNA_def_property_range(prop, -100.0, 100.0);
675 prop, "rna_ClothSettings_gravity_get", "rna_ClothSettings_gravity_set", nullptr);
676 RNA_def_property_ui_text(prop, "Gravity", "Gravity or external force vector");
677 RNA_def_property_update(prop, 0, "rna_cloth_update");
678
679 /* various */
680
681 prop = RNA_def_property(srna, "air_damping", PROP_FLOAT, PROP_NONE);
682 RNA_def_property_float_sdna(prop, nullptr, "Cvi");
683 RNA_def_property_range(prop, 0.0f, 10.0f);
685 prop, "Air Damping", "Air has normally some thickness which slows falling things down");
686 RNA_def_property_update(prop, 0, "rna_cloth_update");
687
688 prop = RNA_def_property(srna, "pin_stiffness", PROP_FLOAT, PROP_NONE);
689 RNA_def_property_float_sdna(prop, nullptr, "goalspring");
690 RNA_def_property_range(prop, 0.0f, 50.0);
691 RNA_def_property_ui_text(prop, "Pin Stiffness", "Pin (vertex target position) spring stiffness");
692 RNA_def_property_update(prop, 0, "rna_cloth_update");
693
694 prop = RNA_def_property(srna, "quality", PROP_INT, PROP_NONE);
695 RNA_def_property_int_sdna(prop, nullptr, "stepsPerFrame");
697 RNA_def_property_ui_range(prop, 1, 80, 1, -1);
699 prop,
700 "Quality",
701 "Quality of the simulation in steps per frame (higher is better quality but slower)");
702 RNA_def_property_update(prop, 0, "rna_cloth_update");
703
704 prop = RNA_def_property(srna, "time_scale", PROP_FLOAT, PROP_NONE);
705 RNA_def_property_float_sdna(prop, nullptr, "time_scale");
706 RNA_def_property_range(prop, 0.0f, FLT_MAX);
707 RNA_def_property_ui_range(prop, 0.0f, 10.0f, 10, 3);
708 RNA_def_property_ui_text(prop, "Speed", "Cloth speed is multiplied by this value");
709 RNA_def_property_update(prop, 0, "rna_cloth_update");
710
711 prop = RNA_def_property(srna, "vertex_group_shrink", PROP_STRING, PROP_NONE);
713 "rna_ClothSettings_shrink_vgroup_get",
714 "rna_ClothSettings_shrink_vgroup_length",
715 "rna_ClothSettings_shrink_vgroup_set");
717 RNA_def_property_ui_text(prop, "Shrink Vertex Group", "Vertex Group for shrinking cloth");
718 RNA_def_property_update(prop, 0, "rna_cloth_update");
719
720 prop = RNA_def_property(srna, "shrink_min", PROP_FLOAT, PROP_FACTOR);
721 RNA_def_property_float_sdna(prop, nullptr, "shrink_min");
722 RNA_def_property_range(prop, -FLT_MAX, 1.0f);
723 RNA_def_property_ui_range(prop, -1.0f, 1.0f, 0.05f, 3);
724 RNA_def_property_float_funcs(prop, nullptr, "rna_ClothSettings_shrink_min_set", nullptr);
725 RNA_def_property_ui_text(prop, "Shrink Factor", "Factor by which to shrink cloth");
726 RNA_def_property_update(prop, 0, "rna_cloth_update");
727
728 prop = RNA_def_property(srna, "shrink_max", PROP_FLOAT, PROP_FACTOR);
729 RNA_def_property_float_sdna(prop, nullptr, "shrink_max");
730 RNA_def_property_range(prop, -FLT_MAX, 1.0f);
731 RNA_def_property_ui_range(prop, -1.0f, 1.0f, 0.05f, 3);
732 RNA_def_property_float_funcs(prop, nullptr, "rna_ClothSettings_shrink_max_set", nullptr);
733 RNA_def_property_ui_text(prop, "Shrink Factor Max", "Max amount to shrink cloth by");
734 RNA_def_property_update(prop, 0, "rna_cloth_update");
735
736 prop = RNA_def_property(srna, "voxel_cell_size", PROP_FLOAT, PROP_UNSIGNED);
737 RNA_def_property_float_sdna(prop, nullptr, "voxel_cell_size");
738 RNA_def_property_range(prop, 0.0001f, 10000.0f);
740 prop, "Voxel Grid Cell Size", "Size of the voxel grid cells for interaction effects");
741 RNA_def_property_update(prop, 0, "rna_cloth_update");
742
743 /* springs */
744 prop = RNA_def_property(srna, "tension_damping", PROP_FLOAT, PROP_NONE);
745 RNA_def_property_float_sdna(prop, nullptr, "tension_damp");
746 RNA_def_property_range(prop, 0.0f, 50.0f);
748 prop, "Tension Spring Damping", "Amount of damping in stretching behavior");
749 RNA_def_property_update(prop, 0, "rna_cloth_update");
750
751 prop = RNA_def_property(srna, "compression_damping", PROP_FLOAT, PROP_NONE);
752 RNA_def_property_float_sdna(prop, nullptr, "compression_damp");
753 RNA_def_property_range(prop, 0.0f, 50.0f);
755 prop, "Compression Spring Damping", "Amount of damping in compression behavior");
756 RNA_def_property_update(prop, 0, "rna_cloth_update");
757
758 prop = RNA_def_property(srna, "shear_damping", PROP_FLOAT, PROP_NONE);
759 RNA_def_property_float_sdna(prop, nullptr, "shear_damp");
760 RNA_def_property_range(prop, 0.0f, 50.0f);
761 RNA_def_property_ui_text(prop, "Shear Spring Damping", "Amount of damping in shearing behavior");
762 RNA_def_property_update(prop, 0, "rna_cloth_update");
763
764 prop = RNA_def_property(srna, "tension_stiffness", PROP_FLOAT, PROP_NONE);
765 RNA_def_property_float_sdna(prop, nullptr, "tension");
766 RNA_def_property_range(prop, 0.0f, 10000.0f);
767 RNA_def_property_float_funcs(prop, nullptr, "rna_ClothSettings_tension_set", nullptr);
768 RNA_def_property_ui_text(prop, "Tension Stiffness", "How much the material resists stretching");
769 RNA_def_property_update(prop, 0, "rna_cloth_update");
770
771 prop = RNA_def_property(srna, "tension_stiffness_max", PROP_FLOAT, PROP_NONE);
772 RNA_def_property_float_sdna(prop, nullptr, "max_tension");
773 RNA_def_property_range(prop, 0.0f, 10000.0f);
774 RNA_def_property_float_funcs(prop, nullptr, "rna_ClothSettings_max_tension_set", nullptr);
775 RNA_def_property_ui_text(prop, "Tension Stiffness Maximum", "Maximum tension stiffness value");
776 RNA_def_property_update(prop, 0, "rna_cloth_update");
777
778 prop = RNA_def_property(srna, "compression_stiffness", PROP_FLOAT, PROP_NONE);
779 RNA_def_property_float_sdna(prop, nullptr, "compression");
780 RNA_def_property_range(prop, 0.0f, 10000.0f);
781 RNA_def_property_float_funcs(prop, nullptr, "rna_ClothSettings_compression_set", nullptr);
783 prop, "Compression Stiffness", "How much the material resists compression");
784 RNA_def_property_update(prop, 0, "rna_cloth_update");
785
786 prop = RNA_def_property(srna, "compression_stiffness_max", PROP_FLOAT, PROP_NONE);
787 RNA_def_property_float_sdna(prop, nullptr, "max_compression");
788 RNA_def_property_range(prop, 0.0f, 10000.0f);
789 RNA_def_property_float_funcs(prop, nullptr, "rna_ClothSettings_max_compression_set", nullptr);
791 prop, "Compression Stiffness Maximum", "Maximum compression stiffness value");
792 RNA_def_property_update(prop, 0, "rna_cloth_update");
793
794 prop = RNA_def_property(srna, "shear_stiffness", PROP_FLOAT, PROP_NONE);
795 RNA_def_property_float_sdna(prop, nullptr, "shear");
796 RNA_def_property_range(prop, 0.0f, 10000.0f);
797 RNA_def_property_float_funcs(prop, nullptr, "rna_ClothSettings_shear_set", nullptr);
798 RNA_def_property_ui_text(prop, "Shear Stiffness", "How much the material resists shearing");
799 RNA_def_property_update(prop, 0, "rna_cloth_update");
800
801 prop = RNA_def_property(srna, "shear_stiffness_max", PROP_FLOAT, PROP_NONE);
802 RNA_def_property_float_sdna(prop, nullptr, "max_shear");
803 RNA_def_property_range(prop, 0.0f, 10000.0f);
804 RNA_def_property_float_funcs(prop, nullptr, "rna_ClothSettings_max_shear_set", nullptr);
805 RNA_def_property_ui_text(prop, "Shear Stiffness Maximum", "Maximum shear scaling value");
806 RNA_def_property_update(prop, 0, "rna_cloth_update");
807
808 prop = RNA_def_property(srna, "sewing_force_max", PROP_FLOAT, PROP_NONE);
809 RNA_def_property_float_sdna(prop, nullptr, "max_sewing");
810 RNA_def_property_range(prop, 0.0f, 10000.0f);
811 RNA_def_property_float_funcs(prop, nullptr, "rna_ClothSettings_max_sewing_set", nullptr);
812 RNA_def_property_ui_text(prop, "Sewing Force Max", "Maximum sewing force");
813 RNA_def_property_update(prop, 0, "rna_cloth_update");
814
815 prop = RNA_def_property(srna, "vertex_group_structural_stiffness", PROP_STRING, PROP_NONE);
817 "rna_ClothSettings_struct_vgroup_get",
818 "rna_ClothSettings_struct_vgroup_length",
819 "rna_ClothSettings_struct_vgroup_set");
822 "Structural Stiffness Vertex Group",
823 "Vertex group for fine control over structural stiffness");
824 RNA_def_property_update(prop, 0, "rna_cloth_update");
825
826 prop = RNA_def_property(srna, "vertex_group_shear_stiffness", PROP_STRING, PROP_NONE);
828 "rna_ClothSettings_shear_vgroup_get",
829 "rna_ClothSettings_shear_vgroup_length",
830 "rna_ClothSettings_shear_vgroup_set");
833 prop, "Shear Stiffness Vertex Group", "Vertex group for fine control over shear stiffness");
834 RNA_def_property_update(prop, 0, "rna_cloth_update");
835
836 prop = RNA_def_property(srna, "bending_stiffness", PROP_FLOAT, PROP_NONE);
837 RNA_def_property_float_sdna(prop, nullptr, "bending");
838 RNA_def_property_range(prop, 0.0f, 10000.0f);
839 RNA_def_property_float_funcs(prop, nullptr, "rna_ClothSettings_bending_set", nullptr);
840 RNA_def_property_ui_text(prop, "Bending Stiffness", "How much the material resists bending");
841 RNA_def_property_update(prop, 0, "rna_cloth_update");
842
843 prop = RNA_def_property(srna, "bending_stiffness_max", PROP_FLOAT, PROP_NONE);
844 RNA_def_property_float_sdna(prop, nullptr, "max_bend");
845 RNA_def_property_range(prop, 0.0f, 10000.0f);
846 RNA_def_property_float_funcs(prop, nullptr, "rna_ClothSettings_max_bend_set", nullptr);
847 RNA_def_property_ui_text(prop, "Bending Stiffness Maximum", "Maximum bending stiffness value");
848 RNA_def_property_update(prop, 0, "rna_cloth_update");
849
850 prop = RNA_def_property(srna, "bending_damping", PROP_FLOAT, PROP_NONE);
851 RNA_def_property_float_sdna(prop, nullptr, "bending_damping");
852 RNA_def_property_range(prop, 0.0f, 1000.0f);
854 prop, "Bending Spring Damping", "Amount of damping in bending behavior");
855 RNA_def_property_update(prop, 0, "rna_cloth_update");
856
857 prop = RNA_def_property(srna, "use_sewing_springs", PROP_BOOLEAN, PROP_NONE);
859 RNA_def_property_ui_text(prop, "Sew Cloth", "Pulls loose edges together");
861 RNA_def_property_update(prop, 0, "rna_cloth_update");
862
863 prop = RNA_def_property(srna, "vertex_group_bending", PROP_STRING, PROP_NONE);
865 "rna_ClothSettings_bend_vgroup_get",
866 "rna_ClothSettings_bend_vgroup_length",
867 "rna_ClothSettings_bend_vgroup_set");
870 "Bending Stiffness Vertex Group",
871 "Vertex group for fine control over bending stiffness");
872 RNA_def_property_update(prop, 0, "rna_cloth_update");
873
874 prop = RNA_def_property(srna, "effector_weights", PROP_POINTER, PROP_NONE);
875 RNA_def_property_struct_type(prop, "EffectorWeights");
877 RNA_def_property_ui_text(prop, "Effector Weights", "");
878
879 prop = RNA_def_property(srna, "rest_shape_key", PROP_POINTER, PROP_NONE);
881 RNA_def_property_struct_type(prop, "ShapeKey");
883 "rna_ClothSettings_rest_shape_key_get",
884 "rna_ClothSettings_rest_shape_key_set",
885 nullptr,
886 nullptr);
889 prop, "Rest Shape Key", "Shape key to use the rest spring lengths from");
890 RNA_def_property_update(prop, 0, "rna_cloth_update");
891
892 prop = RNA_def_property(srna, "use_dynamic_mesh", PROP_BOOLEAN, PROP_NONE);
895 prop, "Dynamic Base Mesh", "Make simulation respect deformations in the base mesh");
896 RNA_def_property_update(prop, 0, "rna_cloth_update");
898
899 prop = RNA_def_property(srna, "bending_model", PROP_ENUM, PROP_NONE);
900 RNA_def_property_enum_sdna(prop, nullptr, "bending_model");
901 RNA_def_property_enum_items(prop, prop_bending_model_items);
902 RNA_def_property_ui_text(prop, "Bending Model", "Physical model for simulating bending forces");
903 RNA_def_property_update(prop, 0, "rna_cloth_update");
905
906 prop = RNA_def_property(srna, "use_internal_springs", PROP_BOOLEAN, PROP_NONE);
909 "Create Internal Springs",
910 "Simulate an internal volume structure by creating springs connecting "
911 "the opposite sides of the mesh");
912 RNA_def_property_update(prop, 0, "rna_cloth_update");
914
915 prop = RNA_def_property(srna, "internal_spring_normal_check", PROP_BOOLEAN, PROP_NONE);
917 prop, nullptr, "flags", CLOTH_SIMSETTINGS_FLAG_INTERNAL_SPRINGS_NORMAL);
919 "Check Internal Spring Normals",
920 "Require the points the internal springs connect to have opposite "
921 "normal directions");
922 RNA_def_property_editable_func(prop, "rna_ClothSettings_internal_editable");
923 RNA_def_property_update(prop, 0, "rna_cloth_update");
925
926 prop = RNA_def_property(srna, "internal_spring_max_length", PROP_FLOAT, PROP_NONE);
927 RNA_def_property_float_sdna(prop, nullptr, "internal_spring_max_length");
928 RNA_def_property_range(prop, 0.0f, 1000.0f);
930 prop,
931 "Internal Spring Max Length",
932 "The maximum length an internal spring can have during creation. If the distance between "
933 "internal points is greater than this, no internal spring will be created between these "
934 "points. "
935 "A length of zero means that there is no length limit.");
936 RNA_def_property_editable_func(prop, "rna_ClothSettings_internal_editable");
937 RNA_def_property_update(prop, 0, "rna_cloth_update");
939
940 prop = RNA_def_property(srna, "internal_spring_max_diversion", PROP_FLOAT, PROP_ANGLE);
941 RNA_def_property_float_sdna(prop, nullptr, "internal_spring_max_diversion");
942 RNA_def_property_range(prop, 0.0f, M_PI_4);
944 "Internal Spring Max Diversion",
945 "How much the rays used to connect the internal points can diverge "
946 "from the vertex normal");
947 RNA_def_property_editable_func(prop, "rna_ClothSettings_internal_editable");
948 RNA_def_property_update(prop, 0, "rna_cloth_update");
950
951 prop = RNA_def_property(srna, "internal_tension_stiffness", PROP_FLOAT, PROP_NONE);
952 RNA_def_property_float_sdna(prop, nullptr, "internal_tension");
953 RNA_def_property_range(prop, 0.0f, 10000.0f);
954 RNA_def_property_float_funcs(prop, nullptr, "rna_ClothSettings_internal_tension_set", nullptr);
955 RNA_def_property_ui_text(prop, "Tension Stiffness", "How much the material resists stretching");
956 RNA_def_property_editable_func(prop, "rna_ClothSettings_internal_editable");
957 RNA_def_property_update(prop, 0, "rna_cloth_update");
958
959 prop = RNA_def_property(srna, "internal_tension_stiffness_max", PROP_FLOAT, PROP_NONE);
960 RNA_def_property_float_sdna(prop, nullptr, "max_internal_tension");
961 RNA_def_property_range(prop, 0.0f, 10000.0f);
963 prop, nullptr, "rna_ClothSettings_max_internal_tension_set", nullptr);
964 RNA_def_property_ui_text(prop, "Tension Stiffness Maximum", "Maximum tension stiffness value");
965 RNA_def_property_editable_func(prop, "rna_ClothSettings_internal_editable");
966 RNA_def_property_update(prop, 0, "rna_cloth_update");
967
968 prop = RNA_def_property(srna, "internal_compression_stiffness", PROP_FLOAT, PROP_NONE);
969 RNA_def_property_float_sdna(prop, nullptr, "internal_compression");
970 RNA_def_property_range(prop, 0.0f, 10000.0f);
972 prop, nullptr, "rna_ClothSettings_internal_compression_set", nullptr);
974 prop, "Compression Stiffness", "How much the material resists compression");
975 RNA_def_property_editable_func(prop, "rna_ClothSettings_internal_editable");
976 RNA_def_property_update(prop, 0, "rna_cloth_update");
977
978 prop = RNA_def_property(srna, "internal_compression_stiffness_max", PROP_FLOAT, PROP_NONE);
979 RNA_def_property_float_sdna(prop, nullptr, "max_internal_compression");
980 RNA_def_property_range(prop, 0.0f, 10000.0f);
982 prop, nullptr, "rna_ClothSettings_max_internal_compression_set", nullptr);
984 prop, "Compression Stiffness Maximum", "Maximum compression stiffness value");
985 RNA_def_property_editable_func(prop, "rna_ClothSettings_internal_editable");
986 RNA_def_property_update(prop, 0, "rna_cloth_update");
987
988 prop = RNA_def_property(srna, "vertex_group_intern", PROP_STRING, PROP_NONE);
990 "rna_ClothSettings_internal_vgroup_get",
991 "rna_ClothSettings_internal_vgroup_length",
992 "rna_ClothSettings_internal_vgroup_set");
995 "Internal Springs Vertex Group",
996 "Vertex group for fine control over the internal spring stiffness");
997 RNA_def_property_editable_func(prop, "rna_ClothSettings_internal_editable");
998 RNA_def_property_update(prop, 0, "rna_cloth_update");
999
1000 /* Pressure */
1001
1002 prop = RNA_def_property(srna, "use_pressure", PROP_BOOLEAN, PROP_NONE);
1004 RNA_def_property_ui_text(prop, "Use Pressure", "Simulate pressure inside a closed cloth mesh");
1006 RNA_def_property_update(prop, 0, "rna_cloth_update");
1007
1008 prop = RNA_def_property(srna, "use_pressure_volume", PROP_BOOLEAN, PROP_NONE);
1011 "Use Custom Volume",
1012 "Use the Target Volume parameter as the initial volume, instead "
1013 "of calculating it from the mesh itself");
1015 RNA_def_property_update(prop, 0, "rna_cloth_update");
1016
1017 prop = RNA_def_property(srna, "uniform_pressure_force", PROP_FLOAT, PROP_NONE);
1018 RNA_def_property_float_sdna(prop, nullptr, "uniform_pressure_force");
1019 RNA_def_property_range(prop, -10000.0f, 10000.0f);
1022 "Pressure",
1023 "The uniform pressure that is constantly applied to the mesh, in units "
1024 "of Pressure Scale. Can be negative.");
1025 RNA_def_property_update(prop, 0, "rna_cloth_update");
1026
1027 prop = RNA_def_property(srna, "target_volume", PROP_FLOAT, PROP_NONE);
1028 RNA_def_property_float_sdna(prop, nullptr, "target_volume");
1029 RNA_def_property_range(prop, 0.0f, 10000.0f);
1032 "Target Volume",
1033 "The mesh volume where the inner/outer pressure will be the same. If "
1034 "set to zero the change in volume will not affect pressure.");
1035 RNA_def_property_update(prop, 0, "rna_cloth_update");
1036
1037 prop = RNA_def_property(srna, "pressure_factor", PROP_FLOAT, PROP_NONE);
1038 RNA_def_property_float_sdna(prop, nullptr, "pressure_factor");
1039 RNA_def_property_range(prop, 0.0f, 10000.0f);
1041 "Pressure Scale",
1042 "Ambient pressure (kPa) that balances out between the inside and "
1043 "outside of the object when it has the target volume");
1044 RNA_def_property_update(prop, 0, "rna_cloth_update");
1045
1046 prop = RNA_def_property(srna, "fluid_density", PROP_FLOAT, PROP_NONE);
1047 RNA_def_property_float_sdna(prop, nullptr, "fluid_density");
1048 RNA_def_property_ui_range(prop, -2.0f, 2.0f, 0.05f, 4);
1050 prop,
1051 "Fluid Density",
1052 "Density (kg/l) of the fluid contained inside the object, used to create "
1053 "a hydrostatic pressure gradient simulating the weight of the internal fluid, "
1054 "or buoyancy from the surrounding fluid if negative");
1055 RNA_def_property_update(prop, 0, "rna_cloth_update");
1056
1057 prop = RNA_def_property(srna, "vertex_group_pressure", PROP_STRING, PROP_NONE);
1059 "rna_ClothSettings_pressure_vgroup_get",
1060 "rna_ClothSettings_pressure_vgroup_length",
1061 "rna_ClothSettings_pressure_vgroup_set");
1064 prop,
1065 "Pressure Vertex Group",
1066 "Vertex Group for where to apply pressure. Zero weight means no "
1067 "pressure while a weight of one means full pressure. Faces with a vertex "
1068 "that has zero weight will be excluded from the volume calculation.");
1069 RNA_def_property_update(prop, 0, "rna_cloth_update");
1070
1071 /* unused */
1072
1073 /* unused still */
1074# if 0
1075 prop = RNA_def_property(srna, "effector_force_scale", PROP_FLOAT, PROP_NONE);
1076 RNA_def_property_float_sdna(prop, nullptr, "eff_force_scale");
1077 RNA_def_property_range(prop, 0.0f, 100.0f);
1078 RNA_def_property_ui_text(prop, "Effector Force Scale", "");
1079# endif
1080 /* unused still */
1081# if 0
1082 prop = RNA_def_property(srna, "effector_wind_scale", PROP_FLOAT, PROP_NONE);
1083 RNA_def_property_float_sdna(prop, nullptr, "eff_wind_scale");
1084 RNA_def_property_range(prop, 0.0f, 100.0f);
1085 RNA_def_property_ui_text(prop, "Effector Wind Scale", "");
1086# endif
1087 /* unused still */
1088# if 0
1089 prop = RNA_def_property(srna, "tearing", PROP_BOOLEAN, PROP_NONE);
1091 RNA_def_property_ui_text(prop, "Tearing", "");
1092# endif
1093 /* unused still */
1094# if 0
1095 prop = RNA_def_property(srna, "max_spring_extensions", PROP_INT, PROP_NONE);
1096 RNA_def_property_int_sdna(prop, nullptr, "maxspringlen");
1097 RNA_def_property_range(prop, 1.0, 1000.0);
1099 prop, "Maximum Spring Extension", "Maximum extension before spring gets cut");
1100# endif
1101
1103}
1104
1106{
1107 StructRNA *srna;
1108 PropertyRNA *prop;
1109
1110 srna = RNA_def_struct(brna, "ClothCollisionSettings", nullptr);
1112 srna,
1113 "Cloth Collision Settings",
1114 "Cloth simulation settings for self collision and collision with other objects");
1115 RNA_def_struct_sdna(srna, "ClothCollSettings");
1116 RNA_def_struct_path_func(srna, "rna_ClothCollisionSettings_path");
1117
1119
1120 /* general collision */
1121
1122 prop = RNA_def_property(srna, "use_collision", PROP_BOOLEAN, PROP_NONE);
1124 RNA_def_property_ui_text(prop, "Enable Collision", "Enable collisions with other objects");
1125 RNA_def_property_update(prop, 0, "rna_cloth_dependency_update");
1126
1127 prop = RNA_def_property(srna, "distance_min", PROP_FLOAT, PROP_DISTANCE);
1128 RNA_def_property_float_sdna(prop, nullptr, "epsilon");
1129 RNA_def_property_range(prop, 0.001f, 1.0f);
1131 prop,
1132 "Minimum Distance",
1133 "Minimum distance between collision objects before collision response takes effect");
1134 RNA_def_property_update(prop, 0, "rna_cloth_update");
1135
1136 prop = RNA_def_property(srna, "friction", PROP_FLOAT, PROP_NONE);
1137 RNA_def_property_range(prop, 0.0f, 80.0f);
1139 prop, "Friction", "Friction force if a collision happened (higher = less movement)");
1140 RNA_def_property_update(prop, 0, "rna_cloth_update");
1141
1142 prop = RNA_def_property(srna, "damping", PROP_FLOAT, PROP_FACTOR);
1143 RNA_def_property_float_sdna(prop, nullptr, "damping");
1144 RNA_def_property_range(prop, 0.0f, 1.0f);
1146 RNA_def_property_ui_text(prop, "Restitution", "Amount of velocity lost on collision");
1147 RNA_def_property_update(prop, 0, "rna_cloth_update");
1148
1149 prop = RNA_def_property(srna, "collision_quality", PROP_INT, PROP_NONE);
1150 RNA_def_property_int_sdna(prop, nullptr, "loop_count");
1152 RNA_def_property_ui_range(prop, 1, 20, 1, -1);
1154 prop,
1155 "Collision Quality",
1156 "How many collision iterations should be done (higher is better quality but slower)");
1157 RNA_def_property_update(prop, 0, "rna_cloth_update");
1158
1159 prop = RNA_def_property(srna, "impulse_clamp", PROP_FLOAT, PROP_NONE);
1160 RNA_def_property_float_sdna(prop, nullptr, "clamp");
1161 RNA_def_property_range(prop, 0.0f, 100.0f);
1163 prop,
1164 "Impulse Clamping",
1165 "Clamp collision impulses to avoid instability (0.0 to disable clamping)");
1166 RNA_def_property_update(prop, 0, "rna_cloth_update");
1167
1168 /* self collision */
1169
1170 prop = RNA_def_property(srna, "use_self_collision", PROP_BOOLEAN, PROP_NONE);
1172 RNA_def_property_ui_text(prop, "Enable Self Collision", "Enable self collisions");
1173 RNA_def_property_update(prop, 0, "rna_cloth_update");
1174
1175 prop = RNA_def_property(srna, "self_distance_min", PROP_FLOAT, PROP_DISTANCE);
1176 RNA_def_property_float_sdna(prop, nullptr, "selfepsilon");
1177 RNA_def_property_range(prop, 0.001f, 0.1f);
1179 prop,
1180 "Self Minimum Distance",
1181 "Minimum distance between cloth faces before collision response takes effect");
1182 RNA_def_property_update(prop, 0, "rna_cloth_update");
1183
1184 prop = RNA_def_property(srna, "self_friction", PROP_FLOAT, PROP_NONE);
1185 RNA_def_property_range(prop, 0.0f, 80.0f);
1186 RNA_def_property_ui_text(prop, "Self Friction", "Friction with self contact");
1187 RNA_def_property_update(prop, 0, "rna_cloth_update");
1188
1189 prop = RNA_def_property(srna, "collection", PROP_POINTER, PROP_NONE);
1190 RNA_def_property_pointer_sdna(prop, nullptr, "group");
1192 RNA_def_property_ui_text(prop, "Collision Collection", "Limit colliders to this Collection");
1193 RNA_def_property_update(prop, 0, "rna_cloth_dependency_update");
1194
1195 prop = RNA_def_property(srna, "vertex_group_self_collisions", PROP_STRING, PROP_NONE);
1197 "rna_CollSettings_selfcol_vgroup_get",
1198 "rna_CollSettings_selfcol_vgroup_length",
1199 "rna_CollSettings_selfcol_vgroup_set");
1202 prop,
1203 "Selfcollision Vertex Group",
1204 "Triangles with all vertices in this group are not used during self collisions");
1205 RNA_def_property_update(prop, 0, "rna_cloth_update");
1206
1207 prop = RNA_def_property(srna, "vertex_group_object_collisions", PROP_STRING, PROP_NONE);
1209 "rna_CollSettings_objcol_vgroup_get",
1210 "rna_CollSettings_objcol_vgroup_length",
1211 "rna_CollSettings_objcol_vgroup_set");
1214 prop,
1215 "Collision Vertex Group",
1216 "Triangles with all vertices in this group are not used during object collisions");
1217 RNA_def_property_update(prop, 0, "rna_cloth_update");
1218
1219 prop = RNA_def_property(srna, "self_impulse_clamp", PROP_FLOAT, PROP_NONE);
1220 RNA_def_property_float_sdna(prop, nullptr, "self_clamp");
1221 RNA_def_property_range(prop, 0.0f, 100.0f);
1223 prop,
1224 "Impulse Clamping",
1225 "Clamp collision impulses to avoid instability (0.0 to disable clamping)");
1226 RNA_def_property_update(prop, 0, "rna_cloth_update");
1227
1229}
1230
1237
1238} // namespace blender
1239
1240#endif
#define M_PI_4
#define ND_MODIFIER
Definition WM_types.hh:503
#define NC_OBJECT
Definition WM_types.hh:392
#define SHRT_MAX
#define FLT_MAX
#define INT_MAX
BMesh Iterators.
void WM_main_add_notifier(uint type, void *reference)
int rna_object_shapekey_index_set(ID *id, PointerRNA value, int current)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable)
@ SIM_SOLVER_NUMERICAL_ISSUE
@ SIM_SOLVER_NO_CONVERGENCE
@ SIM_SOLVER_INVALID_INPUT
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
@ CLOTH_BENDING_LINEAR
@ CLOTH_BENDING_ANGULAR
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *type_fn, const char *poll)
void cloth_free_modifier(ClothModifierData *clmd)
Definition cloth.cc:445
void RNA_define_lib_overridable(const bool make_overridable)
void RNA_def_cloth(BlenderRNA *brna)
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
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
int rna_object_vgroup_name_index_length(PointerRNA *ptr, int index)
void RNA_def_property_float_default(PropertyRNA *prop, float value)
static void rna_def_cloth_solver_result(BlenderRNA *brna)
Definition rna_cloth.cc:500
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier_c_str, int type, int subtype)
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
PointerRNA rna_object_shapekey_index_get(ID *id, int value)
@ PROP_BOOLEAN
Definition RNA_types.hh:210
@ PROP_POINTER
Definition RNA_types.hh:215
@ PROP_STRING
Definition RNA_types.hh:213
void DEG_id_tag_update(ID *id, unsigned int flags)
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)
static void rna_def_cloth_collision_settings(BlenderRNA *brna)
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
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)
@ CLOTH_SIMSETTINGS_FLAG_INTERNAL_SPRINGS_NORMAL
@ CLOTH_SIMSETTINGS_FLAG_DYNAMIC_BASEMESH
@ CLOTH_SIMSETTINGS_FLAG_INTERNAL_SPRINGS
@ CLOTH_SIMSETTINGS_FLAG_PRESSURE_VOL
@ CLOTH_SIMSETTINGS_FLAG_TEARING
@ CLOTH_SIMSETTINGS_FLAG_SEW
@ CLOTH_SIMSETTINGS_FLAG_PRESSURE
void rna_object_vgroup_name_index_set(PointerRNA *ptr, const char *value, short *index)
void RNA_def_property_override_clear_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
@ PROP_EDITABLE
Definition RNA_types.hh:376
@ PROP_ENUM_FLAG
Definition RNA_types.hh:474
@ PROP_ANIMATABLE
Definition RNA_types.hh:389
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)
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
void RNA_define_verify_sdna(bool verify)
@ PROP_ACCELERATION
Definition RNA_types.hh:321
@ PROP_FACTOR
Definition RNA_types.hh:308
@ PROP_DISTANCE
Definition RNA_types.hh:313
@ PROP_UNSIGNED
Definition RNA_types.hh:306
@ CLOTH_COLLSETTINGS_FLAG_ENABLED
@ CLOTH_COLLSETTINGS_FLAG_SELF
static void rna_def_cloth_sim_settings(BlenderRNA *brna)
Definition rna_cloth.cc:570
void RNA_def_property_array(PropertyRNA *prop, int length)
void rna_object_vgroup_name_index_get(PointerRNA *ptr, char *value, int index)
ustring name
Definition graph/node.h:178
#define N_(msgid)