Changeset 8284 for code/branches/kicklib2/src/external/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpa2.cpp
- Timestamp:
- Apr 21, 2011, 6:58:23 PM (14 years ago)
- Location:
- code/branches/kicklib2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/kicklib2
- Property svn:mergeinfo changed
-
code/branches/kicklib2/src/external/bullet/BulletCollision/NarrowPhaseCollision/btGjkEpa2.cpp
r5781 r8284 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 */
Note: See TracChangeset
for help on using the changeset viewer.