- Timestamp:
- Feb 27, 2011, 7:43:24 AM (14 years ago)
- Location:
- code/branches/kicklib/src/external/bullet/BulletCollision/NarrowPhaseCollision
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/kicklib/src/external/bullet/BulletCollision/NarrowPhaseCollision/btContinuousConvexCollision.cpp
r5781 r7983 97 97 { 98 98 99 btGjkPairDetector gjk(m_convexA,m_convexB,m_ simplexSolver,m_penetrationDepthSolver);99 btGjkPairDetector gjk(m_convexA,m_convexB,m_convexA->getShapeType(),m_convexB->getShapeType(),m_convexA->getMargin(),m_convexB->getMargin(),m_simplexSolver,m_penetrationDepthSolver); 100 100 btGjkPairDetector::ClosestPointInput input; 101 101 … … 122 122 while (dist > radius) 123 123 { 124 if (result.m_debugDrawer) 125 { 126 result.m_debugDrawer->drawSphere(c,0.2f,btVector3(1,1,1)); 127 } 124 128 numIter++; 125 129 if (numIter > maxIter) … … 170 174 btTransformUtil::integrateTransform(fromB,linVelB,angVelB,lambda,interpolatedTransB); 171 175 relativeTrans = interpolatedTransB.inverseTimes(interpolatedTransA); 176 177 if (result.m_debugDrawer) 178 { 179 result.m_debugDrawer->drawSphere(interpolatedTransA.getOrigin(),0.2f,btVector3(1,0,0)); 180 } 172 181 173 182 result.DebugDraw( lambda ); … … 198 207 return false; 199 208 } 209 200 210 201 211 } … … 225 235 226 236 } 227 -
code/branches/kicklib/src/external/bullet/BulletCollision/NarrowPhaseCollision/btConvexCast.h
r5781 r7983 42 42 43 43 CastResult() 44 :m_fraction(btScalar( 1e30)),44 :m_fraction(btScalar(BT_LARGE_FLOAT)), 45 45 m_debugDrawer(0), 46 46 m_allowedPenetration(btScalar(0)) -
code/branches/kicklib/src/external/bullet/BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h
r5781 r7983 15 15 16 16 17 #ifndef CONVEX_PENETRATION_DEPTH_H18 #define CONVEX_PENETRATION_DEPTH_H17 #ifndef __CONVEX_PENETRATION_DEPTH_H 18 #define __CONVEX_PENETRATION_DEPTH_H 19 19 20 20 class btStackAlloc; -
code/branches/kicklib/src/external/bullet/BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h
r5781 r7983 34 34 virtual ~Result(){} 35 35 36 ///setShapeIdentifiers provides experimental support for per-triangle material / custom material combiner 37 virtual void setShapeIdentifiers(int partId0,int index0, int partId1,int index1)=0; 36 ///setShapeIdentifiersA/B provides experimental support for per-triangle material / custom material combiner 37 virtual void setShapeIdentifiersA(int partId0,int index0)=0; 38 virtual void setShapeIdentifiersB(int partId1,int index1)=0; 38 39 virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth)=0; 39 40 }; … … 42 43 { 43 44 ClosestPointInput() 44 :m_maximumDistanceSquared(btScalar( 1e30)),45 :m_maximumDistanceSquared(btScalar(BT_LARGE_FLOAT)), 45 46 m_stackAlloc(0) 46 47 { … … 69 70 btScalar m_distance; //negative means penetration ! 70 71 71 btStorageResult() : m_distance(btScalar( 1e30))72 btStorageResult() : m_distance(btScalar(BT_LARGE_FLOAT)) 72 73 { 73 74 -
code/branches/kicklib/src/external/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpa2.cpp
r5781 r7983 69 69 btMatrix3x3 m_toshape1; 70 70 btTransform m_toshape0; 71 #ifdef __SPU__ 72 bool m_enableMargin; 73 #else 71 74 btVector3 (btConvexShape::*Ls)(const btVector3&) const; 75 #endif//__SPU__ 76 77 78 MinkowskiDiff() 79 { 80 81 } 82 #ifdef __SPU__ 83 void EnableMargin(bool enable) 84 { 85 m_enableMargin = enable; 86 } 87 inline btVector3 Support0(const btVector3& d) const 88 { 89 if (m_enableMargin) 90 { 91 return m_shapes[0]->localGetSupportVertexNonVirtual(d); 92 } else 93 { 94 return m_shapes[0]->localGetSupportVertexWithoutMarginNonVirtual(d); 95 } 96 } 97 inline btVector3 Support1(const btVector3& d) const 98 { 99 if (m_enableMargin) 100 { 101 return m_toshape0*(m_shapes[1]->localGetSupportVertexNonVirtual(m_toshape1*d)); 102 } else 103 { 104 return m_toshape0*(m_shapes[1]->localGetSupportVertexWithoutMarginNonVirtual(m_toshape1*d)); 105 } 106 } 107 #else 72 108 void EnableMargin(bool enable) 73 109 { … … 85 121 return(m_toshape0*((m_shapes[1])->*(Ls))(m_toshape1*d)); 86 122 } 123 #endif //__SPU__ 124 87 125 inline btVector3 Support(const btVector3& d) const 88 126 { … … 203 241 } 204 242 /* Check for termination */ 205 const btScalar omega= dot(m_ray,w)/rl;243 const btScalar omega=btDot(m_ray,w)/rl; 206 244 alpha=btMax(omega,alpha); 207 245 if(((rl-alpha)-(GJK_ACCURARY*rl))<=0) … … 260 298 case eStatus::Valid: m_distance=m_ray.length();break; 261 299 case eStatus::Inside: m_distance=0;break; 300 default: 301 { 302 } 262 303 } 263 304 return(m_status); … … 289 330 btVector3 axis=btVector3(0,0,0); 290 331 axis[i]=1; 291 const btVector3 p= cross(d,axis);332 const btVector3 p=btCross(d,axis); 292 333 if(p.length2()>0) 293 334 { … … 304 345 case 3: 305 346 { 306 const btVector3 n= cross(m_simplex->c[1]->w-m_simplex->c[0]->w,347 const btVector3 n=btCross(m_simplex->c[1]->w-m_simplex->c[0]->w, 307 348 m_simplex->c[2]->w-m_simplex->c[0]->w); 308 349 if(n.length2()>0) … … 358 399 if(l>GJK_SIMPLEX2_EPS) 359 400 { 360 const btScalar t(l>0?- dot(a,d)/l:0);401 const btScalar t(l>0?-btDot(a,d)/l:0); 361 402 if(t>=1) { w[0]=0;w[1]=1;m=2;return(b.length2()); } 362 403 else if(t<=0) { w[0]=1;w[1]=0;m=1;return(a.length2()); } … … 373 414 const btVector3* vt[]={&a,&b,&c}; 374 415 const btVector3 dl[]={a-b,b-c,c-a}; 375 const btVector3 n= cross(dl[0],dl[1]);416 const btVector3 n=btCross(dl[0],dl[1]); 376 417 const btScalar l=n.length2(); 377 418 if(l>GJK_SIMPLEX3_EPS) 378 419 { 379 420 btScalar mindist=-1; 380 btScalar subw[2] ;381 U subm ;421 btScalar subw[2]={0.f,0.f}; 422 U subm(0); 382 423 for(U i=0;i<3;++i) 383 424 { 384 if( dot(*vt[i],cross(dl[i],n))>0)425 if(btDot(*vt[i],btCross(dl[i],n))>0) 385 426 { 386 427 const U j=imd3[i]; … … 398 439 if(mindist<0) 399 440 { 400 const btScalar d= dot(a,n);441 const btScalar d=btDot(a,n); 401 442 const btScalar s=btSqrt(l); 402 443 const btVector3 p=n*(d/l); 403 444 mindist = p.length2(); 404 445 m = 7; 405 w[0] = ( cross(dl[1],b-p)).length()/s;406 w[1] = ( cross(dl[2],c-p)).length()/s;446 w[0] = (btCross(dl[1],b-p)).length()/s; 447 w[1] = (btCross(dl[2],c-p)).length()/s; 407 448 w[2] = 1-(w[0]+w[1]); 408 449 } … … 421 462 const btVector3 dl[]={a-d,b-d,c-d}; 422 463 const btScalar vl=det(dl[0],dl[1],dl[2]); 423 const bool ng=(vl* dot(a,cross(b-c,a-b)))<=0;464 const bool ng=(vl*btDot(a,btCross(b-c,a-b)))<=0; 424 465 if(ng&&(btFabs(vl)>GJK_SIMPLEX4_EPS)) 425 466 { 426 467 btScalar mindist=-1; 427 btScalar subw[3] ;428 U subm ;468 btScalar subw[3]={0.f,0.f,0.f}; 469 U subm(0); 429 470 for(U i=0;i<3;++i) 430 471 { 431 472 const U j=imd3[i]; 432 const btScalar s=vl* dot(d,cross(dl[i],dl[j]));473 const btScalar s=vl*btDot(d,btCross(dl[i],dl[j])); 433 474 if(s>0) 434 475 { … … 602 643 best->pass = (U1)(++pass); 603 644 gjk.getsupport(best->n,*w); 604 const btScalar wdist= dot(best->n,w->w)-best->d;645 const btScalar wdist=btDot(best->n,w->w)-best->d; 605 646 if(wdist>EPA_ACCURACY) 606 647 { … … 629 670 m_result.c[1] = outer.c[1]; 630 671 m_result.c[2] = outer.c[2]; 631 m_result.p[0] = cross( outer.c[1]->w-projection,672 m_result.p[0] = btCross( outer.c[1]->w-projection, 632 673 outer.c[2]->w-projection).length(); 633 m_result.p[1] = cross( outer.c[2]->w-projection,674 m_result.p[1] = btCross( outer.c[2]->w-projection, 634 675 outer.c[0]->w-projection).length(); 635 m_result.p[2] = cross( outer.c[0]->w-projection,676 m_result.p[2] = btCross( outer.c[0]->w-projection, 636 677 outer.c[1]->w-projection).length(); 637 678 const btScalar sum=m_result.p[0]+m_result.p[1]+m_result.p[2]; … … 667 708 face->c[1] = b; 668 709 face->c[2] = c; 669 face->n = cross(b->w-a->w,c->w-a->w);710 face->n = btCross(b->w-a->w,c->w-a->w); 670 711 const btScalar l=face->n.length(); 671 712 const bool v=l>EPA_ACCURACY; 672 713 face->p = btMin(btMin( 673 dot(a->w,cross(face->n,a->w-b->w)),674 dot(b->w,cross(face->n,b->w-c->w))),675 dot(c->w,cross(face->n,c->w-a->w))) /714 btDot(a->w,btCross(face->n,a->w-b->w)), 715 btDot(b->w,btCross(face->n,b->w-c->w))), 716 btDot(c->w,btCross(face->n,c->w-a->w))) / 676 717 (v?l:1); 677 718 face->p = face->p>=-EPA_INSIDE_EPS?0:face->p; 678 719 if(v) 679 720 { 680 face->d = dot(a->w,face->n)/l;721 face->d = btDot(a->w,face->n)/l; 681 722 face->n /= l; 682 723 if(forced||(face->d>=-EPA_PLANE_EPS)) … … 716 757 { 717 758 const U e1=i1m3[e]; 718 if(( dot(f->n,w->w)-f->d)<-EPA_PLANE_EPS)759 if((btDot(f->n,w->w)-f->d)<-EPA_PLANE_EPS) 719 760 { 720 761 sFace* nf=newface(f->c[e1],f->c[e],w,false); … … 855 896 results.status=sResults::GJK_Failed; 856 897 break; 898 default: 899 { 900 } 857 901 } 858 902 return(false); 859 903 } 860 904 905 #ifndef __SPU__ 861 906 // 862 907 btScalar btGjkEpaSolver2::SignedDistance(const btVector3& position, … … 924 969 return(true); 925 970 } 971 #endif //__SPU__ 926 972 927 973 /* Symbols cleanup */ -
code/branches/kicklib/src/external/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpa2.h
r5781 r7983 56 56 sResults& results, 57 57 bool usemargins=true); 58 58 #ifndef __SPU__ 59 59 static btScalar SignedDistance( const btVector3& position, 60 60 btScalar margin, … … 67 67 const btVector3& guess, 68 68 sResults& results); 69 #endif //__SPU__ 70 69 71 }; 70 72 -
code/branches/kicklib/src/external/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.cpp
r5781 r7983 33 33 (void)simplexSolver; 34 34 35 const btScalar radialmargin(btScalar(0.));35 // const btScalar radialmargin(btScalar(0.)); 36 36 37 37 btVector3 guessVector(transformA.getOrigin()-transformB.getOrigin()); 38 38 btGjkEpaSolver2::sResults results; 39 40 39 41 if(btGjkEpaSolver2::Penetration(pConvexA,transformA, 40 42 pConvexB,transformB, … … 46 48 wWitnessOnA = results.witnesses[0]; 47 49 wWitnessOnB = results.witnesses[1]; 50 v = results.normal; 48 51 return true; 52 } else 53 { 54 if(btGjkEpaSolver2::Distance(pConvexA,transformA,pConvexB,transformB,guessVector,results)) 55 { 56 wWitnessOnA = results.witnesses[0]; 57 wWitnessOnB = results.witnesses[1]; 58 v = results.normal; 59 return false; 49 60 } 61 } 50 62 51 63 return false; -
code/branches/kicklib/src/external/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h
r5781 r7983 26 26 public : 27 27 28 btGjkEpaPenetrationDepthSolver() 29 { 30 } 31 28 32 bool calcPenDepth( btSimplexSolverInterface& simplexSolver, 29 33 const btConvexShape* pConvexA, const btConvexShape* pConvexB, -
code/branches/kicklib/src/external/bullet/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp
r5781 r7983 39 39 40 40 41 42 41 btGjkPairDetector::btGjkPairDetector(const btConvexShape* objectA,const btConvexShape* objectB,btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver) 43 :m_cachedSeparatingAxis(btScalar(0.),btScalar( 0.),btScalar(1.)),42 :m_cachedSeparatingAxis(btScalar(0.),btScalar(1.),btScalar(0.)), 44 43 m_penetrationDepthSolver(penetrationDepthSolver), 45 44 m_simplexSolver(simplexSolver), 46 45 m_minkowskiA(objectA), 47 46 m_minkowskiB(objectB), 47 m_shapeTypeA(objectA->getShapeType()), 48 m_shapeTypeB(objectB->getShapeType()), 49 m_marginA(objectA->getMargin()), 50 m_marginB(objectB->getMargin()), 48 51 m_ignoreMargin(false), 49 52 m_lastUsedMethod(-1), … … 51 54 { 52 55 } 53 54 void btGjkPairDetector::getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw,bool swapResults) 56 btGjkPairDetector::btGjkPairDetector(const btConvexShape* objectA,const btConvexShape* objectB,int shapeTypeA,int shapeTypeB,btScalar marginA, btScalar marginB, btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver) 57 :m_cachedSeparatingAxis(btScalar(0.),btScalar(1.),btScalar(0.)), 58 m_penetrationDepthSolver(penetrationDepthSolver), 59 m_simplexSolver(simplexSolver), 60 m_minkowskiA(objectA), 61 m_minkowskiB(objectB), 62 m_shapeTypeA(shapeTypeA), 63 m_shapeTypeB(shapeTypeB), 64 m_marginA(marginA), 65 m_marginB(marginB), 66 m_ignoreMargin(false), 67 m_lastUsedMethod(-1), 68 m_catchDegeneracies(1) 69 { 70 } 71 72 void btGjkPairDetector::getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw,bool swapResults) 73 { 74 (void)swapResults; 75 76 getClosestPointsNonVirtual(input,output,debugDraw); 77 } 78 79 #ifdef __SPU__ 80 void btGjkPairDetector::getClosestPointsNonVirtual(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw) 81 #else 82 void btGjkPairDetector::getClosestPointsNonVirtual(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw) 83 #endif 55 84 { 56 85 m_cachedSeparatingDistance = 0.f; … … 65 94 localTransB.getOrigin() -= positionOffset; 66 95 67 #ifdef __SPU__ 68 btScalar marginA = m_minkowskiA->getMarginNonVirtual(); 69 btScalar marginB = m_minkowskiB->getMarginNonVirtual(); 70 #else 71 btScalar marginA = m_minkowskiA->getMargin(); 72 btScalar marginB = m_minkowskiB->getMargin(); 73 #ifdef TEST_NON_VIRTUAL 74 btScalar marginAv = m_minkowskiA->getMarginNonVirtual(); 75 btScalar marginBv = m_minkowskiB->getMarginNonVirtual(); 76 btAssert(marginA == marginAv); 77 btAssert(marginB == marginBv); 78 #endif //TEST_NON_VIRTUAL 79 #endif 80 81 96 bool check2d = m_minkowskiA->isConvex2d() && m_minkowskiB->isConvex2d(); 97 98 btScalar marginA = m_marginA; 99 btScalar marginB = m_marginB; 82 100 83 101 gNumGjkChecks++; … … 108 126 109 127 { 110 btScalar squaredDistance = SIMD_INFINITY;128 btScalar squaredDistance = BT_LARGE_FLOAT; 111 129 btScalar delta = btScalar(0.); 112 130 … … 124 142 btVector3 seperatingAxisInB = m_cachedSeparatingAxis* input.m_transformB.getBasis(); 125 143 144 #if 1 145 146 btVector3 pInA = m_minkowskiA->localGetSupportVertexWithoutMarginNonVirtual(seperatingAxisInA); 147 btVector3 qInB = m_minkowskiB->localGetSupportVertexWithoutMarginNonVirtual(seperatingAxisInB); 148 149 // btVector3 pInA = localGetSupportingVertexWithoutMargin(m_shapeTypeA, m_minkowskiA, seperatingAxisInA,input.m_convexVertexData[0]);//, &featureIndexA); 150 // btVector3 qInB = localGetSupportingVertexWithoutMargin(m_shapeTypeB, m_minkowskiB, seperatingAxisInB,input.m_convexVertexData[1]);//, &featureIndexB); 151 152 #else 126 153 #ifdef __SPU__ 127 154 btVector3 pInA = m_minkowskiA->localGetSupportVertexWithoutMarginNonVirtual(seperatingAxisInA); … … 137 164 #endif // 138 165 #endif //__SPU__ 166 #endif 167 139 168 140 169 btVector3 pWorld = localTransA(pInA); … … 145 174 #endif 146 175 176 if (check2d) 177 { 178 pWorld[2] = 0.f; 179 qWorld[2] = 0.f; 180 } 181 147 182 btVector3 w = pWorld - qWorld; 148 183 delta = m_cachedSeparatingAxis.dot(w); … … 151 186 if ((delta > btScalar(0.0)) && (delta * delta > squaredDistance * input.m_maximumDistanceSquared)) 152 187 { 188 m_degenerateSimplex = 10; 153 189 checkSimplex=true; 154 190 //checkPenetration = false; … … 172 208 { 173 209 m_degenerateSimplex = 2; 210 } else 211 { 212 m_degenerateSimplex = 11; 174 213 } 175 214 checkSimplex = true; … … 185 224 spu_printf("addVertex 2\n"); 186 225 #endif 226 btVector3 newCachedSeparatingAxis; 227 187 228 //calculate the closest point to the origin (update vector v) 188 if (!m_simplexSolver->closest( m_cachedSeparatingAxis))229 if (!m_simplexSolver->closest(newCachedSeparatingAxis)) 189 230 { 190 231 m_degenerateSimplex = 3; … … 193 234 } 194 235 195 if( m_cachedSeparatingAxis.length2()<REL_ERROR2)236 if(newCachedSeparatingAxis.length2()<REL_ERROR2) 196 237 { 238 m_cachedSeparatingAxis = newCachedSeparatingAxis; 197 239 m_degenerateSimplex = 6; 198 240 checkSimplex = true; … … 201 243 202 244 btScalar previousSquaredDistance = squaredDistance; 203 squaredDistance = m_cachedSeparatingAxis.length2(); 245 squaredDistance = newCachedSeparatingAxis.length2(); 246 #if 0 247 ///warning: this termination condition leads to some problems in 2d test case see Bullet/Demos/Box2dDemo 248 if (squaredDistance>previousSquaredDistance) 249 { 250 m_degenerateSimplex = 7; 251 squaredDistance = previousSquaredDistance; 252 checkSimplex = false; 253 break; 254 } 255 #endif // 204 256 257 m_cachedSeparatingAxis = newCachedSeparatingAxis; 258 205 259 //redundant m_simplexSolver->compute_points(pointOnA, pointOnB); 206 260 … … 210 264 m_simplexSolver->backup_closest(m_cachedSeparatingAxis); 211 265 checkSimplex = true; 266 m_degenerateSimplex = 12; 267 212 268 break; 213 269 } … … 240 296 //do we need this backup_closest here ? 241 297 m_simplexSolver->backup_closest(m_cachedSeparatingAxis); 298 m_degenerateSimplex = 13; 242 299 break; 243 300 } … … 248 305 m_simplexSolver->compute_points(pointOnA, pointOnB); 249 306 normalInB = pointOnA-pointOnB; 250 btScalar lenSqr = m_cachedSeparatingAxis.length2(); 307 btScalar lenSqr =m_cachedSeparatingAxis.length2(); 308 251 309 //valid normal 252 310 if (lenSqr < 0.0001) … … 280 338 { 281 339 //penetration case 282 340 283 341 //if there is no way to handle penetrations, bail out 284 342 if (m_penetrationDepthSolver) … … 288 346 289 347 gNumDeepPenetrationChecks++; 348 m_cachedSeparatingAxis.setZero(); 290 349 291 350 bool isValid2 = m_penetrationDepthSolver->calcPenDepth( … … 297 356 ); 298 357 358 299 359 if (isValid2) 300 360 { 301 361 btVector3 tmpNormalInB = tmpPointOnB-tmpPointOnA; 302 362 btScalar lenSqr = tmpNormalInB.length2(); 363 if (lenSqr <= (SIMD_EPSILON*SIMD_EPSILON)) 364 { 365 tmpNormalInB = m_cachedSeparatingAxis; 366 lenSqr = m_cachedSeparatingAxis.length2(); 367 } 368 303 369 if (lenSqr > (SIMD_EPSILON*SIMD_EPSILON)) 304 370 { … … 316 382 } else 317 383 { 318 384 m_lastUsedMethod = 8; 319 385 } 320 386 } else 321 387 { 322 //isValid = false; 323 m_lastUsedMethod = 4; 388 m_lastUsedMethod = 9; 324 389 } 325 390 } else 391 326 392 { 327 m_lastUsedMethod = 5; 393 ///this is another degenerate case, where the initial GJK calculation reports a degenerate case 394 ///EPA reports no penetration, and the second GJK (using the supporting vector without margin) 395 ///reports a valid positive distance. Use the results of the second GJK instead of failing. 396 ///thanks to Jacob.Langford for the reproduction case 397 ///http://code.google.com/p/bullet/issues/detail?id=250 398 399 400 if (m_cachedSeparatingAxis.length2() > btScalar(0.)) 401 { 402 btScalar distance2 = (tmpPointOnA-tmpPointOnB).length()-margin; 403 //only replace valid distances when the distance is less 404 if (!isValid || (distance2 < distance)) 405 { 406 distance = distance2; 407 pointOnA = tmpPointOnA; 408 pointOnB = tmpPointOnB; 409 pointOnA -= m_cachedSeparatingAxis * marginA ; 410 pointOnB += m_cachedSeparatingAxis * marginB ; 411 normalInB = m_cachedSeparatingAxis; 412 normalInB.normalize(); 413 isValid = true; 414 m_lastUsedMethod = 6; 415 } else 416 { 417 m_lastUsedMethod = 5; 418 } 419 } 328 420 } 329 421 330 422 } 423 331 424 } 332 425 } 333 426 334 if (isValid) 427 428 429 if (isValid && ((distance < 0) || (distance*distance < input.m_maximumDistanceSquared))) 335 430 { 336 #ifdef __SPU__ 337 //spu_printf("distance\n"); 338 #endif //__CELLOS_LV2__ 339 340 341 #ifdef DEBUG_SPU_COLLISION_DETECTION 342 spu_printf("output 1\n"); 343 #endif 431 #if 0 432 ///some debugging 433 // if (check2d) 434 { 435 printf("n = %2.3f,%2.3f,%2.3f. ",normalInB[0],normalInB[1],normalInB[2]); 436 printf("distance = %2.3f exit=%d deg=%d\n",distance,m_lastUsedMethod,m_degenerateSimplex); 437 } 438 #endif 439 344 440 m_cachedSeparatingAxis = normalInB; 345 441 m_cachedSeparatingDistance = distance; … … 350 446 distance); 351 447 352 #ifdef DEBUG_SPU_COLLISION_DETECTION353 spu_printf("output 2\n");354 #endif355 //printf("gjk add:%f",distance);356 448 } 357 449 -
code/branches/kicklib/src/external/bullet/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h
r5781 r7983 37 37 const btConvexShape* m_minkowskiA; 38 38 const btConvexShape* m_minkowskiB; 39 int m_shapeTypeA; 40 int m_shapeTypeB; 41 btScalar m_marginA; 42 btScalar m_marginB; 43 39 44 bool m_ignoreMargin; 40 45 btScalar m_cachedSeparatingDistance; … … 51 56 52 57 btGjkPairDetector(const btConvexShape* objectA,const btConvexShape* objectB,btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver); 58 btGjkPairDetector(const btConvexShape* objectA,const btConvexShape* objectB,int shapeTypeA,int shapeTypeB,btScalar marginA, btScalar marginB, btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver); 53 59 virtual ~btGjkPairDetector() {}; 54 60 55 61 virtual void getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw,bool swapResults=false); 62 63 void getClosestPointsNonVirtual(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw); 64 56 65 57 66 void setMinkowskiA(btConvexShape* minkA) -
code/branches/kicklib/src/external/bullet/BulletCollision/NarrowPhaseCollision/btManifoldPoint.h
r5781 r7983 20 20 #include "LinearMath/btTransformUtil.h" 21 21 22 // Don't change following order of parameters 23 ATTRIBUTE_ALIGNED16(struct) PfxConstraintRow { 24 btScalar mNormal[3]; 25 btScalar mRhs; 26 btScalar mJacDiagInv; 27 btScalar mLowerLimit; 28 btScalar mUpperLimit; 29 btScalar mAccumImpulse; 30 }; 22 31 23 32 … … 35 44 m_appliedImpulseLateral1(0.f), 36 45 m_appliedImpulseLateral2(0.f), 46 m_contactMotion1(0.f), 47 m_contactMotion2(0.f), 48 m_contactCFM1(0.f), 49 m_contactCFM2(0.f), 37 50 m_lifeTime(0) 38 51 { … … 53 66 m_appliedImpulseLateral1(0.f), 54 67 m_appliedImpulseLateral2(0.f), 68 m_contactMotion1(0.f), 69 m_contactMotion2(0.f), 70 m_contactCFM1(0.f), 71 m_contactCFM2(0.f), 55 72 m_lifeTime(0) 56 73 { 57 58 74 mConstraintRow[0].mAccumImpulse = 0.f; 75 mConstraintRow[1].mAccumImpulse = 0.f; 76 mConstraintRow[2].mAccumImpulse = 0.f; 59 77 } 60 78 … … 84 102 btScalar m_appliedImpulseLateral1; 85 103 btScalar m_appliedImpulseLateral2; 104 btScalar m_contactMotion1; 105 btScalar m_contactMotion2; 106 btScalar m_contactCFM1; 107 btScalar m_contactCFM2; 108 86 109 int m_lifeTime;//lifetime of the contactpoint in frames 87 110 88 111 btVector3 m_lateralFrictionDir1; 89 112 btVector3 m_lateralFrictionDir2; 113 114 115 116 PfxConstraintRow mConstraintRow[3]; 117 90 118 91 119 btScalar getDistance() const -
code/branches/kicklib/src/external/bullet/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp
r5781 r7983 21 21 22 22 #define NUM_UNITSPHERE_POINTS 42 23 static btVector3 sPenetrationDirections[NUM_UNITSPHERE_POINTS+MAX_PREFERRED_PENETRATION_DIRECTIONS*2] =24 {25 btVector3(btScalar(0.000000) , btScalar(-0.000000),btScalar(-1.000000)),26 btVector3(btScalar(0.723608) , btScalar(-0.525725),btScalar(-0.447219)),27 btVector3(btScalar(-0.276388) , btScalar(-0.850649),btScalar(-0.447219)),28 btVector3(btScalar(-0.894426) , btScalar(-0.000000),btScalar(-0.447216)),29 btVector3(btScalar(-0.276388) , btScalar(0.850649),btScalar(-0.447220)),30 btVector3(btScalar(0.723608) , btScalar(0.525725),btScalar(-0.447219)),31 btVector3(btScalar(0.276388) , btScalar(-0.850649),btScalar(0.447220)),32 btVector3(btScalar(-0.723608) , btScalar(-0.525725),btScalar(0.447219)),33 btVector3(btScalar(-0.723608) , btScalar(0.525725),btScalar(0.447219)),34 btVector3(btScalar(0.276388) , btScalar(0.850649),btScalar(0.447219)),35 btVector3(btScalar(0.894426) , btScalar(0.000000),btScalar(0.447216)),36 btVector3(btScalar(-0.000000) , btScalar(0.000000),btScalar(1.000000)),37 btVector3(btScalar(0.425323) , btScalar(-0.309011),btScalar(-0.850654)),38 btVector3(btScalar(-0.162456) , btScalar(-0.499995),btScalar(-0.850654)),39 btVector3(btScalar(0.262869) , btScalar(-0.809012),btScalar(-0.525738)),40 btVector3(btScalar(0.425323) , btScalar(0.309011),btScalar(-0.850654)),41 btVector3(btScalar(0.850648) , btScalar(-0.000000),btScalar(-0.525736)),42 btVector3(btScalar(-0.525730) , btScalar(-0.000000),btScalar(-0.850652)),43 btVector3(btScalar(-0.688190) , btScalar(-0.499997),btScalar(-0.525736)),44 btVector3(btScalar(-0.162456) , btScalar(0.499995),btScalar(-0.850654)),45 btVector3(btScalar(-0.688190) , btScalar(0.499997),btScalar(-0.525736)),46 btVector3(btScalar(0.262869) , btScalar(0.809012),btScalar(-0.525738)),47 btVector3(btScalar(0.951058) , btScalar(0.309013),btScalar(0.000000)),48 btVector3(btScalar(0.951058) , btScalar(-0.309013),btScalar(0.000000)),49 btVector3(btScalar(0.587786) , btScalar(-0.809017),btScalar(0.000000)),50 btVector3(btScalar(0.000000) , btScalar(-1.000000),btScalar(0.000000)),51 btVector3(btScalar(-0.587786) , btScalar(-0.809017),btScalar(0.000000)),52 btVector3(btScalar(-0.951058) , btScalar(-0.309013),btScalar(-0.000000)),53 btVector3(btScalar(-0.951058) , btScalar(0.309013),btScalar(-0.000000)),54 btVector3(btScalar(-0.587786) , btScalar(0.809017),btScalar(-0.000000)),55 btVector3(btScalar(-0.000000) , btScalar(1.000000),btScalar(-0.000000)),56 btVector3(btScalar(0.587786) , btScalar(0.809017),btScalar(-0.000000)),57 btVector3(btScalar(0.688190) , btScalar(-0.499997),btScalar(0.525736)),58 btVector3(btScalar(-0.262869) , btScalar(-0.809012),btScalar(0.525738)),59 btVector3(btScalar(-0.850648) , btScalar(0.000000),btScalar(0.525736)),60 btVector3(btScalar(-0.262869) , btScalar(0.809012),btScalar(0.525738)),61 btVector3(btScalar(0.688190) , btScalar(0.499997),btScalar(0.525736)),62 btVector3(btScalar(0.525730) , btScalar(0.000000),btScalar(0.850652)),63 btVector3(btScalar(0.162456) , btScalar(-0.499995),btScalar(0.850654)),64 btVector3(btScalar(-0.425323) , btScalar(-0.309011),btScalar(0.850654)),65 btVector3(btScalar(-0.425323) , btScalar(0.309011),btScalar(0.850654)),66 btVector3(btScalar(0.162456) , btScalar(0.499995),btScalar(0.850654))67 };68 23 69 24 … … 79 34 (void)v; 80 35 36 bool check2d= convexA->isConvex2d() && convexB->isConvex2d(); 81 37 82 38 struct btIntermediateResult : public btDiscreteCollisionDetectorInterface::Result … … 92 48 bool m_hasResult; 93 49 94 virtual void setShapeIdentifiers (int partId0,int index0, int partId1,int index1)50 virtual void setShapeIdentifiersA(int partId0,int index0) 95 51 { 96 52 (void)partId0; 97 53 (void)index0; 54 } 55 virtual void setShapeIdentifiersB(int partId1,int index1) 56 { 98 57 (void)partId1; 99 58 (void)index1; … … 109 68 110 69 //just take fixed number of orientation, and sample the penetration depth in that direction 111 btScalar minProj = btScalar( 1e30);70 btScalar minProj = btScalar(BT_LARGE_FLOAT); 112 71 btVector3 minNorm(btScalar(0.), btScalar(0.), btScalar(0.)); 113 72 btVector3 minA,minB; … … 130 89 for (i=0;i<numSampleDirections;i++) 131 90 { 132 const btVector3& norm = sPenetrationDirections[i];91 btVector3 norm = getPenetrationDirections()[i]; 133 92 seperatingAxisInABatch[i] = (-norm) * transA.getBasis() ; 134 93 seperatingAxisInBBatch[i] = norm * transB.getBasis() ; … … 144 103 convexA->getPreferredPenetrationDirection(i,norm); 145 104 norm = transA.getBasis() * norm; 146 sPenetrationDirections[numSampleDirections] = norm;105 getPenetrationDirections()[numSampleDirections] = norm; 147 106 seperatingAxisInABatch[numSampleDirections] = (-norm) * transA.getBasis(); 148 107 seperatingAxisInBBatch[numSampleDirections] = norm * transB.getBasis(); … … 161 120 convexB->getPreferredPenetrationDirection(i,norm); 162 121 norm = transB.getBasis() * norm; 163 sPenetrationDirections[numSampleDirections] = norm;122 getPenetrationDirections()[numSampleDirections] = norm; 164 123 seperatingAxisInABatch[numSampleDirections] = (-norm) * transA.getBasis(); 165 124 seperatingAxisInBBatch[numSampleDirections] = norm * transB.getBasis(); … … 171 130 172 131 132 173 133 convexA->batchedUnitVectorGetSupportingVertexWithoutMargin(seperatingAxisInABatch,supportVerticesABatch,numSampleDirections); 174 134 convexB->batchedUnitVectorGetSupportingVertexWithoutMargin(seperatingAxisInBBatch,supportVerticesBBatch,numSampleDirections); … … 176 136 for (i=0;i<numSampleDirections;i++) 177 137 { 178 const btVector3& norm = sPenetrationDirections[i]; 179 seperatingAxisInA = seperatingAxisInABatch[i]; 180 seperatingAxisInB = seperatingAxisInBBatch[i]; 181 182 pInA = supportVerticesABatch[i]; 183 qInB = supportVerticesBBatch[i]; 184 185 pWorld = transA(pInA); 186 qWorld = transB(qInB); 187 w = qWorld - pWorld; 188 btScalar delta = norm.dot(w); 189 //find smallest delta 190 if (delta < minProj) 191 { 192 minProj = delta; 193 minNorm = norm; 194 minA = pWorld; 195 minB = qWorld; 138 btVector3 norm = getPenetrationDirections()[i]; 139 if (check2d) 140 { 141 norm[2] = 0.f; 142 } 143 if (norm.length2()>0.01) 144 { 145 146 seperatingAxisInA = seperatingAxisInABatch[i]; 147 seperatingAxisInB = seperatingAxisInBBatch[i]; 148 149 pInA = supportVerticesABatch[i]; 150 qInB = supportVerticesBBatch[i]; 151 152 pWorld = transA(pInA); 153 qWorld = transB(qInB); 154 if (check2d) 155 { 156 pWorld[2] = 0.f; 157 qWorld[2] = 0.f; 158 } 159 160 w = qWorld - pWorld; 161 btScalar delta = norm.dot(w); 162 //find smallest delta 163 if (delta < minProj) 164 { 165 minProj = delta; 166 minNorm = norm; 167 minA = pWorld; 168 minB = qWorld; 169 } 196 170 } 197 171 } … … 210 184 convexA->getPreferredPenetrationDirection(i,norm); 211 185 norm = transA.getBasis() * norm; 212 sPenetrationDirections[numSampleDirections] = norm;186 getPenetrationDirections()[numSampleDirections] = norm; 213 187 numSampleDirections++; 214 188 } … … 225 199 convexB->getPreferredPenetrationDirection(i,norm); 226 200 norm = transB.getBasis() * norm; 227 sPenetrationDirections[numSampleDirections] = norm;201 getPenetrationDirections()[numSampleDirections] = norm; 228 202 numSampleDirections++; 229 203 } … … 234 208 for (int i=0;i<numSampleDirections;i++) 235 209 { 236 const btVector3& norm = sPenetrationDirections[i];210 const btVector3& norm = getPenetrationDirections()[i]; 237 211 seperatingAxisInA = (-norm)* transA.getBasis(); 238 212 seperatingAxisInB = norm* transB.getBasis(); … … 262 236 return false; 263 237 264 minProj += (convexA->getMarginNonVirtual() + convexB->getMarginNonVirtual()); 238 btScalar extraSeparation = 0.5f;///scale dependent 239 minProj += extraSeparation+(convexA->getMarginNonVirtual() + convexB->getMarginNonVirtual()); 265 240 266 241 … … 300 275 input.m_transformA = displacedTrans; 301 276 input.m_transformB = transB; 302 input.m_maximumDistanceSquared = btScalar( 1e30);//minProj;277 input.m_maximumDistanceSquared = btScalar(BT_LARGE_FLOAT);//minProj; 303 278 304 279 btIntermediateResult res; 280 gjkdet.setCachedSeperatingAxis(-minNorm); 305 281 gjkdet.getClosestPoints(input,res,debugDraw); 306 282 … … 311 287 btScalar penetration_relaxation= btScalar(1.); 312 288 minNorm*=penetration_relaxation; 289 313 290 314 291 if (res.m_hasResult) … … 317 294 pa = res.m_pointInWorld - minNorm * correctedMinNorm; 318 295 pb = res.m_pointInWorld; 296 v = minNorm; 319 297 320 298 #ifdef DEBUG_DRAW … … 331 309 } 332 310 333 334 311 btVector3* btMinkowskiPenetrationDepthSolver::getPenetrationDirections() 312 { 313 static btVector3 sPenetrationDirections[NUM_UNITSPHERE_POINTS+MAX_PREFERRED_PENETRATION_DIRECTIONS*2] = 314 { 315 btVector3(btScalar(0.000000) , btScalar(-0.000000),btScalar(-1.000000)), 316 btVector3(btScalar(0.723608) , btScalar(-0.525725),btScalar(-0.447219)), 317 btVector3(btScalar(-0.276388) , btScalar(-0.850649),btScalar(-0.447219)), 318 btVector3(btScalar(-0.894426) , btScalar(-0.000000),btScalar(-0.447216)), 319 btVector3(btScalar(-0.276388) , btScalar(0.850649),btScalar(-0.447220)), 320 btVector3(btScalar(0.723608) , btScalar(0.525725),btScalar(-0.447219)), 321 btVector3(btScalar(0.276388) , btScalar(-0.850649),btScalar(0.447220)), 322 btVector3(btScalar(-0.723608) , btScalar(-0.525725),btScalar(0.447219)), 323 btVector3(btScalar(-0.723608) , btScalar(0.525725),btScalar(0.447219)), 324 btVector3(btScalar(0.276388) , btScalar(0.850649),btScalar(0.447219)), 325 btVector3(btScalar(0.894426) , btScalar(0.000000),btScalar(0.447216)), 326 btVector3(btScalar(-0.000000) , btScalar(0.000000),btScalar(1.000000)), 327 btVector3(btScalar(0.425323) , btScalar(-0.309011),btScalar(-0.850654)), 328 btVector3(btScalar(-0.162456) , btScalar(-0.499995),btScalar(-0.850654)), 329 btVector3(btScalar(0.262869) , btScalar(-0.809012),btScalar(-0.525738)), 330 btVector3(btScalar(0.425323) , btScalar(0.309011),btScalar(-0.850654)), 331 btVector3(btScalar(0.850648) , btScalar(-0.000000),btScalar(-0.525736)), 332 btVector3(btScalar(-0.525730) , btScalar(-0.000000),btScalar(-0.850652)), 333 btVector3(btScalar(-0.688190) , btScalar(-0.499997),btScalar(-0.525736)), 334 btVector3(btScalar(-0.162456) , btScalar(0.499995),btScalar(-0.850654)), 335 btVector3(btScalar(-0.688190) , btScalar(0.499997),btScalar(-0.525736)), 336 btVector3(btScalar(0.262869) , btScalar(0.809012),btScalar(-0.525738)), 337 btVector3(btScalar(0.951058) , btScalar(0.309013),btScalar(0.000000)), 338 btVector3(btScalar(0.951058) , btScalar(-0.309013),btScalar(0.000000)), 339 btVector3(btScalar(0.587786) , btScalar(-0.809017),btScalar(0.000000)), 340 btVector3(btScalar(0.000000) , btScalar(-1.000000),btScalar(0.000000)), 341 btVector3(btScalar(-0.587786) , btScalar(-0.809017),btScalar(0.000000)), 342 btVector3(btScalar(-0.951058) , btScalar(-0.309013),btScalar(-0.000000)), 343 btVector3(btScalar(-0.951058) , btScalar(0.309013),btScalar(-0.000000)), 344 btVector3(btScalar(-0.587786) , btScalar(0.809017),btScalar(-0.000000)), 345 btVector3(btScalar(-0.000000) , btScalar(1.000000),btScalar(-0.000000)), 346 btVector3(btScalar(0.587786) , btScalar(0.809017),btScalar(-0.000000)), 347 btVector3(btScalar(0.688190) , btScalar(-0.499997),btScalar(0.525736)), 348 btVector3(btScalar(-0.262869) , btScalar(-0.809012),btScalar(0.525738)), 349 btVector3(btScalar(-0.850648) , btScalar(0.000000),btScalar(0.525736)), 350 btVector3(btScalar(-0.262869) , btScalar(0.809012),btScalar(0.525738)), 351 btVector3(btScalar(0.688190) , btScalar(0.499997),btScalar(0.525736)), 352 btVector3(btScalar(0.525730) , btScalar(0.000000),btScalar(0.850652)), 353 btVector3(btScalar(0.162456) , btScalar(-0.499995),btScalar(0.850654)), 354 btVector3(btScalar(-0.425323) , btScalar(-0.309011),btScalar(0.850654)), 355 btVector3(btScalar(-0.425323) , btScalar(0.309011),btScalar(0.850654)), 356 btVector3(btScalar(0.162456) , btScalar(0.499995),btScalar(0.850654)) 357 }; 358 359 return sPenetrationDirections; 360 } 361 362 -
code/branches/kicklib/src/external/bullet/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h
r5781 r7983 23 23 class btMinkowskiPenetrationDepthSolver : public btConvexPenetrationDepthSolver 24 24 { 25 protected: 26 27 static btVector3* getPenetrationDirections(); 28 25 29 public: 26 30 -
code/branches/kicklib/src/external/bullet/BulletCollision/NarrowPhaseCollision/btPersistentManifold.cpp
r5781 r7983 26 26 27 27 btPersistentManifold::btPersistentManifold() 28 :m_body0(0), 28 :btTypedObject(BT_PERSISTENT_MANIFOLD_TYPE), 29 m_body0(0), 29 30 m_body1(0), 30 31 m_cachedPoints (0), -
code/branches/kicklib/src/external/bullet/BulletCollision/NarrowPhaseCollision/btPersistentManifold.h
r5781 r7983 31 31 typedef bool (*ContactProcessedCallback)(btManifoldPoint& cp,void* body0,void* body1); 32 32 extern ContactDestroyedCallback gContactDestroyedCallback; 33 34 35 33 extern ContactProcessedCallback gContactProcessedCallback; 34 35 36 enum btContactManifoldTypes 37 { 38 BT_PERSISTENT_MANIFOLD_TYPE = 1, 39 MAX_CONTACT_MANIFOLD_TYPE 40 }; 36 41 37 42 #define MANIFOLD_CACHE_SIZE 4 … … 44 49 ///the contact point with deepest penetration is always kept, and it tries to maximuze the area covered by the points 45 50 ///note that some pairs of objects might have more then one contact manifold. 46 ATTRIBUTE_ALIGNED16( class) btPersistentManifold 51 52 53 ATTRIBUTE_ALIGNED128( class) btPersistentManifold : public btTypedObject 54 //ATTRIBUTE_ALIGNED16( class) btPersistentManifold : public btTypedObject 47 55 { 48 56 … … 53 61 void* m_body0; 54 62 void* m_body1; 63 55 64 int m_cachedPoints; 56 65 … … 68 77 BT_DECLARE_ALIGNED_ALLOCATOR(); 69 78 79 int m_companionIdA; 80 int m_companionIdB; 81 70 82 int m_index1a; 71 83 … … 73 85 74 86 btPersistentManifold(void* body0,void* body1,int , btScalar contactBreakingThreshold,btScalar contactProcessingThreshold) 75 : m_body0(body0),m_body1(body1),m_cachedPoints(0), 87 : btTypedObject(BT_PERSISTENT_MANIFOLD_TYPE), 88 m_body0(body0),m_body1(body1),m_cachedPoints(0), 76 89 m_contactBreakingThreshold(contactBreakingThreshold), 77 90 m_contactProcessingThreshold(contactProcessingThreshold) 78 91 { 79 80 92 } 81 93 … … 135 147 //get rid of duplicated userPersistentData pointer 136 148 m_pointCache[lastUsedIndex].m_userPersistentData = 0; 149 m_pointCache[lastUsedIndex].mConstraintRow[0].mAccumImpulse = 0.f; 150 m_pointCache[lastUsedIndex].mConstraintRow[1].mAccumImpulse = 0.f; 151 m_pointCache[lastUsedIndex].mConstraintRow[2].mAccumImpulse = 0.f; 152 137 153 m_pointCache[lastUsedIndex].m_appliedImpulse = 0.f; 138 154 m_pointCache[lastUsedIndex].m_lateralFrictionInitialized = false; … … 152 168 #ifdef MAINTAIN_PERSISTENCY 153 169 int lifeTime = m_pointCache[insertIndex].getLifeTime(); 154 btScalar appliedImpulse = m_pointCache[insertIndex].m_appliedImpulse; 155 btScalar appliedLateralImpulse1 = m_pointCache[insertIndex].m_appliedImpulseLateral1; 156 btScalar appliedLateralImpulse2 = m_pointCache[insertIndex].m_appliedImpulseLateral2; 157 170 btScalar appliedImpulse = m_pointCache[insertIndex].mConstraintRow[0].mAccumImpulse; 171 btScalar appliedLateralImpulse1 = m_pointCache[insertIndex].mConstraintRow[1].mAccumImpulse; 172 btScalar appliedLateralImpulse2 = m_pointCache[insertIndex].mConstraintRow[2].mAccumImpulse; 173 // bool isLateralFrictionInitialized = m_pointCache[insertIndex].m_lateralFrictionInitialized; 174 175 176 158 177 btAssert(lifeTime>=0); 159 178 void* cache = m_pointCache[insertIndex].m_userPersistentData; … … 166 185 m_pointCache[insertIndex].m_appliedImpulseLateral2 = appliedLateralImpulse2; 167 186 187 m_pointCache[insertIndex].mConstraintRow[0].mAccumImpulse = appliedImpulse; 188 m_pointCache[insertIndex].mConstraintRow[1].mAccumImpulse = appliedLateralImpulse1; 189 m_pointCache[insertIndex].mConstraintRow[2].mAccumImpulse = appliedLateralImpulse2; 190 191 168 192 m_pointCache[insertIndex].m_lifeTime = lifeTime; 169 193 #else -
code/branches/kicklib/src/external/bullet/BulletCollision/NarrowPhaseCollision/btPointCollector.h
r5781 r7983 32 32 33 33 btPointCollector () 34 : m_distance(btScalar( 1e30)),m_hasResult(false)34 : m_distance(btScalar(BT_LARGE_FLOAT)),m_hasResult(false) 35 35 { 36 36 } 37 37 38 virtual void setShapeIdentifiers (int partId0,int index0, int partId1,int index1)38 virtual void setShapeIdentifiersA(int partId0,int index0) 39 39 { 40 40 (void)partId0; 41 41 (void)index0; 42 43 } 44 virtual void setShapeIdentifiersB(int partId1,int index1) 45 { 42 46 (void)partId1; 43 47 (void)index1; 44 //??45 48 } 46 49 -
code/branches/kicklib/src/external/bullet/BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.cpp
r5781 r7983 115 115 } 116 116 } 117 m_simplexSolver->addVertex( w, supVertexA , supVertexB); 117 ///Just like regular GJK only add the vertex if it isn't already (close) to current vertex, it would lead to divisions by zero and NaN etc. 118 if (!m_simplexSolver->inSimplex(w)) 119 m_simplexSolver->addVertex( w, supVertexA , supVertexB); 120 118 121 if (m_simplexSolver->closest(v)) 119 122 { -
code/branches/kicklib/src/external/bullet/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.cpp
r5781 r7983 69 69 m_numVertices = 0; 70 70 m_needsUpdate = true; 71 m_lastW = btVector3(btScalar( 1e30),btScalar(1e30),btScalar(1e30));71 m_lastW = btVector3(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT)); 72 72 m_cachedBC.reset(); 73 73 } … … 290 290 for (i=0;i<numverts;i++) 291 291 { 292 #ifdef BT_USE_EQUAL_VERTEX_THRESHOLD 293 if ( m_simplexVectorW[i].distance2(w) <= m_equalVertexThreshold) 294 #else 292 295 if (m_simplexVectorW[i] == w) 296 #endif 293 297 found = true; 294 298 } -
code/branches/kicklib/src/external/bullet/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h
r5781 r7983 24 24 25 25 #define VORONOI_SIMPLEX_MAX_VERTS 5 26 27 ///disable next define, or use defaultCollisionConfiguration->getSimplexSolver()->setEqualVertexThreshold(0.f) to disable/configure 28 #define BT_USE_EQUAL_VERTEX_THRESHOLD 29 #define VORONOI_DEFAULT_EQUAL_VERTEX_THRESHOLD 0.0001f 30 26 31 27 32 struct btUsageBitfield{ … … 107 112 btVector3 m_cachedV; 108 113 btVector3 m_lastW; 114 115 btScalar m_equalVertexThreshold; 109 116 bool m_cachedValidClosest; 117 110 118 111 119 btSubSimplexClosestResult m_cachedBC; … … 123 131 public: 124 132 133 btVoronoiSimplexSolver() 134 : m_equalVertexThreshold(VORONOI_DEFAULT_EQUAL_VERTEX_THRESHOLD) 135 { 136 } 125 137 void reset(); 126 138 127 139 void addVertex(const btVector3& w, const btVector3& p, const btVector3& q); 128 140 141 void setEqualVertexThreshold(btScalar threshold) 142 { 143 m_equalVertexThreshold = threshold; 144 } 145 146 btScalar getEqualVertexThreshold() const 147 { 148 return m_equalVertexThreshold; 149 } 129 150 130 151 bool closest(btVector3& v);
Note: See TracChangeset
for help on using the changeset viewer.