Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 27, 2011, 7:43:24 AM (14 years ago)
Author:
rgrieder
Message:

Updated Bullet Physics Engine from v2.74 to v2.77

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/kicklib/src/external/bullet/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp

    r5781 r7983  
    2121
    2222#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 };
    6823
    6924
     
    7934        (void)v;
    8035       
     36        bool check2d= convexA->isConvex2d() && convexB->isConvex2d();
    8137
    8238        struct btIntermediateResult : public btDiscreteCollisionDetectorInterface::Result
     
    9248                bool    m_hasResult;
    9349
    94                 virtual void setShapeIdentifiers(int partId0,int index0,        int partId1,int index1)
     50                virtual void setShapeIdentifiersA(int partId0,int index0)
    9551                {
    9652                        (void)partId0;
    9753                        (void)index0;
     54                }
     55                virtual void setShapeIdentifiersB(int partId1,int index1)
     56                {
    9857                        (void)partId1;
    9958                        (void)index1;
     
    10968
    11069        //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);
    11271        btVector3 minNorm(btScalar(0.), btScalar(0.), btScalar(0.));
    11372        btVector3 minA,minB;
     
    13089        for (i=0;i<numSampleDirections;i++)
    13190        {
    132                 const btVector3& norm = sPenetrationDirections[i];
     91                btVector3 norm = getPenetrationDirections()[i];
    13392                seperatingAxisInABatch[i] =  (-norm) * transA.getBasis() ;
    13493                seperatingAxisInBBatch[i] =  norm   * transB.getBasis() ;
     
    144103                                convexA->getPreferredPenetrationDirection(i,norm);
    145104                                norm  = transA.getBasis() * norm;
    146                                 sPenetrationDirections[numSampleDirections] = norm;
     105                                getPenetrationDirections()[numSampleDirections] = norm;
    147106                                seperatingAxisInABatch[numSampleDirections] = (-norm) * transA.getBasis();
    148107                                seperatingAxisInBBatch[numSampleDirections] = norm * transB.getBasis();
     
    161120                                convexB->getPreferredPenetrationDirection(i,norm);
    162121                                norm  = transB.getBasis() * norm;
    163                                 sPenetrationDirections[numSampleDirections] = norm;
     122                                getPenetrationDirections()[numSampleDirections] = norm;
    164123                                seperatingAxisInABatch[numSampleDirections] = (-norm) * transA.getBasis();
    165124                                seperatingAxisInBBatch[numSampleDirections] = norm * transB.getBasis();
     
    171130
    172131
     132
    173133        convexA->batchedUnitVectorGetSupportingVertexWithoutMargin(seperatingAxisInABatch,supportVerticesABatch,numSampleDirections);
    174134        convexB->batchedUnitVectorGetSupportingVertexWithoutMargin(seperatingAxisInBBatch,supportVerticesBBatch,numSampleDirections);
     
    176136        for (i=0;i<numSampleDirections;i++)
    177137        {
    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                        }
    196170                }
    197171        }       
     
    210184                                convexA->getPreferredPenetrationDirection(i,norm);
    211185                                norm  = transA.getBasis() * norm;
    212                                 sPenetrationDirections[numSampleDirections] = norm;
     186                                getPenetrationDirections()[numSampleDirections] = norm;
    213187                                numSampleDirections++;
    214188                        }
     
    225199                                convexB->getPreferredPenetrationDirection(i,norm);
    226200                                norm  = transB.getBasis() * norm;
    227                                 sPenetrationDirections[numSampleDirections] = norm;
     201                                getPenetrationDirections()[numSampleDirections] = norm;
    228202                                numSampleDirections++;
    229203                        }
     
    234208        for (int i=0;i<numSampleDirections;i++)
    235209        {
    236                 const btVector3& norm = sPenetrationDirections[i];
     210                const btVector3& norm = getPenetrationDirections()[i];
    237211                seperatingAxisInA = (-norm)* transA.getBasis();
    238212                seperatingAxisInB = norm* transB.getBasis();
     
    262236                return false;
    263237
    264         minProj += (convexA->getMarginNonVirtual() + convexB->getMarginNonVirtual());
     238        btScalar extraSeparation = 0.5f;///scale dependent
     239        minProj += extraSeparation+(convexA->getMarginNonVirtual() + convexB->getMarginNonVirtual());
    265240
    266241
     
    300275        input.m_transformA = displacedTrans;
    301276        input.m_transformB = transB;
    302         input.m_maximumDistanceSquared = btScalar(1e30);//minProj;
     277        input.m_maximumDistanceSquared = btScalar(BT_LARGE_FLOAT);//minProj;
    303278       
    304279        btIntermediateResult res;
     280        gjkdet.setCachedSeperatingAxis(-minNorm);
    305281        gjkdet.getClosestPoints(input,res,debugDraw);
    306282
     
    311287        btScalar penetration_relaxation= btScalar(1.);
    312288        minNorm*=penetration_relaxation;
     289       
    313290
    314291        if (res.m_hasResult)
     
    317294                pa = res.m_pointInWorld - minNorm * correctedMinNorm;
    318295                pb = res.m_pointInWorld;
     296                v = minNorm;
    319297               
    320298#ifdef DEBUG_DRAW
     
    331309}
    332310
    333 
    334 
     311btVector3*      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
Note: See TracChangeset for help on using the changeset viewer.