Enable graphical benchmark by default in cmake
Toggle between point to point and generic 6dof constraint for mouse picking in the demos Use a 'equal vertex thresdhold' in the btVoronoiSimplexSolver of 0.0001f by default. This can be disabled (or configured) using defaultCollisionConfiguration->getSimplexSolver()->setEqualVertexThreshold(0.f); See http://code.google.com/p/bullet/issues/detail?id=305
This commit is contained in:
@@ -14,7 +14,7 @@ ENDIF (NOT CMAKE_BUILD_TYPE)
|
|||||||
|
|
||||||
|
|
||||||
OPTION(USE_DOUBLE_PRECISION "Use double precision" OFF)
|
OPTION(USE_DOUBLE_PRECISION "Use double precision" OFF)
|
||||||
OPTION(USE_GRAPHICAL_BENCHMARK "Use Graphical Benchmark" OFF)
|
OPTION(USE_GRAPHICAL_BENCHMARK "Use Graphical Benchmark" ON)
|
||||||
OPTION(USE_MULTITHREADED_BENCHMARK "Use Multithreaded Benchmark" OFF)
|
OPTION(USE_MULTITHREADED_BENCHMARK "Use Multithreaded Benchmark" OFF)
|
||||||
|
|
||||||
IF (USE_MULTITHREADED_BENCHMARK)
|
IF (USE_MULTITHREADED_BENCHMARK)
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#undef USE_PARALLEL_SOLVER_BENCHMARK
|
||||||
#ifdef USE_PARALLEL_SOLVER_BENCHMARK
|
#ifdef USE_PARALLEL_SOLVER_BENCHMARK
|
||||||
#include "BulletMultiThreaded/btParallelConstraintSolver.h"
|
#include "BulletMultiThreaded/btParallelConstraintSolver.h"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ subject to the following restrictions:
|
|||||||
#include "DemoApplication.h"
|
#include "DemoApplication.h"
|
||||||
#include "LinearMath/btIDebugDraw.h"
|
#include "LinearMath/btIDebugDraw.h"
|
||||||
#include "BulletDynamics/Dynamics/btDynamicsWorld.h"
|
#include "BulletDynamics/Dynamics/btDynamicsWorld.h"
|
||||||
//#define USE_6DOF 1
|
|
||||||
#include "BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h"//picking
|
#include "BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h"//picking
|
||||||
#include "BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h"//picking
|
#include "BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h"//picking
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ subject to the following restrictions:
|
|||||||
#include "LinearMath/btSerializer.h"
|
#include "LinearMath/btSerializer.h"
|
||||||
#include "GLDebugFont.h"
|
#include "GLDebugFont.h"
|
||||||
|
|
||||||
|
static bool use6Dof = false;
|
||||||
extern bool gDisableDeactivation;
|
extern bool gDisableDeactivation;
|
||||||
int numObjects = 0;
|
int numObjects = 0;
|
||||||
const int maxNumObjects = 16384;
|
const int maxNumObjects = 16384;
|
||||||
@@ -554,6 +554,7 @@ void DemoApplication::shootBox(const btVector3& destination)
|
|||||||
|
|
||||||
btRigidBody* body = this->localCreateRigidBody(mass, startTransform,m_shootBoxShape);
|
btRigidBody* body = this->localCreateRigidBody(mass, startTransform,m_shootBoxShape);
|
||||||
body->setLinearFactor(btVector3(1,1,1));
|
body->setLinearFactor(btVector3(1,1,1));
|
||||||
|
//body->setRestitution(1);
|
||||||
|
|
||||||
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();
|
||||||
@@ -782,37 +783,62 @@ void DemoApplication::mouseFunc(int button, int state, int x, int y)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_6DOF
|
|
||||||
btTransform tr;
|
|
||||||
tr.setIdentity();
|
|
||||||
tr.setOrigin(localPivot);
|
|
||||||
btGeneric6DofConstraint* dof6 = new btGeneric6DofConstraint(*body, tr,false);
|
|
||||||
dof6->setLinearLowerLimit(btVector3(0,0,0));
|
|
||||||
dof6->setLinearUpperLimit(btVector3(0,0,0));
|
|
||||||
dof6->setAngularLowerLimit(btVector3(0,0,0));
|
|
||||||
dof6->setAngularUpperLimit(btVector3(0,0,0));
|
|
||||||
|
|
||||||
m_dynamicsWorld->addConstraint(dof6);
|
|
||||||
m_pickConstraint = dof6;
|
|
||||||
|
|
||||||
#else
|
|
||||||
btPoint2PointConstraint* p2p = new btPoint2PointConstraint(*body,localPivot);
|
|
||||||
m_dynamicsWorld->addConstraint(p2p);
|
if (use6Dof)
|
||||||
m_pickConstraint = p2p;
|
{
|
||||||
p2p->m_setting.m_impulseClamp = mousePickClamping;
|
btTransform tr;
|
||||||
//very weak constraint for picking
|
tr.setIdentity();
|
||||||
p2p->m_setting.m_tau = 0.1f;
|
tr.setOrigin(localPivot);
|
||||||
#endif
|
btGeneric6DofConstraint* dof6 = new btGeneric6DofConstraint(*body, tr,false);
|
||||||
|
dof6->setLinearLowerLimit(btVector3(0,0,0));
|
||||||
|
dof6->setLinearUpperLimit(btVector3(0,0,0));
|
||||||
|
dof6->setAngularLowerLimit(btVector3(0,0,0));
|
||||||
|
dof6->setAngularUpperLimit(btVector3(0,0,0));
|
||||||
|
|
||||||
|
m_dynamicsWorld->addConstraint(dof6);
|
||||||
|
m_pickConstraint = dof6;
|
||||||
|
|
||||||
|
dof6->setParam(BT_CONSTRAINT_STOP_CFM,0.8,0);
|
||||||
|
dof6->setParam(BT_CONSTRAINT_STOP_CFM,0.8,1);
|
||||||
|
dof6->setParam(BT_CONSTRAINT_STOP_CFM,0.8,2);
|
||||||
|
dof6->setParam(BT_CONSTRAINT_STOP_CFM,0.8,3);
|
||||||
|
dof6->setParam(BT_CONSTRAINT_STOP_CFM,0.8,4);
|
||||||
|
dof6->setParam(BT_CONSTRAINT_STOP_CFM,0.8,5);
|
||||||
|
|
||||||
|
dof6->setParam(BT_CONSTRAINT_STOP_ERP,0.1,0);
|
||||||
|
dof6->setParam(BT_CONSTRAINT_STOP_ERP,0.1,1);
|
||||||
|
dof6->setParam(BT_CONSTRAINT_STOP_ERP,0.1,2);
|
||||||
|
dof6->setParam(BT_CONSTRAINT_STOP_ERP,0.1,3);
|
||||||
|
dof6->setParam(BT_CONSTRAINT_STOP_ERP,0.1,4);
|
||||||
|
dof6->setParam(BT_CONSTRAINT_STOP_ERP,0.1,5);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
btPoint2PointConstraint* p2p = new btPoint2PointConstraint(*body,localPivot);
|
||||||
|
m_dynamicsWorld->addConstraint(p2p);
|
||||||
|
m_pickConstraint = p2p;
|
||||||
|
p2p->m_setting.m_impulseClamp = mousePickClamping;
|
||||||
|
//very weak constraint for picking
|
||||||
|
p2p->m_setting.m_tau = 0.001f;
|
||||||
|
/*
|
||||||
|
p2p->setParam(BT_CONSTRAINT_CFM,0.8,0);
|
||||||
|
p2p->setParam(BT_CONSTRAINT_CFM,0.8,1);
|
||||||
|
p2p->setParam(BT_CONSTRAINT_CFM,0.8,2);
|
||||||
|
p2p->setParam(BT_CONSTRAINT_ERP,0.1,0);
|
||||||
|
p2p->setParam(BT_CONSTRAINT_ERP,0.1,1);
|
||||||
|
p2p->setParam(BT_CONSTRAINT_ERP,0.1,2);
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
use6Dof = !use6Dof;
|
||||||
|
|
||||||
//save mouse position for dragging
|
//save mouse position for dragging
|
||||||
gOldPickingPos = rayTo;
|
gOldPickingPos = rayTo;
|
||||||
gHitPos = pickPos;
|
gHitPos = pickPos;
|
||||||
|
|
||||||
gOldPickingDist = (pickPos-rayFrom).length();
|
gOldPickingDist = (pickPos-rayFrom).length();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -851,47 +877,64 @@ void DemoApplication::mouseMotionFunc(int x,int y)
|
|||||||
if (m_pickConstraint)
|
if (m_pickConstraint)
|
||||||
{
|
{
|
||||||
//move the constraint pivot
|
//move the constraint pivot
|
||||||
#ifdef USE_6DOF
|
|
||||||
btGeneric6DofConstraint* pickCon = static_cast<btGeneric6DofConstraint*>(m_pickConstraint);
|
if (m_pickConstraint->getConstraintType() == D6_CONSTRAINT_TYPE)
|
||||||
#else
|
|
||||||
btPoint2PointConstraint* pickCon = static_cast<btPoint2PointConstraint*>(m_pickConstraint);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (pickCon)
|
|
||||||
{
|
{
|
||||||
//keep it at the same picking distance
|
btGeneric6DofConstraint* pickCon = static_cast<btGeneric6DofConstraint*>(m_pickConstraint);
|
||||||
|
if (pickCon)
|
||||||
btVector3 newRayTo = getRayTo(x,y);
|
|
||||||
btVector3 rayFrom;
|
|
||||||
#ifdef USE_6DOF
|
|
||||||
btVector3 oldPivotInB = pickCon->getFrameOffsetA().getOrigin();
|
|
||||||
#else
|
|
||||||
btVector3 oldPivotInB = pickCon->getPivotInB();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
btVector3 newPivotB;
|
|
||||||
if (m_ortho)
|
|
||||||
{
|
{
|
||||||
newPivotB = oldPivotInB;
|
//keep it at the same picking distance
|
||||||
newPivotB.setX(newRayTo.getX());
|
|
||||||
newPivotB.setY(newRayTo.getY());
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
rayFrom = m_cameraPosition;
|
|
||||||
btVector3 dir = newRayTo-rayFrom;
|
|
||||||
dir.normalize();
|
|
||||||
dir *= gOldPickingDist;
|
|
||||||
|
|
||||||
newPivotB = rayFrom + dir;
|
btVector3 newRayTo = getRayTo(x,y);
|
||||||
|
btVector3 rayFrom;
|
||||||
|
btVector3 oldPivotInB = pickCon->getFrameOffsetA().getOrigin();
|
||||||
|
|
||||||
|
btVector3 newPivotB;
|
||||||
|
if (m_ortho)
|
||||||
|
{
|
||||||
|
newPivotB = oldPivotInB;
|
||||||
|
newPivotB.setX(newRayTo.getX());
|
||||||
|
newPivotB.setY(newRayTo.getY());
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
rayFrom = m_cameraPosition;
|
||||||
|
btVector3 dir = newRayTo-rayFrom;
|
||||||
|
dir.normalize();
|
||||||
|
dir *= gOldPickingDist;
|
||||||
|
|
||||||
|
newPivotB = rayFrom + dir;
|
||||||
|
}
|
||||||
|
pickCon->getFrameOffsetA().setOrigin(newPivotB);
|
||||||
}
|
}
|
||||||
#ifdef USE_6DOF
|
|
||||||
pickCon->getFrameOffsetA().setOrigin(newPivotB);
|
|
||||||
#else
|
|
||||||
pickCon->setPivotB(newPivotB);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
btPoint2PointConstraint* pickCon = static_cast<btPoint2PointConstraint*>(m_pickConstraint);
|
||||||
|
if (pickCon)
|
||||||
|
{
|
||||||
|
//keep it at the same picking distance
|
||||||
|
|
||||||
|
btVector3 newRayTo = getRayTo(x,y);
|
||||||
|
btVector3 rayFrom;
|
||||||
|
btVector3 oldPivotInB = pickCon->getPivotInB();
|
||||||
|
btVector3 newPivotB;
|
||||||
|
if (m_ortho)
|
||||||
|
{
|
||||||
|
newPivotB = oldPivotInB;
|
||||||
|
newPivotB.setX(newRayTo.getX());
|
||||||
|
newPivotB.setY(newRayTo.getY());
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
rayFrom = m_cameraPosition;
|
||||||
|
btVector3 dir = newRayTo-rayFrom;
|
||||||
|
dir.normalize();
|
||||||
|
dir *= gOldPickingDist;
|
||||||
|
|
||||||
|
newPivotB = rayFrom + dir;
|
||||||
|
}
|
||||||
|
pickCon->setPivotB(newPivotB);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float dx, dy;
|
float dx, dy;
|
||||||
|
|||||||
@@ -112,6 +112,11 @@ public:
|
|||||||
return m_stackAlloc;
|
return m_stackAlloc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual btVoronoiSimplexSolver* getSimplexSolver()
|
||||||
|
{
|
||||||
|
return m_simplexSolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual btCollisionAlgorithmCreateFunc* getCollisionAlgorithmCreateFunc(int proxyType0,int proxyType1);
|
virtual btCollisionAlgorithmCreateFunc* getCollisionAlgorithmCreateFunc(int proxyType0,int proxyType1);
|
||||||
|
|
||||||
|
|||||||
@@ -289,7 +289,11 @@ bool btVoronoiSimplexSolver::inSimplex(const btVector3& w)
|
|||||||
//w is in the current (reduced) simplex
|
//w is in the current (reduced) simplex
|
||||||
for (i=0;i<numverts;i++)
|
for (i=0;i<numverts;i++)
|
||||||
{
|
{
|
||||||
|
#ifdef BT_USE_EQUAL_VERTEX_THRESHOLD
|
||||||
|
if ( m_simplexVectorW[i].distance2(w) <= m_equalVertexThreshold)
|
||||||
|
#else
|
||||||
if (m_simplexVectorW[i] == w)
|
if (m_simplexVectorW[i] == w)
|
||||||
|
#endif
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,11 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
#define VORONOI_SIMPLEX_MAX_VERTS 5
|
#define VORONOI_SIMPLEX_MAX_VERTS 5
|
||||||
|
|
||||||
|
///disable next define, or use defaultCollisionConfiguration->getSimplexSolver()->setEqualVertexThreshold(0.f) to disable/configure
|
||||||
|
#define BT_USE_EQUAL_VERTEX_THRESHOLD
|
||||||
|
#define VORONOI_DEFAULT_EQUAL_VERTEX_THRESHOLD 0.0001f
|
||||||
|
|
||||||
|
|
||||||
struct btUsageBitfield{
|
struct btUsageBitfield{
|
||||||
btUsageBitfield()
|
btUsageBitfield()
|
||||||
{
|
{
|
||||||
@@ -106,8 +111,11 @@ public:
|
|||||||
btVector3 m_cachedP2;
|
btVector3 m_cachedP2;
|
||||||
btVector3 m_cachedV;
|
btVector3 m_cachedV;
|
||||||
btVector3 m_lastW;
|
btVector3 m_lastW;
|
||||||
|
|
||||||
|
btScalar m_equalVertexThreshold;
|
||||||
bool m_cachedValidClosest;
|
bool m_cachedValidClosest;
|
||||||
|
|
||||||
|
|
||||||
btSubSimplexClosestResult m_cachedBC;
|
btSubSimplexClosestResult m_cachedBC;
|
||||||
|
|
||||||
bool m_needsUpdate;
|
bool m_needsUpdate;
|
||||||
@@ -122,10 +130,23 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
btVoronoiSimplexSolver()
|
||||||
|
: m_equalVertexThreshold(VORONOI_DEFAULT_EQUAL_VERTEX_THRESHOLD)
|
||||||
|
{
|
||||||
|
}
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
void addVertex(const btVector3& w, const btVector3& p, const btVector3& q);
|
void addVertex(const btVector3& w, const btVector3& p, const btVector3& q);
|
||||||
|
|
||||||
|
void setEqualVertexThreshold(btScalar threshold)
|
||||||
|
{
|
||||||
|
m_equalVertexThreshold = threshold;
|
||||||
|
}
|
||||||
|
|
||||||
|
btScalar getEqualVertexThreshold() const
|
||||||
|
{
|
||||||
|
return m_equalVertexThreshold;
|
||||||
|
}
|
||||||
|
|
||||||
bool closest(btVector3& v);
|
bool closest(btVector3& v);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user