Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_cloth.h2
-rw-r--r--source/blender/blenkernel/intern/cloth.c14
-rw-r--r--source/blender/blenkernel/intern/collision.c4
-rw-r--r--source/blender/makesdna/DNA_cloth_types.h5
-rw-r--r--source/blender/makesrna/intern/rna_cloth.c26
5 files changed, 47 insertions, 4 deletions
diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h
index 378cc72beb1..3475ef532da 100644
--- a/source/blender/blenkernel/BKE_cloth.h
+++ b/source/blender/blenkernel/BKE_cloth.h
@@ -56,7 +56,7 @@ struct CollisionTree;
/* Bits to or into the ClothVertex.flags. */
#define CLOTH_VERT_FLAG_PINNED 1
-#define CLOTH_VERT_FLAG_COLLISION 2
+#define CLOTH_VERT_FLAG_NOSELFCOLL 2 /* vertex NOT used for self collisions */
#define CLOTH_VERT_FLAG_PINNED_EM 3
/**
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index e067b7195ce..b681426f8a7 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -143,6 +143,7 @@ void cloth_init(ClothModifierData *clmd )
clmd->coll_parms->collision_list = NULL;
clmd->coll_parms->self_loop_count = 1.0;
clmd->coll_parms->selfepsilon = 0.75;
+ clmd->coll_parms->vgroup_selfcol = 0;
/* These defaults are copied from softbody.c's
* softbody_calc_forces() function.
@@ -756,10 +757,12 @@ static void cloth_to_object (Object *ob, ClothModifierData *clmd, float (*verte
int cloth_uses_vgroup(ClothModifierData *clmd)
{
return (((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SCALING ) ||
- (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL )) &&
+ (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL ) ||
+ (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF)) &&
((clmd->sim_parms->vgroup_mass>0) ||
(clmd->sim_parms->vgroup_struct>0)||
- (clmd->sim_parms->vgroup_bend>0)));
+ (clmd->sim_parms->vgroup_bend>0) ||
+ (clmd->coll_parms->vgroup_selfcol>0)));
}
/**
@@ -815,6 +818,13 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm )
verts->bend_stiff = dvert->dw [j].weight;
}
}
+
+ if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF ) {
+ if ( dvert->dw[j].def_nr == (clmd->coll_parms->vgroup_selfcol-1)) {
+ if( dvert->dw [j].weight > 0.0)
+ verts->flags |= CLOTH_VERT_FLAG_NOSELFCOLL;
+ }
+ }
/*
// for later
if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_weight-1))
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index 32e9dd7508b..44f524304d2 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -840,6 +840,10 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData * clmd, float step, flo
continue;
}
}
+
+ if( ( cloth->verts[i].flags & CLOTH_VERT_FLAG_NOSELFCOLL ) ||
+ ( cloth->verts[j].flags & CLOTH_VERT_FLAG_NOSELFCOLL ) )
+ continue;
sub_v3_v3v3(temp, verts[i].tx, verts[j].tx);
diff --git a/source/blender/makesdna/DNA_cloth_types.h b/source/blender/makesdna/DNA_cloth_types.h
index fd8b08e68c6..b214186fee6 100644
--- a/source/blender/makesdna/DNA_cloth_types.h
+++ b/source/blender/makesdna/DNA_cloth_types.h
@@ -83,7 +83,7 @@ typedef struct ClothSimSettings
short shapekey_rest; /* vertex group for scaling structural stiffness */
short presets; /* used for presets on GUI */
short reset;
- short pad;
+ short pad;
struct EffectorWeights *effector_weights;
} ClothSimSettings;
@@ -101,6 +101,9 @@ typedef struct ClothCollSettings
short self_loop_count; /* How many iterations for the selfcollision loop */
short loop_count; /* How many iterations for the collision loop. */
struct Group *group; /* Only use colliders from this group of objects */
+ short vgroup_selfcol; /* vgroup to paint which vertices are used for self collisions */
+ short pad;
+ int pad2;
} ClothCollSettings;
diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c
index 37795edb884..82a838010f6 100644
--- a/source/blender/makesrna/intern/rna_cloth.c
+++ b/source/blender/makesrna/intern/rna_cloth.c
@@ -155,6 +155,25 @@ static void rna_ClothSettings_bend_vgroup_set(PointerRNA *ptr, const char *value
rna_object_vgroup_name_index_set(ptr, value, &sim->vgroup_bend);
}
+
+static void rna_CollSettings_selfcol_vgroup_get(PointerRNA *ptr, char *value)
+{
+ ClothCollSettings *coll = (ClothCollSettings *)ptr->data;
+ rna_object_vgroup_name_index_get(ptr, value, coll->vgroup_selfcol);
+}
+
+static int rna_CollSettings_selfcol_vgroup_length(PointerRNA *ptr)
+{
+ ClothCollSettings *coll = (ClothCollSettings *)ptr->data;
+ return rna_object_vgroup_name_index_length(ptr, coll->vgroup_selfcol);
+}
+
+static void rna_CollSettings_selfcol_vgroup_set(PointerRNA *ptr, const char *value)
+{
+ ClothCollSettings *coll = (ClothCollSettings *)ptr->data;
+ rna_object_vgroup_name_index_set(ptr, value, &coll->vgroup_selfcol);
+}
+
static PointerRNA rna_ClothSettings_rest_shape_key_get(PointerRNA *ptr)
{
Object *ob = (Object *)ptr->id.data;
@@ -523,6 +542,13 @@ static void rna_def_cloth_collision_settings(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Collision Group", "Limit colliders to this Group");
RNA_def_property_update(prop, 0, "rna_cloth_update");
+
+ prop = RNA_def_property(srna, "vertex_group_self_collisions", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_funcs(prop, "rna_CollSettings_selfcol_vgroup_get", "rna_CollSettings_selfcol_vgroup_length",
+ "rna_CollSettings_selfcol_vgroup_set");
+ RNA_def_property_ui_text(prop, "Selfcollision Vertex Group",
+ "Vertex group to define vertices which are not used during self collisions.");
+ RNA_def_property_update(prop, 0, "rna_cloth_update");
}
void RNA_def_cloth(BlenderRNA *brna)