diff options
author | Daniel Genrich <daniel.genrich@gmx.net> | 2008-01-30 02:13:31 +0300 |
---|---|---|
committer | Daniel Genrich <daniel.genrich@gmx.net> | 2008-01-30 02:13:31 +0300 |
commit | 7a7a52226f52952534c93832c3e7b0492ec0ad30 (patch) | |
tree | eef652aeff416bc8a3857172984d786c76861666 /source | |
parent | 2e697f3b9395eb0eb1649997588f3e73a4e1ba8b (diff) |
makes bullet independant from gameengine for cmake, introduces esc-key during sim, disables collisions when no bullet there
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_cloth.h | 21 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/cloth.c | 12 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/collision.c | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/implicit.c | 14 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/modifier.c | 1 | ||||
-rw-r--r-- | source/blender/src/buttons_object.c | 7 |
6 files changed, 46 insertions, 15 deletions
diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h index 530601fe5af..430a8fd50a6 100644 --- a/source/blender/blenkernel/BKE_cloth.h +++ b/source/blender/blenkernel/BKE_cloth.h @@ -130,14 +130,14 @@ ClothSpring; typedef enum { CLOTH_SIMSETTINGS_FLAG_RESET = ( 1 << 1 ), // The CM object requires a reinitializaiton. - CLOTH_SIMSETTINGS_FLAG_COLLOBJ = ( 1 << 2 ),// object is only collision object, no cloth simulation is done - CLOTH_SIMSETTINGS_FLAG_GOAL = ( 1 << 3 ), // we have goals enabled - CLOTH_SIMSETTINGS_FLAG_TEARING = ( 1 << 4 ),// true if tearing is enabled - CLOTH_SIMSETTINGS_FLAG_CCACHE_PROTECT = ( 1 << 5 ), // true if tearing is enabled - CLOTH_SIMSETTINGS_FLAG_EDITMODE = ( 1 << 6 ), // are we in editmode? -several things disabled - CLOTH_SIMSETTINGS_FLAG_CCACHE_FFREE = (1 << 7), /* force cache freeing */ - CLOTH_SIMSETTINGS_FLAG_SCALING = (1 << 8), /* is advanced scaling active? */ - CLOTH_SIMSETTINGS_FLAG_LOADED = (1 << 9), /* did we just got load? */ + CLOTH_SIMSETTINGS_FLAG_COLLOBJ = ( 1 << 2 ),// object is only collision object, no cloth simulation is done + CLOTH_SIMSETTINGS_FLAG_GOAL = ( 1 << 3 ), // we have goals enabled + CLOTH_SIMSETTINGS_FLAG_TEARING = ( 1 << 4 ),// true if tearing is enabled + CLOTH_SIMSETTINGS_FLAG_CCACHE_PROTECT = ( 1 << 5 ), // true if tearing is enabled + CLOTH_SIMSETTINGS_FLAG_EDITMODE = ( 1 << 6 ), // are we in editmode? -several things disabled + CLOTH_SIMSETTINGS_FLAG_CCACHE_FFREE = (1 << 7), /* force cache freeing */ + CLOTH_SIMSETTINGS_FLAG_SCALING = (1 << 8), /* is advanced scaling active? */ + CLOTH_SIMSETTINGS_FLAG_LOADED = (1 << 9), /* did we just got load? */ } CLOTH_SIMSETTINGS_FLAGS; /* COLLISION FLAGS */ @@ -159,7 +159,7 @@ typedef enum typedef enum { CLOTH_SPRING_FLAG_DEACTIVATE = ( 1 << 1 ), - CLOTH_SPRING_FLAG_NEEDED = ( 1 << 2 ), // springs has values to be applied + CLOTH_SPRING_FLAG_NEEDED = ( 1 << 2 ), // springs has values to be applied } CLOTH_SPRINGS_FLAGS; /* Bits to or into the ClothVertex.flags. */ @@ -190,6 +190,9 @@ int implicit_init ( Object *ob, ClothModifierData *clmd ); int implicit_free ( ClothModifierData *clmd ); int implicit_solver ( Object *ob, float frame, ClothModifierData *clmd, ListBase *effectors ); void implicit_set_positions ( ClothModifierData *clmd ); + +// globally needed +void clmdSetInterruptCallBack(int (*f)(void)); //////////////////////////////////////////////// diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index f871a307325..dac77381175 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -639,6 +639,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd,Object *ob, DerivedMesh *d MEdge *medge = NULL; MFace *mface = NULL; DerivedMesh *result = NULL; + int ret = 0; if(G.rt > 0) printf("clothModifier_do start\n"); @@ -782,12 +783,17 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd,Object *ob, DerivedMesh *d // Call the solver. if ( solvers [clmd->sim_parms->solver_type].solver ) - solvers [clmd->sim_parms->solver_type].solver ( ob, framenr, clmd, effectors ); + { + ret = solvers [clmd->sim_parms->solver_type].solver ( ob, framenr, clmd, effectors ); + } tend(); // printf ( "Cloth simulation time: %f\n", ( float ) tval() ); - - cloth_write_cache(ob, clmd, framenr); + + if(ret) + cloth_write_cache(ob, clmd, framenr); + else + clmd->sim_parms->sim_time--; // check for autoprotection if(framenr >= clmd->sim_parms->autoprotect) diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 5946b842d85..7d2284e3193 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -680,9 +680,13 @@ void cloth_collision_static(ClothModifierData *clmd, CollisionModifierData *coll if(i < 4) { // calc distance + normal +#if WITH_BULLET == 1 distance = plNearestPoints( 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); - +#else + // just be sure that we don't add anything + distance = 2.0 * (epsilon + ALMOST_ZERO); +#endif if (distance <= (epsilon + ALMOST_ZERO)) { // printf("dist: %f\n", (float)distance); diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index f56b94c97ce..72edef1766b 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -110,6 +110,10 @@ double itval() return t2-t1; } #endif + +/* callbacks for errors and interrupts and some goo */ +static int (*CT_localInterruptCallBack)(void) = NULL; + /* #define C99 #ifdef C99 @@ -1525,6 +1529,10 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase step += dt; if(effectors) pdEndEffectors(effectors); + + /* ask for user break */ + if (CT_localInterruptCallBack && CT_localInterruptCallBack()) + return 0; } for(i = 0; i < numverts; i++) @@ -1569,3 +1577,9 @@ void implicit_set_positions (ClothModifierData *clmd) if(G.rt > 0) printf("implicit_set_positions\n"); } + +/* Cloth global visible functions */ +void clmdSetInterruptCallBack(int (*f)(void)) +{ + CT_localInterruptCallBack = f; +} diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index d552fdad5c2..d243a8e3b3c 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -4960,6 +4960,7 @@ static void clothModifier_initData(ModifierData *md) return; cloth_init (clmd); + if(G.rt >0) printf("clothModifier_initData\n"); } diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index b6d7d4afd5c..210eb286951 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -3304,7 +3304,7 @@ static void object_panel_deflection(Object *ob) uiDefButF(block, NUM, B_DIFF, "Permeability: ", 160,80,150,20, &pd->pdef_perm, 0.0, 1.0, 10, 0, "Chance that the particle will pass through the mesh"); uiBlockEndAlign(block); - uiDefBut(block, LABEL, 0, "Soft Body", 160,60,150,20, NULL, 0.0, 0, 0, 0, ""); + uiDefBut(block, LABEL, 0, "Soft Body / Cloth", 160,60,150,20, NULL, 0.0, 0, 0, 0, ""); uiBlockBeginAlign(block); uiDefButF(block, NUM, B_FIELD_CHANGE, "Damping:", 160,40,150,20, &pd->pdef_sbdamp, 0.0, 1.0, 10, 0, "Amount of damping during soft body collision"); @@ -5123,6 +5123,9 @@ static void object_panel_cloth(Object *ob) int defCount; char *clvg1, *clvg2; char clmvg [] = "Vertex Groups%t|"; + + clmdSetInterruptCallBack(blender_test_break); // make softbody module ESC aware + G.afbreek=0; // init global break system val2=0; @@ -5265,7 +5268,7 @@ static void object_panel_cloth_II(Object *ob) { uiDefButF(block, NUM, REDRAWBUTSOBJECT, "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, can be changed for each frame"); uiDefButS(block, NUM, REDRAWBUTSOBJECT, "Collision Quality:", 10,40,150,20, &clmd->coll_parms->loop_count, 1.0, 100.0, 1.0, 0, "How many collision iterations should be done. (higher = better = slower), can be changed for each frame"); - uiDefButF(block, NUM, REDRAWBUTSOBJECT, "Friction:", 160,40,150,20, &clmd->coll_parms->friction, 1.0, 100.0, 1.0, 0, "Friction force if a collision happened"); + uiDefButF(block, NUM, REDRAWBUTSOBJECT, "Friction:", 160,40,150,20, &clmd->coll_parms->friction, 1.0, 100.0, 1.0, 0, "Friction force if a collision happened (high=slower movement when collided)"); } else uiDefBut(block, LABEL, 0, "",160,60,150,20, NULL, 0.0, 0, 0, 0, ""); |