Refactoring: another huge number of changes, renamed methods to start with lower-case.

This commit is contained in:
ejcoumans
2006-09-28 01:11:16 +00:00
parent d0f09040e9
commit 2b1657b1dd
185 changed files with 2103 additions and 2095 deletions

View File

@@ -90,7 +90,7 @@ void BspConverter::convertBsp(BspLoader& bspLoader,float scaling)
bool isEntity = false; bool isEntity = false;
btVector3 entityTarget(0.f,0.f,0.f); btVector3 entityTarget(0.f,0.f,0.f);
AddConvexVerticesCollider(vertices,isEntity,entityTarget); addConvexVerticesCollider(vertices,isEntity,entityTarget);
} }
} }
@@ -107,11 +107,11 @@ void BspConverter::convertBsp(BspLoader& bspLoader,float scaling)
for (i=0;i<bspLoader.m_num_entities;i++) for (i=0;i<bspLoader.m_num_entities;i++)
{ {
const BSPEntity& entity = bspLoader.m_entities[i]; const BSPEntity& entity = bspLoader.m_entities[i];
const char* cl = bspLoader.ValueForKey(&entity,"classname"); const char* cl = bspLoader.getValueForKey(&entity,"classname");
if ( !strcmp( cl, "trigger_push" ) ) { if ( !strcmp( cl, "trigger_push" ) ) {
btVector3 targetLocation(0.f,0.f,0.f); btVector3 targetLocation(0.f,0.f,0.f);
cl = bspLoader.ValueForKey(&entity,"target"); cl = bspLoader.getValueForKey(&entity,"target");
if ( strcmp( cl, "" ) ) { if ( strcmp( cl, "" ) ) {
//its not empty so ... //its not empty so ...
@@ -119,13 +119,13 @@ void BspConverter::convertBsp(BspLoader& bspLoader,float scaling)
const BSPEntity* targetentity = bspLoader.getEntityByValue( "targetname" , cl ); const BSPEntity* targetentity = bspLoader.getEntityByValue( "targetname" , cl );
if (targetentity) if (targetentity)
{ {
if (bspLoader.GetVectorForKey( targetentity , "origin",&targetLocation[0])) if (bspLoader.getVectorForKey( targetentity , "origin",&targetLocation[0]))
{ {
} }
} }
cl = bspLoader.ValueForKey(&entity,"model"); cl = bspLoader.getValueForKey(&entity,"model");
if ( strcmp( cl, "" ) ) { if ( strcmp( cl, "" ) ) {
// add the model as a brush // add the model as a brush
if (cl[0] == '*') if (cl[0] == '*')
@@ -164,7 +164,7 @@ void BspConverter::convertBsp(BspLoader& bspLoader,float scaling)
getVerticesFromPlaneEquations(planeEquations,vertices); getVerticesFromPlaneEquations(planeEquations,vertices);
bool isEntity=true; bool isEntity=true;
AddConvexVerticesCollider(vertices,isEntity,targetLocation); addConvexVerticesCollider(vertices,isEntity,targetLocation);
} }
} }

View File

@@ -35,7 +35,7 @@ class BspConverter
bool isInside(const std::vector<btVector3>& planeEquations, const btVector3& point, float margin); bool isInside(const std::vector<btVector3>& planeEquations, const btVector3& point, float margin);
///this callback is called for each brush that succesfully converted into vertices ///this callback is called for each brush that succesfully converted into vertices
virtual void AddConvexVerticesCollider(std::vector<btVector3>& vertices, bool isEntity, const btVector3& entityTargetLocation) = 0; virtual void addConvexVerticesCollider(std::vector<btVector3>& vertices, bool isEntity, const btVector3& entityTargetLocation) = 0;
}; };

View File

@@ -60,7 +60,7 @@ public:
{ {
} }
virtual void AddConvexVerticesCollider(std::vector<btVector3>& vertices, bool isEntity, const btVector3& entityTargetLocation) virtual void addConvexVerticesCollider(std::vector<btVector3>& vertices, bool isEntity, const btVector3& entityTargetLocation)
{ {
///perhaps we can do something special with entities (isEntity) ///perhaps we can do something special with entities (isEntity)
///like adding a collision Triggering (as example) ///like adding a collision Triggering (as example)
@@ -76,7 +76,7 @@ public:
//this create an internal copy of the vertices //this create an internal copy of the vertices
btCollisionShape* shape = new btConvexHullShape(&vertices[0],vertices.size()); btCollisionShape* shape = new btConvexHullShape(&vertices[0],vertices.size());
m_demoApp->LocalCreatePhysicsObject(isDynamic, mass, startTransform,shape); m_demoApp->localCreatePhysicsObject(isDynamic, mass, startTransform,shape);
} }
} }
}; };
@@ -168,7 +168,7 @@ void BspDemo::initPhysics(char* bspfilename)
//how to detect file size? //how to detect file size?
memoryBuffer = malloc(size+1); memoryBuffer = malloc(size+1);
fread(memoryBuffer,1,size,file); fread(memoryBuffer,1,size,file);
bspLoader.LoadBSPFile( memoryBuffer); bspLoader.loadBSPFile( memoryBuffer);
BspToBulletConverter bsp2bullet(this); BspToBulletConverter bsp2bullet(this);
float bspScaling = 0.1f; float bspScaling = 0.1f;

View File

@@ -40,12 +40,12 @@ bool endofscript;
bool tokenready; // only true if UnGetToken was just called bool tokenready; // only true if UnGetToken was just called
// //
//LoadBSPFile //loadBSPFile
// //
int extrasize = 100; int extrasize = 100;
bool BspLoader::LoadBSPFile( void* memoryBuffer) { bool BspLoader::loadBSPFile( void* memoryBuffer) {
BSPHeader *header = (BSPHeader*) memoryBuffer; BSPHeader *header = (BSPHeader*) memoryBuffer;
@@ -53,73 +53,73 @@ bool BspLoader::LoadBSPFile( void* memoryBuffer) {
if (header) if (header)
{ {
// swap the header // swap the header
SwapBlock( (int *)header, sizeof(*header) ); swapBlock( (int *)header, sizeof(*header) );
int length = (header->lumps[BSPLUMP_SHADERS].filelen) / sizeof(BSPShader); int length = (header->lumps[BSPLUMP_SHADERS].filelen) / sizeof(BSPShader);
m_dshaders.resize(length+extrasize); m_dshaders.resize(length+extrasize);
m_numShaders = CopyLump( header, BSPLUMP_SHADERS, &m_dshaders[0], sizeof(BSPShader) ); m_numShaders = copyLump( header, BSPLUMP_SHADERS, &m_dshaders[0], sizeof(BSPShader) );
length = (header->lumps[LUMP_MODELS].filelen) / sizeof(BSPModel); length = (header->lumps[LUMP_MODELS].filelen) / sizeof(BSPModel);
m_dmodels.resize(length+extrasize); m_dmodels.resize(length+extrasize);
m_nummodels = CopyLump( header, LUMP_MODELS, &m_dmodels[0], sizeof(BSPModel) ); m_nummodels = copyLump( header, LUMP_MODELS, &m_dmodels[0], sizeof(BSPModel) );
length = (header->lumps[BSPLUMP_PLANES].filelen) / sizeof(BSPPlane); length = (header->lumps[BSPLUMP_PLANES].filelen) / sizeof(BSPPlane);
m_dplanes.resize(length+extrasize); m_dplanes.resize(length+extrasize);
m_numplanes = CopyLump( header, BSPLUMP_PLANES, &m_dplanes[0], sizeof(BSPPlane) ); m_numplanes = copyLump( header, BSPLUMP_PLANES, &m_dplanes[0], sizeof(BSPPlane) );
length = (header->lumps[BSPLUMP_LEAFS].filelen) / sizeof(BSPLeaf); length = (header->lumps[BSPLUMP_LEAFS].filelen) / sizeof(BSPLeaf);
m_dleafs.resize(length+extrasize); m_dleafs.resize(length+extrasize);
m_numleafs = CopyLump( header, BSPLUMP_LEAFS, &m_dleafs[0], sizeof(BSPLeaf) ); m_numleafs = copyLump( header, BSPLUMP_LEAFS, &m_dleafs[0], sizeof(BSPLeaf) );
length = (header->lumps[BSPLUMP_NODES].filelen) / sizeof(BSPNode); length = (header->lumps[BSPLUMP_NODES].filelen) / sizeof(BSPNode);
m_dnodes.resize(length+extrasize); m_dnodes.resize(length+extrasize);
m_numnodes = CopyLump( header, BSPLUMP_NODES, &m_dnodes[0], sizeof(BSPNode) ); m_numnodes = copyLump( header, BSPLUMP_NODES, &m_dnodes[0], sizeof(BSPNode) );
length = (header->lumps[BSPLUMP_LEAFSURFACES].filelen) / sizeof(m_dleafsurfaces[0]); length = (header->lumps[BSPLUMP_LEAFSURFACES].filelen) / sizeof(m_dleafsurfaces[0]);
m_dleafsurfaces.resize(length+extrasize); m_dleafsurfaces.resize(length+extrasize);
m_numleafsurfaces = CopyLump( header, BSPLUMP_LEAFSURFACES, &m_dleafsurfaces[0], sizeof(m_dleafsurfaces[0]) ); m_numleafsurfaces = copyLump( header, BSPLUMP_LEAFSURFACES, &m_dleafsurfaces[0], sizeof(m_dleafsurfaces[0]) );
length = (header->lumps[BSPLUMP_LEAFBRUSHES].filelen) / sizeof(m_dleafbrushes[0]) ; length = (header->lumps[BSPLUMP_LEAFBRUSHES].filelen) / sizeof(m_dleafbrushes[0]) ;
m_dleafbrushes.resize(length+extrasize); m_dleafbrushes.resize(length+extrasize);
m_numleafbrushes = CopyLump( header, BSPLUMP_LEAFBRUSHES, &m_dleafbrushes[0], sizeof(m_dleafbrushes[0]) ); m_numleafbrushes = copyLump( header, BSPLUMP_LEAFBRUSHES, &m_dleafbrushes[0], sizeof(m_dleafbrushes[0]) );
length = (header->lumps[LUMP_BRUSHES].filelen) / sizeof(BSPBrush); length = (header->lumps[LUMP_BRUSHES].filelen) / sizeof(BSPBrush);
m_dbrushes.resize(length+extrasize); m_dbrushes.resize(length+extrasize);
m_numbrushes = CopyLump( header, LUMP_BRUSHES, &m_dbrushes[0], sizeof(BSPBrush) ); m_numbrushes = copyLump( header, LUMP_BRUSHES, &m_dbrushes[0], sizeof(BSPBrush) );
length = (header->lumps[LUMP_BRUSHSIDES].filelen) / sizeof(BSPBrushSide); length = (header->lumps[LUMP_BRUSHSIDES].filelen) / sizeof(BSPBrushSide);
m_dbrushsides.resize(length+extrasize); m_dbrushsides.resize(length+extrasize);
m_numbrushsides = CopyLump( header, LUMP_BRUSHSIDES, &m_dbrushsides[0], sizeof(BSPBrushSide) ); m_numbrushsides = copyLump( header, LUMP_BRUSHSIDES, &m_dbrushsides[0], sizeof(BSPBrushSide) );
length = (header->lumps[LUMP_SURFACES].filelen) / sizeof(BSPSurface); length = (header->lumps[LUMP_SURFACES].filelen) / sizeof(BSPSurface);
m_drawSurfaces.resize(length+extrasize); m_drawSurfaces.resize(length+extrasize);
m_numDrawSurfaces = CopyLump( header, LUMP_SURFACES, &m_drawSurfaces[0], sizeof(BSPSurface) ); m_numDrawSurfaces = copyLump( header, LUMP_SURFACES, &m_drawSurfaces[0], sizeof(BSPSurface) );
length = (header->lumps[LUMP_DRAWINDEXES].filelen) / sizeof(m_drawIndexes[0]); length = (header->lumps[LUMP_DRAWINDEXES].filelen) / sizeof(m_drawIndexes[0]);
m_drawIndexes.resize(length+extrasize); m_drawIndexes.resize(length+extrasize);
m_numDrawIndexes = CopyLump( header, LUMP_DRAWINDEXES, &m_drawIndexes[0], sizeof(m_drawIndexes[0]) ); m_numDrawIndexes = copyLump( header, LUMP_DRAWINDEXES, &m_drawIndexes[0], sizeof(m_drawIndexes[0]) );
length = (header->lumps[LUMP_VISIBILITY].filelen) / 1; length = (header->lumps[LUMP_VISIBILITY].filelen) / 1;
m_visBytes.resize(length+extrasize); m_visBytes.resize(length+extrasize);
m_numVisBytes = CopyLump( header, LUMP_VISIBILITY, &m_visBytes[0], 1 ); m_numVisBytes = copyLump( header, LUMP_VISIBILITY, &m_visBytes[0], 1 );
length = (header->lumps[LUMP_LIGHTMAPS].filelen) / 1; length = (header->lumps[LUMP_LIGHTMAPS].filelen) / 1;
m_lightBytes.resize(length+extrasize); m_lightBytes.resize(length+extrasize);
m_numLightBytes = CopyLump( header, LUMP_LIGHTMAPS, &m_lightBytes[0], 1 ); m_numLightBytes = copyLump( header, LUMP_LIGHTMAPS, &m_lightBytes[0], 1 );
length = (header->lumps[BSPLUMP_ENTITIES].filelen) / 1; length = (header->lumps[BSPLUMP_ENTITIES].filelen) / 1;
m_dentdata.resize(length+extrasize); m_dentdata.resize(length+extrasize);
m_entdatasize = CopyLump( header, BSPLUMP_ENTITIES, &m_dentdata[0], 1); m_entdatasize = copyLump( header, BSPLUMP_ENTITIES, &m_dentdata[0], 1);
length = (header->lumps[LUMP_LIGHTGRID].filelen) / 1; length = (header->lumps[LUMP_LIGHTGRID].filelen) / 1;
m_gridData.resize(length+extrasize); m_gridData.resize(length+extrasize);
m_numGridPoints = CopyLump( header, LUMP_LIGHTGRID, &m_gridData[0], 8 ); m_numGridPoints = copyLump( header, LUMP_LIGHTGRID, &m_gridData[0], 8 );
// swap everything // swap everything
SwapBSPFile(); swapBSPFile();
return true; return true;
@@ -129,7 +129,7 @@ bool BspLoader::LoadBSPFile( void* memoryBuffer) {
const char* BspLoader::ValueForKey( const BSPEntity* ent, const char* key ) const { const char* BspLoader::getValueForKey( const BSPEntity* ent, const char* key ) const {
const BSPKeyValuePair* ep; const BSPKeyValuePair* ep;
@@ -141,17 +141,17 @@ const char* BspLoader::ValueForKey( const BSPEntity* ent, const char* key ) con
return ""; return "";
} }
float BspLoader::FloatForKey( const BSPEntity *ent, const char *key ) { float BspLoader::getFloatForKey( const BSPEntity *ent, const char *key ) {
const char *k; const char *k;
k = ValueForKey( ent, key ); k = getValueForKey( ent, key );
return float(atof(k)); return float(atof(k));
} }
bool BspLoader::GetVectorForKey( const BSPEntity *ent, const char *key, BSPVector3 vec ) { bool BspLoader::getVectorForKey( const BSPEntity *ent, const char *key, BSPVector3 vec ) {
const char *k; const char *k;
k = ValueForKey (ent, key); k = getValueForKey (ent, key);
if (strcmp(k, "")) if (strcmp(k, ""))
{ {
sscanf (k, "%f %f %f", &vec[0], &vec[1], &vec[2]); sscanf (k, "%f %f %f", &vec[0], &vec[1], &vec[2]);
@@ -165,10 +165,10 @@ bool BspLoader::GetVectorForKey( const BSPEntity *ent, const char *key, BSPVect
/* /*
============== ==============
ParseFromMemory parseFromMemory
============== ==============
*/ */
void BspLoader::ParseFromMemory (char *buffer, int size) void BspLoader::parseFromMemory (char *buffer, int size)
{ {
script = scriptstack; script = scriptstack;
script++; script++;
@@ -188,7 +188,7 @@ void BspLoader::ParseFromMemory (char *buffer, int size)
} }
bool BspLoader::EndOfScript (bool crossline) bool BspLoader::isEndOfScript (bool crossline)
{ {
if (!crossline) if (!crossline)
//printf("Line %i is incomplete\n",scriptline); //printf("Line %i is incomplete\n",scriptline);
@@ -208,16 +208,16 @@ bool BspLoader::EndOfScript (bool crossline)
script--; script--;
scriptline = script->line; scriptline = script->line;
//printf ("returning to %s\n", script->filename); //printf ("returning to %s\n", script->filename);
return GetToken (crossline); return getToken (crossline);
} }
/* /*
============== ==============
GetToken getToken
============== ==============
*/ */
bool BspLoader::GetToken (bool crossline) bool BspLoader::getToken (bool crossline)
{ {
char *token_p; char *token_p;
@@ -228,7 +228,7 @@ bool BspLoader::GetToken (bool crossline)
} }
if (script->script_p >= script->end_p) if (script->script_p >= script->end_p)
return EndOfScript (crossline); return isEndOfScript (crossline);
// //
// skip space // skip space
@@ -237,7 +237,7 @@ skipspace:
while (*script->script_p <= 32) while (*script->script_p <= 32)
{ {
if (script->script_p >= script->end_p) if (script->script_p >= script->end_p)
return EndOfScript (crossline); return isEndOfScript (crossline);
if (*script->script_p++ == '\n') if (*script->script_p++ == '\n')
{ {
if (!crossline) if (!crossline)
@@ -249,7 +249,7 @@ skipspace:
} }
if (script->script_p >= script->end_p) if (script->script_p >= script->end_p)
return EndOfScript (crossline); return isEndOfScript (crossline);
// ; # // comments // ; # // comments
if (*script->script_p == ';' || *script->script_p == '#' if (*script->script_p == ';' || *script->script_p == '#'
@@ -261,7 +261,7 @@ skipspace:
} }
while (*script->script_p++ != '\n') while (*script->script_p++ != '\n')
if (script->script_p >= script->end_p) if (script->script_p >= script->end_p)
return EndOfScript (crossline); return isEndOfScript (crossline);
scriptline = script->line++; scriptline = script->line++;
goto skipspace; goto skipspace;
} }
@@ -281,7 +281,7 @@ skipspace:
} }
script->script_p++; script->script_p++;
if (script->script_p >= script->end_p) if (script->script_p >= script->end_p)
return EndOfScript (crossline); return isEndOfScript (crossline);
} }
script->script_p += 2; script->script_p += 2;
goto skipspace; goto skipspace;
@@ -324,9 +324,9 @@ skipspace:
if (!strcmp (token, "$include")) if (!strcmp (token, "$include"))
{ {
//GetToken (false); //getToken (false);
//AddScriptToStack (token); //AddScriptToStack (token);
return false;//GetToken (crossline); return false;//getToken (crossline);
} }
return true; return true;
@@ -340,7 +340,7 @@ char *BspLoader::copystring(const char *s)
return b; return b;
} }
void BspLoader::StripTrailing( char *e ) { void BspLoader::stripTrailing( char *e ) {
char *s; char *s;
s = e + strlen(e)-1; s = e + strlen(e)-1;
@@ -352,10 +352,10 @@ void BspLoader::StripTrailing( char *e ) {
} }
/* /*
================= =================
ParseEpair parseEpair
================= =================
*/ */
BSPKeyValuePair *BspLoader::ParseEpair( void ) { BSPKeyValuePair *BspLoader::parseEpair( void ) {
BSPKeyValuePair *e; BSPKeyValuePair *e;
e = (struct BSPPair*) malloc( sizeof(BSPKeyValuePair)); e = (struct BSPPair*) malloc( sizeof(BSPKeyValuePair));
@@ -365,7 +365,7 @@ BSPKeyValuePair *BspLoader::ParseEpair( void ) {
//printf ("ParseEpar: token too long"); //printf ("ParseEpar: token too long");
} }
e->key = copystring( token ); e->key = copystring( token );
GetToken( false ); getToken( false );
if ( strlen(token) >= BSPMAX_VALUE-1 ) { if ( strlen(token) >= BSPMAX_VALUE-1 ) {
//printf ("ParseEpar: token too long"); //printf ("ParseEpar: token too long");
@@ -374,8 +374,8 @@ BSPKeyValuePair *BspLoader::ParseEpair( void ) {
// strip trailing spaces that sometimes get accidentally // strip trailing spaces that sometimes get accidentally
// added in the editor // added in the editor
StripTrailing( e->key ); stripTrailing( e->key );
StripTrailing( e->value ); stripTrailing( e->value );
return e; return e;
} }
@@ -383,20 +383,20 @@ BSPKeyValuePair *BspLoader::ParseEpair( void ) {
/* /*
================ ================
ParseEntity parseEntity
================ ================
*/ */
bool BspLoader::ParseEntity( void ) { bool BspLoader::parseEntity( void ) {
BSPKeyValuePair *e; BSPKeyValuePair *e;
BSPEntity *mapent; BSPEntity *mapent;
if ( !GetToken (true) ) { if ( !getToken (true) ) {
return false; return false;
} }
if ( strcmp (token, "{") ) { if ( strcmp (token, "{") ) {
//printf ("ParseEntity: { not found"); //printf ("parseEntity: { not found");
} }
BSPEntity bla; BSPEntity bla;
@@ -413,13 +413,13 @@ bool BspLoader::ParseEntity( void ) {
m_num_entities++; m_num_entities++;
do { do {
if ( !GetToken (true) ) { if ( !getToken (true) ) {
//printf("ParseEntity: EOF without closing brace"); //printf("parseEntity: EOF without closing brace");
} }
if ( !strcmp (token, "}") ) { if ( !strcmp (token, "}") ) {
break; break;
} }
e = (struct BSPPair*)ParseEpair (); e = (struct BSPPair*)parseEpair ();
e->next = mapent->epairs; e->next = mapent->epairs;
mapent->epairs = e; mapent->epairs = e;
} while (1); } while (1);
@@ -429,18 +429,18 @@ bool BspLoader::ParseEntity( void ) {
/* /*
================ ================
ParseEntities parseEntities
Parses the dentdata string into entities Parses the dentdata string into entities
================ ================
*/ */
void BspLoader::ParseEntities( void ) { void BspLoader::parseEntities( void ) {
m_num_entities = 0; m_num_entities = 0;
m_entities.clear(); m_entities.clear();
ParseFromMemory( &m_dentdata[0], m_entdatasize ); parseFromMemory( &m_dentdata[0], m_entdatasize );
while ( ParseEntity () ) { while ( parseEntity () ) {
} }
} }
@@ -456,7 +456,7 @@ int BspLoader::getMachineEndianness()
return BSP_BIG_ENDIAN; return BSP_BIG_ENDIAN;
} }
short BspLoader::LittleShort (short l) short BspLoader::isLittleShort (short l)
{ {
if (machineEndianness() == BSP_BIG_ENDIAN) if (machineEndianness() == BSP_BIG_ENDIAN)
{ {
@@ -471,7 +471,7 @@ short BspLoader::LittleShort (short l)
return l; return l;
} }
short BspLoader::BigShort (short l) short BspLoader::isBigShort (short l)
{ {
if (machineEndianness() == BSP_BIG_ENDIAN) if (machineEndianness() == BSP_BIG_ENDIAN)
{ {
@@ -490,7 +490,7 @@ short BspLoader::BigShort (short l)
} }
int BspLoader::LittleLong (int l) int BspLoader::isLittleLong (int l)
{ {
if (machineEndianness() == BSP_BIG_ENDIAN) if (machineEndianness() == BSP_BIG_ENDIAN)
{ {
@@ -509,7 +509,7 @@ int BspLoader::LittleLong (int l)
} }
int BspLoader::BigLong (int l) int BspLoader::isBigLong (int l)
{ {
if (machineEndianness() == BSP_BIG_ENDIAN) if (machineEndianness() == BSP_BIG_ENDIAN)
{ {
@@ -529,7 +529,7 @@ int BspLoader::BigLong (int l)
} }
float BspLoader::LittleFloat (float l) float BspLoader::isLittleFloat (float l)
{ {
if (machineEndianness() == BSP_BIG_ENDIAN) if (machineEndianness() == BSP_BIG_ENDIAN)
{ {
@@ -548,7 +548,7 @@ float BspLoader::LittleFloat (float l)
return l; return l;
} }
float BspLoader::BigFloat (float l) float BspLoader::isBigFloat (float l)
{ {
if (machineEndianness() == BSP_BIG_ENDIAN) if (machineEndianness() == BSP_BIG_ENDIAN)
{ {
@@ -572,31 +572,31 @@ float BspLoader::BigFloat (float l)
// //
// SwapBlock // swapBlock
// If all values are 32 bits, this can be used to swap everything // If all values are 32 bits, this can be used to swap everything
// //
void BspLoader::SwapBlock( int *block, int sizeOfBlock ) { void BspLoader::swapBlock( int *block, int sizeOfBlock ) {
int i; int i;
sizeOfBlock >>= 2; sizeOfBlock >>= 2;
for ( i = 0 ; i < sizeOfBlock ; i++ ) { for ( i = 0 ; i < sizeOfBlock ; i++ ) {
block[i] = LittleLong( block[i] ); block[i] = isLittleLong( block[i] );
} }
} }
// //
// CopyLump // copyLump
// //
int BspLoader::CopyLump( BSPHeader *header, int lump, void *dest, int size ) { int BspLoader::copyLump( BSPHeader *header, int lump, void *dest, int size ) {
int length, ofs; int length, ofs;
length = header->lumps[lump].filelen; length = header->lumps[lump].filelen;
ofs = header->lumps[lump].fileofs; ofs = header->lumps[lump].fileofs;
//if ( length % size ) { //if ( length % size ) {
// printf ("LoadBSPFile: odd lump size"); // printf ("loadBSPFile: odd lump size");
//} //}
memcpy( dest, (unsigned char *)header + ofs, length ); memcpy( dest, (unsigned char *)header + ofs, length );
@@ -608,52 +608,52 @@ int BspLoader::CopyLump( BSPHeader *header, int lump, void *dest, int size ) {
// //
// SwapBSPFile // swapBSPFile
// //
void BspLoader::SwapBSPFile( void ) { void BspLoader::swapBSPFile( void ) {
int i; int i;
// models // models
SwapBlock( (int *) &m_dmodels[0], m_nummodels * sizeof( m_dmodels[0] ) ); swapBlock( (int *) &m_dmodels[0], m_nummodels * sizeof( m_dmodels[0] ) );
// shaders (don't swap the name) // shaders (don't swap the name)
for ( i = 0 ; i < m_numShaders ; i++ ) { for ( i = 0 ; i < m_numShaders ; i++ ) {
m_dshaders[i].contentFlags = LittleLong( m_dshaders[i].contentFlags ); m_dshaders[i].contentFlags = isLittleLong( m_dshaders[i].contentFlags );
m_dshaders[i].surfaceFlags = LittleLong( m_dshaders[i].surfaceFlags ); m_dshaders[i].surfaceFlags = isLittleLong( m_dshaders[i].surfaceFlags );
} }
// planes // planes
SwapBlock( (int *)&m_dplanes[0], m_numplanes * sizeof( m_dplanes[0] ) ); swapBlock( (int *)&m_dplanes[0], m_numplanes * sizeof( m_dplanes[0] ) );
// nodes // nodes
SwapBlock( (int *)&m_dnodes[0], m_numnodes * sizeof( m_dnodes[0] ) ); swapBlock( (int *)&m_dnodes[0], m_numnodes * sizeof( m_dnodes[0] ) );
// leafs // leafs
SwapBlock( (int *)&m_dleafs[0], m_numleafs * sizeof( m_dleafs[0] ) ); swapBlock( (int *)&m_dleafs[0], m_numleafs * sizeof( m_dleafs[0] ) );
// leaffaces // leaffaces
SwapBlock( (int *)&m_dleafsurfaces[0], m_numleafsurfaces * sizeof( m_dleafsurfaces[0] ) ); swapBlock( (int *)&m_dleafsurfaces[0], m_numleafsurfaces * sizeof( m_dleafsurfaces[0] ) );
// leafbrushes // leafbrushes
SwapBlock( (int *)&m_dleafbrushes[0], m_numleafbrushes * sizeof( m_dleafbrushes[0] ) ); swapBlock( (int *)&m_dleafbrushes[0], m_numleafbrushes * sizeof( m_dleafbrushes[0] ) );
// brushes // brushes
SwapBlock( (int *)&m_dbrushes[0], m_numbrushes * sizeof( m_dbrushes[0] ) ); swapBlock( (int *)&m_dbrushes[0], m_numbrushes * sizeof( m_dbrushes[0] ) );
// brushsides // brushsides
SwapBlock( (int *)&m_dbrushsides[0], m_numbrushsides * sizeof( m_dbrushsides[0] ) ); swapBlock( (int *)&m_dbrushsides[0], m_numbrushsides * sizeof( m_dbrushsides[0] ) );
// vis // vis
((int *)&m_visBytes)[0] = LittleLong( ((int *)&m_visBytes)[0] ); ((int *)&m_visBytes)[0] = isLittleLong( ((int *)&m_visBytes)[0] );
((int *)&m_visBytes)[1] = LittleLong( ((int *)&m_visBytes)[1] ); ((int *)&m_visBytes)[1] = isLittleLong( ((int *)&m_visBytes)[1] );
// drawindexes // drawindexes
SwapBlock( (int *)&m_drawIndexes[0], m_numDrawIndexes * sizeof( m_drawIndexes[0] ) ); swapBlock( (int *)&m_drawIndexes[0], m_numDrawIndexes * sizeof( m_drawIndexes[0] ) );
// drawsurfs // drawsurfs
SwapBlock( (int *)&m_drawSurfaces[0], m_numDrawSurfaces * sizeof( m_drawSurfaces[0] ) ); swapBlock( (int *)&m_drawSurfaces[0], m_numDrawSurfaces * sizeof( m_drawSurfaces[0] ) );
} }
@@ -668,17 +668,17 @@ bool BspLoader::findVectorByName(float* outvec,const char* name)
bool found = false; bool found = false;
ParseEntities(); parseEntities();
for ( int i = 1; i < m_num_entities; i++ ) { for ( int i = 1; i < m_num_entities; i++ ) {
cl = ValueForKey (&m_entities[i], "classname"); cl = getValueForKey (&m_entities[i], "classname");
if ( !strcmp( cl, "info_player_start" ) ) { if ( !strcmp( cl, "info_player_start" ) ) {
GetVectorForKey( &m_entities[i], "origin", origin ); getVectorForKey( &m_entities[i], "origin", origin );
found = true; found = true;
break; break;
} }
if ( !strcmp( cl, "info_player_deathmatch" ) ) { if ( !strcmp( cl, "info_player_deathmatch" ) ) {
GetVectorForKey( &m_entities[i], "origin", origin ); getVectorForKey( &m_entities[i], "origin", origin );
found = true; found = true;
break; break;
} }
@@ -703,7 +703,7 @@ const BSPEntity * BspLoader::getEntityByValue( const char* name, const char* val
const BSPEntity& ent = m_entities[i]; const BSPEntity& ent = m_entities[i];
const char* cl = ValueForKey (&m_entities[i], name); const char* cl = getValueForKey (&m_entities[i], name);
if ( !strcmp( cl, value ) ) { if ( !strcmp( cl, value ) ) {
entity = &ent; entity = &ent;
break; break;

View File

@@ -184,15 +184,15 @@ class BspLoader
printf("Machine is Little Endian\n"); printf("Machine is Little Endian\n");
} }
} }
bool LoadBSPFile( void* memoryBuffer); bool loadBSPFile( void* memoryBuffer);
const char* ValueForKey( const BSPEntity *ent, const char *key ) const; const char* getValueForKey( const BSPEntity *ent, const char *key ) const;
bool GetVectorForKey( const BSPEntity *ent, const char *key, BSPVector3 vec ); bool getVectorForKey( const BSPEntity *ent, const char *key, BSPVector3 vec );
float FloatForKey( const BSPEntity *ent, const char *key ); float getFloatForKey( const BSPEntity *ent, const char *key );
void ParseEntities( void ); void parseEntities( void );
bool findVectorByName(float* outvec,const char* name); bool findVectorByName(float* outvec,const char* name);
@@ -201,35 +201,35 @@ class BspLoader
protected: protected:
void ParseFromMemory (char *buffer, int size); void parseFromMemory (char *buffer, int size);
bool EndOfScript (bool crossline); bool isEndOfScript (bool crossline);
bool GetToken (bool crossline); bool getToken (bool crossline);
char *copystring(const char *s); char *copystring(const char *s);
void StripTrailing( char *e ); void stripTrailing( char *e );
BSPKeyValuePair * ParseEpair( void ); BSPKeyValuePair * parseEpair( void );
bool ParseEntity( void ); bool parseEntity( void );
short LittleShort (short l); short isLittleShort (short l);
int LittleLong (int l); int isLittleLong (int l);
float LittleFloat (float l); float isLittleFloat (float l);
int BigLong (int l); int isBigLong (int l);
short BigShort (short l); short isBigShort (short l);
float BigFloat (float l); float isBigFloat (float l);
void SwapBlock( int *block, int sizeOfBlock ); void swapBlock( int *block, int sizeOfBlock );
int CopyLump( BSPHeader *header, int lump, void *dest, int size ); int copyLump( BSPHeader *header, int lump, void *dest, int size );
void SwapBSPFile( void ); void swapBSPFile( void );

View File

@@ -29,7 +29,7 @@ subject to the following restrictions:
#include <stdio.h> //printf debugging #include <stdio.h> //printf debugging
float deltaTime = 1.f/60.f; float deltaTime = 1.f/60.f;
float gCollisionMargin = 0.05f;
#include "CcdPhysicsDemo.h" #include "CcdPhysicsDemo.h"
#include "GL_ShapeDrawer.h" #include "GL_ShapeDrawer.h"
@@ -77,7 +77,8 @@ btCollisionShape* shapePtr[numShapes] =
new btBoxShape (btVector3(50,10,50)), new btBoxShape (btVector3(50,10,50)),
#endif #endif
new btBoxShape (btVector3(CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS)), new btCylinderShape (btVector3(CUBE_HALF_EXTENTS-gCollisionMargin,CUBE_HALF_EXTENTS-gCollisionMargin,CUBE_HALF_EXTENTS-gCollisionMargin)),
//new btBoxShape (btVector3(CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS)),
new btSphereShape (CUBE_HALF_EXTENTS- 0.05f), new btSphereShape (CUBE_HALF_EXTENTS- 0.05f),
//new btConeShape(CUBE_HALF_EXTENTS,2.f*CUBE_HALF_EXTENTS), //new btConeShape(CUBE_HALF_EXTENTS,2.f*CUBE_HALF_EXTENTS),
@@ -109,7 +110,7 @@ int main(int argc,char** argv)
ccdDemo->setCameraDistance(26.f); ccdDemo->setCameraDistance(26.f);
return glutmain(argc, argv,640,480,"Bullet Physics Demo. http://www.continuousphysics.com/Bullet/phpBB2/",ccdDemo); return glutmain(argc, argv,640,480,"Bullet Physics Demo. http://bullet.sf.net",ccdDemo);
} }
@@ -190,16 +191,16 @@ void CcdPhysicsDemo::clientResetScene()
if ((getDebugMode() & btIDebugDraw::DBG_NoHelpText)) if ((getDebugMode() & btIDebugDraw::DBG_NoHelpText))
{ {
if (ctrl->GetRigidBody()->GetCollisionShape()->GetShapeType() != SPHERE_SHAPE_PROXYTYPE) if (ctrl->getRigidBody()->getCollisionShape()->getShapeType() != SPHERE_SHAPE_PROXYTYPE)
{ {
ctrl->GetRigidBody()->SetCollisionShape(shapePtr[2]); ctrl->getRigidBody()->SetCollisionShape(shapePtr[2]);
} else } else
{ {
ctrl->GetRigidBody()->SetCollisionShape(shapePtr[1]); ctrl->getRigidBody()->SetCollisionShape(shapePtr[1]);
} }
btBroadphaseProxy* bpproxy = ctrl->GetRigidBody()->m_broadphaseHandle; btBroadphaseProxy* bpproxy = ctrl->getRigidBody()->m_broadphaseHandle;
m_physicsEnvironmentPtr->GetBroadphase()->CleanProxyFromPairs(bpproxy); m_physicsEnvironmentPtr->getBroadphase()->cleanProxyFromPairs(bpproxy);
} }
//stack them //stack them
@@ -245,7 +246,7 @@ void CcdPhysicsDemo::initPhysics()
// btOverlappingPairCache* broadphase = new btSimpleBroadphase; // btOverlappingPairCache* broadphase = new btSimpleBroadphase;
#ifdef REGISTER_CUSTOM_COLLISION_ALGORITHM #ifdef REGISTER_CUSTOM_COLLISION_ALGORITHM
dispatcher->RegisterCollisionCreateFunc(SPHERE_SHAPE_PROXYTYPE,SPHERE_SHAPE_PROXYTYPE,new btSphereSphereCollisionAlgorithm::CreateFunc); dispatcher->registerCollisionCreateFunc(SPHERE_SHAPE_PROXYTYPE,SPHERE_SHAPE_PROXYTYPE,new btSphereSphereCollisionAlgorithm::CreateFunc);
#endif //REGISTER_CUSTOM_COLLISION_ALGORITHM #endif //REGISTER_CUSTOM_COLLISION_ALGORITHM
btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver; btSequentialImpulseConstraintSolver* solver = new btSequentialImpulseConstraintSolver;
@@ -255,7 +256,7 @@ void CcdPhysicsDemo::initPhysics()
#ifdef USER_DEFINED_FRICTION_MODEL #ifdef USER_DEFINED_FRICTION_MODEL
btSequentialImpulseConstraintSolver* solver = (btSequentialImpulseConstraintSolver*) m_physicsEnvironmentPtr->GetConstraintSolver(); btSequentialImpulseConstraintSolver* solver = (btSequentialImpulseConstraintSolver*) m_physicsEnvironmentPtr->GetConstraintSolver();
//solver->SetContactSolverFunc(ContactSolverFunc func,USER_CONTACT_SOLVER_TYPE1,DEFAULT_CONTACT_SOLVER_TYPE); //solver->setContactSolverFunc(ContactSolverFunc func,USER_CONTACT_SOLVER_TYPE1,DEFAULT_CONTACT_SOLVER_TYPE);
solver->SetFrictionSolverFunc(myFrictionModel,USER_CONTACT_SOLVER_TYPE1,DEFAULT_CONTACT_SOLVER_TYPE); solver->SetFrictionSolverFunc(myFrictionModel,USER_CONTACT_SOLVER_TYPE1,DEFAULT_CONTACT_SOLVER_TYPE);
solver->SetFrictionSolverFunc(myFrictionModel,DEFAULT_CONTACT_SOLVER_TYPE,USER_CONTACT_SOLVER_TYPE1); solver->SetFrictionSolverFunc(myFrictionModel,DEFAULT_CONTACT_SOLVER_TYPE,USER_CONTACT_SOLVER_TYPE1);
solver->SetFrictionSolverFunc(myFrictionModel,USER_CONTACT_SOLVER_TYPE1,USER_CONTACT_SOLVER_TYPE1); solver->SetFrictionSolverFunc(myFrictionModel,USER_CONTACT_SOLVER_TYPE1,USER_CONTACT_SOLVER_TYPE1);
@@ -288,15 +289,15 @@ void CcdPhysicsDemo::initPhysics()
btTransform ident; btTransform ident;
ident.setIdentity(); ident.setIdentity();
ident.setOrigin(btVector3(0,0,0)); ident.setOrigin(btVector3(0,0,0));
compoundShape->AddChildShape(ident,oldShape);// compoundShape->addChildShape(ident,oldShape);//
ident.setOrigin(btVector3(0,0,2)); ident.setOrigin(btVector3(0,0,2));
compoundShape->AddChildShape(ident,new btSphereShape(0.9));// compoundShape->addChildShape(ident,new btSphereShape(0.9));//
} }
for (i=0;i<gNumObjects;i++) for (i=0;i<gNumObjects;i++)
{ {
btCollisionShape* shape = shapePtr[shapeIndex[i]]; btCollisionShape* shape = shapePtr[shapeIndex[i]];
shape->SetMargin(0.05f); shape->setMargin(gCollisionMargin);
bool isDyna = i>0; bool isDyna = i>0;
@@ -332,9 +333,9 @@ void CcdPhysicsDemo::initPhysics()
if (!isDyna) if (!isDyna)
mass = 0.f; mass = 0.f;
btRigidBody* body = LocalCreateRigidBody(isDyna,mass,trans,shape); btRigidBody* body = localCreateRigidBody(isDyna,mass,trans,shape);
m_dynamicsWorld->AddCollisionObject(body); m_dynamicsWorld->addCollisionObject(body);
// Only do CCD if motion in one timestep (1.f/60.f) exceeds CUBE_HALF_EXTENTS // Only do CCD if motion in one timestep (1.f/60.f) exceeds CUBE_HALF_EXTENTS
body->m_ccdSquareMotionTreshold = CUBE_HALF_EXTENTS; body->m_ccdSquareMotionTreshold = CUBE_HALF_EXTENTS;
@@ -344,7 +345,7 @@ void CcdPhysicsDemo::initPhysics()
#ifdef USER_DEFINED_FRICTION_MODEL #ifdef USER_DEFINED_FRICTION_MODEL
///Advanced use: override the friction solver ///Advanced use: override the friction solver
ctrl->GetRigidBody()->m_frictionSolverType = USER_CONTACT_SOLVER_TYPE1; ctrl->getRigidBody()->m_frictionSolverType = USER_CONTACT_SOLVER_TYPE1;
#endif //USER_DEFINED_FRICTION_MODEL #endif //USER_DEFINED_FRICTION_MODEL
} }

View File

@@ -185,20 +185,20 @@ bool ColladaConverter::convert()
printf(" X is Up Data and Hiearchies must be converted!\n" ); printf(" X is Up Data and Hiearchies must be converted!\n" );
printf(" Conversion to X axis Up isn't currently supported!\n" ); printf(" Conversion to X axis Up isn't currently supported!\n" );
printf(" COLLADA_RT defaulting to Y Up \n" ); printf(" COLLADA_RT defaulting to Y Up \n" );
SetGravity(btVector3(-10,0,0)); setGravity(btVector3(-10,0,0));
SetCameraInfo(btVector3(1,0,0),1); setCameraInfo(btVector3(1,0,0),1);
break; break;
case UPAXISTYPE_Y_UP: case UPAXISTYPE_Y_UP:
printf(" Y Axis is Up for this file \n" ); printf(" Y Axis is Up for this file \n" );
printf(" COLLADA_RT set to Y Up \n" ); printf(" COLLADA_RT set to Y Up \n" );
SetGravity(btVector3(0,-10,0)); setGravity(btVector3(0,-10,0));
SetCameraInfo(btVector3(0,1,0),0); setCameraInfo(btVector3(0,1,0),0);
break; break;
case UPAXISTYPE_Z_UP: case UPAXISTYPE_Z_UP:
printf(" Z Axis is Up for this file \n" ); printf(" Z Axis is Up for this file \n" );
printf(" All Geometry and Hiearchies must be converted!\n" ); printf(" All Geometry and Hiearchies must be converted!\n" );
SetGravity(btVector3(0,0,-10)); setGravity(btVector3(0,0,-10));
break; break;
default: default:
@@ -294,7 +294,7 @@ bool ColladaConverter::convert()
const domFloat3 grav = physicsSceneRef->getTechnique_common()->getGravity()->getValue(); const domFloat3 grav = physicsSceneRef->getTechnique_common()->getGravity()->getValue();
printf("gravity set to %f,%f,%f\n",grav.get(0),grav.get(1),grav.get(2)); printf("gravity set to %f,%f,%f\n",grav.get(0),grav.get(1),grav.get(2));
SetGravity(btVector3(grav.get(0),grav.get(1),grav.get(2))); setGravity(btVector3(grav.get(0),grav.get(1),grav.get(2)));
} }
} }
@@ -481,7 +481,7 @@ bool ColladaConverter::convert()
ConstraintInput cInput; ConstraintInput cInput;
cInput.m_instance_physicsModelRef = instance_physicsModelRef; cInput.m_instance_physicsModelRef = instance_physicsModelRef;
cInput.m_model = model; cInput.m_model = model;
PrepareConstraints(cInput); prepareConstraints(cInput);
} }
//also don't forget the model's 'instance_physics_models! //also don't forget the model's 'instance_physics_models!
@@ -496,7 +496,7 @@ bool ColladaConverter::convert()
ConstraintInput cInput; ConstraintInput cInput;
cInput.m_instance_physicsModelRef = instancePhysicsModelRef; cInput.m_instance_physicsModelRef = instancePhysicsModelRef;
cInput.m_model = model; cInput.m_model = model;
PrepareConstraints(cInput); prepareConstraints(cInput);
} }
@@ -509,7 +509,7 @@ bool ColladaConverter::convert()
} }
void ColladaConverter::PrepareConstraints(ConstraintInput& input) void ColladaConverter::prepareConstraints(ConstraintInput& input)
{ {
domInstance_physics_modelRef instance_physicsModelRef = input.m_instance_physicsModelRef; domInstance_physics_modelRef instance_physicsModelRef = input.m_instance_physicsModelRef;
domPhysics_modelRef model = input.m_model; domPhysics_modelRef model = input.m_model;
@@ -699,7 +699,7 @@ void ColladaConverter::PreparePhysicsObject(struct btRigidBodyInput& input, bool
CcdPhysicsController* ctrl = CreatePhysicsObject(isDynamics,mass,startTransform,colShape); CcdPhysicsController* ctrl = createPhysicsObject(isDynamics,mass,startTransform,colShape);
if (ctrl) if (ctrl)
{ {
//for bodyName lookup in constraints //for bodyName lookup in constraints
@@ -764,7 +764,7 @@ bool ColladaConverter::saveAs(const char* filename)
} }
{ {
btQuaternion quat = m_physObjects[i]->GetRigidBody()->getCenterOfMassTransform().getRotation(); btQuaternion quat = m_physObjects[i]->getRigidBody()->getCenterOfMassTransform().getRotation();
btVector3 axis(quat.getX(),quat.getY(),quat.getZ()); btVector3 axis(quat.getX(),quat.getY(),quat.getZ());
axis[3] = 0.f; axis[3] = 0.f;
//check for axis length //check for axis length
@@ -1035,7 +1035,7 @@ void ColladaConverter::ConvertRigidBodyRef( btRigidBodyInput& rbInput,btRigidBod
k+=meshPart.m_triangleIndexStride; k+=meshPart.m_triangleIndexStride;
verts[i].setValue(fl0,fl1,fl2); verts[i].setValue(fl0,fl1,fl2);
} }
trimesh->AddTriangle(verts[0],verts[1],verts[2]); trimesh->addTriangle(verts[0],verts[1],verts[2]);
} }
} }
} }
@@ -1051,7 +1051,7 @@ void ColladaConverter::ConvertRigidBodyRef( btRigidBodyInput& rbInput,btRigidBod
//int m_vertexStride;//use the accessor for this //int m_vertexStride;//use the accessor for this
//}; //};
//tindexArray->AddIndexedMesh(meshPart); //tindexArray->addIndexedMesh(meshPart);
if (rbOutput.m_isDynamics) if (rbOutput.m_isDynamics)
{ {
printf("moving concave <mesh> not supported, transformed into convex\n"); printf("moving concave <mesh> not supported, transformed into convex\n");
@@ -1144,7 +1144,7 @@ void ColladaConverter::ConvertRigidBodyRef( btRigidBodyInput& rbInput,btRigidBod
domFloat fl2 = listFloats.get(k+2); domFloat fl2 = listFloats.get(k+2);
//printf("float %f %f %f\n",fl0,fl1,fl2); //printf("float %f %f %f\n",fl0,fl1,fl2);
convexHullShape->AddPoint(btPoint3(fl0,fl1,fl2)); convexHullShape->addPoint(btPoint3(fl0,fl1,fl2));
} }
} }
@@ -1192,7 +1192,7 @@ void ColladaConverter::ConvertRigidBodyRef( btRigidBodyInput& rbInput,btRigidBod
domFloat fl2 = listFloats.get(k+2); domFloat fl2 = listFloats.get(k+2);
//printf("float %f %f %f\n",fl0,fl1,fl2); //printf("float %f %f %f\n",fl0,fl1,fl2);
convexHullShape->AddPoint(btPoint3(fl0,fl1,fl2)); convexHullShape->addPoint(btPoint3(fl0,fl1,fl2));
} }
} }
@@ -1205,10 +1205,10 @@ void ColladaConverter::ConvertRigidBodyRef( btRigidBodyInput& rbInput,btRigidBod
} }
if (convexHullShape->GetNumVertices()) if (convexHullShape->getNumVertices())
{ {
rbOutput.m_colShape = convexHullShape; rbOutput.m_colShape = convexHullShape;
printf("created convexHullShape with %i points\n",convexHullShape->GetNumVertices()); printf("created convexHullShape with %i points\n",convexHullShape->getNumVertices());
} else } else
{ {
delete convexHullShape; delete convexHullShape;
@@ -1251,7 +1251,7 @@ void ColladaConverter::ConvertRigidBodyRef( btRigidBodyInput& rbInput,btRigidBod
); );
} }
rbOutput.m_compoundShape->AddChildShape(localTransform,rbOutput.m_colShape); rbOutput.m_compoundShape->addChildShape(localTransform,rbOutput.m_colShape);
rbOutput.m_colShape = 0; rbOutput.m_colShape = 0;
} }
} }

View File

@@ -46,7 +46,7 @@ protected:
void PreparePhysicsObject(struct btRigidBodyInput& input, bool isDynamics, float mass,btCollisionShape* colShape); void PreparePhysicsObject(struct btRigidBodyInput& input, bool isDynamics, float mass,btCollisionShape* colShape);
void PrepareConstraints(ConstraintInput& input); void prepareConstraints(ConstraintInput& input);
void ConvertRigidBodyRef( struct btRigidBodyInput& , struct btRigidBodyOutput& output ); void ConvertRigidBodyRef( struct btRigidBodyInput& , struct btRigidBodyOutput& output );
@@ -76,14 +76,14 @@ public:
const btVector3& angularMaxLimits const btVector3& angularMaxLimits
) = 0; ) = 0;
virtual CcdPhysicsController* CreatePhysicsObject(bool isDynamic, virtual CcdPhysicsController* createPhysicsObject(bool isDynamic,
float mass, float mass,
const btTransform& startTransform, const btTransform& startTransform,
btCollisionShape* shape) = 0; btCollisionShape* shape) = 0;
virtual void SetGravity(const btVector3& gravity) = 0; virtual void setGravity(const btVector3& gravity) = 0;
virtual void SetCameraInfo(const btVector3& up, int forwardAxis) = 0; virtual void setCameraInfo(const btVector3& up, int forwardAxis) = 0;
}; };

View File

@@ -58,7 +58,7 @@ class MyColladaConverter : public ColladaConverter
const btVector3& angularMaxLimits const btVector3& angularMaxLimits
) )
{ {
return m_demoApp->GetPhysicsEnvironment()->createUniversalD6Constraint( return m_demoApp->getPhysicsEnvironment()->createUniversalD6Constraint(
ctrlRef,ctrlOther, ctrlRef,ctrlOther,
localAttachmentFrameRef, localAttachmentFrameRef,
localAttachmentOther, localAttachmentOther,
@@ -69,21 +69,21 @@ class MyColladaConverter : public ColladaConverter
); );
} }
virtual CcdPhysicsController* CreatePhysicsObject(bool isDynamic, virtual CcdPhysicsController* createPhysicsObject(bool isDynamic,
float mass, float mass,
const btTransform& startTransform, const btTransform& startTransform,
btCollisionShape* shape) btCollisionShape* shape)
{ {
CcdPhysicsController* ctrl = m_demoApp->LocalCreatePhysicsObject(isDynamic, mass, startTransform,shape); CcdPhysicsController* ctrl = m_demoApp->localCreatePhysicsObject(isDynamic, mass, startTransform,shape);
return ctrl; return ctrl;
} }
virtual void SetGravity(const btVector3& grav) virtual void setGravity(const btVector3& grav)
{ {
m_demoApp->GetPhysicsEnvironment()->setGravity(grav.getX(),grav.getY(),grav.getZ()); m_demoApp->getPhysicsEnvironment()->setGravity(grav.getX(),grav.getY(),grav.getZ());
} }
virtual void SetCameraInfo(const btVector3& camUp,int forwardAxis) virtual void setCameraInfo(const btVector3& camUp,int forwardAxis)
{ {
m_demoApp->setCameraUp(camUp); m_demoApp->setCameraUp(camUp);
m_demoApp->setCameraForwardAxis(forwardAxis); m_demoApp->setCameraForwardAxis(forwardAxis);

View File

@@ -122,7 +122,7 @@ void CollisionDemo::displayCallback(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
//GL_ShapeDrawer::DrawCoordSystem(); //GL_ShapeDrawer::drawCoordSystem();
float m[16]; float m[16];
int i; int i;
@@ -130,14 +130,14 @@ void CollisionDemo::displayCallback(void) {
btGjkPairDetector convexConvex(shapePtr[0],shapePtr[1],&sGjkSimplexSolver,0); btGjkPairDetector convexConvex(shapePtr[0],shapePtr[1],&sGjkSimplexSolver,0);
btVector3 seperatingAxis(0.00000000f,0.059727669f,0.29259586f); btVector3 seperatingAxis(0.00000000f,0.059727669f,0.29259586f);
convexConvex.SetCachedSeperatingAxis(seperatingAxis); convexConvex.setCachedSeperatingAxis(seperatingAxis);
btPointCollector gjkOutput; btPointCollector gjkOutput;
btGjkPairDetector::ClosestPointInput input; btGjkPairDetector::ClosestPointInput input;
input.m_transformA = tr[0]; input.m_transformA = tr[0];
input.m_transformB = tr[1]; input.m_transformB = tr[1];
convexConvex.GetClosestPoints(input ,gjkOutput,0); convexConvex.getClosestPoints(input ,gjkOutput,0);
if (gjkOutput.m_hasResult) if (gjkOutput.m_hasResult)
{ {
@@ -159,23 +159,23 @@ void CollisionDemo::displayCallback(void) {
tr[i].getOpenGLMatrix( m ); tr[i].getOpenGLMatrix( m );
GL_ShapeDrawer::DrawOpenGL(m,shapePtr[i],btVector3(1,1,1),getDebugMode()); GL_ShapeDrawer::drawOpenGL(m,shapePtr[i],btVector3(1,1,1),getDebugMode());
} }
simplex.SetSimplexSolver(&sGjkSimplexSolver); simplex.setSimplexSolver(&sGjkSimplexSolver);
btPoint3 ybuf[4],pbuf[4],qbuf[4]; btPoint3 ybuf[4],pbuf[4],qbuf[4];
int numpoints = sGjkSimplexSolver.getSimplex(pbuf,qbuf,ybuf); int numpoints = sGjkSimplexSolver.getSimplex(pbuf,qbuf,ybuf);
simplex.Reset(); simplex.reset();
for (i=0;i<numpoints;i++) for (i=0;i<numpoints;i++)
simplex.AddVertex(ybuf[i]); simplex.addVertex(ybuf[i]);
btTransform ident; btTransform ident;
ident.setIdentity(); ident.setIdentity();
ident.getOpenGLMatrix(m); ident.getOpenGLMatrix(m);
GL_ShapeDrawer::DrawOpenGL(m,&simplex,btVector3(1,1,1),getDebugMode()); GL_ShapeDrawer::drawOpenGL(m,&simplex,btVector3(1,1,1),getDebugMode());
btQuaternion orn; btQuaternion orn;

View File

@@ -92,8 +92,8 @@ void CollisionInterfaceDemo::initPhysics()
collisionWorld = new btCollisionWorld(dispatcher,broadphase); collisionWorld = new btCollisionWorld(dispatcher,broadphase);
collisionWorld->AddCollisionObject(&objects[0]); collisionWorld->addCollisionObject(&objects[0]);
collisionWorld->AddCollisionObject(&objects[1]); collisionWorld->addCollisionObject(&objects[1]);
} }
@@ -118,30 +118,30 @@ void CollisionInterfaceDemo::displayCallback(void) {
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
if (collisionWorld) if (collisionWorld)
collisionWorld->PerformDiscreteCollisionDetection(); collisionWorld->performDiscreteCollisionDetection();
int i; int i;
///one way to draw all the contact points is iterating over contact manifolds / points: ///one way to draw all the contact points is iterating over contact manifolds / points:
int numManifolds = collisionWorld->GetDispatcher()->GetNumManifolds(); int numManifolds = collisionWorld->getDispatcher()->getNumManifolds();
for (i=0;i<numManifolds;i++) for (i=0;i<numManifolds;i++)
{ {
btPersistentManifold* contactManifold = collisionWorld->GetDispatcher()->GetManifoldByIndexInternal(i); btPersistentManifold* contactManifold = collisionWorld->getDispatcher()->getManifoldByIndexInternal(i);
btCollisionObject* obA = static_cast<btCollisionObject*>(contactManifold->GetBody0()); btCollisionObject* obA = static_cast<btCollisionObject*>(contactManifold->getBody0());
btCollisionObject* obB = static_cast<btCollisionObject*>(contactManifold->GetBody1()); btCollisionObject* obB = static_cast<btCollisionObject*>(contactManifold->getBody1());
contactManifold->RefreshContactPoints(obA->m_worldTransform,obB->m_worldTransform); contactManifold->refreshContactPoints(obA->m_worldTransform,obB->m_worldTransform);
int numContacts = contactManifold->GetNumContacts(); int numContacts = contactManifold->getNumContacts();
for (int j=0;j<numContacts;j++) for (int j=0;j<numContacts;j++)
{ {
btManifoldPoint& pt = contactManifold->GetContactPoint(j); btManifoldPoint& pt = contactManifold->getContactPoint(j);
glBegin(GL_LINES); glBegin(GL_LINES);
glColor3f(1, 0, 1); glColor3f(1, 0, 1);
btVector3 ptA = pt.GetPositionWorldOnA(); btVector3 ptA = pt.getPositionWorldOnA();
btVector3 ptB = pt.GetPositionWorldOnB(); btVector3 ptB = pt.getPositionWorldOnB();
glVertex3d(ptA.x(),ptA.y(),ptA.z()); glVertex3d(ptA.x(),ptA.y(),ptA.z());
glVertex3d(ptB.x(),ptB.y(),ptB.z()); glVertex3d(ptB.x(),ptB.y(),ptB.z());
@@ -149,10 +149,10 @@ void CollisionInterfaceDemo::displayCallback(void) {
} }
//you can un-comment out this line, and then all points are removed //you can un-comment out this line, and then all points are removed
//contactManifold->ClearManifold(); //contactManifold->clearManifold();
} }
//GL_ShapeDrawer::DrawCoordSystem(); //GL_ShapeDrawer::drawCoordSystem();
float m[16]; float m[16];
@@ -162,7 +162,7 @@ void CollisionInterfaceDemo::displayCallback(void) {
{ {
objects[i].m_worldTransform.getOpenGLMatrix( m ); objects[i].m_worldTransform.getOpenGLMatrix( m );
GL_ShapeDrawer::DrawOpenGL(m,objects[i].m_collisionShape,btVector3(1,1,1),getDebugMode()); GL_ShapeDrawer::drawOpenGL(m,objects[i].m_collisionShape,btVector3(1,1,1),getDebugMode());
} }

View File

@@ -168,16 +168,16 @@ void ConcaveDemo::initPhysics()
startTransform.setIdentity(); startTransform.setIdentity();
startTransform.setOrigin(btVector3(0,-2,0)); startTransform.setOrigin(btVector3(0,-2,0));
CcdPhysicsController* staticTrimesh = LocalCreatePhysicsObject(isDynamic, mass, startTransform,trimeshShape); CcdPhysicsController* staticTrimesh = localCreatePhysicsObject(isDynamic, mass, startTransform,trimeshShape);
//enable custom material callback //enable custom material callback
staticTrimesh->GetRigidBody()->m_collisionFlags |= btCollisionObject::customMaterialCallback; staticTrimesh->getRigidBody()->m_collisionFlags |= btCollisionObject::customMaterialCallback;
{ {
for (int i=0;i<10;i++) for (int i=0;i<10;i++)
{ {
btCollisionShape* boxShape = new btBoxShape(btVector3(1,1,1)); btCollisionShape* boxShape = new btBoxShape(btVector3(1,1,1));
startTransform.setOrigin(btVector3(2*i,1,1)); startTransform.setOrigin(btVector3(2*i,1,1));
LocalCreatePhysicsObject(true, 1, startTransform,boxShape); localCreatePhysicsObject(true, 1, startTransform,boxShape);
} }
} }
m_physicsEnvironmentPtr->setGravity(-1,-10,1); m_physicsEnvironmentPtr->setGravity(-1,-10,1);

View File

@@ -74,10 +74,10 @@ void ConstraintDemo::initPhysics()
bool isDynamic = false; bool isDynamic = false;
float mass = 1.f; float mass = 1.f;
CcdPhysicsController* ctrl0 = LocalCreatePhysicsObject( isDynamic,mass,trans,shape); CcdPhysicsController* ctrl0 = localCreatePhysicsObject( isDynamic,mass,trans,shape);
trans.setOrigin(btVector3(2*CUBE_HALF_EXTENTS,20,0)); trans.setOrigin(btVector3(2*CUBE_HALF_EXTENTS,20,0));
isDynamic = true; isDynamic = true;
CcdPhysicsController* ctrl1 = LocalCreatePhysicsObject( isDynamic,mass,trans,shape); CcdPhysicsController* ctrl1 = localCreatePhysicsObject( isDynamic,mass,trans,shape);
clientResetScene(); clientResetScene();

View File

@@ -110,12 +110,12 @@ void btContinuousConvexCollisionDemo::initPhysics()
shapePtr[0] = boxA; shapePtr[0] = boxA;
shapePtr[1] = boxB; shapePtr[1] = boxB;
shapePtr[0]->SetMargin(0.01f); shapePtr[0]->setMargin(0.01f);
shapePtr[1]->SetMargin(0.01f); shapePtr[1]->setMargin(0.01f);
for (int i=0;i<numObjects;i++) for (int i=0;i<numObjects;i++)
{ {
btTransformUtil::CalculateVelocity(fromTrans[i],toTrans[i],1.f,linVels[i],angVels[i]); btTransformUtil::calculateVelocity(fromTrans[i],toTrans[i],1.f,linVels[i],angVels[i]);
} }
} }
@@ -144,7 +144,7 @@ void btContinuousConvexCollisionDemo::displayCallback(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
//GL_ShapeDrawer::DrawCoordSystem(); //GL_ShapeDrawer::drawCoordSystem();
float m[16]; float m[16];
int i; int i;
@@ -152,7 +152,7 @@ void btContinuousConvexCollisionDemo::displayCallback(void) {
/*for (i=0;i<numObjects;i++) /*for (i=0;i<numObjects;i++)
{ {
fromTrans[i].getOpenGLMatrix( m ); fromTrans[i].getOpenGLMatrix( m );
GL_ShapeDrawer::DrawOpenGL(m,shapePtr[i]); GL_ShapeDrawer::drawOpenGL(m,shapePtr[i]);
} }
*/ */
@@ -168,16 +168,16 @@ void btContinuousConvexCollisionDemo::displayCallback(void) {
btScalar subStep = s * 1.f/(float)numSubSteps; btScalar subStep = s * 1.f/(float)numSubSteps;
btTransform interpolatedTrans; btTransform interpolatedTrans;
btTransformUtil::IntegrateTransform(fromTrans[i],linVels[i],angVels[i],subStep,interpolatedTrans); btTransformUtil::integrateTransform(fromTrans[i],linVels[i],angVels[i],subStep,interpolatedTrans);
//fromTrans[i].getOpenGLMatrix(m); //fromTrans[i].getOpenGLMatrix(m);
//GL_ShapeDrawer::DrawOpenGL(m,shapePtr[i]); //GL_ShapeDrawer::drawOpenGL(m,shapePtr[i]);
//toTrans[i].getOpenGLMatrix(m); //toTrans[i].getOpenGLMatrix(m);
//GL_ShapeDrawer::DrawOpenGL(m,shapePtr[i]); //GL_ShapeDrawer::drawOpenGL(m,shapePtr[i]);
interpolatedTrans.getOpenGLMatrix( m ); interpolatedTrans.getOpenGLMatrix( m );
GL_ShapeDrawer::DrawOpenGL(m,shapePtr[i],btVector3(1,0,1),getDebugMode()); GL_ShapeDrawer::drawOpenGL(m,shapePtr[i],btVector3(1,0,1),getDebugMode());
} }
} }
} }
@@ -229,7 +229,7 @@ void btContinuousConvexCollisionDemo::displayCallback(void) {
for (i=0;i<numObjects;i++) for (i=0;i<numObjects;i++)
{ {
fromTrans[i].getOpenGLMatrix(m); fromTrans[i].getOpenGLMatrix(m);
GL_ShapeDrawer::DrawOpenGL(m,shapePtr[i],btVector3(1,1,1),getDebugMode()); GL_ShapeDrawer::drawOpenGL(m,shapePtr[i],btVector3(1,1,1),getDebugMode());
} }
btDebugCastResult rayResult1(fromTrans[0],shapePtr[0],linVels[0],angVels[0]); btDebugCastResult rayResult1(fromTrans[0],shapePtr[0],linVels[0],angVels[0]);
@@ -264,15 +264,15 @@ void btContinuousConvexCollisionDemo::displayCallback(void) {
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
btTransform hitTrans; btTransform hitTrans;
btTransformUtil::IntegrateTransform(fromTrans[0],linVels[0],angVels[0],rayResultPtr->m_fraction,hitTrans); btTransformUtil::integrateTransform(fromTrans[0],linVels[0],angVels[0],rayResultPtr->m_fraction,hitTrans);
hitTrans.getOpenGLMatrix(m); hitTrans.getOpenGLMatrix(m);
GL_ShapeDrawer::DrawOpenGL(m,shapePtr[0],btVector3(0,1,0),getDebugMode()); GL_ShapeDrawer::drawOpenGL(m,shapePtr[0],btVector3(0,1,0),getDebugMode());
btTransformUtil::IntegrateTransform(fromTrans[i],linVels[i],angVels[i],rayResultPtr->m_fraction,hitTrans); btTransformUtil::integrateTransform(fromTrans[i],linVels[i],angVels[i],rayResultPtr->m_fraction,hitTrans);
hitTrans.getOpenGLMatrix(m); hitTrans.getOpenGLMatrix(m);
GL_ShapeDrawer::DrawOpenGL(m,shapePtr[i],btVector3(0,1,1),getDebugMode()); GL_ShapeDrawer::drawOpenGL(m,shapePtr[i],btVector3(0,1,1),getDebugMode());
} }

View File

@@ -99,7 +99,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
startTransform.setIdentity(); startTransform.setIdentity();
startTransform.setOrigin(btVector3(0,-4,0)); startTransform.setOrigin(btVector3(0,-4,0));
LocalCreatePhysicsObject(false,0,startTransform,new btBoxShape(btVector3(30,2,30))); localCreatePhysicsObject(false,0,startTransform,new btBoxShape(btVector3(30,2,30)));
class MyConvexDecomposition : public ConvexDecomposition::ConvexDecompInterface class MyConvexDecomposition : public ConvexDecomposition::ConvexDecompInterface
{ {
@@ -184,7 +184,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
vertex1 -= centroid; vertex1 -= centroid;
vertex2 -= centroid; vertex2 -= centroid;
trimesh->AddTriangle(vertex0,vertex1,vertex2); trimesh->addTriangle(vertex0,vertex1,vertex2);
index0+=mBaseCount; index0+=mBaseCount;
index1+=mBaseCount; index1+=mBaseCount;
@@ -200,7 +200,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
btTransform trans; btTransform trans;
trans.setIdentity(); trans.setIdentity();
trans.setOrigin(centroid); trans.setOrigin(centroid);
m_convexDemo->LocalCreatePhysicsObject(isDynamic, mass, trans,convexShape); m_convexDemo->localCreatePhysicsObject(isDynamic, mass, trans,convexShape);
mBaseCount+=result.mHullVcount; // advance the 'base index' counter. mBaseCount+=result.mHullVcount; // advance the 'base index' counter.
@@ -234,7 +234,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
vertex1 *= localScaling; vertex1 *= localScaling;
vertex2 *= localScaling; vertex2 *= localScaling;
trimesh->AddTriangle(vertex0,vertex1,vertex2); trimesh->addTriangle(vertex0,vertex1,vertex2);
} }
btCollisionShape* convexShape = new btConvexTriangleMeshShape(trimesh); btCollisionShape* convexShape = new btConvexTriangleMeshShape(trimesh);
@@ -245,7 +245,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
startTransform.setIdentity(); startTransform.setIdentity();
startTransform.setOrigin(btVector3(20,2,0)); startTransform.setOrigin(btVector3(20,2,0));
LocalCreatePhysicsObject(isDynamic, mass, startTransform,convexShape); localCreatePhysicsObject(isDynamic, mass, startTransform,convexShape);
} }

View File

@@ -107,7 +107,7 @@ void clientDisplay(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
//GL_ShapeDrawer::DrawCoordSystem(); //GL_ShapeDrawer::drawCoordSystem();
float m[16]; float m[16];
int i; int i;
@@ -115,14 +115,14 @@ void clientDisplay(void) {
btGjkPairDetector convexConvex(shapePtr[0],shapePtr[1],&sGjkSimplexSolver,0); btGjkPairDetector convexConvex(shapePtr[0],shapePtr[1],&sGjkSimplexSolver,0);
btVector3 seperatingAxis(0.00000000f,0.059727669f,0.29259586f); btVector3 seperatingAxis(0.00000000f,0.059727669f,0.29259586f);
convexConvex.SetCachedSeperatingAxis(seperatingAxis); convexConvex.setCachedSeperatingAxis(seperatingAxis);
btPointCollector gjkOutput; btPointCollector gjkOutput;
btGjkPairDetector::ClosestPointInput input; btGjkPairDetector::ClosestPointInput input;
input.m_transformA = tr[0]; input.m_transformA = tr[0];
input.m_transformB = tr[1]; input.m_transformB = tr[1];
convexConvex.GetClosestPoints(input ,gjkOutput,0); convexConvex.getClosestPoints(input ,gjkOutput,0);
if (gjkOutput.m_hasResult) if (gjkOutput.m_hasResult)
{ {
@@ -142,23 +142,23 @@ void clientDisplay(void) {
tr[i].getOpenGLMatrix( m ); tr[i].getOpenGLMatrix( m );
GL_ShapeDrawer::DrawOpenGL(m,shapePtr[i],btVector3(1,1,1),getDebugMode()); GL_ShapeDrawer::drawOpenGL(m,shapePtr[i],btVector3(1,1,1),getDebugMode());
} }
simplex.SetSimplexSolver(&sGjkSimplexSolver); simplex.setSimplexSolver(&sGjkSimplexSolver);
btPoint3 ybuf[4],pbuf[4],qbuf[4]; btPoint3 ybuf[4],pbuf[4],qbuf[4];
int numpoints = sGjkSimplexSolver.getSimplex(pbuf,qbuf,ybuf); int numpoints = sGjkSimplexSolver.getSimplex(pbuf,qbuf,ybuf);
simplex.Reset(); simplex.reset();
for (i=0;i<numpoints;i++) for (i=0;i<numpoints;i++)
simplex.AddVertex(ybuf[i]); simplex.addVertex(ybuf[i]);
btTransform ident; btTransform ident;
ident.setIdentity(); ident.setIdentity();
ident.getOpenGLMatrix(m); ident.getOpenGLMatrix(m);
GL_ShapeDrawer::DrawOpenGL(m,&simplex,btVector3(1,1,1),getDebugMode()); GL_ShapeDrawer::drawOpenGL(m,&simplex,btVector3(1,1,1),getDebugMode());
btQuaternion orn; btQuaternion orn;

View File

@@ -106,7 +106,7 @@ bool createBoxShape( int shapeIndex )
//{ //{
// g_pConvexShapes[ shapeIndex ] = new btBoxShape( btVector3( 1, 1, 1 ) ); // g_pConvexShapes[ shapeIndex ] = new btBoxShape( btVector3( 1, 1, 1 ) );
// g_pConvexShapes[ shapeIndex ]->SetMargin( 0.05 ); // g_pConvexShapes[ shapeIndex ]->setMargin( 0.05 );
// g_convexShapesTransform[ shapeIndex ].setIdentity(); // g_convexShapesTransform[ shapeIndex ].setIdentity();
@@ -123,7 +123,7 @@ bool createBoxShape( int shapeIndex )
//{ //{
// g_pConvexShapes[ shapeIndex ] = new btBoxShape( btVector3( 25, 10, 25 ) ); // g_pConvexShapes[ shapeIndex ] = new btBoxShape( btVector3( 25, 10, 25 ) );
// g_pConvexShapes[ shapeIndex ]->SetMargin( 0.05 ); // g_pConvexShapes[ shapeIndex ]->setMargin( 0.05 );
// //btMatrix3x3 basis( 0.658257, 0.675022, -0.333709, // //btMatrix3x3 basis( 0.658257, 0.675022, -0.333709,
// // -0.333120, 0.658556, 0.675023, // // -0.333120, 0.658556, 0.675023,
@@ -138,7 +138,7 @@ bool createBoxShape( int shapeIndex )
g_pConvexShapes[ shapeIndex ] = new btBoxShape( btVector3( 1, 1, 1 ) ); g_pConvexShapes[ shapeIndex ] = new btBoxShape( btVector3( 1, 1, 1 ) );
g_pConvexShapes[ shapeIndex ]->SetMargin( 1e-1 ); g_pConvexShapes[ shapeIndex ]->setMargin( 1e-1 );
g_convexShapesTransform[ shapeIndex ].setIdentity(); g_convexShapesTransform[ shapeIndex ].setIdentity();
@@ -151,7 +151,7 @@ bool createSphereShape( int shapeIndex )
{ {
g_pConvexShapes[ shapeIndex ] = new btSphereShape( g_sphereRadius ); g_pConvexShapes[ shapeIndex ] = new btSphereShape( g_sphereRadius );
g_pConvexShapes[ shapeIndex ]->SetMargin( 1e-1 ); g_pConvexShapes[ shapeIndex ]->setMargin( 1e-1 );
g_convexShapesTransform[ shapeIndex ].setIdentity(); g_convexShapesTransform[ shapeIndex ].setIdentity();
g_convexShapesTransform[ shapeIndex ].setOrigin( randomPosition( g_sceneVolumeMin, g_sceneVolumeMax ) ); g_convexShapesTransform[ shapeIndex ].setOrigin( randomPosition( g_sceneVolumeMin, g_sceneVolumeMax ) );
@@ -196,7 +196,7 @@ bool calcPenDepth()
btScalar squaredDistance = SIMD_INFINITY; btScalar squaredDistance = SIMD_INFINITY;
btScalar delta = 0.f; btScalar delta = 0.f;
const btScalar margin = g_pConvexShapes[ 0 ]->GetMargin() + g_pConvexShapes[ 1 ]->GetMargin(); const btScalar margin = g_pConvexShapes[ 0 ]->getMargin() + g_pConvexShapes[ 1 ]->getMargin();
const btScalar marginSqrd = margin * margin; const btScalar marginSqrd = margin * margin;
btScalar maxRelErrorSqrd = 1e-3 * 1e-3; btScalar maxRelErrorSqrd = 1e-3 * 1e-3;
@@ -210,8 +210,8 @@ bool calcPenDepth()
btVector3 seperatingAxisInA = -v * g_convexShapesTransform[ 0 ].getBasis(); btVector3 seperatingAxisInA = -v * g_convexShapesTransform[ 0 ].getBasis();
btVector3 seperatingAxisInB = v * g_convexShapesTransform[ 1 ].getBasis(); btVector3 seperatingAxisInB = v * g_convexShapesTransform[ 1 ].getBasis();
btVector3 pInA = g_pConvexShapes[ 0 ]->LocalGetSupportingVertexWithoutMargin( seperatingAxisInA ); btVector3 pInA = g_pConvexShapes[ 0 ]->localGetSupportingVertexWithoutMargin( seperatingAxisInA );
btVector3 qInB = g_pConvexShapes[ 1 ]->LocalGetSupportingVertexWithoutMargin( seperatingAxisInB ); btVector3 qInB = g_pConvexShapes[ 1 ]->localGetSupportingVertexWithoutMargin( seperatingAxisInB );
btPoint3 pWorld = g_convexShapesTransform[ 0 ]( pInA ); btPoint3 pWorld = g_convexShapesTransform[ 0 ]( pInA );
btPoint3 qWorld = g_convexShapesTransform[ 1 ]( qInB ); btPoint3 qWorld = g_convexShapesTransform[ 1 ]( qInB );
@@ -234,8 +234,8 @@ bool calcPenDepth()
assert( ( squaredDistance > 0 ) && "squaredDistance is zero!" ); assert( ( squaredDistance > 0 ) && "squaredDistance is zero!" );
btScalar vLength = sqrt( squaredDistance ); btScalar vLength = sqrt( squaredDistance );
g_wWitnesses[ 0 ] -= v * ( g_pConvexShapes[ 0 ]->GetMargin() / vLength ); g_wWitnesses[ 0 ] -= v * ( g_pConvexShapes[ 0 ]->getMargin() / vLength );
g_wWitnesses[ 1 ] += v * ( g_pConvexShapes[ 1 ]->GetMargin() / vLength ); g_wWitnesses[ 1 ] += v * ( g_pConvexShapes[ 1 ]->getMargin() / vLength );
return true; return true;
} }
@@ -251,8 +251,8 @@ bool calcPenDepth()
assert( ( squaredDistance > 0 ) && "squaredDistance is zero!" ); assert( ( squaredDistance > 0 ) && "squaredDistance is zero!" );
btScalar vLength = sqrt( squaredDistance ); btScalar vLength = sqrt( squaredDistance );
g_wWitnesses[ 0 ] -= v * ( g_pConvexShapes[ 0 ]->GetMargin() / vLength ); g_wWitnesses[ 0 ] -= v * ( g_pConvexShapes[ 0 ]->getMargin() / vLength );
g_wWitnesses[ 1 ] += v * ( g_pConvexShapes[ 1 ]->GetMargin() / vLength ); g_wWitnesses[ 1 ] += v * ( g_pConvexShapes[ 1 ]->getMargin() / vLength );
return true; return true;
} }
@@ -271,8 +271,8 @@ bool calcPenDepth()
assert( ( squaredDistance > 0 ) && "squaredDistance is zero!" ); assert( ( squaredDistance > 0 ) && "squaredDistance is zero!" );
btScalar vLength = sqrt( squaredDistance ); btScalar vLength = sqrt( squaredDistance );
g_wWitnesses[ 0 ] -= v * ( g_pConvexShapes[ 0 ]->GetMargin() / vLength ); g_wWitnesses[ 0 ] -= v * ( g_pConvexShapes[ 0 ]->getMargin() / vLength );
g_wWitnesses[ 1 ] += v * ( g_pConvexShapes[ 1 ]->GetMargin() / vLength ); g_wWitnesses[ 1 ] += v * ( g_pConvexShapes[ 1 ]->getMargin() / vLength );
return true; return true;
} }
@@ -284,7 +284,7 @@ bool calcPenDepth()
} }
} }
return epaPenDepthSolver.CalcPenDepth( simplexSolver, g_pConvexShapes[ 0 ], g_pConvexShapes[ 1 ], return epaPenDepthSolver.calcPenDepth( simplexSolver, g_pConvexShapes[ 0 ], g_pConvexShapes[ 1 ],
g_convexShapesTransform[ 0 ], g_convexShapesTransform[ 1 ], v, g_convexShapesTransform[ 0 ], g_convexShapesTransform[ 1 ], v,
g_wWitnesses[ 0 ], g_wWitnesses[ 1 ], 0 ); g_wWitnesses[ 0 ], g_wWitnesses[ 1 ], 0 );
} }
@@ -311,11 +311,11 @@ void drawShape( int shapeIndex )
glMultMatrixf( m ); glMultMatrixf( m );
if ( g_pConvexShapes[ shapeIndex ]->GetShapeType() == BOX_SHAPE_PROXYTYPE ) if ( g_pConvexShapes[ shapeIndex ]->getShapeType() == BOX_SHAPE_PROXYTYPE )
{ {
glutWireCube( ( ( btBoxShape* ) g_pConvexShapes[ shapeIndex ] )->GetHalfExtents().x() * 2 ); glutWireCube( ( ( btBoxShape* ) g_pConvexShapes[ shapeIndex ] )->getHalfExtents().x() * 2 );
} }
else if ( g_pConvexShapes[ shapeIndex ]->GetShapeType() == SPHERE_SHAPE_PROXYTYPE ) else if ( g_pConvexShapes[ shapeIndex ]->getShapeType() == SPHERE_SHAPE_PROXYTYPE )
{ {
glutWireSphere( 1, 16, 16 ); glutWireSphere( 1, 16, 16 );
} }
@@ -370,7 +370,7 @@ void clientDisplay(void) {
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glDisable( GL_LIGHTING ); glDisable( GL_LIGHTING );
GL_ShapeDrawer::DrawCoordSystem(); GL_ShapeDrawer::drawCoordSystem();
glMatrixMode( GL_MODELVIEW ); glMatrixMode( GL_MODELVIEW );

View File

@@ -185,12 +185,12 @@ const float TRIANGLE_SIZE=20.f;
tr.setOrigin(btVector3(0,-20.f,0)); tr.setOrigin(btVector3(0,-20.f,0));
//create ground object //create ground object
LocalCreatePhysicsObject(false,0,tr,groundShape); localCreatePhysicsObject(false,0,tr,groundShape);
btCollisionShape* chassisShape = new btBoxShape(btVector3(1.f,0.5f,2.f)); btCollisionShape* chassisShape = new btBoxShape(btVector3(1.f,0.5f,2.f));
tr.setOrigin(btVector3(0,0.f,0)); tr.setOrigin(btVector3(0,0.f,0));
m_carChassis = LocalCreatePhysicsObject(true,800,tr,chassisShape); m_carChassis = localCreatePhysicsObject(true,800,tr,chassisShape);
clientResetScene(); clientResetScene();
@@ -207,7 +207,7 @@ const float TRIANGLE_SIZE=20.f;
0,0,0); 0,0,0);
///never deactivate the vehicle ///never deactivate the vehicle
m_carChassis->GetRigidBody()->SetActivationState(DISABLE_DEACTIVATION); m_carChassis->getRigidBody()->SetActivationState(DISABLE_DEACTIVATION);
gVehicleConstraint = m_physicsEnvironmentPtr->getVehicleConstraint(constraintId); gVehicleConstraint = m_physicsEnvironmentPtr->getVehicleConstraint(constraintId);
@@ -218,25 +218,25 @@ const float TRIANGLE_SIZE=20.f;
int upIndex = 1; int upIndex = 1;
int forwardIndex = 2; int forwardIndex = 2;
gVehicleConstraint->SetCoordinateSystem(rightIndex,upIndex,forwardIndex); gVehicleConstraint->setCoordinateSystem(rightIndex,upIndex,forwardIndex);
gVehicleConstraint->AddWheel(&wheelMotionState[0], gVehicleConstraint->addWheel(&wheelMotionState[0],
(PHY__Vector3&)connectionPointCS0, (PHY__Vector3&)connectionPointCS0,
(PHY__Vector3&)wheelDirectionCS0,(PHY__Vector3&)wheelAxleCS,suspensionRestLength,wheelRadius,isFrontWheel); (PHY__Vector3&)wheelDirectionCS0,(PHY__Vector3&)wheelAxleCS,suspensionRestLength,wheelRadius,isFrontWheel);
connectionPointCS0 = btVector3(-CUBE_HALF_EXTENTS+(0.3*wheelWidth),0,2*CUBE_HALF_EXTENTS-wheelRadius); connectionPointCS0 = btVector3(-CUBE_HALF_EXTENTS+(0.3*wheelWidth),0,2*CUBE_HALF_EXTENTS-wheelRadius);
gVehicleConstraint->AddWheel(&wheelMotionState[1], gVehicleConstraint->addWheel(&wheelMotionState[1],
(PHY__Vector3&)connectionPointCS0, (PHY__Vector3&)connectionPointCS0,
(PHY__Vector3&)wheelDirectionCS0,(PHY__Vector3&)wheelAxleCS,suspensionRestLength,wheelRadius,isFrontWheel); (PHY__Vector3&)wheelDirectionCS0,(PHY__Vector3&)wheelAxleCS,suspensionRestLength,wheelRadius,isFrontWheel);
connectionPointCS0 = btVector3(-CUBE_HALF_EXTENTS+(0.3*wheelWidth),0,-2*CUBE_HALF_EXTENTS+wheelRadius); connectionPointCS0 = btVector3(-CUBE_HALF_EXTENTS+(0.3*wheelWidth),0,-2*CUBE_HALF_EXTENTS+wheelRadius);
isFrontWheel = false; isFrontWheel = false;
gVehicleConstraint->AddWheel(&wheelMotionState[2], gVehicleConstraint->addWheel(&wheelMotionState[2],
(PHY__Vector3&)connectionPointCS0, (PHY__Vector3&)connectionPointCS0,
(PHY__Vector3&)wheelDirectionCS0,(PHY__Vector3&)wheelAxleCS,suspensionRestLength,wheelRadius,isFrontWheel); (PHY__Vector3&)wheelDirectionCS0,(PHY__Vector3&)wheelAxleCS,suspensionRestLength,wheelRadius,isFrontWheel);
connectionPointCS0 = btVector3(CUBE_HALF_EXTENTS-(0.3*wheelWidth),0,-2*CUBE_HALF_EXTENTS+wheelRadius); connectionPointCS0 = btVector3(CUBE_HALF_EXTENTS-(0.3*wheelWidth),0,-2*CUBE_HALF_EXTENTS+wheelRadius);
gVehicleConstraint->AddWheel(&wheelMotionState[3], gVehicleConstraint->addWheel(&wheelMotionState[3],
(PHY__Vector3&)connectionPointCS0, (PHY__Vector3&)connectionPointCS0,
(PHY__Vector3&)wheelDirectionCS0,(PHY__Vector3&)wheelAxleCS,suspensionRestLength,wheelRadius,isFrontWheel); (PHY__Vector3&)wheelDirectionCS0,(PHY__Vector3&)wheelAxleCS,suspensionRestLength,wheelRadius,isFrontWheel);
@@ -276,7 +276,7 @@ void ForkLiftDemo::renderme()
{ {
updateCamera(); updateCamera();
debugDrawer.SetDebugMode(getDebugMode()); debugDrawer.setDebugMode(getDebugMode());
float m[16]; float m[16];
int i; int i;
@@ -287,7 +287,7 @@ void ForkLiftDemo::renderme()
{ {
//draw wheels (cylinders) //draw wheels (cylinders)
wheelMotionState[i].m_worldTransform.getOpenGLMatrix(m); wheelMotionState[i].m_worldTransform.getOpenGLMatrix(m);
GL_ShapeDrawer::DrawOpenGL(m,&wheelShape,wheelColor,getDebugMode()); GL_ShapeDrawer::drawOpenGL(m,&wheelShape,wheelColor,getDebugMode());
} }
DemoApplication::renderme(); DemoApplication::renderme();
@@ -301,14 +301,14 @@ void ForkLiftDemo::clientMoveAndDisplay()
{ {
int steerWheelIndex = 2; int steerWheelIndex = 2;
gVehicleConstraint->ApplyEngineForce(gEngineForce,steerWheelIndex); gVehicleConstraint->applyEngineForce(gEngineForce,steerWheelIndex);
steerWheelIndex = 3; steerWheelIndex = 3;
gVehicleConstraint->ApplyEngineForce(gEngineForce,steerWheelIndex); gVehicleConstraint->applyEngineForce(gEngineForce,steerWheelIndex);
steerWheelIndex = 0; steerWheelIndex = 0;
gVehicleConstraint->SetSteeringValue(gVehicleSteering,steerWheelIndex); gVehicleConstraint->setSteeringValue(gVehicleSteering,steerWheelIndex);
steerWheelIndex = 1; steerWheelIndex = 1;
gVehicleConstraint->SetSteeringValue(gVehicleSteering,steerWheelIndex); gVehicleConstraint->setSteeringValue(gVehicleSteering,steerWheelIndex);
} }
@@ -414,7 +414,7 @@ void ForkLiftDemo::updateCamera()
glLoadIdentity(); glLoadIdentity();
//look at the vehicle //look at the vehicle
m_cameraTargetPosition = m_carChassis->GetRigidBody()->m_worldTransform.getOrigin(); m_cameraTargetPosition = m_carChassis->getRigidBody()->m_worldTransform.getOrigin();
//interpolate the camera height //interpolate the camera height
m_cameraPosition[1] = (15.0*m_cameraPosition[1] + m_cameraTargetPosition[1] + m_cameraHeight)/16.0; m_cameraPosition[1] = (15.0*m_cameraPosition[1] + m_cameraTargetPosition[1] + m_cameraHeight)/16.0;

View File

@@ -96,18 +96,18 @@ void LinearConvexCastDemo::initPhysics()
btBoxShape* boxA = new btBoxShape(boxHalfExtentsA); btBoxShape* boxA = new btBoxShape(boxHalfExtentsA);
/* btBU_Simplex1to4 boxB; /* btBU_Simplex1to4 boxB;
boxB.AddVertex(btPoint3(-5,0,-5)); boxB.addVertex(btPoint3(-5,0,-5));
boxB.AddVertex(btPoint3(5,0,-5)); boxB.addVertex(btPoint3(5,0,-5));
boxB.AddVertex(btPoint3(0,0,5)); boxB.addVertex(btPoint3(0,0,5));
boxB.AddVertex(btPoint3(0,5,0)); boxB.addVertex(btPoint3(0,5,0));
*/ */
btBoxShape* boxB = new btBoxShape(boxHalfExtentsB); btBoxShape* boxB = new btBoxShape(boxHalfExtentsB);
shapePtr[0] = boxA; shapePtr[0] = boxA;
shapePtr[1] = boxB; shapePtr[1] = boxB;
shapePtr[0]->SetMargin(0.01f); shapePtr[0]->setMargin(0.01f);
shapePtr[1]->SetMargin(0.01f); shapePtr[1]->setMargin(0.01f);
btTransform tr; btTransform tr;
tr.setIdentity(); tr.setIdentity();
@@ -137,7 +137,7 @@ void LinearConvexCastDemo::displayCallback(void)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
//GL_ShapeDrawer::DrawCoordSystem(); //GL_ShapeDrawer::drawCoordSystem();
float m[16]; float m[16];
int i; int i;
@@ -145,7 +145,7 @@ void LinearConvexCastDemo::displayCallback(void)
for (i=0;i<numObjects;i++) for (i=0;i<numObjects;i++)
{ {
tr[i].getOpenGLMatrix( m ); tr[i].getOpenGLMatrix( m );
GL_ShapeDrawer::DrawOpenGL(m,shapePtr[i],btVector3(1,1,1),getDebugMode()); GL_ShapeDrawer::drawOpenGL(m,shapePtr[i],btVector3(1,1,1),getDebugMode());
} }
@@ -224,7 +224,7 @@ void LinearConvexCastDemo::displayCallback(void)
toTransWorld.setOrigin(hitPoint); toTransWorld.setOrigin(hitPoint);
toTransWorld.getOpenGLMatrix( m ); toTransWorld.getOpenGLMatrix( m );
GL_ShapeDrawer::DrawOpenGL(m,shapePtr[0],btVector3(0,1,1),getDebugMode()); GL_ShapeDrawer::drawOpenGL(m,shapePtr[0],btVector3(0,1,1),getDebugMode());
} }

View File

@@ -126,7 +126,7 @@ int BMF_DrawCharacter(BMF_Font* font, char c)
int BMF_DrawString(BMF_Font* font, const char* str) int BMF_DrawString(BMF_Font* font, const char* str)
{ {
if (!font) return 0; if (!font) return 0;
((BMF_BitmapFont*)font)->DrawString(str); ((BMF_BitmapFont*)font)->drawString(str);
return 1; return 1;
} }
@@ -141,22 +141,22 @@ int BMF_GetCharacterWidth(BMF_Font* font, char c)
int BMF_GetStringWidth(BMF_Font* font, char* str) int BMF_GetStringWidth(BMF_Font* font, char* str)
{ {
if (!font) return 0; if (!font) return 0;
return ((BMF_BitmapFont*)font)->GetStringWidth(str); return ((BMF_BitmapFont*)font)->getStringWidth(str);
} }
void BMF_GetBoundingBox(BMF_Font* font, int *xmin_r, int *ymin_r, int *xmax_r, int *ymax_r) void BMF_GetBoundingBox(BMF_Font* font, int *xmin_r, int *ymin_r, int *xmax_r, int *ymax_r)
{ {
if (!font) return; if (!font) return;
((BMF_BitmapFont*)font)->GetBoundingBox(*xmin_r, *ymin_r, *xmax_r, *ymax_r); ((BMF_BitmapFont*)font)->getBoundingBox(*xmin_r, *ymin_r, *xmax_r, *ymax_r);
} }
int BMF_GetFontTexture(BMF_Font* font) { int BMF_GetFontTexture(BMF_Font* font) {
if (!font) return -1; if (!font) return -1;
return ((BMF_BitmapFont*)font)->GetTexture(); return ((BMF_BitmapFont*)font)->getTexture();
} }
void BMF_DrawStringTexture(BMF_Font* font, char *string, float x, float y, float z) { void BMF_DrawStringTexture(BMF_Font* font, char *string, float x, float y, float z) {
if (!font) return; if (!font) return;
((BMF_BitmapFont*)font)->DrawStringTexture(string, x, y, z); ((BMF_BitmapFont*)font)->drawStringTexture(string, x, y, z);
} }

View File

@@ -98,7 +98,7 @@ void BMF_GetBoundingBox(BMF_Font* font, int *xmin_r, int *ymin_r, int *xmax_r, i
/** /**
* Convert the given @a font to a texture, and return the GL texture * Convert the given @a font to a texture, and return the GL texture
* ID of the texture. If the texture ID is bound, text can * ID of the texture. If the texture ID is bound, text can
* be drawn using the texture by calling DrawStringTexture. * be drawn using the texture by calling drawStringTexture.
* *
* @param font The font to create the texture from. * @param font The font to create the texture from.
* @return The GL texture ID of the new texture, or -1 if unable * @return The GL texture ID of the new texture, or -1 if unable
@@ -109,7 +109,7 @@ int BMF_GetFontTexture(BMF_Font* font);
/** /**
* Draw the given @a str at the point @a x, @a y, @a z, using * Draw the given @a str at the point @a x, @a y, @a z, using
* texture coordinates. This assumes that an appropriate texture * texture coordinates. This assumes that an appropriate texture
* has been bound, see BMF_BitmapFont::GetTexture(). The string * has been bound, see BMF_BitmapFont::getTexture(). The string
* is drawn along the positive X axis. * is drawn along the positive X axis.
* *
* @param font The font to draw with. * @param font The font to draw with.

View File

@@ -64,7 +64,7 @@ BMF_BitmapFont::~BMF_BitmapFont(void)
} }
void BMF_BitmapFont::DrawString(const char* str) void BMF_BitmapFont::drawString(const char* str)
{ {
if (!str) if (!str)
return; return;
@@ -93,7 +93,7 @@ void BMF_BitmapFont::DrawString(const char* str)
} }
int BMF_BitmapFont::GetStringWidth(char* str) int BMF_BitmapFont::getStringWidth(char* str)
{ {
unsigned char c; unsigned char c;
int length = 0; int length = 0;
@@ -105,7 +105,7 @@ int BMF_BitmapFont::GetStringWidth(char* str)
return length; return length;
} }
void BMF_BitmapFont::GetBoundingBox(int & xMin, int & yMin, int & xMax, int & yMax) void BMF_BitmapFont::getBoundingBox(int & xMin, int & yMin, int & xMax, int & yMax)
{ {
xMin = m_fontData->xmin; xMin = m_fontData->xmin;
yMin = m_fontData->ymin; yMin = m_fontData->ymin;
@@ -113,7 +113,7 @@ void BMF_BitmapFont::GetBoundingBox(int & xMin, int & yMin, int & xMax, int & yM
yMax = m_fontData->ymax; yMax = m_fontData->ymax;
} }
int BMF_BitmapFont::GetTexture() int BMF_BitmapFont::getTexture()
{ {
int fWidth = m_fontData->xmax - m_fontData->xmin; int fWidth = m_fontData->xmax - m_fontData->xmin;
int fHeight = m_fontData->ymax - m_fontData->ymin; int fHeight = m_fontData->ymax - m_fontData->ymin;
@@ -174,7 +174,7 @@ int BMF_BitmapFont::GetTexture()
return texId; return texId;
} }
void BMF_BitmapFont::DrawStringTexture(char *str, float x, float y, float z) void BMF_BitmapFont::drawStringTexture(char *str, float x, float y, float z)
{ {
unsigned char c; unsigned char c;
float pos = 0; float pos = 0;

View File

@@ -58,9 +58,9 @@ public:
* Draws a string at the current raster position. * Draws a string at the current raster position.
* @param str The string to draw. * @param str The string to draw.
*/ */
void DrawString(const char* str); void drawString(const char* str);
void DrawStringMemory(char* str); void drawStringMemory(char* str);
/** /**
@@ -68,7 +68,7 @@ public:
* @param str The string to draw. * @param str The string to draw.
* @return The width of the string. * @return The width of the string.
*/ */
int GetStringWidth(char* str); int getStringWidth(char* str);
/** /**
* Returns the bounding box of the font. The width and * Returns the bounding box of the font. The width and
@@ -77,22 +77,22 @@ public:
* box represent the extent of the font and its positioning * box represent the extent of the font and its positioning
* about the origin. * about the origin.
*/ */
void GetBoundingBox(int & xMin, int & yMin, int & xMax, int & yMax); void getBoundingBox(int & xMin, int & yMin, int & xMax, int & yMax);
/** /**
* Convert the font to a texture, and return the GL texture * Convert the font to a texture, and return the GL texture
* ID of the texture. If the texture ID is bound, text can * ID of the texture. If the texture ID is bound, text can
* be drawn using the texture by calling DrawStringTexture. * be drawn using the texture by calling drawStringTexture.
* *
* @return The GL texture ID of the new texture, or -1 if unable * @return The GL texture ID of the new texture, or -1 if unable
* to create. * to create.
*/ */
int GetTexture(); int getTexture();
/** /**
* Draw the given @a string at the point @a x, @a y, @a z, using * Draw the given @a string at the point @a x, @a y, @a z, using
* texture coordinates. This assumes that an appropriate texture * texture coordinates. This assumes that an appropriate texture
* has been bound, see BMF_BitmapFont::GetTexture(). The string * has been bound, see BMF_BitmapFont::getTexture(). The string
* is drawn along the positive X axis. * is drawn along the positive X axis.
* *
* @param string The c-string to draw. * @param string The c-string to draw.
@@ -100,7 +100,7 @@ public:
* @param y The y coordinate to start drawing at. * @param y The y coordinate to start drawing at.
* @param z The z coordinate to start drawing at. * @param z The z coordinate to start drawing at.
*/ */
void DrawStringTexture(char* string, float x, float y, float z); void drawStringTexture(char* string, float x, float y, float z);
protected: protected:
/** Pointer to the font data. */ /** Pointer to the font data. */

View File

@@ -46,7 +46,7 @@ struct btDebugCastResult : public btConvexCast::CastResult
{ {
} }
virtual void DrawCoordSystem(const btTransform& tr) virtual void drawCoordSystem(const btTransform& tr)
{ {
float m[16]; float m[16];
tr.getOpenGLMatrix(m); tr.getOpenGLMatrix(m);
@@ -71,9 +71,9 @@ struct btDebugCastResult : public btConvexCast::CastResult
float m[16]; float m[16];
btTransform hitTrans; btTransform hitTrans;
btTransformUtil::IntegrateTransform(m_fromTrans,m_linVel,m_angVel,fraction,hitTrans); btTransformUtil::integrateTransform(m_fromTrans,m_linVel,m_angVel,fraction,hitTrans);
hitTrans.getOpenGLMatrix(m); hitTrans.getOpenGLMatrix(m);
GL_ShapeDrawer::DrawOpenGL(m,m_shape,btVector3(1,0,0),btIDebugDraw::DBG_NoDebug); GL_ShapeDrawer::drawOpenGL(m,m_shape,btVector3(1,0,0),btIDebugDraw::DBG_NoDebug);
} }
}; };

View File

@@ -397,8 +397,8 @@ void DemoApplication::shootBox(const btVector3& destination)
startTransform.setOrigin(camPos); startTransform.setOrigin(camPos);
btCollisionShape* boxShape = new btBoxShape(btVector3(1.f,1.f,1.f)); btCollisionShape* boxShape = new btBoxShape(btVector3(1.f,1.f,1.f));
btRigidBody* body = this->LocalCreateRigidBody(isDynamic, mass, startTransform,boxShape); btRigidBody* body = this->localCreateRigidBody(isDynamic, mass, startTransform,boxShape);
m_dynamicsWorld->AddCollisionObject(body); m_dynamicsWorld->addCollisionObject(body);
btVector3 linVel(destination[0]-camPos[0],destination[1]-camPos[1],destination[2]-camPos[2]); btVector3 linVel(destination[0]-camPos[0],destination[1]-camPos[1],destination[2]-camPos[2]);
linVel.normalize(); linVel.normalize();
@@ -420,7 +420,7 @@ void DemoApplication::shootBox(const btVector3& destination)
startTransform.setOrigin(camPos); startTransform.setOrigin(camPos);
btCollisionShape* boxShape = new btBoxShape(btVector3(1.f,1.f,1.f)); btCollisionShape* boxShape = new btBoxShape(btVector3(1.f,1.f,1.f));
CcdPhysicsController* newBox = LocalCreatePhysicsObject(isDynamic, mass, startTransform,boxShape); CcdPhysicsController* newBox = localCreatePhysicsObject(isDynamic, mass, startTransform,boxShape);
btVector3 linVel(destination[0]-camPos[0],destination[1]-camPos[1],destination[2]-camPos[2]); btVector3 linVel(destination[0]-camPos[0],destination[1]-camPos[1],destination[2]-camPos[2]);
linVel.normalize(); linVel.normalize();
@@ -440,7 +440,7 @@ float gOldPickingDist = 0.f;
btRigidBody* pickedBody = 0;//for deactivation state btRigidBody* pickedBody = 0;//for deactivation state
btVector3 DemoApplication::GetRayTo(int x,int y) btVector3 DemoApplication::getRayTo(int x,int y)
{ {
float top = 1.f; float top = 1.f;
@@ -482,7 +482,7 @@ void DemoApplication::mouseFunc(int button, int state, int x, int y)
//printf("button %i, state %i, x=%i,y=%i\n",button,state,x,y); //printf("button %i, state %i, x=%i,y=%i\n",button,state,x,y);
//button 0, state 0 means left mouse down //button 0, state 0 means left mouse down
btVector3 rayTo = GetRayTo(x,y); btVector3 rayTo = getRayTo(x,y);
switch (button) switch (button)
{ {
@@ -508,7 +508,7 @@ void DemoApplication::mouseFunc(int button, int state, int x, int y)
float normal[3]; float normal[3];
btCollisionWorld::ClosestRayResultCallback rayCallback(m_cameraPosition,rayTo); btCollisionWorld::ClosestRayResultCallback rayCallback(m_cameraPosition,rayTo);
m_dynamicsWorld->RayTest(m_cameraPosition,rayTo,rayCallback); m_dynamicsWorld->rayTest(m_cameraPosition,rayTo,rayCallback);
if (rayCallback.HasHit()) if (rayCallback.HasHit())
{ {
@@ -539,7 +539,7 @@ void DemoApplication::mouseFunc(int button, int state, int x, int y)
if (hitObj) if (hitObj)
{ {
CcdPhysicsController* physCtrl = static_cast<CcdPhysicsController*>(hitObj); CcdPhysicsController* physCtrl = static_cast<CcdPhysicsController*>(hitObj);
btRigidBody* body = physCtrl->GetRigidBody(); btRigidBody* body = physCtrl->getRigidBody();
if (body) if (body)
{ {
body->SetActivationState(ACTIVE_TAG); body->SetActivationState(ACTIVE_TAG);
@@ -576,7 +576,7 @@ void DemoApplication::mouseFunc(int button, int state, int x, int y)
float hit[3]; float hit[3];
float normal[3]; float normal[3];
btCollisionWorld::ClosestRayResultCallback rayCallback(m_cameraPosition,rayTo); btCollisionWorld::ClosestRayResultCallback rayCallback(m_cameraPosition,rayTo);
m_dynamicsWorld->RayTest(m_cameraPosition,rayTo,rayCallback); m_dynamicsWorld->rayTest(m_cameraPosition,rayTo,rayCallback);
if (rayCallback.HasHit()) if (rayCallback.HasHit())
{ {
@@ -621,7 +621,7 @@ void DemoApplication::mouseFunc(int button, int state, int x, int y)
{ {
CcdPhysicsController* physCtrl = static_cast<CcdPhysicsController*>(hitObj); CcdPhysicsController* physCtrl = static_cast<CcdPhysicsController*>(hitObj);
btRigidBody* body = physCtrl->GetRigidBody(); btRigidBody* body = physCtrl->getRigidBody();
if (body && !body->IsStatic()) if (body && !body->IsStatic())
{ {
@@ -704,14 +704,14 @@ void DemoApplication::mouseMotionFunc(int x,int y)
{ {
//keep it at the same picking distance //keep it at the same picking distance
btVector3 newRayTo = GetRayTo(x,y); btVector3 newRayTo = getRayTo(x,y);
btVector3 eyePos(m_cameraPosition[0],m_cameraPosition[1],m_cameraPosition[2]); btVector3 eyePos(m_cameraPosition[0],m_cameraPosition[1],m_cameraPosition[2]);
btVector3 dir = newRayTo-eyePos; btVector3 dir = newRayTo-eyePos;
dir.normalize(); dir.normalize();
dir *= gOldPickingDist; dir *= gOldPickingDist;
btVector3 newPos = eyePos + dir; btVector3 newPos = eyePos + dir;
p2p->SetPivotB(newPos); p2p->setPivotB(newPos);
} }
} }
@@ -726,14 +726,14 @@ void DemoApplication::mouseMotionFunc(int x,int y)
{ {
//keep it at the same picking distance //keep it at the same picking distance
btVector3 newRayTo = GetRayTo(x,y); btVector3 newRayTo = getRayTo(x,y);
btVector3 eyePos(m_cameraPosition[0],m_cameraPosition[1],m_cameraPosition[2]); btVector3 eyePos(m_cameraPosition[0],m_cameraPosition[1],m_cameraPosition[2]);
btVector3 dir = newRayTo-eyePos; btVector3 dir = newRayTo-eyePos;
dir.normalize(); dir.normalize();
dir *= gOldPickingDist; dir *= gOldPickingDist;
btVector3 newPos = eyePos + dir; btVector3 newPos = eyePos + dir;
p2p->SetPivotB(newPos); p2p->setPivotB(newPos);
} }
} }
@@ -741,11 +741,11 @@ void DemoApplication::mouseMotionFunc(int x,int y)
btRigidBody* DemoApplication::LocalCreateRigidBody(bool isDynamic, float mass, const btTransform& startTransform,btCollisionShape* shape) btRigidBody* DemoApplication::localCreateRigidBody(bool isDynamic, float mass, const btTransform& startTransform,btCollisionShape* shape)
{ {
btVector3 localInertia(0,0,0); btVector3 localInertia(0,0,0);
if (isDynamic) if (isDynamic)
shape->CalculateLocalInertia(mass,localInertia); shape->calculateLocalInertia(mass,localInertia);
btMassProps massProps(0.f,localInertia); btMassProps massProps(0.f,localInertia);
@@ -765,7 +765,7 @@ btRigidBody* DemoApplication::LocalCreateRigidBody(bool isDynamic, float mass, c
///Very basic import ///Very basic import
CcdPhysicsController* DemoApplication::LocalCreatePhysicsObject(bool isDynamic, float mass, const btTransform& startTransform,btCollisionShape* shape) CcdPhysicsController* DemoApplication::localCreatePhysicsObject(bool isDynamic, float mass, const btTransform& startTransform,btCollisionShape* shape)
{ {
startTransforms[numObjects] = startTransform; startTransforms[numObjects] = startTransform;
@@ -779,7 +779,7 @@ CcdPhysicsController* DemoApplication::LocalCreatePhysicsObject(bool isDynamic,
int i = numObjects; int i = numObjects;
{ {
gShapePtr[i] = shape; gShapePtr[i] = shape;
gShapePtr[i]->SetMargin(0.05f); gShapePtr[i]->setMargin(0.05f);
btQuaternion orn = startTransform.getRotation(); btQuaternion orn = startTransform.getRotation();
@@ -806,7 +806,7 @@ CcdPhysicsController* DemoApplication::LocalCreatePhysicsObject(bool isDynamic,
if (isDynamic) if (isDynamic)
{ {
gShapePtr[i]->CalculateLocalInertia(ccdObjectCi.m_mass,localInertia); gShapePtr[i]->calculateLocalInertia(ccdObjectCi.m_mass,localInertia);
} }
ccdObjectCi.m_localInertiaTensor = localInertia; ccdObjectCi.m_localInertiaTensor = localInertia;
@@ -816,10 +816,10 @@ CcdPhysicsController* DemoApplication::LocalCreatePhysicsObject(bool isDynamic,
physObjects[i]= new CcdPhysicsController( ccdObjectCi); physObjects[i]= new CcdPhysicsController( ccdObjectCi);
// Only do CCD if motion in one timestep (1.f/60.f) exceeds CUBE_HALF_EXTENTS // Only do CCD if motion in one timestep (1.f/60.f) exceeds CUBE_HALF_EXTENTS
physObjects[i]->GetRigidBody()->m_ccdSquareMotionTreshold = 0.f; physObjects[i]->getRigidBody()->m_ccdSquareMotionTreshold = 0.f;
//Experimental: better estimation of CCD Time of Impact: //Experimental: better estimation of CCD Time of Impact:
//physObjects[i]->GetRigidBody()->m_ccdSweptShereRadius = 0.5*CUBE_HALF_EXTENTS; //physObjects[i]->getRigidBody()->m_ccdSweptShereRadius = 0.5*CUBE_HALF_EXTENTS;
m_physicsEnvironmentPtr->addCcdPhysicsController( physObjects[i]); m_physicsEnvironmentPtr->addCcdPhysicsController( physObjects[i]);
@@ -837,11 +837,11 @@ void DemoApplication::renderme()
if (m_dynamicsWorld) if (m_dynamicsWorld)
{ {
int numObjects = m_dynamicsWorld->GetNumCollisionObjects(); int numObjects = m_dynamicsWorld->getNumCollisionObjects();
btVector3 wireColor(1,0,0); btVector3 wireColor(1,0,0);
for (int i=0;i<numObjects;i++) for (int i=0;i<numObjects;i++)
{ {
btCollisionObject* colObj = m_dynamicsWorld->GetCollisionObjectArray()[i]; btCollisionObject* colObj = m_dynamicsWorld->getCollisionObjectArray()[i];
colObj->m_worldTransform.getOpenGLMatrix(m); colObj->m_worldTransform.getOpenGLMatrix(m);
btVector3 wireColor(1.f,1.0f,0.5f); //wants deactivation btVector3 wireColor(1.f,1.0f,0.5f); //wants deactivation
@@ -871,7 +871,7 @@ void DemoApplication::renderme()
} }
} }
GL_ShapeDrawer::DrawOpenGL(m,colObj->m_collisionShape,wireColor,getDebugMode()); GL_ShapeDrawer::drawOpenGL(m,colObj->m_collisionShape,wireColor,getDebugMode());
} }
} }
@@ -909,7 +909,7 @@ void DemoApplication::renderme()
{ {
CcdPhysicsController* ctrl = m_physicsEnvironmentPtr->GetPhysicsController(i); CcdPhysicsController* ctrl = m_physicsEnvironmentPtr->GetPhysicsController(i);
btRigidBody* body = ctrl->GetRigidBody(); btRigidBody* body = ctrl->getRigidBody();
body->m_worldTransform.getOpenGLMatrix( m ); body->m_worldTransform.getOpenGLMatrix( m );
@@ -919,7 +919,7 @@ void DemoApplication::renderme()
wireColor = btVector3(0.f,0.0f,1.f); wireColor = btVector3(0.f,0.0f,1.f);
} }
///color differently for active, sleeping, wantsdeactivation states ///color differently for active, sleeping, wantsdeactivation states
if (ctrl->GetRigidBody()->GetActivationState() == 1) //active if (ctrl->getRigidBody()->GetActivationState() == 1) //active
{ {
if (i & 1) if (i & 1)
{ {
@@ -929,7 +929,7 @@ void DemoApplication::renderme()
wireColor += btVector3 (.5f,0.f,0.f); wireColor += btVector3 (.5f,0.f,0.f);
} }
} }
if (ctrl->GetRigidBody()->GetActivationState() == 2) //ISLAND_SLEEPING if (ctrl->getRigidBody()->GetActivationState() == 2) //ISLAND_SLEEPING
{ {
if (i & 1) if (i & 1)
{ {
@@ -941,8 +941,8 @@ void DemoApplication::renderme()
} }
char extraDebug[125]; char extraDebug[125];
sprintf(extraDebug,"Island:%i, Body:%i",ctrl->GetRigidBody()->m_islandTag1,ctrl->GetRigidBody()->m_debugBodyId); sprintf(extraDebug,"Island:%i, Body:%i",ctrl->getRigidBody()->m_islandTag1,ctrl->getRigidBody()->m_debugBodyId);
ctrl->GetRigidBody()->GetCollisionShape()->SetExtraDebugInfo(extraDebug); ctrl->getRigidBody()->getCollisionShape()->setExtraDebugInfo(extraDebug);
float vec[16]; float vec[16];
btTransform ident; btTransform ident;
@@ -950,7 +950,7 @@ void DemoApplication::renderme()
ident.getOpenGLMatrix(vec); ident.getOpenGLMatrix(vec);
GL_ShapeDrawer::DrawOpenGL(m,ctrl->GetRigidBody()->GetCollisionShape(),wireColor,getDebugMode()); GL_ShapeDrawer::drawOpenGL(m,ctrl->getRigidBody()->getCollisionShape(),wireColor,getDebugMode());

View File

@@ -99,7 +99,7 @@ class DemoApplication
m_debugMode = mode; m_debugMode = mode;
} }
CcdPhysicsEnvironment* GetPhysicsEnvironment() CcdPhysicsEnvironment* getPhysicsEnvironment()
{ {
return m_physicsEnvironmentPtr; return m_physicsEnvironmentPtr;
} }
@@ -142,11 +142,11 @@ class DemoApplication
///Demo functions ///Demo functions
void shootBox(const btVector3& destination); void shootBox(const btVector3& destination);
btVector3 GetRayTo(int x,int y); btVector3 getRayTo(int x,int y);
CcdPhysicsController* LocalCreatePhysicsObject(bool isDynamic, float mass, const btTransform& startTransform,btCollisionShape* shape); CcdPhysicsController* localCreatePhysicsObject(bool isDynamic, float mass, const btTransform& startTransform,btCollisionShape* shape);
btRigidBody* LocalCreateRigidBody(bool isDynamic, float mass, const btTransform& startTransform,btCollisionShape* shape); btRigidBody* localCreateRigidBody(bool isDynamic, float mass, const btTransform& startTransform,btCollisionShape* shape);
///callback methods by glut ///callback methods by glut

View File

@@ -22,7 +22,7 @@ GLDebugDrawer::GLDebugDrawer()
{ {
} }
void GLDebugDrawer::DrawLine(const btVector3& from,const btVector3& to,const btVector3& color) void GLDebugDrawer::drawLine(const btVector3& from,const btVector3& to,const btVector3& color)
{ {
if (m_debugMode > 0) if (m_debugMode > 0)
{ {
@@ -34,13 +34,13 @@ void GLDebugDrawer::DrawLine(const btVector3& from,const btVector3& to,const btV
} }
} }
void GLDebugDrawer::SetDebugMode(int debugMode) void GLDebugDrawer::setDebugMode(int debugMode)
{ {
m_debugMode = debugMode; m_debugMode = debugMode;
} }
void GLDebugDrawer::DrawContactPoint(const btVector3& pointOnB,const btVector3& normalOnB,float distance,int lifeTime,const btVector3& color) void GLDebugDrawer::drawContactPoint(const btVector3& pointOnB,const btVector3& normalOnB,float distance,int lifeTime,const btVector3& color)
{ {
if (m_debugMode & btIDebugDraw::DBG_DrawContactPoints) if (m_debugMode & btIDebugDraw::DBG_DrawContactPoints)
{ {

View File

@@ -13,13 +13,13 @@ public:
GLDebugDrawer(); GLDebugDrawer();
virtual void DrawLine(const btVector3& from,const btVector3& to,const btVector3& color); virtual void drawLine(const btVector3& from,const btVector3& to,const btVector3& color);
virtual void DrawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,float distance,int lifeTime,const btVector3& color); virtual void drawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,float distance,int lifeTime,const btVector3& color);
virtual void SetDebugMode(int debugMode); virtual void setDebugMode(int debugMode);
virtual int GetDebugMode() const { return m_debugMode;} virtual int getDebugMode() const { return m_debugMode;}
}; };

View File

@@ -44,7 +44,7 @@ subject to the following restrictions:
#include "BMF_Api.h" #include "BMF_Api.h"
#include <stdio.h> //printf debugging #include <stdio.h> //printf debugging
void GL_ShapeDrawer::DrawCoordSystem() { void GL_ShapeDrawer::drawCoordSystem() {
glBegin(GL_LINES); glBegin(GL_LINES);
glColor3f(1, 0, 0); glColor3f(1, 0, 0);
glVertex3d(0, 0, 0); glVertex3d(0, 0, 0);
@@ -67,7 +67,7 @@ class GlDrawcallback : public btTriangleCallback
{ {
public: public:
virtual void ProcessTriangle(btVector3* triangle,int partId, int triangleIndex) virtual void processTriangle(btVector3* triangle,int partId, int triangleIndex)
{ {
glBegin(GL_LINES); glBegin(GL_LINES);
glColor3f(1, 0, 0); glColor3f(1, 0, 0);
@@ -87,7 +87,7 @@ public:
class TriangleGlDrawcallback : public btInternalTriangleIndexCallback class TriangleGlDrawcallback : public btInternalTriangleIndexCallback
{ {
public: public:
virtual void InternalProcessTriangleIndex(btVector3* triangle,int partId,int triangleIndex) virtual void internalProcessTriangleIndex(btVector3* triangle,int partId,int triangleIndex)
{ {
glBegin(GL_TRIANGLES);//LINES); glBegin(GL_TRIANGLES);//LINES);
glColor3f(1, 0, 0); glColor3f(1, 0, 0);
@@ -104,28 +104,28 @@ public:
}; };
void GL_ShapeDrawer::DrawOpenGL(float* m, const btCollisionShape* shape, const btVector3& color,int debugMode) void GL_ShapeDrawer::drawOpenGL(float* m, const btCollisionShape* shape, const btVector3& color,int debugMode)
{ {
glPushMatrix(); glPushMatrix();
glMultMatrixf(m); glMultMatrixf(m);
if (shape->GetShapeType() == COMPOUND_SHAPE_PROXYTYPE) if (shape->getShapeType() == COMPOUND_SHAPE_PROXYTYPE)
{ {
const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(shape); const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(shape);
for (int i=compoundShape->GetNumChildShapes()-1;i>=0;i--) for (int i=compoundShape->getNumChildShapes()-1;i>=0;i--)
{ {
btTransform childTrans = compoundShape->GetChildTransform(i); btTransform childTrans = compoundShape->getChildTransform(i);
const btCollisionShape* colShape = compoundShape->GetChildShape(i); const btCollisionShape* colShape = compoundShape->getChildShape(i);
float childMat[16]; float childMat[16];
childTrans.getOpenGLMatrix(childMat); childTrans.getOpenGLMatrix(childMat);
DrawOpenGL(childMat,colShape,color,debugMode); drawOpenGL(childMat,colShape,color,debugMode);
} }
} else } else
{ {
//DrawCoordSystem(); //drawCoordSystem();
//glPushMatrix(); //glPushMatrix();
glEnable(GL_COLOR_MATERIAL); glEnable(GL_COLOR_MATERIAL);
@@ -137,12 +137,12 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const btCollisionShape* shape, const b
if (!(debugMode & btIDebugDraw::DBG_DrawWireframe)) if (!(debugMode & btIDebugDraw::DBG_DrawWireframe))
{ {
switch (shape->GetShapeType()) switch (shape->getShapeType())
{ {
case BOX_SHAPE_PROXYTYPE: case BOX_SHAPE_PROXYTYPE:
{ {
const btBoxShape* boxShape = static_cast<const btBoxShape*>(shape); const btBoxShape* boxShape = static_cast<const btBoxShape*>(shape);
btVector3 halfExtent = boxShape->GetHalfExtents(); btVector3 halfExtent = boxShape->getHalfExtents();
glScaled(2*halfExtent[0], 2*halfExtent[1], 2*halfExtent[2]); glScaled(2*halfExtent[0], 2*halfExtent[1], 2*halfExtent[2]);
glutSolidCube(1.0); glutSolidCube(1.0);
useWireframeFallback = false; useWireframeFallback = false;
@@ -160,7 +160,7 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const btCollisionShape* shape, const b
case SPHERE_SHAPE_PROXYTYPE: case SPHERE_SHAPE_PROXYTYPE:
{ {
const btSphereShape* sphereShape = static_cast<const btSphereShape*>(shape); const btSphereShape* sphereShape = static_cast<const btSphereShape*>(shape);
float radius = sphereShape->GetMargin();//radius doesn't include the margin, so draw with margin float radius = sphereShape->getMargin();//radius doesn't include the margin, so draw with margin
glutSolidSphere(radius,10,10); glutSolidSphere(radius,10,10);
useWireframeFallback = false; useWireframeFallback = false;
break; break;
@@ -169,8 +169,8 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const btCollisionShape* shape, const b
case CONE_SHAPE_PROXYTYPE: case CONE_SHAPE_PROXYTYPE:
{ {
const btConeShape* coneShape = static_cast<const btConeShape*>(shape); const btConeShape* coneShape = static_cast<const btConeShape*>(shape);
float radius = coneShape->GetRadius();//+coneShape->GetMargin(); float radius = coneShape->getRadius();//+coneShape->getMargin();
float height = coneShape->GetHeight();//+coneShape->GetMargin(); float height = coneShape->getHeight();//+coneShape->getMargin();
//glRotatef(-90.0, 1.0, 0.0, 0.0); //glRotatef(-90.0, 1.0, 0.0, 0.0);
glTranslatef(0.0, 0.0, -0.5*height); glTranslatef(0.0, 0.0, -0.5*height);
glutSolidCone(radius,height,10,10); glutSolidCone(radius,height,10,10);
@@ -188,11 +188,11 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const btCollisionShape* shape, const b
case CYLINDER_SHAPE_PROXYTYPE: case CYLINDER_SHAPE_PROXYTYPE:
{ {
const btCylinderShape* cylinder = static_cast<const btCylinderShape*>(shape); const btCylinderShape* cylinder = static_cast<const btCylinderShape*>(shape);
int upAxis = cylinder->GetUpAxis(); int upAxis = cylinder->getUpAxis();
GLUquadricObj *quadObj = gluNewQuadric(); GLUquadricObj *quadObj = gluNewQuadric();
float radius = cylinder->GetRadius(); float radius = cylinder->getRadius();
float halfHeight = cylinder->GetHalfExtents()[upAxis]; float halfHeight = cylinder->getHalfExtents()[upAxis];
glPushMatrix(); glPushMatrix();
switch (upAxis) switch (upAxis)
@@ -244,7 +244,7 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const btCollisionShape* shape, const b
if (useWireframeFallback) if (useWireframeFallback)
{ {
/// for polyhedral shapes /// for polyhedral shapes
if (shape->IsPolyhedral()) if (shape->isPolyhedral())
{ {
btPolyhedralConvexShape* polyshape = (btPolyhedralConvexShape*) shape; btPolyhedralConvexShape* polyshape = (btPolyhedralConvexShape*) shape;
@@ -253,10 +253,10 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const btCollisionShape* shape, const b
int i; int i;
for (i=0;i<polyshape->GetNumEdges();i++) for (i=0;i<polyshape->getNumEdges();i++)
{ {
btPoint3 a,b; btPoint3 a,b;
polyshape->GetEdge(i,a,b); polyshape->getEdge(i,a,b);
glVertex3f(a.getX(),a.getY(),a.getZ()); glVertex3f(a.getX(),a.getY(),a.getZ());
glVertex3f(b.getX(),b.getY(),b.getZ()); glVertex3f(b.getX(),b.getY(),b.getZ());
@@ -269,24 +269,24 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const btCollisionShape* shape, const b
if (debugMode==btIDebugDraw::DBG_DrawFeaturesText) if (debugMode==btIDebugDraw::DBG_DrawFeaturesText)
{ {
glRasterPos3f(0.0, 0.0, 0.0); glRasterPos3f(0.0, 0.0, 0.0);
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),polyshape->GetExtraDebugInfo()); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),polyshape->getExtraDebugInfo());
glColor3f(1.f, 1.f, 1.f); glColor3f(1.f, 1.f, 1.f);
for (i=0;i<polyshape->GetNumVertices();i++) for (i=0;i<polyshape->getNumVertices();i++)
{ {
btPoint3 vtx; btPoint3 vtx;
polyshape->GetVertex(i,vtx); polyshape->getVertex(i,vtx);
glRasterPos3f(vtx.x(), vtx.y(), vtx.z()); glRasterPos3f(vtx.x(), vtx.y(), vtx.z());
char buf[12]; char buf[12];
sprintf(buf," %d",i); sprintf(buf," %d",i);
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf);
} }
for (i=0;i<polyshape->GetNumPlanes();i++) for (i=0;i<polyshape->getNumPlanes();i++)
{ {
btVector3 normal; btVector3 normal;
btPoint3 vtx; btPoint3 vtx;
polyshape->GetPlane(normal,vtx,i); polyshape->getPlane(normal,vtx,i);
btScalar d = vtx.dot(normal); btScalar d = vtx.dot(normal);
glRasterPos3f(normal.x()*d, normal.y()*d, normal.z()*d); glRasterPos3f(normal.x()*d, normal.y()*d, normal.z()*d);
@@ -301,7 +301,7 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const btCollisionShape* shape, const b
} }
} }
if (shape->GetShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE) if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)
{ {
btTriangleMeshShape* concaveMesh = (btTriangleMeshShape*) shape; btTriangleMeshShape* concaveMesh = (btTriangleMeshShape*) shape;
//btVector3 aabbMax(1e30f,1e30f,1e30f); //btVector3 aabbMax(1e30f,1e30f,1e30f);
@@ -313,12 +313,12 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const btCollisionShape* shape, const b
GlDrawcallback drawCallback; GlDrawcallback drawCallback;
concaveMesh->ProcessAllTriangles(&drawCallback,aabbMin,aabbMax); concaveMesh->processAllTriangles(&drawCallback,aabbMin,aabbMax);
} }
if (shape->GetShapeType() == CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE) if (shape->getShapeType() == CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE)
{ {
btConvexTriangleMeshShape* convexMesh = (btConvexTriangleMeshShape*) shape; btConvexTriangleMeshShape* convexMesh = (btConvexTriangleMeshShape*) shape;
@@ -326,7 +326,7 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const btCollisionShape* shape, const b
btVector3 aabbMax(1e30f,1e30f,1e30f); btVector3 aabbMax(1e30f,1e30f,1e30f);
btVector3 aabbMin(-1e30f,-1e30f,-1e30f); btVector3 aabbMin(-1e30f,-1e30f,-1e30f);
TriangleGlDrawcallback drawCallback; TriangleGlDrawcallback drawCallback;
convexMesh->GetStridingMesh()->InternalProcessAllTriangles(&drawCallback,aabbMin,aabbMax); convexMesh->getStridingMesh()->InternalProcessAllTriangles(&drawCallback,aabbMin,aabbMax);
} }
@@ -335,12 +335,12 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const btCollisionShape* shape, const b
glRasterPos3f(0,0,0);//mvtx.x(), vtx.y(), vtx.z()); glRasterPos3f(0,0,0);//mvtx.x(), vtx.y(), vtx.z());
if (debugMode&btIDebugDraw::DBG_DrawText) if (debugMode&btIDebugDraw::DBG_DrawText)
{ {
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),shape->GetName()); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),shape->getName());
} }
if (debugMode& btIDebugDraw::DBG_DrawFeaturesText) if (debugMode& btIDebugDraw::DBG_DrawFeaturesText)
{ {
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),shape->GetExtraDebugInfo()); BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),shape->getExtraDebugInfo());
} }
glEnable(GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_BUFFER_BIT);

View File

@@ -23,8 +23,8 @@ class GL_ShapeDrawer
{ {
public: public:
static void DrawOpenGL(float* m, const btCollisionShape* shape, const btVector3& color,int debugMode); static void drawOpenGL(float* m, const btCollisionShape* shape, const btVector3& color,int debugMode);
static void DrawCoordSystem(); static void drawCoordSystem();
}; };

View File

@@ -34,16 +34,16 @@ GL_Simplex1to4::GL_Simplex1to4()
} }
/// ///
/// Debugging method CalcClosest calculates the closest point to the origin, using m_simplexSolver /// Debugging method calcClosest calculates the closest point to the origin, using m_simplexSolver
/// ///
void GL_Simplex1to4::CalcClosest(float* m) void GL_Simplex1to4::calcClosest(float* m)
{ {
btTransform tr; btTransform tr;
tr.setFromOpenGLMatrix(m); tr.setFromOpenGLMatrix(m);
GL_ShapeDrawer::DrawCoordSystem(); GL_ShapeDrawer::drawCoordSystem();
if (m_simplexSolver) if (m_simplexSolver)
{ {

View File

@@ -29,9 +29,9 @@ class GL_Simplex1to4 : public btBU_Simplex1to4
GL_Simplex1to4(); GL_Simplex1to4();
void CalcClosest(float* m); void calcClosest(float* m);
void SetSimplexSolver(btSimplexSolverInterface* simplexSolver) { void setSimplexSolver(btSimplexSolverInterface* simplexSolver) {
m_simplexSolver = simplexSolver; m_simplexSolver = simplexSolver;
} }

View File

@@ -13,11 +13,11 @@ subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
*/ */
#include "RenderTexture.h" #include "renderTexture.h"
#include <memory.h> #include <memory.h>
#include "BMF_FontData.h" #include "BMF_FontData.h"
RenderTexture::RenderTexture(int width,int height) renderTexture::renderTexture(int width,int height)
:m_height(height),m_width(width) :m_height(height),m_width(width)
{ {
m_buffer = new unsigned char[m_width*m_height*4]; m_buffer = new unsigned char[m_width*m_height*4];
@@ -30,14 +30,14 @@ RenderTexture::RenderTexture(int width,int height)
{ {
for (int y=0;y<m_height;y++) for (int y=0;y<m_height;y++)
{ {
SetPixel(x,y,btVector4(float(x),float(y),0.f,1.f)); setPixel(x,y,btVector4(float(x),float(y),0.f,1.f));
} }
} }
} }
void RenderTexture::Printf(char* str, BMF_FontData* fontData, int startx,int starty) void renderTexture::grapicalPrintf(char* str, BMF_FontData* fontData, int startx,int starty)
{ {
unsigned char c; unsigned char c;
int rasterposx = startx; int rasterposx = startx;
@@ -55,7 +55,7 @@ void RenderTexture::Printf(char* str, BMF_FontData* fontData, int startx,int sta
char packedColor = bitmap[y]; char packedColor = bitmap[y];
float colorf = packedColor & bit ? 1.f : 0.f; float colorf = packedColor & bit ? 1.f : 0.f;
btVector4 rgba(colorf,colorf,colorf,1.f); btVector4 rgba(colorf,colorf,colorf,1.f);
SetPixel(rasterposx+x,rasterposy+8-y-1,rgba); setPixel(rasterposx+x,rasterposy+8-y-1,rgba);
bit >>=1; bit >>=1;
} }
} }
@@ -64,7 +64,7 @@ void RenderTexture::Printf(char* str, BMF_FontData* fontData, int startx,int sta
} }
} }
RenderTexture::~RenderTexture() renderTexture::~renderTexture()
{ {
delete [] m_buffer; delete [] m_buffer;
} }

View File

@@ -20,9 +20,9 @@ subject to the following restrictions:
#include "BMF_FontData.h" #include "BMF_FontData.h"
/// ///
///RenderTexture provides a software-render context (setpixel/printf) ///renderTexture provides a software-render context (setpixel/printf)
/// ///
class RenderTexture class renderTexture
{ {
int m_height; int m_height;
int m_width; int m_width;
@@ -30,10 +30,10 @@ class RenderTexture
public: public:
RenderTexture(int width,int height); renderTexture(int width,int height);
~RenderTexture(); ~renderTexture();
inline void SetPixel(int x,int y,const btVector4& rgba) inline void setPixel(int x,int y,const btVector4& rgba)
{ {
unsigned char* pixel = &m_buffer[ (x+y*m_width) * 4]; unsigned char* pixel = &m_buffer[ (x+y*m_width) * 4];
@@ -43,10 +43,10 @@ public:
pixel[3] = (unsigned char)(255*rgba.getW()); pixel[3] = (unsigned char)(255*rgba.getW());
} }
const unsigned char* GetBuffer() const { return m_buffer;} const unsigned char* getBuffer() const { return m_buffer;}
int GetWidth() const { return m_width;} int getWidth() const { return m_width;}
int GetHeight() const { return m_height;} int getHeight() const { return m_height;}
void Printf(char* str, BMF_FontData* fontData, int startx = 0,int starty=0); void grapicalPrintf(char* str, BMF_FontData* fontData, int startx = 0,int starty=0);
}; };

View File

@@ -12,7 +12,7 @@
/* /*
Raytracer uses the Convex Raycast to visualize the Collision Shapes/Minkowski Sum. Raytracer uses the Convex rayCast to visualize the Collision Shapes/Minkowski Sum.
Very basic raytracer, rendering into a texture. Very basic raytracer, rendering into a texture.
*/ */
@@ -46,7 +46,7 @@ Very basic raytracer, rendering into a texture.
#include "RenderTexture.h" #include "renderTexture.h"
btVoronoiSimplexSolver simplexSolver; btVoronoiSimplexSolver simplexSolver;
@@ -60,7 +60,7 @@ GL_Simplex1to4 simplex;
btConvexShape* shapePtr[maxNumObjects]; btConvexShape* shapePtr[maxNumObjects];
btTransform transforms[maxNumObjects]; btTransform transforms[maxNumObjects];
RenderTexture* raytracePicture = 0; renderTexture* raytracePicture = 0;
int screenWidth = 128; int screenWidth = 128;
int screenHeight = 128; int screenHeight = 128;
@@ -90,16 +90,16 @@ int main(int argc,char** argv)
void Raytracer::initPhysics() void Raytracer::initPhysics()
{ {
raytracePicture = new RenderTexture(screenWidth,screenHeight); raytracePicture = new renderTexture(screenWidth,screenHeight);
myBox.SetMargin(0.02f); myBox.setMargin(0.02f);
myCone.SetMargin(0.2f); myCone.setMargin(0.2f);
simplex.SetSimplexSolver(&simplexSolver); simplex.setSimplexSolver(&simplexSolver);
simplex.AddVertex(btPoint3(-1,0,-1)); simplex.addVertex(btPoint3(-1,0,-1));
simplex.AddVertex(btPoint3(1,0,-1)); simplex.addVertex(btPoint3(1,0,-1));
simplex.AddVertex(btPoint3(0,0,1)); simplex.addVertex(btPoint3(0,0,1));
simplex.AddVertex(btPoint3(0,1,0)); simplex.addVertex(btPoint3(0,1,0));
/// convex hull of 5 spheres /// convex hull of 5 spheres
@@ -123,7 +123,7 @@ void Raytracer::initPhysics()
shapePtr[2] =convexHullShape; shapePtr[2] =convexHullShape;
shapePtr[3] =&myMink;//myBox;//multiSphereShape shapePtr[3] =&myMink;//myBox;//multiSphereShape
simplex.SetMargin(0.3f); simplex.setMargin(0.3f);
} }
@@ -155,7 +155,7 @@ void Raytracer::displayCallback()
transforms[i].setRotation(orn); transforms[i].setRotation(orn);
} }
} }
myMink.SetTransformA(btTransform(transforms[0].getRotation())); myMink.setTransformA(btTransform(transforms[0].getRotation()));
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
@@ -236,7 +236,7 @@ void Raytracer::displayCallback()
for (int y=0;y<screenHeight;y++) for (int y=0;y<screenHeight;y++)
{ {
btVector4 rgba(0.f,0.f,0.f,0.f); btVector4 rgba(0.f,0.f,0.f,0.f);
raytracePicture->SetPixel(x,y,rgba); raytracePicture->setPixel(x,y,rgba);
} }
} }
@@ -286,12 +286,12 @@ void Raytracer::displayCallback()
light = 1.f; light = 1.f;
rgba = btVector4(light,light,light,1.f); rgba = btVector4(light,light,light,1.f);
raytracePicture->SetPixel(x,y,rgba); raytracePicture->setPixel(x,y,rgba);
} else } else
{ {
//clear is already done //clear is already done
//rgba = btVector4(0.f,0.f,0.f,0.f); //rgba = btVector4(0.f,0.f,0.f,0.f);
//raytracePicture->SetPixel(x,y,rgba); //raytracePicture->setPixel(x,y,rgba);
} }
@@ -306,10 +306,10 @@ void Raytracer::displayCallback()
extern BMF_FontData BMF_font_helv10; extern BMF_FontData BMF_font_helv10;
raytracePicture->Printf("CCD RAYTRACER",&BMF_font_helv10); raytracePicture->grapicalPrintf("CCD RAYTRACER",&BMF_font_helv10);
char buffer[256]; char buffer[256];
sprintf(buffer,"%d RAYS / Frame",screenWidth*screenHeight*numObjects); sprintf(buffer,"%d RAYS / Frame",screenWidth*screenHeight*numObjects);
raytracePicture->Printf(buffer,&BMF_font_helv10,0,10); raytracePicture->grapicalPrintf(buffer,&BMF_font_helv10,0,10);
#endif //TEST_PRINTF #endif //TEST_PRINTF
@@ -321,7 +321,7 @@ void Raytracer::displayCallback()
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glPushMatrix(); glPushMatrix();
glLoadIdentity(); // Reset The Modelview Matrix glLoadIdentity(); // reset The Modelview Matrix
glTranslatef(0.0f,0.0f,-3.0f); // Move Into The Screen 5 Units glTranslatef(0.0f,0.0f,-3.0f); // Move Into The Screen 5 Units
@@ -329,11 +329,11 @@ void Raytracer::displayCallback()
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,glTextureId ); glBindTexture(GL_TEXTURE_2D,glTextureId );
const unsigned char *ptr = raytracePicture->GetBuffer(); const unsigned char *ptr = raytracePicture->getBuffer();
glTexImage2D(GL_TEXTURE_2D, glTexImage2D(GL_TEXTURE_2D,
0, 0,
GL_RGBA, GL_RGBA,
raytracePicture->GetWidth(),raytracePicture->GetHeight(), raytracePicture->getWidth(),raytracePicture->getHeight(),
0, 0,
GL_RGBA, GL_RGBA,
GL_UNSIGNED_BYTE, GL_UNSIGNED_BYTE,
@@ -368,7 +368,7 @@ void Raytracer::displayCallback()
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
GL_ShapeDrawer::DrawCoordSystem(); GL_ShapeDrawer::drawCoordSystem();
glPushMatrix(); glPushMatrix();
@@ -386,9 +386,9 @@ void Raytracer::displayCallback()
transA.getOpenGLMatrix( m ); transA.getOpenGLMatrix( m );
/// draw the simplex /// draw the simplex
GL_ShapeDrawer::DrawOpenGL(m,shapePtr[i],btVector3(1,1,1)); GL_ShapeDrawer::drawOpenGL(m,shapePtr[i],btVector3(1,1,1));
/// calculate closest point from simplex to the origin, and draw this vector /// calculate closest point from simplex to the origin, and draw this vector
simplex.CalcClosest(m); simplex.calcClosest(m);
} }
*/ */

View File

@@ -71,7 +71,7 @@ void SimplexDemo::displayCallback()
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
GL_ShapeDrawer::DrawCoordSystem(); GL_ShapeDrawer::drawCoordSystem();
float m[16]; float m[16];
int i; int i;
@@ -88,10 +88,10 @@ void SimplexDemo::displayCallback()
transA.getOpenGLMatrix( m ); transA.getOpenGLMatrix( m );
/// draw the simplex /// draw the simplex
GL_ShapeDrawer::DrawOpenGL(m,shapePtr[i],btVector3(1,1,1),getDebugMode()); GL_ShapeDrawer::drawOpenGL(m,shapePtr[i],btVector3(1,1,1),getDebugMode());
/// calculate closest point from simplex to the origin, and draw this vector /// calculate closest point from simplex to the origin, and draw this vector
simplex.CalcClosest(m); simplex.calcClosest(m);
} }
pitch += 0.005f; pitch += 0.005f;
@@ -104,12 +104,12 @@ void SimplexDemo::displayCallback()
void SimplexDemo::initPhysics() void SimplexDemo::initPhysics()
{ {
simplex.SetSimplexSolver(&simplexSolver); simplex.setSimplexSolver(&simplexSolver);
simplex.AddVertex(btPoint3(-2,0,-2)); simplex.addVertex(btPoint3(-2,0,-2));
simplex.AddVertex(btPoint3(2,0,-2)); simplex.addVertex(btPoint3(2,0,-2));
simplex.AddVertex(btPoint3(0,0,2)); simplex.addVertex(btPoint3(0,0,2));
simplex.AddVertex(btPoint3(0,2,0)); simplex.addVertex(btPoint3(0,2,0));
shapePtr[0] = &simplex; shapePtr[0] = &simplex;

View File

@@ -126,7 +126,7 @@ void UserCollisionAlgorithm::initPhysics()
btVector3 maxAabb(10000,10000,10000); btVector3 maxAabb(10000,10000,10000);
btOverlappingPairCache* broadphase = new btAxisSweep3(-maxAabb,maxAabb);//SimpleBroadphase(); btOverlappingPairCache* broadphase = new btAxisSweep3(-maxAabb,maxAabb);//SimpleBroadphase();
dispatcher->RegisterCollisionCreateFunc(SPHERE_SHAPE_PROXYTYPE,SPHERE_SHAPE_PROXYTYPE,new btSphereSphereCollisionAlgorithm::CreateFunc); dispatcher->registerCollisionCreateFunc(SPHERE_SHAPE_PROXYTYPE,SPHERE_SHAPE_PROXYTYPE,new btSphereSphereCollisionAlgorithm::CreateFunc);
m_physicsEnvironmentPtr = new CcdPhysicsEnvironment(dispatcher,broadphase); m_physicsEnvironmentPtr = new CcdPhysicsEnvironment(dispatcher,broadphase);
@@ -137,16 +137,16 @@ void UserCollisionAlgorithm::initPhysics()
startTransform.setIdentity(); startTransform.setIdentity();
startTransform.setOrigin(btVector3(0,-2,0)); startTransform.setOrigin(btVector3(0,-2,0));
CcdPhysicsController* staticTrimesh = LocalCreatePhysicsObject(isDynamic, mass, startTransform,trimeshShape); CcdPhysicsController* staticTrimesh = localCreatePhysicsObject(isDynamic, mass, startTransform,trimeshShape);
//enable custom material callback //enable custom material callback
staticTrimesh->GetRigidBody()->m_collisionFlags |= btCollisionObject::customMaterialCallback; staticTrimesh->getRigidBody()->m_collisionFlags |= btCollisionObject::customMaterialCallback;
{ {
for (int i=0;i<10;i++) for (int i=0;i<10;i++)
{ {
btCollisionShape* sphereShape = new btSphereShape(1); btCollisionShape* sphereShape = new btSphereShape(1);
startTransform.setOrigin(btVector3(1,2*i,1)); startTransform.setOrigin(btVector3(1,2*i,1));
LocalCreatePhysicsObject(true, 1, startTransform,sphereShape); localCreatePhysicsObject(true, 1, startTransform,sphereShape);
} }
} }
m_physicsEnvironmentPtr->setGravity(-1,-10,1); m_physicsEnvironmentPtr->setGravity(-1,-10,1);

View File

@@ -186,12 +186,12 @@ const float TRIANGLE_SIZE=20.f;
tr.setOrigin(btVector3(0,-20.f,0)); tr.setOrigin(btVector3(0,-20.f,0));
//create ground object //create ground object
LocalCreatePhysicsObject(false,0,tr,groundShape); localCreatePhysicsObject(false,0,tr,groundShape);
btCollisionShape* chassisShape = new btBoxShape(btVector3(1.f,0.5f,2.f)); btCollisionShape* chassisShape = new btBoxShape(btVector3(1.f,0.5f,2.f));
tr.setOrigin(btVector3(0,0.f,0)); tr.setOrigin(btVector3(0,0.f,0));
m_carChassis = LocalCreatePhysicsObject(true,800,tr,chassisShape); m_carChassis = localCreatePhysicsObject(true,800,tr,chassisShape);
clientResetScene(); clientResetScene();
@@ -208,7 +208,7 @@ const float TRIANGLE_SIZE=20.f;
0,0,0); 0,0,0);
///never deactivate the vehicle ///never deactivate the vehicle
m_carChassis->GetRigidBody()->SetActivationState(DISABLE_DEACTIVATION); m_carChassis->getRigidBody()->SetActivationState(DISABLE_DEACTIVATION);
gVehicleConstraint = m_physicsEnvironmentPtr->getVehicleConstraint(constraintId); gVehicleConstraint = m_physicsEnvironmentPtr->getVehicleConstraint(constraintId);
@@ -219,25 +219,25 @@ const float TRIANGLE_SIZE=20.f;
int upIndex = 1; int upIndex = 1;
int forwardIndex = 2; int forwardIndex = 2;
gVehicleConstraint->SetCoordinateSystem(rightIndex,upIndex,forwardIndex); gVehicleConstraint->setCoordinateSystem(rightIndex,upIndex,forwardIndex);
gVehicleConstraint->AddWheel(&wheelMotionState[0], gVehicleConstraint->addWheel(&wheelMotionState[0],
(PHY__Vector3&)connectionPointCS0, (PHY__Vector3&)connectionPointCS0,
(PHY__Vector3&)wheelDirectionCS0,(PHY__Vector3&)wheelAxleCS,suspensionRestLength,wheelRadius,isFrontWheel); (PHY__Vector3&)wheelDirectionCS0,(PHY__Vector3&)wheelAxleCS,suspensionRestLength,wheelRadius,isFrontWheel);
connectionPointCS0 = btVector3(-CUBE_HALF_EXTENTS+(0.3*wheelWidth),0,2*CUBE_HALF_EXTENTS-wheelRadius); connectionPointCS0 = btVector3(-CUBE_HALF_EXTENTS+(0.3*wheelWidth),0,2*CUBE_HALF_EXTENTS-wheelRadius);
gVehicleConstraint->AddWheel(&wheelMotionState[1], gVehicleConstraint->addWheel(&wheelMotionState[1],
(PHY__Vector3&)connectionPointCS0, (PHY__Vector3&)connectionPointCS0,
(PHY__Vector3&)wheelDirectionCS0,(PHY__Vector3&)wheelAxleCS,suspensionRestLength,wheelRadius,isFrontWheel); (PHY__Vector3&)wheelDirectionCS0,(PHY__Vector3&)wheelAxleCS,suspensionRestLength,wheelRadius,isFrontWheel);
connectionPointCS0 = btVector3(-CUBE_HALF_EXTENTS+(0.3*wheelWidth),0,-2*CUBE_HALF_EXTENTS+wheelRadius); connectionPointCS0 = btVector3(-CUBE_HALF_EXTENTS+(0.3*wheelWidth),0,-2*CUBE_HALF_EXTENTS+wheelRadius);
isFrontWheel = false; isFrontWheel = false;
gVehicleConstraint->AddWheel(&wheelMotionState[2], gVehicleConstraint->addWheel(&wheelMotionState[2],
(PHY__Vector3&)connectionPointCS0, (PHY__Vector3&)connectionPointCS0,
(PHY__Vector3&)wheelDirectionCS0,(PHY__Vector3&)wheelAxleCS,suspensionRestLength,wheelRadius,isFrontWheel); (PHY__Vector3&)wheelDirectionCS0,(PHY__Vector3&)wheelAxleCS,suspensionRestLength,wheelRadius,isFrontWheel);
connectionPointCS0 = btVector3(CUBE_HALF_EXTENTS-(0.3*wheelWidth),0,-2*CUBE_HALF_EXTENTS+wheelRadius); connectionPointCS0 = btVector3(CUBE_HALF_EXTENTS-(0.3*wheelWidth),0,-2*CUBE_HALF_EXTENTS+wheelRadius);
gVehicleConstraint->AddWheel(&wheelMotionState[3], gVehicleConstraint->addWheel(&wheelMotionState[3],
(PHY__Vector3&)connectionPointCS0, (PHY__Vector3&)connectionPointCS0,
(PHY__Vector3&)wheelDirectionCS0,(PHY__Vector3&)wheelAxleCS,suspensionRestLength,wheelRadius,isFrontWheel); (PHY__Vector3&)wheelDirectionCS0,(PHY__Vector3&)wheelAxleCS,suspensionRestLength,wheelRadius,isFrontWheel);
@@ -277,7 +277,7 @@ void VehicleDemo::renderme()
{ {
updateCamera(); updateCamera();
debugDrawer.SetDebugMode(getDebugMode()); debugDrawer.setDebugMode(getDebugMode());
float m[16]; float m[16];
int i; int i;
@@ -288,7 +288,7 @@ void VehicleDemo::renderme()
{ {
//draw wheels (cylinders) //draw wheels (cylinders)
wheelMotionState[i].m_worldTransform.getOpenGLMatrix(m); wheelMotionState[i].m_worldTransform.getOpenGLMatrix(m);
GL_ShapeDrawer::DrawOpenGL(m,&wheelShape,wheelColor,getDebugMode()); GL_ShapeDrawer::drawOpenGL(m,&wheelShape,wheelColor,getDebugMode());
} }
DemoApplication::renderme(); DemoApplication::renderme();
@@ -302,14 +302,14 @@ void VehicleDemo::clientMoveAndDisplay()
{ {
int steerWheelIndex = 2; int steerWheelIndex = 2;
gVehicleConstraint->ApplyEngineForce(gEngineForce,steerWheelIndex); gVehicleConstraint->applyEngineForce(gEngineForce,steerWheelIndex);
steerWheelIndex = 3; steerWheelIndex = 3;
gVehicleConstraint->ApplyEngineForce(gEngineForce,steerWheelIndex); gVehicleConstraint->applyEngineForce(gEngineForce,steerWheelIndex);
steerWheelIndex = 0; steerWheelIndex = 0;
gVehicleConstraint->SetSteeringValue(gVehicleSteering,steerWheelIndex); gVehicleConstraint->setSteeringValue(gVehicleSteering,steerWheelIndex);
steerWheelIndex = 1; steerWheelIndex = 1;
gVehicleConstraint->SetSteeringValue(gVehicleSteering,steerWheelIndex); gVehicleConstraint->setSteeringValue(gVehicleSteering,steerWheelIndex);
} }
@@ -415,7 +415,7 @@ void VehicleDemo::updateCamera()
glLoadIdentity(); glLoadIdentity();
//look at the vehicle //look at the vehicle
m_cameraTargetPosition = m_carChassis->GetRigidBody()->m_worldTransform.getOrigin(); m_cameraTargetPosition = m_carChassis->getRigidBody()->m_worldTransform.getOrigin();
//interpolate the camera height //interpolate the camera height
m_cameraPosition[1] = (15.0*m_cameraPosition[1] + m_cameraTargetPosition[1] + m_cameraHeight)/16.0; m_cameraPosition[1] = (15.0*m_cameraPosition[1] + m_cameraTargetPosition[1] + m_cameraHeight)/16.0;

View File

@@ -267,7 +267,7 @@ WARN_LOGFILE =
# directories like "/usr/src/myproject". Separate the files or directories # directories like "/usr/src/myproject". Separate the files or directories
# with spaces. # with spaces.
INPUT = src Extras/PhysicsInterface Demos INPUT = src Demos
# If the value of the INPUT tag contains directories, you can use the # If the value of the INPUT tag contains directories, you can use the

View File

@@ -58,8 +58,8 @@ bool BU_CollisionPair::calcTimeOfImpact(
btVector3 linvelA,angvelA; btVector3 linvelA,angvelA;
btVector3 linvelB,angvelB; btVector3 linvelB,angvelB;
btTransformUtil::CalculateVelocity(fromA,toA,1.f,linvelA,angvelA); btTransformUtil::calculateVelocity(fromA,toA,1.f,linvelA,angvelA);
btTransformUtil::CalculateVelocity(fromB,toB,1.f,linvelB,angvelB); btTransformUtil::calculateVelocity(fromB,toB,1.f,linvelB,angvelB);
btVector3 linearMotionA = toA.getOrigin() - fromA.getOrigin(); btVector3 linearMotionA = toA.getOrigin() - fromA.getOrigin();
@@ -85,11 +85,11 @@ bool BU_CollisionPair::calcTimeOfImpact(
/* debugging code /* debugging code
{ {
const int numvertsB = m_convexB->GetNumVertices(); const int numvertsB = m_convexB->getNumVertices();
for (int v=0;v<numvertsB;v++) for (int v=0;v<numvertsB;v++)
{ {
btPoint3 pt; btPoint3 pt;
m_convexB->GetVertex(v,pt); m_convexB->getVertex(v,pt);
pt = b2w * pt; pt = b2w * pt;
char buf[1000]; char buf[1000];
@@ -182,11 +182,11 @@ bool BU_CollisionPair::calcTimeOfImpact(
//toi = 0; //toi = 0;
/* /*
{ {
const int numvertsB = m_convexB->GetNumVertices(); const int numvertsB = m_convexB->getNumVertices();
for (int v=0;v<numvertsB;v++) for (int v=0;v<numvertsB;v++)
{ {
btPoint3 pt; btPoint3 pt;
m_convexB->GetVertex(v,pt); m_convexB->getVertex(v,pt);
pt = impactTransB * pt; pt = impactTransB * pt;
char buf[1000]; char buf[1000];
@@ -215,11 +215,11 @@ bool BU_CollisionPair::calcTimeOfImpact(
BU_EdgeEdge edgeEdge; BU_EdgeEdge edgeEdge;
//for all edged in A check agains all edges in B //for all edged in A check agains all edges in B
for (int ea = 0;ea < m_convexA->GetNumEdges();ea++) for (int ea = 0;ea < m_convexA->getNumEdges();ea++)
{ {
btPoint3 pA0,pA1; btPoint3 pA0,pA1;
m_convexA->GetEdge(ea,pA0,pA1); m_convexA->getEdge(ea,pA0,pA1);
pA0= a2w * pA0;//in world space pA0= a2w * pA0;//in world space
pA0 = w2s * pA0;//in screwing space pA0 = w2s * pA0;//in screwing space
@@ -227,12 +227,12 @@ bool BU_CollisionPair::calcTimeOfImpact(
pA1= a2w * pA1;//in world space pA1= a2w * pA1;//in world space
pA1 = w2s * pA1;//in screwing space pA1 = w2s * pA1;//in screwing space
int numedgesB = m_convexB->GetNumEdges(); int numedgesB = m_convexB->getNumEdges();
for (int eb = 0; eb < numedgesB;eb++) for (int eb = 0; eb < numedgesB;eb++)
{ {
{ {
btPoint3 pB0,pB1; btPoint3 pB0,pB1;
m_convexB->GetEdge(eb,pB0,pB1); m_convexB->getEdge(eb,pB0,pB1);
pB0= b2w * pB0;//in world space pB0= b2w * pB0;//in world space
pB0 = w2s * pB0;//in screwing space pB0 = w2s * pB0;//in screwing space
@@ -307,18 +307,18 @@ bool BU_CollisionPair::calcTimeOfImpact(
// for all vertices in A, for each face in B,do vertex-face // for all vertices in A, for each face in B,do vertex-face
{ {
const int numvertsA = m_convexA->GetNumVertices(); const int numvertsA = m_convexA->getNumVertices();
for (int v=0;v<numvertsA;v++) for (int v=0;v<numvertsA;v++)
//int v=3; //int v=3;
{ {
btPoint3 vtx; btPoint3 vtx;
m_convexA->GetVertex(v,vtx); m_convexA->getVertex(v,vtx);
vtx = a2w * vtx;//in world space vtx = a2w * vtx;//in world space
vtx = w2s * vtx;//in screwing space vtx = w2s * vtx;//in screwing space
const int numplanesB = m_convexB->GetNumPlanes(); const int numplanesB = m_convexB->getNumPlanes();
for (int p = 0 ; p < numplanesB; p++) for (int p = 0 ; p < numplanesB; p++)
//int p=2; //int p=2;
@@ -329,7 +329,7 @@ bool BU_CollisionPair::calcTimeOfImpact(
btVector3 planeNorm; btVector3 planeNorm;
btPoint3 planeSupport; btPoint3 planeSupport;
m_convexB->GetPlane(planeNorm,planeSupport,p); m_convexB->getPlane(planeNorm,planeSupport,p);
planeSupport = b2w * planeSupport;//transform to world space planeSupport = b2w * planeSupport;//transform to world space
@@ -377,7 +377,7 @@ bool BU_CollisionPair::calcTimeOfImpact(
hitpt = b2winv * hitptWorld; hitpt = b2winv * hitptWorld;
//vertex has to be 'within' the facet's boundary //vertex has to be 'within' the facet's boundary
if (m_convexB->IsInside(hitpt,m_tolerance)) if (m_convexB->isInside(hitpt,m_tolerance))
{ {
// m_manifold.SetContactPoint(BUM_FeatureVertexFace, index,v,p,hitptWorld,hitNormalWorld); // m_manifold.SetContactPoint(BUM_FeatureVertexFace, index,v,p,hitptWorld,hitNormalWorld);
@@ -403,13 +403,13 @@ bool BU_CollisionPair::calcTimeOfImpact(
//todo: make this into one method with a kind of 'swapped' logic //todo: make this into one method with a kind of 'swapped' logic
// //
{ {
const int numvertsB = m_convexB->GetNumVertices(); const int numvertsB = m_convexB->getNumVertices();
for (int v=0;v<numvertsB;v++) for (int v=0;v<numvertsB;v++)
//int v=0; //int v=0;
{ {
btPoint3 vtx; btPoint3 vtx;
m_convexB->GetVertex(v,vtx); m_convexB->getVertex(v,vtx);
vtx = b2w * vtx;//in world space vtx = b2w * vtx;//in world space
/* /*
@@ -429,7 +429,7 @@ bool BU_CollisionPair::calcTimeOfImpact(
*/ */
vtx = w2s * vtx;//in screwing space vtx = w2s * vtx;//in screwing space
const int numplanesA = m_convexA->GetNumPlanes(); const int numplanesA = m_convexA->getNumPlanes();
for (int p = 0 ; p < numplanesA; p++) for (int p = 0 ; p < numplanesA; p++)
//int p=2; //int p=2;
@@ -439,7 +439,7 @@ bool BU_CollisionPair::calcTimeOfImpact(
btVector3 planeNorm; btVector3 planeNorm;
btPoint3 planeSupport; btPoint3 planeSupport;
m_convexA->GetPlane(planeNorm,planeSupport,p); m_convexA->getPlane(planeNorm,planeSupport,p);
planeSupport = a2w * planeSupport;//transform to world space planeSupport = a2w * planeSupport;//transform to world space
@@ -477,7 +477,7 @@ bool BU_CollisionPair::calcTimeOfImpact(
//vertex has to be 'within' the facet's boundary //vertex has to be 'within' the facet's boundary
if (m_convexA->IsInside(hitpt,m_tolerance)) if (m_convexA->isInside(hitpt,m_tolerance))
{ {
// m_manifold.SetContactPoint(BUM_FeatureFaceVertex,index,p,v,hitptWorld,hitNormalWorld); // m_manifold.SetContactPoint(BUM_FeatureFaceVertex,index,p,v,hitptWorld,hitNormalWorld);
@@ -552,11 +552,11 @@ bool BU_CollisionPair::calcTimeOfImpact(
/* /*
{ {
const int numvertsB = m_convexB->GetNumVertices(); const int numvertsB = m_convexB->getNumVertices();
for (int v=0;v<numvertsB;v++) for (int v=0;v<numvertsB;v++)
{ {
btPoint3 pt; btPoint3 pt;
m_convexB->GetVertex(v,pt); m_convexB->getVertex(v,pt);
pt = impactTransB * pt; pt = impactTransB * pt;
char buf[1000]; char buf[1000];

View File

@@ -23,9 +23,9 @@ btSphereSphereCollisionAlgorithm::btSphereSphereCollisionAlgorithm(btPersistentM
m_ownManifold(false), m_ownManifold(false),
m_manifoldPtr(mf) m_manifoldPtr(mf)
{ {
if (!m_manifoldPtr && m_dispatcher->NeedsCollision(*proxy0,*proxy1)) if (!m_manifoldPtr && m_dispatcher->needsCollision(*proxy0,*proxy1))
{ {
m_manifoldPtr = m_dispatcher->GetNewManifold(proxy0->m_clientObject,proxy1->m_clientObject); m_manifoldPtr = m_dispatcher->getNewManifold(proxy0->m_clientObject,proxy1->m_clientObject);
m_ownManifold = true; m_ownManifold = true;
} }
} }
@@ -35,11 +35,11 @@ btSphereSphereCollisionAlgorithm::~btSphereSphereCollisionAlgorithm()
if (m_ownManifold) if (m_ownManifold)
{ {
if (m_manifoldPtr) if (m_manifoldPtr)
m_dispatcher->ReleaseManifold(m_manifoldPtr); m_dispatcher->releaseManifold(m_manifoldPtr);
} }
} }
void btSphereSphereCollisionAlgorithm::ProcessCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo) void btSphereSphereCollisionAlgorithm::processCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo)
{ {
if (!m_manifoldPtr) if (!m_manifoldPtr)
return; return;
@@ -51,8 +51,8 @@ void btSphereSphereCollisionAlgorithm::ProcessCollision (btBroadphaseProxy* prox
btVector3 diff = col0->m_worldTransform.getOrigin()- col1->m_worldTransform.getOrigin(); btVector3 diff = col0->m_worldTransform.getOrigin()- col1->m_worldTransform.getOrigin();
float len = diff.length(); float len = diff.length();
btScalar radius0 = sphere0->GetRadius(); btScalar radius0 = sphere0->getRadius();
btScalar radius1 = sphere1->GetRadius(); btScalar radius1 = sphere1->getRadius();
///iff distance positive, don't generate a new contact ///iff distance positive, don't generate a new contact
if ( len > (radius0+radius1)) if ( len > (radius0+radius1))
@@ -68,13 +68,13 @@ void btSphereSphereCollisionAlgorithm::ProcessCollision (btBroadphaseProxy* prox
btVector3 pos1 = col1->m_worldTransform.getOrigin() + radius1* normalOnSurfaceB; btVector3 pos1 = col1->m_worldTransform.getOrigin() + radius1* normalOnSurfaceB;
/// report a contact. internally this will be kept persistent, and contact reduction is done /// report a contact. internally this will be kept persistent, and contact reduction is done
btManifoldResult* resultOut = m_dispatcher->GetNewManifoldResult(col0,col1,m_manifoldPtr); btManifoldResult* resultOut = m_dispatcher->getNewManifoldResult(col0,col1,m_manifoldPtr);
resultOut->AddContactPoint(normalOnSurfaceB,pos1,dist); resultOut->addContactPoint(normalOnSurfaceB,pos1,dist);
m_dispatcher->ReleaseManifoldResult(resultOut); m_dispatcher->releaseManifoldResult(resultOut);
} }
float btSphereSphereCollisionAlgorithm::CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo) float btSphereSphereCollisionAlgorithm::calculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo)
{ {
//not yet //not yet
return 1.f; return 1.f;

View File

@@ -33,9 +33,9 @@ public:
btSphereSphereCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci) btSphereSphereCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci)
: btCollisionAlgorithm(ci) {} : btCollisionAlgorithm(ci) {}
virtual void ProcessCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo); virtual void processCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo);
virtual float CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo); virtual float calculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo);
btSphereSphereCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1); btSphereSphereCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);

View File

@@ -2916,7 +2916,7 @@ HullError HullLibrary::ReleaseResult(HullResult &result) // release memory alloc
} }
static void AddPoint(unsigned int &vcount,float *p,float x,float y,float z) static void addPoint(unsigned int &vcount,float *p,float x,float y,float z)
{ {
float *dest = &p[vcount*3]; float *dest = &p[vcount*3];
dest[0] = x; dest[0] = x;
@@ -3022,14 +3022,14 @@ bool HullLibrary::CleanupVertices(unsigned int svcount,
float z1 = center[2] - dz; float z1 = center[2] - dz;
float z2 = center[2] + dz; float z2 = center[2] + dz;
AddPoint(vcount,vertices,x1,y1,z1); addPoint(vcount,vertices,x1,y1,z1);
AddPoint(vcount,vertices,x2,y1,z1); addPoint(vcount,vertices,x2,y1,z1);
AddPoint(vcount,vertices,x2,y2,z1); addPoint(vcount,vertices,x2,y2,z1);
AddPoint(vcount,vertices,x1,y2,z1); addPoint(vcount,vertices,x1,y2,z1);
AddPoint(vcount,vertices,x1,y1,z2); addPoint(vcount,vertices,x1,y1,z2);
AddPoint(vcount,vertices,x2,y1,z2); addPoint(vcount,vertices,x2,y1,z2);
AddPoint(vcount,vertices,x2,y2,z2); addPoint(vcount,vertices,x2,y2,z2);
AddPoint(vcount,vertices,x1,y2,z2); addPoint(vcount,vertices,x1,y2,z2);
return true; // return cube return true; // return cube
@@ -3177,14 +3177,14 @@ bool HullLibrary::CleanupVertices(unsigned int svcount,
vcount = 0; // add box vcount = 0; // add box
AddPoint(vcount,vertices,x1,y1,z1); addPoint(vcount,vertices,x1,y1,z1);
AddPoint(vcount,vertices,x2,y1,z1); addPoint(vcount,vertices,x2,y1,z1);
AddPoint(vcount,vertices,x2,y2,z1); addPoint(vcount,vertices,x2,y2,z1);
AddPoint(vcount,vertices,x1,y2,z1); addPoint(vcount,vertices,x1,y2,z1);
AddPoint(vcount,vertices,x1,y1,z2); addPoint(vcount,vertices,x1,y1,z2);
AddPoint(vcount,vertices,x2,y1,z2); addPoint(vcount,vertices,x2,y1,z2);
AddPoint(vcount,vertices,x2,y2,z2); addPoint(vcount,vertices,x2,y2,z2);
AddPoint(vcount,vertices,x1,y2,z2); addPoint(vcount,vertices,x1,y2,z2);
return true; return true;
} }

View File

@@ -570,7 +570,7 @@ public:
int ParseLine(int lineno,int argc,const char **argv); // return TRUE to continue parsing, return FALSE to abort parsing process int ParseLine(int lineno,int argc,const char **argv); // return TRUE to continue parsing, return FALSE to abort parsing process
private: private:
void GetVertex(GeometryVertex &v,const char *face) const; void getVertex(GeometryVertex &v,const char *face) const;
FloatVector mVerts; FloatVector mVerts;
FloatVector mTexels; FloatVector mTexels;
@@ -609,7 +609,7 @@ static const char * GetArg(const char **argv,int i,int argc)
return ret; return ret;
} }
void OBJ::GetVertex(GeometryVertex &v,const char *face) const void OBJ::getVertex(GeometryVertex &v,const char *face) const
{ {
v.mPos[0] = 0; v.mPos[0] = 0;
v.mPos[1] = 0; v.mPos[1] = 0;
@@ -717,7 +717,7 @@ int OBJ::ParseLine(int lineno,int argc,const char **argv) // return TRUE to con
for (int i=1; i<argc; i++) for (int i=1; i<argc; i++)
{ {
GetVertex(v[i-1],argv[i] ); getVertex(v[i-1],argv[i] );
} }
// need to generate a normal! // need to generate a normal!
@@ -765,7 +765,7 @@ class BuildMesh : public GeometryInterface
{ {
public: public:
int GetIndex(const float *p) int getIndex(const float *p)
{ {
int vcount = mVertices.size()/3; int vcount = mVertices.size()/3;
@@ -791,9 +791,9 @@ public:
virtual void NodeTriangle(const GeometryVertex *v1,const GeometryVertex *v2,const GeometryVertex *v3) virtual void NodeTriangle(const GeometryVertex *v1,const GeometryVertex *v2,const GeometryVertex *v3)
{ {
mIndices.push_back( GetIndex(v1->mPos) ); mIndices.push_back( getIndex(v1->mPos) );
mIndices.push_back( GetIndex(v2->mPos) ); mIndices.push_back( getIndex(v2->mPos) );
mIndices.push_back( GetIndex(v3->mPos) ); mIndices.push_back( getIndex(v3->mPos) );
} }
const FloatVector& GetVertices(void) const { return mVertices; }; const FloatVector& GetVertices(void) const { return mVertices; };

View File

@@ -173,7 +173,7 @@ public:
typedef std::set<int, VertexLess > VertexSet; typedef std::set<int, VertexLess > VertexSet;
typedef std::vector< Type > VertexVector; typedef std::vector< Type > VertexVector;
int GetVertex(const Type& vtx) int getVertex(const Type& vtx)
{ {
VertexLess::SetSearch(vtx,&mVtxs); VertexLess::SetSearch(vtx,&mVtxs);
VertexSet::iterator found; VertexSet::iterator found;
@@ -224,7 +224,7 @@ public:
}; };
Type * GetBuffer(void) Type * getBuffer(void)
{ {
return &mVtxs[0]; return &mVtxs[0];
}; };
@@ -289,7 +289,7 @@ unsigned int Vl_getIndex(VertexLookup vlook,const float *pos) // get index.
{ {
VertexPool< VertexPosition > *vp = (VertexPool< VertexPosition > *) vlook; VertexPool< VertexPosition > *vp = (VertexPool< VertexPosition > *) vlook;
VertexPosition p(pos); VertexPosition p(pos);
return vp->GetVertex(p); return vp->getVertex(p);
} }
const float * Vl_getVertices(VertexLookup vlook) const float * Vl_getVertices(VertexLookup vlook)

View File

@@ -73,8 +73,8 @@ bool Epa::Initialize( btSimplexSolverInterface& simplexSolver )
btVector3 seperatingAxisInA = -v * m_transformA.getBasis(); btVector3 seperatingAxisInA = -v * m_transformA.getBasis();
btVector3 seperatingAxisInB = v * m_transformB.getBasis(); btVector3 seperatingAxisInB = v * m_transformB.getBasis();
btVector3 pInA = m_pConvexShapeA->LocalGetSupportingVertex( seperatingAxisInA ); btVector3 pInA = m_pConvexShapeA->localGetSupportingVertex( seperatingAxisInA );
btVector3 qInB = m_pConvexShapeB->LocalGetSupportingVertex( seperatingAxisInB ); btVector3 qInB = m_pConvexShapeB->localGetSupportingVertex( seperatingAxisInB );
btPoint3 pWorld = m_transformA( pInA ); btPoint3 pWorld = m_transformA( pInA );
btPoint3 qWorld = m_transformB( qInB ); btPoint3 qWorld = m_transformB( qInB );
@@ -189,8 +189,8 @@ bool Epa::Initialize( btSimplexSolverInterface& simplexSolver )
btVector3 seperatingAxisInA = v1 * m_transformA.getBasis(); btVector3 seperatingAxisInA = v1 * m_transformA.getBasis();
btVector3 seperatingAxisInB = -v1 * m_transformB.getBasis(); btVector3 seperatingAxisInB = -v1 * m_transformB.getBasis();
btVector3 p = m_pConvexShapeA->LocalGetSupportingVertex( seperatingAxisInA ); btVector3 p = m_pConvexShapeA->localGetSupportingVertex( seperatingAxisInA );
btVector3 q = m_pConvexShapeB->LocalGetSupportingVertex( seperatingAxisInB ); btVector3 q = m_pConvexShapeB->localGetSupportingVertex( seperatingAxisInB );
btPoint3 pWorld = m_transformA( p ); btPoint3 pWorld = m_transformA( p );
btPoint3 qWorld = m_transformB( q ); btPoint3 qWorld = m_transformB( q );
@@ -202,8 +202,8 @@ bool Epa::Initialize( btSimplexSolverInterface& simplexSolver )
seperatingAxisInA = v2 * m_transformA.getBasis(); seperatingAxisInA = v2 * m_transformA.getBasis();
seperatingAxisInB = -v2 * m_transformB.getBasis(); seperatingAxisInB = -v2 * m_transformB.getBasis();
p = m_pConvexShapeA->LocalGetSupportingVertex( seperatingAxisInA ); p = m_pConvexShapeA->localGetSupportingVertex( seperatingAxisInA );
q = m_pConvexShapeB->LocalGetSupportingVertex( seperatingAxisInB ); q = m_pConvexShapeB->localGetSupportingVertex( seperatingAxisInB );
pWorld = m_transformA( p ); pWorld = m_transformA( p );
qWorld = m_transformB( q ); qWorld = m_transformB( q );
@@ -215,8 +215,8 @@ bool Epa::Initialize( btSimplexSolverInterface& simplexSolver )
seperatingAxisInA = v3 * m_transformA.getBasis(); seperatingAxisInA = v3 * m_transformA.getBasis();
seperatingAxisInB = -v3 * m_transformB.getBasis(); seperatingAxisInB = -v3 * m_transformB.getBasis();
p = m_pConvexShapeA->LocalGetSupportingVertex( seperatingAxisInA ); p = m_pConvexShapeA->localGetSupportingVertex( seperatingAxisInA );
q = m_pConvexShapeB->LocalGetSupportingVertex( seperatingAxisInB ); q = m_pConvexShapeB->localGetSupportingVertex( seperatingAxisInB );
pWorld = m_transformA( p ); pWorld = m_transformA( p );
qWorld = m_transformB( q ); qWorld = m_transformB( q );
@@ -265,8 +265,8 @@ bool Epa::Initialize( btSimplexSolverInterface& simplexSolver )
btVector3 seperatingAxisInA = triangleNormal * m_transformA.getBasis(); btVector3 seperatingAxisInA = triangleNormal * m_transformA.getBasis();
btVector3 seperatingAxisInB = -triangleNormal * m_transformB.getBasis(); btVector3 seperatingAxisInB = -triangleNormal * m_transformB.getBasis();
btVector3 p = m_pConvexShapeA->LocalGetSupportingVertex( seperatingAxisInA ); btVector3 p = m_pConvexShapeA->localGetSupportingVertex( seperatingAxisInA );
btVector3 q = m_pConvexShapeB->LocalGetSupportingVertex( seperatingAxisInB ); btVector3 q = m_pConvexShapeB->localGetSupportingVertex( seperatingAxisInB );
btPoint3 pWorld = m_transformA( p ); btPoint3 pWorld = m_transformA( p );
btPoint3 qWorld = m_transformB( q ); btPoint3 qWorld = m_transformB( q );
@@ -284,8 +284,8 @@ bool Epa::Initialize( btSimplexSolverInterface& simplexSolver )
seperatingAxisInA = -triangleNormal * m_transformA.getBasis(); seperatingAxisInA = -triangleNormal * m_transformA.getBasis();
seperatingAxisInB = triangleNormal * m_transformB.getBasis(); seperatingAxisInB = triangleNormal * m_transformB.getBasis();
p = m_pConvexShapeA->LocalGetSupportingVertex( seperatingAxisInA ); p = m_pConvexShapeA->localGetSupportingVertex( seperatingAxisInA );
q = m_pConvexShapeB->LocalGetSupportingVertex( seperatingAxisInB ); q = m_pConvexShapeB->localGetSupportingVertex( seperatingAxisInB );
pWorld = m_transformA( p ); pWorld = m_transformA( p );
qWorld = m_transformB( q ); qWorld = m_transformB( q );
@@ -398,7 +398,7 @@ bool Epa::Initialize( btSimplexSolverInterface& simplexSolver )
return true; return true;
} }
btScalar Epa::CalcPenDepth( btPoint3& wWitnessOnA, btPoint3& wWitnessOnB ) btScalar Epa::calcPenDepth( btPoint3& wWitnessOnA, btPoint3& wWitnessOnB )
{ {
btVector3 v; btVector3 v;
@@ -448,8 +448,8 @@ btScalar Epa::CalcPenDepth( btPoint3& wWitnessOnA, btPoint3& wWitnessOnB )
btVector3 seperatingAxisInA = v * m_transformA.getBasis(); btVector3 seperatingAxisInA = v * m_transformA.getBasis();
btVector3 seperatingAxisInB = -v * m_transformB.getBasis(); btVector3 seperatingAxisInB = -v * m_transformB.getBasis();
btVector3 p = m_pConvexShapeA->LocalGetSupportingVertex( seperatingAxisInA ); btVector3 p = m_pConvexShapeA->localGetSupportingVertex( seperatingAxisInA );
btVector3 q = m_pConvexShapeB->LocalGetSupportingVertex( seperatingAxisInB ); btVector3 q = m_pConvexShapeB->localGetSupportingVertex( seperatingAxisInB );
btPoint3 pWorld = m_transformA( p ); btPoint3 pWorld = m_transformA( p );
btPoint3 qWorld = m_transformB( q ); btPoint3 qWorld = m_transformB( q );

View File

@@ -40,7 +40,7 @@ class Epa
bool Initialize( btSimplexSolverInterface& simplexSolver ); bool Initialize( btSimplexSolverInterface& simplexSolver );
btScalar CalcPenDepth( btPoint3& wWitnessOnA, btPoint3& wWitnessOnB ); btScalar calcPenDepth( btPoint3& wWitnessOnA, btPoint3& wWitnessOnB );
private : private :

View File

@@ -39,7 +39,7 @@ subject to the following restrictions:
btScalar g_GJKMaxRelError = 1e-3f; btScalar g_GJKMaxRelError = 1e-3f;
btScalar g_GJKMaxRelErrorSqrd = g_GJKMaxRelError * g_GJKMaxRelError; btScalar g_GJKMaxRelErrorSqrd = g_GJKMaxRelError * g_GJKMaxRelError;
bool EpaPenetrationDepthSolver::CalcPenDepth( btSimplexSolverInterface& simplexSolver, bool EpaPenetrationDepthSolver::calcPenDepth( btSimplexSolverInterface& simplexSolver,
btConvexShape* pConvexA, btConvexShape* pConvexB, btConvexShape* pConvexA, btConvexShape* pConvexB,
const btTransform& transformA, const btTransform& transformB, const btTransform& transformA, const btTransform& transformB,
btVector3& v, btPoint3& wWitnessOnA, btPoint3& wWitnessOnB, btVector3& v, btPoint3& wWitnessOnA, btPoint3& wWitnessOnB,
@@ -79,7 +79,7 @@ bool EpaPenetrationDepthSolver::HybridPenDepth( btSimplexSolverInterface& simple
btScalar squaredDistance = SIMD_INFINITY; btScalar squaredDistance = SIMD_INFINITY;
btScalar delta = 0.f; btScalar delta = 0.f;
const btScalar margin = pConvexA->GetMargin() + pConvexB->GetMargin(); const btScalar margin = pConvexA->getMargin() + pConvexB->getMargin();
const btScalar marginSqrd = margin * margin; const btScalar marginSqrd = margin * margin;
simplexSolver.reset(); simplexSolver.reset();
@@ -93,8 +93,8 @@ bool EpaPenetrationDepthSolver::HybridPenDepth( btSimplexSolverInterface& simple
btVector3 seperatingAxisInA = -v * transformA.getBasis(); btVector3 seperatingAxisInA = -v * transformA.getBasis();
btVector3 seperatingAxisInB = v * transformB.getBasis(); btVector3 seperatingAxisInB = v * transformB.getBasis();
btVector3 pInA = pConvexA->LocalGetSupportingVertexWithoutMargin( seperatingAxisInA ); btVector3 pInA = pConvexA->localGetSupportingVertexWithoutMargin( seperatingAxisInA );
btVector3 qInB = pConvexB->LocalGetSupportingVertexWithoutMargin( seperatingAxisInB ); btVector3 qInB = pConvexB->localGetSupportingVertexWithoutMargin( seperatingAxisInB );
btPoint3 pWorld = transformA( pInA ); btPoint3 pWorld = transformA( pInA );
btPoint3 qWorld = transformB( qInB ); btPoint3 qWorld = transformB( qInB );
@@ -119,10 +119,10 @@ bool EpaPenetrationDepthSolver::HybridPenDepth( btSimplexSolverInterface& simple
assert( ( squaredDistance > 0 ) && "squaredDistance is zero!" ); assert( ( squaredDistance > 0 ) && "squaredDistance is zero!" );
btScalar vLength = sqrt( squaredDistance ); btScalar vLength = sqrt( squaredDistance );
wWitnessOnA -= v * ( pConvexA->GetMargin() / vLength ); wWitnessOnA -= v * ( pConvexA->getMargin() / vLength );
wWitnessOnB += v * ( pConvexB->GetMargin() / vLength ); wWitnessOnB += v * ( pConvexB->getMargin() / vLength );
penDepth = pConvexA->GetMargin() + pConvexB->GetMargin() - vLength; penDepth = pConvexA->getMargin() + pConvexB->getMargin() - vLength;
// Returning true means that Hybrid's result is ok and there's no need to run EPA // Returning true means that Hybrid's result is ok and there's no need to run EPA
return true; return true;
@@ -139,10 +139,10 @@ bool EpaPenetrationDepthSolver::HybridPenDepth( btSimplexSolverInterface& simple
assert( ( squaredDistance > 0 ) && "squaredDistance is zero!" ); assert( ( squaredDistance > 0 ) && "squaredDistance is zero!" );
btScalar vLength = sqrt( squaredDistance ); btScalar vLength = sqrt( squaredDistance );
wWitnessOnA -= v * ( pConvexA->GetMargin() / vLength ); wWitnessOnA -= v * ( pConvexA->getMargin() / vLength );
wWitnessOnB += v * ( pConvexB->GetMargin() / vLength ); wWitnessOnB += v * ( pConvexB->getMargin() / vLength );
penDepth = pConvexA->GetMargin() + pConvexB->GetMargin() - vLength; penDepth = pConvexA->getMargin() + pConvexB->getMargin() - vLength;
// Returning true means that Hybrid's result is ok and there's no need to run EPA // Returning true means that Hybrid's result is ok and there's no need to run EPA
return true; return true;
@@ -162,10 +162,10 @@ bool EpaPenetrationDepthSolver::HybridPenDepth( btSimplexSolverInterface& simple
assert( ( squaredDistance > 0 ) && "squaredDistance is zero!" ); assert( ( squaredDistance > 0 ) && "squaredDistance is zero!" );
btScalar vLength = sqrt( squaredDistance ); btScalar vLength = sqrt( squaredDistance );
wWitnessOnA -= v * ( pConvexA->GetMargin() / vLength ); wWitnessOnA -= v * ( pConvexA->getMargin() / vLength );
wWitnessOnB += v * ( pConvexB->GetMargin() / vLength ); wWitnessOnB += v * ( pConvexB->getMargin() / vLength );
penDepth = pConvexA->GetMargin() + pConvexB->GetMargin() - vLength; penDepth = pConvexA->getMargin() + pConvexB->getMargin() - vLength;
// Returning true means that Hybrid's result is ok and there's no need to run EPA // Returning true means that Hybrid's result is ok and there's no need to run EPA
return true; return true;
@@ -197,6 +197,6 @@ btScalar EpaPenetrationDepthSolver::EpaPenDepth( btSimplexSolverInterface& simpl
return 0; return 0;
} }
return epa.CalcPenDepth( wWitnessOnA, wWitnessOnB ); return epa.calcPenDepth( wWitnessOnA, wWitnessOnB );
} }

View File

@@ -30,7 +30,7 @@ class EpaPenetrationDepthSolver : public btConvexPenetrationDepthSolver
{ {
public : public :
bool CalcPenDepth( btSimplexSolverInterface& simplexSolver, bool calcPenDepth( btSimplexSolverInterface& simplexSolver,
btConvexShape* pConvexA, btConvexShape* pConvexB, btConvexShape* pConvexA, btConvexShape* pConvexB,
const btTransform& transformA, const btTransform& transformB, const btTransform& transformA, const btTransform& transformB,
btVector3& v, btPoint3& wWitnessOnA, btPoint3& wWitnessOnB, btVector3& v, btPoint3& wWitnessOnA, btPoint3& wWitnessOnB,

View File

@@ -317,7 +317,7 @@ inline bool originInTetrahedron(const btVector3& p1, const btVector3& p2,
bool Solid3EpaPenetrationDepth::CalcPenDepth( btSimplexSolverInterface& simplexSolver, bool Solid3EpaPenetrationDepth::calcPenDepth( btSimplexSolverInterface& simplexSolver,
btConvexShape* convexA,btConvexShape* convexB, btConvexShape* convexA,btConvexShape* convexB,
const btTransform& transformA,const btTransform& transformB, const btTransform& transformA,const btTransform& transformB,
btVector3& v, btPoint3& pa, btPoint3& pb) btVector3& v, btPoint3& pa, btPoint3& pb)
@@ -348,16 +348,16 @@ bool Solid3EpaPenetrationDepth::CalcPenDepth( btSimplexSolverInterface& simplexS
btVector3 aux2 = rot_mat * aux1; btVector3 aux2 = rot_mat * aux1;
btVector3 aux3 = rot_mat * aux2; btVector3 aux3 = rot_mat * aux2;
pBuf[2] = transformA(convexA->LocalGetSupportingVertex(aux1*transformA.getBasis())); pBuf[2] = transformA(convexA->localGetSupportingVertex(aux1*transformA.getBasis()));
qBuf[2] = transformB(convexB->LocalGetSupportingVertex((-aux1)*transformB.getBasis())); qBuf[2] = transformB(convexB->localGetSupportingVertex((-aux1)*transformB.getBasis()));
yBuf[2] = pBuf[2] - qBuf[2]; yBuf[2] = pBuf[2] - qBuf[2];
pBuf[3] = transformA(convexA->LocalGetSupportingVertex(aux2*transformA.getBasis())); pBuf[3] = transformA(convexA->localGetSupportingVertex(aux2*transformA.getBasis()));
qBuf[3] = transformB(convexB->LocalGetSupportingVertex((-aux2)*transformB.getBasis())); qBuf[3] = transformB(convexB->localGetSupportingVertex((-aux2)*transformB.getBasis()));
yBuf[3] = pBuf[3] - qBuf[3]; yBuf[3] = pBuf[3] - qBuf[3];
pBuf[4] = transformA(convexA->LocalGetSupportingVertex(aux3*transformA.getBasis())); pBuf[4] = transformA(convexA->localGetSupportingVertex(aux3*transformA.getBasis()));
qBuf[4] = transformB(convexB->LocalGetSupportingVertex((-aux3)*transformB.getBasis())); qBuf[4] = transformB(convexB->localGetSupportingVertex((-aux3)*transformB.getBasis()));
yBuf[4] = pBuf[4] - qBuf[4]; yBuf[4] = pBuf[4] - qBuf[4];
if (originInTetrahedron(yBuf[0], yBuf[2], yBuf[3], yBuf[4])) if (originInTetrahedron(yBuf[0], yBuf[2], yBuf[3], yBuf[4]))
@@ -391,11 +391,11 @@ bool Solid3EpaPenetrationDepth::CalcPenDepth( btSimplexSolverInterface& simplexS
btVector3 v2 = yBuf[2] - yBuf[0]; btVector3 v2 = yBuf[2] - yBuf[0];
btVector3 vv = v1.cross(v2); btVector3 vv = v1.cross(v2);
pBuf[3] = transformA(convexA->LocalGetSupportingVertex(vv*transformA.getBasis())); pBuf[3] = transformA(convexA->localGetSupportingVertex(vv*transformA.getBasis()));
qBuf[3] = transformB(convexB->LocalGetSupportingVertex((-vv)*transformB.getBasis())); qBuf[3] = transformB(convexB->localGetSupportingVertex((-vv)*transformB.getBasis()));
yBuf[3] = pBuf[3] - qBuf[3]; yBuf[3] = pBuf[3] - qBuf[3];
pBuf[4] = transformA(convexA->LocalGetSupportingVertex((-vv)*transformA.getBasis())); pBuf[4] = transformA(convexA->localGetSupportingVertex((-vv)*transformA.getBasis()));
qBuf[4] = transformB(convexB->LocalGetSupportingVertex(vv*transformB.getBasis())); qBuf[4] = transformB(convexB->localGetSupportingVertex(vv*transformB.getBasis()));
yBuf[4] = pBuf[4] - qBuf[4]; yBuf[4] = pBuf[4] - qBuf[4];
@@ -481,8 +481,8 @@ bool Solid3EpaPenetrationDepth::CalcPenDepth( btSimplexSolverInterface& simplexS
break; break;
} }
pBuf[num_verts] = transformA(convexA->LocalGetSupportingVertex((facet->getClosest())*transformA.getBasis())); pBuf[num_verts] = transformA(convexA->localGetSupportingVertex((facet->getClosest())*transformA.getBasis()));
qBuf[num_verts] = transformB(convexB->LocalGetSupportingVertex((-facet->getClosest())*transformB.getBasis())); qBuf[num_verts] = transformB(convexB->localGetSupportingVertex((-facet->getClosest())*transformB.getBasis()));
yBuf[num_verts] = pBuf[num_verts] - qBuf[num_verts]; yBuf[num_verts] = pBuf[num_verts] - qBuf[num_verts];

View File

@@ -32,7 +32,7 @@ class Solid3EpaPenetrationDepth : public btConvexPenetrationDepthSolver
{ {
public: public:
virtual bool CalcPenDepth(btSimplexSolverInterface& simplexSolver, virtual bool calcPenDepth(btSimplexSolverInterface& simplexSolver,
btConvexShape* convexA,btConvexShape* convexB, btConvexShape* convexA,btConvexShape* convexB,
const btTransform& transformA,const btTransform& transformB, const btTransform& transformA,const btTransform& transformB,
btVector3& v, btPoint3& pa, btPoint3& pb); btVector3& v, btPoint3& pa, btPoint3& pb);

View File

@@ -122,7 +122,7 @@ void initGLcontext ( int argc, char **argv,
glutInit ( &argc, argv ) ; glutInit ( &argc, argv ) ;
glutInitDisplayMode ( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE ) ; glutInitDisplayMode ( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE ) ;
glutInitWindowSize ( win_width, win_height ) ; glutInitWindowSize ( win_width, win_height ) ;
glutCreateWindow ( "Shader Math Demo" ) ; glutCreateWindow ( "Bullet GPU Physics Demo. http://bullet.sf.net" ) ;
glutDisplayFunc ( display ) ; glutDisplayFunc ( display ) ;
glutKeyboardFunc ( keybd ) ; glutKeyboardFunc ( keybd ) ;
glutReshapeFunc ( reshape ) ; glutReshapeFunc ( reshape ) ;
@@ -703,7 +703,7 @@ void help ()
int main ( int argc, char **argv ) int main ( int argc, char **argv )
{ {
bool disableVertexTextureSupport = false ; bool disableVertexTextureSupport = true ;
debugOpt = DRAW_ALL ; debugOpt = DRAW_ALL ;
for ( int i = 1 ; i < argc ; i++ ) for ( int i = 1 ; i < argc ; i++ )

View File

@@ -131,7 +131,7 @@ bool CcdPhysicsController::SynchronizeMotionStates(float time)
float scale[3]; float scale[3];
m_MotionState->getWorldScaling(scale[0],scale[1],scale[2]); m_MotionState->getWorldScaling(scale[0],scale[1],scale[2]);
btVector3 scaling(scale[0],scale[1],scale[2]); btVector3 scaling(scale[0],scale[1],scale[2]);
GetCollisionShape()->setLocalScaling(scaling); getCollisionShape()->setLocalScaling(scaling);
} else } else
{ {
btVector3 worldPos; btVector3 worldPos;
@@ -150,7 +150,7 @@ bool CcdPhysicsController::SynchronizeMotionStates(float time)
float scale[3]; float scale[3];
m_MotionState->getWorldScaling(scale[0],scale[1],scale[2]); m_MotionState->getWorldScaling(scale[0],scale[1],scale[2]);
btVector3 scaling(scale[0],scale[1],scale[2]); btVector3 scaling(scale[0],scale[1],scale[2]);
GetCollisionShape()->setLocalScaling(scaling); getCollisionShape()->setLocalScaling(scaling);
} }
return true; return true;
@@ -312,10 +312,10 @@ void CcdPhysicsController::setScaling(float scaleX,float scaleY,float scaleZ)
{ {
m_cci.m_scaling = btVector3(scaleX,scaleY,scaleZ); m_cci.m_scaling = btVector3(scaleX,scaleY,scaleZ);
if (m_body && m_body->GetCollisionShape()) if (m_body && m_body->getCollisionShape())
{ {
m_body->GetCollisionShape()->setLocalScaling(m_cci.m_scaling); m_body->getCollisionShape()->setLocalScaling(m_cci.m_scaling);
m_body->GetCollisionShape()->CalculateLocalInertia(m_cci.m_mass, m_cci.m_localInertiaTensor); m_body->getCollisionShape()->calculateLocalInertia(m_cci.m_mass, m_cci.m_localInertiaTensor);
m_body->setMassProps(m_cci.m_mass, m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor); m_body->setMassProps(m_cci.m_mass, m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor);
} }
} }
@@ -499,7 +499,7 @@ PHY_IPhysicsController* CcdPhysicsController::GetReplica()
btCcdConstructionInfo cinfo = m_cci; btCcdConstructionInfo cinfo = m_cci;
if (cinfo.m_collisionShape) if (cinfo.m_collisionShape)
{ {
switch (cinfo.m_collisionShape->GetShapeType()) switch (cinfo.m_collisionShape->getShapeType())
{ {
case SPHERE_SHAPE_PROXYTYPE: case SPHERE_SHAPE_PROXYTYPE:
{ {

View File

@@ -46,7 +46,7 @@ struct btCcdConstructionInfo
///CollisionFilterGroups provides some optional usage of basic collision filtering ///CollisionFilterGroups provides some optional usage of basic collision filtering
///this is done during broadphase, so very early in the pipeline ///this is done during broadphase, so very early in the pipeline
///more advanced collision filtering should be done in btCollisionDispatcher::NeedsCollision ///more advanced collision filtering should be done in btCollisionDispatcher::needsCollision
enum CollisionFilterGroups enum CollisionFilterGroups
{ {
DefaultFilter = 1, DefaultFilter = 1,
@@ -87,7 +87,7 @@ struct btCcdConstructionInfo
///optional use of collision group/mask: ///optional use of collision group/mask:
///only collision with object goups that match the collision mask. ///only collision with object goups that match the collision mask.
///this is very basic early out. advanced collision filtering should be ///this is very basic early out. advanced collision filtering should be
///done in the btCollisionDispatcher::NeedsCollision and NeedsResponse ///done in the btCollisionDispatcher::needsCollision and needsResponse
///both values default to 1 ///both values default to 1
short int m_collisionFilterGroup; short int m_collisionFilterGroup;
short int m_collisionFilterMask; short int m_collisionFilterMask;
@@ -127,10 +127,10 @@ class CcdPhysicsController : public PHY_IPhysicsController
virtual ~CcdPhysicsController(); virtual ~CcdPhysicsController();
btRigidBody* GetRigidBody() { return m_body;} btRigidBody* getRigidBody() { return m_body;}
btCollisionShape* GetCollisionShape() { btCollisionShape* getCollisionShape() {
return m_body->GetCollisionShape(); return m_body->getCollisionShape();
} }
//////////////////////////////////// ////////////////////////////////////
// PHY_IPhysicsController interface // PHY_IPhysicsController interface
@@ -198,8 +198,8 @@ class CcdPhysicsController : public PHY_IPhysicsController
virtual void calcXform() {} ; virtual void calcXform() {} ;
virtual void SetMargin(float margin) {}; virtual void setMargin(float margin) {};
virtual float GetMargin() const {return 0.f;}; virtual float getMargin() const {return 0.f;};
bool wantsSleeping(); bool wantsSleeping();
@@ -208,7 +208,7 @@ class CcdPhysicsController : public PHY_IPhysicsController
static btTransform GetTransformFromMotionState(PHY_IMotionState* motionState); static btTransform GetTransformFromMotionState(PHY_IMotionState* motionState);
void SetAabb(const btVector3& aabbMin,const btVector3& aabbMax); void setAabb(const btVector3& aabbMin,const btVector3& aabbMax);
class PHY_IMotionState* GetMotionState() class PHY_IMotionState* GetMotionState()

View File

@@ -117,7 +117,7 @@ public:
return m_chassis; return m_chassis;
} }
virtual void AddWheel( virtual void addWheel(
PHY_IMotionState* motionState, PHY_IMotionState* motionState,
PHY__Vector3 connectionPoint, PHY__Vector3 connectionPoint,
PHY__Vector3 downDirection, PHY__Vector3 downDirection,
@@ -132,7 +132,7 @@ public:
btVector3 wheelAxle(axleDirection[0],axleDirection[1],axleDirection[2]); btVector3 wheelAxle(axleDirection[0],axleDirection[1],axleDirection[2]);
btWheelInfo& info = m_vehicle->AddWheel(connectionPointCS0,wheelDirectionCS0,wheelAxle, btWheelInfo& info = m_vehicle->addWheel(connectionPointCS0,wheelDirectionCS0,wheelAxle,
suspensionRestLength,wheelRadius,gTuning,hasSteering); suspensionRestLength,wheelRadius,gTuning,hasSteering);
info.m_clientInfo = motionState; info.m_clientInfo = motionState;
@@ -140,14 +140,14 @@ public:
void SyncWheels() void SyncWheels()
{ {
int numWheels = GetNumWheels(); int numWheels = getNumWheels();
int i; int i;
for (i=0;i<numWheels;i++) for (i=0;i<numWheels;i++)
{ {
btWheelInfo& info = m_vehicle->GetWheelInfo(i); btWheelInfo& info = m_vehicle->getWheelInfo(i);
PHY_IMotionState* motionState = (PHY_IMotionState*)info.m_clientInfo ; PHY_IMotionState* motionState = (PHY_IMotionState*)info.m_clientInfo ;
m_vehicle->UpdateWheelTransform(i); m_vehicle->updateWheelTransform(i);
btTransform trans = m_vehicle->GetWheelTransformWS(i); btTransform trans = m_vehicle->getWheelTransformWS(i);
btQuaternion orn = trans.getRotation(); btQuaternion orn = trans.getRotation();
const btVector3& pos = trans.getOrigin(); const btVector3& pos = trans.getOrigin();
motionState->setWorldOrientation(orn.x(),orn.y(),orn.z(),orn[3]); motionState->setWorldOrientation(orn.x(),orn.y(),orn.z(),orn[3]);
@@ -156,21 +156,21 @@ public:
} }
} }
virtual int GetNumWheels() const virtual int getNumWheels() const
{ {
return m_vehicle->GetNumWheels(); return m_vehicle->getNumWheels();
} }
virtual void GetWheelPosition(int wheelIndex,float& posX,float& posY,float& posZ) const virtual void GetWheelPosition(int wheelIndex,float& posX,float& posY,float& posZ) const
{ {
btTransform trans = m_vehicle->GetWheelTransformWS(wheelIndex); btTransform trans = m_vehicle->getWheelTransformWS(wheelIndex);
posX = trans.getOrigin().x(); posX = trans.getOrigin().x();
posY = trans.getOrigin().y(); posY = trans.getOrigin().y();
posZ = trans.getOrigin().z(); posZ = trans.getOrigin().z();
} }
virtual void GetWheelOrientationQuaternion(int wheelIndex,float& quatX,float& quatY,float& quatZ,float& quatW) const virtual void GetWheelOrientationQuaternion(int wheelIndex,float& quatX,float& quatY,float& quatZ,float& quatW) const
{ {
btTransform trans = m_vehicle->GetWheelTransformWS(wheelIndex); btTransform trans = m_vehicle->getWheelTransformWS(wheelIndex);
btQuaternion quat = trans.getRotation(); btQuaternion quat = trans.getRotation();
btMatrix3x3 orn2(quat); btMatrix3x3 orn2(quat);
@@ -189,9 +189,9 @@ public:
{ {
float rotation = 0.f; float rotation = 0.f;
if ((wheelIndex>=0) && (wheelIndex< m_vehicle->GetNumWheels())) if ((wheelIndex>=0) && (wheelIndex< m_vehicle->getNumWheels()))
{ {
btWheelInfo& info = m_vehicle->GetWheelInfo(wheelIndex); btWheelInfo& info = m_vehicle->getWheelInfo(wheelIndex);
rotation = info.m_rotation; rotation = info.m_rotation;
} }
return rotation; return rotation;
@@ -200,40 +200,40 @@ public:
virtual int GetUserConstraintId() const virtual int getUserConstraintId() const
{ {
return m_vehicle->GetUserConstraintId(); return m_vehicle->getUserConstraintId();
} }
virtual int GetUserConstraintType() const virtual int getUserConstraintType() const
{ {
return m_vehicle->GetUserConstraintType(); return m_vehicle->getUserConstraintType();
} }
virtual void SetSteeringValue(float steering,int wheelIndex) virtual void setSteeringValue(float steering,int wheelIndex)
{ {
m_vehicle->SetSteeringValue(steering,wheelIndex); m_vehicle->setSteeringValue(steering,wheelIndex);
} }
virtual void ApplyEngineForce(float force,int wheelIndex) virtual void applyEngineForce(float force,int wheelIndex)
{ {
m_vehicle->ApplyEngineForce(force,wheelIndex); m_vehicle->applyEngineForce(force,wheelIndex);
} }
virtual void ApplyBraking(float braking,int wheelIndex) virtual void ApplyBraking(float braking,int wheelIndex)
{ {
if ((wheelIndex>=0) && (wheelIndex< m_vehicle->GetNumWheels())) if ((wheelIndex>=0) && (wheelIndex< m_vehicle->getNumWheels()))
{ {
btWheelInfo& info = m_vehicle->GetWheelInfo(wheelIndex); btWheelInfo& info = m_vehicle->getWheelInfo(wheelIndex);
info.m_brake = braking; info.m_brake = braking;
} }
} }
virtual void SetWheelFriction(float friction,int wheelIndex) virtual void SetWheelFriction(float friction,int wheelIndex)
{ {
if ((wheelIndex>=0) && (wheelIndex< m_vehicle->GetNumWheels())) if ((wheelIndex>=0) && (wheelIndex< m_vehicle->getNumWheels()))
{ {
btWheelInfo& info = m_vehicle->GetWheelInfo(wheelIndex); btWheelInfo& info = m_vehicle->getWheelInfo(wheelIndex);
info.m_frictionSlip = friction; info.m_frictionSlip = friction;
} }
@@ -241,9 +241,9 @@ public:
virtual void SetSuspensionStiffness(float suspensionStiffness,int wheelIndex) virtual void SetSuspensionStiffness(float suspensionStiffness,int wheelIndex)
{ {
if ((wheelIndex>=0) && (wheelIndex< m_vehicle->GetNumWheels())) if ((wheelIndex>=0) && (wheelIndex< m_vehicle->getNumWheels()))
{ {
btWheelInfo& info = m_vehicle->GetWheelInfo(wheelIndex); btWheelInfo& info = m_vehicle->getWheelInfo(wheelIndex);
info.m_suspensionStiffness = suspensionStiffness; info.m_suspensionStiffness = suspensionStiffness;
} }
@@ -251,18 +251,18 @@ public:
virtual void SetSuspensionDamping(float suspensionDamping,int wheelIndex) virtual void SetSuspensionDamping(float suspensionDamping,int wheelIndex)
{ {
if ((wheelIndex>=0) && (wheelIndex< m_vehicle->GetNumWheels())) if ((wheelIndex>=0) && (wheelIndex< m_vehicle->getNumWheels()))
{ {
btWheelInfo& info = m_vehicle->GetWheelInfo(wheelIndex); btWheelInfo& info = m_vehicle->getWheelInfo(wheelIndex);
info.m_wheelsDampingRelaxation = suspensionDamping; info.m_wheelsDampingRelaxation = suspensionDamping;
} }
} }
virtual void SetSuspensionCompression(float suspensionCompression,int wheelIndex) virtual void SetSuspensionCompression(float suspensionCompression,int wheelIndex)
{ {
if ((wheelIndex>=0) && (wheelIndex< m_vehicle->GetNumWheels())) if ((wheelIndex>=0) && (wheelIndex< m_vehicle->getNumWheels()))
{ {
btWheelInfo& info = m_vehicle->GetWheelInfo(wheelIndex); btWheelInfo& info = m_vehicle->getWheelInfo(wheelIndex);
info.m_wheelsDampingCompression = suspensionCompression; info.m_wheelsDampingCompression = suspensionCompression;
} }
} }
@@ -271,16 +271,16 @@ public:
virtual void SetRollInfluence(float rollInfluence,int wheelIndex) virtual void SetRollInfluence(float rollInfluence,int wheelIndex)
{ {
if ((wheelIndex>=0) && (wheelIndex< m_vehicle->GetNumWheels())) if ((wheelIndex>=0) && (wheelIndex< m_vehicle->getNumWheels()))
{ {
btWheelInfo& info = m_vehicle->GetWheelInfo(wheelIndex); btWheelInfo& info = m_vehicle->getWheelInfo(wheelIndex);
info.m_rollInfluence = rollInfluence; info.m_rollInfluence = rollInfluence;
} }
} }
virtual void SetCoordinateSystem(int rightIndex,int upIndex,int forwardIndex) virtual void setCoordinateSystem(int rightIndex,int upIndex,int forwardIndex)
{ {
m_vehicle->SetCoordinateSystem(rightIndex,upIndex,forwardIndex); m_vehicle->setCoordinateSystem(rightIndex,upIndex,forwardIndex);
} }
@@ -311,7 +311,7 @@ static void DrawAabb(btIDebugDraw* debugDrawer,const btVector3& from,const btVec
edgecoord[2]*halfExtents[2]); edgecoord[2]*halfExtents[2]);
pb+=center; pb+=center;
debugDrawer->DrawLine(pa,pb,color); debugDrawer->drawLine(pa,pb,color);
} }
edgecoord = btVector3(-1.f,-1.f,-1.f); edgecoord = btVector3(-1.f,-1.f,-1.f);
if (i<3) if (i<3)
@@ -371,7 +371,7 @@ m_scalingPropagated(false)
void CcdPhysicsEnvironment::addCcdPhysicsController(CcdPhysicsController* ctrl) void CcdPhysicsEnvironment::addCcdPhysicsController(CcdPhysicsController* ctrl)
{ {
btRigidBody* body = ctrl->GetRigidBody(); btRigidBody* body = ctrl->getRigidBody();
//this m_userPointer is just used for triggers, see CallbackTriggers //this m_userPointer is just used for triggers, see CallbackTriggers
body->m_internalOwner = ctrl; body->m_internalOwner = ctrl;
@@ -379,21 +379,21 @@ void CcdPhysicsEnvironment::addCcdPhysicsController(CcdPhysicsController* ctrl)
body->setGravity( m_gravity ); body->setGravity( m_gravity );
m_controllers.push_back(ctrl); m_controllers.push_back(ctrl);
m_collisionWorld->AddCollisionObject(body,ctrl->GetCollisionFilterGroup(),ctrl->GetCollisionFilterMask()); m_collisionWorld->addCollisionObject(body,ctrl->GetCollisionFilterGroup(),ctrl->GetCollisionFilterMask());
assert(body->m_broadphaseHandle); assert(body->m_broadphaseHandle);
btCollisionShape* shapeinterface = ctrl->GetCollisionShape(); btCollisionShape* shapeinterface = ctrl->getCollisionShape();
assert(shapeinterface); assert(shapeinterface);
const btTransform& t = ctrl->GetRigidBody()->getCenterOfMassTransform(); const btTransform& t = ctrl->getRigidBody()->getCenterOfMassTransform();
body->m_cachedInvertedWorldTransform = body->m_worldTransform.inverse(); body->m_cachedInvertedWorldTransform = body->m_worldTransform.inverse();
btPoint3 minAabb,maxAabb; btPoint3 minAabb,maxAabb;
shapeinterface->GetAabb(t,minAabb,maxAabb); shapeinterface->getAabb(t,minAabb,maxAabb);
float timeStep = 0.02f; float timeStep = 0.02f;
@@ -443,10 +443,10 @@ void CcdPhysicsEnvironment::removeCcdPhysicsController(CcdPhysicsController* ctr
!(i==m_constraints.end()); i++) !(i==m_constraints.end()); i++)
{ {
btTypedConstraint* constraint = (*i); btTypedConstraint* constraint = (*i);
if ((&constraint->GetRigidBodyA() == ctrl->GetRigidBody() || if ((&constraint->getRigidBodyA() == ctrl->getRigidBody() ||
(&constraint->GetRigidBodyB() == ctrl->GetRigidBody()))) (&constraint->getRigidBodyB() == ctrl->getRigidBody())))
{ {
removeConstraint(constraint->GetUserConstraintId()); removeConstraint(constraint->getUserConstraintId());
//only 1 constraint per constroller //only 1 constraint per constroller
break; break;
} }
@@ -460,10 +460,10 @@ void CcdPhysicsEnvironment::removeCcdPhysicsController(CcdPhysicsController* ctr
!(i==m_constraints.end()); i++) !(i==m_constraints.end()); i++)
{ {
btTypedConstraint* constraint = (*i); btTypedConstraint* constraint = (*i);
if ((&constraint->GetRigidBodyA() == ctrl->GetRigidBody() || if ((&constraint->getRigidBodyA() == ctrl->getRigidBody() ||
(&constraint->GetRigidBodyB() == ctrl->GetRigidBody()))) (&constraint->getRigidBodyB() == ctrl->getRigidBody())))
{ {
removeConstraint(constraint->GetUserConstraintId()); removeConstraint(constraint->getUserConstraintId());
//only 1 constraint per constroller //only 1 constraint per constroller
break; break;
} }
@@ -471,7 +471,7 @@ void CcdPhysicsEnvironment::removeCcdPhysicsController(CcdPhysicsController* ctr
} }
m_collisionWorld->RemoveCollisionObject(ctrl->GetRigidBody()); m_collisionWorld->removeCollisionObject(ctrl->getRigidBody());
{ {
@@ -516,7 +516,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep)
#ifdef USE_QUICKPROF #ifdef USE_QUICKPROF
//toggle btProfiler //toggle btProfiler
if ( m_debugDrawer && m_debugDrawer->GetDebugMode() & btIDebugDraw::DBG_ProfileTimings) if ( m_debugDrawer && m_debugDrawer->getDebugMode() & btIDebugDraw::DBG_ProfileTimings)
{ {
if (!m_profileTimings) if (!m_profileTimings)
{ {
@@ -554,7 +554,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep)
CcdPhysicsController* ctrl = *i; CcdPhysicsController* ctrl = *i;
btTransform predictedTrans; btTransform predictedTrans;
btRigidBody* body = ctrl->GetRigidBody(); btRigidBody* body = ctrl->getRigidBody();
if (body->GetActivationState() != ISLAND_SLEEPING) if (body->GetActivationState() != ISLAND_SLEEPING)
{ {
@@ -607,7 +607,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
if (m_debugDrawer) if (m_debugDrawer)
{ {
gDisableDeactivation = (m_debugDrawer->GetDebugMode() & btIDebugDraw::DBG_NoDeactivation); gDisableDeactivation = (m_debugDrawer->getDebugMode() & btIDebugDraw::DBG_NoDeactivation);
} }
@@ -640,7 +640,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
{ {
CcdPhysicsController* ctrl = m_controllers[k]; CcdPhysicsController* ctrl = m_controllers[k];
// btTransform predictedTrans; // btTransform predictedTrans;
btRigidBody* body = ctrl->GetRigidBody(); btRigidBody* body = ctrl->getRigidBody();
body->m_cachedInvertedWorldTransform = body->m_worldTransform.inverse(); body->m_cachedInvertedWorldTransform = body->m_worldTransform.inverse();
@@ -661,7 +661,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
btProfiler::endBlock("predictIntegratedTransform"); btProfiler::endBlock("predictIntegratedTransform");
#endif //USE_QUICKPROF #endif //USE_QUICKPROF
btOverlappingPairCache* scene = m_collisionWorld->GetPairCache(); btOverlappingPairCache* scene = m_collisionWorld->getPairCache();
// //
@@ -670,7 +670,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
#ifdef USE_QUICKPROF #ifdef USE_QUICKPROF
btProfiler::beginBlock("DispatchAllCollisionPairs"); btProfiler::beginBlock("dispatchAllCollisionPairs");
#endif //USE_QUICKPROF #endif //USE_QUICKPROF
@@ -683,16 +683,16 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
dispatchInfo.m_enableSatConvex = m_enableSatCollisionDetection; dispatchInfo.m_enableSatConvex = m_enableSatCollisionDetection;
dispatchInfo.m_debugDraw = this->m_debugDrawer; dispatchInfo.m_debugDraw = this->m_debugDrawer;
scene->RefreshOverlappingPairs(); scene->refreshOverlappingPairs();
GetCollisionWorld()->GetDispatcher()->DispatchAllCollisionPairs(scene,dispatchInfo); getCollisionWorld()->getDispatcher()->dispatchAllCollisionPairs(scene,dispatchInfo);
#ifdef USE_QUICKPROF #ifdef USE_QUICKPROF
btProfiler::endBlock("DispatchAllCollisionPairs"); btProfiler::endBlock("dispatchAllCollisionPairs");
#endif //USE_QUICKPROF #endif //USE_QUICKPROF
m_islandManager->UpdateActivationState(GetCollisionWorld(),GetCollisionWorld()->GetDispatcher()); m_islandManager->updateActivationState(getCollisionWorld(),getCollisionWorld()->getDispatcher());
{ {
int i; int i;
@@ -701,8 +701,8 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
{ {
btTypedConstraint* constraint = m_constraints[i]; btTypedConstraint* constraint = m_constraints[i];
const btRigidBody* colObj0 = &constraint->GetRigidBodyA(); const btRigidBody* colObj0 = &constraint->getRigidBodyA();
const btRigidBody* colObj1 = &constraint->GetRigidBodyB(); const btRigidBody* colObj1 = &constraint->getRigidBodyB();
if (((colObj0) && ((colObj0)->mergesSimulationIslands())) && if (((colObj0) && ((colObj0)->mergesSimulationIslands())) &&
((colObj1) && ((colObj1)->mergesSimulationIslands()))) ((colObj1) && ((colObj1)->mergesSimulationIslands())))
@@ -710,19 +710,19 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
if (colObj0->IsActive() || colObj1->IsActive()) if (colObj0->IsActive() || colObj1->IsActive())
{ {
m_islandManager->GetUnionFind().unite((colObj0)->m_islandTag1, m_islandManager->getUnionFind().unite((colObj0)->m_islandTag1,
(colObj1)->m_islandTag1); (colObj1)->m_islandTag1);
} }
} }
} }
} }
m_islandManager->StoreIslandActivationState(GetCollisionWorld()); m_islandManager->storeIslandActivationState(getCollisionWorld());
//contacts //contacts
#ifdef USE_QUICKPROF #ifdef USE_QUICKPROF
btProfiler::beginBlock("SolveConstraint"); btProfiler::beginBlock("solveConstraint");
#endif //USE_QUICKPROF #endif //USE_QUICKPROF
@@ -743,8 +743,8 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
{ {
btTypedConstraint* constraint = m_constraints[i]; btTypedConstraint* constraint = m_constraints[i];
constraint->BuildJacobian(); constraint->buildJacobian();
constraint->SolveConstraint( timeStep ); constraint->solveConstraint( timeStep );
} }
@@ -752,7 +752,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
} }
#ifdef USE_QUICKPROF #ifdef USE_QUICKPROF
btProfiler::endBlock("SolveConstraint"); btProfiler::endBlock("solveConstraint");
#endif //USE_QUICKPROF #endif //USE_QUICKPROF
//solve the vehicles //solve the vehicles
@@ -764,7 +764,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
{ {
WrapperVehicle* wrapperVehicle = m_wrapperVehicles[i]; WrapperVehicle* wrapperVehicle = m_wrapperVehicles[i];
btRaycastVehicle* vehicle = wrapperVehicle->GetVehicle(); btRaycastVehicle* vehicle = wrapperVehicle->GetVehicle();
vehicle->UpdateVehicle( timeStep); vehicle->updateVehicle( timeStep);
} }
#endif //NEW_BULLET_VEHICLE_SUPPORT #endif //NEW_BULLET_VEHICLE_SUPPORT
@@ -789,7 +789,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
virtual void ProcessIsland(btPersistentManifold** manifolds,int numManifolds) virtual void ProcessIsland(btPersistentManifold** manifolds,int numManifolds)
{ {
m_solver->SolveGroup( manifolds, numManifolds,m_solverInfo,m_debugDrawer); m_solver->solveGroup( manifolds, numManifolds,m_solverInfo,m_debugDrawer);
} }
}; };
@@ -806,14 +806,14 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
m_debugDrawer); m_debugDrawer);
#ifdef USE_QUICKPROF #ifdef USE_QUICKPROF
btProfiler::beginBlock("BuildAndProcessIslands"); btProfiler::beginBlock("buildAndProcessIslands");
#endif //USE_QUICKPROF #endif //USE_QUICKPROF
/// solve all the contact points and contact friction /// solve all the contact points and contact friction
m_islandManager->BuildAndProcessIslands(GetCollisionWorld()->GetDispatcher(),m_collisionWorld->GetCollisionObjectArray(),&solverCallback); m_islandManager->buildAndProcessIslands(getCollisionWorld()->getDispatcher(),m_collisionWorld->getCollisionObjectArray(),&solverCallback);
#ifdef USE_QUICKPROF #ifdef USE_QUICKPROF
btProfiler::endBlock("BuildAndProcessIslands"); btProfiler::endBlock("buildAndProcessIslands");
btProfiler::beginBlock("CallbackTriggers"); btProfiler::beginBlock("CallbackTriggers");
#endif //USE_QUICKPROF #endif //USE_QUICKPROF
@@ -849,8 +849,8 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
dispatchInfo.m_stepCount = 0; dispatchInfo.m_stepCount = 0;
dispatchInfo.m_dispatchFunc = btDispatcherInfo::DISPATCH_CONTINUOUS; dispatchInfo.m_dispatchFunc = btDispatcherInfo::DISPATCH_CONTINUOUS;
//pairCache->RefreshOverlappingPairs();//?? //pairCache->refreshOverlappingPairs();//??
GetCollisionWorld()->GetDispatcher()->DispatchAllCollisionPairs(scene,dispatchInfo); getCollisionWorld()->getDispatcher()->dispatchAllCollisionPairs(scene,dispatchInfo);
toi = dispatchInfo.m_timeOfImpact; toi = dispatchInfo.m_timeOfImpact;
@@ -873,7 +873,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
CcdPhysicsController* ctrl = *i; CcdPhysicsController* ctrl = *i;
btTransform predictedTrans; btTransform predictedTrans;
btRigidBody* body = ctrl->GetRigidBody(); btRigidBody* body = ctrl->getRigidBody();
if (body->IsActive()) if (body->IsActive())
{ {
@@ -910,7 +910,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
!(i==m_controllers.end()); i++) !(i==m_controllers.end()); i++)
{ {
CcdPhysicsController* ctrl = (*i); CcdPhysicsController* ctrl = (*i);
btRigidBody* body = ctrl->GetRigidBody(); btRigidBody* body = ctrl->getRigidBody();
ctrl->UpdateDeactivation(timeStep); ctrl->UpdateDeactivation(timeStep);
@@ -979,7 +979,7 @@ bool CcdPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
void CcdPhysicsEnvironment::setDebugMode(int debugMode) void CcdPhysicsEnvironment::setDebugMode(int debugMode)
{ {
if (m_debugDrawer){ if (m_debugDrawer){
m_debugDrawer->SetDebugMode(debugMode); m_debugDrawer->setDebugMode(debugMode);
} }
} }
@@ -1100,7 +1100,7 @@ void CcdPhysicsEnvironment::setGravity(float x,float y,float z)
{ {
CcdPhysicsController* ctrl = (*i); CcdPhysicsController* ctrl = (*i);
ctrl->GetRigidBody()->setGravity(m_gravity); ctrl->getRigidBody()->setGravity(m_gravity);
} }
} }
@@ -1131,7 +1131,7 @@ public:
btScalar m_distFraction; btScalar m_distFraction;
}; };
*/ */
virtual void* CastRay(const btVector3& from,const btVector3& to, btVehicleRaycasterResult& result) virtual void* castRay(const btVector3& from,const btVector3& to, btVehicleRaycasterResult& result)
{ {
@@ -1156,7 +1156,7 @@ public:
//some safety for 'explosion' due to sudden penetration of the full 'ray' //some safety for 'explosion' due to sudden penetration of the full 'ray'
/* if (result.m_distFraction<0.1) /* if (result.m_distFraction<0.1)
{ {
printf("Vehicle Raycast: avoided instability due to penetration. Consider moving the connection points deeper inside vehicle chassis"); printf("Vehicle rayCast: avoided instability due to penetration. Consider moving the connection points deeper inside vehicle chassis");
result.m_distFraction = 1.f; result.m_distFraction = 1.f;
hitObject = 0; hitObject = 0;
} }
@@ -1164,7 +1164,7 @@ public:
/* if (result.m_distFraction>1.) /* if (result.m_distFraction>1.)
{ {
printf("Vehicle Raycast: avoided instability 1Consider moving the connection points deeper inside vehicle chassis"); printf("Vehicle rayCast: avoided instability 1Consider moving the connection points deeper inside vehicle chassis");
result.m_distFraction = 1.f; result.m_distFraction = 1.f;
hitObject = 0; hitObject = 0;
} }
@@ -1190,8 +1190,8 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl
CcdPhysicsController* c0 = (CcdPhysicsController*)ctrl0; CcdPhysicsController* c0 = (CcdPhysicsController*)ctrl0;
CcdPhysicsController* c1 = (CcdPhysicsController*)ctrl1; CcdPhysicsController* c1 = (CcdPhysicsController*)ctrl1;
btRigidBody* rb0 = c0 ? c0->GetRigidBody() : 0; btRigidBody* rb0 = c0 ? c0->getRigidBody() : 0;
btRigidBody* rb1 = c1 ? c1->GetRigidBody() : 0; btRigidBody* rb1 = c1 ? c1->getRigidBody() : 0;
ASSERT(rb0); ASSERT(rb0);
@@ -1222,10 +1222,10 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl
} }
m_constraints.push_back(p2p); m_constraints.push_back(p2p);
p2p->SetUserConstraintId(gConstraintUid++); p2p->setUserConstraintId(gConstraintUid++);
p2p->SetUserConstraintType(type); p2p->setUserConstraintType(type);
//64 bit systems can't cast pointer to int. could use size_t instead. //64 bit systems can't cast pointer to int. could use size_t instead.
return p2p->GetUserConstraintId(); return p2p->getUserConstraintId();
break; break;
} }
@@ -1268,10 +1268,10 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl
m_constraints.push_back(genericConstraint); m_constraints.push_back(genericConstraint);
genericConstraint->SetUserConstraintId(gConstraintUid++); genericConstraint->setUserConstraintId(gConstraintUid++);
genericConstraint->SetUserConstraintType(type); genericConstraint->setUserConstraintType(type);
//64 bit systems can't cast pointer to int. could use size_t instead. //64 bit systems can't cast pointer to int. could use size_t instead.
return genericConstraint->GetUserConstraintId(); return genericConstraint->getUserConstraintId();
break; break;
} }
@@ -1299,10 +1299,10 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl
hinge->setAngularOnly(angularOnly); hinge->setAngularOnly(angularOnly);
m_constraints.push_back(hinge); m_constraints.push_back(hinge);
hinge->SetUserConstraintId(gConstraintUid++); hinge->setUserConstraintId(gConstraintUid++);
hinge->SetUserConstraintType(type); hinge->setUserConstraintType(type);
//64 bit systems can't cast pointer to int. could use size_t instead. //64 bit systems can't cast pointer to int. could use size_t instead.
return hinge->GetUserConstraintId(); return hinge->getUserConstraintId();
break; break;
} }
#ifdef NEW_BULLET_VEHICLE_SUPPORT #ifdef NEW_BULLET_VEHICLE_SUPPORT
@@ -1315,9 +1315,9 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl
btRaycastVehicle* vehicle = new btRaycastVehicle(*tuning,chassis,raycaster); btRaycastVehicle* vehicle = new btRaycastVehicle(*tuning,chassis,raycaster);
WrapperVehicle* wrapperVehicle = new WrapperVehicle(vehicle,ctrl0); WrapperVehicle* wrapperVehicle = new WrapperVehicle(vehicle,ctrl0);
m_wrapperVehicles.push_back(wrapperVehicle); m_wrapperVehicles.push_back(wrapperVehicle);
vehicle->SetUserConstraintId(gConstraintUid++); vehicle->setUserConstraintId(gConstraintUid++);
vehicle->SetUserConstraintType(type); vehicle->setUserConstraintType(type);
return vehicle->GetUserConstraintId(); return vehicle->getUserConstraintId();
break; break;
}; };
@@ -1356,8 +1356,8 @@ int CcdPhysicsEnvironment::createUniversalD6Constraint(
CcdPhysicsController* ctrl0 = (CcdPhysicsController*) ctrlRef; CcdPhysicsController* ctrl0 = (CcdPhysicsController*) ctrlRef;
CcdPhysicsController* ctrl1 = (CcdPhysicsController*) ctrlOther; CcdPhysicsController* ctrl1 = (CcdPhysicsController*) ctrlOther;
btRigidBody* rb0 = ctrl0->GetRigidBody(); btRigidBody* rb0 = ctrl0->getRigidBody();
btRigidBody* rb1 = ctrl1->GetRigidBody(); btRigidBody* rb1 = ctrl1->getRigidBody();
if (rb1) if (rb1)
{ {
@@ -1380,10 +1380,10 @@ int CcdPhysicsEnvironment::createUniversalD6Constraint(
if (genericConstraint) if (genericConstraint)
{ {
m_constraints.push_back(genericConstraint); m_constraints.push_back(genericConstraint);
genericConstraint->SetUserConstraintId(gConstraintUid++); genericConstraint->setUserConstraintId(gConstraintUid++);
genericConstraint->SetUserConstraintType(PHY_GENERIC_6DOF_CONSTRAINT); genericConstraint->setUserConstraintType(PHY_GENERIC_6DOF_CONSTRAINT);
//64 bit systems can't cast pointer to int. could use size_t instead. //64 bit systems can't cast pointer to int. could use size_t instead.
return genericConstraint->GetUserConstraintId(); return genericConstraint->getUserConstraintId();
} }
return 0; return 0;
} }
@@ -1398,7 +1398,7 @@ void CcdPhysicsEnvironment::removeConstraint(int constraintId)
!(i==m_constraints.end()); i++) !(i==m_constraints.end()); i++)
{ {
btTypedConstraint* constraint = (*i); btTypedConstraint* constraint = (*i);
if (constraint->GetUserConstraintId() == constraintId) if (constraint->getUserConstraintId() == constraintId)
{ {
std::swap(*i, m_constraints.back()); std::swap(*i, m_constraints.back());
m_constraints.pop_back(); m_constraints.pop_back();
@@ -1454,7 +1454,7 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IPhysicsController* i
PHY_IPhysicsController* nearestHit = 0; PHY_IPhysicsController* nearestHit = 0;
m_collisionWorld->RayTest(rayFrom,rayTo,rayCallback); m_collisionWorld->rayTest(rayFrom,rayTo,rayCallback);
if (rayCallback.HasHit()) if (rayCallback.HasHit())
{ {
nearestHit = static_cast<CcdPhysicsController*>(rayCallback.m_collisionObject->m_internalOwner); nearestHit = static_cast<CcdPhysicsController*>(rayCallback.m_collisionObject->m_internalOwner);
@@ -1487,9 +1487,9 @@ void CcdPhysicsEnvironment::getContactPoint(int i,float& hitX,float& hitY,float&
btBroadphaseInterface* CcdPhysicsEnvironment::GetBroadphase() btBroadphaseInterface* CcdPhysicsEnvironment::getBroadphase()
{ {
return m_collisionWorld->GetBroadphase(); return m_collisionWorld->getBroadphase();
} }
@@ -1537,7 +1537,7 @@ btTypedConstraint* CcdPhysicsEnvironment::getConstraintById(int constraintId)
for (i=0;i<numConstraint;i++) for (i=0;i<numConstraint;i++)
{ {
btTypedConstraint* constraint = m_constraints[i]; btTypedConstraint* constraint = m_constraints[i];
if (constraint->GetUserConstraintId()==constraintId) if (constraint->getUserConstraintId()==constraintId)
{ {
return constraint; return constraint;
} }
@@ -1621,28 +1621,28 @@ void CcdPhysicsEnvironment::requestCollisionCallback(PHY_IPhysicsController* ctr
void CcdPhysicsEnvironment::CallbackTriggers() void CcdPhysicsEnvironment::CallbackTriggers()
{ {
if (m_triggerCallbacks[PHY_OBJECT_RESPONSE] || (m_debugDrawer && (m_debugDrawer->GetDebugMode() & btIDebugDraw::DBG_DrawContactPoints))) if (m_triggerCallbacks[PHY_OBJECT_RESPONSE] || (m_debugDrawer && (m_debugDrawer->getDebugMode() & btIDebugDraw::DBG_DrawContactPoints)))
{ {
//walk over all overlapping pairs, and if one of the involved bodies is registered for trigger callback, perform callback //walk over all overlapping pairs, and if one of the involved bodies is registered for trigger callback, perform callback
int numManifolds = m_collisionWorld->GetDispatcher()->GetNumManifolds(); int numManifolds = m_collisionWorld->getDispatcher()->getNumManifolds();
for (int i=0;i<numManifolds;i++) for (int i=0;i<numManifolds;i++)
{ {
btPersistentManifold* manifold = m_collisionWorld->GetDispatcher()->GetManifoldByIndexInternal(i); btPersistentManifold* manifold = m_collisionWorld->getDispatcher()->getManifoldByIndexInternal(i);
int numContacts = manifold->GetNumContacts(); int numContacts = manifold->getNumContacts();
if (numContacts) if (numContacts)
{ {
if (m_debugDrawer && (m_debugDrawer->GetDebugMode() & btIDebugDraw::DBG_DrawContactPoints)) if (m_debugDrawer && (m_debugDrawer->getDebugMode() & btIDebugDraw::DBG_DrawContactPoints))
{ {
for (int j=0;j<numContacts;j++) for (int j=0;j<numContacts;j++)
{ {
btVector3 color(1,0,0); btVector3 color(1,0,0);
const btManifoldPoint& cp = manifold->GetContactPoint(j); const btManifoldPoint& cp = manifold->getContactPoint(j);
if (m_debugDrawer) if (m_debugDrawer)
m_debugDrawer->DrawContactPoint(cp.m_positionWorldOnB,cp.m_normalWorldOnB,cp.GetDistance(),cp.GetLifeTime(),color); m_debugDrawer->drawContactPoint(cp.m_positionWorldOnB,cp.m_normalWorldOnB,cp.getDistance(),cp.getLifeTime(),color);
} }
} }
btRigidBody* obj0 = static_cast<btRigidBody* >(manifold->GetBody0()); btRigidBody* obj0 = static_cast<btRigidBody* >(manifold->getBody0());
btRigidBody* obj1 = static_cast<btRigidBody* >(manifold->GetBody1()); btRigidBody* obj1 = static_cast<btRigidBody* >(manifold->getBody1());
//m_internalOwner is set in 'addPhysicsController' //m_internalOwner is set in 'addPhysicsController'
CcdPhysicsController* ctrl0 = static_cast<CcdPhysicsController*>(obj0->m_internalOwner); CcdPhysicsController* ctrl0 = static_cast<CcdPhysicsController*>(obj0->m_internalOwner);
@@ -1686,7 +1686,7 @@ PHY_IVehicle* CcdPhysicsEnvironment::getVehicleConstraint(int constraintId)
for (i=0;i<numVehicles;i++) for (i=0;i<numVehicles;i++)
{ {
WrapperVehicle* wrapperVehicle = m_wrapperVehicles[i]; WrapperVehicle* wrapperVehicle = m_wrapperVehicles[i];
if (wrapperVehicle->GetVehicle()->GetUserConstraintId() == constraintId) if (wrapperVehicle->GetVehicle()->getUserConstraintId() == constraintId)
return wrapperVehicle; return wrapperVehicle;
} }
@@ -1703,7 +1703,7 @@ int numController = 0;
void CcdPhysicsEnvironment::UpdateAabbs(float timeStep) void CcdPhysicsEnvironment::UpdateAabbs(float timeStep)
{ {
std::vector<CcdPhysicsController*>::iterator i; std::vector<CcdPhysicsController*>::iterator i;
btBroadphaseInterface* scene = GetBroadphase(); btBroadphaseInterface* scene = getBroadphase();
numController = m_controllers.size(); numController = m_controllers.size();
currentController = 0; currentController = 0;
@@ -1716,15 +1716,15 @@ void CcdPhysicsEnvironment::UpdateAabbs(float timeStep)
{ {
currentController++; currentController++;
CcdPhysicsController* ctrl = (*i); CcdPhysicsController* ctrl = (*i);
btRigidBody* body = ctrl->GetRigidBody(); btRigidBody* body = ctrl->getRigidBody();
btPoint3 minAabb,maxAabb; btPoint3 minAabb,maxAabb;
btCollisionShape* shapeinterface = ctrl->GetCollisionShape(); btCollisionShape* shapeinterface = ctrl->getCollisionShape();
shapeinterface->CalculateTemporalAabb(body->getCenterOfMassTransform(), shapeinterface->calculateTemporalAabb(body->getCenterOfMassTransform(),
body->getLinearVelocity(), body->getLinearVelocity(),
//body->getAngularVelocity(), //body->getAngularVelocity(),
btVector3(0.f,0.f,0.f),//no angular effect for now //body->getAngularVelocity(), btVector3(0.f,0.f,0.f),//no angular effect for now //body->getAngularVelocity(),
@@ -1767,7 +1767,7 @@ void CcdPhysicsEnvironment::UpdateAabbs(float timeStep)
}; };
if (m_debugDrawer->GetDebugMode() & btIDebugDraw::DBG_DrawAabb) if (m_debugDrawer->getDebugMode() & btIDebugDraw::DBG_DrawAabb)
{ {
DrawAabb(m_debugDrawer,minAabb,maxAabb,color); DrawAabb(m_debugDrawer,minAabb,maxAabb,color);
} }
@@ -1776,7 +1776,7 @@ void CcdPhysicsEnvironment::UpdateAabbs(float timeStep)
if ( (maxAabb-minAabb).length2() < 1e12f) if ( (maxAabb-minAabb).length2() < 1e12f)
{ {
scene->SetAabb(bp,minAabb,maxAabb); scene->setAabb(bp,minAabb,maxAabb);
} else } else
{ {
//something went wrong, investigate //something went wrong, investigate
@@ -1844,9 +1844,9 @@ float CcdPhysicsEnvironment::getAppliedImpulse(int constraintid)
!(i==m_constraints.end()); i++) !(i==m_constraints.end()); i++)
{ {
btTypedConstraint* constraint = (*i); btTypedConstraint* constraint = (*i);
if (constraint->GetUserConstraintId() == constraintid) if (constraint->getUserConstraintId() == constraintid)
{ {
return constraint->GetAppliedImpulse(); return constraint->getAppliedImpulse();
} }
} }
return 0.f; return 0.f;

View File

@@ -183,7 +183,7 @@ protected:
void removeCcdPhysicsController(CcdPhysicsController* ctrl); void removeCcdPhysicsController(CcdPhysicsController* ctrl);
btBroadphaseInterface* GetBroadphase(); btBroadphaseInterface* getBroadphase();
@@ -207,29 +207,29 @@ protected:
const btPersistentManifold* GetManifold(int index) const; const btPersistentManifold* getManifold(int index) const;
std::vector<btTypedConstraint*> m_constraints; std::vector<btTypedConstraint*> m_constraints;
void SyncMotionStates(float timeStep); void SyncMotionStates(float timeStep);
class btCollisionWorld* GetCollisionWorld() class btCollisionWorld* getCollisionWorld()
{ {
return m_collisionWorld; return m_collisionWorld;
} }
const class btCollisionWorld* GetCollisionWorld() const const class btCollisionWorld* getCollisionWorld() const
{ {
return m_collisionWorld; return m_collisionWorld;
} }
btSimulationIslandManager* GetSimulationIslandManager() btSimulationIslandManager* getSimulationIslandManager()
{ {
return m_islandManager; return m_islandManager;
} }
const btSimulationIslandManager* GetSimulationIslandManager() const const btSimulationIslandManager* getSimulationIslandManager() const
{ {
return m_islandManager; return m_islandManager;
} }

View File

@@ -51,7 +51,7 @@ ParallelIslandDispatcher::ParallelIslandDispatcher ():
}; };
btPersistentManifold* ParallelIslandDispatcher::GetNewManifold(void* b0,void* b1) btPersistentManifold* ParallelIslandDispatcher::getNewManifold(void* b0,void* b1)
{ {
gNumManifold2++; gNumManifold2++;
@@ -67,20 +67,20 @@ btPersistentManifold* ParallelIslandDispatcher::GetNewManifold(void* b0,void* b1
return manifold; return manifold;
} }
void ParallelIslandDispatcher::ClearManifold(btPersistentManifold* manifold) void ParallelIslandDispatcher::clearManifold(btPersistentManifold* manifold)
{ {
manifold->ClearManifold(); manifold->clearManifold();
} }
void ParallelIslandDispatcher::ReleaseManifold(btPersistentManifold* manifold) void ParallelIslandDispatcher::releaseManifold(btPersistentManifold* manifold)
{ {
gNumManifold2--; gNumManifold2--;
//printf("ReleaseManifold: gNumManifold2 %d\n",gNumManifold2); //printf("releaseManifold: gNumManifold2 %d\n",gNumManifold2);
ClearManifold(manifold); clearManifold(manifold);
std::vector<btPersistentManifold*>::iterator i = std::vector<btPersistentManifold*>::iterator i =
std::find(m_manifoldsPtr.begin(), m_manifoldsPtr.end(), manifold); std::find(m_manifoldsPtr.begin(), m_manifoldsPtr.end(), manifold);
@@ -99,7 +99,7 @@ void ParallelIslandDispatcher::ReleaseManifold(btPersistentManifold* manifold)
// //
// todo: this is random access, it can be walked 'cache friendly'! // todo: this is random access, it can be walked 'cache friendly'!
// //
void ParallelIslandDispatcher::BuildAndProcessIslands(btCollisionObjectArray& collisionObjects, IslandCallback* callback) void ParallelIslandDispatcher::buildAndProcessIslands(btCollisionObjectArray& collisionObjects, IslandCallback* callback)
{ {
int numBodies = collisionObjects.size(); int numBodies = collisionObjects.size();
@@ -130,20 +130,20 @@ void ParallelIslandDispatcher::BuildAndProcessIslands(btCollisionObjectArray& co
} }
for (i=0;i<GetNumManifolds();i++) for (i=0;i<getNumManifolds();i++)
{ {
btPersistentManifold* manifold = this->GetManifoldByIndexInternal(i); btPersistentManifold* manifold = this->getManifoldByIndexInternal(i);
//filtering for response //filtering for response
btCollisionObject* colObj0 = static_cast<btCollisionObject*>(manifold->GetBody0()); btCollisionObject* colObj0 = static_cast<btCollisionObject*>(manifold->getBody0());
btCollisionObject* colObj1 = static_cast<btCollisionObject*>(manifold->GetBody1()); btCollisionObject* colObj1 = static_cast<btCollisionObject*>(manifold->getBody1());
{ {
if (((colObj0) && (colObj0)->m_islandTag1 == (islandId)) || if (((colObj0) && (colObj0)->m_islandTag1 == (islandId)) ||
((colObj1) && (colObj1)->m_islandTag1 == (islandId))) ((colObj1) && (colObj1)->m_islandTag1 == (islandId)))
{ {
if (NeedsResponse(*colObj0,*colObj1)) if (needsResponse(*colObj0,*colObj1))
islandmanifold.push_back(manifold); islandmanifold.push_back(manifold);
} }
} }
@@ -189,7 +189,7 @@ void ParallelIslandDispatcher::BuildAndProcessIslands(btCollisionObjectArray& co
btCollisionAlgorithm* ParallelIslandDispatcher::InternalFindAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1) btCollisionAlgorithm* ParallelIslandDispatcher::internalFindAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1)
{ {
m_count++; m_count++;
btCollisionObject* body0 = (btCollisionObject*)proxy0.m_clientObject; btCollisionObject* body0 = (btCollisionObject*)proxy0.m_clientObject;
@@ -198,27 +198,27 @@ btCollisionAlgorithm* ParallelIslandDispatcher::InternalFindAlgorithm(btBroadpha
btCollisionAlgorithmConstructionInfo ci; btCollisionAlgorithmConstructionInfo ci;
ci.m_dispatcher = this; ci.m_dispatcher = this;
if (body0->m_collisionShape->IsConvex() && body1->m_collisionShape->IsConvex() ) if (body0->m_collisionShape->isConvex() && body1->m_collisionShape->isConvex() )
{ {
return new btConvexConvexAlgorithm(0,ci,&proxy0,&proxy1); return new btConvexConvexAlgorithm(0,ci,&proxy0,&proxy1);
} }
if (body0->m_collisionShape->IsConvex() && body1->m_collisionShape->IsConcave()) if (body0->m_collisionShape->isConvex() && body1->m_collisionShape->isConcave())
{ {
return new btConvexConcaveCollisionAlgorithm(ci,&proxy0,&proxy1); return new btConvexConcaveCollisionAlgorithm(ci,&proxy0,&proxy1);
} }
if (body1->m_collisionShape->IsConvex() && body0->m_collisionShape->IsConcave()) if (body1->m_collisionShape->isConvex() && body0->m_collisionShape->isConcave())
{ {
return new btConvexConcaveCollisionAlgorithm(ci,&proxy1,&proxy0); return new btConvexConcaveCollisionAlgorithm(ci,&proxy1,&proxy0);
} }
if (body0->m_collisionShape->IsCompound()) if (body0->m_collisionShape->isCompound())
{ {
return new btCompoundCollisionAlgorithm(ci,&proxy0,&proxy1); return new btCompoundCollisionAlgorithm(ci,&proxy0,&proxy1);
} else } else
{ {
if (body1->m_collisionShape->IsCompound()) if (body1->m_collisionShape->isCompound())
{ {
return new btCompoundCollisionAlgorithm(ci,&proxy1,&proxy0); return new btCompoundCollisionAlgorithm(ci,&proxy1,&proxy0);
} }
@@ -230,7 +230,7 @@ btCollisionAlgorithm* ParallelIslandDispatcher::InternalFindAlgorithm(btBroadpha
} }
bool ParallelIslandDispatcher::NeedsResponse(const btCollisionObject& colObj0,const btCollisionObject& colObj1) bool ParallelIslandDispatcher::needsResponse(const btCollisionObject& colObj0,const btCollisionObject& colObj1)
{ {
@@ -243,7 +243,7 @@ bool ParallelIslandDispatcher::NeedsResponse(const btCollisionObject& colObj0,c
return hasResponse; return hasResponse;
} }
bool ParallelIslandDispatcher::NeedsCollision(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1) bool ParallelIslandDispatcher::needsCollision(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1)
{ {
btCollisionObject* body0 = (btCollisionObject*)proxy0.m_clientObject; btCollisionObject* body0 = (btCollisionObject*)proxy0.m_clientObject;
@@ -266,7 +266,7 @@ bool ParallelIslandDispatcher::NeedsCollision(btBroadphaseProxy& proxy0,btBroadp
} }
///allows the user to get contact point callbacks ///allows the user to get contact point callbacks
btManifoldResult* ParallelIslandDispatcher::GetNewManifoldResult(btCollisionObject* obj0,btCollisionObject* obj1,btPersistentManifold* manifold) btManifoldResult* ParallelIslandDispatcher::getNewManifoldResult(btCollisionObject* obj0,btCollisionObject* obj1,btPersistentManifold* manifold)
{ {
@@ -276,13 +276,13 @@ btManifoldResult* ParallelIslandDispatcher::GetNewManifoldResult(btCollisionObje
} }
///allows the user to get contact point callbacks ///allows the user to get contact point callbacks
void ParallelIslandDispatcher::ReleaseManifoldResult(btManifoldResult*) void ParallelIslandDispatcher::releaseManifoldResult(btManifoldResult*)
{ {
} }
void ParallelIslandDispatcher::DispatchAllCollisionPairs(btOverlappingPairCache* pairCache,btDispatcherInfo& dispatchInfo) void ParallelIslandDispatcher::dispatchAllCollisionPairs(btOverlappingPairCache* pairCache,btDispatcherInfo& dispatchInfo)
{ {
//m_blockedForChanges = true; //m_blockedForChanges = true;
@@ -291,7 +291,7 @@ void ParallelIslandDispatcher::DispatchAllCollisionPairs(btOverlappingPairCache*
assert(0); assert(0);
/* /*
int dispatcherId = GetUniqueId(); int dispatcherId = getUniqueId();
int i; int i;
for (i=0;i<numPairs;i++) for (i=0;i<numPairs;i++)
{ {
@@ -303,7 +303,7 @@ void ParallelIslandDispatcher::DispatchAllCollisionPairs(btOverlappingPairCache*
//dispatcher will keep algorithms persistent in the collision pair //dispatcher will keep algorithms persistent in the collision pair
if (!pair.m_algorithms[dispatcherId]) if (!pair.m_algorithms[dispatcherId])
{ {
pair.m_algorithms[dispatcherId] = FindAlgorithm( pair.m_algorithms[dispatcherId] = findAlgorithm(
*pair.m_pProxy0, *pair.m_pProxy0,
*pair.m_pProxy1); *pair.m_pProxy1);
} }
@@ -312,10 +312,10 @@ void ParallelIslandDispatcher::DispatchAllCollisionPairs(btOverlappingPairCache*
{ {
if (dispatchInfo.m_dispatchFunc == btDispatcherInfo::DISPATCH_DISCRETE) if (dispatchInfo.m_dispatchFunc == btDispatcherInfo::DISPATCH_DISCRETE)
{ {
pair.m_algorithms[dispatcherId]->ProcessCollision(pair.m_pProxy0,pair.m_pProxy1,dispatchInfo); pair.m_algorithms[dispatcherId]->processCollision(pair.m_pProxy0,pair.m_pProxy1,dispatchInfo);
} else } else
{ {
float toi = pair.m_algorithms[dispatcherId]->CalculateTimeOfImpact(pair.m_pProxy0,pair.m_pProxy1,dispatchInfo); float toi = pair.m_algorithms[dispatcherId]->calculateTimeOfImpact(pair.m_pProxy0,pair.m_pProxy1,dispatchInfo);
if (dispatchInfo.m_timeOfImpact > toi) if (dispatchInfo.m_timeOfImpact > toi)
dispatchInfo.m_timeOfImpact = toi; dispatchInfo.m_timeOfImpact = toi;
@@ -324,7 +324,7 @@ void ParallelIslandDispatcher::DispatchAllCollisionPairs(btOverlappingPairCache*
} else } else
{ {
//non-persistent algorithm dispatcher //non-persistent algorithm dispatcher
btCollisionAlgorithm* algo = FindAlgorithm( btCollisionAlgorithm* algo = findAlgorithm(
*pair.m_pProxy0, *pair.m_pProxy0,
*pair.m_pProxy1); *pair.m_pProxy1);
@@ -332,10 +332,10 @@ void ParallelIslandDispatcher::DispatchAllCollisionPairs(btOverlappingPairCache*
{ {
if (dispatchInfo.m_dispatchFunc == btDispatcherInfo::DISPATCH_DISCRETE) if (dispatchInfo.m_dispatchFunc == btDispatcherInfo::DISPATCH_DISCRETE)
{ {
algo->ProcessCollision(pair.m_pProxy0,pair.m_pProxy1,dispatchInfo); algo->processCollision(pair.m_pProxy0,pair.m_pProxy1,dispatchInfo);
} else } else
{ {
float toi = algo->CalculateTimeOfImpact(pair.m_pProxy0,pair.m_pProxy1,dispatchInfo); float toi = algo->calculateTimeOfImpact(pair.m_pProxy0,pair.m_pProxy1,dispatchInfo);
if (dispatchInfo.m_timeOfImpact > toi) if (dispatchInfo.m_timeOfImpact > toi)
dispatchInfo.m_timeOfImpact = toi; dispatchInfo.m_timeOfImpact = toi;
} }

View File

@@ -50,7 +50,7 @@ class ParallelIslandDispatcher : public btDispatcher
public: public:
btUnionFind& GetUnionFind() { return m_unionFind;} btUnionFind& getUnionFind() { return m_unionFind;}
struct IslandCallback struct IslandCallback
{ {
@@ -60,65 +60,65 @@ public:
}; };
int GetNumManifolds() const int getNumManifolds() const
{ {
return m_manifoldsPtr.size(); return m_manifoldsPtr.size();
} }
btPersistentManifold* GetManifoldByIndexInternal(int index) btPersistentManifold* getManifoldByIndexInternal(int index)
{ {
return m_manifoldsPtr[index]; return m_manifoldsPtr[index];
} }
const btPersistentManifold* GetManifoldByIndexInternal(int index) const const btPersistentManifold* getManifoldByIndexInternal(int index) const
{ {
return m_manifoldsPtr[index]; return m_manifoldsPtr[index];
} }
void InitUnionFind(int n) void initUnionFind(int n)
{ {
if (m_useIslands) if (m_useIslands)
m_unionFind.reset(n); m_unionFind.reset(n);
} }
void FindUnions(); void findUnions();
int m_count; int m_count;
ParallelIslandDispatcher (); ParallelIslandDispatcher ();
virtual ~ParallelIslandDispatcher() {}; virtual ~ParallelIslandDispatcher() {};
virtual btPersistentManifold* GetNewManifold(void* b0,void* b1); virtual btPersistentManifold* getNewManifold(void* b0,void* b1);
virtual void ReleaseManifold(btPersistentManifold* manifold); virtual void releaseManifold(btPersistentManifold* manifold);
virtual void BuildAndProcessIslands(btCollisionObjectArray& collisionObjects, IslandCallback* callback); virtual void buildAndProcessIslands(btCollisionObjectArray& collisionObjects, IslandCallback* callback);
///allows the user to get contact point callbacks ///allows the user to get contact point callbacks
virtual btManifoldResult* GetNewManifoldResult(btCollisionObject* obj0,btCollisionObject* obj1,btPersistentManifold* manifold); virtual btManifoldResult* getNewManifoldResult(btCollisionObject* obj0,btCollisionObject* obj1,btPersistentManifold* manifold);
///allows the user to get contact point callbacks ///allows the user to get contact point callbacks
virtual void ReleaseManifoldResult(btManifoldResult*); virtual void releaseManifoldResult(btManifoldResult*);
virtual void ClearManifold(btPersistentManifold* manifold); virtual void clearManifold(btPersistentManifold* manifold);
btCollisionAlgorithm* FindAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1) btCollisionAlgorithm* findAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1)
{ {
btCollisionAlgorithm* algo = InternalFindAlgorithm(proxy0,proxy1); btCollisionAlgorithm* algo = internalFindAlgorithm(proxy0,proxy1);
return algo; return algo;
} }
btCollisionAlgorithm* InternalFindAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1); btCollisionAlgorithm* internalFindAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1);
virtual bool NeedsCollision(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1); virtual bool needsCollision(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1);
virtual bool NeedsResponse(const btCollisionObject& colObj0,const btCollisionObject& colObj1); virtual bool needsResponse(const btCollisionObject& colObj0,const btCollisionObject& colObj1);
virtual int GetUniqueId() { return RIGIDBODY_DISPATCHER;} virtual int getUniqueId() { return RIGIDBODY_DISPATCHER;}
virtual void DispatchAllCollisionPairs(btOverlappingPairCache* pairCache,btDispatcherInfo& dispatchInfo); virtual void dispatchAllCollisionPairs(btOverlappingPairCache* pairCache,btDispatcherInfo& dispatchInfo);

View File

@@ -41,8 +41,8 @@ ParallelPhysicsEnvironment::~ParallelPhysicsEnvironment()
bool ParallelPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep) bool ParallelPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
{ {
// Make sure the broadphase / overlapping AABB paircache is up-to-date // Make sure the broadphase / overlapping AABB paircache is up-to-date
btOverlappingPairCache* scene = m_collisionWorld->GetPairCache(); btOverlappingPairCache* scene = m_collisionWorld->getPairCache();
scene->RefreshOverlappingPairs(); scene->refreshOverlappingPairs();
// Find the connected sets that can be simulated in parallel // Find the connected sets that can be simulated in parallel
// Using union find // Using union find
@@ -51,7 +51,7 @@ bool ParallelPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
btProfiler::beginBlock("IslandUnionFind"); btProfiler::beginBlock("IslandUnionFind");
#endif //USE_QUICKPROF #endif //USE_QUICKPROF
GetSimulationIslandManager()->UpdateActivationState(GetCollisionWorld(),GetCollisionWorld()->GetDispatcher()); getSimulationIslandManager()->updateActivationState(getCollisionWorld(),getCollisionWorld()->getDispatcher());
{ {
int i; int i;
@@ -60,8 +60,8 @@ bool ParallelPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
{ {
btTypedConstraint* constraint = m_constraints[i]; btTypedConstraint* constraint = m_constraints[i];
const btRigidBody* colObj0 = &constraint->GetRigidBodyA(); const btRigidBody* colObj0 = &constraint->getRigidBodyA();
const btRigidBody* colObj1 = &constraint->GetRigidBodyB(); const btRigidBody* colObj1 = &constraint->getRigidBodyB();
if (((colObj0) && ((colObj0)->mergesSimulationIslands())) && if (((colObj0) && ((colObj0)->mergesSimulationIslands())) &&
((colObj1) && ((colObj1)->mergesSimulationIslands()))) ((colObj1) && ((colObj1)->mergesSimulationIslands())))
@@ -69,7 +69,7 @@ bool ParallelPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
if (colObj0->IsActive() || colObj1->IsActive()) if (colObj0->IsActive() || colObj1->IsActive())
{ {
GetSimulationIslandManager()->GetUnionFind().unite((colObj0)->m_islandTag1, getSimulationIslandManager()->getUnionFind().unite((colObj0)->m_islandTag1,
(colObj1)->m_islandTag1); (colObj1)->m_islandTag1);
} }
} }
@@ -77,7 +77,7 @@ bool ParallelPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
} }
//Store the island id in each body //Store the island id in each body
GetSimulationIslandManager()->StoreIslandActivationState(GetCollisionWorld()); getSimulationIslandManager()->storeIslandActivationState(getCollisionWorld());
#ifdef USE_QUICKPROF #ifdef USE_QUICKPROF
btProfiler::endBlock("IslandUnionFind"); btProfiler::endBlock("IslandUnionFind");
@@ -98,14 +98,14 @@ bool ParallelPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
for (k=0;k<GetNumControllers();k++) for (k=0;k<GetNumControllers();k++)
{ {
CcdPhysicsController* ctrl = m_controllers[k]; CcdPhysicsController* ctrl = m_controllers[k];
int tag = ctrl->GetRigidBody()->m_islandTag1; int tag = ctrl->getRigidBody()->m_islandTag1;
if (tag>=0) if (tag>=0)
{ {
simulationIslands[tag].m_controllers.push_back(ctrl); simulationIslands[tag].m_controllers.push_back(ctrl);
} }
} }
btDispatcher* dispatcher = GetCollisionWorld()->GetDispatcher(); btDispatcher* dispatcher = getCollisionWorld()->getDispatcher();
//this is a brute force approach, will rethink later about more subtle ways //this is a brute force approach, will rethink later about more subtle ways
@@ -137,32 +137,32 @@ bool ParallelPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
for (unsigned int ui=0;ui<m_constraints.size();ui++) for (unsigned int ui=0;ui<m_constraints.size();ui++)
{ {
btTypedConstraint& constraint = *m_constraints[ui]; btTypedConstraint& constraint = *m_constraints[ui];
if (constraint.GetRigidBodyA().m_islandTag1 > constraint.GetRigidBodyB().m_islandTag1) if (constraint.getRigidBodyA().m_islandTag1 > constraint.getRigidBodyB().m_islandTag1)
{ {
simulationIslands[constraint.GetRigidBodyA().m_islandTag1].m_constraintIndices.push_back(ui); simulationIslands[constraint.getRigidBodyA().m_islandTag1].m_constraintIndices.push_back(ui);
} else } else
{ {
simulationIslands[constraint.GetRigidBodyB().m_islandTag1].m_constraintIndices.push_back(ui); simulationIslands[constraint.getRigidBodyB().m_islandTag1].m_constraintIndices.push_back(ui);
} }
} }
//add all overlapping pairs for each island //add all overlapping pairs for each island
for (i=0;i<dispatcher->GetNumManifolds();i++) for (i=0;i<dispatcher->getNumManifolds();i++)
{ {
btPersistentManifold* manifold = dispatcher->GetManifoldByIndexInternal(i); btPersistentManifold* manifold = dispatcher->getManifoldByIndexInternal(i);
//filtering for response //filtering for response
btCollisionObject* colObj0 = static_cast<btCollisionObject*>(manifold->GetBody0()); btCollisionObject* colObj0 = static_cast<btCollisionObject*>(manifold->getBody0());
btCollisionObject* colObj1 = static_cast<btCollisionObject*>(manifold->GetBody1()); btCollisionObject* colObj1 = static_cast<btCollisionObject*>(manifold->getBody1());
{ {
int islandTag = colObj0->m_islandTag1; int islandTag = colObj0->m_islandTag1;
if (colObj1->m_islandTag1 > islandTag) if (colObj1->m_islandTag1 > islandTag)
islandTag = colObj1->m_islandTag1; islandTag = colObj1->m_islandTag1;
if (dispatcher->NeedsResponse(*colObj0,*colObj1)) if (dispatcher->needsResponse(*colObj0,*colObj1))
simulationIslands[islandTag].m_manifolds.push_back(manifold); simulationIslands[islandTag].m_manifolds.push_back(manifold);
} }
@@ -191,7 +191,7 @@ bool ParallelPhysicsEnvironment::proceedDeltaTimeOneStep(float timeStep)
if (simulationIslands[k].m_controllers.size()) if (simulationIslands[k].m_controllers.size())
{ {
assert(0);//seems to be wrong, passing ALL overlapping pairs assert(0);//seems to be wrong, passing ALL overlapping pairs
simulationIslands[k].Simulate(m_debugDrawer,m_numIterations, constraintBase ,&scene->GetOverlappingPair(0),dispatcher,GetBroadphase(),m_solver,timeStep); simulationIslands[k].Simulate(m_debugDrawer,m_numIterations, constraintBase ,&scene->GetOverlappingPair(0),dispatcher,getBroadphase(),m_solver,timeStep);
} }
} }
*/ */

View File

@@ -45,7 +45,7 @@ bool SimulationIsland::Simulate(btIDebugDraw* debugDrawer,int numSolverIteration
{ {
CcdPhysicsController* ctrl = m_controllers[k]; CcdPhysicsController* ctrl = m_controllers[k];
// btTransform predictedTrans; // btTransform predictedTrans;
btRigidBody* body = ctrl->GetRigidBody(); btRigidBody* body = ctrl->getRigidBody();
//todo: only do this when necessary, it's used for contact points //todo: only do this when necessary, it's used for contact points
body->m_cachedInvertedWorldTransform = body->m_worldTransform.inverse(); body->m_cachedInvertedWorldTransform = body->m_worldTransform.inverse();
@@ -66,7 +66,7 @@ bool SimulationIsland::Simulate(btIDebugDraw* debugDrawer,int numSolverIteration
btProfiler::endBlock("predictIntegratedTransform"); btProfiler::endBlock("predictIntegratedTransform");
#endif //USE_QUICKPROF #endif //USE_QUICKPROF
//BroadphaseInterface* scene = GetBroadphase(); //BroadphaseInterface* scene = getBroadphase();
// //
@@ -75,7 +75,7 @@ bool SimulationIsland::Simulate(btIDebugDraw* debugDrawer,int numSolverIteration
#ifdef USE_QUICKPROF #ifdef USE_QUICKPROF
btProfiler::beginBlock("DispatchAllCollisionPairs"); btProfiler::beginBlock("dispatchAllCollisionPairs");
#endif //USE_QUICKPROF #endif //USE_QUICKPROF
@@ -99,11 +99,11 @@ bool SimulationIsland::Simulate(btIDebugDraw* debugDrawer,int numSolverIteration
} }
//pairCache->RefreshOverlappingPairs(); //pairCache->refreshOverlappingPairs();
if (overlappingPairs.size()) if (overlappingPairs.size())
{ {
assert(0); assert(0);
//dispatcher->DispatchAllCollisionPairs(&overlappingPairs[0],overlappingPairs.size(),dispatchInfo);///numsubstep,g); //dispatcher->dispatchAllCollisionPairs(&overlappingPairs[0],overlappingPairs.size(),dispatchInfo);///numsubstep,g);
} }
//scatter overlapping pair info, mainly the created algorithms/contact caches //scatter overlapping pair info, mainly the created algorithms/contact caches
@@ -115,13 +115,13 @@ bool SimulationIsland::Simulate(btIDebugDraw* debugDrawer,int numSolverIteration
#ifdef USE_QUICKPROF #ifdef USE_QUICKPROF
btProfiler::endBlock("DispatchAllCollisionPairs"); btProfiler::endBlock("dispatchAllCollisionPairs");
#endif //USE_QUICKPROF #endif //USE_QUICKPROF
//contacts //contacts
#ifdef USE_QUICKPROF #ifdef USE_QUICKPROF
btProfiler::beginBlock("SolveConstraint"); btProfiler::beginBlock("solveConstraint");
#endif //USE_QUICKPROF #endif //USE_QUICKPROF
@@ -140,8 +140,8 @@ bool SimulationIsland::Simulate(btIDebugDraw* debugDrawer,int numSolverIteration
for (i=0;i< numConstraints ; i++ ) for (i=0;i< numConstraints ; i++ )
{ {
btTypedConstraint* constraint = constraintsBaseAddress[m_constraintIndices[i]]; btTypedConstraint* constraint = constraintsBaseAddress[m_constraintIndices[i]];
constraint->BuildJacobian(); constraint->buildJacobian();
constraint->SolveConstraint( timeStep ); constraint->solveConstraint( timeStep );
} }
@@ -149,7 +149,7 @@ bool SimulationIsland::Simulate(btIDebugDraw* debugDrawer,int numSolverIteration
} }
#ifdef USE_QUICKPROF #ifdef USE_QUICKPROF
btProfiler::endBlock("SolveConstraint"); btProfiler::endBlock("solveConstraint");
#endif //USE_QUICKPROF #endif //USE_QUICKPROF
/* /*
@@ -163,7 +163,7 @@ bool SimulationIsland::Simulate(btIDebugDraw* debugDrawer,int numSolverIteration
{ {
WrapperVehicle* wrapperVehicle = m_wrapperVehicles[i]; WrapperVehicle* wrapperVehicle = m_wrapperVehicles[i];
btRaycastVehicle* vehicle = wrapperVehicle->GetVehicle(); btRaycastVehicle* vehicle = wrapperVehicle->GetVehicle();
vehicle->UpdateVehicle( timeStep); vehicle->updateVehicle( timeStep);
} }
#endif //NEW_BULLET_VEHICLE_SUPPORT #endif //NEW_BULLET_VEHICLE_SUPPORT
*/ */
@@ -181,7 +181,7 @@ bool SimulationIsland::Simulate(btIDebugDraw* debugDrawer,int numSolverIteration
} }
*/ */
//OverlappingPairCache* scene = GetCollisionWorld()->GetPairCache(); //OverlappingPairCache* scene = getCollisionWorld()->getPairCache();
btContactSolverInfo solverInfo; btContactSolverInfo solverInfo;
@@ -193,7 +193,7 @@ bool SimulationIsland::Simulate(btIDebugDraw* debugDrawer,int numSolverIteration
if (m_manifolds.size()) if (m_manifolds.size())
{ {
solver->SolveGroup( &m_manifolds[0],m_manifolds.size(),solverInfo,0); solver->solveGroup( &m_manifolds[0],m_manifolds.size(),solverInfo,0);
} }
@@ -221,7 +221,7 @@ bool SimulationIsland::Simulate(btIDebugDraw* debugDrawer,int numSolverIteration
dispatchInfo.m_stepCount = 0; dispatchInfo.m_stepCount = 0;
dispatchInfo.m_dispatchFunc = btDispatcherInfo::DISPATCH_CONTINUOUS; dispatchInfo.m_dispatchFunc = btDispatcherInfo::DISPATCH_CONTINUOUS;
// GetCollisionWorld()->GetDispatcher()->DispatchAllCollisionPairs(scene,dispatchInfo); // getCollisionWorld()->getDispatcher()->dispatchAllCollisionPairs(scene,dispatchInfo);
toi = dispatchInfo.m_timeOfImpact; toi = dispatchInfo.m_timeOfImpact;
} }
@@ -244,7 +244,7 @@ bool SimulationIsland::Simulate(btIDebugDraw* debugDrawer,int numSolverIteration
CcdPhysicsController* ctrl = *i; CcdPhysicsController* ctrl = *i;
btTransform predictedTrans; btTransform predictedTrans;
btRigidBody* body = ctrl->GetRigidBody(); btRigidBody* body = ctrl->getRigidBody();
if (body->IsActive()) if (body->IsActive())
{ {
@@ -276,7 +276,7 @@ bool SimulationIsland::Simulate(btIDebugDraw* debugDrawer,int numSolverIteration
!(i==m_controllers.end()); i++) !(i==m_controllers.end()); i++)
{ {
CcdPhysicsController* ctrl = (*i); CcdPhysicsController* ctrl = (*i);
btRigidBody* body = ctrl->GetRigidBody(); btRigidBody* body = ctrl->getRigidBody();
ctrl->UpdateDeactivation(timeStep); ctrl->UpdateDeactivation(timeStep);
@@ -375,15 +375,15 @@ void SimulationIsland::UpdateAabbs(btIDebugDraw* debugDrawer,btBroadphaseInterfa
!(i==m_controllers.end()); i++) !(i==m_controllers.end()); i++)
{ {
CcdPhysicsController* ctrl = (*i); CcdPhysicsController* ctrl = (*i);
btRigidBody* body = ctrl->GetRigidBody(); btRigidBody* body = ctrl->getRigidBody();
btPoint3 minAabb,maxAabb; btPoint3 minAabb,maxAabb;
btCollisionShape* shapeinterface = ctrl->GetCollisionShape(); btCollisionShape* shapeinterface = ctrl->getCollisionShape();
shapeinterface->CalculateTemporalAabb(body->getCenterOfMassTransform(), shapeinterface->calculateTemporalAabb(body->getCenterOfMassTransform(),
body->getLinearVelocity(), body->getLinearVelocity(),
//body->getAngularVelocity(), //body->getAngularVelocity(),
btVector3(0.f,0.f,0.f),//no angular effect for now //body->getAngularVelocity(), btVector3(0.f,0.f,0.f),//no angular effect for now //body->getAngularVelocity(),
@@ -428,7 +428,7 @@ void SimulationIsland::UpdateAabbs(btIDebugDraw* debugDrawer,btBroadphaseInterfa
}; };
if (m_debugDrawer->GetDebugMode() & btIDebugDraw::DBG_DrawAabb) if (m_debugDrawer->getDebugMode() & btIDebugDraw::DBG_DrawAabb)
{ {
DrawAabb(m_debugDrawer,minAabb,maxAabb,color); DrawAabb(m_debugDrawer,minAabb,maxAabb,color);
} }
@@ -438,7 +438,7 @@ void SimulationIsland::UpdateAabbs(btIDebugDraw* debugDrawer,btBroadphaseInterfa
if ( (maxAabb-minAabb).length2() < 1e12f) if ( (maxAabb-minAabb).length2() < 1e12f)
{ {
scene->SetAabb(bp,minAabb,maxAabb); scene->setAabb(bp,minAabb,maxAabb);
} else } else
{ {
//something went wrong, investigate //something went wrong, investigate

View File

@@ -77,9 +77,9 @@ class PHY_IPhysicsController
virtual PHY_IPhysicsController* GetReplica() {return 0;} virtual PHY_IPhysicsController* GetReplica() {return 0;}
virtual void calcXform() =0; virtual void calcXform() =0;
virtual void SetMargin(float margin) =0; virtual void setMargin(float margin) =0;
virtual float GetMargin() const=0; virtual float getMargin() const=0;
virtual float GetRadius() const { return 0.f;} virtual float getRadius() const { return 0.f;}
PHY__Vector3 GetWorldPosition(PHY__Vector3& localpos); PHY__Vector3 GetWorldPosition(PHY__Vector3& localpos);
}; };

View File

@@ -27,7 +27,7 @@ public:
virtual ~PHY_IVehicle(); virtual ~PHY_IVehicle();
virtual void AddWheel( virtual void addWheel(
PHY_IMotionState* motionState, PHY_IMotionState* motionState,
PHY__Vector3 connectionPoint, PHY__Vector3 connectionPoint,
PHY__Vector3 downDirection, PHY__Vector3 downDirection,
@@ -38,20 +38,20 @@ public:
) = 0; ) = 0;
virtual int GetNumWheels() const = 0; virtual int getNumWheels() const = 0;
virtual void GetWheelPosition(int wheelIndex,float& posX,float& posY,float& posZ) const = 0; virtual void GetWheelPosition(int wheelIndex,float& posX,float& posY,float& posZ) const = 0;
virtual void GetWheelOrientationQuaternion(int wheelIndex,float& quatX,float& quatY,float& quatZ,float& quatW) const = 0; virtual void GetWheelOrientationQuaternion(int wheelIndex,float& quatX,float& quatY,float& quatZ,float& quatW) const = 0;
virtual float GetWheelRotation(int wheelIndex) const = 0; virtual float GetWheelRotation(int wheelIndex) const = 0;
virtual int GetUserConstraintId() const =0; virtual int getUserConstraintId() const =0;
virtual int GetUserConstraintType() const =0; virtual int getUserConstraintType() const =0;
//some basic steering/braking/tuning/balancing (bikes) //some basic steering/braking/tuning/balancing (bikes)
virtual void SetSteeringValue(float steering,int wheelIndex) = 0; virtual void setSteeringValue(float steering,int wheelIndex) = 0;
virtual void ApplyEngineForce(float force,int wheelIndex) = 0; virtual void applyEngineForce(float force,int wheelIndex) = 0;
virtual void ApplyBraking(float braking,int wheelIndex) = 0; virtual void ApplyBraking(float braking,int wheelIndex) = 0;
@@ -65,7 +65,7 @@ public:
virtual void SetRollInfluence(float rollInfluence,int wheelIndex) = 0; virtual void SetRollInfluence(float rollInfluence,int wheelIndex) = 0;
virtual void SetCoordinateSystem(int rightIndex,int upIndex,int forwardIndex) =0; virtual void setCoordinateSystem(int rightIndex,int upIndex,int forwardIndex) =0;
}; };

View File

@@ -110,7 +110,7 @@ public:
// element access // element access
const Vector3 GetNormal() const; const Vector3 GetNormal() const;
const Scalar GetDistance() const; const Scalar getDistance() const;
// transformations // transformations
friend const Plane operator-(const Plane& p); friend const Plane operator-(const Plane& p);

View File

@@ -49,10 +49,10 @@ Point3 Hull::GetFaceCentroid(short face) const
short edge; short edge;
edge = GetFaceFirstEdge(face); edge = GetFaceFirstEdge(face);
Vector3 c = Vector3(GetVertex(GetEdgeVertex0(face, edge))); Vector3 c = Vector3(getVertex(GetEdgeVertex0(face, edge)));
for (edge = GetFaceNextEdge(face, edge); edge >= 0; edge = GetFaceNextEdge(face, edge)) for (edge = GetFaceNextEdge(face, edge); edge >= 0; edge = GetFaceNextEdge(face, edge))
c += Vector3(GetVertex(GetEdgeVertex0(face, edge))); c += Vector3(getVertex(GetEdgeVertex0(face, edge)));
c /= Scalar(GetFace(face).m_numEdges); c /= Scalar(GetFace(face).m_numEdges);
@@ -767,8 +767,8 @@ int Hull::AddContactsHullHull(btSeparation& sep, const Point3* pVertsA, const Po
// edge->edge contact is always a single point // edge->edge contact is always a single point
if (sep.m_separator == btSeparation::kFeatureBoth) if (sep.m_separator == btSeparation::kFeatureBoth)
{ {
const Hull::Edge& edgeA = hullA.GetEdge(sep.m_featureA); const Hull::Edge& edgeA = hullA.getEdge(sep.m_featureA);
const Hull::Edge& edgeB = hullB.GetEdge(sep.m_featureB); const Hull::Edge& edgeB = hullB.getEdge(sep.m_featureB);
float ta, tb; float ta, tb;
Line la(pVertsA[edgeA.m_verts[0]], pVertsA[edgeA.m_verts[1]]); Line la(pVertsA[edgeA.m_verts[0]], pVertsA[edgeA.m_verts[1]]);
@@ -801,13 +801,13 @@ int Hull::AddContactsHullHull(btSeparation& sep, const Point3* pVertsA, const Po
// TODO: avoid having to transform planes here // TODO: avoid having to transform planes here
if (sep.m_separator == btSeparation::kFeatureB) if (sep.m_separator == btSeparation::kFeatureB)
{ {
const Hull::Edge& edgeB = hullB.GetEdge(hullB.GetFaceFirstEdge(faceB)); const Hull::Edge& edgeB = hullB.getEdge(hullB.GetFaceFirstEdge(faceB));
tangent = Normalize(pVertsB[edgeB.m_verts[1]] - pVertsB[edgeB.m_verts[0]]); tangent = Normalize(pVertsB[edgeB.m_verts[1]] - pVertsB[edgeB.m_verts[0]]);
Scalar dmin = Scalar::Consts::MaxValue; Scalar dmin = Scalar::Consts::MaxValue;
for (short face = 0; face < hullA.m_numFaces; face++) for (short face = 0; face < hullA.m_numFaces; face++)
{ {
Vector3 normal = hullA.GetPlane(face).GetNormal() * trA; Vector3 normal = hullA.getPlane(face).GetNormal() * trA;
Scalar d = Dot(normal, sep.m_axis); Scalar d = Dot(normal, sep.m_axis);
if (d < dmin) if (d < dmin)
{ {
@@ -818,13 +818,13 @@ int Hull::AddContactsHullHull(btSeparation& sep, const Point3* pVertsA, const Po
} }
else else
{ {
const Hull::Edge& edgeA = hullA.GetEdge(hullA.GetFaceFirstEdge(faceA)); const Hull::Edge& edgeA = hullA.getEdge(hullA.GetFaceFirstEdge(faceA));
tangent = Normalize(pVertsA[edgeA.m_verts[1]] - pVertsA[edgeA.m_verts[0]]); tangent = Normalize(pVertsA[edgeA.m_verts[1]] - pVertsA[edgeA.m_verts[0]]);
Scalar dmin = Scalar::Consts::MaxValue; Scalar dmin = Scalar::Consts::MaxValue;
for (short face = 0; face < hullB.m_numFaces; face++) for (short face = 0; face < hullB.m_numFaces; face++)
{ {
Vector3 normal = hullB.GetPlane(face).GetNormal() * trB; Vector3 normal = hullB.getPlane(face).GetNormal() * trB;
Scalar d = Dot(normal, -sep.m_axis); Scalar d = Dot(normal, -sep.m_axis);
if (d < dmin) if (d < dmin)
{ {
@@ -848,19 +848,19 @@ int Hull::AddContactsHullHull(btSeparation& sep, const Point3* pVertsA, const Po
#if 0 #if 0
for (short edge = hullA.GetFaceFirstEdge(faceA); edge != -1; edge = hullA.GetFaceNextEdge(faceA, edge)) for (short edge = hullA.GetFaceFirstEdge(faceA); edge != -1; edge = hullA.GetFaceNextEdge(faceA, edge))
{ {
Plane planeA = hullA.GetPlane( hullA.GetEdgeOtherFace(edge, faceA) ) * trA; Plane planeA = hullA.getPlane( hullA.GetEdgeOtherFace(edge, faceA) ) * trA;
numContacts = ClipFace(numContacts, &pVtxIn, &pVtxOut, planeA); numContacts = ClipFace(numContacts, &pVtxIn, &pVtxOut, planeA);
} }
#else #else
for (short f = 0; f < hullA.GetNumFaces(); f++) for (short f = 0; f < hullA.GetNumFaces(); f++)
{ {
Plane planeA = hullA.GetPlane(f) * trA; Plane planeA = hullA.getPlane(f) * trA;
numContacts = ClipFace(numContacts, &pVtxIn, &pVtxOut, planeA); numContacts = ClipFace(numContacts, &pVtxIn, &pVtxOut, planeA);
} }
#endif #endif
// only keep points that are behind the witness face // only keep points that are behind the witness face
Plane planeA = hullA.GetPlane(faceA) * trA; Plane planeA = hullA.getPlane(faceA) * trA;
float depths[Hull::kMaxVerts]; float depths[Hull::kMaxVerts];
int numPoints = 0; int numPoints = 0;
@@ -1002,11 +1002,11 @@ bool Hull::GetSeparationHullHull(btSeparation& sep, const Point3* pVertsA, const
for (short ea = hullA.GetFaceFirstEdge(faceA); ea != -1; ea = hullA.GetFaceNextEdge(faceA, ea)) for (short ea = hullA.GetFaceFirstEdge(faceA); ea != -1; ea = hullA.GetFaceNextEdge(faceA, ea))
{ {
const Hull::Edge& edgeA = hullA.GetEdge(ea); const Hull::Edge& edgeA = hullA.getEdge(ea);
for (short eb = hullB.GetFaceFirstEdge(faceB); eb != -1; eb = hullB.GetFaceNextEdge(faceB, eb)) for (short eb = hullB.GetFaceFirstEdge(faceB); eb != -1; eb = hullB.GetFaceNextEdge(faceB, eb))
{ {
const Hull::Edge& edgeB = hullB.GetEdge(eb); const Hull::Edge& edgeB = hullB.getEdge(eb);
Vector3 va = pVertsA[edgeA.m_verts[1]] - pVertsA[edgeA.m_verts[0]]; Vector3 va = pVertsA[edgeA.m_verts[1]] - pVertsA[edgeA.m_verts[0]];
Vector3 vb = pVertsB[edgeB.m_verts[1]] - pVertsB[edgeB.m_verts[0]]; Vector3 vb = pVertsB[edgeB.m_verts[1]] - pVertsB[edgeB.m_verts[0]];

View File

@@ -119,14 +119,14 @@ public:
// ObjectType GetObjectType() const {return kTypeHull;} // ObjectType GetObjectType() const {return kTypeHull;}
short GetNumVertices() const; short getNumVertices() const;
short GetNumFaces() const; short GetNumFaces() const;
short GetNumEdges() const; short getNumEdges() const;
const Point3& GetVertex(short index) const; const Point3& getVertex(short index) const;
const Face& GetFace(short index) const; const Face& GetFace(short index) const;
const Edge& GetEdge(short index) const; const Edge& getEdge(short index) const;
const Plane& GetPlane(short index) const; const Plane& getPlane(short index) const;
short GetFaceFirstEdge(short face) const; short GetFaceFirstEdge(short face) const;
short GetFaceNextEdge(short face, short prevEdge) const; short GetFaceNextEdge(short face, short prevEdge) const;

View File

@@ -69,7 +69,7 @@ m_erp(0.4f)
//iterative lcp and penalty method //iterative lcp and penalty method
float OdeConstraintSolver::SolveGroup(btPersistentManifold** manifoldPtr, int numManifolds,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer) float OdeConstraintSolver::solveGroup(btPersistentManifold** manifoldPtr, int numManifolds,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer)
{ {
m_CurBody = 0; m_CurBody = 0;
m_CurJoint = 0; m_CurJoint = 0;
@@ -87,10 +87,10 @@ float OdeConstraintSolver::SolveGroup(btPersistentManifold** manifoldPtr, int nu
int body0=-1,body1=-1; int body0=-1,body1=-1;
btPersistentManifold* manifold = manifoldPtr[j]; btPersistentManifold* manifold = manifoldPtr[j];
if (manifold->GetNumContacts() > 0) if (manifold->getNumContacts() > 0)
{ {
body0 = ConvertBody((btRigidBody*)manifold->GetBody0(),bodies,numBodies); body0 = ConvertBody((btRigidBody*)manifold->getBody0(),bodies,numBodies);
body1 = ConvertBody((btRigidBody*)manifold->GetBody1(),bodies,numBodies); body1 = ConvertBody((btRigidBody*)manifold->getBody1(),bodies,numBodies);
ConvertConstraint(manifold,joints,numJoints,bodies,body0,body1,debugDrawer); ConvertConstraint(manifold,joints,numJoints,bodies,body0,body1,debugDrawer);
} }
} }
@@ -199,12 +199,12 @@ void OdeConstraintSolver::ConvertConstraint(btPersistentManifold* manifold,BU_Jo
{ {
manifold->RefreshContactPoints(((btRigidBody*)manifold->GetBody0())->getCenterOfMassTransform(), manifold->refreshContactPoints(((btRigidBody*)manifold->getBody0())->getCenterOfMassTransform(),
((btRigidBody*)manifold->GetBody1())->getCenterOfMassTransform()); ((btRigidBody*)manifold->getBody1())->getCenterOfMassTransform());
int bodyId0 = _bodyId0,bodyId1 = _bodyId1; int bodyId0 = _bodyId0,bodyId1 = _bodyId1;
int i,numContacts = manifold->GetNumContacts(); int i,numContacts = manifold->getNumContacts();
bool swapBodies = (bodyId0 < 0); bool swapBodies = (bodyId0 < 0);
@@ -216,13 +216,13 @@ void OdeConstraintSolver::ConvertConstraint(btPersistentManifold* manifold,BU_Jo
bodyId0 = _bodyId1; bodyId0 = _bodyId1;
bodyId1 = _bodyId0; bodyId1 = _bodyId0;
body0 = (btRigidBody*)manifold->GetBody1(); body0 = (btRigidBody*)manifold->getBody1();
body1 = (btRigidBody*)manifold->GetBody0(); body1 = (btRigidBody*)manifold->getBody0();
} else } else
{ {
body0 = (btRigidBody*)manifold->GetBody0(); body0 = (btRigidBody*)manifold->getBody0();
body1 = (btRigidBody*)manifold->GetBody1(); body1 = (btRigidBody*)manifold->getBody1();
} }
assert(bodyId0 >= 0); assert(bodyId0 >= 0);
@@ -233,19 +233,19 @@ void OdeConstraintSolver::ConvertConstraint(btPersistentManifold* manifold,BU_Jo
if (debugDrawer) if (debugDrawer)
{ {
const btManifoldPoint& cp = manifold->GetContactPoint(i); const btManifoldPoint& cp = manifold->getContactPoint(i);
debugDrawer->DrawContactPoint( debugDrawer->drawContactPoint(
cp.m_positionWorldOnB, cp.m_positionWorldOnB,
cp.m_normalWorldOnB, cp.m_normalWorldOnB,
cp.GetDistance(), cp.getDistance(),
cp.GetLifeTime(), cp.getLifeTime(),
color); color);
} }
assert (m_CurJoint < MAX_JOINTS_1); assert (m_CurJoint < MAX_JOINTS_1);
// if (manifold->GetContactPoint(i).GetDistance() < 0.0f) // if (manifold->getContactPoint(i).getDistance() < 0.0f)
{ {
ContactJoint* cont = new (&gJointArray[m_CurJoint++]) ContactJoint( manifold ,i, swapBodies,body0,body1); ContactJoint* cont = new (&gJointArray[m_CurJoint++]) ContactJoint( manifold ,i, swapBodies,body0,body1);

View File

@@ -44,7 +44,7 @@ public:
virtual ~OdeConstraintSolver() {} virtual ~OdeConstraintSolver() {}
virtual float SolveGroup(btPersistentManifold** manifold,int numManifolds,const btContactSolverInfo& info,btIDebugDraw* debugDrawer = 0); virtual float solveGroup(btPersistentManifold** manifold,int numManifolds,const btContactSolverInfo& info,btIDebugDraw* debugDrawer = 0);
///setConstraintForceMixing, the cfm adds some positive value to the main diagonal ///setConstraintForceMixing, the cfm adds some positive value to the main diagonal
///This can improve convergence (make matrix positive semidefinite), but it can make the simulation look more 'springy' ///This can improve convergence (make matrix positive semidefinite), but it can make the simulation look more 'springy'

View File

@@ -179,7 +179,7 @@ static void command (int cmd)
// destroy the body and geoms for slot i // destroy the body and geoms for slot i
dBodyDestroy (obj[i].body); dBodyDestroy (obj[i].body);
collisionWorld->RemoveCollisionObject(&obj[i].collider); collisionWorld->removeCollisionObject(&obj[i].collider);
obj[i].collider.m_broadphaseHandle = (btBroadphaseProxy*)(-1); obj[i].collider.m_broadphaseHandle = (btBroadphaseProxy*)(-1);
@@ -212,7 +212,7 @@ static void command (int cmd)
dMassSetBox (&m,DENSITY,sides[0],sides[1],sides[2]); dMassSetBox (&m,DENSITY,sides[0],sides[1],sides[2]);
obj[i].collider.m_collisionShape = new btBoxShape(btVector3(0.5*sides[0],0.5*sides[1],0.5*sides[2])); obj[i].collider.m_collisionShape = new btBoxShape(btVector3(0.5*sides[0],0.5*sides[1],0.5*sides[2]));
obj[i].collider.m_worldTransform = GetTransformFromOde(dBodyGetPosition(obj[i].body),dBodyGetRotation(obj[i].body)); obj[i].collider.m_worldTransform = GetTransformFromOde(dBodyGetPosition(obj[i].body),dBodyGetRotation(obj[i].body));
collisionWorld->AddCollisionObject(&obj[i].collider); collisionWorld->addCollisionObject(&obj[i].collider);
obj[i].collider.m_userPointer = obj[i].body; obj[i].collider.m_userPointer = obj[i].body;
} }
@@ -223,7 +223,7 @@ static void command (int cmd)
dMassSetCappedCylinder (&m,DENSITY,3,sides[0],sides[1]); dMassSetCappedCylinder (&m,DENSITY,3,sides[0],sides[1]);
obj[i].collider.m_collisionShape = new btCylinderShapeZ(btVector3(sides[0],sides[1],sides[1])); obj[i].collider.m_collisionShape = new btCylinderShapeZ(btVector3(sides[0],sides[1],sides[1]));
obj[i].collider.m_worldTransform = GetTransformFromOde(dBodyGetPosition(obj[i].body),dBodyGetRotation(obj[i].body)); obj[i].collider.m_worldTransform = GetTransformFromOde(dBodyGetPosition(obj[i].body),dBodyGetRotation(obj[i].body));
collisionWorld->AddCollisionObject(&obj[i].collider); collisionWorld->addCollisionObject(&obj[i].collider);
obj[i].collider.m_userPointer = obj[i].body; obj[i].collider.m_userPointer = obj[i].body;
//obj[i].geom[0] = dCreateCCylinder (space,sides[0],sides[1]); //obj[i].geom[0] = dCreateCCylinder (space,sides[0],sides[1]);
} }
@@ -242,7 +242,7 @@ static void command (int cmd)
obj[i].collider.m_worldTransform = GetTransformFromOde(dBodyGetPosition(obj[i].body),dBodyGetRotation(obj[i].body)); obj[i].collider.m_worldTransform = GetTransformFromOde(dBodyGetPosition(obj[i].body),dBodyGetRotation(obj[i].body));
collisionWorld->AddCollisionObject(&obj[i].collider); collisionWorld->addCollisionObject(&obj[i].collider);
obj[i].collider.m_userPointer = obj[i].body; obj[i].collider.m_userPointer = obj[i].body;
//obj[i].geom[0] = dCreateSphere (space,sides[0]); //obj[i].geom[0] = dCreateSphere (space,sides[0]);
@@ -300,21 +300,21 @@ void drawGeom (btCollisionObject& collider)//, const dReal *pos, const dReal *R,
if (!collider.m_collisionShape) return; if (!collider.m_collisionShape) return;
int type = collider.m_collisionShape->GetShapeType(); int type = collider.m_collisionShape->getShapeType();
if (type == BOX_SHAPE_PROXYTYPE) { if (type == BOX_SHAPE_PROXYTYPE) {
dVector3 sides; dVector3 sides;
btBoxShape* boxShape = static_cast<btBoxShape*>(collider.m_collisionShape); btBoxShape* boxShape = static_cast<btBoxShape*>(collider.m_collisionShape);
sides[0] = 2.f*boxShape->GetHalfExtents().x(); sides[0] = 2.f*boxShape->getHalfExtents().x();
sides[1] = 2.f*boxShape->GetHalfExtents().y(); sides[1] = 2.f*boxShape->getHalfExtents().y();
sides[2] = 2.f*boxShape->GetHalfExtents().z(); sides[2] = 2.f*boxShape->getHalfExtents().z();
///boxshape already has margins 'inside' ///boxshape already has margins 'inside'
dsDrawBox (pos,R,sides); dsDrawBox (pos,R,sides);
} }
else if (type == SPHERE_SHAPE_PROXYTYPE) { else if (type == SPHERE_SHAPE_PROXYTYPE) {
btSphereShape* sphereShape = static_cast<btSphereShape*>(collider.m_collisionShape); btSphereShape* sphereShape = static_cast<btSphereShape*>(collider.m_collisionShape);
dReal radius = sphereShape->GetMargin(); dReal radius = sphereShape->getMargin();
dsDrawSphere (pos,R,radius); dsDrawSphere (pos,R,radius);
@@ -323,10 +323,10 @@ void drawGeom (btCollisionObject& collider)//, const dReal *pos, const dReal *R,
else if (type == CYLINDER_SHAPE_PROXYTYPE) { else if (type == CYLINDER_SHAPE_PROXYTYPE) {
btCylinderShapeZ* cylinder = static_cast<btCylinderShapeZ*>(collider.m_collisionShape); btCylinderShapeZ* cylinder = static_cast<btCylinderShapeZ*>(collider.m_collisionShape);
dReal radius = cylinder->GetHalfExtents()[0]; dReal radius = cylinder->getHalfExtents()[0];
dReal length = 2.f*cylinder->GetHalfExtents()[1]; dReal length = 2.f*cylinder->getHalfExtents()[1];
radius += cylinder->GetMargin(); radius += cylinder->getMargin();
length += 2.f*cylinder->GetMargin(); length += 2.f*cylinder->getMargin();
//dGeomCCylinderGetParams (g,&radius,&length); //dGeomCCylinderGetParams (g,&radius,&length);
dsDrawCylinder (pos,R,length,radius); dsDrawCylinder (pos,R,length,radius);
@@ -376,21 +376,21 @@ static void simLoop (int pause)
{ {
dsSetColor (0,0,2); dsSetColor (0,0,2);
//dSpaceCollide (space,0,&nearCallback); //dSpaceCollide (space,0,&nearCallback);
collisionWorld->PerformDiscreteCollisionDetection(); collisionWorld->performDiscreteCollisionDetection();
//now the collisionWorld contains all contact points... just copy them over to ODE and that's it //now the collisionWorld contains all contact points... just copy them over to ODE and that's it
for (int i=0;i<collisionWorld->GetDispatcher()->GetNumManifolds();i++) for (int i=0;i<collisionWorld->getDispatcher()->getNumManifolds();i++)
{ {
btPersistentManifold* manifold = collisionWorld->GetDispatcher()->GetManifoldByIndexInternal(i); btPersistentManifold* manifold = collisionWorld->getDispatcher()->getManifoldByIndexInternal(i);
btCollisionObject* obj0 = static_cast<btCollisionObject*>(manifold->GetBody0()); btCollisionObject* obj0 = static_cast<btCollisionObject*>(manifold->getBody0());
btCollisionObject* obj1 = static_cast<btCollisionObject*>(manifold->GetBody1()); btCollisionObject* obj1 = static_cast<btCollisionObject*>(manifold->getBody1());
//RefreshContactPoints will update and/or remove existing contactpoints from previous frames //refreshContactPoints will update and/or remove existing contactpoints from previous frames
manifold->RefreshContactPoints(obj0->m_worldTransform,obj1->m_worldTransform); manifold->refreshContactPoints(obj0->m_worldTransform,obj1->m_worldTransform);
for (int j=0;j<manifold->GetNumContacts();j++) for (int j=0;j<manifold->getNumContacts();j++)
{ {
btManifoldPoint& pt = manifold->GetContactPoint(j); btManifoldPoint& pt = manifold->getContactPoint(j);
if (pt.GetDistance()<0.f) if (pt.getDistance()<0.f)
{ {
//report point to ODE //report point to ODE
@@ -401,7 +401,7 @@ static void simLoop (int pause)
contact.surface.bounce = 0.1; contact.surface.bounce = 0.1;
contact.surface.bounce_vel = 0.1; contact.surface.bounce_vel = 0.1;
contact.surface.soft_cfm = 0.01; contact.surface.soft_cfm = 0.01;
contact.geom.depth = -pt.GetDistance(); contact.geom.depth = -pt.getDistance();
contact.geom.normal[0] = pt.m_normalWorldOnB.x(); contact.geom.normal[0] = pt.m_normalWorldOnB.x();
@@ -410,9 +410,9 @@ static void simLoop (int pause)
//contact.geom.g1 does it really need this? //contact.geom.g1 does it really need this?
contact.geom.g1 = 0; contact.geom.g1 = 0;
contact.geom.g2 = 0; contact.geom.g2 = 0;
contact.geom.pos[0] = pt.GetPositionWorldOnB().x(); contact.geom.pos[0] = pt.getPositionWorldOnB().x();
contact.geom.pos[1] = pt.GetPositionWorldOnB().y(); contact.geom.pos[1] = pt.getPositionWorldOnB().y();
contact.geom.pos[2] = pt.GetPositionWorldOnB().z(); contact.geom.pos[2] = pt.getPositionWorldOnB().z();
contact.fdir1[0] = 0.f; contact.fdir1[0] = 0.f;
contact.fdir1[1] = 0.f; contact.fdir1[1] = 0.f;
@@ -513,8 +513,8 @@ int main (int argc, char **argv)
btCollisionObject groundPlane; btCollisionObject groundPlane;
groundPlane.m_worldTransform.setIdentity(); groundPlane.m_worldTransform.setIdentity();
groundPlane.m_collisionShape = new btBoxShape(btVector3(50,50,0.04)); groundPlane.m_collisionShape = new btBoxShape(btVector3(50,50,0.04));
groundPlane.m_collisionShape->SetMargin(0.005f); groundPlane.m_collisionShape->setMargin(0.005f);
collisionWorld->AddCollisionObject(&groundPlane); collisionWorld->addCollisionObject(&groundPlane);
groundPlane.m_userPointer = 0; groundPlane.m_userPointer = 0;
memset (obj,0,sizeof(obj)); memset (obj,0,sizeof(obj));

View File

@@ -1,6 +1,12 @@
Bullet Continuous Collision Detection and Physics Library Bullet Continuous Collision Detection and Physics Library
Erwin Coumans Erwin Coumans
2006 Sept 27
Big Refactoring: renamed and moved files, create a replacement for CcdPhysicsEnvironment/CcdPhysicsController.
All Bullet classes in LinearMath, BulletCollision and BulletDynamics start with bt, and methods start with lowercase.
Moved classes into src folder, which is the only include folder needed.
Added 2 headerfiles in src: btBulletCollisionCommon.h and btBulletDynamicsCommon.h
2006 Sept 23 2006 Sept 23
Fixed 2 bugs, causing crashes when removing objects. Should do better unit-testing. UnionFind and 3D SAP were involved. Fixed 2 bugs, causing crashes when removing objects. Should do better unit-testing. UnionFind and 3D SAP were involved.

View File

@@ -21,25 +21,25 @@
#include <assert.h> #include <assert.h>
btBroadphaseProxy* btAxisSweep3::CreateProxy( const btVector3& min, const btVector3& max,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask) btBroadphaseProxy* btAxisSweep3::createProxy( const btVector3& min, const btVector3& max,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask)
{ {
unsigned short handleId = AddHandle(min,max, userPtr,collisionFilterGroup,collisionFilterMask); unsigned short handleId = addHandle(min,max, userPtr,collisionFilterGroup,collisionFilterMask);
Handle* handle = GetHandle(handleId); Handle* handle = getHandle(handleId);
return handle; return handle;
} }
void btAxisSweep3::DestroyProxy(btBroadphaseProxy* proxy) void btAxisSweep3::destroyProxy(btBroadphaseProxy* proxy)
{ {
Handle* handle = static_cast<Handle*>(proxy); Handle* handle = static_cast<Handle*>(proxy);
RemoveHandle(handle->m_handleId); removeHandle(handle->m_handleId);
} }
void btAxisSweep3::SetAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax) void btAxisSweep3::setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax)
{ {
Handle* handle = static_cast<Handle*>(proxy); Handle* handle = static_cast<Handle*>(proxy);
UpdateHandle(handle->m_handleId,aabbMin,aabbMax); updateHandle(handle->m_handleId,aabbMin,aabbMax);
} }
@@ -107,7 +107,7 @@ btAxisSweep3::~btAxisSweep3()
delete[] m_pHandles; delete[] m_pHandles;
} }
void btAxisSweep3::Quantize(unsigned short* out, const btPoint3& point, int isMax) const void btAxisSweep3::quantize(unsigned short* out, const btPoint3& point, int isMax) const
{ {
btPoint3 clampedPoint(point); btPoint3 clampedPoint(point);
/* /*
@@ -132,22 +132,22 @@ void btAxisSweep3::Quantize(unsigned short* out, const btPoint3& point, int isMa
unsigned short btAxisSweep3::AllocHandle() unsigned short btAxisSweep3::allocHandle()
{ {
assert(m_firstFreeHandle); assert(m_firstFreeHandle);
unsigned short handle = m_firstFreeHandle; unsigned short handle = m_firstFreeHandle;
m_firstFreeHandle = GetHandle(handle)->GetNextFree(); m_firstFreeHandle = getHandle(handle)->GetNextFree();
m_numHandles++; m_numHandles++;
return handle; return handle;
} }
void btAxisSweep3::FreeHandle(unsigned short handle) void btAxisSweep3::freeHandle(unsigned short handle)
{ {
assert(handle > 0 && handle < m_maxHandles); assert(handle > 0 && handle < m_maxHandles);
GetHandle(handle)->SetNextFree(m_firstFreeHandle); getHandle(handle)->SetNextFree(m_firstFreeHandle);
m_firstFreeHandle = handle; m_firstFreeHandle = handle;
m_numHandles--; m_numHandles--;
@@ -155,18 +155,18 @@ void btAxisSweep3::FreeHandle(unsigned short handle)
unsigned short btAxisSweep3::AddHandle(const btPoint3& aabbMin,const btPoint3& aabbMax, void* pOwner,short int collisionFilterGroup,short int collisionFilterMask) unsigned short btAxisSweep3::addHandle(const btPoint3& aabbMin,const btPoint3& aabbMax, void* pOwner,short int collisionFilterGroup,short int collisionFilterMask)
{ {
// quantize the bounds // quantize the bounds
unsigned short min[3], max[3]; unsigned short min[3], max[3];
Quantize(min, aabbMin, 0); quantize(min, aabbMin, 0);
Quantize(max, aabbMax, 1); quantize(max, aabbMax, 1);
// allocate a handle // allocate a handle
unsigned short handle = AllocHandle(); unsigned short handle = allocHandle();
assert(handle!= 0xcdcd); assert(handle!= 0xcdcd);
Handle* pHandle = GetHandle(handle); Handle* pHandle = getHandle(handle);
pHandle->m_handleId = handle; pHandle->m_handleId = handle;
//pHandle->m_pOverlaps = 0; //pHandle->m_pOverlaps = 0;
@@ -195,12 +195,12 @@ unsigned short btAxisSweep3::AddHandle(const btPoint3& aabbMin,const btPoint3& a
} }
// now sort the new edges to their correct position // now sort the new edges to their correct position
SortMinDown(0, pHandle->m_minEdges[0], false); sortMinDown(0, pHandle->m_minEdges[0], false);
SortMaxDown(0, pHandle->m_maxEdges[0], false); sortMaxDown(0, pHandle->m_maxEdges[0], false);
SortMinDown(1, pHandle->m_minEdges[1], false); sortMinDown(1, pHandle->m_minEdges[1], false);
SortMaxDown(1, pHandle->m_maxEdges[1], false); sortMaxDown(1, pHandle->m_maxEdges[1], false);
SortMinDown(2, pHandle->m_minEdges[2], true); sortMinDown(2, pHandle->m_minEdges[2], true);
SortMaxDown(2, pHandle->m_maxEdges[2], true); sortMaxDown(2, pHandle->m_maxEdges[2], true);
//PrintAxis(1); //PrintAxis(1);
@@ -208,14 +208,14 @@ unsigned short btAxisSweep3::AddHandle(const btPoint3& aabbMin,const btPoint3& a
} }
void btAxisSweep3::RemoveHandle(unsigned short handle) void btAxisSweep3::removeHandle(unsigned short handle)
{ {
Handle* pHandle = GetHandle(handle); Handle* pHandle = getHandle(handle);
//explicitly remove the pairs containing the proxy //explicitly remove the pairs containing the proxy
//we could do it also in the SortMinUp (passing true) //we could do it also in the sortMinUp (passing true)
//todo: compare performance //todo: compare performance
RemoveOverlappingPairsContainingProxy(pHandle); removeOverlappingPairsContainingProxy(pHandle);
// compute current limit of edge arrays // compute current limit of edge arrays
@@ -238,12 +238,12 @@ void btAxisSweep3::RemoveHandle(unsigned short handle)
int max = pHandle->m_maxEdges[axis]; int max = pHandle->m_maxEdges[axis];
pEdges[max].m_pos = 0xffff; pEdges[max].m_pos = 0xffff;
SortMaxUp(axis,max,false); sortMaxUp(axis,max,false);
int i = pHandle->m_minEdges[axis]; int i = pHandle->m_minEdges[axis];
pEdges[i].m_pos = 0xffff; pEdges[i].m_pos = 0xffff;
SortMinUp(axis,i,false); sortMinUp(axis,i,false);
pEdges[limit-1].m_handle = 0; pEdges[limit-1].m_handle = 0;
pEdges[limit-1].m_pos = 0xffff; pEdges[limit-1].m_pos = 0xffff;
@@ -251,12 +251,12 @@ void btAxisSweep3::RemoveHandle(unsigned short handle)
} }
// free the handle // free the handle
FreeHandle(handle); freeHandle(handle);
} }
bool btAxisSweep3::TestOverlap(int ignoreAxis,const Handle* pHandleA, const Handle* pHandleB) bool btAxisSweep3::testOverlap(int ignoreAxis,const Handle* pHandleA, const Handle* pHandleB)
{ {
//optimization 1: check the array index (memory address), instead of the m_pos //optimization 1: check the array index (memory address), instead of the m_pos
@@ -287,17 +287,17 @@ bool btAxisSweep3::TestOverlap(int ignoreAxis,const Handle* pHandleA, const Hand
return true; return true;
} }
void btAxisSweep3::UpdateHandle(unsigned short handle, const btPoint3& aabbMin,const btPoint3& aabbMax) void btAxisSweep3::updateHandle(unsigned short handle, const btPoint3& aabbMin,const btPoint3& aabbMax)
{ {
// assert(bounds.IsFinite()); // assert(bounds.IsFinite());
//assert(bounds.HasVolume()); //assert(bounds.HasVolume());
Handle* pHandle = GetHandle(handle); Handle* pHandle = getHandle(handle);
// quantize the new bounds // quantize the new bounds
unsigned short min[3], max[3]; unsigned short min[3], max[3];
Quantize(min, aabbMin, 0); quantize(min, aabbMin, 0);
Quantize(max, aabbMax, 1); quantize(max, aabbMax, 1);
// update changed edges // update changed edges
for (int axis = 0; axis < 3; axis++) for (int axis = 0; axis < 3; axis++)
@@ -313,39 +313,39 @@ void btAxisSweep3::UpdateHandle(unsigned short handle, const btPoint3& aabbMin,c
// expand (only adds overlaps) // expand (only adds overlaps)
if (dmin < 0) if (dmin < 0)
SortMinDown(axis, emin); sortMinDown(axis, emin);
if (dmax > 0) if (dmax > 0)
SortMaxUp(axis, emax); sortMaxUp(axis, emax);
// shrink (only removes overlaps) // shrink (only removes overlaps)
if (dmin > 0) if (dmin > 0)
SortMinUp(axis, emin); sortMinUp(axis, emin);
if (dmax < 0) if (dmax < 0)
SortMaxDown(axis, emax); sortMaxDown(axis, emax);
} }
//PrintAxis(1); //PrintAxis(1);
} }
// sorting a min edge downwards can only ever *add* overlaps // sorting a min edge downwards can only ever *add* overlaps
void btAxisSweep3::SortMinDown(int axis, unsigned short edge, bool updateOverlaps) void btAxisSweep3::sortMinDown(int axis, unsigned short edge, bool updateOverlaps)
{ {
Edge* pEdge = m_pEdges[axis] + edge; Edge* pEdge = m_pEdges[axis] + edge;
Edge* pPrev = pEdge - 1; Edge* pPrev = pEdge - 1;
Handle* pHandleEdge = GetHandle(pEdge->m_handle); Handle* pHandleEdge = getHandle(pEdge->m_handle);
while (pEdge->m_pos < pPrev->m_pos) while (pEdge->m_pos < pPrev->m_pos)
{ {
Handle* pHandlePrev = GetHandle(pPrev->m_handle); Handle* pHandlePrev = getHandle(pPrev->m_handle);
if (pPrev->IsMax()) if (pPrev->IsMax())
{ {
// if previous edge is a maximum check the bounds and add an overlap if necessary // if previous edge is a maximum check the bounds and add an overlap if necessary
if (updateOverlaps && TestOverlap(axis,pHandleEdge, pHandlePrev)) if (updateOverlaps && testOverlap(axis,pHandleEdge, pHandlePrev))
{ {
AddOverlappingPair(pHandleEdge,pHandlePrev); addOverlappingPair(pHandleEdge,pHandlePrev);
//AddOverlap(pEdge->m_handle, pPrev->m_handle); //AddOverlap(pEdge->m_handle, pPrev->m_handle);
@@ -371,25 +371,25 @@ void btAxisSweep3::SortMinDown(int axis, unsigned short edge, bool updateOverlap
} }
// sorting a min edge upwards can only ever *remove* overlaps // sorting a min edge upwards can only ever *remove* overlaps
void btAxisSweep3::SortMinUp(int axis, unsigned short edge, bool updateOverlaps) void btAxisSweep3::sortMinUp(int axis, unsigned short edge, bool updateOverlaps)
{ {
Edge* pEdge = m_pEdges[axis] + edge; Edge* pEdge = m_pEdges[axis] + edge;
Edge* pNext = pEdge + 1; Edge* pNext = pEdge + 1;
Handle* pHandleEdge = GetHandle(pEdge->m_handle); Handle* pHandleEdge = getHandle(pEdge->m_handle);
while (pEdge->m_pos > pNext->m_pos) while (pEdge->m_pos > pNext->m_pos)
{ {
Handle* pHandleNext = GetHandle(pNext->m_handle); Handle* pHandleNext = getHandle(pNext->m_handle);
if (pNext->IsMax()) if (pNext->IsMax())
{ {
// if next edge is maximum remove any overlap between the two handles // if next edge is maximum remove any overlap between the two handles
if (updateOverlaps) if (updateOverlaps)
{ {
Handle* handle0 = GetHandle(pEdge->m_handle); Handle* handle0 = getHandle(pEdge->m_handle);
Handle* handle1 = GetHandle(pNext->m_handle); Handle* handle1 = getHandle(pNext->m_handle);
btBroadphasePair tmpPair(*handle0,*handle1); btBroadphasePair tmpPair(*handle0,*handle1);
RemoveOverlappingPair(tmpPair); removeOverlappingPair(tmpPair);
} }
@@ -413,29 +413,29 @@ void btAxisSweep3::SortMinUp(int axis, unsigned short edge, bool updateOverlaps)
} }
// sorting a max edge downwards can only ever *remove* overlaps // sorting a max edge downwards can only ever *remove* overlaps
void btAxisSweep3::SortMaxDown(int axis, unsigned short edge, bool updateOverlaps) void btAxisSweep3::sortMaxDown(int axis, unsigned short edge, bool updateOverlaps)
{ {
Edge* pEdge = m_pEdges[axis] + edge; Edge* pEdge = m_pEdges[axis] + edge;
Edge* pPrev = pEdge - 1; Edge* pPrev = pEdge - 1;
Handle* pHandleEdge = GetHandle(pEdge->m_handle); Handle* pHandleEdge = getHandle(pEdge->m_handle);
while (pEdge->m_pos < pPrev->m_pos) while (pEdge->m_pos < pPrev->m_pos)
{ {
Handle* pHandlePrev = GetHandle(pPrev->m_handle); Handle* pHandlePrev = getHandle(pPrev->m_handle);
if (!pPrev->IsMax()) if (!pPrev->IsMax())
{ {
// if previous edge was a minimum remove any overlap between the two handles // if previous edge was a minimum remove any overlap between the two handles
if (updateOverlaps) if (updateOverlaps)
{ {
Handle* handle0 = GetHandle(pEdge->m_handle); Handle* handle0 = getHandle(pEdge->m_handle);
Handle* handle1 = GetHandle(pPrev->m_handle); Handle* handle1 = getHandle(pPrev->m_handle);
btBroadphasePair* pair = FindPair(handle0,handle1); btBroadphasePair* pair = findPair(handle0,handle1);
//assert(pair); //assert(pair);
if (pair) if (pair)
{ {
RemoveOverlappingPair(*pair); removeOverlappingPair(*pair);
} }
} }
@@ -459,24 +459,24 @@ void btAxisSweep3::SortMaxDown(int axis, unsigned short edge, bool updateOverlap
} }
// sorting a max edge upwards can only ever *add* overlaps // sorting a max edge upwards can only ever *add* overlaps
void btAxisSweep3::SortMaxUp(int axis, unsigned short edge, bool updateOverlaps) void btAxisSweep3::sortMaxUp(int axis, unsigned short edge, bool updateOverlaps)
{ {
Edge* pEdge = m_pEdges[axis] + edge; Edge* pEdge = m_pEdges[axis] + edge;
Edge* pNext = pEdge + 1; Edge* pNext = pEdge + 1;
Handle* pHandleEdge = GetHandle(pEdge->m_handle); Handle* pHandleEdge = getHandle(pEdge->m_handle);
while (pEdge->m_pos > pNext->m_pos) while (pEdge->m_pos > pNext->m_pos)
{ {
Handle* pHandleNext = GetHandle(pNext->m_handle); Handle* pHandleNext = getHandle(pNext->m_handle);
if (!pNext->IsMax()) if (!pNext->IsMax())
{ {
// if next edge is a minimum check the bounds and add an overlap if necessary // if next edge is a minimum check the bounds and add an overlap if necessary
if (updateOverlaps && TestOverlap(axis, pHandleEdge, pHandleNext)) if (updateOverlaps && testOverlap(axis, pHandleEdge, pHandleNext))
{ {
Handle* handle0 = GetHandle(pEdge->m_handle); Handle* handle0 = getHandle(pEdge->m_handle);
Handle* handle1 = GetHandle(pNext->m_handle); Handle* handle1 = getHandle(pNext->m_handle);
AddOverlappingPair(handle0,handle1); addOverlappingPair(handle0,handle1);
} }
// update edge reference in other handle // update edge reference in other handle

View File

@@ -26,7 +26,7 @@
/// btAxisSweep3 is an efficient implementation of the 3d axis sweep and prune broadphase. /// btAxisSweep3 is an efficient implementation of the 3d axis sweep and prune broadphase.
/// It uses arrays rather then lists for storage of the 3 axis. Also it operates using integer coordinates instead of floats. /// It uses arrays rather then lists for storage of the 3 axis. Also it operates using integer coordinates instead of floats.
/// The TestOverlap check is optimized to check the array index, rather then the actual AABB coordinates/pos /// The testOverlap check is optimized to check the array index, rather then the actual AABB coordinates/pos
class btAxisSweep3 : public btOverlappingPairCache class btAxisSweep3 : public btOverlappingPairCache
{ {
@@ -74,41 +74,41 @@ private:
// allocation/deallocation // allocation/deallocation
unsigned short AllocHandle(); unsigned short allocHandle();
void FreeHandle(unsigned short handle); void freeHandle(unsigned short handle);
bool TestOverlap(int ignoreAxis,const Handle* pHandleA, const Handle* pHandleB); bool testOverlap(int ignoreAxis,const Handle* pHandleA, const Handle* pHandleB);
//Overlap* AddOverlap(unsigned short handleA, unsigned short handleB); //Overlap* AddOverlap(unsigned short handleA, unsigned short handleB);
//void RemoveOverlap(unsigned short handleA, unsigned short handleB); //void RemoveOverlap(unsigned short handleA, unsigned short handleB);
void Quantize(unsigned short* out, const btPoint3& point, int isMax) const; void quantize(unsigned short* out, const btPoint3& point, int isMax) const;
void SortMinDown(int axis, unsigned short edge, bool updateOverlaps = true); void sortMinDown(int axis, unsigned short edge, bool updateOverlaps = true);
void SortMinUp(int axis, unsigned short edge, bool updateOverlaps = true); void sortMinUp(int axis, unsigned short edge, bool updateOverlaps = true);
void SortMaxDown(int axis, unsigned short edge, bool updateOverlaps = true); void sortMaxDown(int axis, unsigned short edge, bool updateOverlaps = true);
void SortMaxUp(int axis, unsigned short edge, bool updateOverlaps = true); void sortMaxUp(int axis, unsigned short edge, bool updateOverlaps = true);
public: public:
btAxisSweep3(const btPoint3& worldAabbMin,const btPoint3& worldAabbMax, int maxHandles = 16384); btAxisSweep3(const btPoint3& worldAabbMin,const btPoint3& worldAabbMax, int maxHandles = 16384);
virtual ~btAxisSweep3(); virtual ~btAxisSweep3();
virtual void RefreshOverlappingPairs() virtual void refreshOverlappingPairs()
{ {
//this is replace by sweep and prune //this is replace by sweep and prune
} }
unsigned short AddHandle(const btPoint3& aabbMin,const btPoint3& aabbMax, void* pOwner,short int collisionFilterGroup,short int collisionFilterMask); unsigned short addHandle(const btPoint3& aabbMin,const btPoint3& aabbMax, void* pOwner,short int collisionFilterGroup,short int collisionFilterMask);
void RemoveHandle(unsigned short handle); void removeHandle(unsigned short handle);
void UpdateHandle(unsigned short handle, const btPoint3& aabbMin,const btPoint3& aabbMax); void updateHandle(unsigned short handle, const btPoint3& aabbMin,const btPoint3& aabbMax);
inline Handle* GetHandle(unsigned short index) const {return m_pHandles + index;} inline Handle* getHandle(unsigned short index) const {return m_pHandles + index;}
//Broadphase Interface //Broadphase Interface
virtual btBroadphaseProxy* CreateProxy( const btVector3& min, const btVector3& max,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask); virtual btBroadphaseProxy* createProxy( const btVector3& min, const btVector3& max,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask);
virtual void DestroyProxy(btBroadphaseProxy* proxy); virtual void destroyProxy(btBroadphaseProxy* proxy);
virtual void SetAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax); virtual void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax);
}; };

View File

@@ -29,10 +29,10 @@ class btBroadphaseInterface
public: public:
virtual ~btBroadphaseInterface() {} virtual ~btBroadphaseInterface() {}
virtual btBroadphaseProxy* CreateProxy( const btVector3& min, const btVector3& max,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask) =0; virtual btBroadphaseProxy* createProxy( const btVector3& min, const btVector3& max,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask) =0;
virtual void DestroyProxy(btBroadphaseProxy* proxy)=0; virtual void destroyProxy(btBroadphaseProxy* proxy)=0;
virtual void SetAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax)=0; virtual void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax)=0;
virtual void CleanProxyFromPairs(btBroadphaseProxy* proxy)=0; virtual void cleanProxyFromPairs(btBroadphaseProxy* proxy)=0;
}; };

View File

@@ -74,22 +74,22 @@ struct btBroadphaseProxy
{ {
} }
static inline bool IsPolyhedral(int proxyType) static inline bool isPolyhedral(int proxyType)
{ {
return (proxyType < IMPLICIT_CONVEX_SHAPES_START_HERE); return (proxyType < IMPLICIT_CONVEX_SHAPES_START_HERE);
} }
static inline bool IsConvex(int proxyType) static inline bool isConvex(int proxyType)
{ {
return (proxyType < CONCAVE_SHAPES_START_HERE); return (proxyType < CONCAVE_SHAPES_START_HERE);
} }
static inline bool IsConcave(int proxyType) static inline bool isConcave(int proxyType)
{ {
return ((proxyType > CONCAVE_SHAPES_START_HERE) && return ((proxyType > CONCAVE_SHAPES_START_HERE) &&
(proxyType < CONCAVE_SHAPES_END_HERE)); (proxyType < CONCAVE_SHAPES_END_HERE));
} }
static inline bool IsCompound(int proxyType) static inline bool isCompound(int proxyType)
{ {
return (proxyType == COMPOUND_SHAPE_PROXYTYPE); return (proxyType == COMPOUND_SHAPE_PROXYTYPE);
} }

View File

@@ -32,7 +32,7 @@ struct btCollisionAlgorithmConstructionInfo
btDispatcher* m_dispatcher; btDispatcher* m_dispatcher;
int GetDispatcherId(); int getDispatcherId();
}; };
@@ -47,7 +47,7 @@ protected:
btDispatcher* m_dispatcher; btDispatcher* m_dispatcher;
protected: protected:
int GetDispatcherId(); int getDispatcherId();
public: public:
@@ -57,9 +57,9 @@ public:
virtual ~btCollisionAlgorithm() {}; virtual ~btCollisionAlgorithm() {};
virtual void ProcessCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const struct btDispatcherInfo& dispatchInfo) = 0; virtual void processCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const struct btDispatcherInfo& dispatchInfo) = 0;
virtual float CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const struct btDispatcherInfo& dispatchInfo) = 0; virtual float calculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const struct btDispatcherInfo& dispatchInfo) = 0;
}; };

View File

@@ -66,32 +66,32 @@ class btDispatcher
public: public:
virtual ~btDispatcher() ; virtual ~btDispatcher() ;
virtual btCollisionAlgorithm* FindAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1) = 0; virtual btCollisionAlgorithm* findAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1) = 0;
// //
// asume dispatchers to have unique id's in the range [0..max dispacher] // asume dispatchers to have unique id's in the range [0..max dispacher]
// //
virtual int GetUniqueId() = 0; virtual int getUniqueId() = 0;
virtual btPersistentManifold* GetNewManifold(void* body0,void* body1)=0; virtual btPersistentManifold* getNewManifold(void* body0,void* body1)=0;
virtual void ReleaseManifold(btPersistentManifold* manifold)=0; virtual void releaseManifold(btPersistentManifold* manifold)=0;
virtual void ClearManifold(btPersistentManifold* manifold)=0; virtual void clearManifold(btPersistentManifold* manifold)=0;
virtual bool NeedsCollision(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1) = 0; virtual bool needsCollision(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1) = 0;
virtual bool NeedsResponse(const btCollisionObject& colObj0,const btCollisionObject& colObj1)=0; virtual bool needsResponse(const btCollisionObject& colObj0,const btCollisionObject& colObj1)=0;
virtual btManifoldResult* GetNewManifoldResult(btCollisionObject* obj0,btCollisionObject* obj1,btPersistentManifold* manifold) =0; virtual btManifoldResult* getNewManifoldResult(btCollisionObject* obj0,btCollisionObject* obj1,btPersistentManifold* manifold) =0;
virtual void ReleaseManifoldResult(btManifoldResult*)=0; virtual void releaseManifoldResult(btManifoldResult*)=0;
virtual void DispatchAllCollisionPairs(btOverlappingPairCache* pairCache,btDispatcherInfo& dispatchInfo)=0; virtual void dispatchAllCollisionPairs(btOverlappingPairCache* pairCache,btDispatcherInfo& dispatchInfo)=0;
virtual int GetNumManifolds() const = 0; virtual int getNumManifolds() const = 0;
virtual btPersistentManifold* GetManifoldByIndexInternal(int index) = 0; virtual btPersistentManifold* getManifoldByIndexInternal(int index) = 0;
}; };

View File

@@ -36,7 +36,7 @@ btOverlappingPairCache::~btOverlappingPairCache()
} }
void btOverlappingPairCache::RemoveOverlappingPair(btBroadphasePair& findPair) void btOverlappingPairCache::removeOverlappingPair(btBroadphasePair& findPair)
{ {
std::set<btBroadphasePair>::iterator it = m_overlappingPairSet.find(findPair); std::set<btBroadphasePair>::iterator it = m_overlappingPairSet.find(findPair);
@@ -46,13 +46,13 @@ void btOverlappingPairCache::RemoveOverlappingPair(btBroadphasePair& findPair)
{ {
gOverlappingPairs--; gOverlappingPairs--;
btBroadphasePair* pair = (btBroadphasePair*)(&(*it)); btBroadphasePair* pair = (btBroadphasePair*)(&(*it));
CleanOverlappingPair(*pair); cleanOverlappingPair(*pair);
m_overlappingPairSet.erase(it); m_overlappingPairSet.erase(it);
} }
} }
void btOverlappingPairCache::CleanOverlappingPair(btBroadphasePair& pair) void btOverlappingPairCache::cleanOverlappingPair(btBroadphasePair& pair)
{ {
for (int dispatcherId=0;dispatcherId<SIMPLE_MAX_ALGORITHMS;dispatcherId++) for (int dispatcherId=0;dispatcherId<SIMPLE_MAX_ALGORITHMS;dispatcherId++)
{ {
@@ -70,12 +70,12 @@ void btOverlappingPairCache::CleanOverlappingPair(btBroadphasePair& pair)
void btOverlappingPairCache::AddOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) void btOverlappingPairCache::addOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1)
{ {
//don't add overlap with own //don't add overlap with own
assert(proxy0 != proxy1); assert(proxy0 != proxy1);
if (!NeedsCollision(proxy0,proxy1)) if (!needsCollision(proxy0,proxy1))
return; return;
@@ -86,13 +86,13 @@ void btOverlappingPairCache::AddOverlappingPair(btBroadphaseProxy* proxy0,btBroa
} }
///this FindPair becomes really slow. Either sort the list to speedup the query, or ///this findPair becomes really slow. Either sort the list to speedup the query, or
///use a different solution. It is mainly used for Removing overlapping pairs. Removal could be delayed. ///use a different solution. It is mainly used for Removing overlapping pairs. Removal could be delayed.
///we could keep a linked list in each proxy, and store pair in one of the proxies (with lowest memory address) ///we could keep a linked list in each proxy, and store pair in one of the proxies (with lowest memory address)
///Also we can use a 2D bitmap, which can be useful for a future GPU implementation ///Also we can use a 2D bitmap, which can be useful for a future GPU implementation
btBroadphasePair* btOverlappingPairCache::FindPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) btBroadphasePair* btOverlappingPairCache::findPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1)
{ {
if (!NeedsCollision(proxy0,proxy1)) if (!needsCollision(proxy0,proxy1))
return 0; return 0;
btBroadphasePair tmpPair(*proxy0,*proxy1); btBroadphasePair tmpPair(*proxy0,*proxy1);
@@ -109,7 +109,7 @@ void btOverlappingPairCache::AddOverlappingPair(btBroadphaseProxy* proxy0,btBroa
void btOverlappingPairCache::CleanProxyFromPairs(btBroadphaseProxy* proxy) void btOverlappingPairCache::cleanProxyFromPairs(btBroadphaseProxy* proxy)
{ {
class CleanPairCallback : public btOverlapCallback class CleanPairCallback : public btOverlapCallback
@@ -123,12 +123,12 @@ void btOverlappingPairCache::CleanProxyFromPairs(btBroadphaseProxy* proxy)
m_pairCache(pairCache) m_pairCache(pairCache)
{ {
} }
virtual bool ProcessOverlap(btBroadphasePair& pair) virtual bool processOverlap(btBroadphasePair& pair)
{ {
if ((pair.m_pProxy0 == m_cleanProxy) || if ((pair.m_pProxy0 == m_cleanProxy) ||
(pair.m_pProxy1 == m_cleanProxy)) (pair.m_pProxy1 == m_cleanProxy))
{ {
m_pairCache->CleanOverlappingPair(pair); m_pairCache->cleanOverlappingPair(pair);
} }
return false; return false;
} }
@@ -137,13 +137,13 @@ void btOverlappingPairCache::CleanProxyFromPairs(btBroadphaseProxy* proxy)
CleanPairCallback cleanPairs(proxy,this); CleanPairCallback cleanPairs(proxy,this);
ProcessAllOverlappingPairs(&cleanPairs); processAllOverlappingPairs(&cleanPairs);
} }
void btOverlappingPairCache::RemoveOverlappingPairsContainingProxy(btBroadphaseProxy* proxy) void btOverlappingPairCache::removeOverlappingPairsContainingProxy(btBroadphaseProxy* proxy)
{ {
class RemovePairCallback : public btOverlapCallback class RemovePairCallback : public btOverlapCallback
@@ -155,7 +155,7 @@ void btOverlappingPairCache::RemoveOverlappingPairsContainingProxy(btBroadphaseP
:m_obsoleteProxy(obsoleteProxy) :m_obsoleteProxy(obsoleteProxy)
{ {
} }
virtual bool ProcessOverlap(btBroadphasePair& pair) virtual bool processOverlap(btBroadphasePair& pair)
{ {
return ((pair.m_pProxy0 == m_obsoleteProxy) || return ((pair.m_pProxy0 == m_obsoleteProxy) ||
(pair.m_pProxy1 == m_obsoleteProxy)); (pair.m_pProxy1 == m_obsoleteProxy));
@@ -166,21 +166,21 @@ void btOverlappingPairCache::RemoveOverlappingPairsContainingProxy(btBroadphaseP
RemovePairCallback removeCallback(proxy); RemovePairCallback removeCallback(proxy);
ProcessAllOverlappingPairs(&removeCallback); processAllOverlappingPairs(&removeCallback);
} }
void btOverlappingPairCache::ProcessAllOverlappingPairs(btOverlapCallback* callback) void btOverlappingPairCache::processAllOverlappingPairs(btOverlapCallback* callback)
{ {
std::set<btBroadphasePair>::iterator it = m_overlappingPairSet.begin(); std::set<btBroadphasePair>::iterator it = m_overlappingPairSet.begin();
for (; !(it==m_overlappingPairSet.end());) for (; !(it==m_overlappingPairSet.end());)
{ {
btBroadphasePair* pair = (btBroadphasePair*)(&(*it)); btBroadphasePair* pair = (btBroadphasePair*)(&(*it));
if (callback->ProcessOverlap(*pair)) if (callback->processOverlap(*pair))
{ {
CleanOverlappingPair(*pair); cleanOverlappingPair(*pair);
std::set<btBroadphasePair>::iterator it2 = it; std::set<btBroadphasePair>::iterator it2 = it;
//why does next line not compile under OS X?? //why does next line not compile under OS X??

View File

@@ -30,7 +30,7 @@ virtual ~btOverlapCallback()
{ {
} }
//return true for deletion of the pair //return true for deletion of the pair
virtual bool ProcessOverlap(btBroadphasePair& pair) = 0; virtual bool processOverlap(btBroadphasePair& pair) = 0;
}; };
///OverlappingPairCache maintains the objects with overlapping AABB ///OverlappingPairCache maintains the objects with overlapping AABB
@@ -48,23 +48,23 @@ class btOverlappingPairCache : public btBroadphaseInterface
btOverlappingPairCache(); btOverlappingPairCache();
virtual ~btOverlappingPairCache(); virtual ~btOverlappingPairCache();
void ProcessAllOverlappingPairs(btOverlapCallback*); void processAllOverlappingPairs(btOverlapCallback*);
void RemoveOverlappingPair(btBroadphasePair& pair); void removeOverlappingPair(btBroadphasePair& pair);
void CleanOverlappingPair(btBroadphasePair& pair); void cleanOverlappingPair(btBroadphasePair& pair);
void AddOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1); void addOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);
btBroadphasePair* FindPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1); btBroadphasePair* findPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);
void CleanProxyFromPairs(btBroadphaseProxy* proxy); void cleanProxyFromPairs(btBroadphaseProxy* proxy);
void RemoveOverlappingPairsContainingProxy(btBroadphaseProxy* proxy); void removeOverlappingPairsContainingProxy(btBroadphaseProxy* proxy);
inline bool NeedsCollision(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) const inline bool needsCollision(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) const
{ {
bool collides = proxy0->m_collisionFilterGroup & proxy1->m_collisionFilterMask; bool collides = proxy0->m_collisionFilterGroup & proxy1->m_collisionFilterMask;
collides = collides && (proxy1->m_collisionFilterGroup & proxy0->m_collisionFilterMask); collides = collides && (proxy1->m_collisionFilterGroup & proxy0->m_collisionFilterMask);
@@ -74,7 +74,7 @@ class btOverlappingPairCache : public btBroadphaseInterface
virtual void RefreshOverlappingPairs() =0; virtual void refreshOverlappingPairs() =0;

View File

@@ -70,7 +70,7 @@ btSimpleBroadphase::~btSimpleBroadphase()
} }
btBroadphaseProxy* btSimpleBroadphase::CreateProxy( const btVector3& min, const btVector3& max,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask) btBroadphaseProxy* btSimpleBroadphase::createProxy( const btVector3& min, const btVector3& max,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask)
{ {
if (m_numProxies >= m_maxProxies) if (m_numProxies >= m_maxProxies)
{ {
@@ -98,7 +98,7 @@ btBroadphaseProxy* btSimpleBroadphase::CreateProxy( const btVector3& min, cons
class RemovingOverlapCallback : public btOverlapCallback class RemovingOverlapCallback : public btOverlapCallback
{ {
protected: protected:
virtual bool ProcessOverlap(btBroadphasePair& pair) virtual bool processOverlap(btBroadphasePair& pair)
{ {
assert(0); assert(0);
} }
@@ -113,7 +113,7 @@ class RemovePairContainingProxy
{ {
} }
protected: protected:
virtual bool ProcessOverlap(btBroadphasePair& pair) virtual bool processOverlap(btBroadphasePair& pair)
{ {
btSimpleBroadphaseProxy* proxy0 = static_cast<btSimpleBroadphaseProxy*>(pair.m_pProxy0); btSimpleBroadphaseProxy* proxy0 = static_cast<btSimpleBroadphaseProxy*>(pair.m_pProxy0);
btSimpleBroadphaseProxy* proxy1 = static_cast<btSimpleBroadphaseProxy*>(pair.m_pProxy1); btSimpleBroadphaseProxy* proxy1 = static_cast<btSimpleBroadphaseProxy*>(pair.m_pProxy1);
@@ -122,7 +122,7 @@ protected:
}; };
}; };
void btSimpleBroadphase::DestroyProxy(btBroadphaseProxy* proxyOrg) void btSimpleBroadphase::destroyProxy(btBroadphaseProxy* proxyOrg)
{ {
int i; int i;
@@ -134,7 +134,7 @@ void btSimpleBroadphase::DestroyProxy(btBroadphaseProxy* proxyOrg)
assert (index < m_maxProxies); assert (index < m_maxProxies);
m_freeProxies[--m_firstFreeProxy] = index; m_freeProxies[--m_firstFreeProxy] = index;
//RemoveOverlappingPairsContainingProxy(proxyOrg); //removeOverlappingPairsContainingProxy(proxyOrg);
assert(0); assert(0);
//then remove non-overlapping ones //then remove non-overlapping ones
@@ -142,11 +142,11 @@ void btSimpleBroadphase::DestroyProxy(btBroadphaseProxy* proxyOrg)
{ {
btBroadphasePair& pair = GetOverlappingPair(i); btBroadphasePair& pair = GetOverlappingPair(i);
btSimpleBroadphaseProxy* proxy0 = GetSimpleProxyFromProxy(pair.m_pProxy0); btSimpleBroadphaseProxy* proxy0 = getSimpleProxyFromProxy(pair.m_pProxy0);
btSimpleBroadphaseProxy* proxy1 = GetSimpleProxyFromProxy(pair.m_pProxy1); btSimpleBroadphaseProxy* proxy1 = getSimpleProxyFromProxy(pair.m_pProxy1);
if ((proxy0==proxyOrg) || (proxy1==proxyOrg)) if ((proxy0==proxyOrg) || (proxy1==proxyOrg))
{ {
RemoveOverlappingPair(pair); removeOverlappingPair(pair);
} }
} }
*/ */
@@ -167,9 +167,9 @@ void btSimpleBroadphase::DestroyProxy(btBroadphaseProxy* proxyOrg)
} }
void btSimpleBroadphase::SetAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax) void btSimpleBroadphase::setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax)
{ {
btSimpleBroadphaseProxy* sbp = GetSimpleProxyFromProxy(proxy); btSimpleBroadphaseProxy* sbp = getSimpleProxyFromProxy(proxy);
sbp->m_min = aabbMin; sbp->m_min = aabbMin;
sbp->m_max = aabbMax; sbp->m_max = aabbMax;
} }
@@ -182,7 +182,7 @@ void btSimpleBroadphase::SetAabb(btBroadphaseProxy* proxy,const btVector3& aabbM
bool btSimpleBroadphase::AabbOverlap(btSimpleBroadphaseProxy* proxy0,btSimpleBroadphaseProxy* proxy1) bool btSimpleBroadphase::aabbOverlap(btSimpleBroadphaseProxy* proxy0,btSimpleBroadphaseProxy* proxy1)
{ {
return proxy0->m_min[0] <= proxy1->m_max[0] && proxy1->m_min[0] <= proxy0->m_max[0] && return proxy0->m_min[0] <= proxy1->m_max[0] && proxy1->m_min[0] <= proxy0->m_max[0] &&
proxy0->m_min[1] <= proxy1->m_max[1] && proxy1->m_min[1] <= proxy0->m_max[1] && proxy0->m_min[1] <= proxy1->m_max[1] && proxy1->m_min[1] <= proxy0->m_max[1] &&
@@ -196,13 +196,13 @@ bool btSimpleBroadphase::AabbOverlap(btSimpleBroadphaseProxy* proxy0,btSimpleBro
class CheckOverlapCallback : public btOverlapCallback class CheckOverlapCallback : public btOverlapCallback
{ {
public: public:
virtual bool ProcessOverlap(btBroadphasePair& pair) virtual bool processOverlap(btBroadphasePair& pair)
{ {
return (!btSimpleBroadphase::AabbOverlap(static_cast<btSimpleBroadphaseProxy*>(pair.m_pProxy0),static_cast<btSimpleBroadphaseProxy*>(pair.m_pProxy1))); return (!btSimpleBroadphase::aabbOverlap(static_cast<btSimpleBroadphaseProxy*>(pair.m_pProxy0),static_cast<btSimpleBroadphaseProxy*>(pair.m_pProxy1)));
} }
}; };
void btSimpleBroadphase::RefreshOverlappingPairs() void btSimpleBroadphase::refreshOverlappingPairs()
{ {
//first check for new overlapping pairs //first check for new overlapping pairs
int i,j; int i,j;
@@ -213,14 +213,14 @@ void btSimpleBroadphase::RefreshOverlappingPairs()
for (j=i+1;j<m_numProxies;j++) for (j=i+1;j<m_numProxies;j++)
{ {
btBroadphaseProxy* proxy1 = m_pProxies[j]; btBroadphaseProxy* proxy1 = m_pProxies[j];
btSimpleBroadphaseProxy* p0 = GetSimpleProxyFromProxy(proxy0); btSimpleBroadphaseProxy* p0 = getSimpleProxyFromProxy(proxy0);
btSimpleBroadphaseProxy* p1 = GetSimpleProxyFromProxy(proxy1); btSimpleBroadphaseProxy* p1 = getSimpleProxyFromProxy(proxy1);
if (AabbOverlap(p0,p1)) if (aabbOverlap(p0,p1))
{ {
if ( !FindPair(proxy0,proxy1)) if ( !findPair(proxy0,proxy1))
{ {
AddOverlappingPair(proxy0,proxy1); addOverlappingPair(proxy0,proxy1);
} }
} }
@@ -230,7 +230,7 @@ void btSimpleBroadphase::RefreshOverlappingPairs()
CheckOverlapCallback checkOverlap; CheckOverlapCallback checkOverlap;
ProcessAllOverlappingPairs(&checkOverlap); processAllOverlappingPairs(&checkOverlap);
} }

View File

@@ -52,7 +52,7 @@ class btSimpleBroadphase : public btOverlappingPairCache
int m_maxProxies; int m_maxProxies;
inline btSimpleBroadphaseProxy* GetSimpleProxyFromProxy(btBroadphaseProxy* proxy) inline btSimpleBroadphaseProxy* getSimpleProxyFromProxy(btBroadphaseProxy* proxy)
{ {
btSimpleBroadphaseProxy* proxy0 = static_cast<btSimpleBroadphaseProxy*>(proxy); btSimpleBroadphaseProxy* proxy0 = static_cast<btSimpleBroadphaseProxy*>(proxy);
return proxy0; return proxy0;
@@ -64,20 +64,20 @@ class btSimpleBroadphase : public btOverlappingPairCache
protected: protected:
virtual void RefreshOverlappingPairs(); virtual void refreshOverlappingPairs();
public: public:
btSimpleBroadphase(int maxProxies=16384); btSimpleBroadphase(int maxProxies=16384);
virtual ~btSimpleBroadphase(); virtual ~btSimpleBroadphase();
static bool AabbOverlap(btSimpleBroadphaseProxy* proxy0,btSimpleBroadphaseProxy* proxy1); static bool aabbOverlap(btSimpleBroadphaseProxy* proxy0,btSimpleBroadphaseProxy* proxy1);
virtual btBroadphaseProxy* CreateProxy( const btVector3& min, const btVector3& max,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask); virtual btBroadphaseProxy* createProxy( const btVector3& min, const btVector3& max,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask);
virtual void DestroyProxy(btBroadphaseProxy* proxy); virtual void destroyProxy(btBroadphaseProxy* proxy);
virtual void SetAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax); virtual void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax);

View File

@@ -52,7 +52,7 @@ btCollisionDispatcher::btCollisionDispatcher ():
{ {
for (int j=0;j<MAX_BROADPHASE_COLLISION_TYPES;j++) for (int j=0;j<MAX_BROADPHASE_COLLISION_TYPES;j++)
{ {
m_doubleDispatch[i][j] = InternalFindCreateFunc(i,j); m_doubleDispatch[i][j] = internalFindCreateFunc(i,j);
assert(m_doubleDispatch[i][j]); assert(m_doubleDispatch[i][j]);
} }
} }
@@ -60,7 +60,7 @@ btCollisionDispatcher::btCollisionDispatcher ():
}; };
void btCollisionDispatcher::RegisterCollisionCreateFunc(int proxyType0, int proxyType1, btCollisionAlgorithmCreateFunc *createFunc) void btCollisionDispatcher::registerCollisionCreateFunc(int proxyType0, int proxyType1, btCollisionAlgorithmCreateFunc *createFunc)
{ {
m_doubleDispatch[proxyType0][proxyType1] = createFunc; m_doubleDispatch[proxyType0][proxyType1] = createFunc;
} }
@@ -75,7 +75,7 @@ btCollisionDispatcher::~btCollisionDispatcher()
delete m_emptyCreateFunc; delete m_emptyCreateFunc;
} }
btPersistentManifold* btCollisionDispatcher::GetNewManifold(void* b0,void* b1) btPersistentManifold* btCollisionDispatcher::getNewManifold(void* b0,void* b1)
{ {
gNumManifold++; gNumManifold++;
@@ -91,20 +91,20 @@ btPersistentManifold* btCollisionDispatcher::GetNewManifold(void* b0,void* b1)
return manifold; return manifold;
} }
void btCollisionDispatcher::ClearManifold(btPersistentManifold* manifold) void btCollisionDispatcher::clearManifold(btPersistentManifold* manifold)
{ {
manifold->ClearManifold(); manifold->clearManifold();
} }
void btCollisionDispatcher::ReleaseManifold(btPersistentManifold* manifold) void btCollisionDispatcher::releaseManifold(btPersistentManifold* manifold)
{ {
gNumManifold--; gNumManifold--;
//printf("ReleaseManifold: gNumManifold %d\n",gNumManifold); //printf("releaseManifold: gNumManifold %d\n",gNumManifold);
ClearManifold(manifold); clearManifold(manifold);
std::vector<btPersistentManifold*>::iterator i = std::vector<btPersistentManifold*>::iterator i =
std::find(m_manifoldsPtr.begin(), m_manifoldsPtr.end(), manifold); std::find(m_manifoldsPtr.begin(), m_manifoldsPtr.end(), manifold);
@@ -121,7 +121,7 @@ void btCollisionDispatcher::ReleaseManifold(btPersistentManifold* manifold)
btCollisionAlgorithm* btCollisionDispatcher::FindAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1) btCollisionAlgorithm* btCollisionDispatcher::findAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1)
{ {
#define USE_DISPATCH_REGISTRY_ARRAY 1 #define USE_DISPATCH_REGISTRY_ARRAY 1
#ifdef USE_DISPATCH_REGISTRY_ARRAY #ifdef USE_DISPATCH_REGISTRY_ARRAY
@@ -129,39 +129,39 @@ btCollisionAlgorithm* btCollisionDispatcher::FindAlgorithm(btBroadphaseProxy& pr
btCollisionObject* body1 = (btCollisionObject*)proxy1.m_clientObject; btCollisionObject* body1 = (btCollisionObject*)proxy1.m_clientObject;
btCollisionAlgorithmConstructionInfo ci; btCollisionAlgorithmConstructionInfo ci;
ci.m_dispatcher = this; ci.m_dispatcher = this;
btCollisionAlgorithm* algo = m_doubleDispatch[body0->m_collisionShape->GetShapeType()][body1->m_collisionShape->GetShapeType()] btCollisionAlgorithm* algo = m_doubleDispatch[body0->m_collisionShape->getShapeType()][body1->m_collisionShape->getShapeType()]
->CreateCollisionAlgorithm(ci,&proxy0,&proxy1); ->CreateCollisionAlgorithm(ci,&proxy0,&proxy1);
#else #else
btCollisionAlgorithm* algo = InternalFindAlgorithm(proxy0,proxy1); btCollisionAlgorithm* algo = internalFindAlgorithm(proxy0,proxy1);
#endif //USE_DISPATCH_REGISTRY_ARRAY #endif //USE_DISPATCH_REGISTRY_ARRAY
return algo; return algo;
} }
btCollisionAlgorithmCreateFunc* btCollisionDispatcher::InternalFindCreateFunc(int proxyType0,int proxyType1) btCollisionAlgorithmCreateFunc* btCollisionDispatcher::internalFindCreateFunc(int proxyType0,int proxyType1)
{ {
if (btBroadphaseProxy::IsConvex(proxyType0) && btBroadphaseProxy::IsConvex(proxyType1)) if (btBroadphaseProxy::isConvex(proxyType0) && btBroadphaseProxy::isConvex(proxyType1))
{ {
return m_convexConvexCreateFunc; return m_convexConvexCreateFunc;
} }
if (btBroadphaseProxy::IsConvex(proxyType0) && btBroadphaseProxy::IsConcave(proxyType1)) if (btBroadphaseProxy::isConvex(proxyType0) && btBroadphaseProxy::isConcave(proxyType1))
{ {
return m_convexConcaveCreateFunc; return m_convexConcaveCreateFunc;
} }
if (btBroadphaseProxy::IsConvex(proxyType1) && btBroadphaseProxy::IsConcave(proxyType0)) if (btBroadphaseProxy::isConvex(proxyType1) && btBroadphaseProxy::isConcave(proxyType0))
{ {
return m_swappedConvexConcaveCreateFunc; return m_swappedConvexConcaveCreateFunc;
} }
if (btBroadphaseProxy::IsCompound(proxyType0)) if (btBroadphaseProxy::isCompound(proxyType0))
{ {
return m_compoundCreateFunc; return m_compoundCreateFunc;
} else } else
{ {
if (btBroadphaseProxy::IsCompound(proxyType1)) if (btBroadphaseProxy::isCompound(proxyType1))
{ {
return m_swappedCompoundCreateFunc; return m_swappedCompoundCreateFunc;
} }
@@ -173,7 +173,7 @@ btCollisionAlgorithmCreateFunc* btCollisionDispatcher::InternalFindCreateFunc(in
btCollisionAlgorithm* btCollisionDispatcher::InternalFindAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1) btCollisionAlgorithm* btCollisionDispatcher::internalFindAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1)
{ {
m_count++; m_count++;
btCollisionObject* body0 = (btCollisionObject*)proxy0.m_clientObject; btCollisionObject* body0 = (btCollisionObject*)proxy0.m_clientObject;
@@ -182,27 +182,27 @@ btCollisionAlgorithm* btCollisionDispatcher::InternalFindAlgorithm(btBroadphaseP
btCollisionAlgorithmConstructionInfo ci; btCollisionAlgorithmConstructionInfo ci;
ci.m_dispatcher = this; ci.m_dispatcher = this;
if (body0->m_collisionShape->IsConvex() && body1->m_collisionShape->IsConvex() ) if (body0->m_collisionShape->isConvex() && body1->m_collisionShape->isConvex() )
{ {
return new btConvexConvexAlgorithm(0,ci,&proxy0,&proxy1); return new btConvexConvexAlgorithm(0,ci,&proxy0,&proxy1);
} }
if (body0->m_collisionShape->IsConvex() && body1->m_collisionShape->IsConcave()) if (body0->m_collisionShape->isConvex() && body1->m_collisionShape->isConcave())
{ {
return new btConvexConcaveCollisionAlgorithm(ci,&proxy0,&proxy1); return new btConvexConcaveCollisionAlgorithm(ci,&proxy0,&proxy1);
} }
if (body1->m_collisionShape->IsConvex() && body0->m_collisionShape->IsConcave()) if (body1->m_collisionShape->isConvex() && body0->m_collisionShape->isConcave())
{ {
return new btConvexConcaveCollisionAlgorithm(ci,&proxy1,&proxy0); return new btConvexConcaveCollisionAlgorithm(ci,&proxy1,&proxy0);
} }
if (body0->m_collisionShape->IsCompound()) if (body0->m_collisionShape->isCompound())
{ {
return new btCompoundCollisionAlgorithm(ci,&proxy0,&proxy1); return new btCompoundCollisionAlgorithm(ci,&proxy0,&proxy1);
} else } else
{ {
if (body1->m_collisionShape->IsCompound()) if (body1->m_collisionShape->isCompound())
{ {
return new btCompoundCollisionAlgorithm(ci,&proxy1,&proxy0); return new btCompoundCollisionAlgorithm(ci,&proxy1,&proxy0);
} }
@@ -213,7 +213,7 @@ btCollisionAlgorithm* btCollisionDispatcher::InternalFindAlgorithm(btBroadphaseP
} }
bool btCollisionDispatcher::NeedsResponse(const btCollisionObject& colObj0,const btCollisionObject& colObj1) bool btCollisionDispatcher::needsResponse(const btCollisionObject& colObj0,const btCollisionObject& colObj1)
{ {
@@ -226,7 +226,7 @@ bool btCollisionDispatcher::NeedsResponse(const btCollisionObject& colObj0,cons
return hasResponse; return hasResponse;
} }
bool btCollisionDispatcher::NeedsCollision(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1) bool btCollisionDispatcher::needsCollision(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1)
{ {
btCollisionObject* body0 = (btCollisionObject*)proxy0.m_clientObject; btCollisionObject* body0 = (btCollisionObject*)proxy0.m_clientObject;
@@ -249,7 +249,7 @@ bool btCollisionDispatcher::NeedsCollision(btBroadphaseProxy& proxy0,btBroadphas
} }
///allows the user to get contact point callbacks ///allows the user to get contact point callbacks
btManifoldResult* btCollisionDispatcher::GetNewManifoldResult(btCollisionObject* obj0,btCollisionObject* obj1,btPersistentManifold* manifold) btManifoldResult* btCollisionDispatcher::getNewManifoldResult(btCollisionObject* obj0,btCollisionObject* obj1,btPersistentManifold* manifold)
{ {
@@ -259,34 +259,34 @@ btManifoldResult* btCollisionDispatcher::GetNewManifoldResult(btCollisionObject*
} }
///allows the user to get contact point callbacks ///allows the user to get contact point callbacks
void btCollisionDispatcher::ReleaseManifoldResult(btManifoldResult*) void btCollisionDispatcher::releaseManifoldResult(btManifoldResult*)
{ {
} }
class CollisionPairCallback : public btOverlapCallback class btCollisionPairCallback : public btOverlapCallback
{ {
btDispatcherInfo& m_dispatchInfo; btDispatcherInfo& m_dispatchInfo;
btCollisionDispatcher* m_dispatcher; btCollisionDispatcher* m_dispatcher;
int m_dispatcherId; int m_dispatcherId;
public: public:
CollisionPairCallback(btDispatcherInfo& dispatchInfo,btCollisionDispatcher* dispatcher,int dispatcherId) btCollisionPairCallback(btDispatcherInfo& dispatchInfo,btCollisionDispatcher* dispatcher,int dispatcherId)
:m_dispatchInfo(dispatchInfo), :m_dispatchInfo(dispatchInfo),
m_dispatcher(dispatcher), m_dispatcher(dispatcher),
m_dispatcherId(dispatcherId) m_dispatcherId(dispatcherId)
{ {
} }
virtual bool ProcessOverlap(btBroadphasePair& pair) virtual bool processOverlap(btBroadphasePair& pair)
{ {
if (m_dispatcherId>= 0) if (m_dispatcherId>= 0)
{ {
//dispatcher will keep algorithms persistent in the collision pair //dispatcher will keep algorithms persistent in the collision pair
if (!pair.m_algorithms[m_dispatcherId]) if (!pair.m_algorithms[m_dispatcherId])
{ {
pair.m_algorithms[m_dispatcherId] = m_dispatcher->FindAlgorithm( pair.m_algorithms[m_dispatcherId] = m_dispatcher->findAlgorithm(
*pair.m_pProxy0, *pair.m_pProxy0,
*pair.m_pProxy1); *pair.m_pProxy1);
} }
@@ -295,10 +295,10 @@ public:
{ {
if (m_dispatchInfo.m_dispatchFunc == btDispatcherInfo::DISPATCH_DISCRETE) if (m_dispatchInfo.m_dispatchFunc == btDispatcherInfo::DISPATCH_DISCRETE)
{ {
pair.m_algorithms[m_dispatcherId]->ProcessCollision(pair.m_pProxy0,pair.m_pProxy1,m_dispatchInfo); pair.m_algorithms[m_dispatcherId]->processCollision(pair.m_pProxy0,pair.m_pProxy1,m_dispatchInfo);
} else } else
{ {
float toi = pair.m_algorithms[m_dispatcherId]->CalculateTimeOfImpact(pair.m_pProxy0,pair.m_pProxy1,m_dispatchInfo); float toi = pair.m_algorithms[m_dispatcherId]->calculateTimeOfImpact(pair.m_pProxy0,pair.m_pProxy1,m_dispatchInfo);
if (m_dispatchInfo.m_timeOfImpact > toi) if (m_dispatchInfo.m_timeOfImpact > toi)
m_dispatchInfo.m_timeOfImpact = toi; m_dispatchInfo.m_timeOfImpact = toi;
@@ -307,7 +307,7 @@ public:
} else } else
{ {
//non-persistent algorithm dispatcher //non-persistent algorithm dispatcher
btCollisionAlgorithm* algo = m_dispatcher->FindAlgorithm( btCollisionAlgorithm* algo = m_dispatcher->findAlgorithm(
*pair.m_pProxy0, *pair.m_pProxy0,
*pair.m_pProxy1); *pair.m_pProxy1);
@@ -315,10 +315,10 @@ public:
{ {
if (m_dispatchInfo.m_dispatchFunc == btDispatcherInfo::DISPATCH_DISCRETE) if (m_dispatchInfo.m_dispatchFunc == btDispatcherInfo::DISPATCH_DISCRETE)
{ {
algo->ProcessCollision(pair.m_pProxy0,pair.m_pProxy1,m_dispatchInfo); algo->processCollision(pair.m_pProxy0,pair.m_pProxy1,m_dispatchInfo);
} else } else
{ {
float toi = algo->CalculateTimeOfImpact(pair.m_pProxy0,pair.m_pProxy1,m_dispatchInfo); float toi = algo->calculateTimeOfImpact(pair.m_pProxy0,pair.m_pProxy1,m_dispatchInfo);
if (m_dispatchInfo.m_timeOfImpact > toi) if (m_dispatchInfo.m_timeOfImpact > toi)
m_dispatchInfo.m_timeOfImpact = toi; m_dispatchInfo.m_timeOfImpact = toi;
} }
@@ -330,15 +330,15 @@ public:
}; };
void btCollisionDispatcher::DispatchAllCollisionPairs(btOverlappingPairCache* pairCache,btDispatcherInfo& dispatchInfo) void btCollisionDispatcher::dispatchAllCollisionPairs(btOverlappingPairCache* pairCache,btDispatcherInfo& dispatchInfo)
{ {
//m_blockedForChanges = true; //m_blockedForChanges = true;
int dispatcherId = GetUniqueId(); int dispatcherId = getUniqueId();
CollisionPairCallback collisionCallback(dispatchInfo,this,dispatcherId); btCollisionPairCallback collisionCallback(dispatchInfo,this,dispatcherId);
pairCache->ProcessAllOverlappingPairs(&collisionCallback); pairCache->processAllOverlappingPairs(&collisionCallback);
//m_blockedForChanges = false; //m_blockedForChanges = false;

View File

@@ -46,7 +46,7 @@ class btCollisionDispatcher : public btDispatcher
btCollisionAlgorithmCreateFunc* m_doubleDispatch[MAX_BROADPHASE_COLLISION_TYPES][MAX_BROADPHASE_COLLISION_TYPES]; btCollisionAlgorithmCreateFunc* m_doubleDispatch[MAX_BROADPHASE_COLLISION_TYPES][MAX_BROADPHASE_COLLISION_TYPES];
btCollisionAlgorithmCreateFunc* InternalFindCreateFunc(int proxyType0,int proxyType1); btCollisionAlgorithmCreateFunc* internalFindCreateFunc(int proxyType0,int proxyType1);
//default CreationFunctions, filling the m_doubleDispatch table //default CreationFunctions, filling the m_doubleDispatch table
btCollisionAlgorithmCreateFunc* m_convexConvexCreateFunc; btCollisionAlgorithmCreateFunc* m_convexConvexCreateFunc;
@@ -58,10 +58,10 @@ class btCollisionDispatcher : public btDispatcher
public: public:
///RegisterCollisionCreateFunc allows registration of custom/alternative collision create functions ///registerCollisionCreateFunc allows registration of custom/alternative collision create functions
void RegisterCollisionCreateFunc(int proxyType0,int proxyType1, btCollisionAlgorithmCreateFunc* createFunc); void registerCollisionCreateFunc(int proxyType0,int proxyType1, btCollisionAlgorithmCreateFunc* createFunc);
int GetNumManifolds() const int getNumManifolds() const
{ {
return m_manifoldsPtr.size(); return m_manifoldsPtr.size();
} }
@@ -71,12 +71,12 @@ public:
return &m_manifoldsPtr[0]; return &m_manifoldsPtr[0];
} }
btPersistentManifold* GetManifoldByIndexInternal(int index) btPersistentManifold* getManifoldByIndexInternal(int index)
{ {
return m_manifoldsPtr[index]; return m_manifoldsPtr[index];
} }
const btPersistentManifold* GetManifoldByIndexInternal(int index) const const btPersistentManifold* getManifoldByIndexInternal(int index) const
{ {
return m_manifoldsPtr[index]; return m_manifoldsPtr[index];
} }
@@ -86,31 +86,31 @@ public:
btCollisionDispatcher (); btCollisionDispatcher ();
virtual ~btCollisionDispatcher(); virtual ~btCollisionDispatcher();
virtual btPersistentManifold* GetNewManifold(void* b0,void* b1); virtual btPersistentManifold* getNewManifold(void* b0,void* b1);
virtual void ReleaseManifold(btPersistentManifold* manifold); virtual void releaseManifold(btPersistentManifold* manifold);
///allows the user to get contact point callbacks ///allows the user to get contact point callbacks
virtual btManifoldResult* GetNewManifoldResult(btCollisionObject* obj0,btCollisionObject* obj1,btPersistentManifold* manifold); virtual btManifoldResult* getNewManifoldResult(btCollisionObject* obj0,btCollisionObject* obj1,btPersistentManifold* manifold);
///allows the user to get contact point callbacks ///allows the user to get contact point callbacks
virtual void ReleaseManifoldResult(btManifoldResult*); virtual void releaseManifoldResult(btManifoldResult*);
virtual void ClearManifold(btPersistentManifold* manifold); virtual void clearManifold(btPersistentManifold* manifold);
btCollisionAlgorithm* FindAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1); btCollisionAlgorithm* findAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1);
btCollisionAlgorithm* InternalFindAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1); btCollisionAlgorithm* internalFindAlgorithm(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1);
virtual bool NeedsCollision(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1); virtual bool needsCollision(btBroadphaseProxy& proxy0,btBroadphaseProxy& proxy1);
virtual bool NeedsResponse(const btCollisionObject& colObj0,const btCollisionObject& colObj1); virtual bool needsResponse(const btCollisionObject& colObj0,const btCollisionObject& colObj1);
virtual int GetUniqueId() { return RIGIDBODY_DISPATCHER;} virtual int getUniqueId() { return RIGIDBODY_DISPATCHER;}
virtual void DispatchAllCollisionPairs(btOverlappingPairCache* pairCache,btDispatcherInfo& dispatchInfo); virtual void dispatchAllCollisionPairs(btOverlappingPairCache* pairCache,btDispatcherInfo& dispatchInfo);

View File

@@ -45,8 +45,8 @@ btCollisionWorld::~btCollisionWorld()
// //
// only clear the cached algorithms // only clear the cached algorithms
// //
GetBroadphase()->CleanProxyFromPairs(bp); getBroadphase()->cleanProxyFromPairs(bp);
GetBroadphase()->DestroyProxy(bp); getBroadphase()->destroyProxy(bp);
} }
} }
@@ -61,7 +61,7 @@ btCollisionWorld::~btCollisionWorld()
void btCollisionWorld::AddCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup,short int collisionFilterMask) void btCollisionWorld::addCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup,short int collisionFilterMask)
{ {
m_collisionObjects.push_back(collisionObject); m_collisionObjects.push_back(collisionObject);
@@ -70,10 +70,10 @@ void btCollisionWorld::AddCollisionObject(btCollisionObject* collisionObject,sho
btVector3 minAabb; btVector3 minAabb;
btVector3 maxAabb; btVector3 maxAabb;
collisionObject->m_collisionShape->GetAabb(trans,minAabb,maxAabb); collisionObject->m_collisionShape->getAabb(trans,minAabb,maxAabb);
int type = collisionObject->m_collisionShape->GetShapeType(); int type = collisionObject->m_collisionShape->getShapeType();
collisionObject->m_broadphaseHandle = GetBroadphase()->CreateProxy( collisionObject->m_broadphaseHandle = getBroadphase()->createProxy(
minAabb, minAabb,
maxAabb, maxAabb,
type, type,
@@ -87,7 +87,7 @@ void btCollisionWorld::AddCollisionObject(btCollisionObject* collisionObject,sho
} }
void btCollisionWorld::PerformDiscreteCollisionDetection() void btCollisionWorld::performDiscreteCollisionDetection()
{ {
btDispatcherInfo dispatchInfo; btDispatcherInfo dispatchInfo;
dispatchInfo.m_timeStep = 0.f; dispatchInfo.m_timeStep = 0.f;
@@ -99,20 +99,20 @@ void btCollisionWorld::PerformDiscreteCollisionDetection()
for (size_t i=0;i<m_collisionObjects.size();i++) for (size_t i=0;i<m_collisionObjects.size();i++)
{ {
m_collisionObjects[i]->m_cachedInvertedWorldTransform = m_collisionObjects[i]->m_worldTransform.inverse(); m_collisionObjects[i]->m_cachedInvertedWorldTransform = m_collisionObjects[i]->m_worldTransform.inverse();
m_collisionObjects[i]->m_collisionShape->GetAabb(m_collisionObjects[i]->m_worldTransform,aabbMin,aabbMax); m_collisionObjects[i]->m_collisionShape->getAabb(m_collisionObjects[i]->m_worldTransform,aabbMin,aabbMax);
m_pairCache->SetAabb(m_collisionObjects[i]->m_broadphaseHandle,aabbMin,aabbMax); m_pairCache->setAabb(m_collisionObjects[i]->m_broadphaseHandle,aabbMin,aabbMax);
} }
m_pairCache->RefreshOverlappingPairs(); m_pairCache->refreshOverlappingPairs();
btDispatcher* dispatcher = GetDispatcher(); btDispatcher* dispatcher = getDispatcher();
if (dispatcher) if (dispatcher)
dispatcher->DispatchAllCollisionPairs(m_pairCache,dispatchInfo); dispatcher->dispatchAllCollisionPairs(m_pairCache,dispatchInfo);
} }
void btCollisionWorld::RemoveCollisionObject(btCollisionObject* collisionObject) void btCollisionWorld::removeCollisionObject(btCollisionObject* collisionObject)
{ {
@@ -126,8 +126,8 @@ void btCollisionWorld::RemoveCollisionObject(btCollisionObject* collisionObject)
// //
// only clear the cached algorithms // only clear the cached algorithms
// //
GetBroadphase()->CleanProxyFromPairs(bp); getBroadphase()->cleanProxyFromPairs(bp);
GetBroadphase()->DestroyProxy(bp); getBroadphase()->destroyProxy(bp);
collisionObject->m_broadphaseHandle = 0; collisionObject->m_broadphaseHandle = 0;
} }
} }
@@ -142,7 +142,7 @@ void btCollisionWorld::RemoveCollisionObject(btCollisionObject* collisionObject)
} }
} }
void btCollisionWorld::RayTestSingle(const btTransform& rayFromTrans,const btTransform& rayToTrans, void btCollisionWorld::rayTestSingle(const btTransform& rayFromTrans,const btTransform& rayToTrans,
btCollisionObject* collisionObject, btCollisionObject* collisionObject,
const btCollisionShape* collisionShape, const btCollisionShape* collisionShape,
const btTransform& colObjWorldTransform, const btTransform& colObjWorldTransform,
@@ -151,7 +151,7 @@ void btCollisionWorld::RayTestSingle(const btTransform& rayFromTrans,const btTra
btSphereShape pointShape(0.0f); btSphereShape pointShape(0.0f);
if (collisionShape->IsConvex()) if (collisionShape->isConvex())
{ {
btConvexCast::CastResult castResult; btConvexCast::CastResult castResult;
castResult.m_fraction = 1.f;//?? castResult.m_fraction = 1.f;//??
@@ -189,7 +189,7 @@ void btCollisionWorld::RayTestSingle(const btTransform& rayFromTrans,const btTra
else else
{ {
if (collisionShape->IsConcave()) if (collisionShape->isConcave())
{ {
btTriangleMeshShape* triangleMesh = (btTriangleMeshShape*)collisionShape; btTriangleMeshShape* triangleMesh = (btTriangleMeshShape*)collisionShape;
@@ -217,7 +217,7 @@ void btCollisionWorld::RayTestSingle(const btTransform& rayFromTrans,const btTra
} }
virtual float ReportHit(const btVector3& hitNormalLocal, float hitFraction, int partId, int triangleIndex ) virtual float reportHit(const btVector3& hitNormalLocal, float hitFraction, int partId, int triangleIndex )
{ {
btCollisionWorld::LocalShapeInfo shapeInfo; btCollisionWorld::LocalShapeInfo shapeInfo;
shapeInfo.m_shapePart = partId; shapeInfo.m_shapePart = partId;
@@ -245,21 +245,21 @@ void btCollisionWorld::RayTestSingle(const btTransform& rayFromTrans,const btTra
btVector3 rayAabbMaxLocal = rayFromLocal; btVector3 rayAabbMaxLocal = rayFromLocal;
rayAabbMaxLocal.setMax(rayToLocal); rayAabbMaxLocal.setMax(rayToLocal);
triangleMesh->ProcessAllTriangles(&rcb,rayAabbMinLocal,rayAabbMaxLocal); triangleMesh->processAllTriangles(&rcb,rayAabbMinLocal,rayAabbMaxLocal);
} else } else
{ {
//todo: use AABB tree or other BVH acceleration structure! //todo: use AABB tree or other BVH acceleration structure!
if (collisionShape->IsCompound()) if (collisionShape->isCompound())
{ {
const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(collisionShape); const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(collisionShape);
int i=0; int i=0;
for (i=0;i<compoundShape->GetNumChildShapes();i++) for (i=0;i<compoundShape->getNumChildShapes();i++)
{ {
btTransform childTrans = compoundShape->GetChildTransform(i); btTransform childTrans = compoundShape->getChildTransform(i);
const btCollisionShape* childCollisionShape = compoundShape->GetChildShape(i); const btCollisionShape* childCollisionShape = compoundShape->getChildShape(i);
btTransform childWorldTrans = colObjWorldTransform * childTrans; btTransform childWorldTrans = colObjWorldTransform * childTrans;
RayTestSingle(rayFromTrans,rayToTrans, rayTestSingle(rayFromTrans,rayToTrans,
collisionObject, collisionObject,
childCollisionShape, childCollisionShape,
childWorldTrans, childWorldTrans,
@@ -273,7 +273,7 @@ void btCollisionWorld::RayTestSingle(const btTransform& rayFromTrans,const btTra
} }
} }
void btCollisionWorld::RayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback) void btCollisionWorld::rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback)
{ {
@@ -304,13 +304,13 @@ void btCollisionWorld::RayTest(const btVector3& rayFromWorld, const btVector3& r
//RigidcollisionObject* collisionObject = ctrl->GetRigidcollisionObject(); //RigidcollisionObject* collisionObject = ctrl->GetRigidcollisionObject();
btVector3 collisionObjectAabbMin,collisionObjectAabbMax; btVector3 collisionObjectAabbMin,collisionObjectAabbMax;
collisionObject->m_collisionShape->GetAabb(collisionObject->m_worldTransform,collisionObjectAabbMin,collisionObjectAabbMax); collisionObject->m_collisionShape->getAabb(collisionObject->m_worldTransform,collisionObjectAabbMin,collisionObjectAabbMax);
//check aabb overlap //check aabb overlap
if (TestAabbAgainstAabb2(rayAabbMin,rayAabbMax,collisionObjectAabbMin,collisionObjectAabbMax)) if (TestAabbAgainstAabb2(rayAabbMin,rayAabbMax,collisionObjectAabbMin,collisionObjectAabbMax))
{ {
RayTestSingle(rayFromTrans,rayToTrans, rayTestSingle(rayFromTrans,rayToTrans,
collisionObject, collisionObject,
collisionObject->m_collisionShape, collisionObject->m_collisionShape,
collisionObject->m_worldTransform, collisionObject->m_worldTransform,

View File

@@ -44,7 +44,8 @@ subject to the following restrictions:
* The Dependencies can be seen in this documentation under Directories * The Dependencies can be seen in this documentation under Directories
* *
* @subsection step4 Step 4: Integrating in your application, Full Rigid Body Simulation * @subsection step4 Step 4: Integrating in your application, Full Rigid Body Simulation
* Check out CcdPhysicsDemo how to create a CcdPhysicsEnvironment , btCollisionShape and btRigidBody, Stepping the simulation and synchronizing your derived version of the PHY_IMotionState class. * Check out CcdPhysicsDemo how to create a btDynamicsWorld, btRigidBody and btCollisionShape, Stepping the simulation and synchronizing your graphics object transform.
* PLEASE NOTE THE CcdPhysicsEnvironment and CcdPhysicsController is obsolete and will be removed. It has been replaced by classes derived frmo btDynamicsWorld and btRididBody
* @subsection step5 Step 5 : Integrate the Collision Detection Library (without Dynamics and other Extras) * @subsection step5 Step 5 : Integrate the Collision Detection Library (without Dynamics and other Extras)
* Bullet Collision Detection can also be used without the Dynamics/Extras. * Bullet Collision Detection can also be used without the Dynamics/Extras.
* Check out btCollisionWorld and btCollisionObject, and the CollisionInterfaceDemo. Also in Extras/test_BulletOde.cpp there is a sample Collision Detection integration with Open Dynamics Engine, ODE, http://www.ode.org * Check out btCollisionWorld and btCollisionObject, and the CollisionInterfaceDemo. Also in Extras/test_BulletOde.cpp there is a sample Collision Detection integration with Open Dynamics Engine, ODE, http://www.ode.org
@@ -101,18 +102,18 @@ public:
virtual ~btCollisionWorld(); virtual ~btCollisionWorld();
btBroadphaseInterface* GetBroadphase() btBroadphaseInterface* getBroadphase()
{ {
return m_pairCache; return m_pairCache;
} }
btOverlappingPairCache* GetPairCache() btOverlappingPairCache* getPairCache()
{ {
return m_pairCache; return m_pairCache;
} }
btDispatcher* GetDispatcher() btDispatcher* getDispatcher()
{ {
return m_dispatcher1; return m_dispatcher1;
} }
@@ -200,40 +201,40 @@ public:
int GetNumCollisionObjects() const int getNumCollisionObjects() const
{ {
return m_collisionObjects.size(); return m_collisionObjects.size();
} }
/// RayTest performs a raycast on all objects in the btCollisionWorld, and calls the resultCallback /// rayTest performs a raycast on all objects in the btCollisionWorld, and calls the resultCallback
/// This allows for several queries: first hit, all hits, any hit, dependent on the value returned by the callback. /// This allows for several queries: first hit, all hits, any hit, dependent on the value returned by the callback.
void RayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback); void rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback);
/// RayTestSingle performs a raycast call and calls the resultCallback. It is used internally by RayTest. /// rayTestSingle performs a raycast call and calls the resultCallback. It is used internally by rayTest.
/// In a future implementation, we consider moving the ray test as a virtual method in btCollisionShape. /// In a future implementation, we consider moving the ray test as a virtual method in btCollisionShape.
/// This allows more customization. /// This allows more customization.
void RayTestSingle(const btTransform& rayFromTrans,const btTransform& rayToTrans, void rayTestSingle(const btTransform& rayFromTrans,const btTransform& rayToTrans,
btCollisionObject* collisionObject, btCollisionObject* collisionObject,
const btCollisionShape* collisionShape, const btCollisionShape* collisionShape,
const btTransform& colObjWorldTransform, const btTransform& colObjWorldTransform,
RayResultCallback& resultCallback); RayResultCallback& resultCallback);
void AddCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup=1,short int collisionFilterMask=1); void addCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup=1,short int collisionFilterMask=1);
btCollisionObjectArray& GetCollisionObjectArray() btCollisionObjectArray& getCollisionObjectArray()
{ {
return m_collisionObjects; return m_collisionObjects;
} }
const btCollisionObjectArray& GetCollisionObjectArray() const const btCollisionObjectArray& getCollisionObjectArray() const
{ {
return m_collisionObjects; return m_collisionObjects;
} }
void RemoveCollisionObject(btCollisionObject* collisionObject); void removeCollisionObject(btCollisionObject* collisionObject);
virtual void PerformDiscreteCollisionDetection(); virtual void performDiscreteCollisionDetection();
}; };

View File

@@ -24,10 +24,10 @@ m_compoundProxy(*proxy0),
m_otherProxy(*proxy1) m_otherProxy(*proxy1)
{ {
btCollisionObject* colObj = static_cast<btCollisionObject*>(m_compoundProxy.m_clientObject); btCollisionObject* colObj = static_cast<btCollisionObject*>(m_compoundProxy.m_clientObject);
assert (colObj->m_collisionShape->IsCompound()); assert (colObj->m_collisionShape->isCompound());
btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->m_collisionShape); btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->m_collisionShape);
int numChildren = compoundShape->GetNumChildShapes(); int numChildren = compoundShape->getNumChildShapes();
m_childProxies.resize( numChildren ); m_childProxies.resize( numChildren );
int i; int i;
for (i=0;i<numChildren;i++) for (i=0;i<numChildren;i++)
@@ -38,11 +38,11 @@ m_otherProxy(*proxy1)
m_childCollisionAlgorithms.resize(numChildren); m_childCollisionAlgorithms.resize(numChildren);
for (i=0;i<numChildren;i++) for (i=0;i<numChildren;i++)
{ {
btCollisionShape* childShape = compoundShape->GetChildShape(i); btCollisionShape* childShape = compoundShape->getChildShape(i);
btCollisionObject* colObj = static_cast<btCollisionObject*>(m_childProxies[i].m_clientObject); btCollisionObject* colObj = static_cast<btCollisionObject*>(m_childProxies[i].m_clientObject);
btCollisionShape* orgShape = colObj->m_collisionShape; btCollisionShape* orgShape = colObj->m_collisionShape;
colObj->m_collisionShape = childShape; colObj->m_collisionShape = childShape;
m_childCollisionAlgorithms[i] = m_dispatcher->FindAlgorithm(m_childProxies[i],m_otherProxy); m_childCollisionAlgorithms[i] = m_dispatcher->findAlgorithm(m_childProxies[i],m_otherProxy);
colObj->m_collisionShape =orgShape; colObj->m_collisionShape =orgShape;
} }
} }
@@ -58,10 +58,10 @@ btCompoundCollisionAlgorithm::~btCompoundCollisionAlgorithm()
} }
} }
void btCompoundCollisionAlgorithm::ProcessCollision (btBroadphaseProxy* ,btBroadphaseProxy* ,const btDispatcherInfo& dispatchInfo) void btCompoundCollisionAlgorithm::processCollision (btBroadphaseProxy* ,btBroadphaseProxy* ,const btDispatcherInfo& dispatchInfo)
{ {
btCollisionObject* colObj = static_cast<btCollisionObject*>(m_compoundProxy.m_clientObject); btCollisionObject* colObj = static_cast<btCollisionObject*>(m_compoundProxy.m_clientObject);
assert (colObj->m_collisionShape->IsCompound()); assert (colObj->m_collisionShape->isCompound());
btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->m_collisionShape); btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->m_collisionShape);
@@ -78,29 +78,29 @@ void btCompoundCollisionAlgorithm::ProcessCollision (btBroadphaseProxy* ,btBroad
for (i=0;i<numChildren;i++) for (i=0;i<numChildren;i++)
{ {
//temporarily exchange parent btCollisionShape with childShape, and recurse //temporarily exchange parent btCollisionShape with childShape, and recurse
btCollisionShape* childShape = compoundShape->GetChildShape(i); btCollisionShape* childShape = compoundShape->getChildShape(i);
btCollisionObject* colObj = static_cast<btCollisionObject*>(m_childProxies[i].m_clientObject); btCollisionObject* colObj = static_cast<btCollisionObject*>(m_childProxies[i].m_clientObject);
//backup //backup
btTransform orgTrans = colObj->m_worldTransform; btTransform orgTrans = colObj->m_worldTransform;
btCollisionShape* orgShape = colObj->m_collisionShape; btCollisionShape* orgShape = colObj->m_collisionShape;
btTransform childTrans = compoundShape->GetChildTransform(i); btTransform childTrans = compoundShape->getChildTransform(i);
btTransform newChildWorldTrans = orgTrans*childTrans ; btTransform newChildWorldTrans = orgTrans*childTrans ;
colObj->m_worldTransform = newChildWorldTrans; colObj->m_worldTransform = newChildWorldTrans;
colObj->m_collisionShape = childShape; colObj->m_collisionShape = childShape;
m_childCollisionAlgorithms[i]->ProcessCollision(&m_childProxies[i],&m_otherProxy,dispatchInfo); m_childCollisionAlgorithms[i]->processCollision(&m_childProxies[i],&m_otherProxy,dispatchInfo);
//revert back //revert back
colObj->m_collisionShape =orgShape; colObj->m_collisionShape =orgShape;
colObj->m_worldTransform = orgTrans; colObj->m_worldTransform = orgTrans;
} }
} }
float btCompoundCollisionAlgorithm::CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo) float btCompoundCollisionAlgorithm::calculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo)
{ {
btCollisionObject* colObj = static_cast<btCollisionObject*>(m_compoundProxy.m_clientObject); btCollisionObject* colObj = static_cast<btCollisionObject*>(m_compoundProxy.m_clientObject);
assert (colObj->m_collisionShape->IsCompound()); assert (colObj->m_collisionShape->isCompound());
btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->m_collisionShape); btCompoundShape* compoundShape = static_cast<btCompoundShape*>(colObj->m_collisionShape);
@@ -118,19 +118,19 @@ float btCompoundCollisionAlgorithm::CalculateTimeOfImpact(btBroadphaseProxy* pro
for (i=0;i<numChildren;i++) for (i=0;i<numChildren;i++)
{ {
//temporarily exchange parent btCollisionShape with childShape, and recurse //temporarily exchange parent btCollisionShape with childShape, and recurse
btCollisionShape* childShape = compoundShape->GetChildShape(i); btCollisionShape* childShape = compoundShape->getChildShape(i);
btCollisionObject* colObj = static_cast<btCollisionObject*>(m_childProxies[i].m_clientObject); btCollisionObject* colObj = static_cast<btCollisionObject*>(m_childProxies[i].m_clientObject);
//backup //backup
btTransform orgTrans = colObj->m_worldTransform; btTransform orgTrans = colObj->m_worldTransform;
btCollisionShape* orgShape = colObj->m_collisionShape; btCollisionShape* orgShape = colObj->m_collisionShape;
btTransform childTrans = compoundShape->GetChildTransform(i); btTransform childTrans = compoundShape->getChildTransform(i);
btTransform newChildWorldTrans = orgTrans*childTrans ; btTransform newChildWorldTrans = orgTrans*childTrans ;
colObj->m_worldTransform = newChildWorldTrans; colObj->m_worldTransform = newChildWorldTrans;
colObj->m_collisionShape = childShape; colObj->m_collisionShape = childShape;
float frac = m_childCollisionAlgorithms[i]->CalculateTimeOfImpact(&m_childProxies[i],&m_otherProxy,dispatchInfo); float frac = m_childCollisionAlgorithms[i]->calculateTimeOfImpact(&m_childProxies[i],&m_otherProxy,dispatchInfo);
if (frac<hitFraction) if (frac<hitFraction)
{ {
hitFraction = frac; hitFraction = frac;

View File

@@ -47,9 +47,9 @@ public:
virtual ~btCompoundCollisionAlgorithm(); virtual ~btCompoundCollisionAlgorithm();
virtual void ProcessCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo); virtual void processCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo);
float CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo); float calculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo);
struct CreateFunc :public btCollisionAlgorithmCreateFunc struct CreateFunc :public btCollisionAlgorithmCreateFunc
{ {

View File

@@ -48,27 +48,27 @@ btConvexTriangleCallback::btConvexTriangleCallback(btDispatcher* dispatcher,btB
// //
// create the manifold from the dispatcher 'manifold pool' // create the manifold from the dispatcher 'manifold pool'
// //
m_manifoldPtr = m_dispatcher->GetNewManifold(proxy0->m_clientObject,proxy1->m_clientObject); m_manifoldPtr = m_dispatcher->getNewManifold(proxy0->m_clientObject,proxy1->m_clientObject);
ClearCache(); clearCache();
} }
btConvexTriangleCallback::~btConvexTriangleCallback() btConvexTriangleCallback::~btConvexTriangleCallback()
{ {
ClearCache(); clearCache();
m_dispatcher->ReleaseManifold( m_manifoldPtr ); m_dispatcher->releaseManifold( m_manifoldPtr );
} }
void btConvexTriangleCallback::ClearCache() void btConvexTriangleCallback::clearCache()
{ {
m_dispatcher->ClearManifold(m_manifoldPtr); m_dispatcher->clearManifold(m_manifoldPtr);
}; };
void btConvexTriangleCallback::ProcessTriangle(btVector3* triangle,int partId, int triangleIndex) void btConvexTriangleCallback::processTriangle(btVector3* triangle,int partId, int triangleIndex)
{ {
//just for debugging purposes //just for debugging purposes
@@ -85,29 +85,29 @@ void btConvexTriangleCallback::ProcessTriangle(btVector3* triangle,int partId, i
///debug drawing of the overlapping triangles ///debug drawing of the overlapping triangles
if (m_dispatchInfoPtr && m_dispatchInfoPtr->m_debugDraw && m_dispatchInfoPtr->m_debugDraw->GetDebugMode() > 0) if (m_dispatchInfoPtr && m_dispatchInfoPtr->m_debugDraw && m_dispatchInfoPtr->m_debugDraw->getDebugMode() > 0)
{ {
btVector3 color(255,255,0); btVector3 color(255,255,0);
btTransform& tr = ob->m_worldTransform; btTransform& tr = ob->m_worldTransform;
m_dispatchInfoPtr->m_debugDraw->DrawLine(tr(triangle[0]),tr(triangle[1]),color); m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[0]),tr(triangle[1]),color);
m_dispatchInfoPtr->m_debugDraw->DrawLine(tr(triangle[1]),tr(triangle[2]),color); m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[1]),tr(triangle[2]),color);
m_dispatchInfoPtr->m_debugDraw->DrawLine(tr(triangle[2]),tr(triangle[0]),color); m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[2]),tr(triangle[0]),color);
//btVector3 center = triangle[0] + triangle[1]+triangle[2]; //btVector3 center = triangle[0] + triangle[1]+triangle[2];
//center *= 0.333333f; //center *= 0.333333f;
//m_dispatchInfoPtr->m_debugDraw->DrawLine(tr(triangle[0]),tr(center),color); //m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[0]),tr(center),color);
//m_dispatchInfoPtr->m_debugDraw->DrawLine(tr(triangle[1]),tr(center),color); //m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[1]),tr(center),color);
//m_dispatchInfoPtr->m_debugDraw->DrawLine(tr(triangle[2]),tr(center),color); //m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[2]),tr(center),color);
} }
btCollisionObject* colObj = static_cast<btCollisionObject*>(m_convexProxy->m_clientObject); btCollisionObject* colObj = static_cast<btCollisionObject*>(m_convexProxy->m_clientObject);
if (colObj->m_collisionShape->IsConvex()) if (colObj->m_collisionShape->isConvex())
{ {
btTriangleShape tm(triangle[0],triangle[1],triangle[2]); btTriangleShape tm(triangle[0],triangle[1],triangle[2]);
tm.SetMargin(m_collisionMarginTriangle); tm.setMargin(m_collisionMarginTriangle);
btCollisionShape* tmpShape = ob->m_collisionShape; btCollisionShape* tmpShape = ob->m_collisionShape;
@@ -115,8 +115,8 @@ void btConvexTriangleCallback::ProcessTriangle(btVector3* triangle,int partId, i
///this should use the btDispatcher, so the actual registered algorithm is used ///this should use the btDispatcher, so the actual registered algorithm is used
btConvexConvexAlgorithm cvxcvxalgo(m_manifoldPtr,ci,m_convexProxy,&m_triangleProxy); btConvexConvexAlgorithm cvxcvxalgo(m_manifoldPtr,ci,m_convexProxy,&m_triangleProxy);
cvxcvxalgo.SetShapeIdentifiers(-1,-1,partId,triangleIndex); cvxcvxalgo.setShapeIdentifiers(-1,-1,partId,triangleIndex);
cvxcvxalgo.ProcessCollision(m_convexProxy,&m_triangleProxy,*m_dispatchInfoPtr); cvxcvxalgo.processCollision(m_convexProxy,&m_triangleProxy,*m_dispatchInfoPtr);
ob->m_collisionShape = tmpShape; ob->m_collisionShape = tmpShape;
} }
@@ -127,7 +127,7 @@ void btConvexTriangleCallback::ProcessTriangle(btVector3* triangle,int partId, i
void btConvexTriangleCallback::SetTimeStepAndCounters(float collisionMarginTriangle,const btDispatcherInfo& dispatchInfo) void btConvexTriangleCallback::setTimeStepAndCounters(float collisionMarginTriangle,const btDispatcherInfo& dispatchInfo)
{ {
m_dispatchInfoPtr = &dispatchInfo; m_dispatchInfoPtr = &dispatchInfo;
m_collisionMarginTriangle = collisionMarginTriangle; m_collisionMarginTriangle = collisionMarginTriangle;
@@ -142,7 +142,7 @@ void btConvexTriangleCallback::SetTimeStepAndCounters(float collisionMarginTrian
btCollisionShape* convexShape = static_cast<btCollisionShape*>(convexBody->m_collisionShape); btCollisionShape* convexShape = static_cast<btCollisionShape*>(convexBody->m_collisionShape);
//CollisionShape* triangleShape = static_cast<btCollisionShape*>(triBody->m_collisionShape); //CollisionShape* triangleShape = static_cast<btCollisionShape*>(triBody->m_collisionShape);
convexShape->GetAabb(convexInTriangleSpace,m_aabbMin,m_aabbMax); convexShape->getAabb(convexInTriangleSpace,m_aabbMin,m_aabbMax);
float extraMargin = collisionMarginTriangle;//CONVEX_DISTANCE_MARGIN;//+0.1f; float extraMargin = collisionMarginTriangle;//CONVEX_DISTANCE_MARGIN;//+0.1f;
@@ -153,22 +153,22 @@ void btConvexTriangleCallback::SetTimeStepAndCounters(float collisionMarginTrian
} }
void btConvexConcaveCollisionAlgorithm::ClearCache() void btConvexConcaveCollisionAlgorithm::clearCache()
{ {
m_btConvexTriangleCallback.ClearCache(); m_btConvexTriangleCallback.clearCache();
} }
void btConvexConcaveCollisionAlgorithm::ProcessCollision (btBroadphaseProxy* ,btBroadphaseProxy* ,const btDispatcherInfo& dispatchInfo) void btConvexConcaveCollisionAlgorithm::processCollision (btBroadphaseProxy* ,btBroadphaseProxy* ,const btDispatcherInfo& dispatchInfo)
{ {
btCollisionObject* convexBody = static_cast<btCollisionObject* >(m_convex.m_clientObject); btCollisionObject* convexBody = static_cast<btCollisionObject* >(m_convex.m_clientObject);
btCollisionObject* triBody = static_cast<btCollisionObject* >(m_concave.m_clientObject); btCollisionObject* triBody = static_cast<btCollisionObject* >(m_concave.m_clientObject);
if (triBody->m_collisionShape->IsConcave()) if (triBody->m_collisionShape->isConcave())
{ {
if (!m_dispatcher->NeedsCollision(m_convex,m_concave)) if (!m_dispatcher->needsCollision(m_convex,m_concave))
return; return;
@@ -176,19 +176,19 @@ void btConvexConcaveCollisionAlgorithm::ProcessCollision (btBroadphaseProxy* ,bt
btCollisionObject* triOb = static_cast<btCollisionObject*>(m_concave.m_clientObject); btCollisionObject* triOb = static_cast<btCollisionObject*>(m_concave.m_clientObject);
ConcaveShape* concaveShape = static_cast<ConcaveShape*>( triOb->m_collisionShape); ConcaveShape* concaveShape = static_cast<ConcaveShape*>( triOb->m_collisionShape);
if (convexBody->m_collisionShape->IsConvex()) if (convexBody->m_collisionShape->isConvex())
{ {
float collisionMarginTriangle = concaveShape->GetMargin(); float collisionMarginTriangle = concaveShape->getMargin();
m_btConvexTriangleCallback.SetTimeStepAndCounters(collisionMarginTriangle,dispatchInfo); m_btConvexTriangleCallback.setTimeStepAndCounters(collisionMarginTriangle,dispatchInfo);
//Disable persistency. previously, some older algorithm calculated all contacts in one go, so you can clear it here. //Disable persistency. previously, some older algorithm calculated all contacts in one go, so you can clear it here.
//m_dispatcher->ClearManifold(m_btConvexTriangleCallback.m_manifoldPtr); //m_dispatcher->clearManifold(m_btConvexTriangleCallback.m_manifoldPtr);
m_btConvexTriangleCallback.m_manifoldPtr->SetBodies(m_convex.m_clientObject,m_concave.m_clientObject); m_btConvexTriangleCallback.m_manifoldPtr->setBodies(m_convex.m_clientObject,m_concave.m_clientObject);
concaveShape->ProcessAllTriangles( &m_btConvexTriangleCallback,m_btConvexTriangleCallback.GetAabbMin(),m_btConvexTriangleCallback.GetAabbMax()); concaveShape->processAllTriangles( &m_btConvexTriangleCallback,m_btConvexTriangleCallback.getAabbMin(),m_btConvexTriangleCallback.getAabbMax());
} }
@@ -198,7 +198,7 @@ void btConvexConcaveCollisionAlgorithm::ProcessCollision (btBroadphaseProxy* ,bt
} }
float btConvexConcaveCollisionAlgorithm::CalculateTimeOfImpact(btBroadphaseProxy* ,btBroadphaseProxy* ,const btDispatcherInfo& dispatchInfo) float btConvexConcaveCollisionAlgorithm::calculateTimeOfImpact(btBroadphaseProxy* ,btBroadphaseProxy* ,const btDispatcherInfo& dispatchInfo)
{ {
//quick approximation using raycast, todo: hook up to the continuous collision detection (one of the btConvexCast) //quick approximation using raycast, todo: hook up to the continuous collision detection (one of the btConvexCast)
@@ -239,7 +239,7 @@ float btConvexConcaveCollisionAlgorithm::CalculateTimeOfImpact(btBroadphaseProxy
} }
virtual void ProcessTriangle(btVector3* triangle, int partId, int triangleIndex) virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex)
{ {
//do a swept sphere for now //do a swept sphere for now
btTransform ident; btTransform ident;
@@ -269,7 +269,7 @@ float btConvexConcaveCollisionAlgorithm::CalculateTimeOfImpact(btBroadphaseProxy
if (triBody->m_collisionShape->IsConcave()) if (triBody->m_collisionShape->isConcave())
{ {
btVector3 rayAabbMin = convexFromLocal.getOrigin(); btVector3 rayAabbMin = convexFromLocal.getOrigin();
rayAabbMin.setMin(convexToLocal.getOrigin()); rayAabbMin.setMin(convexToLocal.getOrigin());
@@ -290,7 +290,7 @@ float btConvexConcaveCollisionAlgorithm::CalculateTimeOfImpact(btBroadphaseProxy
if (triangleMesh) if (triangleMesh)
{ {
triangleMesh->ProcessAllTriangles(&raycastCallback,rayAabbMin,rayAabbMax); triangleMesh->processAllTriangles(&raycastCallback,rayAabbMin,rayAabbMax);
} }

View File

@@ -25,7 +25,7 @@ class btDispatcher;
#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
#include "btCollisionCreateFunc.h" #include "btCollisionCreateFunc.h"
///For each triangle in the concave mesh that overlaps with the AABB of a convex (m_convexProxy), ProcessTriangle is called. ///For each triangle in the concave mesh that overlaps with the AABB of a convex (m_convexProxy), processTriangle is called.
class btConvexTriangleCallback : public btTriangleCallback class btConvexTriangleCallback : public btTriangleCallback
{ {
btBroadphaseProxy* m_convexProxy; btBroadphaseProxy* m_convexProxy;
@@ -45,19 +45,19 @@ int m_triangleCount;
btConvexTriangleCallback(btDispatcher* dispatcher,btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1); btConvexTriangleCallback(btDispatcher* dispatcher,btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);
void SetTimeStepAndCounters(float collisionMarginTriangle,const btDispatcherInfo& dispatchInfo); void setTimeStepAndCounters(float collisionMarginTriangle,const btDispatcherInfo& dispatchInfo);
virtual ~btConvexTriangleCallback(); virtual ~btConvexTriangleCallback();
virtual void ProcessTriangle(btVector3* triangle, int partId, int triangleIndex); virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex);
void ClearCache(); void clearCache();
inline const btVector3& GetAabbMin() const inline const btVector3& getAabbMin() const
{ {
return m_aabbMin; return m_aabbMin;
} }
inline const btVector3& GetAabbMax() const inline const btVector3& getAabbMax() const
{ {
return m_aabbMax; return m_aabbMax;
} }
@@ -84,11 +84,11 @@ public:
virtual ~btConvexConcaveCollisionAlgorithm(); virtual ~btConvexConcaveCollisionAlgorithm();
virtual void ProcessCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo); virtual void processCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo);
float CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo); float calculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo);
void ClearCache(); void clearCache();
struct CreateFunc :public btCollisionAlgorithmCreateFunc struct CreateFunc :public btCollisionAlgorithmCreateFunc
{ {

View File

@@ -91,12 +91,12 @@ m_ownManifold (false),
m_manifoldPtr(mf), m_manifoldPtr(mf),
m_lowLevelOfDetail(false) m_lowLevelOfDetail(false)
{ {
CheckPenetrationDepthSolver(); checkPenetrationDepthSolver();
{ {
if (!m_manifoldPtr && m_dispatcher->NeedsCollision(m_box0,m_box1)) if (!m_manifoldPtr && m_dispatcher->needsCollision(m_box0,m_box1))
{ {
m_manifoldPtr = m_dispatcher->GetNewManifold(proxy0->m_clientObject,proxy1->m_clientObject); m_manifoldPtr = m_dispatcher->getNewManifold(proxy0->m_clientObject,proxy1->m_clientObject);
m_ownManifold = true; m_ownManifold = true;
} }
} }
@@ -110,11 +110,11 @@ btConvexConvexAlgorithm::~btConvexConvexAlgorithm()
if (m_ownManifold) if (m_ownManifold)
{ {
if (m_manifoldPtr) if (m_manifoldPtr)
m_dispatcher->ReleaseManifold(m_manifoldPtr); m_dispatcher->releaseManifold(m_manifoldPtr);
} }
} }
void btConvexConvexAlgorithm ::SetLowLevelOfDetail(bool useLowLevel) void btConvexConvexAlgorithm ::setLowLevelOfDetail(bool useLowLevel)
{ {
m_lowLevelOfDetail = useLowLevel; m_lowLevelOfDetail = useLowLevel;
} }
@@ -133,11 +133,11 @@ public:
} }
virtual void AddContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,float depth) virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,float depth)
{ {
btVector3 flippedNormal = -normalOnBInWorld; btVector3 flippedNormal = -normalOnBInWorld;
m_org->AddContactPoint(flippedNormal,pointInWorld,depth); m_org->addContactPoint(flippedNormal,pointInWorld,depth);
} }
}; };
@@ -150,7 +150,7 @@ static btMinkowskiPenetrationDepthSolver gPenetrationDepthSolver;
Solid3EpaPenetrationDepth gSolidEpaPenetrationSolver; Solid3EpaPenetrationDepth gSolidEpaPenetrationSolver;
#endif //USE_EPA #endif //USE_EPA
void btConvexConvexAlgorithm::CheckPenetrationDepthSolver() void btConvexConvexAlgorithm::checkPenetrationDepthSolver()
{ {
if (m_useEpa != gUseEpa) if (m_useEpa != gUseEpa)
{ {
@@ -158,12 +158,12 @@ void btConvexConvexAlgorithm::CheckPenetrationDepthSolver()
if (m_useEpa) if (m_useEpa)
{ {
// m_gjkPairDetector.SetPenetrationDepthSolver(&gEpaPenetrationDepthSolver); // m_gjkPairDetector.setPenetrationDepthSolver(&gEpaPenetrationDepthSolver);
} else } else
{ {
m_gjkPairDetector.SetPenetrationDepthSolver(&gPenetrationDepthSolver); m_gjkPairDetector.setPenetrationDepthSolver(&gPenetrationDepthSolver);
} }
} }
@@ -219,7 +219,7 @@ public:
//normalOnBInWorld.normalize(); //normalOnBInWorld.normalize();
btVector3 pointInWorld(positionsWorld[i].GetX(),positionsWorld[i].GetY(),positionsWorld[i].GetZ()); btVector3 pointInWorld(positionsWorld[i].GetX(),positionsWorld[i].GetY(),positionsWorld[i].GetZ());
float depth = -depths[i]; float depth = -depths[i];
m_manifoldResult.AddContactPoint(normalOnBInWorld,pointInWorld,depth); m_manifoldResult.addContactPoint(normalOnBInWorld,pointInWorld,depth);
} }
return 0; return 0;
@@ -237,17 +237,17 @@ public:
// //
// Convex-Convex collision algorithm // Convex-Convex collision algorithm
// //
void btConvexConvexAlgorithm ::ProcessCollision (btBroadphaseProxy* ,btBroadphaseProxy* ,const btDispatcherInfo& dispatchInfo) void btConvexConvexAlgorithm ::processCollision (btBroadphaseProxy* ,btBroadphaseProxy* ,const btDispatcherInfo& dispatchInfo)
{ {
if (!m_manifoldPtr) if (!m_manifoldPtr)
return; return;
CheckPenetrationDepthSolver(); checkPenetrationDepthSolver();
// printf("btConvexConvexAlgorithm::ProcessCollision\n"); // printf("btConvexConvexAlgorithm::processCollision\n");
bool needsCollision = m_dispatcher->NeedsCollision(m_box0,m_box1); bool needsCollision = m_dispatcher->needsCollision(m_box0,m_box1);
if (!needsCollision) if (!needsCollision)
return; return;
@@ -259,8 +259,8 @@ void btConvexConvexAlgorithm ::ProcessCollision (btBroadphaseProxy* ,btBroadphas
if (dispatchInfo.m_enableSatConvex) if (dispatchInfo.m_enableSatConvex)
{ {
if ((col0->m_collisionShape->IsPolyhedral()) && if ((col0->m_collisionShape->isPolyhedral()) &&
(col1->m_collisionShape->IsPolyhedral())) (col1->m_collisionShape->isPolyhedral()))
{ {
@@ -283,8 +283,8 @@ void btConvexConvexAlgorithm ::ProcessCollision (btBroadphaseProxy* ,btBroadphas
Transform trB = GetTransformFrombtTransform(col1->m_worldTransform); Transform trB = GetTransformFrombtTransform(col1->m_worldTransform);
//either use persistent manifold or clear it every time //either use persistent manifold or clear it every time
m_dispatcher->ClearManifold(m_manifoldPtr); m_dispatcher->clearManifold(m_manifoldPtr);
btManifoldResult* resultOut = m_dispatcher->GetNewManifoldResult(col0,col1,m_manifoldPtr); btManifoldResult* resultOut = m_dispatcher->getNewManifoldResult(col0,col1,m_manifoldPtr);
btManifoldResultCollector hullContactCollector(*resultOut); btManifoldResultCollector hullContactCollector(*resultOut);
@@ -301,7 +301,7 @@ void btConvexConvexAlgorithm ::ProcessCollision (btBroadphaseProxy* ,btBroadphas
#endif //USE_HULL #endif //USE_HULL
btManifoldResult* resultOut = m_dispatcher->GetNewManifoldResult(col0,col1,m_manifoldPtr); btManifoldResult* resultOut = m_dispatcher->getNewManifoldResult(col0,col1,m_manifoldPtr);
btConvexShape* min0 = static_cast<btConvexShape*>(col0->m_collisionShape); btConvexShape* min0 = static_cast<btConvexShape*>(col0->m_collisionShape);
btConvexShape* min1 = static_cast<btConvexShape*>(col1->m_collisionShape); btConvexShape* min1 = static_cast<btConvexShape*>(col1->m_collisionShape);
@@ -310,9 +310,9 @@ void btConvexConvexAlgorithm ::ProcessCollision (btBroadphaseProxy* ,btBroadphas
//TODO: if (dispatchInfo.m_useContinuous) //TODO: if (dispatchInfo.m_useContinuous)
m_gjkPairDetector.SetMinkowskiA(min0); m_gjkPairDetector.setMinkowskiA(min0);
m_gjkPairDetector.SetMinkowskiB(min1); m_gjkPairDetector.setMinkowskiB(min1);
input.m_maximumDistanceSquared = min0->GetMargin() + min1->GetMargin() + m_manifoldPtr->GetContactBreakingTreshold(); input.m_maximumDistanceSquared = min0->getMargin() + min1->getMargin() + m_manifoldPtr->getContactBreakingTreshold();
input.m_maximumDistanceSquared*= input.m_maximumDistanceSquared; input.m_maximumDistanceSquared*= input.m_maximumDistanceSquared;
// input.m_maximumDistanceSquared = 1e30f; // input.m_maximumDistanceSquared = 1e30f;
@@ -320,15 +320,15 @@ void btConvexConvexAlgorithm ::ProcessCollision (btBroadphaseProxy* ,btBroadphas
input.m_transformA = col0->m_worldTransform; input.m_transformA = col0->m_worldTransform;
input.m_transformB = col1->m_worldTransform; input.m_transformB = col1->m_worldTransform;
m_gjkPairDetector.GetClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw); m_gjkPairDetector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw);
m_dispatcher->ReleaseManifoldResult(resultOut); m_dispatcher->releaseManifoldResult(resultOut);
} }
bool disableCcd = false; bool disableCcd = false;
float btConvexConvexAlgorithm::CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo) float btConvexConvexAlgorithm::calculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo)
{ {
///Rather then checking ALL pairs, only calculate TOI when motion exceeds treshold ///Rather then checking ALL pairs, only calculate TOI when motion exceeds treshold
@@ -350,7 +350,7 @@ float btConvexConvexAlgorithm::CalculateTimeOfImpact(btBroadphaseProxy* proxy0,b
if (disableCcd) if (disableCcd)
return 1.f; return 1.f;
CheckPenetrationDepthSolver(); checkPenetrationDepthSolver();
//An adhoc way of testing the Continuous Collision Detection algorithms //An adhoc way of testing the Continuous Collision Detection algorithms
//One object is approximated as a sphere, to simplify things //One object is approximated as a sphere, to simplify things
@@ -358,7 +358,7 @@ float btConvexConvexAlgorithm::CalculateTimeOfImpact(btBroadphaseProxy* proxy0,b
//For proper CCD, better accuracy and handling of 'allowed' penetration should be added //For proper CCD, better accuracy and handling of 'allowed' penetration should be added
//also the mainloop of the physics should have a kind of toi queue (something like Brian Mirtich's application of Timewarp for Rigidbodies) //also the mainloop of the physics should have a kind of toi queue (something like Brian Mirtich's application of Timewarp for Rigidbodies)
bool needsCollision = m_dispatcher->NeedsCollision(m_box0,m_box1); bool needsCollision = m_dispatcher->needsCollision(m_box0,m_box1);
if (!needsCollision) if (!needsCollision)
return 1.f; return 1.f;

View File

@@ -40,7 +40,7 @@ public:
btPersistentManifold* m_manifoldPtr; btPersistentManifold* m_manifoldPtr;
bool m_lowLevelOfDetail; bool m_lowLevelOfDetail;
void CheckPenetrationDepthSolver(); void checkPenetrationDepthSolver();
@@ -50,13 +50,13 @@ public:
virtual ~btConvexConvexAlgorithm(); virtual ~btConvexConvexAlgorithm();
virtual void ProcessCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo); virtual void processCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo);
virtual float CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo); virtual float calculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo);
void SetLowLevelOfDetail(bool useLowLevel); void setLowLevelOfDetail(bool useLowLevel);
virtual void SetShapeIdentifiers(int partId0,int index0, int partId1,int index1) virtual void setShapeIdentifiers(int partId0,int index0, int partId1,int index1)
{ {
m_gjkPairDetector.m_partId0=partId0; m_gjkPairDetector.m_partId0=partId0;
m_gjkPairDetector.m_partId1=partId1; m_gjkPairDetector.m_partId1=partId1;
@@ -64,7 +64,7 @@ public:
m_gjkPairDetector.m_index1=index1; m_gjkPairDetector.m_index1=index1;
} }
const btPersistentManifold* GetManifold() const btPersistentManifold* getManifold()
{ {
return m_manifoldPtr; return m_manifoldPtr;
} }

View File

@@ -22,12 +22,12 @@ btEmptyAlgorithm::btEmptyAlgorithm(const btCollisionAlgorithmConstructionInfo& c
{ {
} }
void btEmptyAlgorithm::ProcessCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo) void btEmptyAlgorithm::processCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo)
{ {
} }
float btEmptyAlgorithm::CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo) float btEmptyAlgorithm::calculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo)
{ {
return 1.f; return 1.f;
} }

View File

@@ -29,9 +29,9 @@ public:
btEmptyAlgorithm(const btCollisionAlgorithmConstructionInfo& ci); btEmptyAlgorithm(const btCollisionAlgorithmConstructionInfo& ci);
virtual void ProcessCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo); virtual void processCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo);
virtual float CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo); virtual float calculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo);
struct CreateFunc :public btCollisionAlgorithmCreateFunc struct CreateFunc :public btCollisionAlgorithmCreateFunc
{ {

View File

@@ -51,9 +51,9 @@ btManifoldResult::btManifoldResult(btCollisionObject* body0,btCollisionObject* b
} }
void btManifoldResult::AddContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,float depth) void btManifoldResult::addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,float depth)
{ {
if (depth > m_manifoldPtr->GetContactBreakingTreshold()) if (depth > m_manifoldPtr->getContactBreakingTreshold())
return; return;
@@ -69,14 +69,14 @@ void btManifoldResult::AddContactPoint(const btVector3& normalOnBInWorld,const b
int insertIndex = m_manifoldPtr->GetCacheEntry(newPt); int insertIndex = m_manifoldPtr->getCacheEntry(newPt);
if (insertIndex >= 0) if (insertIndex >= 0)
{ {
// This is not needed, just use the old info! // This is not needed, just use the old info!
// const btManifoldPoint& oldPoint = m_manifoldPtr->GetContactPoint(insertIndex); // const btManifoldPoint& oldPoint = m_manifoldPtr->getContactPoint(insertIndex);
// newPt.CopyPersistentInformation(oldPoint); // newPt.CopyPersistentInformation(oldPoint);
// m_manifoldPtr->ReplaceContactPoint(newPt,insertIndex); // m_manifoldPtr->replaceContactPoint(newPt,insertIndex);
} else } else

View File

@@ -43,7 +43,7 @@ public:
virtual ~btManifoldResult() {}; virtual ~btManifoldResult() {};
virtual void SetShapeIdentifiers(int partId0,int index0, int partId1,int index1) virtual void setShapeIdentifiers(int partId0,int index0, int partId1,int index1)
{ {
m_partId0=partId0; m_partId0=partId0;
m_partId1=partId1; m_partId1=partId1;
@@ -51,7 +51,7 @@ public:
m_index1=index1; m_index1=index1;
} }
virtual void AddContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,float depth); virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,float depth);

View File

@@ -18,23 +18,23 @@ btSimulationIslandManager::~btSimulationIslandManager()
} }
void btSimulationIslandManager::InitUnionFind(int n) void btSimulationIslandManager::initUnionFind(int n)
{ {
m_unionFind.reset(n); m_unionFind.reset(n);
} }
void btSimulationIslandManager::FindUnions(btDispatcher* dispatcher) void btSimulationIslandManager::findUnions(btDispatcher* dispatcher)
{ {
{ {
for (int i=0;i<dispatcher->GetNumManifolds();i++) for (int i=0;i<dispatcher->getNumManifolds();i++)
{ {
const btPersistentManifold* manifold = dispatcher->GetManifoldByIndexInternal(i); const btPersistentManifold* manifold = dispatcher->getManifoldByIndexInternal(i);
//static objects (invmass 0.f) don't merge ! //static objects (invmass 0.f) don't merge !
const btCollisionObject* colObj0 = static_cast<const btCollisionObject*>(manifold->GetBody0()); const btCollisionObject* colObj0 = static_cast<const btCollisionObject*>(manifold->getBody0());
const btCollisionObject* colObj1 = static_cast<const btCollisionObject*>(manifold->GetBody1()); const btCollisionObject* colObj1 = static_cast<const btCollisionObject*>(manifold->getBody1());
if (((colObj0) && ((colObj0)->mergesSimulationIslands())) && if (((colObj0) && ((colObj0)->mergesSimulationIslands())) &&
((colObj1) && ((colObj1)->mergesSimulationIslands()))) ((colObj1) && ((colObj1)->mergesSimulationIslands())))
@@ -48,18 +48,18 @@ void btSimulationIslandManager::FindUnions(btDispatcher* dispatcher)
} }
void btSimulationIslandManager::UpdateActivationState(btCollisionWorld* colWorld,btDispatcher* dispatcher) void btSimulationIslandManager::updateActivationState(btCollisionWorld* colWorld,btDispatcher* dispatcher)
{ {
InitUnionFind(colWorld->GetCollisionObjectArray().size()); initUnionFind(colWorld->getCollisionObjectArray().size());
// put the index into m_controllers into m_tag // put the index into m_controllers into m_tag
{ {
std::vector<btCollisionObject*>::iterator i; std::vector<btCollisionObject*>::iterator i;
int index = 0; int index = 0;
for (i=colWorld->GetCollisionObjectArray().begin(); for (i=colWorld->getCollisionObjectArray().begin();
!(i==colWorld->GetCollisionObjectArray().end()); i++) !(i==colWorld->getCollisionObjectArray().end()); i++)
{ {
btCollisionObject* collisionObject= (*i); btCollisionObject* collisionObject= (*i);
@@ -71,7 +71,7 @@ void btSimulationIslandManager::UpdateActivationState(btCollisionWorld* colWorld
} }
// do the union find // do the union find
FindUnions(dispatcher); findUnions(dispatcher);
@@ -80,7 +80,7 @@ void btSimulationIslandManager::UpdateActivationState(btCollisionWorld* colWorld
void btSimulationIslandManager::StoreIslandActivationState(btCollisionWorld* colWorld) void btSimulationIslandManager::storeIslandActivationState(btCollisionWorld* colWorld)
{ {
// put the islandId ('find' value) into m_tag // put the islandId ('find' value) into m_tag
{ {
@@ -89,8 +89,8 @@ void btSimulationIslandManager::StoreIslandActivationState(btCollisionWorld* col
std::vector<btCollisionObject*>::iterator i; std::vector<btCollisionObject*>::iterator i;
int index = 0; int index = 0;
for (i=colWorld->GetCollisionObjectArray().begin(); for (i=colWorld->getCollisionObjectArray().begin();
!(i==colWorld->GetCollisionObjectArray().end()); i++) !(i==colWorld->getCollisionObjectArray().end()); i++)
{ {
btCollisionObject* collisionObject= (*i); btCollisionObject* collisionObject= (*i);
@@ -109,8 +109,8 @@ void btSimulationIslandManager::StoreIslandActivationState(btCollisionWorld* col
inline int getIslandId(const btPersistentManifold* lhs) inline int getIslandId(const btPersistentManifold* lhs)
{ {
int islandId; int islandId;
const btCollisionObject* rcolObj0 = static_cast<const btCollisionObject*>(lhs->GetBody0()); const btCollisionObject* rcolObj0 = static_cast<const btCollisionObject*>(lhs->getBody0());
const btCollisionObject* rcolObj1 = static_cast<const btCollisionObject*>(lhs->GetBody1()); const btCollisionObject* rcolObj1 = static_cast<const btCollisionObject*>(lhs->getBody1());
islandId= rcolObj0->m_islandTag1>=0?rcolObj0->m_islandTag1:rcolObj1->m_islandTag1; islandId= rcolObj0->m_islandTag1>=0?rcolObj0->m_islandTag1:rcolObj1->m_islandTag1;
return islandId; return islandId;
@@ -128,21 +128,21 @@ bool btPersistentManifoldSortPredicate(const btPersistentManifold* lhs, const bt
// //
// todo: this is random access, it can be walked 'cache friendly'! // todo: this is random access, it can be walked 'cache friendly'!
// //
void btSimulationIslandManager::BuildAndProcessIslands(btDispatcher* dispatcher,btCollisionObjectArray& collisionObjects, IslandCallback* callback) void btSimulationIslandManager::buildAndProcessIslands(btDispatcher* dispatcher,btCollisionObjectArray& collisionObjects, IslandCallback* callback)
{ {
//we are going to sort the unionfind array, and store the element id in the size //we are going to sort the unionfind array, and store the element id in the size
//afterwards, we clean unionfind, to make sure no-one uses it anymore //afterwards, we clean unionfind, to make sure no-one uses it anymore
GetUnionFind().sortIslands(); getUnionFind().sortIslands();
int numElem = GetUnionFind().getNumElements(); int numElem = getUnionFind().getNumElements();
int endIslandIndex=1; int endIslandIndex=1;
//update the sleeping state for bodies, if all are sleeping //update the sleeping state for bodies, if all are sleeping
for (int startIslandIndex=0;startIslandIndex<numElem;startIslandIndex = endIslandIndex) for (int startIslandIndex=0;startIslandIndex<numElem;startIslandIndex = endIslandIndex)
{ {
int islandId = GetUnionFind().getElement(startIslandIndex).m_id; int islandId = getUnionFind().getElement(startIslandIndex).m_id;
for (endIslandIndex = startIslandIndex+1;(endIslandIndex<numElem) && (GetUnionFind().getElement(endIslandIndex).m_id == islandId);endIslandIndex++) for (endIslandIndex = startIslandIndex+1;(endIslandIndex<numElem) && (getUnionFind().getElement(endIslandIndex).m_id == islandId);endIslandIndex++)
{ {
} }
@@ -153,7 +153,7 @@ void btSimulationIslandManager::BuildAndProcessIslands(btDispatcher* dispatcher,
int idx; int idx;
for (idx=startIslandIndex;idx<endIslandIndex;idx++) for (idx=startIslandIndex;idx<endIslandIndex;idx++)
{ {
int i = GetUnionFind().getElement(idx).m_sz; int i = getUnionFind().getElement(idx).m_sz;
btCollisionObject* colObj0 = collisionObjects[i]; btCollisionObject* colObj0 = collisionObjects[i];
if ((colObj0->m_islandTag1 != islandId) && (colObj0->m_islandTag1 != -1)) if ((colObj0->m_islandTag1 != islandId) && (colObj0->m_islandTag1 != -1))
@@ -180,7 +180,7 @@ void btSimulationIslandManager::BuildAndProcessIslands(btDispatcher* dispatcher,
int idx; int idx;
for (idx=startIslandIndex;idx<endIslandIndex;idx++) for (idx=startIslandIndex;idx<endIslandIndex;idx++)
{ {
int i = GetUnionFind().getElement(idx).m_sz; int i = getUnionFind().getElement(idx).m_sz;
btCollisionObject* colObj0 = collisionObjects[i]; btCollisionObject* colObj0 = collisionObjects[i];
if ((colObj0->m_islandTag1 != islandId) && (colObj0->m_islandTag1 != -1)) if ((colObj0->m_islandTag1 != islandId) && (colObj0->m_islandTag1 != -1))
{ {
@@ -200,7 +200,7 @@ void btSimulationIslandManager::BuildAndProcessIslands(btDispatcher* dispatcher,
int idx; int idx;
for (idx=startIslandIndex;idx<endIslandIndex;idx++) for (idx=startIslandIndex;idx<endIslandIndex;idx++)
{ {
int i = GetUnionFind().getElement(idx).m_sz; int i = getUnionFind().getElement(idx).m_sz;
btCollisionObject* colObj0 = collisionObjects[i]; btCollisionObject* colObj0 = collisionObjects[i];
if ((colObj0->m_islandTag1 != islandId) && (colObj0->m_islandTag1 != -1)) if ((colObj0->m_islandTag1 != islandId) && (colObj0->m_islandTag1 != -1))
@@ -223,22 +223,22 @@ void btSimulationIslandManager::BuildAndProcessIslands(btDispatcher* dispatcher,
std::vector<btPersistentManifold*> islandmanifold; std::vector<btPersistentManifold*> islandmanifold;
int i; int i;
int maxNumManifolds = dispatcher->GetNumManifolds(); int maxNumManifolds = dispatcher->getNumManifolds();
islandmanifold.reserve(maxNumManifolds); islandmanifold.reserve(maxNumManifolds);
for (i=0;i<maxNumManifolds ;i++) for (i=0;i<maxNumManifolds ;i++)
{ {
btPersistentManifold* manifold = dispatcher->GetManifoldByIndexInternal(i); btPersistentManifold* manifold = dispatcher->getManifoldByIndexInternal(i);
btCollisionObject* colObj0 = static_cast<btCollisionObject*>(manifold->GetBody0()); btCollisionObject* colObj0 = static_cast<btCollisionObject*>(manifold->getBody0());
btCollisionObject* colObj1 = static_cast<btCollisionObject*>(manifold->GetBody1()); btCollisionObject* colObj1 = static_cast<btCollisionObject*>(manifold->getBody1());
//todo: check sleeping conditions! //todo: check sleeping conditions!
if (((colObj0) && colObj0->GetActivationState() != ISLAND_SLEEPING) || if (((colObj0) && colObj0->GetActivationState() != ISLAND_SLEEPING) ||
((colObj1) && colObj1->GetActivationState() != ISLAND_SLEEPING)) ((colObj1) && colObj1->GetActivationState() != ISLAND_SLEEPING))
{ {
//filtering for response //filtering for response
if (dispatcher->NeedsResponse(*colObj0,*colObj1)) if (dispatcher->needsResponse(*colObj0,*colObj1))
islandmanifold.push_back(manifold); islandmanifold.push_back(manifold);
} }
} }

View File

@@ -32,16 +32,16 @@ public:
virtual ~btSimulationIslandManager(); virtual ~btSimulationIslandManager();
void InitUnionFind(int n); void initUnionFind(int n);
btUnionFind& GetUnionFind() { return m_unionFind;} btUnionFind& getUnionFind() { return m_unionFind;}
virtual void UpdateActivationState(btCollisionWorld* colWorld,btDispatcher* dispatcher); virtual void updateActivationState(btCollisionWorld* colWorld,btDispatcher* dispatcher);
virtual void StoreIslandActivationState(btCollisionWorld* world); virtual void storeIslandActivationState(btCollisionWorld* world);
void FindUnions(btDispatcher* dispatcher); void findUnions(btDispatcher* dispatcher);
@@ -52,7 +52,7 @@ public:
virtual void ProcessIsland(class btPersistentManifold** manifolds,int numManifolds) = 0; virtual void ProcessIsland(class btPersistentManifold** manifolds,int numManifolds) = 0;
}; };
void BuildAndProcessIslands(btDispatcher* dispatcher,btCollisionObjectArray& collisionObjects, IslandCallback* callback); void buildAndProcessIslands(btDispatcher* dispatcher,btCollisionObjectArray& collisionObjects, IslandCallback* callback);
}; };

View File

@@ -23,9 +23,9 @@ btSphereSphereCollisionAlgorithm::btSphereSphereCollisionAlgorithm(btPersistentM
m_ownManifold(false), m_ownManifold(false),
m_manifoldPtr(mf) m_manifoldPtr(mf)
{ {
if (!m_manifoldPtr && m_dispatcher->NeedsCollision(*proxy0,*proxy1)) if (!m_manifoldPtr && m_dispatcher->needsCollision(*proxy0,*proxy1))
{ {
m_manifoldPtr = m_dispatcher->GetNewManifold(proxy0->m_clientObject,proxy1->m_clientObject); m_manifoldPtr = m_dispatcher->getNewManifold(proxy0->m_clientObject,proxy1->m_clientObject);
m_ownManifold = true; m_ownManifold = true;
} }
} }
@@ -35,11 +35,11 @@ btSphereSphereCollisionAlgorithm::~btSphereSphereCollisionAlgorithm()
if (m_ownManifold) if (m_ownManifold)
{ {
if (m_manifoldPtr) if (m_manifoldPtr)
m_dispatcher->ReleaseManifold(m_manifoldPtr); m_dispatcher->releaseManifold(m_manifoldPtr);
} }
} }
void btSphereSphereCollisionAlgorithm::ProcessCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo) void btSphereSphereCollisionAlgorithm::processCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo)
{ {
if (!m_manifoldPtr) if (!m_manifoldPtr)
return; return;
@@ -51,8 +51,8 @@ void btSphereSphereCollisionAlgorithm::ProcessCollision (btBroadphaseProxy* prox
btVector3 diff = col0->m_worldTransform.getOrigin()- col1->m_worldTransform.getOrigin(); btVector3 diff = col0->m_worldTransform.getOrigin()- col1->m_worldTransform.getOrigin();
float len = diff.length(); float len = diff.length();
btScalar radius0 = sphere0->GetRadius(); btScalar radius0 = sphere0->getRadius();
btScalar radius1 = sphere1->GetRadius(); btScalar radius1 = sphere1->getRadius();
///iff distance positive, don't generate a new contact ///iff distance positive, don't generate a new contact
if ( len > (radius0+radius1)) if ( len > (radius0+radius1))
@@ -68,13 +68,13 @@ void btSphereSphereCollisionAlgorithm::ProcessCollision (btBroadphaseProxy* prox
btVector3 pos1 = col1->m_worldTransform.getOrigin() + radius1* normalOnSurfaceB; btVector3 pos1 = col1->m_worldTransform.getOrigin() + radius1* normalOnSurfaceB;
/// report a contact. internally this will be kept persistent, and contact reduction is done /// report a contact. internally this will be kept persistent, and contact reduction is done
btManifoldResult* resultOut = m_dispatcher->GetNewManifoldResult(col0,col1,m_manifoldPtr); btManifoldResult* resultOut = m_dispatcher->getNewManifoldResult(col0,col1,m_manifoldPtr);
resultOut->AddContactPoint(normalOnSurfaceB,pos1,dist); resultOut->addContactPoint(normalOnSurfaceB,pos1,dist);
m_dispatcher->ReleaseManifoldResult(resultOut); m_dispatcher->releaseManifoldResult(resultOut);
} }
float btSphereSphereCollisionAlgorithm::CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo) float btSphereSphereCollisionAlgorithm::calculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo)
{ {
//not yet //not yet
return 1.f; return 1.f;

View File

@@ -33,9 +33,9 @@ public:
btSphereSphereCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci) btSphereSphereCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci)
: btCollisionAlgorithm(ci) {} : btCollisionAlgorithm(ci) {}
virtual void ProcessCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo); virtual void processCollision (btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo);
virtual float CalculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo); virtual float calculateTimeOfImpact(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1,const btDispatcherInfo& dispatchInfo);
btSphereSphereCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1); btSphereSphereCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);

View File

@@ -30,7 +30,7 @@ btUnionFind::btUnionFind()
} }
void btUnionFind::Allocate(int N) void btUnionFind::allocate(int N)
{ {
m_elements.resize(N); m_elements.resize(N);
} }
@@ -42,7 +42,7 @@ void btUnionFind::Free()
void btUnionFind::reset(int N) void btUnionFind::reset(int N)
{ {
Allocate(N); allocate(N);
for (int i = 0; i < N; i++) for (int i = 0; i < N; i++)
{ {

View File

@@ -61,7 +61,7 @@ class btUnionFind
return m_elements[index]; return m_elements[index];
} }
void Allocate(int N); void allocate(int N);
void Free(); void Free();

View File

@@ -15,23 +15,23 @@ subject to the following restrictions:
#include "btBoxShape.h" #include "btBoxShape.h"
btVector3 btBoxShape::GetHalfExtents() const btVector3 btBoxShape::getHalfExtents() const
{ {
return m_boxHalfExtents1 * m_localScaling; return m_boxHalfExtents1 * m_localScaling;
} }
//{ //{
void btBoxShape::GetAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const void btBoxShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
{ {
btVector3 halfExtents = GetHalfExtents(); btVector3 halfExtents = getHalfExtents();
btMatrix3x3 abs_b = t.getBasis().absolute(); btMatrix3x3 abs_b = t.getBasis().absolute();
btPoint3 center = t.getOrigin(); btPoint3 center = t.getOrigin();
btVector3 extent = btVector3(abs_b[0].dot(halfExtents), btVector3 extent = btVector3(abs_b[0].dot(halfExtents),
abs_b[1].dot(halfExtents), abs_b[1].dot(halfExtents),
abs_b[2].dot(halfExtents)); abs_b[2].dot(halfExtents));
extent += btVector3(GetMargin(),GetMargin(),GetMargin()); extent += btVector3(getMargin(),getMargin(),getMargin());
aabbMin = center - extent; aabbMin = center - extent;
aabbMax = center + extent; aabbMax = center + extent;
@@ -40,10 +40,10 @@ void btBoxShape::GetAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabb
} }
void btBoxShape::CalculateLocalInertia(btScalar mass,btVector3& inertia) void btBoxShape::calculateLocalInertia(btScalar mass,btVector3& inertia)
{ {
//float margin = 0.f; //float margin = 0.f;
btVector3 halfExtents = GetHalfExtents(); btVector3 halfExtents = getHalfExtents();
btScalar lx=2.f*(halfExtents.x()); btScalar lx=2.f*(halfExtents.x());
btScalar ly=2.f*(halfExtents.y()); btScalar ly=2.f*(halfExtents.y());

Some files were not shown because too many files have changed in this diff Show More