First successfull use of collision modifier. Means: Collision with cloth are enabled using the 'Deflection' panel from now on

This commit is contained in:
Daniel Genrich
2008-01-22 00:34:28 +00:00
parent 3759c772fd
commit 3db5a4e8dc
8 changed files with 191 additions and 189 deletions

View File

@@ -61,6 +61,47 @@ struct ClothModifierData;
#define CLOTH_MAX_THREAD 2
/**
* Pin and unpin frames are the frames on which the vertices stop moving.
* They will assume the position they had prior to pinFrame until unpinFrame
* is reached.
*/
typedef struct ClothVertex
{
int flags; /* General flags per vertex. */
float v [3]; /* The velocity of the point. */
float xconst [3]; /* constrained position */
float x [3]; /* The current position of this vertex. */
float xold [3]; /* The previous position of this vertex.*/
float tx [3]; /* temporary position */
float txold [3]; /* temporary old position */
float tv[3]; /* temporary "velocity", mostly used as tv = tx-txold */
float mass; /* mass / weight of the vertex */
float goal; /* goal, from SB */
float impulse[3]; /* used in collision.c */
unsigned int impulse_count; /* same as above */
}
ClothVertex;
/**
* The definition of a spring.
*/
typedef struct ClothSpring
{
int ij; /* Pij from the paper, one end of the spring. */
int kl; /* Pkl from the paper, one end of the spring. */
float restlen; /* The original length of the spring. */
int matrix_index; /* needed for implicit solver (fast lookup) */
int type; /* types defined in BKE_cloth.h ("springType") */
int flags; /* defined in BKE_cloth.h, e.g. deactivated due to tearing */
float dfdx[3][3];
float dfdv[3][3];
float f[3];
}
ClothSpring;
/* goal defines */
#define SOFTGOALSNAP 0.999f
@@ -161,7 +202,7 @@ typedef struct BVH
}
BVH;
typedef void ( *CM_COLLISION_RESPONSE ) ( ClothModifierData *clmd, ClothModifierData *coll_clmd, CollisionTree * tree1, CollisionTree * tree2 );
typedef void ( *CM_COLLISION_RESPONSE ) ( ClothModifierData *clmd, CollisionModifierData *collmd, CollisionTree * tree1, CollisionTree * tree2 );
/////////////////////////////////////////////////
@@ -191,7 +232,7 @@ void bvh_build (BVH *bvh);
LinkNode *BLI_linklist_append_fast ( LinkNode **listp, void *ptr );
// needed for collision.c
int bvh_traverse ( ClothModifierData * clmd, ClothModifierData * coll_clmd, CollisionTree * tree1, CollisionTree * tree2, float step, CM_COLLISION_RESPONSE collision_response );
int bvh_traverse ( ClothModifierData * clmd, CollisionModifierData * collmd, CollisionTree * tree1, CollisionTree * tree2, float step, CM_COLLISION_RESPONSE collision_response );
void bvh_update(BVH * bvh, int moving);
////////////////////////////////////////////////

View File

