Blender  V2.59
rna_cloth.c
Go to the documentation of this file.
00001 /*
00002  * $Id: rna_cloth.c 37031 2011-05-31 02:14:25Z campbellbarton $
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * Contributor(s): Blender Foundation (2008)
00021  *
00022  * ***** END GPL LICENSE BLOCK *****
00023  */
00024 
00030 #include <stdlib.h>
00031 #include <limits.h>
00032 
00033 #include "RNA_define.h"
00034 
00035 #include "rna_internal.h"
00036 
00037 #include "BKE_cloth.h"
00038 #include "BKE_modifier.h"
00039 
00040 #include "DNA_cloth_types.h"
00041 #include "DNA_object_types.h"
00042 #include "DNA_scene_types.h"
00043 
00044 #include "WM_api.h"
00045 #include "WM_types.h"
00046 
00047 #ifdef RNA_RUNTIME
00048 
00049 #include "BKE_context.h"
00050 #include "BKE_depsgraph.h"
00051 
00052 static void rna_cloth_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
00053 {
00054         Object *ob= (Object*)ptr->id.data;
00055 
00056         DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
00057         WM_main_add_notifier(NC_OBJECT|ND_MODIFIER, ob);
00058 }
00059 
00060 static void rna_cloth_pinning_changed(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
00061 {
00062         Object *ob= (Object*)ptr->id.data;
00063 //      ClothSimSettings *settings = (ClothSimSettings*)ptr->data;
00064         ClothModifierData *clmd = (ClothModifierData*)modifiers_findByType(ob, eModifierType_Cloth);
00065 
00066         cloth_free_modifier(clmd);
00067 
00068         DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
00069         WM_main_add_notifier(NC_OBJECT|ND_MODIFIER, ob);
00070 }
00071 
00072 static void rna_cloth_reset(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
00073 {
00074         Object *ob= (Object*)ptr->id.data;
00075         ClothSimSettings *settings = (ClothSimSettings*)ptr->data;
00076 
00077         settings->reset = 1;
00078 
00079         DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
00080         WM_main_add_notifier(NC_OBJECT|ND_MODIFIER, ob);
00081 }
00082 
00083 
00084 static void rna_ClothSettings_max_bend_set(struct PointerRNA *ptr, float value)
00085 {
00086         ClothSimSettings *settings = (ClothSimSettings*)ptr->data;
00087         
00088         /* check for clipping */
00089         if(value < settings->bending)
00090                 value = settings->bending;
00091         
00092         settings->max_bend = value;
00093 }
00094 
00095 static void rna_ClothSettings_max_struct_set(struct PointerRNA *ptr, float value)
00096 {
00097         ClothSimSettings *settings = (ClothSimSettings*)ptr->data;
00098         
00099         /* check for clipping */
00100         if(value < settings->structural)
00101                 value = settings->structural;
00102         
00103         settings->max_struct = value;
00104 }
00105 
00106 static void rna_ClothSettings_mass_vgroup_get(PointerRNA *ptr, char *value)
00107 {
00108         ClothSimSettings *sim= (ClothSimSettings*)ptr->data;
00109         rna_object_vgroup_name_index_get(ptr, value, sim->vgroup_mass);
00110 }
00111 
00112 static int rna_ClothSettings_mass_vgroup_length(PointerRNA *ptr)
00113 {
00114         ClothSimSettings *sim= (ClothSimSettings*)ptr->data;
00115         return rna_object_vgroup_name_index_length(ptr, sim->vgroup_mass);
00116 }
00117 
00118 static void rna_ClothSettings_mass_vgroup_set(PointerRNA *ptr, const char *value)
00119 {
00120         ClothSimSettings *sim= (ClothSimSettings*)ptr->data;
00121         rna_object_vgroup_name_index_set(ptr, value, &sim->vgroup_mass);
00122 }
00123 
00124 static void rna_ClothSettings_struct_vgroup_get(PointerRNA *ptr, char *value)
00125 {
00126         ClothSimSettings *sim= (ClothSimSettings*)ptr->data;
00127         rna_object_vgroup_name_index_get(ptr, value, sim->vgroup_struct);
00128 }
00129 
00130 static int rna_ClothSettings_struct_vgroup_length(PointerRNA *ptr)
00131 {
00132         ClothSimSettings *sim= (ClothSimSettings*)ptr->data;
00133         return rna_object_vgroup_name_index_length(ptr, sim->vgroup_struct);
00134 }
00135 
00136 static void rna_ClothSettings_struct_vgroup_set(PointerRNA *ptr, const char *value)
00137 {
00138         ClothSimSettings *sim= (ClothSimSettings*)ptr->data;
00139         rna_object_vgroup_name_index_set(ptr, value, &sim->vgroup_struct);
00140 }
00141 
00142 static void rna_ClothSettings_bend_vgroup_get(PointerRNA *ptr, char *value)
00143 {
00144         ClothSimSettings *sim= (ClothSimSettings*)ptr->data;
00145         rna_object_vgroup_name_index_get(ptr, value, sim->vgroup_bend);
00146 }
00147 
00148 static int rna_ClothSettings_bend_vgroup_length(PointerRNA *ptr)
00149 {
00150         ClothSimSettings *sim= (ClothSimSettings*)ptr->data;
00151         return rna_object_vgroup_name_index_length(ptr, sim->vgroup_bend);
00152 }
00153 
00154 static void rna_ClothSettings_bend_vgroup_set(PointerRNA *ptr, const char *value)
00155 {
00156         ClothSimSettings *sim= (ClothSimSettings*)ptr->data;
00157         rna_object_vgroup_name_index_set(ptr, value, &sim->vgroup_bend);
00158 }
00159 
00160 static PointerRNA rna_ClothSettings_rest_shape_key_get(PointerRNA *ptr)
00161 {
00162         Object *ob= (Object*)ptr->id.data;
00163         ClothSimSettings *sim= (ClothSimSettings*)ptr->data;
00164 
00165         return rna_object_shapekey_index_get(ob->data, sim->shapekey_rest);
00166 }
00167 
00168 static void rna_ClothSettings_rest_shape_key_set(PointerRNA *ptr, PointerRNA value)
00169 {
00170         Object *ob= (Object*)ptr->id.data;
00171         ClothSimSettings *sim= (ClothSimSettings*)ptr->data;
00172 
00173         sim->shapekey_rest= rna_object_shapekey_index_set(ob->data, value, sim->shapekey_rest);
00174 }
00175 
00176 static void rna_ClothSettings_gravity_get(PointerRNA *ptr, float *values)
00177 {
00178         ClothSimSettings *sim= (ClothSimSettings*)ptr->data;
00179 
00180         values[0]= sim->gravity[0];
00181         values[1]= sim->gravity[1];
00182         values[2]= sim->gravity[2];
00183 }
00184 
00185 static void rna_ClothSettings_gravity_set(PointerRNA *ptr, const float *values)
00186 {
00187         ClothSimSettings *sim= (ClothSimSettings*)ptr->data;
00188 
00189         sim->gravity[0]= values[0];
00190         sim->gravity[1]= values[1];
00191         sim->gravity[2]= values[2];
00192 }
00193 
00194 static char *rna_ClothSettings_path(PointerRNA *ptr)
00195 {
00196         Object *ob= (Object*)ptr->id.data;
00197         ModifierData *md= modifiers_findByType(ob, eModifierType_Cloth);
00198 
00199         return md ? BLI_sprintfN("modifiers[\"%s\"].settings", md->name) : NULL;
00200 }
00201 
00202 static char *rna_ClothCollisionSettings_path(PointerRNA *ptr)
00203 {
00204         Object *ob= (Object*)ptr->id.data;
00205         ModifierData *md= modifiers_findByType(ob, eModifierType_Cloth);
00206 
00207         return md ? BLI_sprintfN("modifiers[\"%s\"].collision_settings", md->name) : NULL;
00208 }
00209 
00210 #else
00211 
00212 static void rna_def_cloth_sim_settings(BlenderRNA *brna)
00213 {
00214         StructRNA *srna;
00215         PropertyRNA *prop;
00216         
00217         srna = RNA_def_struct(brna, "ClothSettings", NULL);
00218         RNA_def_struct_ui_text(srna, "Cloth Settings", "Cloth simulation settings for an object");
00219         RNA_def_struct_sdna(srna, "ClothSimSettings");
00220         RNA_def_struct_path_func(srna, "rna_ClothSettings_path");
00221         
00222         /* goal */
00223         
00224         prop= RNA_def_property(srna, "goal_min", PROP_FLOAT, PROP_NONE);
00225         RNA_def_property_float_sdna(prop, NULL, "mingoal");
00226         RNA_def_property_range(prop, 0.0f, 1.0f);
00227         RNA_def_property_ui_text(prop, "Goal Minimum", "Goal minimum, vertex group weights are scaled to match this range");
00228         RNA_def_property_update(prop, 0, "rna_cloth_update");
00229 
00230         prop= RNA_def_property(srna, "goal_max", PROP_FLOAT, PROP_NONE);
00231         RNA_def_property_float_sdna(prop, NULL, "maxgoal");
00232         RNA_def_property_range(prop, 0.0f, 1.0f);
00233         RNA_def_property_ui_text(prop, "Goal Maximum", "Goal maximum, vertex group weights are scaled to match this range");
00234         RNA_def_property_update(prop, 0, "rna_cloth_update");
00235 
00236         prop= RNA_def_property(srna, "goal_default", PROP_FLOAT, PROP_NONE);
00237         RNA_def_property_float_sdna(prop, NULL, "defgoal");
00238         RNA_def_property_range(prop, 0.0f, 1.0f);
00239         RNA_def_property_ui_text(prop, "Goal Default", "Default Goal (vertex target position) value, when no Vertex Group used");
00240         RNA_def_property_update(prop, 0, "rna_cloth_update");
00241         
00242         prop= RNA_def_property(srna, "goal_spring", PROP_FLOAT, PROP_NONE);
00243         RNA_def_property_float_sdna(prop, NULL, "goalspring");
00244         RNA_def_property_range(prop, 0.0f, 0.999f);
00245         RNA_def_property_ui_text(prop, "Goal Stiffness", "Goal (vertex target position) spring stiffness");
00246         RNA_def_property_update(prop, 0, "rna_cloth_update");
00247         
00248         prop= RNA_def_property(srna, "goal_friction", PROP_FLOAT, PROP_NONE);
00249         RNA_def_property_float_sdna(prop, NULL, "goalfrict");
00250         RNA_def_property_range(prop, 0.0f, 50.0f);
00251         RNA_def_property_ui_text(prop, "Goal Damping", "Goal (vertex target position) friction");
00252         RNA_def_property_update(prop, 0, "rna_cloth_update");
00253 
00254         prop= RNA_def_property(srna, "internal_friction", PROP_FLOAT, PROP_NONE);
00255         RNA_def_property_float_sdna(prop, NULL, "velocity_smooth");
00256         RNA_def_property_range(prop, 0.0f, 1.0f);
00257         RNA_def_property_ui_text(prop, "Internal Friction", "");
00258         RNA_def_property_update(prop, 0, "rna_cloth_update");
00259 
00260         prop= RNA_def_property(srna, "collider_friction", PROP_FLOAT, PROP_NONE);
00261         RNA_def_property_float_sdna(prop, NULL, "collider_friction");
00262         RNA_def_property_range(prop, 0.0f, 1.0f);
00263         RNA_def_property_ui_text(prop, "Collider Friction", "");
00264         RNA_def_property_update(prop, 0, "rna_cloth_update");
00265 
00266         /* mass */
00267 
00268         prop= RNA_def_property(srna, "mass", PROP_FLOAT, PROP_NONE);
00269         RNA_def_property_range(prop, 0.0f, 10.0f);
00270         RNA_def_property_ui_text(prop, "Mass", "Mass of cloth material");
00271         RNA_def_property_update(prop, 0, "rna_cloth_update");
00272 
00273         prop= RNA_def_property(srna, "vertex_group_mass", PROP_STRING, PROP_NONE);
00274         RNA_def_property_string_funcs(prop, "rna_ClothSettings_mass_vgroup_get", "rna_ClothSettings_mass_vgroup_length", "rna_ClothSettings_mass_vgroup_set");
00275         RNA_def_property_ui_text(prop, "Mass Vertex Group", "Vertex Group for pinning of vertices");
00276         RNA_def_property_update(prop, 0, "rna_cloth_pinning_changed");
00277         
00278         prop= RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_ACCELERATION);
00279         RNA_def_property_array(prop, 3);
00280         RNA_def_property_range(prop, -100.0, 100.0);
00281         RNA_def_property_float_funcs(prop, "rna_ClothSettings_gravity_get", "rna_ClothSettings_gravity_set", NULL);
00282         RNA_def_property_ui_text(prop, "Gravity", "Gravity or external force vector");
00283         RNA_def_property_update(prop, 0, "rna_cloth_update");
00284 
00285         /* various */
00286 
00287         prop= RNA_def_property(srna, "air_damping", PROP_FLOAT, PROP_NONE);
00288         RNA_def_property_float_sdna(prop, NULL, "Cvi");
00289         RNA_def_property_range(prop, 0.0f, 10.0f);
00290         RNA_def_property_ui_text(prop, "Air Damping", "Air has normally some thickness which slows falling things down");
00291         RNA_def_property_update(prop, 0, "rna_cloth_update");
00292 
00293         prop= RNA_def_property(srna, "use_pin_cloth", PROP_BOOLEAN, PROP_NONE);
00294         RNA_def_property_boolean_sdna(prop, NULL, "flags", CLOTH_SIMSETTINGS_FLAG_GOAL);
00295         RNA_def_property_ui_text(prop, "Pin Cloth", "Enable pinning of cloth vertices to other objects/positions");
00296         RNA_def_property_update(prop, 0, "rna_cloth_pinning_changed");
00297 
00298         prop= RNA_def_property(srna, "pin_stiffness", PROP_FLOAT, PROP_NONE);
00299         RNA_def_property_float_sdna(prop, NULL, "goalspring");
00300         RNA_def_property_range(prop, 0.0f, 50.0);
00301         RNA_def_property_ui_text(prop, "Pin Stiffness", "Pin (vertex target position) spring stiffness");
00302         RNA_def_property_update(prop, 0, "rna_cloth_update");
00303 
00304         prop= RNA_def_property(srna, "quality", PROP_INT, PROP_NONE);
00305         RNA_def_property_int_sdna(prop, NULL, "stepsPerFrame");
00306         RNA_def_property_range(prop, 4, 80);
00307         RNA_def_property_ui_text(prop, "Quality", "Quality of the simulation in steps per frame. (higher is better quality but slower)");
00308         RNA_def_property_update(prop, 0, "rna_cloth_update");
00309 
00310         /* springs */
00311 
00312         prop= RNA_def_property(srna, "use_stiffness_scale", PROP_BOOLEAN, PROP_NONE);
00313         RNA_def_property_boolean_sdna(prop, NULL, "flags", CLOTH_SIMSETTINGS_FLAG_SCALING);
00314         RNA_def_property_ui_text(prop, "Stiffness Scaling", "If enabled, stiffness can be scaled along a weight painted vertex group");
00315         RNA_def_property_update(prop, 0, "rna_cloth_update");
00316         
00317         prop= RNA_def_property(srna, "spring_damping", PROP_FLOAT, PROP_NONE);
00318         RNA_def_property_float_sdna(prop, NULL, "Cdis");
00319         RNA_def_property_range(prop, 0.0f, 50.0f);
00320         RNA_def_property_ui_text(prop, "Spring Damping", "Damping of cloth velocity. (higher = more smooth, less jiggling)");
00321         RNA_def_property_update(prop, 0, "rna_cloth_update");
00322         
00323         prop= RNA_def_property(srna, "structural_stiffness", PROP_FLOAT, PROP_NONE);
00324         RNA_def_property_float_sdna(prop, NULL, "structural");
00325         RNA_def_property_range(prop, 0.0f, 10000.0f);
00326         RNA_def_property_ui_text(prop, "Structural Stiffness", "Overall stiffness of structure");
00327         RNA_def_property_update(prop, 0, "rna_cloth_update");
00328 
00329         prop= RNA_def_property(srna, "structural_stiffness_max", PROP_FLOAT, PROP_NONE);
00330         RNA_def_property_float_sdna(prop, NULL, "max_struct");
00331         RNA_def_property_range(prop, 0.0f, 10000.0f);
00332         RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_max_struct_set", NULL);
00333         RNA_def_property_ui_text(prop, "Structural Stiffness Maximum", "Maximum structural stiffness value");
00334         RNA_def_property_update(prop, 0, "rna_cloth_update");
00335 
00336         prop= RNA_def_property(srna, "vertex_group_structural_stiffness", PROP_STRING, PROP_NONE);
00337         RNA_def_property_string_funcs(prop, "rna_ClothSettings_struct_vgroup_get", "rna_ClothSettings_struct_vgroup_length", "rna_ClothSettings_struct_vgroup_set");
00338         RNA_def_property_ui_text(prop, "Structural Stiffness Vertex Group", "Vertex group for fine control over structural stiffness");
00339         RNA_def_property_update(prop, 0, "rna_cloth_update");
00340 
00341         prop= RNA_def_property(srna, "bending_stiffness", PROP_FLOAT, PROP_NONE);
00342         RNA_def_property_float_sdna(prop, NULL, "bending");
00343         RNA_def_property_range(prop, 0.0f, 10000.0f);
00344         RNA_def_property_ui_text(prop, "Bending Stiffness", "Wrinkle coefficient. (higher = less smaller but more big wrinkles)");
00345         RNA_def_property_update(prop, 0, "rna_cloth_update");
00346 
00347         prop= RNA_def_property(srna, "bending_stiffness_max", PROP_FLOAT, PROP_NONE);
00348         RNA_def_property_float_sdna(prop, NULL, "max_bend");
00349         RNA_def_property_range(prop, 0.0f, 10000.0f);
00350         RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_max_bend_set", NULL);
00351         RNA_def_property_ui_text(prop, "Bending Stiffness Maximum", "Maximum bending stiffness value");
00352         RNA_def_property_update(prop, 0, "rna_cloth_update");
00353 
00354         prop= RNA_def_property(srna, "vertex_group_bending", PROP_STRING, PROP_NONE);
00355         RNA_def_property_string_funcs(prop, "rna_ClothSettings_bend_vgroup_get", "rna_ClothSettings_bend_vgroup_length", "rna_ClothSettings_bend_vgroup_set");
00356         RNA_def_property_ui_text(prop, "Bending Stiffness Vertex Group", "Vertex group for fine control over bending stiffness");
00357         RNA_def_property_update(prop, 0, "rna_cloth_update");
00358 
00359         prop= RNA_def_property(srna, "effector_weights", PROP_POINTER, PROP_NONE);
00360         RNA_def_property_struct_type(prop, "EffectorWeights");
00361         RNA_def_property_clear_flag(prop, PROP_EDITABLE);
00362         RNA_def_property_ui_text(prop, "Effector Weights", "");
00363 
00364         prop= RNA_def_property(srna, "pre_roll", PROP_INT, PROP_NONE);
00365         RNA_def_property_int_sdna(prop, NULL, "preroll");
00366         RNA_def_property_range(prop, 0, 200);
00367         RNA_def_property_ui_text(prop, "Pre Roll", "Simulation starts on this frame");
00368         RNA_def_property_update(prop, 0, "rna_cloth_reset");
00369 
00370         prop= RNA_def_property(srna, "rest_shape_key", PROP_POINTER, PROP_NONE);
00371         RNA_def_property_flag(prop, PROP_EDITABLE);
00372         RNA_def_property_struct_type(prop, "ShapeKey");
00373         RNA_def_property_pointer_funcs(prop, "rna_ClothSettings_rest_shape_key_get", "rna_ClothSettings_rest_shape_key_set", NULL, NULL);
00374         RNA_def_property_ui_text(prop, "Rest Shade Key", "Shape key to use the rest spring lengths from");
00375         RNA_def_property_update(prop, 0, "rna_cloth_update");
00376 
00377         /* unused */
00378 
00379         /* unused still
00380         prop= RNA_def_property(srna, "shear_stiffness", PROP_FLOAT, PROP_NONE);
00381         RNA_def_property_float_sdna(prop, NULL, "shear");
00382         RNA_def_property_range(prop, 0.0f, 1000.0f);
00383         RNA_def_property_ui_text(prop, "Shear Stiffness", "Shear spring stiffness"); */
00384 
00385         /* unused still
00386         prop= RNA_def_property(srna, "shear_stiffness_max", PROP_FLOAT, PROP_NONE);
00387         RNA_def_property_float_sdna(prop, NULL, "max_shear");
00388         RNA_def_property_range(prop, 0.0f, upperLimitf);
00389         RNA_def_property_ui_text(prop, "Shear Stiffness Maximum", "Maximum shear scaling value"); */
00390         
00391         /* unused still
00392         prop= RNA_def_property(srna, "effector_force_scale", PROP_FLOAT, PROP_NONE);
00393         RNA_def_property_float_sdna(prop, NULL, "eff_force_scale");
00394         RNA_def_property_range(prop, 0.0f, 100.0f);
00395         RNA_def_property_ui_text(prop, "Effector Force Scale", ""); */
00396 
00397         /* unused still
00398         prop= RNA_def_property(srna, "effector_wind_scale", PROP_FLOAT, PROP_NONE);
00399         RNA_def_property_float_sdna(prop, NULL, "eff_wind_scale");
00400         RNA_def_property_range(prop, 0.0f, 100.0f);
00401         RNA_def_property_ui_text(prop, "Effector Wind Scale", ""); */
00402         
00403         /* unused still
00404         prop= RNA_def_property(srna, "tearing", PROP_BOOLEAN, PROP_NONE);
00405         RNA_def_property_boolean_sdna(prop, NULL, "flags", CLOTH_SIMSETTINGS_FLAG_TEARING);
00406         RNA_def_property_ui_text(prop, "Tearing", "");*/
00407         
00408         /* unused still
00409         prop= RNA_def_property(srna, "max_spring_extensions", PROP_INT, PROP_NONE);
00410         RNA_def_property_int_sdna(prop, NULL, "maxspringlen");
00411         RNA_def_property_range(prop, 1.0, 1000.0);
00412         RNA_def_property_ui_text(prop, "Maximum Spring Extension", "Maximum extension before spring gets cut"); */
00413 }
00414 
00415 static void rna_def_cloth_collision_settings(BlenderRNA *brna)
00416 {
00417         StructRNA *srna;
00418         PropertyRNA *prop;
00419         
00420         srna = RNA_def_struct(brna, "ClothCollisionSettings", NULL);
00421         RNA_def_struct_ui_text(srna, "Cloth Collision Settings", "Cloth simulation settings for self collision and collision with other objects");
00422         RNA_def_struct_sdna(srna, "ClothCollSettings");
00423         RNA_def_struct_path_func(srna, "rna_ClothCollisionSettings_path");
00424 
00425         /* general collision */
00426 
00427         prop= RNA_def_property(srna, "use_collision", PROP_BOOLEAN, PROP_NONE);
00428         RNA_def_property_boolean_sdna(prop, NULL, "flags", CLOTH_COLLSETTINGS_FLAG_ENABLED);
00429         RNA_def_property_ui_text(prop, "Enable Collision", "Enable collisions with other objects");
00430         RNA_def_property_update(prop, 0, "rna_cloth_update");
00431 
00432         prop= RNA_def_property(srna, "repel_force", PROP_FLOAT, PROP_NONE);
00433         RNA_def_property_float_sdna(prop, NULL, "repel_force");
00434         RNA_def_property_range(prop, 0.0f, 20.0f);
00435         RNA_def_property_float_default(prop, 1.0f);
00436         RNA_def_property_ui_text(prop, "Repulsion Force", "Repulsion force to apply on cloth when close to colliding");
00437         RNA_def_property_update(prop, 0, "rna_cloth_update");
00438 
00439         prop= RNA_def_property(srna, "distance_repel", PROP_FLOAT, PROP_NONE);
00440         RNA_def_property_float_sdna(prop, NULL, "distance_repel");
00441         RNA_def_property_range(prop, 0.001f, 10.0f);
00442         RNA_def_property_float_default(prop, 0.005f);
00443         RNA_def_property_ui_text(prop, "Repulsion Distance", "Maximum distance to apply repulsion force, must be greater then minimum distance");
00444         RNA_def_property_update(prop, 0, "rna_cloth_update");
00445         
00446         prop= RNA_def_property(srna, "distance_min", PROP_FLOAT, PROP_NONE);
00447         RNA_def_property_float_sdna(prop, NULL, "epsilon");
00448         RNA_def_property_range(prop, 0.001f, 1.0f);
00449         RNA_def_property_ui_text(prop, "Minimum Distance", "Minimum distance between collision objects before collision response takes in");
00450         RNA_def_property_update(prop, 0, "rna_cloth_update");
00451 
00452         prop= RNA_def_property(srna, "friction", PROP_FLOAT, PROP_NONE);
00453         RNA_def_property_range(prop, 0.0f, 80.0f);
00454         RNA_def_property_ui_text(prop, "Friction", "Friction force if a collision happened. (higher = less movement)");
00455         RNA_def_property_update(prop, 0, "rna_cloth_update");
00456 
00457         prop= RNA_def_property(srna, "collision_quality", PROP_INT, PROP_NONE);
00458         RNA_def_property_int_sdna(prop, NULL, "loop_count");
00459         RNA_def_property_range(prop, 1, 20);
00460         RNA_def_property_ui_text(prop, "Collision Quality", "How many collision iterations should be done. (higher is better quality but slower)");
00461         RNA_def_property_update(prop, 0, "rna_cloth_update");
00462 
00463         /* self collision */
00464 
00465         prop= RNA_def_property(srna, "use_self_collision", PROP_BOOLEAN, PROP_NONE);
00466         RNA_def_property_boolean_sdna(prop, NULL, "flags", CLOTH_COLLSETTINGS_FLAG_SELF);
00467         RNA_def_property_ui_text(prop, "Enable Self Collision", "Enable self collisions");
00468         RNA_def_property_update(prop, 0, "rna_cloth_update");
00469         
00470         prop= RNA_def_property(srna, "self_distance_min", PROP_FLOAT, PROP_NONE);
00471         RNA_def_property_float_sdna(prop, NULL, "selfepsilon");
00472         RNA_def_property_range(prop, 0.5f, 1.0f);
00473         RNA_def_property_ui_text(prop, "Self Minimum Distance", "0.5 means no distance at all, 1.0 is maximum distance");
00474         RNA_def_property_update(prop, 0, "rna_cloth_update");
00475         
00476         prop= RNA_def_property(srna, "self_friction", PROP_FLOAT, PROP_NONE);
00477         RNA_def_property_range(prop, 0.0f, 80.0f);
00478         RNA_def_property_ui_text(prop, "Self Friction", "Friction/damping with self contact");
00479         RNA_def_property_update(prop, 0, "rna_cloth_update");
00480 
00481         prop= RNA_def_property(srna, "self_collision_quality", PROP_INT, PROP_NONE);
00482         RNA_def_property_int_sdna(prop, NULL, "self_loop_count");
00483         RNA_def_property_range(prop, 1, 10);
00484         RNA_def_property_ui_text(prop, "Self Collision Quality", "How many self collision iterations should be done. (higher is better quality but slower)");
00485         RNA_def_property_update(prop, 0, "rna_cloth_update");
00486 
00487         prop= RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
00488         RNA_def_property_flag(prop, PROP_EDITABLE);
00489         RNA_def_property_ui_text(prop, "Collision Group", "Limit colliders to this Group");
00490         RNA_def_property_update(prop, 0, "rna_cloth_update");
00491 }
00492 
00493 void RNA_def_cloth(BlenderRNA *brna)
00494 {
00495         rna_def_cloth_sim_settings(brna);
00496         rna_def_cloth_collision_settings(brna);
00497 }
00498 
00499 #endif
00500