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"
|
||||
|
||||
#define USE_SIMDAWARE_SOLVER
|
||||
#define USE_GPU_SOLVER
|
||||
//#define USE_GPU_SOLVER
|
||||
#define USE_GPU_COPY
|
||||
const int numFlags = 5;
|
||||
const int clothWidth = 40;
|
||||
|
||||
@@ -306,6 +306,9 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
return 0;
|
||||
}
|
||||
default:
|
||||
{
|
||||
gDemoApplication->keyboardUpCallback(tolower(wParam),0,0);
|
||||
}
|
||||
return DefWindowProc( hWnd, message, wParam, lParam );
|
||||
}
|
||||
|
||||
|
||||
@@ -502,6 +502,13 @@ public:
|
||||
#endif //DESERIALIZE_SOFT_BODIES
|
||||
|
||||
|
||||
SerializeDemo::~SerializeDemo()
|
||||
{
|
||||
m_fileLoader->deleteAllData();
|
||||
delete m_fileLoader;
|
||||
exitPhysics();
|
||||
}
|
||||
|
||||
void SerializeDemo::initPhysics()
|
||||
{
|
||||
setTexturing(true);
|
||||
@@ -512,14 +519,14 @@ void SerializeDemo::initPhysics()
|
||||
setupEmptyDynamicsWorld();
|
||||
|
||||
#ifdef DESERIALIZE_SOFT_BODIES
|
||||
btBulletWorldImporter* fileLoader = new MySoftBulletWorldImporter((btSoftRigidDynamicsWorld*)m_dynamicsWorld);
|
||||
m_fileLoader = new MySoftBulletWorldImporter((btSoftRigidDynamicsWorld*)m_dynamicsWorld);
|
||||
#else
|
||||
btBulletWorldImporter* fileLoader = new btBulletWorldImporter(m_dynamicsWorld);
|
||||
m_fileLoader = new btBulletWorldImporter(m_dynamicsWorld);
|
||||
#endif //DESERIALIZE_SOFT_BODIES
|
||||
// fileLoader->setVerboseMode(true);
|
||||
|
||||
if (!fileLoader->loadFile("testFile.bullet"))
|
||||
// if (!fileLoader->loadFile("../SoftDemo/testFile.bullet"))
|
||||
if (!m_fileLoader->loadFile("testFile.bullet"))
|
||||
// if (!m_fileLoader->loadFile("../SoftDemo/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.)));
|
||||
|
||||
@@ -49,15 +49,15 @@ class SerializeDemo : public PlatformDemoApplication
|
||||
|
||||
btDefaultCollisionConfiguration* m_collisionConfiguration;
|
||||
|
||||
class btBulletWorldImporter* m_fileLoader;
|
||||
|
||||
public:
|
||||
|
||||
SerializeDemo()
|
||||
{
|
||||
}
|
||||
virtual ~SerializeDemo()
|
||||
{
|
||||
exitPhysics();
|
||||
}
|
||||
virtual ~SerializeDemo();
|
||||
|
||||
void initPhysics();
|
||||
|
||||
void setupEmptyDynamicsWorld();
|
||||
|
||||
@@ -25,23 +25,31 @@ btBulletWorldImporter::~btBulletWorldImporter()
|
||||
void btBulletWorldImporter::deleteAllData()
|
||||
{
|
||||
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++)
|
||||
{
|
||||
delete m_allocatedCollisionShapes[i];
|
||||
}
|
||||
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++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user