@@ -70,7 +70,11 @@
#include "Bullet-C-Api.h"
// step is limited from 0 (frame start position) to 1 (frame end position)
/***********************************
Collision modifier code start
***********************************/
/* step is limited from 0 (frame start position) to 1 (frame end position) */
void collision_move_object(CollisionModifierData *collmd, float step, float prevstep)
{
float tv[3] = {0,0,0};
@@ -85,6 +89,7 @@ void collision_move_object(CollisionModifierData *collmd, float step, float prev
}
}
/* build bounding volume hierarchy from mverts (see kdop.c for whole BVH code) */
BVH *bvh_build_from_mvert (MFace *mfaces, unsigned int numfaces, MVert *x, unsigned int numverts, float epsilon)
{
BVH *bvh=NULL;
@@ -137,6 +142,10 @@ void bvh_update_from_mvert(BVH * bvh, MVert *x, unsigned int numverts, MVert *xn
bvh_update(bvh, moving);
}
/***********************************
Collision modifier code end
***********************************/
/**
* gsl_poly_solve_cubic -
*
@@ -437,19 +446,18 @@ DO_INLINE void calculateFrictionImpulse(float to[3], float vrel[3], float normal
VecMulf(to, MAX2(1.0f - frictionConstant * delta_V_n / INPR(vrel_t_pre,vrel_t_pre), 0.0f));
}
int cloth_collision_response_static(ClothModifierData *clmd, ClothModifierData *coll_clmd)
int cloth_collision_response_static(ClothModifierData *clmd, CollisionModifierData *collmd)
{
unsigned int i = 0;
int result = 0;
LinkNode *search = NULL;
CollPair *collpair = NULL;
Cloth *cloth1, *cloth2;
Cloth *cloth1;
float w1, w2, w3, u1, u2, u3;
float v1[3], v2[3], relativeVelocity[3];
float magrelVel;
cloth1 = clmd->clothObject;
cloth2 = coll_clmd->clothObject;
search = clmd->coll_parms.collision_list;
@@ -463,17 +471,18 @@ int cloth_collision_response_static(ClothModifierData *clmd, ClothModifierData *
cloth1->verts[collpair->ap2].txold,
cloth1->verts[collpair->ap3].txold,
&w1, &w2, &w3);
// was: txold
cloth_compute_barycentric(collpair->pb,
cloth2->verts[collpair->bp1].txold,
cloth2->verts[collpair->bp2].txold,
cloth2->verts[collpair->bp3].txold,
collmd->current_x[collpair->bp1].co,
collmd->current_x[collpair->bp2].co,
collmd->current_x[collpair->bp3].co,
&u1, &u2, &u3);
// Calculate relative "velocity".
interpolateOnTriangle(v1, cloth1->verts[collpair->ap1].tv, cloth1->verts[collpair->ap2].tv, cloth1->verts[collpair->ap3].tv, w1, w2, w3);
interpolateOnTriangle(v2, cloth2->verts[collpair->bp1].tv, cloth2->verts[collpair->bp2].tv, cloth2->verts[collpair->bp3].tv, u1, u2, u3);
interpolateOnTriangle(v2, collmd->current_v[collpair->bp1].co, collmd->current_v[collpair->bp2].co, collmd->current_v[collpair->bp3].co, u1, u2, u3);
VECSUB(relativeVelocity, v1, v2);
@@ -575,21 +584,21 @@ int cloth_collision_response_static(ClothModifierData *clmd, ClothModifierData *
int cloth_collision_response_moving_tris(ClothModifierData *clmd, ClothModifierData *coll_clmd)
{
return 1;
}
int cloth_collision_response_moving_edges(ClothModifierData *clmd, ClothModifierData *coll_clmd)
{
return 1;
}
void cloth_collision_static(ClothModifierData *clmd, ClothModifierData *coll_clmd, CollisionTree *tree1, CollisionTree *tree2)
void cloth_collision_static(ClothModifierData *clmd, CollisionModifierData *collmd, CollisionTree *tree1, CollisionTree *tree2)
{
CollPair *collpair = NULL;
Cloth *cloth1=NULL, *cloth2=NULL;
Cloth *cloth1=NULL;
MFace *face1=NULL, *face2=NULL;
ClothVertex *verts1=NULL, *verts2=NULL;
ClothVertex *verts1=NULL;
double distance = 0;
float epsilon = clmd->coll_parms.epsilon;
unsigned int i = 0;
@@ -599,13 +608,11 @@ void cloth_collision_static(ClothModifierData *clmd, ClothModifierData *coll_clm
collpair = (CollPair *)MEM_callocN(sizeof(CollPair), "cloth coll pair");
cloth1 = clmd->clothObject;
cloth2 = coll_clmd->clothObject;
verts1 = cloth1->verts;
verts2 = cloth2->verts;
face1 = &(cloth1->mfaces[tree1->tri_index]);
face2 = &(cloth2->mfaces[tree2->tri_index]);
face2 = &(collmd->mfaces[tree2->tri_index]);
// check all possible pairs of triangles
if(i == 0)
@@ -674,7 +681,7 @@ void cloth_collision_static(ClothModifierData *clmd, ClothModifierData *coll_clm
{
// calc distance + normal
distance = plNearestPoints(
verts1[collpair->ap1].txold, verts1[collpair->ap2].txold, verts1[collpair->ap3].txold, verts2[collpair->bp1].txold, verts2[collpair->bp2].txold, verts2[collpair->bp3].txold, collpair->pa,collpair->pb,collpair->vector);
verts1[collpair->ap1].txold, verts1[collpair->ap2].txold, verts1[collpair->ap3].txold, collmd->current_x[collpair->bp1].co, collmd->current_x[collpair->bp2].co, collmd->current_x[collpair->bp3].co, collpair->pa,collpair->pb,collpair->vector);
if (distance <= (epsilon + ALMOST_ZERO))
{
@@ -688,6 +695,7 @@ void cloth_collision_static(ClothModifierData *clmd, ClothModifierData *coll_clm
collpair->distance = distance;
BLI_linklist_append(&clmd->coll_parms.collision_list, collpair);
}
else
{
@@ -703,8 +711,8 @@ void cloth_collision_static(ClothModifierData *clmd, ClothModifierData *coll_clm
int cloth_are_edges_adjacent(ClothModifierData *clmd, ClothModifierData *coll_clmd, EdgeCollPair *edgecollpair)
{
Cloth *cloth1, *cloth2;
ClothVertex *verts1, *verts2;
Cloth *cloth1 = NULL, *cloth2 = NULL;
ClothVertex *verts1 = NULL, *verts2 = NULL;
float temp[3];
cloth1 = clmd->clothObject;
@@ -1023,7 +1031,7 @@ void cloth_update_collision_objects(float step)
int cloth_bvh_objcollision(ClothModifierData * clmd, float step, float dt)
{
Base *base=NULL;
ClothModifierData *coll_clmd=NULL;
CollisionModifierData *collmd=NULL;
Cloth *cloth=NULL;
Object *coll_ob=NULL;
BVH *cloth_bvh=NULL;
@@ -1064,23 +1072,21 @@ int cloth_bvh_objcollision(ClothModifierData * clmd, float step, float dt)
for (base = G.scene->base.first; base; base = base->next)
{
coll_ob = base->object;
coll_clmd = (ClothModifierData *) modifiers_findByType (coll_ob, eModifierType_Cloth);
collmd = (CollisionModifierData *) modifiers_findByType (coll_ob, eModifierType_Collision);
if (!coll_clmd)
if (!collmd)
continue;
// if collision object go on
if (coll_clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_COLLOBJ)
if (collmd->tree)
{
if (coll_clmd->clothObject && coll_clmd->clothObject->tree)
{
BVH *coll_bvh = coll_clmd->clothObject->tree;
BVH *coll_bvh = collmd->tree;
collision_move_object(collmd, step + dt, step);
bvh_traverse(clmd, coll_clmd, cloth_bvh->root, coll_bvh->root, step, cloth_collision_static);
}
else
printf ("cloth_bvh_objcollision: found a collision object with clothObject or collData NULL.\n");
bvh_traverse(clmd, collmd, cloth_bvh->root, coll_bvh->root, step, cloth_collision_static);
}
else
printf ("cloth_bvh_objcollision: found a collision object with clothObject or collData NULL.\n");
}
// process all collisions (calculate impulses, TODO: also repulses if distance too short)
@@ -1094,18 +1100,11 @@ int cloth_bvh_objcollision(ClothModifierData * clmd, float step, float dt)
{
coll_ob = base->object;
coll_clmd = (ClothModifierData *) modifiers_findByType (coll_ob, eModifierType_Cloth);
if (!coll_clmd)
collmd = (CollisionModifierData *) modifiers_findByType (coll_ob, eModifierType_Collision);
if (!collmd)
continue;
// if collision object go on
if (coll_clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_COLLOBJ)
{
if (coll_clmd->clothObject)
result += cloth_collision_response_static(clmd, coll_clmd);
else
printf ("cloth_bvh_objcollision: found a collision object with clothObject or collData NULL.\n");
}
result += cloth_collision_response_static(clmd, collmd);
}
// apply impulses in parallel
@@ -1140,14 +1139,10 @@ int cloth_bvh_objcollision(ClothModifierData * clmd, float step, float dt)
clmd->coll_parms.collision_list = NULL;
}
// printf("ic: %d\n", ic);
rounds++;
}
while(result && (CLOTH_MAX_THRESHOLD>rounds));
// printf("\n");
////////////////////////////////////////////////////////////
// update positions
// this is needed for bvh_calc_DOP_hull_moving() [kdop.c]
@@ -1162,9 +1157,11 @@ int cloth_bvh_objcollision(ClothModifierData * clmd, float step, float dt)
////////////////////////////////////////////////////////////
// moving collisions
//
// response code is just missing itm
////////////////////////////////////////////////////////////
/*
// update cloth bvh
bvh_update_from_cloth(clmd, 1); // 0 means STATIC, 1 means MOVING
@@ -1294,7 +1291,6 @@ int cloth_bvh_objcollision(ClothModifierData * clmd, float step, float dt)
}
while(result && (CLOTH_MAX_THRESHOLD>rounds));
////////////////////////////////////////////////////////////
// update positions + velocities
////////////////////////////////////////////////////////////
@@ -1305,6 +1301,7 @@ int cloth_bvh_objcollision(ClothModifierData * clmd, float step, float dt)
VECADD(verts[i].tx, verts[i].txold, verts[i].tv);
}
////////////////////////////////////////////////////////////
*/
return MIN2(ret, 1);
}

