Page MenuHome

patch.diff

patch.diff

diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 3ab522a..f967393 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -100,6 +100,7 @@ void cloth_init(ClothModifierData *clmd )
clmd->sim_parms->vgroup_mass = 0;
clmd->sim_parms->vgroup_shrink = 0;
clmd->sim_parms->shrink_min = 0.0f; /* min amount the fabric will shrink by 0.0 = no shrinking, 1.0 = shrink to nothing*/
+ clmd->sim_parms->shrink_max = 1.0f; /* max amount the fabric will shrink by 0.0 = no shrinking, 1.0 = shrink to nothing*/
clmd->sim_parms->avg_spring_len = 0.0;
clmd->sim_parms->presets = 2; /* cotton as start setting */
clmd->sim_parms->timescale = 1.0f; /* speed factor, describes how fast cloth moves */
@@ -732,14 +733,17 @@ 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 ) ||
+
+ return (((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SEW) &&
+ (clmd->sim_parms->vgroup_shrink>0)) ||
+ (((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_shrink>0) ||
- (clmd->coll_parms->vgroup_selfcol>0)));
+ (clmd->coll_parms->vgroup_selfcol>0))));
}
/**
@@ -774,10 +778,16 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm )
else
verts->goal= 0.0f;
+ /* Reset sew values to standard */
+ if (clmd->coll_parms->flags & CLOTH_SIMSETTINGS_FLAG_SEW )
+ verts->shrink_factor = clmd->sim_parms->shrink_min;
+
/* Reset vertex flags */
verts->flags &= ~CLOTH_VERT_FLAG_PINNED;
verts->flags &= ~CLOTH_VERT_FLAG_NOSELFCOLL;
+
+
dvert = dm->getVertData ( dm, i, CD_MDEFORMVERT );
if ( dvert ) {
for ( j = 0; j < dvert->totweight; j++ ) {
@@ -812,18 +822,15 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm )
}
}
- if (clmd->sim_parms->vgroup_shrink > 0 )
- {
- if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_shrink-1))
- {
- verts->shrink_factor = clmd->sim_parms->shrink_min*(1.0f-dvert->dw[j].weight)+clmd->sim_parms->shrink_max*dvert->dw [j].weight; // linear interpolation between min and max shrink factor based on weight
+ if (clmd->coll_parms->flags & CLOTH_SIMSETTINGS_FLAG_SEW ) {
+ if ( dvert->dw[j].def_nr == (clmd->sim_parms->vgroup_shrink-1)) {
+ /* linear interpolation between min and max shrink factor based on weight */
+ verts->shrink_factor = clmd->sim_parms->shrink_min*
+ (1.0f-dvert->dw[j].weight)+
+ clmd->sim_parms->shrink_max*dvert->dw [j].weight;
+ }
}
}
- else {
- verts->shrink_factor = clmd->sim_parms->shrink_min;
- }
-
- }
}
}
}
@@ -1149,20 +1156,23 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
if ( spring ) {
spring_verts_ordered_set(spring, medge[i].v1, medge[i].v2);
- if(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SEW && medge[i].flag & ME_LOOSEEDGE) {
- // handle sewing (loose edges will be pulled together)
- spring->restlen = 0.0f;
- spring->stiffness = 1.0f;
- spring->type = CLOTH_SPRING_TYPE_SEWING;
- } else {
- if(clmd->sim_parms->vgroup_shrink > 0)
- shrink_factor = 1.0f - ((cloth->verts[spring->ij].shrink_factor + cloth->verts[spring->kl].shrink_factor) / 2.0f);
- else
- shrink_factor = 1.0f - clmd->sim_parms->shrink_min;
- spring->restlen = len_v3v3(cloth->verts[spring->kl].xrest, cloth->verts[spring->ij].xrest) * shrink_factor;
- spring->stiffness = (cloth->verts[spring->kl].struct_stiff + cloth->verts[spring->ij].struct_stiff) / 2.0f;
- spring->type = CLOTH_SPRING_TYPE_STRUCTURAL;
- }
+ if(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_SEW) {
+ if(medge[i].flag & ME_LOOSEEDGE) {
+ // handle sewing (loose edges will be pulled together)
+ spring->restlen = 0.0f;
+ spring->stiffness = 1.0f;
+ spring->type = CLOTH_SPRING_TYPE_SEWING;
+ } else {
+ if(clmd->sim_parms->vgroup_shrink > 0)
+ shrink_factor = 1.0f - ((cloth->verts[spring->ij].shrink_factor + cloth->verts[spring->kl].shrink_factor) / 2.0f);
+ else
+ shrink_factor = 1.0f - clmd->sim_parms->shrink_min;
+
+ spring->restlen = len_v3v3(cloth->verts[spring->kl].xrest, cloth->verts[spring->ij].xrest) * shrink_factor;
+ spring->stiffness = (cloth->verts[spring->kl].struct_stiff + cloth->verts[spring->ij].struct_stiff) / 2.0f;
+ spring->type = CLOTH_SPRING_TYPE_STRUCTURAL;
+ }
+ }
clmd->sim_parms->avg_spring_len += spring->restlen;
cloth->verts[spring->ij].avg_spring_len += spring->restlen;
cloth->verts[spring->kl].avg_spring_len += spring->restlen;

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
b1/73/e220024720824c62ad37010f4512

Event Timeline