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