Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 8, 2009, 12:58:47 AM (16 years ago)
Author:
dafrick
Message:

Reverted to revision 2906 (because I'm too stupid to merge correctly, 2nd try will follow shortly. ;))

Location:
code/branches/questsystem5
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/questsystem5

  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.cpp

    r2907 r2908  
    55This software is provided 'as-is', without any express or implied warranty.
    66In no event will the authors be held liable for any damages arising from the use of this software.
    7 Permission is granted to anyone to use this software for any purpose,
    8 including commercial applications, and to alter it and redistribute it freely,
     7Permission is granted to anyone to use this software for any purpose, 
     8including commercial applications, and to alter it and redistribute it freely, 
    99subject to the following restrictions:
    1010
     
    2323//#include <stdio.h>
    2424
    25 btConvexPlaneCollisionAlgorithm::btConvexPlaneCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped, int numPerturbationIterations,int minimumPointsPerturbationThreshold)
     25btConvexPlaneCollisionAlgorithm::btConvexPlaneCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped)
    2626: btCollisionAlgorithm(ci),
    2727m_ownManifold(false),
    2828m_manifoldPtr(mf),
    29 m_isSwapped(isSwapped),
    30 m_numPerturbationIterations(numPerturbationIterations),
    31 m_minimumPointsPerturbationThreshold(minimumPointsPerturbationThreshold)
     29m_isSwapped(isSwapped)
    3230{
    3331        btCollisionObject* convexObj = m_isSwapped? col1 : col0;
    3432        btCollisionObject* planeObj = m_isSwapped? col0 : col1;
    35 
     33       
    3634        if (!m_manifoldPtr && m_dispatcher->needsCollision(convexObj,planeObj))
    3735        {
     
    5149}
    5250
    53 void btConvexPlaneCollisionAlgorithm::collideSingleContact (const btQuaternion& perturbeRot, btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
     51
     52
     53void btConvexPlaneCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
    5454{
    55     btCollisionObject* convexObj = m_isSwapped? body1 : body0;
     55        (void)dispatchInfo;
     56        (void)resultOut;
     57        if (!m_manifoldPtr)
     58                return;
     59
     60        btCollisionObject* convexObj = m_isSwapped? body1 : body0;
    5661        btCollisionObject* planeObj = m_isSwapped? body0: body1;
    5762
     
    5964        btStaticPlaneShape* planeShape = (btStaticPlaneShape*) planeObj->getCollisionShape();
    6065
    61     bool hasCollision = false;
     66        bool hasCollision = false;
    6267        const btVector3& planeNormal = planeShape->getPlaneNormal();
    6368        const btScalar& planeConstant = planeShape->getPlaneConstant();
    64        
    65         btTransform convexWorldTransform = convexObj->getWorldTransform();
     69        btTransform planeInConvex;
     70        planeInConvex= convexObj->getWorldTransform().inverse() * planeObj->getWorldTransform();
    6671        btTransform convexInPlaneTrans;
    67         convexInPlaneTrans= planeObj->getWorldTransform().inverse() * convexWorldTransform;
    68         //now perturbe the convex-world transform
    69         convexWorldTransform.getBasis()*=btMatrix3x3(perturbeRot);
    70         btTransform planeInConvex;
    71         planeInConvex= convexWorldTransform.inverse() * planeObj->getWorldTransform();
    72        
     72        convexInPlaneTrans= planeObj->getWorldTransform().inverse() * convexObj->getWorldTransform();
     73
    7374        btVector3 vtx = convexShape->localGetSupportingVertex(planeInConvex.getBasis()*-planeNormal);
    74 
    7575        btVector3 vtxInPlane = convexInPlaneTrans(vtx);
    7676        btScalar distance = (planeNormal.dot(vtxInPlane) - planeConstant);
     
    8888                resultOut->addContactPoint(normalOnSurfaceB,pOnB,distance);
    8989        }
    90 }
    91 
    92 
    93 void btConvexPlaneCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
    94 {
    95         (void)dispatchInfo;
    96         if (!m_manifoldPtr)
    97                 return;
    98 
    99     btCollisionObject* convexObj = m_isSwapped? body1 : body0;
    100         btCollisionObject* planeObj = m_isSwapped? body0: body1;
    101 
    102         btConvexShape* convexShape = (btConvexShape*) convexObj->getCollisionShape();
    103         btStaticPlaneShape* planeShape = (btStaticPlaneShape*) planeObj->getCollisionShape();
    104 
    105     bool hasCollision = false;
    106         const btVector3& planeNormal = planeShape->getPlaneNormal();
    107         const btScalar& planeConstant = planeShape->getPlaneConstant();
    108 
    109         //first perform a collision query with the non-perturbated collision objects
    110         {
    111                 btQuaternion rotq(0,0,0,1);
    112                 collideSingleContact(rotq,body0,body1,dispatchInfo,resultOut);
    113         }
    114 
    115         if (resultOut->getPersistentManifold()->getNumContacts()<m_minimumPointsPerturbationThreshold)
    116         {
    117                 btVector3 v0,v1;
    118                 btPlaneSpace1(planeNormal,v0,v1);
    119                 //now perform 'm_numPerturbationIterations' collision queries with the perturbated collision objects
    120 
    121                 const btScalar angleLimit = 0.125f * SIMD_PI;
    122                 btScalar perturbeAngle;
    123                 btScalar radius = convexShape->getAngularMotionDisc();
    124                 perturbeAngle = gContactBreakingThreshold / radius;
    125                 if ( perturbeAngle > angleLimit )
    126                                 perturbeAngle = angleLimit;
    127 
    128                 btQuaternion perturbeRot(v0,perturbeAngle);
    129                 for (int i=0;i<m_numPerturbationIterations;i++)
    130                 {
    131                         btScalar iterationAngle = i*(SIMD_2_PI/btScalar(m_numPerturbationIterations));
    132                         btQuaternion rotq(planeNormal,iterationAngle);
    133                         collideSingleContact(rotq.inverse()*perturbeRot*rotq,body0,body1,dispatchInfo,resultOut);
    134                 }
    135         }
    136 
    13790        if (m_ownManifold)
    13891        {
Note: See TracChangeset for help on using the changeset viewer.