Page MenuHome

patch-against-55292.diff

Authored By
jz p (acme_pjz)
Nov 13 2013, 4:32 PM
Size
25 KB
Subscribers
None

patch-against-55292.diff

Index: release/scripts/startup/bl_ui/properties_physics_cloth.py
===================================================================
--- release/scripts/startup/bl_ui/properties_physics_cloth.py (revision 55292)
+++ release/scripts/startup/bl_ui/properties_physics_cloth.py (working copy)
@@ -77,6 +77,23 @@
col.prop(cloth, "structural_stiffness", text="Structural")
col.prop(cloth, "bending_stiffness", text="Bending")
+ # new properties: air pressure
+ col.label(text="Air Pressure:")
+ col.prop(cloth, "cloth_pressure")
+ col.prop(cloth, "init_volume")
+ col.prop(cloth, "pressure_scale", text="Scale")
+
+ # new properties: sewing and spring rest length shrink
+ col.label(text="Sewing:")
+ col.prop(cloth, "use_sewing_springs", text="Use Sewing Springs")
+ col.prop(cloth, "sewing_force_max", text="Sewing Force")
+
+ sub = col.column()
+ col.label(text="Shrinking:")
+ col.prop_search(cloth, "vertex_group_shrink", ob, "vertex_groups", text="")
+ col.prop(cloth, "shrink_min", text="Min")
+ col.prop(cloth, "shrink_max", text="Max")
+
col = split.column()
col.label(text="Damping:")
Index: source/blender/blenkernel/intern/cloth.c
===================================================================
--- source/blender/blenkernel/intern/cloth.c (revision 55292)
+++ source/blender/blenkernel/intern/cloth.c (working copy)
@@ -97,6 +97,9 @@
clmd->sim_parms->flags = 0;
clmd->sim_parms->solver_type = 0;
clmd->sim_parms->preroll = 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->maxspringlen = 10;
clmd->sim_parms->vgroup_mass = 0;
clmd->sim_parms->avg_spring_len = 0.0;
@@ -104,6 +107,10 @@
clmd->sim_parms->timescale = 1.0f; /* speed factor, describes how fast cloth moves */
clmd->sim_parms->reset = 0;
clmd->sim_parms->vel_damping = 1.0f; /* 1.0 = no damping, 0.0 = fully dampened */
+
+ clmd->sim_parms->cloth_pressure = 0.0f;
+ clmd->sim_parms->init_volume = 0.0f;
+ clmd->sim_parms->pressure_scale = 1.0f;
clmd->coll_parms->self_friction = 5.0;
clmd->coll_parms->friction = 5.0;
@@ -736,6 +743,7 @@
((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)));
}
@@ -802,6 +810,15 @@
}
}
+ 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
+ }
+ }
+ else {
+ verts->shrink_factor = clmd->sim_parms->shrink_min;
+ }
+
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.0f) {
@@ -1084,6 +1101,7 @@
unsigned int numverts = (unsigned int)dm->getNumVerts (dm);
unsigned int numedges = (unsigned int)dm->getNumEdges (dm);
unsigned int numfaces = (unsigned int)dm->getNumTessFaces (dm);
+ float shrink_factor;
MEdge *medge = dm->getEdgeArray (dm);
MFace *mface = dm->getTessFaceArray (dm);
int index2 = 0; // our second vertex index
@@ -1119,15 +1137,26 @@
if ( spring ) {
spring->ij = MIN2(medge[i].v1, medge[i].v2);
spring->kl = MAX2(medge[i].v2, medge[i].v1);
- spring->restlen = len_v3v3(cloth->verts[spring->kl].xrest, cloth->verts[spring->ij].xrest);
+ 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;
+ }
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;
cloth->verts[spring->ij].spring_count++;
cloth->verts[spring->kl].spring_count++;
- spring->type = CLOTH_SPRING_TYPE_STRUCTURAL;
spring->flags = 0;
- spring->stiffness = (cloth->verts[spring->kl].struct_stiff + cloth->verts[spring->ij].struct_stiff) / 2.0f;
struct_springs++;
BLI_linklist_prepend ( &cloth->springs, spring );
@@ -1160,7 +1189,11 @@
spring->ij = MIN2(mface[i].v1, mface[i].v3);
spring->kl = MAX2(mface[i].v3, mface[i].v1);
- spring->restlen = len_v3v3(cloth->verts[spring->kl].xrest, cloth->verts[spring->ij].xrest);
+ 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->type = CLOTH_SPRING_TYPE_SHEAR;
spring->stiffness = (cloth->verts[spring->kl].shear_stiff + cloth->verts[spring->ij].shear_stiff) / 2.0f;
@@ -1181,7 +1214,11 @@
spring->ij = MIN2(mface[i].v2, mface[i].v4);
spring->kl = MAX2(mface[i].v4, mface[i].v2);
- spring->restlen = len_v3v3(cloth->verts[spring->kl].xrest, cloth->verts[spring->ij].xrest);
+ 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->type = CLOTH_SPRING_TYPE_SHEAR;
spring->stiffness = (cloth->verts[spring->kl].shear_stiff + cloth->verts[spring->ij].shear_stiff) / 2.0f;
Index: source/blender/blenkernel/intern/implicit.c
===================================================================
--- source/blender/blenkernel/intern/implicit.c (revision 55292)
+++ source/blender/blenkernel/intern/implicit.c (working copy)
@@ -1255,7 +1255,7 @@
}
// calculate force of structural + shear springs
- if ((s->type & CLOTH_SPRING_TYPE_STRUCTURAL) || (s->type & CLOTH_SPRING_TYPE_SHEAR)) {
+ if ((s->type & CLOTH_SPRING_TYPE_STRUCTURAL) || (s->type & CLOTH_SPRING_TYPE_SHEAR) || (s->type & CLOTH_SPRING_TYPE_SEWING)) {
if (length > L || no_compress) {
s->flags |= CLOTH_SPRING_FLAG_NEEDED;
@@ -1266,7 +1266,16 @@
k = scaling / (clmd->sim_parms->avg_spring_len + FLT_EPSILON);
// TODO: verify, half verified (couldn't see error)
- mul_fvector_S(stretch_force, dir, k*(length-L));
+ if(s->type & CLOTH_SPRING_TYPE_SEWING) {
+ // sewing springs usually have a large distance at first so clamp the force so we don't get tunnelling through colission objects
+ float force = k*(length-L);
+ if(force > clmd->sim_parms->max_sewing) {
+ force = clmd->sim_parms->max_sewing;
+ }
+ mul_fvector_S(stretch_force, dir, force);
+ } else {
+ mul_fvector_S(stretch_force, dir, k*(length-L));
+ }
VECADD(s->f, s->f, stretch_force);
@@ -1337,7 +1346,7 @@
if (!(s->type & CLOTH_SPRING_TYPE_BENDING)) {
sub_fmatrix_fmatrix(dFdV[s->ij].m, dFdV[s->ij].m, s->dfdv);
sub_fmatrix_fmatrix(dFdV[s->kl].m, dFdV[s->kl].m, s->dfdv);
- add_fmatrix_fmatrix(dFdV[s->matrix_index].m, dFdV[s->matrix_index].m, s->dfdv);
+ add_fmatrix_fmatrix(dFdV[s->matrix_index].m, dFdV[s->matrix_index].m, s->dfdv);
}
VECADD(lF[s->ij], lF[s->ij], s->f);
@@ -1541,8 +1550,10 @@
MFace *mfaces = cloth->mfaces;
unsigned int numverts = cloth->numverts;
LinkNode *search;
- lfVector *winvec;
+ lfVector *winvec = NULL;
EffectedPoint epoint;
+ int calc_pressure = 0;
+ float cloth_pressure = 0.0f;
tm2[0][0] = tm2[1][1] = tm2[2][2] = -spring_air;
@@ -1572,20 +1583,85 @@
}
submul_lfvectorS(lF, lV, spring_air, numverts);
+
+ //new: check if we need to calculate pressure
+ if(fabs(clmd->sim_parms->cloth_pressure) > 1E-6f || clmd->sim_parms->init_volume > 1E-6f) {
+ calc_pressure = 1;
+ }
/* handle external forces like wind */
- if (effectors) {
- // 0 = force, 1 = normalized force
- winvec = create_lfvector(cloth->numverts);
-
- if (!winvec)
- printf("winvec: out of memory in implicit.c\n");
-
- // precalculate wind forces
- for (i = 0; i < cloth->numverts; i++) {
- pd_point_from_loc(clmd->scene, (float*)lX[i], (float*)lV[i], i, &epoint);
- pdDoEffectors(effectors, NULL, clmd->sim_parms->effector_weights, &epoint, winvec[i], NULL);
+ if (effectors || calc_pressure) {
+ if (effectors) {
+ // 0 = force, 1 = normalized force
+ winvec = create_lfvector(cloth->numverts);
+
+ if (!winvec)
+ printf("winvec: out of memory in implicit.c\n");
+
+ // precalculate wind forces
+ for (i = 0; i < cloth->numverts; i++) {
+ pd_point_from_loc(clmd->scene, (float*)lX[i], (float*)lV[i], i, &epoint);
+ pdDoEffectors(effectors, NULL, clmd->sim_parms->effector_weights, &epoint, winvec[i], NULL);
+ }
}
+
+ if (calc_pressure) {
+ //check if we need to calculate volume
+ if (clmd->sim_parms->init_volume > 1E-6f) {
+ float f;
+
+ //calc the volume of (closed) cloth
+ for (i = 0; i < cloth->numfaces; i++) {
+ float vol;
+ unsigned int v1 = mfaces[i].v1;
+ unsigned int v2 = mfaces[i].v2;
+ unsigned int v3 = mfaces[i].v3;
+ unsigned int v4 = mfaces[i].v4;
+
+ if (v4) {
+ //we have 4 vertices, calculate the volume of
+ //four tetrahedra (0,v1,v2,u) (0,v2,v3,u) (0,v3,v4,u)
+ //and (0,v4,v1,u) where u=(v1+v2+v3+v4)/4
+ //after simplifying we got formula below
+ vol = 0.5f * (
+ (lX[v1][0] * lX[v2][1] - lX[v1][1] * lX[v2][0]) * (lX[v3][2] + lX[v4][2]) +
+ (lX[v1][1] * lX[v2][2] - lX[v1][2] * lX[v2][1]) * (lX[v3][0] + lX[v4][0]) +
+ (lX[v1][2] * lX[v2][0] - lX[v1][0] * lX[v2][2]) * (lX[v3][1] + lX[v4][1]) +
+ (lX[v3][0] * lX[v4][1] - lX[v3][1] * lX[v4][0]) * (lX[v1][2] + lX[v2][2]) +
+ (lX[v3][1] * lX[v4][2] - lX[v3][2] * lX[v4][1]) * (lX[v1][0] + lX[v2][0]) +
+ (lX[v3][2] * lX[v4][0] - lX[v3][0] * lX[v4][2]) * (lX[v1][1] + lX[v2][1]));
+ } else {
+ //we have 3 vertices, calculate the volume of
+ //tetrahedra (0,v1,v2,v3)
+ vol =
+ (lX[v1][0] * lX[v2][1] - lX[v1][1] * lX[v2][0]) * lX[v3][2] +
+ (lX[v1][1] * lX[v2][2] - lX[v1][2] * lX[v2][1]) * lX[v3][0] +
+ (lX[v1][2] * lX[v2][0] - lX[v1][0] * lX[v2][2]) * lX[v3][1];
+ }
+
+ cloth_pressure += vol;
+ }
+
+ //divide by 6 to get real volume
+ cloth_pressure /= 6.0f;
+
+ //calculate an artifical maximum value for cloth pressure.
+ //TODO: adjuatable
+ f = fabs(clmd->sim_parms->cloth_pressure) + 200.0f;
+
+ //clamp the cloth pressure to the maximum value
+ if (cloth_pressure * f < clmd->sim_parms->init_volume) {
+ cloth_pressure = f;
+ } else {
+ cloth_pressure = clmd->sim_parms->init_volume / cloth_pressure;
+ }
+ }
+
+ cloth_pressure += clmd->sim_parms->cloth_pressure;
+
+ //do some scaling (?)
+ cloth_pressure *= 0.1f * clmd->sim_parms->pressure_scale;
+ }
for (i = 0; i < cloth->numfaces; i++) {
float trinormal[3] = {0, 0, 0}; // normalized triangle normal
@@ -1602,59 +1678,81 @@
normalize_v3_v3(trinormal, triunnormal);
- // add wind from v1
- copy_v3_v3(tmp, trinormal);
- mul_v3_fl(tmp, calculateVertexWindForce(winvec[mfaces[i].v1], triunnormal));
- VECADDS(lF[mfaces[i].v1], lF[mfaces[i].v1], tmp, factor);
-
- // add wind from v2
- copy_v3_v3(tmp, trinormal);
- mul_v3_fl(tmp, calculateVertexWindForce(winvec[mfaces[i].v2], triunnormal));
- VECADDS(lF[mfaces[i].v2], lF[mfaces[i].v2], tmp, factor);
-
- // add wind from v3
- copy_v3_v3(tmp, trinormal);
- mul_v3_fl(tmp, calculateVertexWindForce(winvec[mfaces[i].v3], triunnormal));
- VECADDS(lF[mfaces[i].v3], lF[mfaces[i].v3], tmp, factor);
-
- // add wind from v4
- if (mfaces[i].v4) {
+ if (effectors) {
+ // add wind from v1
copy_v3_v3(tmp, trinormal);
- mul_v3_fl(tmp, calculateVertexWindForce(winvec[mfaces[i].v4], triunnormal));
- VECADDS(lF[mfaces[i].v4], lF[mfaces[i].v4], tmp, factor);
+ mul_v3_fl(tmp, calculateVertexWindForce(winvec[mfaces[i].v1], triunnormal));
+ VECADDS(lF[mfaces[i].v1], lF[mfaces[i].v1], tmp, factor);
+
+ // add wind from v2
+ copy_v3_v3(tmp, trinormal);
+ mul_v3_fl(tmp, calculateVertexWindForce(winvec[mfaces[i].v2], triunnormal));
+ VECADDS(lF[mfaces[i].v2], lF[mfaces[i].v2], tmp, factor);
+
+ // add wind from v3
+ copy_v3_v3(tmp, trinormal);
+ mul_v3_fl(tmp, calculateVertexWindForce(winvec[mfaces[i].v3], triunnormal));
+ VECADDS(lF[mfaces[i].v3], lF[mfaces[i].v3], tmp, factor);
+
+ // add wind from v4
+ if (mfaces[i].v4) {
+ copy_v3_v3(tmp, trinormal);
+ mul_v3_fl(tmp, calculateVertexWindForce(winvec[mfaces[i].v4], triunnormal));
+ VECADDS(lF[mfaces[i].v4], lF[mfaces[i].v4], tmp, factor);
+ }
}
+
+ if (calc_pressure) {
+ factor *= cloth_pressure;
+
+ // add pressure from v1
+ VECADDS(lF[mfaces[i].v1], lF[mfaces[i].v1], triunnormal, cloth_pressure);
+
+ // add pressure from v2
+ VECADDS(lF[mfaces[i].v2], lF[mfaces[i].v2], triunnormal, cloth_pressure);
+
+ // add pressure from v3
+ VECADDS(lF[mfaces[i].v3], lF[mfaces[i].v3], triunnormal, cloth_pressure);
+
+ // add pressure from v4
+ if (mfaces[i].v4) {
+ VECADDS(lF[mfaces[i].v4], lF[mfaces[i].v4], triunnormal, cloth_pressure);
+ }
+ }
}
- /* Hair has only edges */
- if (cloth->numfaces == 0) {
- ClothSpring *spring;
- float edgevec[3] = {0, 0, 0}; //edge vector
- float edgeunnormal[3] = {0, 0, 0}; // not-normalized-edge normal
- float tmp[3] = {0, 0, 0};
+ if (effectors) {
+ /* Hair has only edges */
+ if (cloth->numfaces == 0) {
+ ClothSpring *spring;
+ float edgevec[3]={0,0,0}; //edge vector
+ float edgeunnormal[3]={0,0,0}; // not-normalized-edge normal
+ float tmp[3]={0,0,0};
float factor = 0.01;
- search = cloth->springs;
- while (search) {
- spring = search->link;
-
- if (spring->type == CLOTH_SPRING_TYPE_STRUCTURAL) {
- sub_v3_v3v3(edgevec, (float*)lX[spring->ij], (float*)lX[spring->kl]);
+ search = cloth->springs;
+ while (search) {
+ spring = search->link;
+
+ if (spring->type == CLOTH_SPRING_TYPE_STRUCTURAL) {
+ sub_v3_v3v3(edgevec, (float*)lX[spring->ij], (float*)lX[spring->kl]);
- project_v3_v3v3(tmp, winvec[spring->ij], edgevec);
- sub_v3_v3v3(edgeunnormal, winvec[spring->ij], tmp);
- /* hair doesn't stretch too much so we can use restlen pretty safely */
- VECADDS(lF[spring->ij], lF[spring->ij], edgeunnormal, spring->restlen * factor);
+ project_v3_v3v3(tmp, winvec[spring->ij], edgevec);
+ sub_v3_v3v3(edgeunnormal, winvec[spring->ij], tmp);
+ /* hair doesn't stretch too much so we can use restlen pretty safely */
+ VECADDS(lF[spring->ij], lF[spring->ij], edgeunnormal, spring->restlen * factor);
- project_v3_v3v3(tmp, winvec[spring->kl], edgevec);
- sub_v3_v3v3(edgeunnormal, winvec[spring->kl], tmp);
- VECADDS(lF[spring->kl], lF[spring->kl], edgeunnormal, spring->restlen * factor);
+ project_v3_v3v3(tmp, winvec[spring->kl], edgevec);
+ sub_v3_v3v3(edgeunnormal, winvec[spring->kl], tmp);
+ VECADDS(lF[spring->kl], lF[spring->kl], edgeunnormal, spring->restlen * factor);
+ }
+
+ search = search->next;
}
+ }
- search = search->next;
- }
+ del_lfvector(winvec);
}
-
- del_lfvector(winvec);
}
// calculate spring forces
Index: source/blender/blenkernel/BKE_cloth.h
===================================================================
--- source/blender/blenkernel/BKE_cloth.h (revision 55292)
+++ source/blender/blenkernel/BKE_cloth.h (working copy)
@@ -108,6 +108,7 @@
float bend_stiff;
float shear_stiff;
int spring_count; /* how many springs attached? */
+ float shrink_factor; /* how much to shrink this cloth */
}
ClothVertex;
@@ -151,7 +152,8 @@
CLOTH_SIMSETTINGS_FLAG_TEARING = ( 1 << 4 ),// true if tearing is enabled
CLOTH_SIMSETTINGS_FLAG_SCALING = ( 1 << 8 ), /* is advanced scaling active? */
CLOTH_SIMSETTINGS_FLAG_CCACHE_EDIT = (1 << 12), /* edit cache in editmode */
- CLOTH_SIMSETTINGS_FLAG_NO_SPRING_COMPRESS = (1 << 13) /* don't allow spring compression */
+ CLOTH_SIMSETTINGS_FLAG_NO_SPRING_COMPRESS = (1 << 13), /* don't allow spring compression */
+ CLOTH_SIMSETTINGS_FLAG_SEW = (1 << 14), /* pull ends of loose edges together */
} CLOTH_SIMSETTINGS_FLAGS;
/* COLLISION FLAGS */
@@ -165,7 +167,8 @@
CLOTH_SPRING_TYPE_STRUCTURAL = (1 << 1),
CLOTH_SPRING_TYPE_SHEAR = (1 << 2),
CLOTH_SPRING_TYPE_BENDING = (1 << 3),
- CLOTH_SPRING_TYPE_GOAL = (1 << 4)
+ CLOTH_SPRING_TYPE_GOAL = (1 << 4),
+ CLOTH_SPRING_TYPE_SEWING = (1 << 5) // added by thesleepless@gmail.com for sewing edges
} CLOTH_SPRING_TYPES;
/* SPRING FLAGS */
Index: source/blender/makesdna/DNA_cloth_types.h
===================================================================
--- source/blender/makesdna/DNA_cloth_types.h (revision 55292)
+++ source/blender/makesdna/DNA_cloth_types.h (working copy)
@@ -58,6 +58,7 @@
float max_bend; /* max bending scaling value, min is "bending" */
float max_struct; /* max structural scaling value, min is "structural" */
float max_shear; /* max shear scaling value, UNUSED */
+ float max_sewing; /* max sewing force */
float avg_spring_len; /* used for normalized springs */
float timescale; /* parameter how fast cloth runs */
float maxgoal; /* see SB */
@@ -70,7 +71,15 @@
float velocity_smooth; /* smoothing of velocities for hair */
float collider_friction; /* friction with colliders */
float vel_damping; /* damp the velocity to speed up getting to the resting position */
+ float shrink_min; /* min amount to shrink cloth by 0.0f (no shrink) - 1.0f (shrink to nothing) */
+ float shrink_max; /* max amount to shrink cloth by 0.0f (no shrink) - 1.0f (shrink to nothing) */
+ /* some new properties */
+ float cloth_pressure; /* air pressure: the pressure differenct of inner and outer air. can be negative */
+ float init_volume; /* air pressure: inner air ammount */
+ float pressure_scale; /* air pressure: scaling factor:
+ pressure=(current_volume/init_volume+cloth_pressure)*pressure_scale */
+
int stepsPerFrame; /* Number of time steps per frame. */
int flags; /* flags, see CSIMSETT_FLAGS enum above. */
int preroll; /* How many frames of simulation to do before we start. */
@@ -79,10 +88,11 @@
short vgroup_bend; /* vertex group for scaling bending stiffness */
short vgroup_mass; /* optional vertexgroup name for assigning weight.*/
short vgroup_struct; /* vertex group for scaling structural stiffness */
+ short vgroup_shrink; /* vertex group for shrinking cloth */
short shapekey_rest; /* vertex group for scaling structural stiffness */
short presets; /* used for presets on GUI */
short reset;
- short pad;
+ char pad[8];
struct EffectorWeights *effector_weights;
} ClothSimSettings;
Index: source/blender/makesrna/intern/rna_cloth.c
===================================================================
--- source/blender/makesrna/intern/rna_cloth.c (revision 55292)
+++ source/blender/makesrna/intern/rna_cloth.c (working copy)
@@ -100,6 +100,17 @@
settings->max_struct = value;
}
+static void rna_ClothSettings_max_sewing_set(struct PointerRNA *ptr, float value)
+{
+ ClothSimSettings *settings = (ClothSimSettings*)ptr->data;
+
+ /* check for clipping */
+ if (value < 0.0f)
+ value = 0.0f;
+
+ settings->max_sewing = value;
+}
+
static void rna_ClothSettings_mass_vgroup_get(PointerRNA *ptr, char *value)
{
ClothSimSettings *sim = (ClothSimSettings *)ptr->data;
@@ -118,6 +129,24 @@
rna_object_vgroup_name_index_set(ptr, value, &sim->vgroup_mass);
}
+static void rna_ClothSettings_shrink_vgroup_get(PointerRNA *ptr, char *value)
+{
+ ClothSimSettings *sim = (ClothSimSettings*)ptr->data;
+ rna_object_vgroup_name_index_get(ptr, value, sim->vgroup_shrink);
+}
+
+static int rna_ClothSettings_shrink_vgroup_length(PointerRNA *ptr)
+{
+ ClothSimSettings *sim = (ClothSimSettings*)ptr->data;
+ return rna_object_vgroup_name_index_length(ptr, sim->vgroup_shrink);
+}
+
+static void rna_ClothSettings_shrink_vgroup_set(PointerRNA *ptr, const char *value)
+{
+ ClothSimSettings *sim = (ClothSimSettings*)ptr->data;
+ rna_object_vgroup_name_index_set(ptr, value, &sim->vgroup_shrink);
+}
+
static void rna_ClothSettings_struct_vgroup_get(PointerRNA *ptr, char *value)
{
ClothSimSettings *sim = (ClothSimSettings *)ptr->data;
@@ -337,6 +366,24 @@
"Quality of the simulation in steps per frame (higher is better quality but slower)");
RNA_def_property_update(prop, 0, "rna_cloth_update");
+ prop = RNA_def_property(srna, "vertex_group_shrink", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_funcs(prop, "rna_ClothSettings_shrink_vgroup_get", "rna_ClothSettings_shrink_vgroup_length",
+ "rna_ClothSettings_shrink_vgroup_set");
+ RNA_def_property_ui_text(prop, "Shrink Vertex Group", "Vertex Group for shrinking cloth");
+ RNA_def_property_update(prop, 0, "rna_cloth_update");
+
+ prop = RNA_def_property(srna, "shrink_min", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "shrink_min");
+ RNA_def_property_range(prop, -100.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Shrink Factor Min", "min amount to shrink cloth by 0.0 (no shrink) - 1.0 (shrink to nothing). negative values will expand the cloth");
+ RNA_def_property_update(prop, 0, "rna_cloth_update");
+
+ prop = RNA_def_property(srna, "shrink_max", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "shrink_max");
+ RNA_def_property_range(prop, -100.0f, 1.0f);
+ RNA_def_property_ui_text(prop, "Shrink Factor Max", "max amount to shrink cloth by 0.0 (no shrink) - 1.0 (shrink to nothing). negative values will expand the cloth");
+ RNA_def_property_update(prop, 0, "rna_cloth_update");
+
/* springs */
prop = RNA_def_property(srna, "use_stiffness_scale", PROP_BOOLEAN, PROP_NONE);
@@ -366,6 +413,13 @@
RNA_def_property_ui_text(prop, "Structural Stiffness Maximum", "Maximum structural stiffness value");
RNA_def_property_update(prop, 0, "rna_cloth_update");
+ prop = RNA_def_property(srna, "sewing_force_max", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "max_sewing");
+ RNA_def_property_range(prop, 0.0f, 10000.0f);
+ RNA_def_property_float_funcs(prop, NULL, "rna_ClothSettings_max_sewing_set", NULL);
+ RNA_def_property_ui_text(prop, "Sewing Force Maximum", "Maximum sewing force");
+ RNA_def_property_update(prop, 0, "rna_cloth_update");
+
prop = RNA_def_property(srna, "vertex_group_structural_stiffness", PROP_STRING, PROP_NONE);
RNA_def_property_string_funcs(prop, "rna_ClothSettings_struct_vgroup_get",
"rna_ClothSettings_struct_vgroup_length",
@@ -388,6 +442,11 @@
RNA_def_property_ui_text(prop, "Bending Stiffness Maximum", "Maximum bending stiffness value");
RNA_def_property_update(prop, 0, "rna_cloth_update");
+ prop = RNA_def_property(srna, "use_sewing_springs", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flags", CLOTH_SIMSETTINGS_FLAG_SEW);
+ RNA_def_property_ui_text(prop, "Sew Cloth", "Pulls loose edges together");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+
prop = RNA_def_property(srna, "vertex_group_bending", PROP_STRING, PROP_NONE);
RNA_def_property_string_funcs(prop, "rna_ClothSettings_bend_vgroup_get", "rna_ClothSettings_bend_vgroup_length",
"rna_ClothSettings_bend_vgroup_set");
@@ -457,6 +516,32 @@
RNA_def_property_range(prop, 1.0, 1000.0);
RNA_def_property_ui_text(prop, "Maximum Spring Extension", "Maximum extension before spring gets cut");
#endif
+
+ //new properties
+
+ prop = RNA_def_property(srna, "cloth_pressure", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "cloth_pressure");
+ RNA_def_property_range(prop, -10000.0f, 10000.0f);
+ RNA_def_property_float_default(prop, 0.0f);
+ RNA_def_property_ui_text(prop, "Pressure",
+ "The pressure difference of inner and outer air. Can be negative");
+ RNA_def_property_update(prop, 0, "rna_cloth_update");
+
+ prop = RNA_def_property(srna, "init_volume", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "init_volume");
+ RNA_def_property_range(prop, 0.0f, 10000.0f);
+ RNA_def_property_float_default(prop, 0.0f);
+ RNA_def_property_ui_text(prop, "Volume",
+ "Inner air amount (volume)");
+ RNA_def_property_update(prop, 0, "rna_cloth_update");
+
+ prop = RNA_def_property(srna, "pressure_scale", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "pressure_scale");
+ RNA_def_property_range(prop, 0.0f, 10000.0f);
+ RNA_def_property_float_default(prop, 1.0f);
+ RNA_def_property_ui_text(prop, "Pressure Scale",
+ "Air pressure scaling factor");
+ RNA_def_property_update(prop, 0, "rna_cloth_update");
}
static void rna_def_cloth_collision_settings(BlenderRNA *brna)

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
59/d4/9da8ceec686516b584ce61365069

Event Timeline