View File

@@ -850,6 +850,7 @@ DO_INLINE float fbstar(float length, float L, float kb, float cb)
return tempfb;
}
// function to calculae bending spring force (taken from Choi & Co)
DO_INLINE float fbstar_jacobi(float length, float L, float kb, float cb)
{
float tempfb = kb * fb(length, L);
@@ -1331,7 +1332,7 @@ void simulate_implicit_euler(lfVector *Vnew, lfVector *lX, lfVector *lV, lfVecto
initdiag_bfmatrix(A, I);
zero_lfvector(dV, numverts);
subadd_bfmatrixS_bfmatrixS(A, dFdV, dt, dFdX, (dt*dt));
subadd_bfmatrixS_bfmatrixS(A, dFdV, dt, dFdX, (dt*dt));
mul_bfmatrix_lfvector(dFdXmV, dFdX, lV);

View File

@@ -670,7 +670,7 @@ DO_INLINE int bvh_overlap(float *bv1, float *bv2)
* every other triangle that doesn't require any realloc, but uses
* much memory
*/
int bvh_traverse(ClothModifierData * clmd, ClothModifierData * coll_clmd, CollisionTree * tree1, CollisionTree * tree2, float step, CM_COLLISION_RESPONSE collision_response)
int bvh_traverse ( ClothModifierData * clmd, CollisionModifierData * collmd, CollisionTree * tree1, CollisionTree * tree2, float step, CM_COLLISION_RESPONSE collision_response)
{
int i = 0, ret=0;
@@ -693,7 +693,7 @@ int bvh_traverse(ClothModifierData * clmd, ClothModifierData * coll_clmd, Collis
// Provide the collision response.
if(collision_response)
collision_response (clmd, coll_clmd, tree1, tree2);
collision_response (clmd, collmd, tree1, tree2);
return 1;
}
else
@@ -702,7 +702,7 @@ int bvh_traverse(ClothModifierData * clmd, ClothModifierData * coll_clmd, Collis
for (i = 0; i < 4; i++)
{
// Only traverse nodes that exist.
if (tree2->nodes[i] && bvh_traverse (clmd, coll_clmd, tree1, tree2->nodes[i], step, collision_response))
if (tree2->nodes[i] && bvh_traverse (clmd, collmd, tree1, tree2->nodes[i], step, collision_response))
ret = 1;
}
}
@@ -713,7 +713,7 @@ int bvh_traverse(ClothModifierData * clmd, ClothModifierData * coll_clmd, Collis
for (i = 0; i < 4; i++)
{
// Only traverse nodes that exist.
if (tree1->nodes [i] && bvh_traverse (clmd, coll_clmd, tree1->nodes[i], tree2, step, collision_response))
if (tree1->nodes [i] && bvh_traverse (clmd, collmd, tree1->nodes[i], tree2, step, collision_response))
ret = 1;
}
}

View File

@@ -5004,7 +5004,7 @@ static void clothModifier_updateDepgraph(
CustomDataMask clothModifier_requiredDataMask(ModifierData *md)
{
ClothModifierData *clmd = (HookModifierData *)md;
ClothModifierData *clmd = (ClothModifierData *)md;
CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
@@ -5067,6 +5067,9 @@ static void collisionModifier_freeData(ModifierData *md)
if(collmd->current_v)
MEM_freeN(collmd->current_v);
if(collmd->mfaces)
MEM_freeN(collmd->mfaces);
collmd->x = NULL;
collmd->xnew = NULL;
collmd->current_x = NULL;
@@ -5075,6 +5078,7 @@ static void collisionModifier_freeData(ModifierData *md)
collmd->time = -1;
collmd->numverts = 0;
collmd->tree = NULL;
collmd->mfaces = NULL;
}
}
@@ -5139,7 +5143,10 @@ static void collisionModifier_deformVerts(
// TODO: epsilon
// create bounding box hierarchy
collmd->tree = bvh_build_from_mvert(dm->getFaceArray(dm), dm->getNumFaces(dm), collmd->current_x, numverts, ob->pd->pdef_sbift);
collmd->tree = bvh_build_from_mvert(dm->getFaceArray(dm), dm->getNumFaces(dm), collmd->x, numverts, ob->pd->pdef_sbift);
collmd->mfaces = dm->dupFaceArray(dm);
collmd->numfaces = dm->getNumFaces(dm);
}
else if(numverts == collmd->numverts)
{
@@ -5156,8 +5163,8 @@ static void collisionModifier_deformVerts(
Mat4MulVecfl ( ob->obmat, collmd->xnew[i].co );
}
memcpy(collmd->current_xnew, dm->getVertArray(dm), numverts*sizeof(MVert));
memcpy(collmd->current_x, dm->getVertArray(dm), numverts*sizeof(MVert));
memcpy(collmd->current_xnew, collmd->x, numverts*sizeof(MVert));
memcpy(collmd->current_x, collmd->x, numverts*sizeof(MVert));
// recalc static bounding boxes
bvh_update_from_mvert(collmd->tree, collmd->current_x, numverts, NULL, 0);

View File

@@ -35,48 +35,6 @@
#include "DNA_listBase.h"
/**
* Pin and unpin frames are the frames on which the vertices stop moving.
* They will assume the position they had prior to pinFrame until unpinFrame
* is reached.
*/
typedef struct ClothVertex
{
int flags; /* General flags per vertex. */
float v [3]; /* The velocity of the point. */
float xconst [3]; /* constrained position */
float x [3]; /* The current position of this vertex. */
float xold [3]; /* The previous position of this vertex.*/
float tx [3]; /* temporary position */
float txold [3]; /* temporary old position */
float tv[3]; /* temporary "velocity", mostly used as tv = tx-txold */
float mass; /* mass / weight of the vertex */
float goal; /* goal, from SB */
float impulse[3]; /* used in collision.c */
unsigned int impulse_count; /* same as above */
}
ClothVertex;
/**
* The definition of a spring.
*/
typedef struct ClothSpring
{
int ij; /* Pij from the paper, one end of the spring. */
int kl; /* Pkl from the paper, one end of the spring. */
float restlen; /* The original length of the spring. */
int matrix_index; /* needed for implicit solver (fast lookup) */
int type; /* types defined in BKE_cloth.h ("springType") */
int flags; /* defined in BKE_cloth.h, e.g. deactivated due to tearing */
float dfdx[3][3];
float dfdv[3][3];
float f[3];
}
ClothSpring;
/**
* This struct contains all the global data required to run a simulation.
* At the time of this writing, this structure contains data appropriate

View File

@@ -354,15 +354,20 @@ typedef struct ClothModifierData {
} ClothModifierData;
typedef struct CollisionModifierData {
ModifierData modifier;
ModifierData modifier;
struct MVert *x; /* position at the beginning of the frame */
struct MVert *xnew; /* position at the end of the frame */
struct MVert *xold; /* unsued atm, but was discussed during sprint */
struct MVert *current_xnew; /* new position at the actual inter-frame step */
struct MVert *current_x; /* position at the actual inter-frame step */
struct MVert *current_v; /* position at the actual inter-frame step */
struct MFace *mfaces; /* object face data */
unsigned int numverts;
unsigned int numfaces;
int pad;
float time;
struct BVH *tree; /* collision tree for this cloth object */
} CollisionModifierData;

View File

@@ -4941,101 +4941,94 @@ static void object_panel_cloth(Object *ob)
if(clmd)
{
but = uiDefButBitI(block, TOG, CLOTH_SIMSETTINGS_FLAG_COLLOBJ, B_EFFECT_DEP, "Collision Object", 170,200,130,20, &clmd->sim_parms.flags, 0, 0, 0, 0, "Sets object to become a cloth collision object");
Cloth *cloth = clmd->clothObject;
int defCount;
char *clvg1, *clvg2;
char clmvg [] = "Weight Paint Groups%t|";
if (!(clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_COLLOBJ))
val2=0;
/* GENERAL STUFF */
uiClearButLock();
uiBlockBeginAlign(block);
uiDefButF(block, NUM, B_CLOTH_RENEW, "StructStiff:", 10,170,150,20, &clmd->sim_parms.structural, 1.0, 10000.0, 100, 0, "Overall stiffness of structure");
uiDefButF(block, NUM, B_CLOTH_RENEW, "BendStiff:", 160,170,150,20, &clmd->sim_parms.bending, 0.0, 10000.0, 1000, 0, "Wrinkle coefficient (higher = less smaller but more big wrinkles)");
uiDefButI(block, NUM, B_CLOTH_RENEW, "Quality:", 10,150,150,20, &clmd->sim_parms.stepsPerFrame, 1.0, 100.0, 5, 0, "Quality of the simulation (higher=better=slower)");
uiBlockEndAlign(block);
uiBlockBeginAlign(block);
uiDefButF(block, NUM, B_CLOTH_RENEW, "Spring Damp:", 160,150,150,20, &clmd->sim_parms.Cdis, 0.0, 10.0, 10, 0, "Spring damping");
uiDefButF(block, NUM, B_DIFF, "Air Damp:", 10,130,150,20, &clmd->sim_parms.Cvi, 0.0, 10.0, 10, 0, "Air has normaly some thickness which slows falling things down");
uiBlockEndAlign(block);
uiClearButLock();
uiBlockBeginAlign(block);
uiDefBut(block, LABEL, 0, "Gravity:", 10,100,60,20, NULL, 0.0, 0, 0, 0, "");
// uiClearButLock();
uiDefButF(block, NUM, B_CLOTH_RENEW, "X:", 70,100,80,20, &clmd->sim_parms.gravity[0], -100.0, 100.0, 10, 0, "Apply gravitation to point movement");
uiDefButF(block, NUM, B_CLOTH_RENEW, "Y:", 150,100,80,20, &clmd->sim_parms.gravity[1], -100.0, 100.0, 10, 0, "Apply gravitation to point movement");
uiDefButF(block, NUM, B_CLOTH_RENEW, "Z:", 230,100,80,20, &clmd->sim_parms.gravity[2], -100.0, 100.0, 10, 0, "Apply gravitation to point movement");
uiBlockEndAlign(block);
/* GOAL STUFF */
uiBlockBeginAlign(block);
uiDefButBitI(block, TOG, CLOTH_SIMSETTINGS_FLAG_GOAL, REDRAWVIEW3D, "Pinning of cloth", 10,70,150,20, &clmd->sim_parms.flags, 0, 0, 0, 0, "Define forces for vertices to stick to animated position");
if (clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_GOAL)
{
Cloth *cloth = clmd->clothObject;
int defCount;
char *clvg1, *clvg2;
char clmvg [] = "Weight Paint Groups%t|";
val2=0;
// uiDefButBitI(block, TOG, CSIMSETT_FLAG_ADVANCED, REDRAWBUTSOBJECT, "Advanced", 180,200,130,20, &clmd->sim_parms.flags, 0, 0, 0, 0, "Enable advanced mode");
/* GENERAL STUFF */
uiClearButLock();
uiBlockBeginAlign(block);
uiDefButF(block, NUM, B_CLOTH_RENEW, "StructStiff:", 10,170,150,20, &clmd->sim_parms.structural, 1.0, 10000.0, 100, 0, "Overall stiffness of structure");
uiDefButF(block, NUM, B_CLOTH_RENEW, "BendStiff:", 160,170,150,20, &clmd->sim_parms.bending, 0.0, 10000.0, 1000, 0, "Wrinkle coefficient (higher = less smaller but more big wrinkles)");
uiDefButI(block, NUM, B_CLOTH_RENEW, "Quality:", 10,150,150,20, &clmd->sim_parms.stepsPerFrame, 1.0, 100.0, 5, 0, "Quality of the simulation (higher=better=slower)");
uiBlockEndAlign(block);
uiBlockBeginAlign(block);
uiDefButF(block, NUM, B_CLOTH_RENEW, "Spring Damp:", 160,150,150,20, &clmd->sim_parms.Cdis, 0.0, 10.0, 10, 0, "Spring damping");
uiDefButF(block, NUM, B_DIFF, "Air Damp:", 10,130,150,20, &clmd->sim_parms.Cvi, 0.0, 10.0, 10, 0, "Air has normaly some thickness which slows falling things down");
uiBlockEndAlign(block);
uiClearButLock();
uiBlockBeginAlign(block);
uiDefBut(block, LABEL, 0, "Gravity:", 10,100,60,20, NULL, 0.0, 0, 0, 0, "");
// uiClearButLock();
uiDefButF(block, NUM, B_CLOTH_RENEW, "X:", 70,100,80,20, &clmd->sim_parms.gravity[0], -100.0, 100.0, 10, 0, "Apply gravitation to point movement");
uiDefButF(block, NUM, B_CLOTH_RENEW, "Y:", 150,100,80,20, &clmd->sim_parms.gravity[1], -100.0, 100.0, 10, 0, "Apply gravitation to point movement");
uiDefButF(block, NUM, B_CLOTH_RENEW, "Z:", 230,100,80,20, &clmd->sim_parms.gravity[2], -100.0, 100.0, 10, 0, "Apply gravitation to point movement");
uiBlockEndAlign(block);
/* GOAL STUFF */
uiBlockBeginAlign(block);
uiDefButBitI(block, TOG, CLOTH_SIMSETTINGS_FLAG_GOAL, REDRAWVIEW3D, "Pinning of cloth", 10,70,150,20, &clmd->sim_parms.flags, 0, 0, 0, 0, "Define forces for vertices to stick to animated position");
if (clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_GOAL)
if(ob->type==OB_MESH)
{
if(ob->type==OB_MESH)
{
defCount = sizeof (clmvg);
clvg1 = get_vertexgroup_menustr (ob);
clvg2 = MEM_callocN (strlen (clvg1) + 1 + defCount, "clothVgMS");
if (! clvg2) {
printf ("draw_modifier: error allocating memory for cloth vertex group menu string.\n");
return;
}
defCount = BLI_countlist (&ob->defbase);
if (defCount == 0)
{
clmd->sim_parms.vgroup_mass = 0;
}
else
if(!clmd->sim_parms.vgroup_mass)
clmd->sim_parms.vgroup_mass = 1;
sprintf (clvg2, "%s%s", clmvg, clvg1);
uiDefButS(block, MENU, B_CLOTH_RENEW, clvg2, 160,70,150,20, &clmd->sim_parms.vgroup_mass, 0, defCount, 0, 0, "Browses available vertex groups");
MEM_freeN (clvg1);
MEM_freeN (clvg2);
}
else
{
uiDefButS(block, TOG, B_CLOTH_RENEW, "W", 140,70,20,20, &clmd->sim_parms.vgroup_mass, 0, 1, 0, 0, "Use control point weight values");
uiDefButF(block, NUM, B_CLOTH_RENEW, "Goal:", 160,70,150,20, &clmd->sim_parms.defgoal, 0.0, 1.0, 10, 0, "Default Goal (vertex target position) value, when no Vertex Group used");
}
uiDefButF(block, NUM, B_CLOTH_RENEW, "Pin Stiff:", 10,50,150,20, &clmd->sim_parms.goalspring, 0.0, 500.0, 10, 0, "Pin (vertex target position) spring stiffness");
/*
// nobody is changing these ones anyway
uiDefButF(block, NUM, B_CLOTH_RENEW, "G Damp:", 160,50,150,20, &clmd->sim_parms.goalfrict , 0.0, 50.0, 10, 0, "Goal (vertex target position) friction");
uiDefButF(block, NUM, B_CLOTH_RENEW, "G Min:", 10,30,150,20, &clmd->sim_parms.mingoal, 0.0, 1.0, 10, 0, "Goal minimum, vertex group weights are scaled to match this range");
uiDefButF(block, NUM, B_CLOTH_RENEW, "G Max:", 160,30,150,20, &clmd->sim_parms.maxgoal, 0.0, 1.0, 10, 0, "Goal maximum, vertex group weights are scaled to match this range");
*/
defCount = sizeof (clmvg);
clvg1 = get_vertexgroup_menustr (ob);
clvg2 = MEM_callocN (strlen (clvg1) + 1 + defCount, "clothVgMS");
if (! clvg2) {
printf ("draw_modifier: error allocating memory for cloth vertex group menu string.\n");
return;
}
defCount = BLI_countlist (&ob->defbase);
if (defCount == 0)
{
clmd->sim_parms.vgroup_mass = 0;
}
else
if(!clmd->sim_parms.vgroup_mass)
clmd->sim_parms.vgroup_mass = 1;
sprintf (clvg2, "%s%s", clmvg, clvg1);
uiDefButS(block, MENU, B_CLOTH_RENEW, clvg2, 160,70,150,20, &clmd->sim_parms.vgroup_mass, 0, defCount, 0, 0, "Browses available vertex groups");
MEM_freeN (clvg1);
MEM_freeN (clvg2);
}
uiBlockEndAlign(block);
/*
// no tearing supported anymore since modifier stack restrictions
uiBlockBeginAlign(block);
uiDefButBitI(block, TOG, CSIMSETT_FLAG_TEARING_ENABLED, B_EFFECT_DEP, "Tearing", 10,0,150,20, &clmd->sim_parms.flags, 0, 0, 0, 0, "Sets object to become a cloth collision object");
if (clmd->sim_parms.flags & CSIMSETT_FLAG_TEARING_ENABLED)
else
{
uiDefButI(block, NUM, B_DIFF, "Max extent:", 160,0,150,20, &clmd->sim_parms.maxspringlen, 1.0, 1000.0, 10, 0, "Maximum extension before spring gets cut");
}
uiDefButS(block, TOG, B_CLOTH_RENEW, "W", 140,70,20,20, &clmd->sim_parms.vgroup_mass, 0, 1, 0, 0, "Use control point weight values");
uiDefButF(block, NUM, B_CLOTH_RENEW, "Goal:", 160,70,150,20, &clmd->sim_parms.defgoal, 0.0, 1.0, 10, 0, "Default Goal (vertex target position) value, when no Vertex Group used");
}
uiBlockEndAlign(block);
uiDefButF(block, NUM, B_CLOTH_RENEW, "Pin Stiff:", 10,50,150,20, &clmd->sim_parms.goalspring, 0.0, 500.0, 10, 0, "Pin (vertex target position) spring stiffness");
/*
// nobody is changing these ones anyway
uiDefButF(block, NUM, B_CLOTH_RENEW, "G Damp:", 160,50,150,20, &clmd->sim_parms.goalfrict , 0.0, 50.0, 10, 0, "Goal (vertex target position) friction");
uiDefButF(block, NUM, B_CLOTH_RENEW, "G Min:", 10,30,150,20, &clmd->sim_parms.mingoal, 0.0, 1.0, 10, 0, "Goal minimum, vertex group weights are scaled to match this range");
uiDefButF(block, NUM, B_CLOTH_RENEW, "G Max:", 160,30,150,20, &clmd->sim_parms.maxgoal, 0.0, 1.0, 10, 0, "Goal maximum, vertex group weights are scaled to match this range");
*/
}
uiBlockEndAlign(block);
/*
// no tearing supported anymore since modifier stack restrictions
uiBlockBeginAlign(block);
uiDefButBitI(block, TOG, CSIMSETT_FLAG_TEARING_ENABLED, B_EFFECT_DEP, "Tearing", 10,0,150,20, &clmd->sim_parms.flags, 0, 0, 0, 0, "Sets object to become a cloth collision object");
if (clmd->sim_parms.flags & CSIMSETT_FLAG_TEARING_ENABLED)
{
uiDefButI(block, NUM, B_DIFF, "Max extent:", 160,0,150,20, &clmd->sim_parms.maxspringlen, 1.0, 1000.0, 10, 0, "Maximum extension before spring gets cut");
}
uiBlockEndAlign(block);
*/
}
}