perform GrahamScanConvexHull2D around an arbitrary oriented 2D plane in 3D, to fix some convex hull face merging problems

add compound shape support to BulletXmlWorldImporter and fix some compile issue under Debian (hopefully)
object picking change in the demos: create a ball-socket picking constraint when holding shift while mouse dragging, otherwise a fixed (6dof) constraint
add assert in constraint solver, when both objects have their inertia tensor rows set to zero
btPolyhedralContactClipping: add edge-edge contact point in  findSeparatingAxis (similar to the default GJK case)
This commit is contained in:
erwin.coumans
2012-09-28 07:14:48 +00:00
parent 837e5cb5e0
commit 60bf599246
24 changed files with 385 additions and 153 deletions

View File

@@ -34,6 +34,9 @@ subject to the following restrictions:
#include "btBulletDynamicsCommon.h"
#include <stdio.h> //printf debugging
#include "GLDebugDrawer.h"
static GLDebugDrawer gDebugDraw;
void BasicDemo::clientMoveAndDisplay()
@@ -100,11 +103,13 @@ void BasicDemo::initPhysics()
m_solver = sol;
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
m_dynamicsWorld->setDebugDrawer(&gDebugDraw);
m_dynamicsWorld->setGravity(btVector3(0,-10,0));
///create a few basic rigid bodies
btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.)));
btBoxShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.)));
//groundShape->initializePolyhedralFeatures();
// btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),50);
m_collisionShapes.push_back(groundShape);
@@ -138,7 +143,7 @@ void BasicDemo::initPhysics()
//create a few dynamic rigidbodies
// Re-using the same collision is better for memory usage and performance
btCollisionShape* colShape = new btBoxShape(btVector3(SCALING*1,SCALING*1,SCALING*1));
btBoxShape* colShape = new btBoxShape(btVector3(SCALING*1,SCALING*1,SCALING*1));
//btCollisionShape* colShape = new btSphereShape(btScalar(1.));
m_collisionShapes.push_back(colShape);

View File

@@ -19,8 +19,6 @@ subject to the following restrictions:
#include "LinearMath/btHashMap.h"
int main(int argc,char** argv)
{

View File

@@ -28,15 +28,24 @@ subject to the following restrictions:
#include <stdio.h> //printf debugging
#include "GLDebugDrawer.h"
GLDebugDrawer gDebugDrawer;
void BulletXmlImportDemo::initPhysics()
{
setTexturing(true);
setTexturing(true);
setShadows(true);
setCameraDistance(btScalar(30.));
setupEmptyDynamicsWorld();
m_dynamicsWorld->setDebugDrawer(&gDebugDrawer);
btBulletXmlWorldImporter* importer = new btBulletXmlWorldImporter(m_dynamicsWorld);
importer->loadFile("bullet_basic.xml");
// importer->loadFile("bulletser.xml");
@@ -54,6 +63,8 @@ void BulletXmlImportDemo::clientMoveAndDisplay()
///step the simulation
if (m_dynamicsWorld)
{
m_dynamicsWorld->stepSimulation(ms / 1000000.f);
m_dynamicsWorld->debugDrawWorld();
}
@@ -90,6 +101,7 @@ void BulletXmlImportDemo::setupEmptyDynamicsWorld()
///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded)
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
btGImpactCollisionAlgorithm::registerAlgorithm(m_dispatcher);
m_broadphase = new btDbvtBroadphase();
@@ -101,7 +113,7 @@ void BulletXmlImportDemo::setupEmptyDynamicsWorld()
//btGImpactCollisionAlgorithm::registerAlgorithm((btCollisionDispatcher*)m_dynamicsWorld->getDispatcher());
m_dynamicsWorld->setGravity(btVector3(0,-10,0));
}
@@ -115,7 +127,11 @@ BulletXmlImportDemo::~BulletXmlImportDemo()
exitPhysics();
}
void BulletXmlImportDemo::clientResetScene()
{
exitPhysics();
initPhysics();
}
void BulletXmlImportDemo::exitPhysics()

