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} ")
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)
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 */
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. */
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));
////////////////////////////////////////////////
MEdge *medge = NULL;
MFace *mface = NULL;
DerivedMesh *result = NULL;
+ int ret = 0;
if(G.rt > 0)
printf("clothModifier_do start\n");
// 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)
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);
return t2-t1;
}
#endif
+
+/* callbacks for errors and interrupts and some goo */
+static int (*CT_localInterruptCallBack)(void) = NULL;
+
/*
#define C99
#ifdef C99
step += dt;
if(effectors) pdEndEffectors(effectors);
+
+ /* ask for user break */
+ if (CT_localInterruptCallBack && CT_localInterruptCallBack())
+ return 0;
}
for(i = 0; i < numverts; i++)
if(G.rt > 0)
printf("implicit_set_positions\n");
}
+
+/* Cloth global visible functions */
+void clmdSetInterruptCallBack(int (*f)(void))
+{
+ CT_localInterruptCallBack = f;
+}
return;
cloth_init (clmd);
+ if(G.rt >0)
printf("clothModifier_initData\n");
}
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");
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;
{
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, "");
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