makes bullet independant from gameengine for cmake, introduces esc-key during sim, disables collisions when no bullet there

This commit is contained in:
Daniel Genrich 2008-01-29 23:13:31 +00:00
parent 2e697f3b93
commit 7a7a52226f
9 changed files with 55 additions and 19 deletions

@ -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} ")

@ -29,12 +29,12 @@
IF(WITH_GAMEENGINE)
SUBDIRS(qhull solid)
IF(WITH_BULLET)
SUBDIRS(bullet2)
ENDIF(WITH_BULLET)
ENDIF(WITH_GAMEENGINE)
IF(WITH_BULLET)
SUBDIRS(bullet2)
ENDIF(WITH_BULLET)
IF(WITH_INTERNATIONAL)
SUBDIRS(bFTGL)
ENDIF(WITH_INTERNATIONAL)

@ -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));
////////////////////////////////////////////////

@ -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)

@ -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);

@ -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;
}

@ -4960,6 +4960,7 @@ static void clothModifier_initData(ModifierData *md)
return;
cloth_init (clmd);
if(G.rt >0)
printf("clothModifier_initData\n");
}

@ -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, "");

@ -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