View File

@@ -55,9 +55,13 @@ class BulletXmlImportDemo : public PlatformDemoApplication
BulletXmlImportDemo()
{
//m_idle=true;
setCameraDistance(btScalar(30.));
}
virtual ~BulletXmlImportDemo();
virtual void clientResetScene();
void initPhysics();
void setupEmptyDynamicsWorld();

View File

@@ -11,9 +11,6 @@ SET(GLUT_ROOT ${BULLET_PHYSICS_SOURCE_DIR}/Glut)
# You shouldn't have to modify anything below this line
########################################################
IF(BUILD_AMD_OPENCL_DEMOS)
SUBDIRS(AMD)
ENDIF()
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src

View File

@@ -15,12 +15,11 @@ subject to the following restrictions:
#include "BulletXmlImportDemo.h"
#include "GlutStuff.h"
#include "GLDebugDrawer.h"
#include "btBulletDynamicsCommon.h"
#include "LinearMath/btHashMap.h"
#ifdef USE_AMD_OPENCL
@@ -84,7 +83,7 @@ bool initCL( void* glCtx, void* glDC )
int main(int argc,char** argv)
{
GLDebugDrawer gDebugDrawer;
#ifdef USE_AMD_OPENCL
bool initialized = initCL(0,0);
@@ -94,8 +93,7 @@ int main(int argc,char** argv)
BulletXmlImportDemo serializeDemo;
serializeDemo.initPhysics();
serializeDemo.getDynamicsWorld()->setDebugDrawer(&gDebugDrawer);
#ifdef CHECK_MEMORY_LEAKS
serializeDemo.exitPhysics();

View File

@@ -62,6 +62,7 @@ ENDIF()
POST_BUILD
# COMMAND copy /Y ${BULLET_PHYSICS_SOURCE_DIR}/GLUT32.DLL ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLUT32.DLL ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLUT32.DLL ${CMAKE_CURRENT_BINARY_DIR}/Debug
)
ENDIF(CMAKE_CL_64)
ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)

View File

@@ -22,12 +22,13 @@ void btFractureBody::recomputeConnectivity(btCollisionWorld* world)
struct MyContactResultCallback : public btCollisionWorld::ContactResultCallback
{
bool m_connected;
MyContactResultCallback() :m_connected(false)
btScalar m_margin;
MyContactResultCallback() :m_connected(false),m_margin(0.05)
{
}
virtual btScalar addSingleResult(btManifoldPoint& cp, const btCollisionObjectWrapper* colObj0Wrap,int partId0,int index0,const btCollisionObjectWrapper* colObj1Wrap,int partId1,int index1)
{
if (cp.getDistance()<=0)
if (cp.getDistance()<=m_margin)
m_connected = true;
return 1.f;
}

View File

@@ -33,7 +33,7 @@ subject to the following restrictions:
#include "LinearMath/btSerializer.h"
#include "GLDebugFont.h"
static bool use6Dof = false;
extern bool gDisableDeactivation;
int numObjects = 0;
const int maxNumObjects = 16384;
@@ -535,7 +535,7 @@ void DemoApplication::setShootBoxShape ()
if (!m_shootBoxShape)
{
btBoxShape* box = new btBoxShape(btVector3(0.5,0.5,0.5));
box->initializePolyhedralFeatures();
// box->initializePolyhedralFeatures();
m_shootBoxShape = box;
}
}
@@ -776,7 +776,7 @@ void DemoApplication::mouseFunc(int button, int state, int x, int y)
if (use6Dof)
if ((m_modifierKeys& BT_ACTIVE_SHIFT)==0)
{
btTransform tr;
tr.setIdentity();
@@ -822,8 +822,7 @@ void DemoApplication::mouseFunc(int button, int state, int x, int y)
}
use6Dof = !use6Dof;
//save mouse position for dragging
gOldPickingPos = rayTo;
gHitPos = pickPos;