Merge pull request #281 from erwincoumans/master
comment-out the memset in DEBUG mode in btVector3.cpp and b3Vector3.cpp
This commit is contained in:
@@ -29,6 +29,8 @@ ADD_EXECUTABLE(AppVoronoiFractureDemo
|
|||||||
main.cpp
|
main.cpp
|
||||||
VoronoiFractureDemo.cpp
|
VoronoiFractureDemo.cpp
|
||||||
VoronoiFractureDemo.h
|
VoronoiFractureDemo.h
|
||||||
|
btConvexConvexMprAlgorithm.cpp
|
||||||
|
btConvexConvexMprAlgorithm.h
|
||||||
${BULLET_PHYSICS_SOURCE_DIR}/build3/bullet.rc
|
${BULLET_PHYSICS_SOURCE_DIR}/build3/bullet.rc
|
||||||
)
|
)
|
||||||
ELSE()
|
ELSE()
|
||||||
@@ -36,6 +38,8 @@ ELSE()
|
|||||||
main.cpp
|
main.cpp
|
||||||
VoronoiFractureDemo.cpp
|
VoronoiFractureDemo.cpp
|
||||||
VoronoiFractureDemo.h
|
VoronoiFractureDemo.h
|
||||||
|
btConvexConvexMprAlgorithm.cpp
|
||||||
|
btConvexConvexMprAlgorithm.h
|
||||||
)
|
)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
@@ -57,6 +61,8 @@ ELSE (USE_GLUT)
|
|||||||
Win32VoronoiFractureDemo.cpp
|
Win32VoronoiFractureDemo.cpp
|
||||||
VoronoiFractureDemo.cpp
|
VoronoiFractureDemo.cpp
|
||||||
VoronoiFractureDemo.h
|
VoronoiFractureDemo.h
|
||||||
|
btConvexConvexMprAlgorithm.cpp
|
||||||
|
btConvexConvexMprAlgorithm.h
|
||||||
${BULLET_PHYSICS_SOURCE_DIR}/build3/bullet.rc
|
${BULLET_PHYSICS_SOURCE_DIR}/build3/bullet.rc
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -25,20 +25,23 @@ Voronoi fracture and shatter code and demo copyright (c) 2011 Alain Ducharme
|
|||||||
|
|
||||||
//maximum number of objects (and allow user to shoot additional boxes)
|
//maximum number of objects (and allow user to shoot additional boxes)
|
||||||
#define MAX_PROXIES (2048)
|
#define MAX_PROXIES (2048)
|
||||||
#define BREAKING_THRESHOLD 2
|
#define BREAKING_THRESHOLD 3
|
||||||
#define CONVEX_MARGIN 0.04
|
#define CONVEX_MARGIN 0.04
|
||||||
|
static int useMpr = 0;
|
||||||
|
|
||||||
#include "VoronoiFractureDemo.h"
|
#include "VoronoiFractureDemo.h"
|
||||||
#include "GlutStuff.h"
|
#include "GlutStuff.h"
|
||||||
///btBulletDynamicsCommon.h is the main Bullet include file, contains most common include files.
|
///btBulletDynamicsCommon.h is the main Bullet include file, contains most common include files.
|
||||||
#include "btBulletDynamicsCommon.h"
|
#include "btBulletDynamicsCommon.h"
|
||||||
|
#include "GLDebugFont.h"
|
||||||
#include <stdio.h> //printf debugging
|
#include <stdio.h> //printf debugging
|
||||||
|
|
||||||
#include "GLDebugDrawer.h"
|
#include "GLDebugDrawer.h"
|
||||||
static GLDebugDrawer sDebugDraw;
|
static GLDebugDrawer sDebugDraw;
|
||||||
static bool useGenericConstraint = false;
|
static bool useGenericConstraint = false;
|
||||||
|
|
||||||
|
#include "btConvexConvexMprAlgorithm.h"
|
||||||
|
|
||||||
|
|
||||||
void VoronoiFractureDemo::attachFixedConstraints()
|
void VoronoiFractureDemo::attachFixedConstraints()
|
||||||
{
|
{
|
||||||
@@ -493,13 +496,13 @@ void VoronoiFractureDemo::clientMoveAndDisplay()
|
|||||||
///step the simulation
|
///step the simulation
|
||||||
if (m_dynamicsWorld)
|
if (m_dynamicsWorld)
|
||||||
{
|
{
|
||||||
m_dynamicsWorld->stepSimulation(ms / 1000000.f);
|
m_dynamicsWorld->stepSimulation(1. / 60., 0);// ms / 1000000.f);
|
||||||
//optional but useful: debug drawing
|
//optional but useful: debug drawing
|
||||||
m_dynamicsWorld->debugDrawWorld();
|
m_dynamicsWorld->debugDrawWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
renderme();
|
renderme();
|
||||||
|
|
||||||
glFlush();
|
glFlush();
|
||||||
|
|
||||||
swapBuffers();
|
swapBuffers();
|
||||||
@@ -520,9 +523,30 @@ void VoronoiFractureDemo::displayCallback(void) {
|
|||||||
swapBuffers();
|
swapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VoronoiFractureDemo::renderme()
|
||||||
|
{
|
||||||
|
DemoApplication::renderme();
|
||||||
|
char buf[124];
|
||||||
|
|
||||||
|
int lineWidth = 200;
|
||||||
|
int xStart = m_glutScreenWidth - lineWidth;
|
||||||
|
|
||||||
|
if (useMpr)
|
||||||
|
{
|
||||||
|
sprintf(buf, "Using GJK+MPR");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprintf(buf, "Using GJK+EPA");
|
||||||
|
}
|
||||||
|
GLDebugDrawString(xStart, 20, buf);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void VoronoiFractureDemo::initPhysics()
|
void VoronoiFractureDemo::initPhysics()
|
||||||
{
|
{
|
||||||
|
srand(13);
|
||||||
useGenericConstraint = !useGenericConstraint;
|
useGenericConstraint = !useGenericConstraint;
|
||||||
printf("useGenericConstraint = %d\n", useGenericConstraint);
|
printf("useGenericConstraint = %d\n", useGenericConstraint);
|
||||||
|
|
||||||
@@ -538,7 +562,22 @@ void VoronoiFractureDemo::initPhysics()
|
|||||||
|
|
||||||
///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded)
|
///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded)
|
||||||
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
|
m_dispatcher = new btCollisionDispatcher(m_collisionConfiguration);
|
||||||
|
|
||||||
|
useMpr = 1 - useMpr;
|
||||||
|
|
||||||
|
if (useMpr)
|
||||||
|
{
|
||||||
|
printf("using GJK+MPR convex-convex collision detection\n");
|
||||||
|
btConvexConvexMprAlgorithm::CreateFunc* cf = new btConvexConvexMprAlgorithm::CreateFunc;
|
||||||
|
m_dispatcher->registerCollisionCreateFunc(CONVEX_HULL_SHAPE_PROXYTYPE, CONVEX_HULL_SHAPE_PROXYTYPE, cf);
|
||||||
|
m_dispatcher->registerCollisionCreateFunc(CONVEX_HULL_SHAPE_PROXYTYPE, BOX_SHAPE_PROXYTYPE, cf);
|
||||||
|
m_dispatcher->registerCollisionCreateFunc(BOX_SHAPE_PROXYTYPE, CONVEX_HULL_SHAPE_PROXYTYPE, cf);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("using default (GJK+EPA) convex-convex collision detection\n");
|
||||||
|
}
|
||||||
|
|
||||||
m_broadphase = new btDbvtBroadphase();
|
m_broadphase = new btDbvtBroadphase();
|
||||||
|
|
||||||
///the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded)
|
///the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded)
|
||||||
|
|||||||
@@ -68,6 +68,8 @@ class VoronoiFractureDemo : public PlatformDemoApplication
|
|||||||
|
|
||||||
void exitPhysics();
|
void exitPhysics();
|
||||||
|
|
||||||
|
virtual void renderme();
|
||||||
|
|
||||||
void getVerticesInsidePlanes(const btAlignedObjectArray<btVector3>& planes, btAlignedObjectArray<btVector3>& verticesOut, std::set<int>& planeIndicesOut);
|
void getVerticesInsidePlanes(const btAlignedObjectArray<btVector3>& planes, btAlignedObjectArray<btVector3>& verticesOut, std::set<int>& planeIndicesOut);
|
||||||
void voronoiBBShatter(const btAlignedObjectArray<btVector3>& points, const btVector3& bbmin, const btVector3& bbmax, const btQuaternion& bbq, const btVector3& bbt, btScalar matDensity);
|
void voronoiBBShatter(const btAlignedObjectArray<btVector3>& points, const btVector3& bbmin, const btVector3& bbmax, const btQuaternion& bbq, const btVector3& bbt, btScalar matDensity);
|
||||||
void voronoiConvexHullShatter(const btAlignedObjectArray<btVector3>& points, const btAlignedObjectArray<btVector3>& verts, const btQuaternion& bbq, const btVector3& bbt, btScalar matDensity);
|
void voronoiConvexHullShatter(const btAlignedObjectArray<btVector3>& points, const btAlignedObjectArray<btVector3>& verts, const btQuaternion& bbq, const btVector3& bbt, btScalar matDensity);
|
||||||
|
|||||||
288
Demos/VoronoiFractureDemo/btConvexConvexMprAlgorithm.cpp
Normal file
288
Demos/VoronoiFractureDemo/btConvexConvexMprAlgorithm.cpp
Normal file
@@ -0,0 +1,288 @@
|
|||||||
|
/*
|
||||||
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
|
Copyright (c) 2003-2014 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
|
subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "btConvexConvexMprAlgorithm.h"
|
||||||
|
|
||||||
|
//#include <stdio.h>
|
||||||
|
#include "BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h"
|
||||||
|
#include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h"
|
||||||
|
#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
|
||||||
|
#include "BulletCollision/CollisionShapes/btConvexShape.h"
|
||||||
|
|
||||||
|
#include "BulletCollision/CollisionShapes/btTriangleShape.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h"
|
||||||
|
#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
|
||||||
|
#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
|
||||||
|
#include "BulletCollision/CollisionShapes/btBoxShape.h"
|
||||||
|
#include "BulletCollision/CollisionDispatch/btManifoldResult.h"
|
||||||
|
|
||||||
|
#include "BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h"
|
||||||
|
#include "BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.h"
|
||||||
|
#include "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h"
|
||||||
|
#include "BulletCollision/NarrowPhaseCollision/btGjkConvexCast.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h"
|
||||||
|
#include "BulletCollision/CollisionShapes/btSphereShape.h"
|
||||||
|
|
||||||
|
#include "BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h"
|
||||||
|
|
||||||
|
#include "BulletCollision/NarrowPhaseCollision/btGjkEpa2.h"
|
||||||
|
#include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h"
|
||||||
|
#include "BulletCollision/NarrowPhaseCollision/btPolyhedralContactClipping.h"
|
||||||
|
#include "BulletCollision/CollisionDispatch/btCollisionObjectWrapper.h"
|
||||||
|
|
||||||
|
#include "BulletCollision/NarrowPhaseCollision/btComputeGjkEpaPenetration.h"
|
||||||
|
#include "BulletCollision/NarrowPhaseCollision/btGjkEpa3.h"
|
||||||
|
#include "BulletCollision/NarrowPhaseCollision/btMprPenetration.h"
|
||||||
|
|
||||||
|
//this is just an internal debug variable to switch between GJK+MPR or GJK+EPA
|
||||||
|
bool gUseMprCollisionFunction = true;
|
||||||
|
|
||||||
|
btConvexConvexMprAlgorithm::CreateFunc::CreateFunc()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
btConvexConvexMprAlgorithm::CreateFunc::~CreateFunc()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
btConvexConvexMprAlgorithm::btConvexConvexMprAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap)
|
||||||
|
: btActivatingCollisionAlgorithm(ci,body0Wrap,body1Wrap),
|
||||||
|
m_ownManifold (false),
|
||||||
|
m_manifoldPtr(mf)
|
||||||
|
{
|
||||||
|
(void)body0Wrap;
|
||||||
|
(void)body1Wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
btConvexConvexMprAlgorithm::~btConvexConvexMprAlgorithm()
|
||||||
|
{
|
||||||
|
if (m_ownManifold)
|
||||||
|
{
|
||||||
|
if (m_manifoldPtr)
|
||||||
|
m_dispatcher->releaseManifold(m_manifoldPtr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
btVector3 btBulletShapeSupportFunc(const void* shapeAptr, const btVector3& dir, bool includeMargin)
|
||||||
|
{
|
||||||
|
btConvexShape* shape = (btConvexShape*) shapeAptr;
|
||||||
|
if (includeMargin)
|
||||||
|
{
|
||||||
|
return shape->localGetSupportingVertex(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
return shape->localGetSupportingVertexWithoutMargin(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
btVector3 btBulletShapeCenterFunc(const void* shapeAptr)
|
||||||
|
{
|
||||||
|
return btVector3(0,0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct btMprConvexWrap
|
||||||
|
{
|
||||||
|
const btConvexShape* m_convex;
|
||||||
|
btTransform m_worldTrans;
|
||||||
|
inline btScalar getMargin() const
|
||||||
|
{
|
||||||
|
return m_convex->getMargin();
|
||||||
|
}
|
||||||
|
inline btVector3 getObjectCenterInWorld() const
|
||||||
|
{
|
||||||
|
return m_worldTrans.getOrigin();
|
||||||
|
}
|
||||||
|
inline const btTransform& getWorldTransform() const
|
||||||
|
{
|
||||||
|
return m_worldTrans;
|
||||||
|
}
|
||||||
|
inline btVector3 getLocalSupportWithMargin(const btVector3& dir) const
|
||||||
|
{
|
||||||
|
return m_convex->localGetSupportingVertex(dir);
|
||||||
|
}
|
||||||
|
inline btVector3 getLocalSupportWithoutMargin(const btVector3& dir) const
|
||||||
|
{
|
||||||
|
return m_convex->localGetSupportingVertexWithoutMargin(dir);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct btMyDistanceInfo
|
||||||
|
{
|
||||||
|
btVector3 m_pointOnA;
|
||||||
|
btVector3 m_pointOnB;
|
||||||
|
btVector3 m_normalBtoA;
|
||||||
|
btScalar m_distance;
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Convex-Convex collision algorithm
|
||||||
|
//
|
||||||
|
void btConvexConvexMprAlgorithm ::processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!m_manifoldPtr)
|
||||||
|
{
|
||||||
|
//swapped?
|
||||||
|
m_manifoldPtr = m_dispatcher->getNewManifold(body0Wrap->getCollisionObject(),body1Wrap->getCollisionObject());
|
||||||
|
m_ownManifold = true;
|
||||||
|
}
|
||||||
|
resultOut->setPersistentManifold(m_manifoldPtr);
|
||||||
|
|
||||||
|
//comment-out next line to test multi-contact generation
|
||||||
|
//resultOut->getPersistentManifold()->clearManifold();
|
||||||
|
|
||||||
|
|
||||||
|
const btConvexShape* min0 = static_cast<const btConvexShape*>(body0Wrap->getCollisionShape());
|
||||||
|
const btConvexShape* min1 = static_cast<const btConvexShape*>(body1Wrap->getCollisionShape());
|
||||||
|
|
||||||
|
btVector3 normalOnB;
|
||||||
|
btVector3 pointOnBWorld;
|
||||||
|
|
||||||
|
btGjkPairDetector::ClosestPointInput input;
|
||||||
|
|
||||||
|
btVoronoiSimplexSolver vs;
|
||||||
|
btGjkEpaPenetrationDepthSolver epa;
|
||||||
|
|
||||||
|
|
||||||
|
if (gUseMprCollisionFunction)
|
||||||
|
{
|
||||||
|
|
||||||
|
btMprConvexWrap a,b;
|
||||||
|
a.m_worldTrans = body0Wrap->getWorldTransform();
|
||||||
|
b.m_worldTrans = body1Wrap->getWorldTransform();
|
||||||
|
a.m_convex = (const btConvexShape*)body0Wrap->getCollisionShape();
|
||||||
|
b.m_convex = (const btConvexShape*)body1Wrap->getCollisionShape();
|
||||||
|
btVoronoiSimplexSolver simplexSolver;
|
||||||
|
simplexSolver.reset();
|
||||||
|
btGjkCollisionDescription colDesc;
|
||||||
|
btMyDistanceInfo distInfo;
|
||||||
|
int res = btComputeGjkDistance(a,b,colDesc,&distInfo);
|
||||||
|
if (res==0)
|
||||||
|
{
|
||||||
|
//printf("use GJK results in distance %f\n",distInfo.m_distance);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
btMprCollisionDescription mprDesc;
|
||||||
|
res = btComputeMprPenetration(a,b,mprDesc, &distInfo);
|
||||||
|
|
||||||
|
//printf("use MPR results in distance %f\n",distInfo.m_distance);
|
||||||
|
|
||||||
|
}
|
||||||
|
if (res == 0)
|
||||||
|
{
|
||||||
|
#if 0
|
||||||
|
printf("Dist=%f,normalOnB[%f,%f,%f],pA=[%f,%f,%f],pB[%f,%f,%f]\n",
|
||||||
|
distInfo.m_distance, distInfo.m_normalBtoA[0], distInfo.m_normalBtoA[1], distInfo.m_normalBtoA[2],
|
||||||
|
distInfo.m_pointOnA[0], distInfo.m_pointOnA[1], distInfo.m_pointOnA[2],
|
||||||
|
distInfo.m_pointOnB[0], distInfo.m_pointOnB[1], distInfo.m_pointOnB[2]);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (distInfo.m_distance<=0)
|
||||||
|
{
|
||||||
|
resultOut->addContactPoint(distInfo.m_normalBtoA, distInfo.m_pointOnB, distInfo.m_distance);
|
||||||
|
}
|
||||||
|
//ASSERT_EQ(0,result);
|
||||||
|
//ASSERT_NEAR(btFabs(btScalar(i-z))-btScalar(j)-ssd.m_radiusB, distInfo.m_distance, abs_error);
|
||||||
|
//btVector3 computedA = distInfo.m_pointOnB+distInfo.m_distance*distInfo.m_normalBtoA;
|
||||||
|
//ASSERT_NEAR(computedA.x(),distInfo.m_pointOnA.x(),abs_error);
|
||||||
|
//ASSERT_NEAR(computedA.y(),distInfo.m_pointOnA.y(),abs_error);
|
||||||
|
//ASSERT_NEAR(computedA.z(),distInfo.m_pointOnA.z(),abs_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
btCollisionDescription colDesc;
|
||||||
|
colDesc.m_objA = min0;
|
||||||
|
colDesc.m_objB = min1;
|
||||||
|
colDesc.m_localSupportFuncA = &btBulletShapeSupportFunc;
|
||||||
|
colDesc.m_localSupportFuncB = &btBulletShapeSupportFunc;
|
||||||
|
colDesc.m_localOriginFuncA = &btBulletShapeCenterFunc;
|
||||||
|
colDesc.m_localOriginFuncB = &btBulletShapeCenterFunc;
|
||||||
|
|
||||||
|
colDesc.m_transformA = body0Wrap->getWorldTransform();
|
||||||
|
colDesc.m_transformB = body1Wrap->getWorldTransform();
|
||||||
|
colDesc.m_marginA = body0Wrap->getCollisionShape()->getMargin();
|
||||||
|
colDesc.m_marginB = body1Wrap->getCollisionShape()->getMargin();
|
||||||
|
btDistanceInfo distInfo;
|
||||||
|
//int result = btComputeGjkEpaPenetration(colDesc, &distInfo);
|
||||||
|
//int result = btComputeGjkEpaPenetration2(colDesc, &distInfo);
|
||||||
|
int result = btComputeMprPenetration(colDesc, &distInfo);
|
||||||
|
|
||||||
|
if (result==0)
|
||||||
|
{
|
||||||
|
resultOut->addContactPoint(distInfo.m_normalBtoA,distInfo.m_pointOnB,distInfo.m_distance);
|
||||||
|
}
|
||||||
|
|
||||||
|
//bool res = b3MprPenetration(pairIndex,bodyIndexA,bodyIndexB,cpuBodyBuf,convexData,collidable2,cpuVertices,sepAxis,hasSepAxis,depthOut,dirOut,posOut);
|
||||||
|
|
||||||
|
/*btCollisionDescription colDesc;
|
||||||
|
btDistanceInfo distInfo;
|
||||||
|
int btComputeGjkEpaPenetration(min0, min1, &colDesc, &distInfo);
|
||||||
|
*/
|
||||||
|
#endif
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
|
||||||
|
btGjkPairDetector gjkPairDetector(min0,min1,&vs,&epa);//m_simplexSolver,m_pdSolver);
|
||||||
|
//TODO: if (dispatchInfo.m_useContinuous)
|
||||||
|
gjkPairDetector.setMinkowskiA(min0);
|
||||||
|
gjkPairDetector.setMinkowskiB(min1);
|
||||||
|
|
||||||
|
{
|
||||||
|
//if (dispatchInfo.m_convexMaxDistanceUseCPT)
|
||||||
|
//{
|
||||||
|
// input.m_maximumDistanceSquared = min0->getMargin() + min1->getMargin() + m_manifoldPtr->getContactProcessingThreshold();
|
||||||
|
//} else
|
||||||
|
//{
|
||||||
|
input.m_maximumDistanceSquared = min0->getMargin() + min1->getMargin() + m_manifoldPtr->getContactBreakingThreshold();
|
||||||
|
// }
|
||||||
|
|
||||||
|
input.m_maximumDistanceSquared*= input.m_maximumDistanceSquared;
|
||||||
|
}
|
||||||
|
|
||||||
|
input.m_transformA = body0Wrap->getWorldTransform();
|
||||||
|
input.m_transformB = body1Wrap->getWorldTransform();
|
||||||
|
|
||||||
|
|
||||||
|
gjkPairDetector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw);
|
||||||
|
}
|
||||||
|
if (m_ownManifold)
|
||||||
|
{
|
||||||
|
resultOut->refreshContactPoints();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
btScalar btConvexConvexMprAlgorithm::calculateTimeOfImpact(btCollisionObject* col0,btCollisionObject* col1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
|
||||||
|
{
|
||||||
|
(void)resultOut;
|
||||||
|
(void)dispatchInfo;
|
||||||
|
btAssert(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
87
Demos/VoronoiFractureDemo/btConvexConvexMprAlgorithm.h
Normal file
87
Demos/VoronoiFractureDemo/btConvexConvexMprAlgorithm.h
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
|
subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef BT_CONVEX_CONVEX_MPR_ALGORITHM_H
|
||||||
|
#define BT_CONVEX_CONVEX_MPR_ALGORITHM_H
|
||||||
|
|
||||||
|
#include "BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.h"
|
||||||
|
#include "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h"
|
||||||
|
#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h"
|
||||||
|
#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
|
||||||
|
#include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h"
|
||||||
|
#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h"
|
||||||
|
#include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
|
||||||
|
#include "LinearMath/btTransformUtil.h" //for btConvexSeparatingDistanceUtil
|
||||||
|
|
||||||
|
class btConvexPenetrationDepthSolver;
|
||||||
|
|
||||||
|
///Enabling USE_SEPDISTANCE_UTIL2 requires 100% reliable distance computation. However, when using large size ratios GJK can be imprecise
|
||||||
|
///so the distance is not conservative. In that case, enabling this USE_SEPDISTANCE_UTIL2 would result in failing/missing collisions.
|
||||||
|
///Either improve GJK for large size ratios (testing a 100 units versus a 0.1 unit object) or only enable the util
|
||||||
|
///for certain pairs that have a small size ratio
|
||||||
|
|
||||||
|
///The convexConvexAlgorithm collision algorithm implements time of impact, convex closest points and penetration depth calculations between two convex objects.
|
||||||
|
///Multiple contact points are calculated by perturbing the orientation of the smallest object orthogonal to the separating normal.
|
||||||
|
///This idea was described by Gino van den Bergen in this forum topic http://www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=4&t=288&p=888#p888
|
||||||
|
class btConvexConvexMprAlgorithm : public btActivatingCollisionAlgorithm
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
bool m_ownManifold;
|
||||||
|
btPersistentManifold* m_manifoldPtr;
|
||||||
|
///cache separating vector to speedup collision detection
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
btConvexConvexMprAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap);
|
||||||
|
|
||||||
|
virtual ~btConvexConvexMprAlgorithm();
|
||||||
|
|
||||||
|
virtual void processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
||||||
|
|
||||||
|
virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
||||||
|
|
||||||
|
virtual void getAllContactManifolds(btManifoldArray& manifoldArray)
|
||||||
|
{
|
||||||
|
///should we use m_ownManifold to avoid adding duplicates?
|
||||||
|
if (m_manifoldPtr && m_ownManifold)
|
||||||
|
manifoldArray.push_back(m_manifoldPtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
const btPersistentManifold* getManifold()
|
||||||
|
{
|
||||||
|
return m_manifoldPtr;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct CreateFunc :public btCollisionAlgorithmCreateFunc
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
CreateFunc();
|
||||||
|
|
||||||
|
virtual ~CreateFunc();
|
||||||
|
|
||||||
|
virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap)
|
||||||
|
{
|
||||||
|
void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btConvexConvexMprAlgorithm));
|
||||||
|
return new(mem) btConvexConvexMprAlgorithm(ci.m_manifold,ci,body0Wrap,body1Wrap);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //BT_CONVEX_CONVEX_MPR_ALGORITHM_H
|
||||||
@@ -25,7 +25,7 @@ subject to the following restrictions:
|
|||||||
int main(int argc,char** argv)
|
int main(int argc,char** argv)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
VoronoiFractureDemo ccdDemo;
|
VoronoiFractureDemo ccdDemo;
|
||||||
ccdDemo.initPhysics();
|
ccdDemo.initPhysics();
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
// OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php
|
// OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php
|
||||||
//
|
//
|
||||||
#include <OpenTissue/configuration.h>
|
#include <OpenTissue/configuration.h>
|
||||||
|
#include <algorithm> //std::min
|
||||||
namespace OpenTissue
|
namespace OpenTissue
|
||||||
{
|
{
|
||||||
namespace fem
|
namespace fem
|
||||||
@@ -22,7 +22,7 @@ namespace OpenTissue
|
|||||||
{
|
{
|
||||||
|
|
||||||
using std::min;
|
using std::min;
|
||||||
using std::sqrt;
|
using std::sqrt;
|
||||||
|
|
||||||
typedef typename tetrahedron_type::vector3_type vector3_type;
|
typedef typename tetrahedron_type::vector3_type vector3_type;
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -63,7 +63,7 @@ long _maxdot_large( const float *vv, const float *vec, unsigned long count, floa
|
|||||||
float4 stack_array[ STACK_ARRAY_COUNT ];
|
float4 stack_array[ STACK_ARRAY_COUNT ];
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
memset( stack_array, -1, STACK_ARRAY_COUNT * sizeof(stack_array[0]) );
|
//memset( stack_array, -1, STACK_ARRAY_COUNT * sizeof(stack_array[0]) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
size_t index;
|
size_t index;
|
||||||
@@ -448,7 +448,7 @@ long _mindot_large( const float *vv, const float *vec, unsigned long count, floa
|
|||||||
float4 stack_array[ STACK_ARRAY_COUNT ];
|
float4 stack_array[ STACK_ARRAY_COUNT ];
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
memset( stack_array, -1, STACK_ARRAY_COUNT * sizeof(stack_array[0]) );
|
//memset( stack_array, -1, STACK_ARRAY_COUNT * sizeof(stack_array[0]) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
size_t index;
|
size_t index;
|
||||||
|
|||||||
Reference in New Issue
Block a user