fix in btParallelConstraintSolver to support double precision
fixes in SAT/polyhedral contact clipping, avoid adding GJK contacts (the contact margin causes different contact depths) add polyhedral convex shape in InternalEdgeDemo as example of the new SAT/polyhedral contact clipping (added reference to Manual/what's new) avoid glueing objecs with contacts that are positive (no gaps)
This commit is contained in:
@@ -275,7 +275,7 @@ void ConcaveRaycastDemo::keyboardCallback(unsigned char key, int x, int y)
|
||||
|
||||
void ConcaveRaycastDemo::initPhysics()
|
||||
{
|
||||
m_ShootBoxInitialSpeed = 1000;
|
||||
|
||||
#define TRISIZE 10.f
|
||||
|
||||
|
||||
@@ -378,37 +378,7 @@ int maxNumOutstandingTasks = 4;
|
||||
|
||||
|
||||
|
||||
{
|
||||
btVector3 camPos(0.000000,10.260604,-28.190779);
|
||||
btVector3 destination(6958.333333,-8539.096384,7501.875480);
|
||||
|
||||
float mass = 1.f;
|
||||
btTransform startTransform;
|
||||
startTransform.setIdentity();
|
||||
startTransform.setOrigin(camPos);
|
||||
|
||||
setShootBoxShape ();
|
||||
|
||||
btRigidBody* body = this->localCreateRigidBody(mass, startTransform,m_shootBoxShape);
|
||||
body->setLinearFactor(btVector3(1,1,1));
|
||||
//body->setRestitution(1);
|
||||
|
||||
btVector3 linVel(destination[0]-camPos[0],destination[1]-camPos[1],destination[2]-camPos[2]);
|
||||
linVel.normalize();
|
||||
linVel*=m_ShootBoxInitialSpeed;
|
||||
|
||||
body->getWorldTransform().setOrigin(camPos);
|
||||
body->getWorldTransform().setRotation(btQuaternion(0,0,0,1));
|
||||
body->setLinearVelocity(linVel);
|
||||
body->setAngularVelocity(btVector3(0,0,0));
|
||||
body->setCcdMotionThreshold(0.5);
|
||||
body->setCcdSweptSphereRadius(0.9f);
|
||||
printf("shootBox uid=%d\n", body->getBroadphaseHandle()->getUid());
|
||||
printf("camPos=%f,%f,%f\n",camPos.getX(),camPos.getY(),camPos.getZ());
|
||||
printf("destination=%f,%f,%f\n",destination.getX(),destination.getY(),destination.getZ());
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void ConcaveRaycastDemo::clientMoveAndDisplay()
|
||||
|
||||
@@ -56,6 +56,14 @@ void btFractureDynamicsWorld::glueCallback()
|
||||
if (!manifold->getNumContacts())
|
||||
continue;
|
||||
|
||||
btScalar minDist = 1e30f;
|
||||
for (int v=0;v<manifold->getNumContacts();v++)
|
||||
{
|
||||
minDist = btMin(minDist,manifold->getContactPoint(v).getDistance());
|
||||
}
|
||||
if (minDist>0.)
|
||||
continue;
|
||||
|
||||
btCollisionObject* colObj0 = (btCollisionObject*)manifold->getBody0();
|
||||
btCollisionObject* colObj1 = (btCollisionObject*)manifold->getBody1();
|
||||
int tag0 = (colObj0)->getIslandTag();
|
||||
|
||||
@@ -25,9 +25,10 @@ bool enable=true;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#include "btBulletDynamicsCommon.h"
|
||||
#include "BulletCollision/CollisionDispatch/btInternalEdgeUtility.h"
|
||||
|
||||
#include "Taru.mdl"
|
||||
|
||||
#include "LinearMath/btIDebugDraw.h"
|
||||
#include "GLDebugDrawer.h"
|
||||
@@ -347,17 +348,18 @@ void InternalEdgeDemo::initPhysics()
|
||||
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
|
||||
|
||||
|
||||
btVector3 worldMin(-1000,-1000,-1000);
|
||||
btVector3 worldMax(1000,1000,1000);
|
||||
m_broadphase = new btAxisSweep3(worldMin,worldMax);
|
||||
|
||||
m_broadphase = new btDbvtBroadphase();
|
||||
m_solver = new btSequentialImpulseConstraintSolver();
|
||||
m_dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
|
||||
m_dynamicsWorld->getSolverInfo().m_splitImpulse = true;
|
||||
/*
|
||||
m_dynamicsWorld->getSolverInfo().m_splitImpulse = true;
|
||||
m_dynamicsWorld->getSolverInfo().m_splitImpulsePenetrationThreshold = 1e30f;
|
||||
m_dynamicsWorld->getSolverInfo().m_maxErrorReduction = 1e30f;
|
||||
m_dynamicsWorld->getSolverInfo().m_erp =1.f;
|
||||
m_dynamicsWorld->getSolverInfo().m_erp2 = 1.f;
|
||||
|
||||
*/
|
||||
|
||||
m_dynamicsWorld->setGravity(btVector3(0,-10,0));
|
||||
|
||||
|
||||
@@ -366,24 +368,40 @@ void InternalEdgeDemo::initPhysics()
|
||||
startTransform.setIdentity();
|
||||
startTransform.setOrigin(btVector3(0,-2,0));
|
||||
|
||||
btBoxShape* colShape = new btBoxShape(btVector3(1,1,1));
|
||||
|
||||
btConvexHullShape* colShape = new btConvexHullShape();
|
||||
for (int i=0;i<TaruVtxCount;i++)
|
||||
{
|
||||
btVector3 vtx(TaruVtx[i*3],TaruVtx[i*3+1],TaruVtx[i*3+2]);
|
||||
colShape->addPoint(vtx);
|
||||
}
|
||||
//this will enable polyhedral contact clipping, better quality, slightly slower
|
||||
colShape->initializePolyhedralFeatures();
|
||||
|
||||
//colShape->setMargin(0.f);
|
||||
colShape->setMargin(0.1f);
|
||||
|
||||
//the polyhedral contact clipping can use either GJK or SAT test to find the separating axis
|
||||
m_dynamicsWorld->getDispatchInfo().m_enableSatConvex=false;
|
||||
|
||||
m_collisionShapes.push_back(colShape);
|
||||
|
||||
{
|
||||
for (int i=0;i<1;i++)
|
||||
{
|
||||
startTransform.setOrigin(btVector3(-10.f+i*3.f,1.f+btScalar(i)*0.1f,-1.3f));
|
||||
btRigidBody* body = localCreateRigidBody(100, startTransform,colShape);
|
||||
startTransform.setOrigin(btVector3(-10.f+i*3.f,2.2f+btScalar(i)*0.1f,-1.3f));
|
||||
btRigidBody* body = localCreateRigidBody(10, startTransform,colShape);
|
||||
body->setActivationState(DISABLE_DEACTIVATION);
|
||||
body->setLinearVelocity(btVector3(0,0,-1));
|
||||
//body->setContactProcessingThreshold(0.f);
|
||||
}
|
||||
}
|
||||
{
|
||||
btBoxShape* colShape = new btBoxShape(btVector3(1,1,1));
|
||||
colShape->initializePolyhedralFeatures();
|
||||
m_collisionShapes.push_back(colShape);
|
||||
startTransform.setOrigin(btVector3(-16.f+i*3.f,1.f+btScalar(i)*0.1f,-1.3f));
|
||||
btRigidBody* body = localCreateRigidBody(10, startTransform,colShape);
|
||||
body->setActivationState(DISABLE_DEACTIVATION);
|
||||
body->setLinearVelocity(btVector3(0,0,-1));
|
||||
}
|
||||
|
||||
startTransform.setIdentity();
|
||||
#ifdef ROTATE_GROUND
|
||||
@@ -471,8 +489,9 @@ void InternalEdgeDemo::clientMoveAndDisplay()
|
||||
|
||||
#endif
|
||||
|
||||
//clear all contact points involving mesh proxy. Note: this is a slow/unoptimized operation.
|
||||
m_dynamicsWorld->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(staticBody->getBroadphaseHandle(),getDynamicsWorld()->getDispatcher());
|
||||
|
||||
//for debugging: clear all contact points involving mesh proxy. Note: this is a slow/unoptimized operation.
|
||||
//m_dynamicsWorld->getBroadphase()->getOverlappingPairCache()->cleanProxyFromPairs(staticBody->getBroadphaseHandle(),getDynamicsWorld()->getDispatcher());
|
||||
}
|
||||
|
||||
|
||||
|
||||
49
Demos/InternalEdgeDemo/Taru.mdl
Normal file
49
Demos/InternalEdgeDemo/Taru.mdl
Normal file
@@ -0,0 +1,49 @@
|
||||
#define TaruVtxCount 43
|
||||
#define TaruIdxCount 132
|
||||
|
||||
static float TaruVtx[] = {
|
||||
1.08664f,-1.99237f,0.0f,
|
||||
0.768369f,-1.99237f,-0.768369f,
|
||||
1.28852f,1.34412e-007f,-1.28852f,
|
||||
1.82224f,1.90735e-007f,0.0f,
|
||||
0.0f,-1.99237f,-1.08664f,
|
||||
0.0f,0.0f,-1.82224f,
|
||||
0.0f,-1.99237f,-1.08664f,
|
||||
-0.768369f,-1.99237f,-0.768369f,
|
||||
-1.28852f,1.34412e-007f,-1.28852f,
|
||||
0.0f,0.0f,-1.82224f,
|
||||
-1.08664f,-1.99237f,1.82086e-007f,
|
||||
-1.82224f,1.90735e-007f,1.59305e-007f,
|
||||
-0.768369f,-1.99237f,0.76837f,
|
||||
-1.28852f,2.47058e-007f,1.28852f,
|
||||
1.42495e-007f,-1.99237f,1.08664f,
|
||||
2.38958e-007f,2.70388e-007f,1.82224f,
|
||||
0.768369f,-1.99237f,0.768369f,
|
||||
1.28852f,2.47058e-007f,1.28852f,
|
||||
0.768369f,1.99237f,-0.768369f,
|
||||
1.08664f,1.99237f,0.0f,
|
||||
0.0f,1.99237f,-1.08664f,
|
||||
-0.768369f,1.99237f,-0.768369f,
|
||||
0.0f,1.99237f,-1.08664f,
|
||||
-1.08664f,1.99237f,0.0f,
|
||||
-0.768369f,1.99237f,0.768369f,
|
||||
1.42495e-007f,1.99237f,1.08664f,
|
||||
0.768369f,1.99237f,0.768369f,
|
||||
1.42495e-007f,-1.99237f,1.08664f,
|
||||
-0.768369f,-1.99237f,0.76837f,
|
||||
-1.08664f,-1.99237f,1.82086e-007f,
|
||||
-0.768369f,-1.99237f,-0.768369f,
|
||||
0.0f,-1.99237f,-1.08664f,
|
||||
0.768369f,-1.99237f,-0.768369f,
|
||||
1.08664f,-1.99237f,0.0f,
|
||||
0.768369f,-1.99237f,0.768369f,
|
||||
0.768369f,1.99237f,-0.768369f,
|
||||
0.0f,1.99237f,-1.08664f,
|
||||
-0.768369f,1.99237f,-0.768369f,
|
||||
-1.08664f,1.99237f,0.0f,
|
||||
-0.768369f,1.99237f,0.768369f,
|
||||
1.42495e-007f,1.99237f,1.08664f,
|
||||
0.768369f,1.99237f,0.768369f,
|
||||
1.08664f,1.99237f,0.0f,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user