+ CMake build system fix under Windows: don't define _WINDOWS to allow Glut console demo to build properly
+ Allow user to enable useConvexConservativeDistanceUtil . Use dynamicsWorld->getDispatchInfo().m_useConvexConservativeDistanceUtil = true; (see Demos/Benchmarks/Benchmark4 (convex objects falling down) + Fix for plane drawing (just wire-frame) + Gimpact: use collision margin of 0.07 for demo (because BULLET_TRIANGLE_COLLISION is used) + replace dot,cross,distance,angle,triple in btVector3 by btDot, btCross,btDistance,btAngle,btDistance to avoid naming conflicts + Some fixes in GJK penetration depth normal direction (broken in a previous commit) + fix in calculateDiffAxisAngleQuaternion to make ConvexConservativeDistanceUtil work properly + allow debug drawing to debug btContinuousConvexCollision + add comment/warning that btTriangleMesh::findOrAddVertex is an internal method, users should use addTriangle instead
This commit is contained in:
@@ -8,8 +8,9 @@ IF (NOT CMAKE_BUILD_TYPE)
|
||||
SET(CMAKE_BUILD_TYPE "Release")
|
||||
ENDIF (NOT CMAKE_BUILD_TYPE)
|
||||
|
||||
|
||||
|
||||
# string (REPLACE "/D_WINDOWS" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
||||
remove_definitions(-D_WINDOWS )
|
||||
|
||||
IF(COMMAND cmake_policy)
|
||||
cmake_policy(SET CMP0003 NEW)
|
||||
ENDIF(COMMAND cmake_policy)
|
||||
|
||||
@@ -302,7 +302,9 @@ void BenchmarkDemo::initPhysics()
|
||||
|
||||
btDiscreteDynamicsWorld* dynamicsWorld;
|
||||
m_dynamicsWorld = dynamicsWorld = new btDiscreteDynamicsWorld(m_dispatcher,m_overlappingPairCache,m_solver,m_collisionConfiguration);
|
||||
dynamicsWorld->getSimulationIslandManager()->setSplitIslands(false);
|
||||
//dynamicsWorld->getSimulationIslandManager()->setSplitIslands(false);
|
||||
dynamicsWorld->getDispatchInfo().m_useConvexConservativeDistanceUtil = true;
|
||||
dynamicsWorld->getDispatchInfo().m_convexConservativeDistanceThreshold = 0.01;
|
||||
|
||||
|
||||
m_dynamicsWorld->setGravity(btVector3(0,-10,0));
|
||||
|
||||
@@ -26,10 +26,10 @@ int main(int argc,char** argv)
|
||||
{
|
||||
GLDebugDrawer gDebugDrawer;
|
||||
|
||||
BenchmarkDemo1 benchmarkDemo;
|
||||
// BenchmarkDemo1 benchmarkDemo;
|
||||
// BenchmarkDemo2 benchmarkDemo;
|
||||
// BenchmarkDemo3 benchmarkDemo;
|
||||
// BenchmarkDemo4 benchmarkDemo;
|
||||
BenchmarkDemo4 benchmarkDemo;
|
||||
// BenchmarkDemo5 benchmarkDemo;
|
||||
// BenchmarkDemo6 benchmarkDemo;
|
||||
// BenchmarkDemo7 benchmarkDemo;
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include "GLDebugDrawer.h"
|
||||
#include "btBulletDynamicsCommon.h"
|
||||
|
||||
#ifndef _WINDOWS
|
||||
|
||||
GLDebugDrawer gDebugDrawer;
|
||||
|
||||
int main(int argc,char** argv)
|
||||
@@ -29,4 +31,10 @@ int main(int argc,char** argv)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
DemoApplication* createDemo()
|
||||
{
|
||||
ConvexDecompositionDemo* convexDecompDemo = new ConvexDecompositionDemo();
|
||||
return convexDecompDemo;
|
||||
}
|
||||
#endif _WINDOWS
|
||||
|
||||
@@ -280,7 +280,10 @@ void GimpactConcaveDemo::initGImpactCollision()
|
||||
btGImpactConvexDecompositionShape * trimesh = new
|
||||
btGImpactConvexDecompositionShape(
|
||||
m_indexVertexArrays, btVector3(1.f,1.f,1.f),btScalar(0.01));
|
||||
trimesh->setMargin(0.07);
|
||||
trimesh->updateBound();
|
||||
|
||||
|
||||
#else
|
||||
btGImpactMeshShape * trimesh = new btGImpactMeshShape(m_indexVertexArrays);
|
||||
trimesh->setLocalScaling(btVector3(1.f,1.f,1.f));
|
||||
@@ -314,6 +317,7 @@ void GimpactConcaveDemo::initGImpactCollision()
|
||||
btGImpactConvexDecompositionShape * trimesh2 = new
|
||||
btGImpactConvexDecompositionShape(
|
||||
m_indexVertexArrays2, btVector3(4.f,4.f,4.f),btScalar(0.01));
|
||||
trimesh2->setMargin(0.07);
|
||||
trimesh2->updateBound();
|
||||
#else
|
||||
btGImpactMeshShape * trimesh2 = new btGImpactMeshShape(m_indexVertexArrays2);
|
||||
|
||||
@@ -21,7 +21,7 @@ class btDefaultCollisionConfiguration;
|
||||
|
||||
//#define BULLET_TRIANGLE_COLLISION 1
|
||||
#define BULLET_GIMPACT 1
|
||||
#define BULLET_GIMPACT_CONVEX_DECOMPOSITION 1
|
||||
//#define BULLET_GIMPACT_CONVEX_DECOMPOSITION 1
|
||||
|
||||
#define TEST_GIMPACT_TORUS
|
||||
|
||||
|
||||
@@ -25,15 +25,15 @@ subject to the following restrictions:
|
||||
#include "BulletMultiThreaded/SpuGatheringCollisionDispatcher.h"
|
||||
#include "BulletMultiThreaded/Win32ThreadSupport.h"
|
||||
#include "GLDebugFont.h"
|
||||
//@ extern int gSkippedCol;
|
||||
//@ extern int gProcessedCol;
|
||||
extern int gSkippedCol;
|
||||
extern int gProcessedCol;
|
||||
|
||||
|
||||
|
||||
#define SPEC_TEST 0
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define LARGE_DEMO 0
|
||||
#define LARGE_DEMO 1
|
||||
// #define LARGE_DEMO 1
|
||||
#else
|
||||
#define LARGE_DEMO 1
|
||||
@@ -192,6 +192,8 @@ void BasicDemo3D::initPhysics()
|
||||
btDefaultCollisionConstructionInfo dci;
|
||||
dci.m_defaultMaxPersistentManifoldPoolSize=100000;
|
||||
dci.m_defaultMaxCollisionAlgorithmPoolSize=100000;
|
||||
dci.m_customCollisionAlgorithmMaxElementSize = sizeof(SpuContactManifoldCollisionAlgorithm);
|
||||
|
||||
|
||||
///SpuContactManifoldCollisionAlgorithm is larger than any of the other collision algorithms
|
||||
//@@ dci.m_customMaxCollisionAlgorithmSize = sizeof(SpuContactManifoldCollisionAlgorithm);
|
||||
@@ -243,13 +245,18 @@ btCudaBroadphase::btCudaBroadphase( btOverlappingPairCache* overlappingPairCache
|
||||
#ifdef USE_CUDA_BROADPHASE
|
||||
m_broadphase = new btCudaBroadphase(gPairCache, gWorldMin, gWorldMax,numOfCellsX, numOfCellsY, numOfCellsZ,MAX_SMALL_PROXIES,20,18,8,1./1.5);
|
||||
#else
|
||||
|
||||
#if DBVT
|
||||
btDbvtBroadphase* dbvt = new btDbvtBroadphase(gPairCache);
|
||||
m_broadphase = dbvt;
|
||||
dbvt->m_deferedcollide=false;
|
||||
dbvt->m_prediction = 0.f;
|
||||
|
||||
#else
|
||||
m_broadphase = new btAxisSweep3(gWorldMin,gWorldMax,32000,gPairCache,true);//(btDbvtBroadphase(gPairCache);
|
||||
#endif //DBVT
|
||||
|
||||
#endif
|
||||
//m_broadphase = new btAxisSweep3(gWorldMin,gWorldMax,32000,0,true);//(btDbvtBroadphase(gPairCache);
|
||||
|
||||
|
||||
// create solvers for tests
|
||||
///the default constraint solver
|
||||
@@ -808,7 +815,6 @@ void BasicDemo3D::outputDebugInfo(int & xOffset,int & yStart, int yIncr)
|
||||
sprintf(buf,"# pairs = %d",getDynamicsWorld()->getBroadphase()->getOverlappingPairCache()->getNumOverlappingPairs());
|
||||
GLDebugDrawString(xOffset,yStart,buf);
|
||||
|
||||
/*@@
|
||||
|
||||
yStart += yIncr;
|
||||
glRasterPos3f(xOffset,yStart,0);
|
||||
@@ -822,12 +828,13 @@ void BasicDemo3D::outputDebugInfo(int & xOffset,int & yStart, int yIncr)
|
||||
|
||||
yStart += yIncr;
|
||||
glRasterPos3f(xOffset,yStart,0);
|
||||
sprintf(buf,"culled narrowphase collisions=%f",btScalar(gSkippedCol)/(gProcessedCol+gSkippedCol));
|
||||
btScalar fract = (gProcessedCol+gSkippedCol)? btScalar(gSkippedCol)/(gProcessedCol+gSkippedCol) : 0.f;
|
||||
sprintf(buf,"culled narrowphase collisions=%f",fract);
|
||||
GLDebugDrawString(xOffset,yStart,buf);
|
||||
yStart += yIncr;
|
||||
@@*/
|
||||
|
||||
|
||||
gProcessedCol = 0;
|
||||
gSkippedCol = 0;
|
||||
|
||||
}
|
||||
} // BasicDemo3D::outputDebugInfo()
|
||||
|
||||
@@ -1065,11 +1065,11 @@ void HfFluidDemo::clientMoveAndDisplay()
|
||||
const btVector3 rayTo=getRayTo(x,y);
|
||||
const btVector3 rayDir=(rayTo-rayFrom).normalized();
|
||||
const btVector3 N=(m_cameraTargetPosition-m_cameraPosition).normalized();
|
||||
const btScalar O=dot(m_impact,N);
|
||||
const btScalar den=dot(N,rayDir);
|
||||
const btScalar O=btDot(m_impact,N);
|
||||
const btScalar den=btDot(N,rayDir);
|
||||
if((den*den)>0)
|
||||
{
|
||||
const btScalar num=O-dot(N,rayFrom);
|
||||
const btScalar num=O-btDot(N,rayFrom);
|
||||
const btScalar hit=num/den;
|
||||
if((hit>0)&&(hit<1500))
|
||||
{
|
||||
|
||||
@@ -557,8 +557,8 @@ void HfFluidDemo_GL_ShapeDrawer::drawShadow(btScalar* m,const btVector3& extrus
|
||||
glBegin(GL_QUADS);
|
||||
for(int i=0;i<sc->m_edges.size();++i)
|
||||
{
|
||||
const btScalar d=dot(sc->m_edges[i].n[0],extrusion);
|
||||
if((d*dot(sc->m_edges[i].n[1],extrusion))<0)
|
||||
const btScalar d=btDot(sc->m_edges[i].n[0],extrusion);
|
||||
if((d*btDot(sc->m_edges[i].n[1],extrusion))<0)
|
||||
{
|
||||
const int q= d<0?1:0;
|
||||
const btVector3& a= hull->getVertexPointer()[sc->m_edges[i].v[q]];
|
||||
|
||||
@@ -39,7 +39,34 @@ void GLDebugDrawer::drawSphere (const btVector3& p, btScalar radius, const btVec
|
||||
glColor4f (color.getX(), color.getY(), color.getZ(), btScalar(1.0f));
|
||||
glPushMatrix ();
|
||||
glTranslatef (p.getX(), p.getY(), p.getZ());
|
||||
// glutSolidSphere (radius, 10, 10);
|
||||
|
||||
int lats = 5;
|
||||
int longs = 5;
|
||||
|
||||
int i, j;
|
||||
for(i = 0; i <= lats; i++) {
|
||||
btScalar lat0 = SIMD_PI * (-btScalar(0.5) + (btScalar) (i - 1) / lats);
|
||||
btScalar z0 = radius*sin(lat0);
|
||||
btScalar zr0 = radius*cos(lat0);
|
||||
|
||||
btScalar lat1 = SIMD_PI * (-btScalar(0.5) + (btScalar) i / lats);
|
||||
btScalar z1 = radius*sin(lat1);
|
||||
btScalar zr1 = radius*cos(lat1);
|
||||
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for(j = 0; j <= longs; j++) {
|
||||
btScalar lng = 2 * SIMD_PI * (btScalar) (j - 1) / longs;
|
||||
btScalar x = cos(lng);
|
||||
btScalar y = sin(lng);
|
||||
|
||||
glNormal3f(x * zr0, y * zr0, z0);
|
||||
glVertex3f(x * zr0, y * zr0, z0);
|
||||
glNormal3f(x * zr1, y * zr1, z1);
|
||||
glVertex3f(x * zr1, y * zr1, z1);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
@@ -62,7 +89,7 @@ void GLDebugDrawer::drawTriangle(const btVector3& a,const btVector3& b,const btV
|
||||
{
|
||||
// if (m_debugMode > 0)
|
||||
{
|
||||
const btVector3 n=cross(b-a,c-a).normalized();
|
||||
const btVector3 n=btCross(b-a,c-a).normalized();
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor4f(color.getX(), color.getY(), color.getZ(),alpha);
|
||||
glNormal3d(n.getX(),n.getY(),n.getZ());
|
||||
|
||||
@@ -365,7 +365,7 @@ GL_ShapeDrawer::ShapeCache* GL_ShapeDrawer::cache(btConvexShape* shape)
|
||||
for(int i=0;i<ni;i+=3)
|
||||
{
|
||||
const unsigned int* ti=pi+i;
|
||||
const btVector3 nrm=cross(pv[ti[1]]-pv[ti[0]],pv[ti[2]]-pv[ti[0]]).normalized();
|
||||
const btVector3 nrm=btCross(pv[ti[1]]-pv[ti[0]],pv[ti[2]]-pv[ti[0]]).normalized();
|
||||
for(int j=2,k=0;k<3;j=k++)
|
||||
{
|
||||
const unsigned int a=ti[j];
|
||||
@@ -857,8 +857,7 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons
|
||||
else
|
||||
{
|
||||
#else
|
||||
if (shape->isConcave())//>getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE||shape->getShapeType() == GIMPACT_SHAPE_PROXYTYPE)
|
||||
// if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)
|
||||
if (shape->isConcave() && !shape->isInfinite())
|
||||
{
|
||||
btConcaveShape* concaveMesh = (btConcaveShape*) shape;
|
||||
|
||||
@@ -939,8 +938,8 @@ void GL_ShapeDrawer::drawShadow(btScalar* m,const btVector3& extrusion,const bt
|
||||
glBegin(GL_QUADS);
|
||||
for(int i=0;i<sc->m_edges.size();++i)
|
||||
{
|
||||
const btScalar d=dot(sc->m_edges[i].n[0],extrusion);
|
||||
if((d*dot(sc->m_edges[i].n[1],extrusion))<0)
|
||||
const btScalar d=btDot(sc->m_edges[i].n[0],extrusion);
|
||||
if((d*btDot(sc->m_edges[i].n[1],extrusion))<0)
|
||||
{
|
||||
const int q= d<0?1:0;
|
||||
const btVector3& a= hull->getVertexPointer()[sc->m_edges[i].v[q]];
|
||||
|
||||
@@ -118,11 +118,11 @@ void SoftDemo::clientMoveAndDisplay()
|
||||
const btVector3 rayTo=getRayTo(x,y);
|
||||
const btVector3 rayDir=(rayTo-rayFrom).normalized();
|
||||
const btVector3 N=(m_cameraTargetPosition-m_cameraPosition).normalized();
|
||||
const btScalar O=dot(m_impact,N);
|
||||
const btScalar den=dot(N,rayDir);
|
||||
const btScalar O=btDot(m_impact,N);
|
||||
const btScalar den=btDot(N,rayDir);
|
||||
if((den*den)>0)
|
||||
{
|
||||
const btScalar num=O-dot(N,rayFrom);
|
||||
const btScalar num=O-btDot(N,rayFrom);
|
||||
const btScalar hit=num/den;
|
||||
if((hit>0)&&(hit<1500))
|
||||
{
|
||||
@@ -1442,8 +1442,8 @@ void SoftDemo::renderme()
|
||||
const btScalar a= (btScalar)0.5;
|
||||
const btVector3 n= m_softBodyWorldInfo.water_normal;
|
||||
const btVector3 o= -n*m_softBodyWorldInfo.water_offset;
|
||||
const btVector3 x= cross(n,axis[n.minAxis()]).normalized();
|
||||
const btVector3 y= cross(x,n).normalized();
|
||||
const btVector3 x= btCross(n,axis[n.minAxis()]).normalized();
|
||||
const btVector3 y= btCross(x,n).normalized();
|
||||
const btScalar s= 25;
|
||||
idraw->drawTriangle(o-x*s-y*s,o+x*s-y*s,o+x*s+y*s,c,a);
|
||||
idraw->drawTriangle(o-x*s-y*s,o+x*s+y*s,o-x*s+y*s,c,a);
|
||||
|
||||
@@ -238,7 +238,7 @@ static void split( const tNodeArray& leaves,
|
||||
right.resize(0);
|
||||
for(int i=0,ni=leaves.size();i<ni;++i)
|
||||
{
|
||||
if(dot(axis,leaves[i]->volume.Center()-org)<0)
|
||||
if(btDot(axis,leaves[i]->volume.Center()-org)<0)
|
||||
left.push_back(leaves[i]);
|
||||
else
|
||||
right.push_back(leaves[i]);
|
||||
@@ -319,7 +319,7 @@ static btDbvtNode* topdown(btDbvt* pdbvt,
|
||||
const btVector3 x=leaves[i]->volume.Center()-org;
|
||||
for(int j=0;j<3;++j)
|
||||
{
|
||||
++splitcount[j][dot(x,axis[j])>0?1:0];
|
||||
++splitcount[j][btDot(x,axis[j])>0?1:0];
|
||||
}
|
||||
}
|
||||
for( i=0;i<3;++i)
|
||||
|
||||
@@ -484,8 +484,8 @@ DBVT_INLINE int btDbvtAabbMm::Classify(const btVector3& n,btScalar o,int s) con
|
||||
case (1+2+4): px=btVector3(mx.x(),mx.y(),mx.z());
|
||||
pi=btVector3(mi.x(),mi.y(),mi.z());break;
|
||||
}
|
||||
if((dot(n,px)+o)<0) return(-1);
|
||||
if((dot(n,pi)+o)>=0) return(+1);
|
||||
if((btDot(n,px)+o)<0) return(-1);
|
||||
if((btDot(n,pi)+o)>=0) return(+1);
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -496,7 +496,7 @@ DBVT_INLINE btScalar btDbvtAabbMm::ProjectMinimum(const btVector3& v,unsigned si
|
||||
const btVector3 p( b[(signs>>0)&1]->x(),
|
||||
b[(signs>>1)&1]->y(),
|
||||
b[(signs>>2)&1]->z());
|
||||
return(dot(p,v));
|
||||
return(btDot(p,v));
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -46,7 +46,7 @@ struct btDispatcherInfo
|
||||
m_enableSPU(true),
|
||||
m_useEpa(true),
|
||||
m_allowedCcdPenetration(btScalar(0.04)),
|
||||
m_useConvexConservativeDistanceUtil(true),
|
||||
m_useConvexConservativeDistanceUtil(false),
|
||||
m_convexConservativeDistanceThreshold(0.0f),
|
||||
m_stackAllocator(0)
|
||||
{
|
||||
|
||||
@@ -69,7 +69,7 @@ m_ownManifold (false),
|
||||
m_manifoldPtr(mf),
|
||||
m_lowLevelOfDetail(false),
|
||||
#ifdef USE_SEPDISTANCE_UTIL2
|
||||
,m_sepDistance((static_cast<btConvexShape*>(body0->getCollisionShape()))->getAngularMotionDisc(),
|
||||
m_sepDistance((static_cast<btConvexShape*>(body0->getCollisionShape()))->getAngularMotionDisc(),
|
||||
(static_cast<btConvexShape*>(body1->getCollisionShape()))->getAngularMotionDisc()),
|
||||
#endif
|
||||
m_numPerturbationIterations(numPerturbationIterations),
|
||||
|
||||
@@ -31,7 +31,8 @@ class btConvexPenetrationDepthSolver;
|
||||
///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
|
||||
///#define USE_SEPDISTANCE_UTIL2 1
|
||||
|
||||
#define USE_SEPDISTANCE_UTIL2 1
|
||||
|
||||
///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.
|
||||
|
||||
@@ -102,7 +102,8 @@ btDefaultCollisionConfiguration::btDefaultCollisionConfiguration(const btDefault
|
||||
int maxSize3 = sizeof(btCompoundCollisionAlgorithm);
|
||||
int sl = sizeof(btConvexSeparatingDistanceUtil);
|
||||
sl = sizeof(btGjkPairDetector);
|
||||
int collisionAlgorithmMaxElementSize = btMax(maxSize,maxSize2);
|
||||
int collisionAlgorithmMaxElementSize = btMax(maxSize,constructionInfo.m_customCollisionAlgorithmMaxElementSize);
|
||||
collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,maxSize2);
|
||||
collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,maxSize3);
|
||||
|
||||
if (constructionInfo.m_stackAlloc)
|
||||
|
||||
@@ -27,6 +27,7 @@ struct btDefaultCollisionConstructionInfo
|
||||
btPoolAllocator* m_collisionAlgorithmPool;
|
||||
int m_defaultMaxPersistentManifoldPoolSize;
|
||||
int m_defaultMaxCollisionAlgorithmPoolSize;
|
||||
int m_customCollisionAlgorithmMaxElementSize;
|
||||
int m_defaultStackAllocatorSize;
|
||||
int m_useEpaPenetrationAlgorithm;
|
||||
|
||||
@@ -36,6 +37,7 @@ struct btDefaultCollisionConstructionInfo
|
||||
m_collisionAlgorithmPool(0),
|
||||
m_defaultMaxPersistentManifoldPoolSize(4096),
|
||||
m_defaultMaxCollisionAlgorithmPoolSize(4096),
|
||||
m_customCollisionAlgorithmMaxElementSize(0),
|
||||
m_defaultStackAllocatorSize(0),
|
||||
m_useEpaPenetrationAlgorithm(true)
|
||||
{
|
||||
|
||||
@@ -40,9 +40,6 @@ class btTriangleMesh : public btTriangleIndexVertexArray
|
||||
|
||||
btTriangleMesh (bool use32bitIndices=true,bool use4componentVertices=true);
|
||||
|
||||
int findOrAddVertex(const btVector3& vertex, bool removeDuplicateVertices);
|
||||
void addIndex(int index);
|
||||
|
||||
bool getUse32bitIndices() const
|
||||
{
|
||||
return m_use32bitIndices;
|
||||
@@ -61,6 +58,10 @@ class btTriangleMesh : public btTriangleIndexVertexArray
|
||||
virtual void preallocateVertices(int numverts){(void) numverts;}
|
||||
virtual void preallocateIndices(int numindices){(void) numindices;}
|
||||
|
||||
///findOrAddVertex is an internal method, use addTriangle instead
|
||||
int findOrAddVertex(const btVector3& vertex, bool removeDuplicateVertices);
|
||||
///addIndex is an internal method, use addTriangle instead
|
||||
void addIndex(int index);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -121,6 +121,10 @@ bool btContinuousConvexCollision::calcTimeOfImpact(
|
||||
//not close enough
|
||||
while (dist > radius)
|
||||
{
|
||||
if (result.m_debugDrawer)
|
||||
{
|
||||
result.m_debugDrawer->drawSphere(c,0.2f,btVector3(1,1,1));
|
||||
}
|
||||
numIter++;
|
||||
if (numIter > maxIter)
|
||||
{
|
||||
@@ -170,6 +174,11 @@ bool btContinuousConvexCollision::calcTimeOfImpact(
|
||||
btTransformUtil::integrateTransform(fromB,linVelB,angVelB,lambda,interpolatedTransB);
|
||||
relativeTrans = interpolatedTransB.inverseTimes(interpolatedTransA);
|
||||
|
||||
if (result.m_debugDrawer)
|
||||
{
|
||||
result.m_debugDrawer->drawSphere(interpolatedTransA.getOrigin(),0.2f,btVector3(1,0,0));
|
||||
}
|
||||
|
||||
result.DebugDraw( lambda );
|
||||
|
||||
btPointCollector pointCollector;
|
||||
@@ -197,6 +206,7 @@ bool btContinuousConvexCollision::calcTimeOfImpact(
|
||||
//??
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -224,4 +234,3 @@ bool btContinuousConvexCollision::calcTimeOfImpact(
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@ namespace gjkepa2_impl
|
||||
lastw[clastw=(clastw+1)&3]=w;
|
||||
}
|
||||
/* Check for termination */
|
||||
const btScalar omega=dot(m_ray,w)/rl;
|
||||
const btScalar omega=btDot(m_ray,w)/rl;
|
||||
alpha=btMax(omega,alpha);
|
||||
if(((rl-alpha)-(GJK_ACCURARY*rl))<=0)
|
||||
{/* Return old simplex */
|
||||
@@ -288,7 +288,7 @@ namespace gjkepa2_impl
|
||||
{
|
||||
btVector3 axis=btVector3(0,0,0);
|
||||
axis[i]=1;
|
||||
const btVector3 p=cross(d,axis);
|
||||
const btVector3 p=btCross(d,axis);
|
||||
if(p.length2()>0)
|
||||
{
|
||||
appendvertice(*m_simplex, p);
|
||||
@@ -303,7 +303,7 @@ namespace gjkepa2_impl
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
const btVector3 n=cross(m_simplex->c[1]->w-m_simplex->c[0]->w,
|
||||
const btVector3 n=btCross(m_simplex->c[1]->w-m_simplex->c[0]->w,
|
||||
m_simplex->c[2]->w-m_simplex->c[0]->w);
|
||||
if(n.length2()>0)
|
||||
{
|
||||
@@ -357,7 +357,7 @@ namespace gjkepa2_impl
|
||||
const btScalar l=d.length2();
|
||||
if(l>GJK_SIMPLEX2_EPS)
|
||||
{
|
||||
const btScalar t(l>0?-dot(a,d)/l:0);
|
||||
const btScalar t(l>0?-btDot(a,d)/l:0);
|
||||
if(t>=1) { w[0]=0;w[1]=1;m=2;return(b.length2()); }
|
||||
else if(t<=0) { w[0]=1;w[1]=0;m=1;return(a.length2()); }
|
||||
else { w[0]=1-(w[1]=t);m=3;return((a+d*t).length2()); }
|
||||
@@ -372,7 +372,7 @@ namespace gjkepa2_impl
|
||||
static const U imd3[]={1,2,0};
|
||||
const btVector3* vt[]={&a,&b,&c};
|
||||
const btVector3 dl[]={a-b,b-c,c-a};
|
||||
const btVector3 n=cross(dl[0],dl[1]);
|
||||
const btVector3 n=btCross(dl[0],dl[1]);
|
||||
const btScalar l=n.length2();
|
||||
if(l>GJK_SIMPLEX3_EPS)
|
||||
{
|
||||
@@ -381,7 +381,7 @@ namespace gjkepa2_impl
|
||||
U subm;
|
||||
for(U i=0;i<3;++i)
|
||||
{
|
||||
if(dot(*vt[i],cross(dl[i],n))>0)
|
||||
if(btDot(*vt[i],btCross(dl[i],n))>0)
|
||||
{
|
||||
const U j=imd3[i];
|
||||
const btScalar subd(projectorigin(*vt[i],*vt[j],subw,subm));
|
||||
@@ -397,13 +397,13 @@ namespace gjkepa2_impl
|
||||
}
|
||||
if(mindist<0)
|
||||
{
|
||||
const btScalar d=dot(a,n);
|
||||
const btScalar d=btDot(a,n);
|
||||
const btScalar s=btSqrt(l);
|
||||
const btVector3 p=n*(d/l);
|
||||
mindist = p.length2();
|
||||
m = 7;
|
||||
w[0] = (cross(dl[1],b-p)).length()/s;
|
||||
w[1] = (cross(dl[2],c-p)).length()/s;
|
||||
w[0] = (btCross(dl[1],b-p)).length()/s;
|
||||
w[1] = (btCross(dl[2],c-p)).length()/s;
|
||||
w[2] = 1-(w[0]+w[1]);
|
||||
}
|
||||
return(mindist);
|
||||
@@ -420,7 +420,7 @@ namespace gjkepa2_impl
|
||||
const btVector3* vt[]={&a,&b,&c,&d};
|
||||
const btVector3 dl[]={a-d,b-d,c-d};
|
||||
const btScalar vl=det(dl[0],dl[1],dl[2]);
|
||||
const bool ng=(vl*dot(a,cross(b-c,a-b)))<=0;
|
||||
const bool ng=(vl*btDot(a,btCross(b-c,a-b)))<=0;
|
||||
if(ng&&(btFabs(vl)>GJK_SIMPLEX4_EPS))
|
||||
{
|
||||
btScalar mindist=-1;
|
||||
@@ -429,7 +429,7 @@ namespace gjkepa2_impl
|
||||
for(U i=0;i<3;++i)
|
||||
{
|
||||
const U j=imd3[i];
|
||||
const btScalar s=vl*dot(d,cross(dl[i],dl[j]));
|
||||
const btScalar s=vl*btDot(d,btCross(dl[i],dl[j]));
|
||||
if(s>0)
|
||||
{
|
||||
const btScalar subd=projectorigin(*vt[i],*vt[j],d,subw,subm);
|
||||
@@ -601,7 +601,7 @@ namespace gjkepa2_impl
|
||||
bool valid=true;
|
||||
best->pass = (U1)(++pass);
|
||||
gjk.getsupport(best->n,*w);
|
||||
const btScalar wdist=dot(best->n,w->w)-best->d;
|
||||
const btScalar wdist=btDot(best->n,w->w)-best->d;
|
||||
if(wdist>EPA_ACCURACY)
|
||||
{
|
||||
for(U j=0;(j<3)&&valid;++j)
|
||||
@@ -628,11 +628,11 @@ namespace gjkepa2_impl
|
||||
m_result.c[0] = outer.c[0];
|
||||
m_result.c[1] = outer.c[1];
|
||||
m_result.c[2] = outer.c[2];
|
||||
m_result.p[0] = cross( outer.c[1]->w-projection,
|
||||
m_result.p[0] = btCross( outer.c[1]->w-projection,
|
||||
outer.c[2]->w-projection).length();
|
||||
m_result.p[1] = cross( outer.c[2]->w-projection,
|
||||
m_result.p[1] = btCross( outer.c[2]->w-projection,
|
||||
outer.c[0]->w-projection).length();
|
||||
m_result.p[2] = cross( outer.c[0]->w-projection,
|
||||
m_result.p[2] = btCross( outer.c[0]->w-projection,
|
||||
outer.c[1]->w-projection).length();
|
||||
const btScalar sum=m_result.p[0]+m_result.p[1]+m_result.p[2];
|
||||
m_result.p[0] /= sum;
|
||||
@@ -666,18 +666,18 @@ namespace gjkepa2_impl
|
||||
face->c[0] = a;
|
||||
face->c[1] = b;
|
||||
face->c[2] = c;
|
||||
face->n = cross(b->w-a->w,c->w-a->w);
|
||||
face->n = btCross(b->w-a->w,c->w-a->w);
|
||||
const btScalar l=face->n.length();
|
||||
const bool v=l>EPA_ACCURACY;
|
||||
face->p = btMin(btMin(
|
||||
dot(a->w,cross(face->n,a->w-b->w)),
|
||||
dot(b->w,cross(face->n,b->w-c->w))),
|
||||
dot(c->w,cross(face->n,c->w-a->w))) /
|
||||
btDot(a->w,btCross(face->n,a->w-b->w)),
|
||||
btDot(b->w,btCross(face->n,b->w-c->w))),
|
||||
btDot(c->w,btCross(face->n,c->w-a->w))) /
|
||||
(v?l:1);
|
||||
face->p = face->p>=-EPA_INSIDE_EPS?0:face->p;
|
||||
if(v)
|
||||
{
|
||||
face->d = dot(a->w,face->n)/l;
|
||||
face->d = btDot(a->w,face->n)/l;
|
||||
face->n /= l;
|
||||
if(forced||(face->d>=-EPA_PLANE_EPS))
|
||||
{
|
||||
@@ -715,7 +715,7 @@ namespace gjkepa2_impl
|
||||
if(f->pass!=pass)
|
||||
{
|
||||
const U e1=i1m3[e];
|
||||
if((dot(f->n,w->w)-f->d)<-EPA_PLANE_EPS)
|
||||
if((btDot(f->n,w->w)-f->d)<-EPA_PLANE_EPS)
|
||||
{
|
||||
sFace* nf=newface(f->c[e1],f->c[e],w,false);
|
||||
if(nf)
|
||||
|
||||
@@ -299,6 +299,7 @@ void btGjkPairDetector::getClosestPoints(const ClosestPointInput& input,Result&
|
||||
btVector3 tmpPointOnA,tmpPointOnB;
|
||||
|
||||
gNumDeepPenetrationChecks++;
|
||||
m_cachedSeparatingAxis.setZero();
|
||||
|
||||
bool isValid2 = m_penetrationDepthSolver->calcPenDepth(
|
||||
*m_simplexSolver,
|
||||
@@ -308,23 +309,40 @@ void btGjkPairDetector::getClosestPoints(const ClosestPointInput& input,Result&
|
||||
debugDraw,input.m_stackAlloc
|
||||
);
|
||||
|
||||
|
||||
if (isValid2)
|
||||
{
|
||||
btScalar distance2 = -(tmpPointOnA-tmpPointOnB).length();
|
||||
//only replace valid penetrations when the result is deeper (check)
|
||||
if (!isValid || (distance2 < distance))
|
||||
btVector3 tmpNormalInB = tmpPointOnB-tmpPointOnA;
|
||||
btScalar lenSqr = tmpNormalInB.length2();
|
||||
if (lenSqr <= (SIMD_EPSILON*SIMD_EPSILON))
|
||||
{
|
||||
distance = distance2;
|
||||
pointOnA = tmpPointOnA;
|
||||
pointOnB = tmpPointOnB;
|
||||
normalInB = m_cachedSeparatingAxis;
|
||||
isValid = true;
|
||||
m_lastUsedMethod = 3;
|
||||
} else
|
||||
tmpNormalInB = m_cachedSeparatingAxis;
|
||||
lenSqr = m_cachedSeparatingAxis.length2();
|
||||
}
|
||||
|
||||
if (lenSqr > (SIMD_EPSILON*SIMD_EPSILON))
|
||||
{
|
||||
m_lastUsedMethod = 4;
|
||||
tmpNormalInB /= btSqrt(lenSqr);
|
||||
btScalar distance2 = -(tmpPointOnA-tmpPointOnB).length();
|
||||
//only replace valid penetrations when the result is deeper (check)
|
||||
if (!isValid || (distance2 < distance))
|
||||
{
|
||||
distance = distance2;
|
||||
pointOnA = tmpPointOnA;
|
||||
pointOnB = tmpPointOnB;
|
||||
normalInB = tmpNormalInB;
|
||||
isValid = true;
|
||||
m_lastUsedMethod = 3;
|
||||
} else
|
||||
{
|
||||
m_lastUsedMethod = 8;
|
||||
}
|
||||
} else
|
||||
{
|
||||
m_lastUsedMethod = 9;
|
||||
}
|
||||
} else
|
||||
|
||||
{
|
||||
///this is another degenerate case, where the initial GJK calculation reports a degenerate case
|
||||
///EPA reports no penetration, and the second GJK (using the supporting vector without margin)
|
||||
@@ -333,21 +351,24 @@ void btGjkPairDetector::getClosestPoints(const ClosestPointInput& input,Result&
|
||||
///http://code.google.com/p/bullet/issues/detail?id=250
|
||||
|
||||
|
||||
btScalar distance2 = (tmpPointOnA-tmpPointOnB).length()-margin;
|
||||
//only replace valid distances when the distance is less
|
||||
if (!isValid || (distance2 < distance))
|
||||
if (m_cachedSeparatingAxis.length2() > btScalar(0.))
|
||||
{
|
||||
distance = distance2;
|
||||
pointOnA = tmpPointOnA;
|
||||
pointOnB = tmpPointOnB;
|
||||
pointOnA -= m_cachedSeparatingAxis * marginA ;
|
||||
pointOnB += m_cachedSeparatingAxis * marginB ;
|
||||
normalInB = m_cachedSeparatingAxis;
|
||||
isValid = true;
|
||||
m_lastUsedMethod = 6;
|
||||
} else
|
||||
{
|
||||
m_lastUsedMethod = 5;
|
||||
btScalar distance2 = (tmpPointOnA-tmpPointOnB).length()-margin;
|
||||
//only replace valid distances when the distance is less
|
||||
if (!isValid || (distance2 < distance))
|
||||
{
|
||||
distance = distance2;
|
||||
pointOnA = tmpPointOnA;
|
||||
pointOnB = tmpPointOnB;
|
||||
pointOnA -= m_cachedSeparatingAxis * marginA ;
|
||||
pointOnB += m_cachedSeparatingAxis * marginB ;
|
||||
normalInB = m_cachedSeparatingAxis;
|
||||
isValid = true;
|
||||
m_lastUsedMethod = 6;
|
||||
} else
|
||||
{
|
||||
m_lastUsedMethod = 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ subject to the following restrictions:
|
||||
|
||||
class btPersistentManifold;
|
||||
|
||||
//#define USE_SEPDISTANCE_UTIL 1
|
||||
#define USE_SEPDISTANCE_UTIL 1
|
||||
|
||||
/// SpuContactManifoldCollisionAlgorithm provides contact manifold and should be processed on SPU.
|
||||
ATTRIBUTE_ALIGNED16(class) SpuContactManifoldCollisionAlgorithm : public btCollisionAlgorithm
|
||||
|
||||
@@ -52,6 +52,9 @@ subject to the following restrictions:
|
||||
#endif
|
||||
#endif //__SPU__
|
||||
|
||||
int gSkippedCol = 0;
|
||||
int gProcessedCol = 0;
|
||||
|
||||
////////////////////////////////////////////////
|
||||
/// software caching
|
||||
#if USE_SOFTWARE_CACHE
|
||||
@@ -624,8 +627,11 @@ SIMD_FORCE_INLINE void dmaAndSetupCollisionObjects(SpuCollisionPairInput& collis
|
||||
|
||||
cellDmaWaitTagStatusAll(DMA_MASK(1) | DMA_MASK(2));
|
||||
|
||||
collisionPairInput.m_worldTransform0 = lsMem.getColObj0()->getWorldTransform();
|
||||
collisionPairInput.m_worldTransform1 = lsMem.getColObj1()->getWorldTransform();
|
||||
btCollisionObject* ob0 = lsMem.getColObj0();
|
||||
btCollisionObject* ob1 = lsMem.getColObj1();
|
||||
|
||||
collisionPairInput.m_worldTransform0 = ob0->getWorldTransform();
|
||||
collisionPairInput.m_worldTransform1 = ob1->getWorldTransform();
|
||||
}
|
||||
|
||||
|
||||
@@ -998,6 +1004,11 @@ void processCollisionTask(void* userPtr, void* lsMemPtr)
|
||||
lsMem.getColObj0()->getFriction(),lsMem.getColObj1()->getFriction(),
|
||||
collisionPairInput.m_isSwapped);
|
||||
|
||||
|
||||
float distance=0.f;
|
||||
btVector3 normalInB;
|
||||
|
||||
|
||||
|
||||
if (//!gUseEpa &&
|
||||
#ifdef USE_SEPDISTANCE_UTIL
|
||||
@@ -1007,7 +1018,7 @@ void processCollisionTask(void* userPtr, void* lsMemPtr)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
//#define USE_PE_BOX_BOX 1
|
||||
#define USE_PE_BOX_BOX 1
|
||||
#ifdef USE_PE_BOX_BOX
|
||||
{
|
||||
|
||||
@@ -1032,9 +1043,9 @@ void processCollisionTask(void* userPtr, void* lsMemPtr)
|
||||
float distanceThreshold = FLT_MAX;//0.0f;//FLT_MAX;//use epsilon?
|
||||
|
||||
|
||||
float distance = boxBoxDistance(resultNormal,resultClosestBoxPointA,resultClosestBoxPointB, boxA, transformA, boxB,transformB,distanceThreshold);
|
||||
distance = boxBoxDistance(resultNormal,resultClosestBoxPointA,resultClosestBoxPointB, boxA, transformA, boxB,transformB,distanceThreshold);
|
||||
|
||||
btVector3 normalInB = -getBtVector3(resultNormal);
|
||||
normalInB = -getBtVector3(resultNormal);
|
||||
|
||||
if(distance < spuManifold->getContactBreakingThreshold())
|
||||
{
|
||||
@@ -1094,9 +1105,13 @@ void processCollisionTask(void* userPtr, void* lsMemPtr)
|
||||
|
||||
lsMem.needsDmaPutContactManifoldAlgo = true;
|
||||
#ifdef USE_SEPDISTANCE_UTIL
|
||||
btScalar sepDist = distance+spuManifold->getContactBreakingThreshold();
|
||||
lsMem.getlocalCollisionAlgorithm()->m_sepDistance.initSeparatingDistance(normalInB,sepDist,collisionPairInput.m_worldTransform0,collisionPairInput.m_worldTransform1);
|
||||
btScalar sepDist2 = distance+spuManifold->getContactBreakingThreshold();
|
||||
lsMem.getlocalCollisionAlgorithm()->m_sepDistance.initSeparatingDistance(normalInB,sepDist2,collisionPairInput.m_worldTransform0,collisionPairInput.m_worldTransform1);
|
||||
#endif //USE_SEPDISTANCE_UTIL
|
||||
gProcessedCol++;
|
||||
} else
|
||||
{
|
||||
gSkippedCol++;
|
||||
}
|
||||
|
||||
spuContacts.flush();
|
||||
@@ -1138,13 +1153,15 @@ void processCollisionTask(void* userPtr, void* lsMemPtr)
|
||||
}
|
||||
|
||||
#ifdef USE_SEPDISTANCE_UTIL
|
||||
#if defined (__SPU__) || defined (USE_LIBSPE2)
|
||||
if (lsMem.needsDmaPutContactManifoldAlgo)
|
||||
{
|
||||
dmaSize = sizeof(SpuContactManifoldCollisionAlgorithm);
|
||||
dmaPpuAddress2 = (ppu_address_t)pair.m_algorithm;
|
||||
cellDmaLargePut(&lsMem.gSpuContactManifoldAlgo, dmaPpuAddress2 , dmaSize, DMA_TAG(1), 0, 0);
|
||||
cellDmaLargePut(&lsMem.gSpuContactManifoldAlgoBuffer, dmaPpuAddress2 , dmaSize, DMA_TAG(1), 0, 0);
|
||||
cellDmaWaitTagStatusAll(DMA_MASK(1));
|
||||
}
|
||||
#endif
|
||||
#endif //#ifdef USE_SEPDISTANCE_UTIL
|
||||
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ eStatus::_ Evaluate(const tShape& shapearg,const btVector3& guess)
|
||||
lastw[clastw=(clastw+1)&3]=w;
|
||||
}
|
||||
/* Check for termination */
|
||||
const btScalar omega=dot(m_ray,w)/rl;
|
||||
const btScalar omega=btDot(m_ray,w)/rl;
|
||||
alpha=btMax(omega,alpha);
|
||||
if(((rl-alpha)-(GJK_ACCURARY*rl))<=0)
|
||||
{/* Return old simplex */
|
||||
@@ -287,9 +287,9 @@ bool EncloseOrigin()
|
||||
{
|
||||
btVector3 axis=btVector3(0,0,0);
|
||||
axis[i]=1;
|
||||
if(btFabs(dot(axis,d))>0)
|
||||
if(btFabs(btDot(axis,d))>0)
|
||||
{
|
||||
const btVector3 p=cross(d,axis);
|
||||
const btVector3 p=btCross(d,axis);
|
||||
appendvertice(*m_simplex, p);
|
||||
if(EncloseOrigin()) return(true);
|
||||
removevertice(*m_simplex);
|
||||
@@ -302,7 +302,7 @@ bool EncloseOrigin()
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
const btVector3 n=cross(m_simplex->c[1]->w-m_simplex->c[0]->w,
|
||||
const btVector3 n=btCross(m_simplex->c[1]->w-m_simplex->c[0]->w,
|
||||
m_simplex->c[2]->w-m_simplex->c[0]->w);
|
||||
const btScalar l=n.length();
|
||||
if(l>0)
|
||||
@@ -357,7 +357,7 @@ static btScalar projectorigin( const btVector3& a,
|
||||
const btScalar l=d.length2();
|
||||
if(l>GJK_SIMPLEX2_EPS)
|
||||
{
|
||||
const btScalar t(l>0?-dot(a,d)/l:0);
|
||||
const btScalar t(l>0?-btDot(a,d)/l:0);
|
||||
if(t>=1) { w[0]=0;w[1]=1;m=2;return(b.length2()); }
|
||||
else if(t<=0) { w[0]=1;w[1]=0;m=1;return(a.length2()); }
|
||||
else { w[0]=1-(w[1]=t);m=3;return((a+d*t).length2()); }
|
||||
@@ -372,7 +372,7 @@ static btScalar projectorigin( const btVector3& a,
|
||||
static const U imd3[]={1,2,0};
|
||||
const btVector3* vt[]={&a,&b,&c};
|
||||
const btVector3 dl[]={a-b,b-c,c-a};
|
||||
const btVector3 n=cross(dl[0],dl[1]);
|
||||
const btVector3 n=btCross(dl[0],dl[1]);
|
||||
const btScalar l=n.length2();
|
||||
if(l>GJK_SIMPLEX3_EPS)
|
||||
{
|
||||
@@ -381,7 +381,7 @@ static btScalar projectorigin( const btVector3& a,
|
||||
U subm;
|
||||
for(U i=0;i<3;++i)
|
||||
{
|
||||
if(dot(*vt[i],cross(dl[i],n))>0)
|
||||
if(btDot(*vt[i],btCross(dl[i],n))>0)
|
||||
{
|
||||
const U j=imd3[i];
|
||||
const btScalar subd(projectorigin(*vt[i],*vt[j],subw,subm));
|
||||
@@ -397,13 +397,13 @@ static btScalar projectorigin( const btVector3& a,
|
||||
}
|
||||
if(mindist<0)
|
||||
{
|
||||
const btScalar d=dot(a,n);
|
||||
const btScalar d=btDot(a,n);
|
||||
const btScalar s=btSqrt(l);
|
||||
const btVector3 p=n*(d/l);
|
||||
mindist = p.length2();
|
||||
m = 7;
|
||||
w[0] = (cross(dl[1],b-p)).length()/s;
|
||||
w[1] = (cross(dl[2],c-p)).length()/s;
|
||||
w[0] = (btCross(dl[1],b-p)).length()/s;
|
||||
w[1] = (btCross(dl[2],c-p)).length()/s;
|
||||
w[2] = 1-(w[0]+w[1]);
|
||||
}
|
||||
return(mindist);
|
||||
@@ -420,7 +420,7 @@ static btScalar projectorigin( const btVector3& a,
|
||||
const btVector3* vt[]={&a,&b,&c,&d};
|
||||
const btVector3 dl[]={a-d,b-d,c-d};
|
||||
const btScalar vl=det(dl[0],dl[1],dl[2]);
|
||||
const bool ng=(vl*dot(a,cross(b-c,a-b)))<=0;
|
||||
const bool ng=(vl*btDot(a,btCross(b-c,a-b)))<=0;
|
||||
if(ng&&(btFabs(vl)>GJK_SIMPLEX4_EPS))
|
||||
{
|
||||
btScalar mindist=-1;
|
||||
@@ -429,7 +429,7 @@ static btScalar projectorigin( const btVector3& a,
|
||||
for(U i=0;i<3;++i)
|
||||
{
|
||||
const U j=imd3[i];
|
||||
const btScalar s=vl*dot(d,cross(dl[i],dl[j]));
|
||||
const btScalar s=vl*btDot(d,btCross(dl[i],dl[j]));
|
||||
if(s>0)
|
||||
{
|
||||
const btScalar subd=projectorigin(*vt[i],*vt[j],d,subw,subm);
|
||||
@@ -577,7 +577,7 @@ eStatus::_ Evaluate(GJK& gjk,const btVector3& guess)
|
||||
bool valid=true;
|
||||
best->pass = (U1)(++pass);
|
||||
gjk.getsupport(best->n,*w);
|
||||
const btScalar wdist=dot(best->n,w->w)-best->d;
|
||||
const btScalar wdist=btDot(best->n,w->w)-best->d;
|
||||
if(wdist>EPA_ACCURACY)
|
||||
{
|
||||
for(U j=0;(j<3)&&valid;++j)
|
||||
@@ -604,11 +604,11 @@ eStatus::_ Evaluate(GJK& gjk,const btVector3& guess)
|
||||
m_result.c[0] = outer.c[0];
|
||||
m_result.c[1] = outer.c[1];
|
||||
m_result.c[2] = outer.c[2];
|
||||
m_result.p[0] = cross( outer.c[1]->w-projection,
|
||||
m_result.p[0] = btCross( outer.c[1]->w-projection,
|
||||
outer.c[2]->w-projection).length();
|
||||
m_result.p[1] = cross( outer.c[2]->w-projection,
|
||||
m_result.p[1] = btCross( outer.c[2]->w-projection,
|
||||
outer.c[0]->w-projection).length();
|
||||
m_result.p[2] = cross( outer.c[0]->w-projection,
|
||||
m_result.p[2] = btCross( outer.c[0]->w-projection,
|
||||
outer.c[1]->w-projection).length();
|
||||
const btScalar sum=m_result.p[0]+m_result.p[1]+m_result.p[2];
|
||||
m_result.p[0] /= sum;
|
||||
@@ -642,18 +642,18 @@ sFace* newface(sSV* a,sSV* b,sSV* c,bool forced)
|
||||
face->c[0] = a;
|
||||
face->c[1] = b;
|
||||
face->c[2] = c;
|
||||
face->n = cross(b->w-a->w,c->w-a->w);
|
||||
face->n = btCross(b->w-a->w,c->w-a->w);
|
||||
const btScalar l=face->n.length();
|
||||
const bool v=l>EPA_ACCURACY;
|
||||
face->p = btMin(btMin(
|
||||
dot(a->w,cross(face->n,a->w-b->w)),
|
||||
dot(b->w,cross(face->n,b->w-c->w))),
|
||||
dot(c->w,cross(face->n,c->w-a->w))) /
|
||||
btDot(a->w,btCross(face->n,a->w-b->w)),
|
||||
btDot(b->w,btCross(face->n,b->w-c->w))),
|
||||
btDot(c->w,btCross(face->n,c->w-a->w))) /
|
||||
(v?l:1);
|
||||
face->p = face->p>=-EPA_INSIDE_EPS?0:face->p;
|
||||
if(v)
|
||||
{
|
||||
face->d = dot(a->w,face->n)/l;
|
||||
face->d = btDot(a->w,face->n)/l;
|
||||
face->n /= l;
|
||||
if(forced||(face->d>=-EPA_PLANE_EPS))
|
||||
{
|
||||
@@ -691,7 +691,7 @@ bool expand(U pass,sSV* w,sFace* f,U e,sHorizon& horizon)
|
||||
if(f->pass!=pass)
|
||||
{
|
||||
const U e1=i1m3[e];
|
||||
if((dot(f->n,w->w)-f->d)<-EPA_PLANE_EPS)
|
||||
if((btDot(f->n,w->w)-f->d)<-EPA_PLANE_EPS)
|
||||
{
|
||||
sFace* nf=newface(f->c[e1],f->c[e],w,false);
|
||||
if(nf)
|
||||
|
||||
@@ -611,7 +611,7 @@ btScalar btSoftBody::getVolume() const
|
||||
for(i=0,ni=m_faces.size();i<ni;++i)
|
||||
{
|
||||
const Face& f=m_faces[i];
|
||||
vol+=dot(f.m_n[0]->m_x-org,cross(f.m_n[1]->m_x-org,f.m_n[2]->m_x-org));
|
||||
vol+=btDot(f.m_n[0]->m_x-org,btCross(f.m_n[1]->m_x-org,f.m_n[2]->m_x-org));
|
||||
}
|
||||
vol/=(btScalar)6;
|
||||
}
|
||||
@@ -644,14 +644,14 @@ btVector3 btSoftBody::clusterCom(int cluster) const
|
||||
//
|
||||
btVector3 btSoftBody::clusterVelocity(const Cluster* cluster,const btVector3& rpos)
|
||||
{
|
||||
return(cluster->m_lv+cross(cluster->m_av,rpos));
|
||||
return(cluster->m_lv+btCross(cluster->m_av,rpos));
|
||||
}
|
||||
|
||||
//
|
||||
void btSoftBody::clusterVImpulse(Cluster* cluster,const btVector3& rpos,const btVector3& impulse)
|
||||
{
|
||||
const btVector3 li=cluster->m_imass*impulse;
|
||||
const btVector3 ai=cluster->m_invwi*cross(rpos,impulse);
|
||||
const btVector3 ai=cluster->m_invwi*btCross(rpos,impulse);
|
||||
cluster->m_vimpulses[0]+=li;cluster->m_lv+=li;
|
||||
cluster->m_vimpulses[1]+=ai;cluster->m_av+=ai;
|
||||
cluster->m_nvimpulses++;
|
||||
@@ -661,7 +661,7 @@ void btSoftBody::clusterVImpulse(Cluster* cluster,const btVector3& rpos,const
|
||||
void btSoftBody::clusterDImpulse(Cluster* cluster,const btVector3& rpos,const btVector3& impulse)
|
||||
{
|
||||
const btVector3 li=cluster->m_imass*impulse;
|
||||
const btVector3 ai=cluster->m_invwi*cross(rpos,impulse);
|
||||
const btVector3 ai=cluster->m_invwi*btCross(rpos,impulse);
|
||||
cluster->m_dimpulses[0]+=li;
|
||||
cluster->m_dimpulses[1]+=ai;
|
||||
cluster->m_ndimpulses++;
|
||||
@@ -1585,19 +1585,19 @@ btScalar btSoftBody::RayFromToCaster::rayFromToTriangle( const btVector3& rayF
|
||||
static const btScalar ceps=-SIMD_EPSILON*10;
|
||||
static const btScalar teps=SIMD_EPSILON*10;
|
||||
|
||||
const btVector3 n=cross(b-a,c-a);
|
||||
const btScalar d=dot(a,n);
|
||||
const btScalar den=dot(rayNormalizedDirection,n);
|
||||
const btVector3 n=btCross(b-a,c-a);
|
||||
const btScalar d=btDot(a,n);
|
||||
const btScalar den=btDot(rayNormalizedDirection,n);
|
||||
if(!btFuzzyZero(den))
|
||||
{
|
||||
const btScalar num=dot(rayFrom,n)-d;
|
||||
const btScalar num=btDot(rayFrom,n)-d;
|
||||
const btScalar t=-num/den;
|
||||
if((t>teps)&&(t<maxt))
|
||||
{
|
||||
const btVector3 hit=rayFrom+rayNormalizedDirection*t;
|
||||
if( (dot(n,cross(a-hit,b-hit))>ceps) &&
|
||||
(dot(n,cross(b-hit,c-hit))>ceps) &&
|
||||
(dot(n,cross(c-hit,a-hit))>ceps))
|
||||
if( (btDot(n,btCross(a-hit,b-hit))>ceps) &&
|
||||
(btDot(n,btCross(b-hit,c-hit))>ceps) &&
|
||||
(btDot(n,btCross(c-hit,a-hit))>ceps))
|
||||
{
|
||||
return(t);
|
||||
}
|
||||
@@ -1783,7 +1783,7 @@ bool btSoftBody::checkContact( btCollisionObject* colObj,
|
||||
{
|
||||
cti.m_colObj = colObj;
|
||||
cti.m_normal = wtr.getBasis()*nrm;
|
||||
cti.m_offset = -dot( cti.m_normal,
|
||||
cti.m_offset = -btDot( cti.m_normal,
|
||||
x-cti.m_normal*dst);
|
||||
return(true);
|
||||
}
|
||||
@@ -1803,7 +1803,7 @@ void btSoftBody::updateNormals()
|
||||
for(i=0,ni=m_faces.size();i<ni;++i)
|
||||
{
|
||||
btSoftBody::Face& f=m_faces[i];
|
||||
const btVector3 n=cross(f.m_n[1]->m_x-f.m_n[0]->m_x,
|
||||
const btVector3 n=btCross(f.m_n[1]->m_x-f.m_n[0]->m_x,
|
||||
f.m_n[2]->m_x-f.m_n[0]->m_x);
|
||||
f.m_normal=n.normalized();
|
||||
f.m_n[0]->m_n+=n;
|
||||
@@ -2058,7 +2058,7 @@ void btSoftBody::updateClusters()
|
||||
{
|
||||
const btVector3 v=c.m_nodes[i]->m_v*c.m_masses[i];
|
||||
c.m_lv += v;
|
||||
c.m_av += cross(c.m_nodes[i]->m_x-c.m_com,v);
|
||||
c.m_av += btCross(c.m_nodes[i]->m_x-c.m_com,v);
|
||||
}
|
||||
}
|
||||
c.m_lv=c.m_imass*c.m_lv*(1-c.m_ldamping);
|
||||
@@ -2174,7 +2174,7 @@ void btSoftBody::applyClusters(bool drift)
|
||||
const int idx=int(c.m_nodes[j]-&m_nodes[0]);
|
||||
const btVector3& x=c.m_nodes[j]->m_x;
|
||||
const btScalar q=c.m_masses[j];
|
||||
deltas[idx] += (v+cross(w,x-c.m_com))*q;
|
||||
deltas[idx] += (v+btCross(w,x-c.m_com))*q;
|
||||
weights[idx] += q;
|
||||
}
|
||||
}
|
||||
@@ -2200,7 +2200,7 @@ void btSoftBody::dampClusters()
|
||||
Node& n=*c.m_nodes[j];
|
||||
if(n.m_im>0)
|
||||
{
|
||||
const btVector3 vx=c.m_lv+cross(c.m_av,c.m_nodes[j]->m_q-c.m_com);
|
||||
const btVector3 vx=c.m_lv+btCross(c.m_av,c.m_nodes[j]->m_q-c.m_com);
|
||||
if(vx.length2()<=n.m_v.length2())
|
||||
{
|
||||
n.m_v += c.m_ndamping*(vx-n.m_v);
|
||||
@@ -2269,8 +2269,8 @@ void btSoftBody::AJoint::Prepare(btScalar dt,int iterations)
|
||||
Joint::Prepare(dt,iterations);
|
||||
m_axis[0] = m_bodies[0].xform().getBasis()*m_refs[0];
|
||||
m_axis[1] = m_bodies[1].xform().getBasis()*m_refs[1];
|
||||
m_drift = NormalizeAny(cross(m_axis[1],m_axis[0]));
|
||||
m_drift *= btMin(maxdrift,btAcos(Clamp<btScalar>(dot(m_axis[0],m_axis[1]),-1,+1)));
|
||||
m_drift = NormalizeAny(btCross(m_axis[1],m_axis[0]));
|
||||
m_drift *= btMin(maxdrift,btAcos(Clamp<btScalar>(btDot(m_axis[0],m_axis[1]),-1,+1)));
|
||||
m_drift *= m_erp/dt;
|
||||
m_massmatrix= AngularImpulseMatrix(m_bodies[0].invWorldInertia(),m_bodies[1].invWorldInertia());
|
||||
if(m_split>0)
|
||||
@@ -2287,7 +2287,7 @@ void btSoftBody::AJoint::Solve(btScalar dt,btScalar sor)
|
||||
const btVector3 va=m_bodies[0].angularVelocity();
|
||||
const btVector3 vb=m_bodies[1].angularVelocity();
|
||||
const btVector3 vr=va-vb;
|
||||
const btScalar sp=dot(vr,m_axis[0]);
|
||||
const btScalar sp=btDot(vr,m_axis[0]);
|
||||
const btVector3 vc=vr-m_axis[0]*m_icontrol->Speed(this,sp);
|
||||
btSoftBody::Impulse impulse;
|
||||
impulse.m_asVelocity = 1;
|
||||
@@ -2334,7 +2334,7 @@ void btSoftBody::CJoint::Solve(btScalar dt,btScalar sor)
|
||||
const btVector3 va=m_bodies[0].velocity(m_rpos[0]);
|
||||
const btVector3 vb=m_bodies[1].velocity(m_rpos[1]);
|
||||
const btVector3 vrel=va-vb;
|
||||
const btScalar rvac=dot(vrel,m_normal);
|
||||
const btScalar rvac=btDot(vrel,m_normal);
|
||||
btSoftBody::Impulse impulse;
|
||||
impulse.m_asVelocity = 1;
|
||||
impulse.m_velocity = m_drift;
|
||||
@@ -2417,9 +2417,9 @@ void btSoftBody::applyForces()
|
||||
case btSoftBody::eAeroModel::V_Point:
|
||||
nrm=NormalizeAny(rel_v);break;
|
||||
case btSoftBody::eAeroModel::V_TwoSided:
|
||||
nrm*=(btScalar)(dot(nrm,rel_v)<0?-1:+1);break;
|
||||
nrm*=(btScalar)(btDot(nrm,rel_v)<0?-1:+1);break;
|
||||
}
|
||||
const btScalar dvn=dot(rel_v,nrm);
|
||||
const btScalar dvn=btDot(rel_v,nrm);
|
||||
/* Compute forces */
|
||||
if(dvn>0)
|
||||
{
|
||||
@@ -2463,9 +2463,9 @@ void btSoftBody::applyForces()
|
||||
switch(m_cfg.aeromodel)
|
||||
{
|
||||
case btSoftBody::eAeroModel::F_TwoSided:
|
||||
nrm*=(btScalar)(dot(nrm,rel_v)<0?-1:+1);break;
|
||||
nrm*=(btScalar)(btDot(nrm,rel_v)<0?-1:+1);break;
|
||||
}
|
||||
const btScalar dvn=dot(rel_v,nrm);
|
||||
const btScalar dvn=btDot(rel_v,nrm);
|
||||
/* Compute forces */
|
||||
if(dvn>0)
|
||||
{
|
||||
@@ -2516,10 +2516,10 @@ void btSoftBody::PSolve_RContacts(btSoftBody* psb,btScalar kst,btScalar ti)
|
||||
const btVector3 va=tmpRigid ? tmpRigid->getVelocityInLocalPoint(c.m_c1)*dt : btVector3(0,0,0);
|
||||
const btVector3 vb=c.m_node->m_x-c.m_node->m_q;
|
||||
const btVector3 vr=vb-va;
|
||||
const btScalar dn=dot(vr,cti.m_normal);
|
||||
const btScalar dn=btDot(vr,cti.m_normal);
|
||||
if(dn<=SIMD_EPSILON)
|
||||
{
|
||||
const btScalar dp=btMin(dot(c.m_node->m_x,cti.m_normal)+cti.m_offset,mrg);
|
||||
const btScalar dp=btMin(btDot(c.m_node->m_x,cti.m_normal)+cti.m_offset,mrg);
|
||||
const btVector3 fv=vr-cti.m_normal*dn;
|
||||
const btVector3 impulse=c.m_c0*((vr-fv*c.m_c3+cti.m_normal*(dp*c.m_c4))*kst);
|
||||
c.m_node->m_x-=impulse*c.m_c2;
|
||||
@@ -2548,9 +2548,9 @@ void btSoftBody::PSolve_SContacts(btSoftBody* psb,btScalar,btScalar ti)
|
||||
c.m_weights);
|
||||
const btVector3 vr=(n.m_x-n.m_q)-(p-q);
|
||||
btVector3 corr(0,0,0);
|
||||
if(dot(vr,nr)<0)
|
||||
if(btDot(vr,nr)<0)
|
||||
{
|
||||
const btScalar j=c.m_margin-(dot(nr,n.m_x)-dot(nr,p));
|
||||
const btScalar j=c.m_margin-(btDot(nr,n.m_x)-btDot(nr,p));
|
||||
corr+=c.m_normal*j;
|
||||
}
|
||||
corr -= ProjectOnPlane(vr,nr)*c.m_friction;
|
||||
@@ -2588,7 +2588,7 @@ void btSoftBody::VSolve_Links(btSoftBody* psb,btScalar kst)
|
||||
{
|
||||
Link& l=psb->m_links[i];
|
||||
Node** n=l.m_n;
|
||||
const btScalar j=-dot(l.m_c3,n[0]->m_v-n[1]->m_v)*l.m_c2*kst;
|
||||
const btScalar j=-btDot(l.m_c3,n[0]->m_v-n[1]->m_v)*l.m_c2*kst;
|
||||
n[0]->m_v+= l.m_c3*(j*n[0]->m_im);
|
||||
n[1]->m_v-= l.m_c3*(j*n[1]->m_im);
|
||||
}
|
||||
|
||||
@@ -370,8 +370,8 @@ public:
|
||||
}
|
||||
btVector3 angularVelocity(const btVector3& rpos) const
|
||||
{
|
||||
if(m_rigid) return(cross(m_rigid->getAngularVelocity(),rpos));
|
||||
if(m_soft) return(cross(m_soft->m_av,rpos));
|
||||
if(m_rigid) return(btCross(m_rigid->getAngularVelocity(),rpos));
|
||||
if(m_soft) return(btCross(m_soft->m_av,rpos));
|
||||
return(btVector3(0,0,0));
|
||||
}
|
||||
btVector3 angularVelocity() const
|
||||
|
||||
@@ -130,7 +130,7 @@ static inline btScalar tetravolume(const btVector3& x0,
|
||||
const btVector3 a=x1-x0;
|
||||
const btVector3 b=x2-x0;
|
||||
const btVector3 c=x3-x0;
|
||||
return(dot(a,cross(b,c)));
|
||||
return(btDot(a,btCross(b,c)));
|
||||
}
|
||||
|
||||
//
|
||||
@@ -209,9 +209,9 @@ void btSoftBodyHelpers::Draw( btSoftBody* psb,
|
||||
{
|
||||
const btSoftBody::RContact& c=psb->m_rcontacts[i];
|
||||
const btVector3 o= c.m_node->m_x-c.m_cti.m_normal*
|
||||
(dot(c.m_node->m_x,c.m_cti.m_normal)+c.m_cti.m_offset);
|
||||
const btVector3 x=cross(c.m_cti.m_normal,axis[c.m_cti.m_normal.minAxis()]).normalized();
|
||||
const btVector3 y=cross(x,c.m_cti.m_normal).normalized();
|
||||
(btDot(c.m_node->m_x,c.m_cti.m_normal)+c.m_cti.m_offset);
|
||||
const btVector3 x=btCross(c.m_cti.m_normal,axis[c.m_cti.m_normal.minAxis()]).normalized();
|
||||
const btVector3 y=btCross(x,c.m_cti.m_normal).normalized();
|
||||
idraw->drawLine(o-x*nscl,o+x*nscl,ccolor);
|
||||
idraw->drawLine(o-y*nscl,o+y*nscl,ccolor);
|
||||
idraw->drawLine(o,o+c.m_cti.m_normal*nscl*3,btVector3(1,1,0));
|
||||
@@ -299,7 +299,7 @@ void btSoftBodyHelpers::Draw( btSoftBody* psb,
|
||||
{
|
||||
const btSoftBody::Cluster& c=psb->m_clusters[i];
|
||||
const btVector3 r=c.m_nodes[j]->m_x-c.m_com;
|
||||
const btVector3 v=c.m_lv+cross(c.m_av,r);
|
||||
const btVector3 v=c.m_lv+btCross(c.m_av,r);
|
||||
idraw->drawLine(c.m_nodes[j]->m_x,c.m_nodes[j]->m_x+v,btVector3(1,0,0));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -124,11 +124,11 @@ public:
|
||||
virtual btVector3 localGetSupportingVertex(const btVector3& vec) const
|
||||
{
|
||||
btSoftBody::Node* const * n=&m_cluster->m_nodes[0];
|
||||
btScalar d=dot(vec,n[0]->m_x);
|
||||
btScalar d=btDot(vec,n[0]->m_x);
|
||||
int j=0;
|
||||
for(int i=1,ni=m_cluster->m_nodes.size();i<ni;++i)
|
||||
{
|
||||
const btScalar k=dot(vec,n[i]->m_x);
|
||||
const btScalar k=btDot(vec,n[i]->m_x);
|
||||
if(k>d) { d=k;j=i; }
|
||||
}
|
||||
return(n[j]->m_x);
|
||||
@@ -296,9 +296,9 @@ static inline btMatrix3x3 Mul(const btMatrix3x3& a,
|
||||
//
|
||||
static inline void Orthogonalize(btMatrix3x3& m)
|
||||
{
|
||||
m[2]=cross(m[0],m[1]).normalized();
|
||||
m[1]=cross(m[2],m[0]).normalized();
|
||||
m[0]=cross(m[1],m[2]).normalized();
|
||||
m[2]=btCross(m[0],m[1]).normalized();
|
||||
m[1]=btCross(m[2],m[0]).normalized();
|
||||
m[0]=btCross(m[1],m[2]).normalized();
|
||||
}
|
||||
//
|
||||
static inline btMatrix3x3 MassMatrix(btScalar im,const btMatrix3x3& iwi,const btVector3& r)
|
||||
@@ -335,7 +335,7 @@ static inline btMatrix3x3 AngularImpulseMatrix( const btMatrix3x3& iia,
|
||||
static inline btVector3 ProjectOnAxis( const btVector3& v,
|
||||
const btVector3& a)
|
||||
{
|
||||
return(a*dot(v,a));
|
||||
return(a*btDot(v,a));
|
||||
}
|
||||
//
|
||||
static inline btVector3 ProjectOnPlane( const btVector3& v,
|
||||
@@ -354,7 +354,7 @@ static inline void ProjectOrigin( const btVector3& a,
|
||||
const btScalar m2=d.length2();
|
||||
if(m2>SIMD_EPSILON)
|
||||
{
|
||||
const btScalar t=Clamp<btScalar>(-dot(a,d)/m2,0,1);
|
||||
const btScalar t=Clamp<btScalar>(-btDot(a,d)/m2,0,1);
|
||||
const btVector3 p=a+d*t;
|
||||
const btScalar l2=p.length2();
|
||||
if(l2<sqd)
|
||||
@@ -371,19 +371,19 @@ static inline void ProjectOrigin( const btVector3& a,
|
||||
btVector3& prj,
|
||||
btScalar& sqd)
|
||||
{
|
||||
const btVector3& q=cross(b-a,c-a);
|
||||
const btVector3& q=btCross(b-a,c-a);
|
||||
const btScalar m2=q.length2();
|
||||
if(m2>SIMD_EPSILON)
|
||||
{
|
||||
const btVector3 n=q/btSqrt(m2);
|
||||
const btScalar k=dot(a,n);
|
||||
const btScalar k=btDot(a,n);
|
||||
const btScalar k2=k*k;
|
||||
if(k2<sqd)
|
||||
{
|
||||
const btVector3 p=n*k;
|
||||
if( (dot(cross(a-p,b-p),q)>0)&&
|
||||
(dot(cross(b-p,c-p),q)>0)&&
|
||||
(dot(cross(c-p,a-p),q)>0))
|
||||
if( (btDot(btCross(a-p,b-p),q)>0)&&
|
||||
(btDot(btCross(b-p,c-p),q)>0)&&
|
||||
(btDot(btCross(c-p,a-p),q)>0))
|
||||
{
|
||||
prj=p;
|
||||
sqd=k2;
|
||||
@@ -413,9 +413,9 @@ static inline btVector3 BaryCoord( const btVector3& a,
|
||||
const btVector3& c,
|
||||
const btVector3& p)
|
||||
{
|
||||
const btScalar w[]={ cross(a-p,b-p).length(),
|
||||
cross(b-p,c-p).length(),
|
||||
cross(c-p,a-p).length()};
|
||||
const btScalar w[]={ btCross(a-p,b-p).length(),
|
||||
btCross(b-p,c-p).length(),
|
||||
btCross(c-p,a-p).length()};
|
||||
const btScalar isum=1/(w[0]+w[1]+w[2]);
|
||||
return(btVector3(w[1]*isum,w[2]*isum,w[0]*isum));
|
||||
}
|
||||
@@ -485,7 +485,7 @@ static inline btScalar AreaOf( const btVector3& x0,
|
||||
{
|
||||
const btVector3 a=x1-x0;
|
||||
const btVector3 b=x2-x0;
|
||||
const btVector3 cr=cross(a,b);
|
||||
const btVector3 cr=btCross(a,b);
|
||||
const btScalar area=cr.length();
|
||||
return(area);
|
||||
}
|
||||
@@ -499,7 +499,7 @@ static inline btScalar VolumeOf( const btVector3& x0,
|
||||
const btVector3 a=x1-x0;
|
||||
const btVector3 b=x2-x0;
|
||||
const btVector3 c=x3-x0;
|
||||
return(dot(a,cross(b,c)));
|
||||
return(btDot(a,btCross(b,c)));
|
||||
}
|
||||
|
||||
//
|
||||
@@ -512,7 +512,7 @@ static void EvaluateMedium( const btSoftBodyWorldInfo* wfi,
|
||||
medium.m_density = wfi->air_density;
|
||||
if(wfi->water_density>0)
|
||||
{
|
||||
const btScalar depth=-(dot(x,wfi->water_normal)+wfi->water_offset);
|
||||
const btScalar depth=-(btDot(x,wfi->water_normal)+wfi->water_offset);
|
||||
if(depth>0)
|
||||
{
|
||||
medium.m_density = wfi->water_density;
|
||||
@@ -676,7 +676,7 @@ struct btSoftColliders
|
||||
const btVector3 va=ba.velocity(ra);
|
||||
const btVector3 vb=bb.velocity(rb);
|
||||
const btVector3 vrel=va-vb;
|
||||
const btScalar rvac=dot(vrel,res.normal);
|
||||
const btScalar rvac=btDot(vrel,res.normal);
|
||||
const btScalar depth=res.distance-margin;
|
||||
const btVector3 iv=res.normal*rvac;
|
||||
const btVector3 fv=vrel-iv;
|
||||
@@ -839,7 +839,7 @@ struct btSoftColliders
|
||||
const btVector3 va=m_rigidBody ? m_rigidBody->getVelocityInLocalPoint(ra)*psb->m_sst.sdt : btVector3(0,0,0);
|
||||
const btVector3 vb=n.m_x-n.m_q;
|
||||
const btVector3 vr=vb-va;
|
||||
const btScalar dn=dot(vr,c.m_cti.m_normal);
|
||||
const btScalar dn=btDot(vr,c.m_cti.m_normal);
|
||||
const btVector3 fv=vr-c.m_cti.m_normal*dn;
|
||||
const btScalar fc=psb->m_cfg.kDF*m_colObj1->getFriction();
|
||||
c.m_node = &n;
|
||||
|
||||
@@ -96,21 +96,21 @@ btVector3 PlaneLineIntersection(const btPlane &plane, const btVector3 &p0, const
|
||||
// returns the point where the line p0-p1 intersects the plane n&d
|
||||
static btVector3 dif;
|
||||
dif = p1-p0;
|
||||
btScalar dn= dot(plane.normal,dif);
|
||||
btScalar t = -(plane.dist+dot(plane.normal,p0) )/dn;
|
||||
btScalar dn= btDot(plane.normal,dif);
|
||||
btScalar t = -(plane.dist+btDot(plane.normal,p0) )/dn;
|
||||
return p0 + (dif*t);
|
||||
}
|
||||
|
||||
btVector3 PlaneProject(const btPlane &plane, const btVector3 &point)
|
||||
{
|
||||
return point - plane.normal * (dot(point,plane.normal)+plane.dist);
|
||||
return point - plane.normal * (btDot(point,plane.normal)+plane.dist);
|
||||
}
|
||||
|
||||
btVector3 TriNormal(const btVector3 &v0, const btVector3 &v1, const btVector3 &v2)
|
||||
{
|
||||
// return the normal of the triangle
|
||||
// inscribed by v0, v1, and v2
|
||||
btVector3 cp=cross(v1-v0,v2-v1);
|
||||
btVector3 cp=btCross(v1-v0,v2-v1);
|
||||
btScalar m=cp.length();
|
||||
if(m==0) return btVector3(1,0,0);
|
||||
return cp*(btScalar(1.0)/m);
|
||||
@@ -120,23 +120,23 @@ btVector3 TriNormal(const btVector3 &v0, const btVector3 &v1, const btVector3 &v
|
||||
btScalar DistanceBetweenLines(const btVector3 &ustart, const btVector3 &udir, const btVector3 &vstart, const btVector3 &vdir, btVector3 *upoint, btVector3 *vpoint)
|
||||
{
|
||||
static btVector3 cp;
|
||||
cp = cross(udir,vdir).normalized();
|
||||
cp = btCross(udir,vdir).normalized();
|
||||
|
||||
btScalar distu = -dot(cp,ustart);
|
||||
btScalar distv = -dot(cp,vstart);
|
||||
btScalar distu = -btDot(cp,ustart);
|
||||
btScalar distv = -btDot(cp,vstart);
|
||||
btScalar dist = (btScalar)fabs(distu-distv);
|
||||
if(upoint)
|
||||
{
|
||||
btPlane plane;
|
||||
plane.normal = cross(vdir,cp).normalized();
|
||||
plane.dist = -dot(plane.normal,vstart);
|
||||
plane.normal = btCross(vdir,cp).normalized();
|
||||
plane.dist = -btDot(plane.normal,vstart);
|
||||
*upoint = PlaneLineIntersection(plane,ustart,ustart+udir);
|
||||
}
|
||||
if(vpoint)
|
||||
{
|
||||
btPlane plane;
|
||||
plane.normal = cross(udir,cp).normalized();
|
||||
plane.dist = -dot(plane.normal,ustart);
|
||||
plane.normal = btCross(udir,cp).normalized();
|
||||
plane.dist = -btDot(plane.normal,ustart);
|
||||
*vpoint = PlaneLineIntersection(plane,vstart,vstart+vdir);
|
||||
}
|
||||
return dist;
|
||||
@@ -170,7 +170,7 @@ ConvexH::ConvexH(int vertices_size,int edges_size,int facets_size)
|
||||
|
||||
int PlaneTest(const btPlane &p, const btVector3 &v);
|
||||
int PlaneTest(const btPlane &p, const btVector3 &v) {
|
||||
btScalar a = dot(v,p.normal)+p.dist;
|
||||
btScalar a = btDot(v,p.normal)+p.dist;
|
||||
int flag = (a>planetestepsilon)?OVER:((a<-planetestepsilon)?UNDER:COPLANAR);
|
||||
return flag;
|
||||
}
|
||||
@@ -228,7 +228,7 @@ int maxdirfiltered(const T *p,int count,const T &dir,btAlignedObjectArray<int> &
|
||||
for(int i=0;i<count;i++)
|
||||
if(allow[i])
|
||||
{
|
||||
if(m==-1 || dot(p[i],dir)>dot(p[m],dir))
|
||||
if(m==-1 || btDot(p[i],dir)>btDot(p[m],dir))
|
||||
m=i;
|
||||
}
|
||||
btAssert(m!=-1);
|
||||
@@ -238,8 +238,8 @@ int maxdirfiltered(const T *p,int count,const T &dir,btAlignedObjectArray<int> &
|
||||
btVector3 orth(const btVector3 &v);
|
||||
btVector3 orth(const btVector3 &v)
|
||||
{
|
||||
btVector3 a=cross(v,btVector3(0,0,1));
|
||||
btVector3 b=cross(v,btVector3(0,1,0));
|
||||
btVector3 a=btCross(v,btVector3(0,0,1));
|
||||
btVector3 b=btCross(v,btVector3(0,1,0));
|
||||
if (a.length() > b.length())
|
||||
{
|
||||
return a.normalized();
|
||||
@@ -258,7 +258,7 @@ int maxdirsterid(const T *p,int count,const T &dir,btAlignedObjectArray<int> &al
|
||||
m = maxdirfiltered(p,count,dir,allow);
|
||||
if(allow[m]==3) return m;
|
||||
T u = orth(dir);
|
||||
T v = cross(u,dir);
|
||||
T v = btCross(u,dir);
|
||||
int ma=-1;
|
||||
for(btScalar x = btScalar(0.0) ; x<= btScalar(360.0) ; x+= btScalar(45.0))
|
||||
{
|
||||
@@ -313,7 +313,7 @@ int above(btVector3* vertices,const int3& t, const btVector3 &p, btScalar epsilo
|
||||
int above(btVector3* vertices,const int3& t, const btVector3 &p, btScalar epsilon)
|
||||
{
|
||||
btVector3 n=TriNormal(vertices[t[0]],vertices[t[1]],vertices[t[2]]);
|
||||
return (dot(n,p-vertices[t[0]]) > epsilon); // EPSILON???
|
||||
return (btDot(n,p-vertices[t[0]]) > epsilon); // EPSILON???
|
||||
}
|
||||
int hasedge(const int3 &t, int a,int b);
|
||||
int hasedge(const int3 &t, int a,int b)
|
||||
@@ -495,8 +495,8 @@ int4 HullLibrary::FindSimplex(btVector3 *verts,int verts_count,btAlignedObjectAr
|
||||
basis[0] = verts[p0]-verts[p1];
|
||||
if(p0==p1 || basis[0]==btVector3(0,0,0))
|
||||
return int4(-1,-1,-1,-1);
|
||||
basis[1] = cross(btVector3( btScalar(1),btScalar(0.02), btScalar(0)),basis[0]);
|
||||
basis[2] = cross(btVector3(btScalar(-0.02), btScalar(1), btScalar(0)),basis[0]);
|
||||
basis[1] = btCross(btVector3( btScalar(1),btScalar(0.02), btScalar(0)),basis[0]);
|
||||
basis[2] = btCross(btVector3(btScalar(-0.02), btScalar(1), btScalar(0)),basis[0]);
|
||||
if (basis[1].length() > basis[2].length())
|
||||
{
|
||||
basis[1].normalize();
|
||||
@@ -512,13 +512,13 @@ int4 HullLibrary::FindSimplex(btVector3 *verts,int verts_count,btAlignedObjectAr
|
||||
if(p2 == p0 || p2 == p1)
|
||||
return int4(-1,-1,-1,-1);
|
||||
basis[1] = verts[p2] - verts[p0];
|
||||
basis[2] = cross(basis[1],basis[0]).normalized();
|
||||
basis[2] = btCross(basis[1],basis[0]).normalized();
|
||||
int p3 = maxdirsterid(verts,verts_count,basis[2],allow);
|
||||
if(p3==p0||p3==p1||p3==p2) p3 = maxdirsterid(verts,verts_count,-basis[2],allow);
|
||||
if(p3==p0||p3==p1||p3==p2)
|
||||
return int4(-1,-1,-1,-1);
|
||||
btAssert(!(p0==p1||p0==p2||p0==p3||p1==p2||p1==p3||p2==p3));
|
||||
if(dot(verts[p3]-verts[p0],cross(verts[p1]-verts[p0],verts[p2]-verts[p0])) <0) {Swap(p2,p3);}
|
||||
if(btDot(verts[p3]-verts[p0],btCross(verts[p1]-verts[p0],verts[p2]-verts[p0])) <0) {Swap(p2,p3);}
|
||||
return int4(p0,p1,p2,p3);
|
||||
}
|
||||
|
||||
@@ -564,7 +564,7 @@ int HullLibrary::calchullgen(btVector3 *verts,int verts_count, int vlimit)
|
||||
btAssert(t->vmax<0);
|
||||
btVector3 n=TriNormal(verts[(*t)[0]],verts[(*t)[1]],verts[(*t)[2]]);
|
||||
t->vmax = maxdirsterid(verts,verts_count,n,allow);
|
||||
t->rise = dot(n,verts[t->vmax]-verts[(*t)[0]]);
|
||||
t->rise = btDot(n,verts[t->vmax]-verts[(*t)[0]]);
|
||||
}
|
||||
btHullTriangle *te;
|
||||
vlimit-=4;
|
||||
@@ -592,7 +592,7 @@ int HullLibrary::calchullgen(btVector3 *verts,int verts_count, int vlimit)
|
||||
if(!m_tris[j]) continue;
|
||||
if(!hasvert(*m_tris[j],v)) break;
|
||||
int3 nt=*m_tris[j];
|
||||
if(above(verts,nt,center,btScalar(0.01)*epsilon) || cross(verts[nt[1]]-verts[nt[0]],verts[nt[2]]-verts[nt[1]]).length()< epsilon*epsilon*btScalar(0.1) )
|
||||
if(above(verts,nt,center,btScalar(0.01)*epsilon) || btCross(verts[nt[1]]-verts[nt[0]],verts[nt[2]]-verts[nt[1]]).length()< epsilon*epsilon*btScalar(0.1) )
|
||||
{
|
||||
btHullTriangle *nb = m_tris[m_tris[j]->n[0]];
|
||||
btAssert(nb);btAssert(!hasvert(*nb,v));btAssert(nb->id<j);
|
||||
@@ -614,7 +614,7 @@ int HullLibrary::calchullgen(btVector3 *verts,int verts_count, int vlimit)
|
||||
}
|
||||
else
|
||||
{
|
||||
t->rise = dot(n,verts[t->vmax]-verts[(*t)[0]]);
|
||||
t->rise = btDot(n,verts[t->vmax]-verts[(*t)[0]]);
|
||||
}
|
||||
}
|
||||
vlimit --;
|
||||
|
||||
@@ -503,7 +503,7 @@ class btMatrix3x3 {
|
||||
SIMD_FORCE_INLINE btScalar
|
||||
btMatrix3x3::determinant() const
|
||||
{
|
||||
return triple((*this)[0], (*this)[1], (*this)[2]);
|
||||
return btTriple((*this)[0], (*this)[1], (*this)[2]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -261,6 +261,18 @@ public:
|
||||
return (-qd);
|
||||
}
|
||||
|
||||
/**@todo document this and it's use */
|
||||
SIMD_FORCE_INLINE btQuaternion nearest( const btQuaternion& qd) const
|
||||
{
|
||||
btQuaternion diff,sum;
|
||||
diff = *this - qd;
|
||||
sum = *this + qd;
|
||||
if( diff.dot(diff) < sum.dot(sum) )
|
||||
return qd;
|
||||
return (-qd);
|
||||
}
|
||||
|
||||
|
||||
/**@brief Return the quaternion which is the result of Spherical Linear Interpolation between this and the other quaternion
|
||||
* @param q The other quaternion to interpolate with
|
||||
* @param t The ratio between this and q to interpolate. If t = 0 the result is this, if t=1 the result is q.
|
||||
|
||||
@@ -96,7 +96,7 @@ public:
|
||||
|
||||
static void calculateDiffAxisAngleQuaternion(const btQuaternion& orn0,const btQuaternion& orn1a,btVector3& axis,btScalar& angle)
|
||||
{
|
||||
btQuaternion orn1 = orn0.farthest(orn1a);
|
||||
btQuaternion orn1 = orn0.nearest(orn1a);
|
||||
btQuaternion dorn = orn1 * orn0.inverse();
|
||||
///floating point inaccuracy can lead to w component > 1..., which breaks
|
||||
dorn.normalize();
|
||||
@@ -206,17 +206,21 @@ public:
|
||||
|
||||
void initSeparatingDistance(const btVector3& separatingVector,btScalar separatingDistance,const btTransform& transA,const btTransform& transB)
|
||||
{
|
||||
m_separatingNormal = separatingVector;
|
||||
m_separatingDistance = separatingDistance;
|
||||
|
||||
const btVector3& toPosA = transA.getOrigin();
|
||||
const btVector3& toPosB = transB.getOrigin();
|
||||
btQuaternion toOrnA = transA.getRotation();
|
||||
btQuaternion toOrnB = transB.getRotation();
|
||||
m_posA = toPosA;
|
||||
m_posB = toPosB;
|
||||
m_ornA = toOrnA;
|
||||
m_ornB = toOrnB;
|
||||
|
||||
if (m_separatingDistance>0.f)
|
||||
{
|
||||
m_separatingNormal = separatingVector;
|
||||
|
||||
const btVector3& toPosA = transA.getOrigin();
|
||||
const btVector3& toPosB = transB.getOrigin();
|
||||
btQuaternion toOrnA = transA.getRotation();
|
||||
btQuaternion toOrnB = transB.getRotation();
|
||||
m_posA = toPosA;
|
||||
m_posB = toPosB;
|
||||
m_ornA = toOrnA;
|
||||
m_ornB = toOrnB;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -306,7 +306,7 @@ public:
|
||||
m_floats[0]=x;
|
||||
m_floats[1]=y;
|
||||
m_floats[2]=z;
|
||||
m_floats[3] = 0.f;
|
||||
m_floats[3] = btScalar(0.);
|
||||
}
|
||||
|
||||
void getSkewSymmetricMatrix(btVector3* v0,btVector3* v1,btVector3* v2) const
|
||||
@@ -316,6 +316,11 @@ public:
|
||||
v2->setValue(-y() ,x() ,0.);
|
||||
}
|
||||
|
||||
void setZero()
|
||||
{
|
||||
setValue(btScalar(0.),btScalar(0.),btScalar(0.));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**@brief Return the sum of two vectors (Point symantics)*/
|
||||
@@ -376,7 +381,7 @@ operator/(const btVector3& v1, const btVector3& v2)
|
||||
|
||||
/**@brief Return the dot product between two vectors */
|
||||
SIMD_FORCE_INLINE btScalar
|
||||
dot(const btVector3& v1, const btVector3& v2)
|
||||
btDot(const btVector3& v1, const btVector3& v2)
|
||||
{
|
||||
return v1.dot(v2);
|
||||
}
|
||||
@@ -384,7 +389,7 @@ dot(const btVector3& v1, const btVector3& v2)
|
||||
|
||||
/**@brief Return the distance squared between two vectors */
|
||||
SIMD_FORCE_INLINE btScalar
|
||||
distance2(const btVector3& v1, const btVector3& v2)
|
||||
btDistance2(const btVector3& v1, const btVector3& v2)
|
||||
{
|
||||
return v1.distance2(v2);
|
||||
}
|
||||
@@ -392,27 +397,27 @@ distance2(const btVector3& v1, const btVector3& v2)
|
||||
|
||||
/**@brief Return the distance between two vectors */
|
||||
SIMD_FORCE_INLINE btScalar
|
||||
distance(const btVector3& v1, const btVector3& v2)
|
||||
btDistance(const btVector3& v1, const btVector3& v2)
|
||||
{
|
||||
return v1.distance(v2);
|
||||
}
|
||||
|
||||
/**@brief Return the angle between two vectors */
|
||||
SIMD_FORCE_INLINE btScalar
|
||||
angle(const btVector3& v1, const btVector3& v2)
|
||||
btAngle(const btVector3& v1, const btVector3& v2)
|
||||
{
|
||||
return v1.angle(v2);
|
||||
}
|
||||
|
||||
/**@brief Return the cross product of two vectors */
|
||||
SIMD_FORCE_INLINE btVector3
|
||||
cross(const btVector3& v1, const btVector3& v2)
|
||||
btCross(const btVector3& v1, const btVector3& v2)
|
||||
{
|
||||
return v1.cross(v2);
|
||||
}
|
||||
|
||||
SIMD_FORCE_INLINE btScalar
|
||||
triple(const btVector3& v1, const btVector3& v2, const btVector3& v3)
|
||||
btTriple(const btVector3& v1, const btVector3& v2, const btVector3& v3)
|
||||
{
|
||||
return v1.triple(v2, v3);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user