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
diff options
context:
space:
mode:
-rw-r--r--source/blender/blenkernel/BKE_cloth.h109
-rw-r--r--source/blender/blenkernel/BKE_modifier.h2
-rw-r--r--source/blender/blenkernel/intern/cloth.c136
-rw-r--r--source/blender/blenkernel/intern/collision.c95
-rw-r--r--source/blender/blenkernel/intern/implicit.c43
-rw-r--r--source/blender/blenkernel/intern/modifier.c55
-rw-r--r--source/blender/blenloader/intern/readfile.c36
-rw-r--r--source/blender/blenloader/intern/writefile.c15
-rw-r--r--source/blender/makesdna/DNA_cloth_types.h5
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h6
-rw-r--r--source/blender/src/buttons_object.c202
11 files changed, 291 insertions, 413 deletions
diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h
index 6ad9893d072..cb52e2f3ca0 100644
--- a/source/blender/blenkernel/BKE_cloth.h
+++ b/source/blender/blenkernel/BKE_cloth.h
@@ -35,6 +35,7 @@
#define BKE_CLOTH_H
#include "BLI_linklist.h"
+#include "BKE_collision.h"
#include "BKE_customdata.h"
#include "BKE_DerivedMesh.h"
#include "DNA_cloth_types.h"
@@ -48,7 +49,7 @@ struct Cloth;
struct MFace;
struct DerivedMesh;
struct ClothModifierData;
-
+struct CollisionTree;
// this is needed for inlining behaviour
#ifndef _WIN32
@@ -60,7 +61,6 @@ 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
@@ -169,40 +169,7 @@ void implicit_set_positions ( ClothModifierData *clmd );
// from cloth.c, needed for modifier.c
void clothModifier_do ( ClothModifierData *clmd, Object *ob, DerivedMesh *dm, float ( *vertexCos ) [3], int numverts );
-// used in collision.c
-typedef struct CollisionTree
-{
- struct CollisionTree *nodes[4]; // 4 children --> quad-tree
- struct CollisionTree *parent;
- struct CollisionTree *nextLeaf;
- struct CollisionTree *prevLeaf;
- float bv[26]; // Bounding volume of all nodes / we have 7 axes on a 14-DOP
- unsigned int tri_index; // this saves the index of the face
- // int point_index[4]; // supports up to 4 points in a leaf
- int count_nodes; // how many nodes are used
- int traversed; // how many nodes already traversed until this level?
- int isleaf;
-}
-CollisionTree;
-
-typedef struct BVH
-{
- unsigned int numfaces;
- unsigned int numverts;
- // ClothVertex *verts; // just a pointer to the original datastructure
- MVert *current_x; // e.g. txold in clothvertex
- MVert *current_xold; // e.g. tx in clothvertex
- MFace *mfaces; // just a pointer to the original datastructure
- struct LinkNode *tree;
- CollisionTree *root; // TODO: saving the root --> is this really needed? YES!
- CollisionTree *leaf_tree; /* Tail of the leaf linked list. */
- CollisionTree *leaf_root; /* Head of the leaf linked list. */
- float epsilon; /* epslion is used for inflation of the k-dop */
- int flags; /* bvhFlags */
-}
-BVH;
-
-typedef void ( *CM_COLLISION_RESPONSE ) ( ClothModifierData *clmd, CollisionModifierData *collmd, CollisionTree * tree1, CollisionTree * tree2 );
+typedef void ( *CM_COLLISION_RESPONSE ) ( ClothModifierData *clmd, CollisionModifierData *collmd, CollisionTree *tree1, CollisionTree *tree2 );
/////////////////////////////////////////////////
@@ -213,31 +180,21 @@ typedef void ( *CM_COLLISION_RESPONSE ) ( ClothModifierData *clmd, CollisionModi
void bvh_collision_response ( ClothModifierData *clmd, ClothModifierData *coll_clmd, CollisionTree * tree1, CollisionTree * tree2 );
int cloth_bvh_objcollision ( ClothModifierData * clmd, float step, float dt );
-// needed for modifier.c
-BVH *bvh_build_from_mvert (MFace *mfaces, unsigned int numfaces, MVert *x, unsigned int numverts, float epsilon);
-
-// needed for collision.c
-void bvh_update_from_mvert(BVH * bvh, MVert *x, unsigned int numverts, MVert *xnew, int moving);
-
+int bvh_traverse ( ClothModifierData * clmd, CollisionModifierData * collmd, CollisionTree * tree1, CollisionTree * tree2, float step, CM_COLLISION_RESPONSE collision_response );
////////////////////////////////////////////////
-/////////////////////////////////////////////////
-// kdop.c
////////////////////////////////////////////////
-
+// implicit.c
+////////////////////////////////////////////////
+
// needed for cloth.c
-void bvh_free ( BVH * bvh );
-void bvh_build (BVH *bvh);
-LinkNode *BLI_linklist_append_fast ( LinkNode **listp, void *ptr );
-
-// needed for collision.c
-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);
+int implicit_init ( Object *ob, ClothModifierData *clmd );
+int implicit_free ( ClothModifierData *clmd );
+int implicit_solver ( Object *ob, float frame, ClothModifierData *clmd, ListBase *effectors );
////////////////////////////////////////////////
-
/////////////////////////////////////////////////
// cloth.c
////////////////////////////////////////////////
@@ -276,12 +233,6 @@ typedef struct
}
CM_SOLVER_DEF;
-
-/* new C implicit simulator */
-int implicit_init ( Object *ob, ClothModifierData *clmd );
-int implicit_free ( ClothModifierData *clmd );
-int implicit_solver ( Object *ob, float frame, ClothModifierData *clmd, ListBase *effectors );
-
/* used for caching in implicit.c */
typedef struct Frame
{
@@ -292,45 +243,5 @@ typedef struct Frame
}
Frame;
-/* used for collisions in collision.c */
-typedef struct CollPair
-{
- unsigned int face1; // cloth face
- unsigned int face2; // object face
- double distance; // magnitude of vector
- float normal[3];
- float vector[3]; // unnormalized collision vector: p2-p1
- float pa[3], pb[3]; // collision point p1 on face1, p2 on face2
- int lastsign; // indicates if the distance sign has changed, unused itm
- float time; // collision time, from 0 up to 1
- unsigned int ap1, ap2, ap3, bp1, bp2, bp3, bp4;
- unsigned int pointsb[4];
-}
-CollPair;
-
-/* used for collisions in collision.c */
-typedef struct EdgeCollPair
-{
- unsigned int p11, p12, p21, p22;
- float normal[3];
- float vector[3];
- float time;
- int lastsign;
- float pa[3], pb[3]; // collision point p1 on face1, p2 on face2
-}
-EdgeCollPair;
-
-/* used for collisions in collision.c */
-typedef struct FaceCollPair
-{
- unsigned int p11, p12, p13, p21;
- float normal[3];
- float vector[3];
- float time;
- int lastsign;
- float pa[3], pb[3]; // collision point p1 on face1, p2 on face2
-}
-FaceCollPair;
-
#endif
diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h
index 682eb1a00dd..068190cb6fa 100644
--- a/source/blender/blenkernel/BKE_modifier.h
+++ b/source/blender/blenkernel/BKE_modifier.h
@@ -287,7 +287,7 @@ int modifiers_getCageIndex(struct Object *ob,
int *lastPossibleCageIndex_r);
int modifiers_isSoftbodyEnabled(struct Object *ob);
-ModifierData * modifiers_isClothEnabled(Object *ob);
+ClothModifierData * modifiers_isClothEnabled(Object *ob);
int modifiers_isParticleEnabled(struct Object *ob);
struct Object *modifiers_isDeformedByArmature(struct Object *ob);
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 3fa99279435..1b284d0d35a 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -141,46 +141,46 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm, short
* 2. fill object with standard values or with the GUI settings if given
*/
void cloth_init ( ClothModifierData *clmd )
-{
+{
/* Initialize our new data structure to reasonable values. */
- clmd->sim_parms.gravity [0] = 0.0;
- clmd->sim_parms.gravity [1] = 0.0;
- clmd->sim_parms.gravity [2] = -9.81;
- clmd->sim_parms.structural = 100.0;
- clmd->sim_parms.shear = 100.0;
- clmd->sim_parms.bending = 1.0;
- clmd->sim_parms.Cdis = 5.0;
- clmd->sim_parms.Cvi = 1.0;
- clmd->sim_parms.mass = 1.0f;
- clmd->sim_parms.stepsPerFrame = 5;
- clmd->sim_parms.sim_time = 1.0;
- clmd->sim_parms.flags = CLOTH_SIMSETTINGS_FLAG_RESET;
- clmd->sim_parms.solver_type = 0;
- clmd->sim_parms.preroll = 0;
- clmd->sim_parms.maxspringlen = 10;
- clmd->sim_parms.firstframe = 1;
- clmd->sim_parms.lastframe = 250;
- clmd->sim_parms.vgroup_mass = 0;
- clmd->coll_parms.self_friction = 5.0;
- clmd->coll_parms.friction = 10.0;
- clmd->coll_parms.loop_count = 1;
- clmd->coll_parms.epsilon = 0.01f;
- clmd->coll_parms.flags = 0;
+ clmd->sim_parms->gravity [0] = 0.0;
+ clmd->sim_parms->gravity [1] = 0.0;
+ clmd->sim_parms->gravity [2] = -9.81;
+ clmd->sim_parms->structural = 100.0;
+ clmd->sim_parms->shear = 100.0;
+ clmd->sim_parms->bending = 1.0;
+ clmd->sim_parms->Cdis = 5.0;
+ clmd->sim_parms->Cvi = 1.0;
+ clmd->sim_parms->mass = 1.0f;
+ clmd->sim_parms->stepsPerFrame = 5;
+ clmd->sim_parms->sim_time = 1.0;
+ clmd->sim_parms->flags = CLOTH_SIMSETTINGS_FLAG_RESET;
+ clmd->sim_parms->solver_type = 0;
+ clmd->sim_parms->preroll = 0;
+ clmd->sim_parms->maxspringlen = 10;
+ clmd->sim_parms->firstframe = 1;
+ clmd->sim_parms->lastframe = 250;
+ clmd->sim_parms->vgroup_mass = 0;
+ clmd->coll_parms->self_friction = 5.0;
+ clmd->coll_parms->friction = 10.0;
+ clmd->coll_parms->loop_count = 1;
+ clmd->coll_parms->epsilon = 0.01f;
+ clmd->coll_parms->flags = 0;
/* These defaults are copied from softbody.c's
* softbody_calc_forces() function.
*/
- clmd->sim_parms.eff_force_scale = 1000.0;
- clmd->sim_parms.eff_wind_scale = 250.0;
+ clmd->sim_parms->eff_force_scale = 1000.0;
+ clmd->sim_parms->eff_wind_scale = 250.0;
// also from softbodies
- clmd->sim_parms.maxgoal = 1.0f;
- clmd->sim_parms.mingoal = 0.0f;
- clmd->sim_parms.defgoal = 0.0f;
- clmd->sim_parms.goalspring = 100.0f;
- clmd->sim_parms.goalfrict = 0.0f;
+ clmd->sim_parms->maxgoal = 1.0f;
+ clmd->sim_parms->mingoal = 0.0f;
+ clmd->sim_parms->defgoal = 0.0f;
+ clmd->sim_parms->goalspring = 100.0f;
+ clmd->sim_parms->goalfrict = 0.0f;
- clmd->sim_parms.cache = NULL;
+ clmd->sim_parms->cache = NULL;
}
@@ -488,7 +488,7 @@ void cloth_clear_cache(Object *ob, ClothModifierData *clmd, float framenr)
{
int stack_index = -1;
- if(!(clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_CCACHE_PROTECT))
+ if(!(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_CCACHE_PROTECT))
{
stack_index = modifiers_indexInObject(ob, (ModifierData *)clmd);
@@ -557,7 +557,7 @@ static int cloth_read_cache(Object *ob, ClothModifierData *clmd, float framenr)
fclose(fp);
}
- if(clmd->sim_parms.solver_type == 0)
+ if(clmd->sim_parms->solver_type == 0)
implicit_set_positions(clmd);
return ret;
@@ -585,21 +585,21 @@ void clothModifier_do ( ClothModifierData *clmd, Object *ob, DerivedMesh *dm,
ClothVertex *newframe= NULL, *verts;
Frame *frame = NULL;
LinkNode *search = NULL;
- float deltaTime = current_time - clmd->sim_parms.sim_time;
+ float deltaTime = current_time - clmd->sim_parms->sim_time;
- clmd->sim_parms.ob = ob;
+ clmd->sim_parms->ob = ob;
// only be active during a specific period:
// that's "first frame" and "last frame" on GUI
/*
- if ( ! ( clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_COLLOBJ ) )
+ if ( ! ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_COLLOBJ ) )
{
if ( clmd->clothObject )
{
- if ( clmd->sim_parms.cache )
+ if ( clmd->sim_parms->cache )
{
- if ( current_time < clmd->sim_parms.firstframe )
+ if ( current_time < clmd->sim_parms->firstframe )
{
int frametime = cloth_cache_first_frame ( clmd );
if ( cloth_cache_search_frame ( clmd, frametime ) )
@@ -609,7 +609,7 @@ void clothModifier_do ( ClothModifierData *clmd, Object *ob, DerivedMesh *dm,
}
return;
}
- else if ( current_time > clmd->sim_parms.lastframe )
+ else if ( current_time > clmd->sim_parms->lastframe )
{
int frametime = cloth_cache_last_frame ( clmd );
if ( cloth_cache_search_frame ( clmd, frametime ) )
@@ -626,7 +626,7 @@ void clothModifier_do ( ClothModifierData *clmd, Object *ob, DerivedMesh *dm,
cloth_cache_get_frame ( clmd, framenr );
cloth_to_object ( ob, clmd, vertexCos, numverts );
}
- clmd->sim_parms.sim_time = current_time;
+ clmd->sim_parms->sim_time = current_time;
return;
}
}
@@ -636,28 +636,28 @@ void clothModifier_do ( ClothModifierData *clmd, Object *ob, DerivedMesh *dm,
*/
// unused in the moment, calculated seperately in implicit.c
- clmd->sim_parms.dt = 1.0f / clmd->sim_parms.stepsPerFrame;
+ clmd->sim_parms->dt = 1.0f / clmd->sim_parms->stepsPerFrame;
- clmd->sim_parms.sim_time = current_time;
+ clmd->sim_parms->sim_time = current_time;
// check if cloth object was some collision object before and needs freeing now
- if ( ! ( clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_COLLOBJ ) && ( clmd->clothObject != NULL ) && ( clmd->clothObject->old_solver_type == 255 ) )
+ if ( ! ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_COLLOBJ ) && ( clmd->clothObject != NULL ) && ( clmd->clothObject->old_solver_type == 255 ) )
{
// temporary set CSIMSETT_FLAG_COLLOBJ flag for proper freeing
- clmd->sim_parms.flags |= CLOTH_SIMSETTINGS_FLAG_COLLOBJ;
+ clmd->sim_parms->flags |= CLOTH_SIMSETTINGS_FLAG_COLLOBJ;
cloth_free_modifier ( clmd );
- clmd->sim_parms.flags &= ~CLOTH_SIMSETTINGS_FLAG_COLLOBJ;
+ clmd->sim_parms->flags &= ~CLOTH_SIMSETTINGS_FLAG_COLLOBJ;
}
// This is for collisions objects: check special case CSIMSETT_FLAG_COLLOBJ
- if ( clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_COLLOBJ )
+ if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_COLLOBJ )
{
// save next position + time
if ( ( clmd->clothObject == NULL ) || ( numverts != clmd->clothObject->numverts ) )
{
if ( !collobj_from_object ( ob, clmd, dm, vertexCos, framenr ) )
{
- clmd->sim_parms.flags |= CLOTH_SIMSETTINGS_FLAG_COLLOBJ;
+ clmd->sim_parms->flags |= CLOTH_SIMSETTINGS_FLAG_COLLOBJ;
cloth_free_modifier ( clmd );
return;
}
@@ -669,8 +669,8 @@ void clothModifier_do ( ClothModifierData *clmd, Object *ob, DerivedMesh *dm,
}
// Save old position
- clmd->sim_parms.sim_time_old = clmd->sim_parms.sim_time;
- clmd->sim_parms.sim_time = current_time;
+ clmd->sim_parms->sim_time_old = clmd->sim_parms->sim_time;
+ clmd->sim_parms->sim_time = current_time;
verts = cloth->verts;
@@ -707,7 +707,7 @@ void clothModifier_do ( ClothModifierData *clmd, Object *ob, DerivedMesh *dm,
cloth = clmd->clothObject;
}
- clmd->clothObject->old_solver_type = clmd->sim_parms.solver_type;
+ clmd->clothObject->old_solver_type = clmd->sim_parms->solver_type;
// Insure we have a clmd->clothObject, in case allocation failed.
if ( clmd->clothObject != NULL )
@@ -731,8 +731,8 @@ void clothModifier_do ( ClothModifierData *clmd, Object *ob, DerivedMesh *dm,
tstart();
// Call the solver.
- if ( solvers [clmd->sim_parms.solver_type].solver )
- solvers [clmd->sim_parms.solver_type].solver ( ob, framenr, clmd, effectors );
+ if ( solvers [clmd->sim_parms->solver_type].solver )
+ solvers [clmd->sim_parms->solver_type].solver ( ob, framenr, clmd, effectors );
tend();
// printf ( "Cloth simulation time: %f\n", ( float ) tval() );
@@ -749,7 +749,7 @@ void clothModifier_do ( ClothModifierData *clmd, Object *ob, DerivedMesh *dm,
cloth_to_object ( ob, clmd, vertexCos, numverts );
// bvh_free(clmd->clothObject->tree);
- // clmd->clothObject->tree = bvh_build(clmd, clmd->coll_parms.epsilon);
+ // clmd->clothObject->tree = bvh_build(clmd, clmd->coll_parms->epsilon);
}
}
@@ -772,14 +772,14 @@ void clothModifier_do ( ClothModifierData *clmd, Object *ob, DerivedMesh *dm,
void cloth_free_modifier ( ClothModifierData *clmd )
{
Cloth *cloth = NULL;
- Object *ob = clmd->sim_parms.ob;
+ Object *ob = clmd->sim_parms->ob;
if ( !clmd )
return;
cloth = clmd->clothObject;
- if ( ! ( clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_CCACHE_PROTECT ) )
+ if ( ! ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_CCACHE_PROTECT ) )
{
if ( cloth )
{
@@ -898,7 +898,7 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm, short
for ( i = 0; i < numverts; i++, verts++ )
{
// LATER ON, support also mass painting here
- if ( clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_GOAL )
+ if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL )
{
dvert = dm->getVertData ( dm, i, CD_MDEFORMVERT );
if ( dvert )
@@ -913,7 +913,7 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm, short
/*
// Kicking goal factor to simplify things...who uses that anyway?
- // ABS ( clmd->sim_parms.maxgoal - clmd->sim_parms.mingoal );
+ // ABS ( clmd->sim_parms->maxgoal - clmd->sim_parms->mingoal );
*/
verts->goal = ( float ) pow ( verts->goal , 4.0f );
@@ -990,7 +990,7 @@ static int collobj_from_object ( Object *ob, ClothModifierData *clmd, DerivedMes
verts->impulse_count = 0;
VECCOPY ( verts->impulse, tnull );
}
- clmd->clothObject->tree = bvh_build_from_cloth ( clmd,clmd->coll_parms.epsilon );
+ clmd->clothObject->tree = bvh_build_from_cloth ( clmd,clmd->coll_parms->epsilon );
}
@@ -1039,7 +1039,7 @@ static int cloth_from_object ( Object *ob, ClothModifierData *clmd, DerivedMesh
return 0;
}
- clmd->sim_parms.ob = ob;
+ clmd->sim_parms->ob = ob;
switch ( ob->type )
{
@@ -1066,10 +1066,10 @@ static int cloth_from_object ( Object *ob, ClothModifierData *clmd, DerivedMesh
VECCOPY ( verts->x, mvert[i].co );
Mat4MulVecfl ( ob->obmat, verts->x );
- verts->mass = clmd->sim_parms.mass;
+ verts->mass = clmd->sim_parms->mass;
- if ( clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_GOAL )
- verts->goal= clmd->sim_parms.defgoal;
+ if ( clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL )
+ verts->goal= clmd->sim_parms->defgoal;
else
verts->goal= 0.0f;
@@ -1090,14 +1090,14 @@ static int cloth_from_object ( Object *ob, ClothModifierData *clmd, DerivedMesh
}
// apply / set vertex groups
- if ( clmd->sim_parms.vgroup_mass > 0 )
- cloth_apply_vgroup ( clmd, dm, clmd->sim_parms.vgroup_mass );
+ if ( clmd->sim_parms->vgroup_mass > 0 )
+ cloth_apply_vgroup ( clmd, dm, clmd->sim_parms->vgroup_mass );
// init our solver
- if ( solvers [clmd->sim_parms.solver_type].init )
- solvers [clmd->sim_parms.solver_type].init ( ob, clmd );
+ if ( solvers [clmd->sim_parms->solver_type].init )
+ solvers [clmd->sim_parms->solver_type].init ( ob, clmd );
- clmd->clothObject->tree = bvh_build_from_cloth ( clmd, clmd->coll_parms.epsilon );
+ clmd->clothObject->tree = bvh_build_from_cloth ( clmd, clmd->coll_parms->epsilon );
cloth_write_cache(ob, clmd, framenr-1);
}
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index c5e6c119e10..75201bbcea3 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -459,7 +459,7 @@ int cloth_collision_response_static(ClothModifierData *clmd, CollisionModifierDa
cloth1 = clmd->clothObject;
- search = clmd->coll_parms.collision_list;
+ search = clmd->coll_parms->collision_list;
while(search)
{
@@ -503,10 +503,10 @@ int cloth_collision_response_static(ClothModifierData *clmd, CollisionModifierDa
float vrel_t_pre[3];
float vrel_t[3];
double impulse;
- float epsilon = clmd->coll_parms.epsilon;
+ float epsilon = clmd->coll_parms->epsilon;
float overlap = (epsilon + ALMOST_ZERO-collpair->distance);
- // calculateFrictionImpulse(tangential, relativeVelocity, collpair->normal, magrelVel, clmd->coll_parms.friction*0.01, magrelVel);
+ // calculateFrictionImpulse(tangential, relativeVelocity, collpair->normal, magrelVel, clmd->coll_parms->friction*0.01, magrelVel);
// magtangent = INPR(tangential, tangential);
@@ -562,11 +562,11 @@ int cloth_collision_response_static(ClothModifierData *clmd, CollisionModifierDa
// Apply the impulse and increase impulse counters.
/*
- // calculateFrictionImpulse(tangential, collvel, collpair->normal, magtangent, clmd->coll_parms.friction*0.01, magtangent);
+ // calculateFrictionImpulse(tangential, collvel, collpair->normal, magtangent, clmd->coll_parms->friction*0.01, magtangent);
VECSUBS(vrel_t_pre, collvel, collpair->normal, magnormal);
- // VecMulf(vrel_t_pre, clmd->coll_parms.friction*0.01f/INPR(vrel_t_pre,vrel_t_pre));
+ // VecMulf(vrel_t_pre, clmd->coll_parms->friction*0.01f/INPR(vrel_t_pre,vrel_t_pre));
magtangent = Normalize(vrel_t_pre);
- VecMulf(vrel_t_pre, MIN2(clmd->coll_parms.friction*0.01f*magnormal,magtangent));
+ VecMulf(vrel_t_pre, MIN2(clmd->coll_parms->friction*0.01f*magnormal,magtangent));
VECSUB(cloth1->verts[face1->v1].tv, cloth1->verts[face1->v1].tv,vrel_t_pre);
*/
@@ -600,7 +600,7 @@ void cloth_collision_static(ClothModifierData *clmd, CollisionModifierData *coll
MFace *face1=NULL, *face2=NULL;
ClothVertex *verts1=NULL;
double distance = 0;
- float epsilon = clmd->coll_parms.epsilon;
+ float epsilon = clmd->coll_parms->epsilon;
unsigned int i = 0;
for(i = 0; i < 4; i++)
@@ -694,7 +694,7 @@ void cloth_collision_static(ClothModifierData *clmd, CollisionModifierData *coll
Normalize(collpair->normal);
collpair->distance = distance;
- BLI_linklist_append(&clmd->coll_parms.collision_list, collpair);
+ BLI_linklist_append(&clmd->coll_parms->collision_list, collpair);
}
else
@@ -747,7 +747,7 @@ void cloth_collision_moving_edges(ClothModifierData *clmd, ClothModifierData *co
MFace *face1=NULL, *face2=NULL;
ClothVertex *verts1=NULL, *verts2=NULL;
double distance = 0;
- float epsilon = clmd->coll_parms.epsilon;
+ float epsilon = clmd->coll_parms->epsilon;
unsigned int i = 0, j = 0, k = 0;
int numsolutions = 0;
float a[3], b[3], c[3], d[3], e[3], f[3], solution[3];
@@ -882,7 +882,7 @@ void cloth_collision_moving_tris(ClothModifierData *clmd, ClothModifierData *col
MFace *face1=NULL, *face2=NULL;
ClothVertex *verts1=NULL, *verts2=NULL;
double distance = 0;
- float epsilon = clmd->coll_parms.epsilon;
+ float epsilon = clmd->coll_parms->epsilon;
unsigned int i = 0, j = 0, k = 0;
int numsolutions = 0;
float a[3], b[3], c[3], d[3], e[3], f[3], solution[3];
@@ -978,52 +978,6 @@ void cloth_collision_moving(ClothModifierData *clmd, ClothModifierData *coll_clm
cloth_collision_moving_tris(coll_clmd, clmd, tree2, tree1);
}
-// move collision objects forward in time and update static bounding boxes
-void cloth_update_collision_objects(float step)
-{
- Base *base=NULL;
- ClothModifierData *coll_clmd=NULL;
- Object *coll_ob=NULL;
- unsigned int i=0;
-
- // search all objects for collision object
- for (base = G.scene->base.first; base; base = base->next)
- {
-
- coll_ob = base->object;
- coll_clmd = (ClothModifierData *) modifiers_findByType (coll_ob, eModifierType_Cloth);
- if (!coll_clmd)
- continue;
-
- // if collision object go on
- if (coll_clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_COLLOBJ)
- {
- if (coll_clmd->clothObject && coll_clmd->clothObject->tree)
- {
- Cloth *coll_cloth = coll_clmd->clothObject;
- BVH *coll_bvh = coll_clmd->clothObject->tree;
- unsigned int coll_numverts = coll_cloth->numverts;
-
- // update position of collision object
- for(i = 0; i < coll_numverts; i++)
- {
- VECCOPY(coll_cloth->verts[i].txold, coll_cloth->verts[i].tx);
-
- VECADDS(coll_cloth->verts[i].tx, coll_cloth->verts[i].xold, coll_cloth->verts[i].v, step);
-
- // no dt here because of float rounding errors
- VECSUB(coll_cloth->verts[i].tv, coll_cloth->verts[i].tx, coll_cloth->verts[i].txold);
- }
-
- // update BVH of collision object
- bvh_update_from_cloth(coll_clmd, 0); // 0 means STATIC, 1 means MOVING
- }
- else
- printf ("cloth_bvh_objcollision: found a collision object with clothObject or collData NULL.\n");
- }
- }
-}
-
// CLOTH_MAX_THRESHOLD defines how much collision rounds/loops should be taken
#define CLOTH_MAX_THRESHOLD 10
@@ -1041,7 +995,7 @@ int cloth_bvh_objcollision(ClothModifierData * clmd, float step, float dt)
float tnull[3] = {0,0,0};
int ret = 0;
- if ((clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_COLLOBJ) || !(((Cloth *)clmd->clothObject)->tree))
+ if ((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_COLLOBJ) || !(((Cloth *)clmd->clothObject)->tree))
{
return 0;
}
@@ -1059,14 +1013,11 @@ int cloth_bvh_objcollision(ClothModifierData * clmd, float step, float dt)
// update cloth bvh
bvh_update_from_cloth(clmd, 0); // 0 means STATIC, 1 means MOVING (see later in this function)
- // update collision objects
- cloth_update_collision_objects(step);
-
do
{
result = 0;
ic = 0;
- clmd->coll_parms.collision_list = NULL;
+ clmd->coll_parms->collision_list = NULL;
// check all collision objects
for (base = G.scene->base.first; base; base = base->next)
@@ -1125,9 +1076,9 @@ int cloth_bvh_objcollision(ClothModifierData * clmd, float step, float dt)
}
// free collision list
- if(clmd->coll_parms.collision_list)
+ if(clmd->coll_parms->collision_list)
{
- LinkNode *search = clmd->coll_parms.collision_list;
+ LinkNode *search = clmd->coll_parms->collision_list;
while(search)
{
CollPair *coll_pair = search->link;
@@ -1135,9 +1086,9 @@ int cloth_bvh_objcollision(ClothModifierData * clmd, float step, float dt)
MEM_freeN(coll_pair);
search = search->next;
}
- BLI_linklist_free(clmd->coll_parms.collision_list,NULL);
+ BLI_linklist_free(clmd->coll_parms->collision_list,NULL);
- clmd->coll_parms.collision_list = NULL;
+ clmd->coll_parms->collision_list = NULL;
}
rounds++;
}
@@ -1191,7 +1142,7 @@ int cloth_bvh_objcollision(ClothModifierData * clmd, float step, float dt)
{
result = 0;
ic = 0;
- clmd->coll_parms.collision_list = NULL;
+ clmd->coll_parms->collision_list = NULL;
// check all collision objects
for (base = G.scene->base.first; base; base = base->next)
@@ -1203,7 +1154,7 @@ int cloth_bvh_objcollision(ClothModifierData * clmd, float step, float dt)
continue;
// if collision object go on
- if (coll_clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_COLLOBJ)
+ if (coll_clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_COLLOBJ)
{
if (coll_clmd->clothObject && coll_clmd->clothObject->tree)
{
@@ -1233,7 +1184,7 @@ int cloth_bvh_objcollision(ClothModifierData * clmd, float step, float dt)
continue;
// if collision object go on
- if (coll_clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_COLLOBJ)
+ if (coll_clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_COLLOBJ)
{
if (coll_clmd->clothObject)
result += cloth_collision_response_moving_tris(clmd, coll_clmd);
@@ -1271,9 +1222,9 @@ int cloth_bvh_objcollision(ClothModifierData * clmd, float step, float dt)
// free collision list
- if(clmd->coll_parms.collision_list)
+ if(clmd->coll_parms->collision_list)
{
- LinkNode *search = clmd->coll_parms.collision_list;
+ LinkNode *search = clmd->coll_parms->collision_list;
while(search)
{
CollPair *coll_pair = search->link;
@@ -1281,9 +1232,9 @@ int cloth_bvh_objcollision(ClothModifierData * clmd, float step, float dt)
MEM_freeN(coll_pair);
search = search->next;
}
- BLI_linklist_free(clmd->coll_parms.collision_list,NULL);
+ BLI_linklist_free(clmd->coll_parms->collision_list,NULL);
- clmd->coll_parms.collision_list = NULL;
+ clmd->coll_parms->collision_list = NULL;
}
// printf("ic: %d\n", ic);
diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c
index 4985b3efa3f..3f21bf2bfc5 100644
--- a/source/blender/blenkernel/intern/implicit.c
+++ b/source/blender/blenkernel/intern/implicit.c
@@ -1081,7 +1081,7 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
float vel[3];
float k = 0.0f;
float L = s->restlen;
- float cb = clmd->sim_parms.structural;
+ float cb = clmd->sim_parms->structural;
float nullf[3] = {0,0,0};
float stretch_force[3] = {0,0,0};
@@ -1089,7 +1089,6 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
float damping_force[3] = {0,0,0};
float nulldfdx[3][3]={ {0,0,0}, {0,0,0}, {0,0,0}};
Cloth *cloth = clmd->clothObject;
- ClothVertex *verts = cloth->verts;
VECCOPY(s->f, nullf);
cp_fmatrix(s->dfdx, nulldfdx);
@@ -1107,8 +1106,8 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
/*
if(length>L)
{
- if((clmd->sim_parms.flags & CSIMSETT_FLAG_TEARING_ENABLED)
- && ((((length-L)*100.0f/L) > clmd->sim_parms.maxspringlen))) // cut spring!
+ if((clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED)
+ && ((((length-L)*100.0f/L) > clmd->sim_parms->maxspringlen))) // cut spring!
{
s->flags |= CSPRING_FLAG_DEACTIVATE;
return;
@@ -1130,19 +1129,19 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
{
s->flags |= CLOTH_SPRING_FLAG_NEEDED;
- k = clmd->sim_parms.structural;
+ k = clmd->sim_parms->structural;
mul_fvector_S(stretch_force, dir, (k*(length-L)));
VECADD(s->f, s->f, stretch_force);
// Ascher & Boxman, p.21: Damping only during elonglation
- mul_fvector_S(damping_force, extent, clmd->sim_parms.Cdis * ((INPR(vel,extent)/length)));
+ mul_fvector_S(damping_force, extent, clmd->sim_parms->Cdis * ((INPR(vel,extent)/length)));
VECADD(s->f, s->f, damping_force);
dfdx_spring_type1(s->dfdx, dir,length,L,k);
- dfdv_damp(s->dfdv, dir,clmd->sim_parms.Cdis);
+ dfdv_damp(s->dfdv, dir,clmd->sim_parms->Cdis);
}
}
else // calculate force of bending springs
@@ -1151,7 +1150,7 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s,
{
s->flags |= CLOTH_SPRING_FLAG_NEEDED;
- k = clmd->sim_parms.bending;
+ k = clmd->sim_parms->bending;
mul_fvector_S(bending_force, dir, fbstar(length, L, k, cb));
VECADD(s->f, s->f, bending_force);
@@ -1228,7 +1227,7 @@ void cloth_calc_force(ClothModifierData *clmd, lfVector *lF, lfVector *lX, lfVec
/* Collect forces and derivatives: F,dFdX,dFdV */
Cloth *cloth = clmd->clothObject;
unsigned int i = 0;
- float spring_air = clmd->sim_parms.Cvi * 0.01f; /* viscosity of air scaled in percent */
+ float spring_air = clmd->sim_parms->Cvi * 0.01f; /* viscosity of air scaled in percent */
float gravity[3];
float tm2[3][3] = {{-spring_air,0,0}, {0,-spring_air,0},{0,0,-spring_air}};
ClothVertex *verts = cloth->verts;
@@ -1240,7 +1239,7 @@ void cloth_calc_force(ClothModifierData *clmd, lfVector *lF, lfVector *lX, lfVec
LinkNode *search = cloth->springs;
- VECCOPY(gravity, clmd->sim_parms.gravity);
+ VECCOPY(gravity, clmd->sim_parms->gravity);
mul_fvector_S(gravity, gravity, 0.001f); /* scale gravity force */
/* set dFdX jacobi matrix to zero */
@@ -1253,7 +1252,7 @@ void cloth_calc_force(ClothModifierData *clmd, lfVector *lF, lfVector *lX, lfVec
submul_lfvectorS(lF, lV, spring_air, numverts);
/* do goal stuff */
- if(clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_GOAL)
+ if(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL)
{
for(i = 0; i < numverts; i++)
{
@@ -1265,12 +1264,12 @@ void cloth_calc_force(ClothModifierData *clmd, lfVector *lF, lfVector *lX, lfVec
VECADD(tvect, tvect, verts[i].xold);
VECSUB(auxvect, tvect, lX[i]);
- ks = 1.0f/(1.0f- verts [i].goal*clmd->sim_parms.goalspring)-1.0f ;
+ ks = 1.0f/(1.0f- verts [i].goal*clmd->sim_parms->goalspring)-1.0f ;
VECADDS(lF[i], lF[i], auxvect, -ks);
// calulate damping forces generated by goals
VECSUB(velgoal,verts[i].xold, verts[i].xconst);
- kd = clmd->sim_parms.goalfrict * 0.01f; // friction force scale taken from SB
+ kd = clmd->sim_parms->goalfrict * 0.01f; // friction force scale taken from SB
VECSUBADDSS(lF[i], velgoal, kd, lV[i], kd);
}
@@ -1287,7 +1286,7 @@ void cloth_calc_force(ClothModifierData *clmd, lfVector *lF, lfVector *lX, lfVec
for(i = 0; i < cloth->numverts; i++)
{
float vertexnormal[3]={0,0,0};
- float fieldfactor = 1000.0f, windfactor = 250.0f; // from sb
+ float fieldfactor = 1000.0f; // windfactor = 250.0f; // from sb
pdDoEffectors(effectors, lX[i], force, speed, (float)G.scene->r.cfra, 0.0f, PE_WIND_AS_SPEED);
@@ -1307,7 +1306,7 @@ void cloth_calc_force(ClothModifierData *clmd, lfVector *lF, lfVector *lX, lfVec
while(search)
{
// only handle active springs
- // if(((clmd->sim_parms.flags & CSIMSETT_FLAG_TEARING_ENABLED) && !(springs[i].flags & CSPRING_FLAG_DEACTIVATE))|| !(clmd->sim_parms.flags & CSIMSETT_FLAG_TEARING_ENABLED)){}
+ // if(((clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED) && !(springs[i].flags & CSPRING_FLAG_DEACTIVATE))|| !(clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED)){}
cloth_calc_spring_force(clmd, search->link, lF, lX, lV, dFdV, dFdX);
search = search->next;
@@ -1318,7 +1317,7 @@ void cloth_calc_force(ClothModifierData *clmd, lfVector *lF, lfVector *lX, lfVec
while(search)
{
// only handle active springs
- // if(((clmd->sim_parms.flags & CSIMSETT_FLAG_TEARING_ENABLED) && !(springs[i].flags & CSPRING_FLAG_DEACTIVATE))|| !(clmd->sim_parms.flags & CSIMSETT_FLAG_TEARING_ENABLED))
+ // if(((clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED) && !(springs[i].flags & CSPRING_FLAG_DEACTIVATE))|| !(clmd->sim_parms->flags & CSIMSETT_FLAG_TEARING_ENABLED))
cloth_apply_spring_force(clmd, search->link, lF, lX, lV, dFdV, dFdX);
search = search->next;
}
@@ -1357,16 +1356,16 @@ void simulate_implicit_euler(lfVector *Vnew, lfVector *lX, lfVector *lV, lfVecto
int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase *effectors)
{
- unsigned int i=0, j;
+ unsigned int i=0;
float step=0.0f, tf=1.0f;
Cloth *cloth = clmd->clothObject;
ClothVertex *verts = cloth->verts;
unsigned int numverts = cloth->numverts;
- float dt = 1.0f / clmd->sim_parms.stepsPerFrame;
+ float dt = 1.0f / clmd->sim_parms->stepsPerFrame;
Implicit_Data *id = cloth->implicit;
int result = 0;
- if(clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_GOAL) /* do goal stuff */
+ if(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) /* do goal stuff */
{
for(i = 0; i < numverts; i++)
{
@@ -1389,7 +1388,7 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
add_lfvector_lfvectorS(id->Xnew, id->X, id->Vnew, dt, numverts);
- if(clmd->coll_parms.flags & CLOTH_COLLISIONSETTINGS_FLAG_ENABLED)
+ if(clmd->coll_parms->flags & CLOTH_COLLISIONSETTINGS_FLAG_ENABLED)
{
// collisions
// itstart();
@@ -1397,7 +1396,7 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
// update verts to current positions
for(i = 0; i < numverts; i++)
{
- if(clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_GOAL) /* do goal stuff */
+ if(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) /* do goal stuff */
{
if(verts [i].goal >= SOFTGOALSNAP)
{
@@ -1472,7 +1471,7 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
for(i = 0; i < numverts; i++)
{
- if(clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_GOAL)
+ if(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL)
{
if(verts [i].goal < SOFTGOALSNAP)
{
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index da31929442d..9273b6bf9ab 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -4947,6 +4947,14 @@ static void softbodyModifier_deformVerts(
static void clothModifier_initData(ModifierData *md)
{
ClothModifierData *clmd = (ClothModifierData*) md;
+
+ clmd->sim_parms = MEM_callocN(sizeof(SimulationSettings), "cloth sim parms");
+ clmd->coll_parms = MEM_callocN(sizeof(CollisionSettings), "cloth coll parms");
+
+ /* check for alloc failing */
+ if(!clmd->sim_parms || !clmd->coll_parms)
+ return;
+
cloth_init (clmd);
}
@@ -4956,7 +4964,7 @@ static void clothModifier_deformVerts(
{
DerivedMesh *dm = NULL;
- // if possible use/create DerivedMesh
+ /* if possible use/create DerivedMesh */
if(derivedData) dm = CDDM_copy(derivedData);
else if(ob->type==OB_MESH) dm = CDDM_from_mesh(ob->data, ob);
@@ -4967,6 +4975,8 @@ static void clothModifier_deformVerts(
CDDM_calc_normals(dm);
}
+ /* TODO: check for sim_parms / coll_parms NOT NULL */
+
clothModifier_do((ClothModifierData *)md, ob, dm, vertexCos, numVerts);
if(dm)
@@ -4991,7 +5001,7 @@ static void clothModifier_updateDepgraph(
ClothModifierData *coll_clmd = (ClothModifierData *)modifiers_findByType(ob1, eModifierType_Cloth);
if(coll_clmd)
{
- if (coll_clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_COLLOBJ)
+ if (coll_clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_COLLOBJ)
{
DagNode *curNode = dag_get_node(forest, ob1);
dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA);
@@ -5008,8 +5018,8 @@ CustomDataMask clothModifier_requiredDataMask(ModifierData *md)
CustomDataMask dataMask = 0;
/* ask for vertexgroups if we need them */
- if(clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_GOAL)
- if (clmd->sim_parms.vgroup_mass > 0)
+ if(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL)
+ if (clmd->sim_parms->vgroup_mass > 0)
dataMask |= (1 << CD_MDEFORMVERT);
return dataMask;
@@ -5027,8 +5037,11 @@ static void clothModifier_freeData(ModifierData *md)
if (clmd)
{
- clmd->sim_parms.flags &= ~CLOTH_SIMSETTINGS_FLAG_CCACHE_PROTECT;
+ clmd->sim_parms->flags &= ~CLOTH_SIMSETTINGS_FLAG_CCACHE_PROTECT;
cloth_free_modifier (clmd);
+
+ MEM_freeN(clmd->sim_parms);
+ MEM_freeN(clmd->coll_parms);
}
}
@@ -5096,9 +5109,8 @@ static void collisionModifier_deformVerts(
float current_time = 0;
unsigned int numverts = 0, i = 0;
MVert *tempVert = NULL;
-
- // if possible use/create DerivedMesh
+ /* if possible use/create DerivedMesh */
if(derivedData) dm = CDDM_copy(derivedData);
else if(ob->type==OB_MESH) dm = CDDM_from_mesh(ob->data, ob);
@@ -5112,12 +5124,11 @@ static void collisionModifier_deformVerts(
{
CDDM_apply_vert_coords(dm, vertexCos);
CDDM_calc_normals(dm);
-
-
+
current_time = bsystem_time ( ob, ( float ) G.scene->r.cfra, 0.0 );
if(current_time > collmd->time)
- {
+ {
numverts = dm->getNumVerts ( dm );
// check if mesh has changed
@@ -5141,12 +5152,12 @@ static void collisionModifier_deformVerts(
collmd->numverts = numverts;
- // TODO: epsilon
- // create bounding box hierarchy
- 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);
+
+ // TODO: epsilon
+ // create bounding box hierarchy
+ collmd->tree = bvh_build_from_mvert(collmd->mfaces, collmd->numfaces, collmd->x, numverts, ob->pd->pdef_sbift);
}
else if(numverts == collmd->numverts)
{
@@ -5166,8 +5177,16 @@ static void collisionModifier_deformVerts(
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);
+ /* happens on file load (ONLY when i decomment changes in readfile.c */
+ if(!collmd->tree)
+ {
+ collmd->tree = bvh_build_from_mvert(collmd->mfaces, collmd->numfaces, collmd->current_x, numverts, ob->pd->pdef_sbift);
+ }
+ else
+ {
+ // recalc static bounding boxes
+ bvh_update_from_mvert(collmd->tree, collmd->current_x, numverts, NULL, 0);
+ }
}
collmd->time = current_time;
@@ -7271,11 +7290,11 @@ int modifiers_isSoftbodyEnabled(Object *ob)
return (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render));
}
-ModifierData * modifiers_isClothEnabled(Object *ob)
+ClothModifierData * modifiers_isClothEnabled(Object *ob)
{
ModifierData *md = modifiers_findByType(ob, eModifierType_Cloth);
- return md;
+ return (ClothModifierData *)md;
}
int modifiers_isParticleEnabled(Object *ob)
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index af75e9490d5..c725b3d63ac 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2998,29 +2998,41 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
SubsurfModifierData *smd = (SubsurfModifierData*) md;
smd->emCache = smd->mCache = 0;
- }
+ }
else if (md->type==eModifierType_Cloth) {
- ClothModifierData *clmd = (ClothModifierData*) md;
-
- clmd->clothObject = NULL;
- /*
- clmd->sim_parms= newdataadr(fd, clmd->sim_parms);
- clmd->coll_parms= newdataadr(fd, clmd->coll_parms);
- */
-
- }
+ ClothModifierData *clmd = (ClothModifierData*) md;
+
+ clmd->clothObject = NULL;
+
+ clmd->sim_parms= newdataadr(fd, clmd->sim_parms);
+ clmd->coll_parms= newdataadr(fd, clmd->coll_parms);
+
+ }
else if (md->type==eModifierType_Collision) {
- /*
+
CollisionModifierData *collmd = (CollisionModifierData*) md;
+ /*
+ // TODO: CollisionModifier should use pointcache
+ // + have proper reset events before enabling this
+ collmd->x = newdataadr(fd, collmd->x);
+ collmd->xnew = newdataadr(fd, collmd->xnew);
+ collmd->mfaces = newdataadr(fd, collmd->mfaces);
+
+ collmd->current_x = MEM_callocN(sizeof(MVert)*collmd->numverts,"current_x");
+ collmd->current_xnew = MEM_callocN(sizeof(MVert)*collmd->numverts,"current_xnew");
+ collmd->current_v = MEM_callocN(sizeof(MVert)*collmd->numverts,"current_v");
+ */
collmd->x = NULL;
collmd->xnew = NULL;
collmd->current_x = NULL;
collmd->current_xnew = NULL;
+ collmd->current_v = NULL;
collmd->time = -1;
collmd->numverts = 0;
collmd->tree = NULL;
- */
+ collmd->mfaces = NULL;
+
}
else if (md->type==eModifierType_Hook) {
HookModifierData *hmd = (HookModifierData*) md;
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 3ac4160b105..8bcc2497dbd 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -839,11 +839,22 @@ static void write_modifiers(WriteData *wd, ListBase *modbase)
}
else if(md->type==eModifierType_Cloth) {
ClothModifierData *clmd = (ClothModifierData*) md;
- /*
+
writestruct(wd, DATA, "SimulationSettings", 1, clmd->sim_parms);
writestruct(wd, DATA, "CollisionSettings", 1, clmd->coll_parms);
- */
+
}
+ else if (md->type==eModifierType_Collision) {
+
+ CollisionModifierData *collmd = (CollisionModifierData*) md;
+ /*
+ // TODO: CollisionModifier should use pointcache
+ // + have proper reset events before enabling this
+ writestruct(wd, DATA, "MVert", collmd->numverts, collmd->x);
+ writestruct(wd, DATA, "MVert", collmd->numverts, collmd->xnew);
+ writestruct(wd, DATA, "MFace", collmd->numfaces, collmd->mfaces);
+ */
+ }
else if (md->type==eModifierType_MeshDeform) {
MeshDeformModifierData *mmd = (MeshDeformModifierData*) md;
int size = mmd->dyngridsize;
diff --git a/source/blender/makesdna/DNA_cloth_types.h b/source/blender/makesdna/DNA_cloth_types.h
index 3cb76c7a845..ee4a0130dbf 100644
--- a/source/blender/makesdna/DNA_cloth_types.h
+++ b/source/blender/makesdna/DNA_cloth_types.h
@@ -34,7 +34,6 @@
#include "DNA_listBase.h"
-
/**
* This struct contains all the global data required to run a simulation.
* At the time of this writing, this structure contains data appropriate
@@ -116,9 +115,9 @@ typedef struct Cloth
unsigned char old_solver_type;
unsigned char pad2;
short pad3;
- void *tree; /* collision tree for this cloth object */
+ struct BVH *tree; /* collision tree for this cloth object */
struct MFace *mfaces;
- void *implicit; /* our implicit solver connects to this pointer */
+ struct Implicit_Data *implicit; /* our implicit solver connects to this pointer */
}
Cloth;
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 9ea0a9c2c9a..e5c3b46d875 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -7,8 +7,6 @@
#define MODSTACK_DEBUG 1
-#include "DNA_cloth_types.h"
-
/* WARNING ALERT! TYPEDEF VALUES ARE WRITTEN IN FILES! SO DO NOT CHANGE! */
typedef enum ModifierType {
@@ -349,8 +347,8 @@ typedef struct ClothModifierData {
ModifierData modifier;
struct Cloth *clothObject; /* The internal data structure for cloth. */
- struct SimulationSettings sim_parms; /* definition is in DNA_cloth_types.h */
- struct CollisionSettings coll_parms; /* definition is in DNA_cloth_types.h */
+ struct SimulationSettings *sim_parms; /* definition is in DNA_cloth_types.h */
+ struct CollisionSettings *coll_parms; /* definition is in DNA_cloth_types.h */
} ClothModifierData;
typedef struct CollisionModifierData {
diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c
index 6b5083c5e26..90f7dab0a58 100644
--- a/source/blender/src/buttons_object.c
+++ b/source/blender/src/buttons_object.c
@@ -3083,7 +3083,7 @@ void do_effects_panels(unsigned short event)
ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth);
if(clmd)
{
- if(clmd->sim_parms.cache)
+ if(clmd->sim_parms->cache)
{
CFRA= 1;
update_for_newframe_muted();
@@ -3099,7 +3099,7 @@ void do_effects_panels(unsigned short event)
ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth);
if(clmd)
{
- clmd->sim_parms.vgroup_mass = 0;
+ clmd->sim_parms->vgroup_mass = 0;
do_object_panels(B_CLOTH_RENEW);
}
allqueue(REDRAWBUTSOBJECT, 0);
@@ -4923,25 +4923,25 @@ static void object_cloth__enabletoggle(void *ob_v, void *arg2)
allqueue(REDRAWBUTSEDIT, 0);
}
+
static void object_panel_cloth(Object *ob)
{
uiBlock *block;
- static int val, val2;
uiBut *but;
+ static int val, val2;
ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth);
- block= uiNewBlock(&curarea->uiblocks, "object_panel_cloth", UI_EMBOSS, UI_HELV, curarea->win);
- if(uiNewPanel(curarea, block, "Cloth", "Physics", 640, 0, 318, 204)==0) return;
+
+ block= uiNewBlock(&curarea->uiblocks, "object_cloth", UI_EMBOSS, UI_HELV, curarea->win);
+ if(uiNewPanel(curarea, block, "Cloth ", "Physics", 640, 0, 318, 204)==0) return;
+ uiSetButLock(object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
- if(ob->id.lib) uiSetButLock(1, "Can't edit library data");
- val = ((clmd)?(1):(0));
+ but = uiDefButI(block, TOG, REDRAWBUTSOBJECT, "Cloth", 10,200,130,20, &val, 0, 0, 0, 0, "Sets object to become cloth");
- but = uiDefButI(block, TOG, REDRAWBUTSOBJECT, "Cloth Object", 10,200,130,20, &val, 0, 0, 0, 0, "Sets object to become cloth");
uiButSetFunc(but, object_cloth__enabletoggle, ob, NULL);
uiDefBut(block, LABEL, 0, "",10,10,300,0, NULL, 0.0, 0, 0, 0, ""); /* tell UI we go to 10,10*/
if(clmd)
{
- Cloth *cloth = clmd->clothObject;
int defCount;
char *clvg1, *clvg2;
char clmvg [] = "Weight Paint Groups%t|";
@@ -4951,13 +4951,13 @@ static void object_panel_cloth(Object *ob)
/* 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)");
+ 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");
+ 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();
@@ -4966,15 +4966,20 @@ static void object_panel_cloth(Object *ob)
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");
+ 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(BLI_countlist (&ob->defbase) > 0)
+ {
+ 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)
{
@@ -4989,30 +4994,30 @@ static void object_panel_cloth(Object *ob)
defCount = BLI_countlist (&ob->defbase);
if (defCount == 0)
{
- clmd->sim_parms.vgroup_mass = 0;
+ clmd->sim_parms->vgroup_mass = 0;
}
else
- if(!clmd->sim_parms.vgroup_mass)
- clmd->sim_parms.vgroup_mass = 1;
+ 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");
+ 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");
+ 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");
+ 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");
+ 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);
@@ -5020,112 +5025,86 @@ static void object_panel_cloth(Object *ob)
/*
// 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");
+ 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)
+ 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");
- }
+ 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);
*/
}
+
+ uiBlockEndAlign(block);
+
+ uiBlockEndAlign(block);
}
-
static void object_panel_cloth_II(Object *ob)
{
uiBlock *block;
- static int val;
- uiBut *but;
ClothModifierData *clmd = NULL;
+
+ block= uiNewBlock(&curarea->uiblocks, "object_cloth_II", UI_EMBOSS, UI_HELV, curarea->win);
+ uiNewPanelTabbed("Cloth ", "Physics");
+ if(uiNewPanel(curarea, block, "Cloth Cache/Collisions", "Physics", 651, 0, 318, 204)==0) return;
+
+ uiSetButLock(object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth);
+
if(clmd)
{
- if (!(clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_COLLOBJ))
- {
- Cloth *cloth = clmd->clothObject;
- char str[128];
-
- block= uiNewBlock(&curarea->uiblocks, "object_panel_cloth_II", UI_EMBOSS, UI_HELV, curarea->win);
- uiNewPanelTabbed("Cloth", "Physics");
- if(uiNewPanel(curarea, block, "Cloth Cache", "Physics", 651, 0, 318, 204)==0) return;
+ // char str[128];
- uiSetButLock(object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
-
- uiDefButI(block, NUM, B_DIFF, "First Frame:", 10,160,150,20, &clmd->sim_parms.firstframe, 0, MAXFRAME, 1, 0, "Frame on which the simulation starts");
- uiDefButI(block, NUM, B_DIFF, "Last Frame:", 160,160,150,20, &clmd->sim_parms.lastframe, 0, MAXFRAME, 10, 0, "Frame on which the simulation stops");
-
- if(clmd->sim_parms.cache)
- {
- int length = BLI_linklist_length(clmd->sim_parms.cache);
-
- /* correct spelling if only 1 frame cacheed --> only gimmick */
- if(length-clmd->sim_parms.preroll>1)
- sprintf (str, "Frame 1 - %d cached. [%d in preroll, %d in total]", length-clmd->sim_parms.preroll, clmd->sim_parms.preroll, length);
- else
- sprintf (str, "Frame %d cached. [%d in preroll, %d in total]", length-clmd->sim_parms.preroll, clmd->sim_parms.preroll, length);
-
- uiDefBut(block, LABEL, 0, str, 10,140,290,20, NULL, 0.0, 0, 0, 0, "");
- uiDefBut(block, LABEL, 0, "Clear cache:", 10,120,290,20, NULL, 0.0, 0, 0, 0, "");
- uiBlockBeginAlign (block);
- uiDefBut(block, BUT, B_CLOTH_CLEARCACHEALL, "All", 10, 100,145,20, NULL, 0.0, 0.0, 0, 0, "Free cloth cache without preroll");
- uiDefBut(block, BUT, B_CLOTH_CLEARCACHEFRAME, "From next frame", 155, 100,145,20, NULL, 0.0, 0.0, 0, 0, "Free cloth cache");
- if(length>1) // B_CLOTH_CHANGEPREROLL
- uiDefButI(block, NUM, B_CLOTH_CHANGEPREROLL, "Preroll:", 10,80,145,20, &clmd->sim_parms.preroll, 0, length-1, 1, 0, "Simulation starts on this frame");
- else
- uiDefBut(block, LABEL, 0, " ", 10,80,145,20, NULL, 0.0, 0, 0, 0, "");
- }
- else
- {
- uiDefBut(block, LABEL, 0, "No frames cached.", 10,120,290,20, NULL, 0.0, 0, 0, 0, "");
- }
- uiDefButBitI(block, TOG, CLOTH_SIMSETTINGS_FLAG_CCACHE_PROTECT, REDRAWVIEW3D, "Protect Cache", 10,50,145,20, &clmd->sim_parms.flags, 0, 0, 0, 0, "Protect cache from automatic freeing when scene changed");
- uiBlockEndAlign(block);
+ uiDefButI(block, NUM, B_DIFF, "First Frame:", 10,160,150,20, &clmd->sim_parms->firstframe, 0, MAXFRAME, 1, 0, "Frame on which the simulation starts");
+ uiDefButI(block, NUM, B_DIFF, "Last Frame:", 160,160,150,20, &clmd->sim_parms->lastframe, 0, MAXFRAME, 10, 0, "Frame on which the simulation stops");
+
+ uiDefBut(block, LABEL, 0, "",10,140,300,20, NULL, 0.0, 0, 0, 0, "");
+
+ /* correct spelling if only 1 frame cacheed --> only gimmick */
+ /*
+ if(length-clmd->sim_parms->preroll>1)
+ sprintf (str, "Frame 1 - %d cached. [%d in preroll, %d in total]", length-clmd->sim_parms->preroll, clmd->sim_parms->preroll, length);
+ else
+ sprintf (str, "Frame %d cached. [%d in preroll, %d in total]", length-clmd->sim_parms->preroll, clmd->sim_parms->preroll, length);
+ */
+
+ uiDefButBitI(block, TOG, CLOTH_SIMSETTINGS_FLAG_CCACHE_PROTECT, REDRAWVIEW3D, "Protect Cache", 10,120,300,20, &clmd->sim_parms->flags, 0, 0, 0, 0, "Protect cache from automatic freeing when scene changed");
+
+ if(!(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_CCACHE_PROTECT))
+ {
+ uiDefBut(block, LABEL, 0, "Clear cache:", 10,100,90,20, NULL, 0.0, 0, 0, 0, "");
+ uiDefBut(block, BUT, B_CLOTH_CLEARCACHEALL, "All", 100, 100,100,20, NULL, 0.0, 0.0, 0, 0, "Free ALL cloth cache without preroll");
+ uiDefBut(block, BUT, B_CLOTH_CLEARCACHEFRAME, "From next frame", 200, 100,110,20, NULL, 0.0, 0.0, 0, 0, "Free cloth cache starting from next frame");
+ uiDefBut(block, LABEL, 0, " ", 10,80,300,20, NULL, 0.0, 0, 0, 0, "");
+ }
+ else
+ {
+ uiDefBut(block, LABEL, 0, " ", 10,100,300,40, NULL, 0.0, 0, 0, 0, "");
}
- }
- // uiBlockEndAlign(block);
-}
-static void object_panel_cloth_III(Object *ob)
-{
- uiBlock *block;
- static int val;
- uiBut *but;
- ClothModifierData *clmd = NULL;
-
- clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth);
- if(clmd)
- {
- if (!(clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_COLLOBJ))
+ /*
+ if(length>1) // B_CLOTH_CHANGEPREROLL
+ uiDefButI(block, NUM, B_CLOTH_CHANGEPREROLL, "Preroll:", 10,80,145,20, &clmd->sim_parms->preroll, 0, length-1, 1, 0, "Simulation starts on this frame");
+ else
+ uiDefBut(block, LABEL, 0, " ", 10,80,145,20, NULL, 0.0, 0, 0, 0, "");
+ */
+
+ uiDefButBitI(block, TOG, CLOTH_COLLISIONSETTINGS_FLAG_ENABLED, REDRAWVIEW3D, "Enable collisions", 10,60,150,20, &clmd->coll_parms->flags, 0, 0, 0, 0, "Enable collisions with this object");
+ if (clmd->coll_parms->flags & CLOTH_COLLISIONSETTINGS_FLAG_ENABLED)
{
- Cloth *cloth = clmd->clothObject;
- char str[128];
-
- block= uiNewBlock(&curarea->uiblocks, "object_panel_cloth_III", UI_EMBOSS, UI_HELV, curarea->win);
- uiNewPanelTabbed("Cloth", "Physics");
- if(uiNewPanel(curarea, block, "Cloth Collisions", "Physics", 651, 0, 318, 204)==0) return;
-
- uiSetButLock(object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
-
- uiBlockBeginAlign(block);
- uiDefButBitI(block, TOG, CLOTH_COLLISIONSETTINGS_FLAG_ENABLED, REDRAWVIEW3D, "Enable collisions", 10,70,130,20, &clmd->coll_parms.flags, 0, 0, 0, 0, "Enable collisions with this object");
- if (clmd->coll_parms.flags & CLOTH_COLLISIONSETTINGS_FLAG_ENABLED)
- {
- // uiDefBut(block, LABEL, 0, "",10,10,300,20, NULL, 0.0, 0, 0, 0, ""); /* tell UI we go to 10,10*/
- uiDefButF(block, NUM, B_CLOTH_RENEW, "Min Distance:", 10,30,150,20, &clmd->coll_parms.epsilon, 0.001f, 1.0, 0.01f, 0, "Minimum distance between collision objects before collision response takes in");
- uiDefBut(block, LABEL, 0, "",160,30,150,20, NULL, 0.0, 0, 0, 0, "");
- }
- else
- uiDefBut(block, LABEL, 0, "",140,10,170,20, NULL, 0.0, 0, 0, 0, "");
- uiBlockEndAlign(block);
+ uiDefButF(block, NUM, B_CLOTH_RENEW, "Min Distance:", 160,60,150,20, &clmd->coll_parms->epsilon, 0.001f, 1.0, 0.01f, 0, "Minimum distance between collision objects before collision response takes in");
}
+ else
+ uiDefBut(block, LABEL, 0, "",160,60,150,20, NULL, 0.0, 0, 0, 0, "");
}
- // uiBlockEndAlign(block);
+
+ uiBlockEndAlign(block);
+
}
-
void object_panels()
{
Object *ob;
@@ -5156,7 +5135,6 @@ void physics_panels()
object_softbodies_II(ob);
object_panel_cloth(ob);
object_panel_cloth_II(ob);
- object_panel_cloth_III(ob);
object_panel_fluidsim(ob);
}
}