makes bullet independant from gameengine for cmake, introduces esc-key during sim...
authorDaniel Genrich <daniel.genrich@gmx.net>
Tue, 29 Jan 2008 23:13:31 +0000 (23:13 +0000)
committerDaniel Genrich <daniel.genrich@gmx.net>
Tue, 29 Jan 2008 23:13:31 +0000 (23:13 +0000)
CMakeLists.txt
extern/CMakeLists.txt
source/blender/blenkernel/BKE_cloth.h
source/blender/blenkernel/intern/cloth.c
source/blender/blenkernel/intern/collision.c
source/blender/blenkernel/intern/implicit.c
source/blender/blenkernel/intern/modifier.c
source/blender/src/buttons_object.c
tools/Blender.py

index 905fb6a26739080304d3d697bbc9e37d282b5ef8..933203a459e5fdc89f3e67e4dd278128d018857c 100644 (file)
@@ -408,6 +408,9 @@ INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
 IF(WITH_GAMEENGINE)
   SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DGAMEBLENDER ")
 ENDIF(WITH_GAMEENGINE)
+IF(WITH_BULLET)
+  SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DWITH_BULLET ")
+ENDIF(WITH_BULLET)
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS} ")
 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PLATFORM_CFLAGS} ")
 
index db2584d012efc087f3213829a183efa7c0c696b9..8d2e1f9dc9b25e8f1d014b4fc0ffadb59338d00d 100644 (file)
 
 IF(WITH_GAMEENGINE)
   SUBDIRS(qhull solid)
+ENDIF(WITH_GAMEENGINE)
 
-  IF(WITH_BULLET)
+IF(WITH_BULLET)
     SUBDIRS(bullet2)
-  ENDIF(WITH_BULLET)
-ENDIF(WITH_GAMEENGINE)
+ENDIF(WITH_BULLET)
 
 IF(WITH_INTERNATIONAL)
   SUBDIRS(bFTGL)
index 530601fe5afc2ae21d226edf9f738f6a828e3ae4..430a8fd50a63e06464b395dfe06cdc362014bcd7 100644 (file)
@@ -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));
 ////////////////////////////////////////////////
 
 
index f871a307325319f40ceed031d62b5a41f54b9400..dac77381175a864f2d4472aff58fef2dd82b609e 100644 (file)
@@ -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)
index 5946b842d85a9f5217d6c1541371b8f13f6c7dfd..7d2284e319343f37026415185f9c02f6eb0eebc2 100644 (file)
@@ -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);
index f56b94c97ce0fb3c33cefee6e1966410b01737b1..72edef1766b5d7197c6ab28d87be0dd86fa0d5bf 100644 (file)
@@ -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;
+}
index d552fdad5c2d3b35a0e5e12d541cf815328c4dd1..d243a8e3b3c7072a3f12c4a42d7203f3693ba4e6 100644 (file)
@@ -4960,6 +4960,7 @@ static void clothModifier_initData(ModifierData *md)
                return;
        
        cloth_init (clmd);
+       if(G.rt >0)
        printf("clothModifier_initData\n");
 }
 
index b6d7d4afd5c9a034297676339433e5694eb03ce8..210eb286951a96995aff58570a65d32977fd5d0b 100644 (file)
@@ -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, "");    
index 77262d6eaafbb64ecd12311c0092ff5d57d878b7..06ffba6912c3d5c84ba8e11c701e7902962d8148 100644 (file)
@@ -392,6 +392,8 @@ class BlenderEnvironment(SConsEnvironment):
             lenv.Append(CPPDEFINES=defines)
             if lenv['WITH_BF_GAMEENGINE']:
                     lenv.Append(CPPDEFINES=['GAMEBLENDER=1'])
+            if lenv['WITH_BF_BULLET']:
+                    lenv.Append(CPPDEFINES=['WITH_BULLET=1'])
             # debug or not
             # CXXFLAGS defaults to CCFLAGS, therefore
             #  we Replace() rather than Append() to CXXFLAGS the first time