remove constraints/rigid bodies from dynamics world in btBulletWorldImporter
Thanks to vicariousentertainment, see http://code.google.com/p/dynamica/issues/detail?id=16 Enable SIMD OpenCL cloth solver by default enable keyboard 'up' for Windows (non-Glut) version
This commit is contained in:
@@ -38,7 +38,7 @@ class btDX11SIMDAwareSoftBodySolver;
|
|||||||
#include "BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h"
|
#include "BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h"
|
||||||
|
|
||||||
#define USE_SIMDAWARE_SOLVER
|
#define USE_SIMDAWARE_SOLVER
|
||||||
#define USE_GPU_SOLVER
|
//#define USE_GPU_SOLVER
|
||||||
#define USE_GPU_COPY
|
#define USE_GPU_COPY
|
||||||
const int numFlags = 5;
|
const int numFlags = 5;
|
||||||
const int clothWidth = 40;
|
const int clothWidth = 40;
|
||||||
|
|||||||
@@ -306,6 +306,9 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
{
|
||||||
|
gDemoApplication->keyboardUpCallback(tolower(wParam),0,0);
|
||||||
|
}
|
||||||
return DefWindowProc( hWnd, message, wParam, lParam );
|
return DefWindowProc( hWnd, message, wParam, lParam );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -502,6 +502,13 @@ public:
|
|||||||
#endif //DESERIALIZE_SOFT_BODIES
|
#endif //DESERIALIZE_SOFT_BODIES
|
||||||
|
|
||||||
|
|
||||||
|
SerializeDemo::~SerializeDemo()
|
||||||
|
{
|
||||||
|
m_fileLoader->deleteAllData();
|
||||||
|
delete m_fileLoader;
|
||||||
|
exitPhysics();
|
||||||
|
}
|
||||||
|
|
||||||
void SerializeDemo::initPhysics()
|
void SerializeDemo::initPhysics()
|
||||||
{
|
{
|
||||||
setTexturing(true);
|
setTexturing(true);
|
||||||
@@ -512,14 +519,14 @@ void SerializeDemo::initPhysics()
|
|||||||
setupEmptyDynamicsWorld();
|
setupEmptyDynamicsWorld();
|
||||||
|
|
||||||
#ifdef DESERIALIZE_SOFT_BODIES
|
#ifdef DESERIALIZE_SOFT_BODIES
|
||||||
btBulletWorldImporter* fileLoader = new MySoftBulletWorldImporter((btSoftRigidDynamicsWorld*)m_dynamicsWorld);
|
m_fileLoader = new MySoftBulletWorldImporter((btSoftRigidDynamicsWorld*)m_dynamicsWorld);
|
||||||
#else
|
#else
|
||||||
btBulletWorldImporter* fileLoader = new btBulletWorldImporter(m_dynamicsWorld);
|
m_fileLoader = new btBulletWorldImporter(m_dynamicsWorld);
|
||||||
#endif //DESERIALIZE_SOFT_BODIES
|
#endif //DESERIALIZE_SOFT_BODIES
|
||||||
// fileLoader->setVerboseMode(true);
|
// fileLoader->setVerboseMode(true);
|
||||||
|
|
||||||
if (!fileLoader->loadFile("testFile.bullet"))
|
if (!m_fileLoader->loadFile("testFile.bullet"))
|
||||||
// if (!fileLoader->loadFile("../SoftDemo/testFile.bullet"))
|
// if (!m_fileLoader->loadFile("../SoftDemo/testFile.bullet"))
|
||||||
{
|
{
|
||||||
///create a few basic rigid bodies and save them to testFile.bullet
|
///create a few basic rigid bodies and save them to testFile.bullet
|
||||||
btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.)));
|
btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.)));
|
||||||
|
|||||||
@@ -49,15 +49,15 @@ class SerializeDemo : public PlatformDemoApplication
|
|||||||
|
|
||||||
btDefaultCollisionConfiguration* m_collisionConfiguration;
|
btDefaultCollisionConfiguration* m_collisionConfiguration;
|
||||||
|
|
||||||
|
class btBulletWorldImporter* m_fileLoader;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SerializeDemo()
|
SerializeDemo()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
virtual ~SerializeDemo()
|
virtual ~SerializeDemo();
|
||||||
{
|
|
||||||
exitPhysics();
|
|
||||||
}
|
|
||||||
void initPhysics();
|
void initPhysics();
|
||||||
|
|
||||||
void setupEmptyDynamicsWorld();
|
void setupEmptyDynamicsWorld();
|
||||||
|
|||||||
@@ -25,24 +25,32 @@ btBulletWorldImporter::~btBulletWorldImporter()
|
|||||||
void btBulletWorldImporter::deleteAllData()
|
void btBulletWorldImporter::deleteAllData()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
for (i=0;i<m_allocatedConstraints.size();i++)
|
||||||
|
{
|
||||||
|
if(m_dynamicsWorld)
|
||||||
|
m_dynamicsWorld->removeConstraint(m_allocatedConstraints[i]);
|
||||||
|
delete m_allocatedConstraints[i];
|
||||||
|
}
|
||||||
|
m_allocatedConstraints.clear();
|
||||||
|
|
||||||
|
|
||||||
|
for (i=0;i<m_allocatedRigidBodies.size();i++)
|
||||||
|
{
|
||||||
|
if(m_dynamicsWorld)
|
||||||
|
m_dynamicsWorld->removeRigidBody(btRigidBody::upcast(m_allocatedRigidBodies[i]));
|
||||||
|
delete m_allocatedRigidBodies[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
m_allocatedRigidBodies.clear();
|
||||||
|
|
||||||
|
|
||||||
for (i=0;i<m_allocatedCollisionShapes.size();i++)
|
for (i=0;i<m_allocatedCollisionShapes.size();i++)
|
||||||
{
|
{
|
||||||
delete m_allocatedCollisionShapes[i];
|
delete m_allocatedCollisionShapes[i];
|
||||||
}
|
}
|
||||||
m_allocatedCollisionShapes.clear();
|
m_allocatedCollisionShapes.clear();
|
||||||
|
|
||||||
for (i=0;i<m_allocatedRigidBodies.size();i++)
|
|
||||||
{
|
|
||||||
delete m_allocatedRigidBodies[i];
|
|
||||||
}
|
|
||||||
m_allocatedRigidBodies.clear();
|
|
||||||
|
|
||||||
for (i=0;i<m_allocatedConstraints.size();i++)
|
|
||||||
{
|
|
||||||
delete m_allocatedConstraints[i];
|
|
||||||
}
|
|
||||||
m_allocatedConstraints.clear();
|
|
||||||
|
|
||||||
for (i=0;i<m_allocatedBvhs.size();i++)
|
for (i=0;i<m_allocatedBvhs.size();i++)
|
||||||
{
|
{
|
||||||
delete m_allocatedBvhs[i];
|
delete m_allocatedBvhs[i];
|
||||||
|
|||||||
Reference in New Issue
Block a user