Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 13, 2008, 11:45:51 PM (16 years ago)
Author:
rgrieder
Message:

Updated to Bullet 2.73 (first part).

Location:
code/branches/physics/src/bullet/BulletCollision/CollisionDispatch
Files:
4 added
28 edited

Legend:

Unmodified
Added
Removed
  • code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/SphereTriangleDetector.cpp

    r2192 r2430  
    2020
    2121
    22 SphereTriangleDetector::SphereTriangleDetector(btSphereShape* sphere,btTriangleShape* triangle)
     22SphereTriangleDetector::SphereTriangleDetector(btSphereShape* sphere,btTriangleShape* triangle,btScalar contactBreakingThreshold)
    2323:m_sphere(sphere),
    24 m_triangle(triangle)
     24m_triangle(triangle),
     25m_contactBreakingThreshold(contactBreakingThreshold)
    2526{
    2627
     
    4142        btTransform     sphereInTr = transformB.inverseTimes(transformA);
    4243
    43         if (collide(sphereInTr.getOrigin(),point,normal,depth,timeOfImpact))
     44        if (collide(sphereInTr.getOrigin(),point,normal,depth,timeOfImpact,m_contactBreakingThreshold))
    4445        {
    4546                if (swapResults)
     
    9495
    9596///combined discrete/continuous sphere-triangle
    96 bool SphereTriangleDetector::collide(const btVector3& sphereCenter,btVector3 &point, btVector3& resultNormal, btScalar& depth, btScalar &timeOfImpact)
     97bool SphereTriangleDetector::collide(const btVector3& sphereCenter,btVector3 &point, btVector3& resultNormal, btScalar& depth, btScalar &timeOfImpact, btScalar contactBreakingThreshold)
    9798{
    9899
     
    116117        }
    117118
    118         ///todo: move this gContactBreakingThreshold into a proper structure
    119         extern btScalar gContactBreakingThreshold;
    120 
    121         btScalar contactMargin = gContactBreakingThreshold;
     119        btScalar contactMargin = contactBreakingThreshold;
    122120        bool isInsideContactPlane = distanceFromPlane < r + contactMargin;
    123121        bool isInsideShellPlane = distanceFromPlane < r;
     
    141139                        for (int i = 0; i < m_triangle->getNumEdges(); i++) {
    142140                               
    143                                 btPoint3 pa;
    144                                 btPoint3 pb;
     141                                btVector3 pa;
     142                                btVector3 pb;
    145143                               
    146144                                m_triangle->getEdge(i,pa,pb);
  • code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/SphereTriangleDetector.h

    r2192 r2430  
    1818
    1919#include "BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h"
    20 #include "LinearMath/btPoint3.h"
     20
    2121
    2222
     
    3131        virtual void    getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw,bool swapResults=false);
    3232
    33         SphereTriangleDetector(btSphereShape* sphere,btTriangleShape* triangle);
     33        SphereTriangleDetector(btSphereShape* sphere,btTriangleShape* triangle, btScalar contactBreakingThreshold);
    3434
    3535        virtual ~SphereTriangleDetector() {};
     
    3737private:
    3838
    39         bool collide(const btVector3& sphereCenter,btVector3 &point, btVector3& resultNormal, btScalar& depth, btScalar &timeOfImpact);
     39        bool collide(const btVector3& sphereCenter,btVector3 &point, btVector3& resultNormal, btScalar& depth, btScalar &timeOfImpact, btScalar contactBreakingThreshold);
    4040        bool pointInTriangle(const btVector3 vertices[], const btVector3 &normal, btVector3 *p );
    4141        bool facecontains(const btVector3 &p,const btVector3* vertices,btVector3& normal);
     
    4343        btSphereShape* m_sphere;
    4444        btTriangleShape* m_triangle;
    45 
     45        btScalar        m_contactBreakingThreshold;
    4646       
    4747};
  • code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.cpp

    r2192 r2430  
    2323
    2424btBoxBoxCollisionAlgorithm::btBoxBoxCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* obj0,btCollisionObject* obj1)
    25 : btCollisionAlgorithm(ci),
     25: btActivatingCollisionAlgorithm(ci,obj0,obj1),
    2626m_ownManifold(false),
    2727m_manifoldPtr(mf)
  • code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.h

    r2192 r2430  
    1717#define BOX_BOX__COLLISION_ALGORITHM_H
    1818
    19 #include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
     19#include "btActivatingCollisionAlgorithm.h"
    2020#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
    2121#include "BulletCollision/BroadphaseCollision/btDispatcher.h"
     
    2525
    2626///box-box collision detection
    27 class btBoxBoxCollisionAlgorithm : public btCollisionAlgorithm
     27class btBoxBoxCollisionAlgorithm : public btActivatingCollisionAlgorithm
    2828{
    2929        bool    m_ownManifold;
     
    3232public:
    3333        btBoxBoxCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci)
    34                 : btCollisionAlgorithm(ci) {}
     34                : btActivatingCollisionAlgorithm(ci) {}
    3535
    3636        virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
  • code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btBoxBoxDetector.cpp

    r2192 r2430  
    208208    }
    209209    q = p[n*2-2]*p[1] - p[0]*p[n*2-1];
    210     a = 1.f/(btScalar(3.0)*(a+q));
     210        if (btFabs(a+q) > SIMD_EPSILON)
     211        {
     212                a = 1.f/(btScalar(3.0)*(a+q));
     213        } else
     214        {
     215                a=1e30f;
     216        }
    211217    cx = a*(cx + q*(p[n*2-2]+p[0]));
    212218    cy = a*(cy + q*(p[n*2-1]+p[1]));
  • code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionConfiguration.h

    r2192 r2430  
    2323///btCollisionConfiguration allows to configure Bullet collision detection
    2424///stack allocator size, default collision algorithms and persistent manifold pool size
    25 ///todo: describe the meaning
     25///@todo: describe the meaning
    2626class   btCollisionConfiguration
    2727{
  • code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionCreateFunc.h

    r2192 r2430  
    1818
    1919#include "LinearMath/btAlignedObjectArray.h"
    20 typedef btAlignedObjectArray<class btCollisionObject*> btCollisionObjectArray;
    2120class btCollisionAlgorithm;
    2221class btCollisionObject;
  • code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp

    r2192 r2430  
    5858       
    5959       
    60 };
     60}
    6161
    6262
     
    7979        btCollisionObject* body0 = (btCollisionObject*)b0;
    8080        btCollisionObject* body1 = (btCollisionObject*)b1;
     81
     82        btScalar contactBreakingThreshold = btMin(gContactBreakingThreshold,btMin(body0->getCollisionShape()->getContactBreakingThreshold(),body1->getCollisionShape()->getContactBreakingThreshold()));
    8183       
    8284        void* mem = 0;
     
    9092
    9193        }
    92         btPersistentManifold* manifold = new(mem) btPersistentManifold (body0,body1,0);
     94        btPersistentManifold* manifold = new(mem) btPersistentManifold (body0,body1,0,contactBreakingThreshold);
    9395        manifold->m_index1a = m_manifoldsPtr.size();
    9496        m_manifoldsPtr.push_back(manifold);
  • code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionObject.h

    r2192 r2430  
    3030#include "LinearMath/btMotionState.h"
    3131#include "LinearMath/btAlignedAllocator.h"
    32 
     32#include "LinearMath/btAlignedObjectArray.h"
     33
     34
     35typedef btAlignedObjectArray<class btCollisionObject*> btCollisionObjectArray;
    3336
    3437
     
    7275        void*                   m_userObjectPointer;
    7376
    74         ///m_internalType is reserved to distinguish Bullet's btCollisionObject, btRigidBody, btSoftBody etc.
     77        ///m_internalType is reserved to distinguish Bullet's btCollisionObject, btRigidBody, btSoftBody, btGhostObject etc.
    7578        ///do not assign your own m_internalType unless you write a new dynamics object class.
    7679        int                             m_internalType;
     
    104107                CF_KINEMATIC_OBJECT= 2,
    105108                CF_NO_CONTACT_RESPONSE = 4,
    106                 CF_CUSTOM_MATERIAL_CALLBACK = 8//this allows per-triangle material (friction/restitution)
     109                CF_CUSTOM_MATERIAL_CALLBACK = 8,//this allows per-triangle material (friction/restitution)
     110                CF_CHARACTER_OBJECT = 16
    107111        };
    108112
     
    111115                CO_COLLISION_OBJECT =1,
    112116                CO_RIGID_BODY,
    113                 CO_SOFT_BODY
     117                CO_SOFT_BODY,
     118                ///CO_GHOST_OBJECT keeps track of all objects overlapping its AABB and that pass its collision filter
     119                ///It is useful for collision sensors, explosion objects, character controller etc.
     120                CO_GHOST_OBJECT
    114121        };
    115122
     
    177184        }
    178185
    179         int     getActivationState() const { return m_activationState1;}
     186        SIMD_FORCE_INLINE       int     getActivationState() const { return m_activationState1;}
    180187       
    181188        void setActivationState(int newState);
     
    194201        void    activate(bool forceActivation = false);
    195202
    196         inline bool isActive() const
     203        SIMD_FORCE_INLINE bool isActive() const
    197204        {
    198205                return ((getActivationState() != ISLAND_SLEEPING) && (getActivationState() != DISABLE_SIMULATION));
     
    238245
    239246
    240         btBroadphaseProxy*      getBroadphaseHandle()
     247        SIMD_FORCE_INLINE btBroadphaseProxy*    getBroadphaseHandle()
    241248        {
    242249                return m_broadphaseHandle;
    243250        }
    244251
    245         const btBroadphaseProxy*        getBroadphaseHandle() const
     252        SIMD_FORCE_INLINE const btBroadphaseProxy*      getBroadphaseHandle() const
    246253        {
    247254                return m_broadphaseHandle;
     
    289296        }
    290297
    291         const int getIslandTag() const
     298        SIMD_FORCE_INLINE int getIslandTag() const
    292299        {
    293300                return  m_islandTag1;
     
    299306        }
    300307
    301         const int getCompanionId() const
     308        SIMD_FORCE_INLINE int getCompanionId() const
    302309        {
    303310                return  m_companionId;
     
    309316        }
    310317
    311         const btScalar                  getHitFraction() const
     318        SIMD_FORCE_INLINE btScalar                      getHitFraction() const
    312319        {
    313320                return m_hitFraction;
     
    320327
    321328       
    322         const int       getCollisionFlags() const
     329        SIMD_FORCE_INLINE int   getCollisionFlags() const
    323330        {
    324331                return m_collisionFlags;
  • code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.cpp

    r2192 r2430  
    3333#include "LinearMath/btStackAlloc.h"
    3434
     35//#define USE_BRUTEFORCE_RAYBROADPHASE 1
     36//RECALCULATE_AABB is slower, but benefit is that you don't need to call 'stepSimulation'  or 'updateAabbs' before using a rayTest
     37//#define RECALCULATE_AABB_RAYCAST 1
    3538
    3639//When the user doesn't provide dispatcher or broadphase, create basic versions (and delete them in destructor)
     
    114117}
    115118
     119
     120
    116121void    btCollisionWorld::updateAabbs()
    117122{
     
    126131                if (colObj->isActive())
    127132                {
    128                         btPoint3 minAabb,maxAabb;
     133                        btVector3 minAabb,maxAabb;
    129134                        colObj->getCollisionShape()->getAabb(colObj->getWorldTransform(), minAabb,maxAabb);
    130135                        //need to increase the aabb for contact thresholds
     
    227232        if (collisionShape->isConvex())
    228233        {
     234//              BT_PROFILE("rayTestConvex");
    229235                btConvexCast::CastResult castResult;
    230236                castResult.m_fraction = resultCallback.m_closestHitFraction;
     
    270276                if (collisionShape->isConcave())
    271277                {
     278//                      BT_PROFILE("rayTestConcave");
    272279                        if (collisionShape->getShapeType()==TRIANGLE_MESH_SHAPE_PROXYTYPE)
    273280                        {
     
    318325                        } else
    319326                        {
    320                                 btTriangleMeshShape* triangleMesh = (btTriangleMeshShape*)collisionShape;
     327                                //generic (slower) case
     328                                btConcaveShape* concaveShape = (btConcaveShape*)collisionShape;
    321329
    322330                                btTransform worldTocollisionObject = colObjWorldTransform.inverse();
     
    331339                                        btCollisionWorld::RayResultCallback* m_resultCallback;
    332340                                        btCollisionObject*      m_collisionObject;
    333                                         btTriangleMeshShape*    m_triangleMesh;
     341                                        btConcaveShape* m_triangleMesh;
    334342
    335343                                        BridgeTriangleRaycastCallback( const btVector3& from,const btVector3& to,
    336                                                 btCollisionWorld::RayResultCallback* resultCallback, btCollisionObject* collisionObject,btTriangleMeshShape*    triangleMesh):
     344                                                btCollisionWorld::RayResultCallback* resultCallback, btCollisionObject* collisionObject,btConcaveShape* triangleMesh):
    337345                                                btTriangleRaycastCallback(from,to),
    338346                                                        m_resultCallback(resultCallback),
     
    364372
    365373
    366                                 BridgeTriangleRaycastCallback   rcb(rayFromLocal,rayToLocal,&resultCallback,collisionObject,triangleMesh);
     374                                BridgeTriangleRaycastCallback   rcb(rayFromLocal,rayToLocal,&resultCallback,collisionObject,concaveShape);
    367375                                rcb.m_hitFraction = resultCallback.m_closestHitFraction;
    368376
     
    372380                                rayAabbMaxLocal.setMax(rayToLocal);
    373381
    374                                 triangleMesh->processAllTriangles(&rcb,rayAabbMinLocal,rayAabbMaxLocal);
     382                                concaveShape->processAllTriangles(&rcb,rayAabbMinLocal,rayAabbMaxLocal);
    375383                        }
    376384                } else {
    377                         //todo: use AABB tree or other BVH acceleration structure!
     385//                      BT_PROFILE("rayTestCompound");
     386                        ///@todo: use AABB tree or other BVH acceleration structure, see btDbvt
    378387                        if (collisionShape->isCompound())
    379388                        {
     
    409418        if (collisionShape->isConvex())
    410419        {
     420                //BT_PROFILE("convexSweepConvex");
    411421                btConvexCast::CastResult castResult;
    412422                castResult.m_allowedPenetration = allowedPenetration;
    413                 castResult.m_fraction = btScalar(1.);//??
     423                castResult.m_fraction = resultCallback.m_closestHitFraction;//btScalar(1.);//??
    414424
    415425                btConvexShape* convexShape = (btConvexShape*) collisionShape;
     
    453463                        if (collisionShape->getShapeType()==TRIANGLE_MESH_SHAPE_PROXYTYPE)
    454464                        {
     465                                //BT_PROFILE("convexSweepbtBvhTriangleMesh");
    455466                                btBvhTriangleMeshShape* triangleMesh = (btBvhTriangleMeshShape*)collisionShape;
    456467                                btTransform worldTocollisionObject = colObjWorldTransform.inverse();
     
    509520                        } else
    510521                        {
    511                                 btBvhTriangleMeshShape* triangleMesh = (btBvhTriangleMeshShape*)collisionShape;
     522                                //BT_PROFILE("convexSweepConcave");
     523                                btConcaveShape* concaveShape = (btConcaveShape*)collisionShape;
    512524                                btTransform worldTocollisionObject = colObjWorldTransform.inverse();
    513525                                btVector3 convexFromLocal = worldTocollisionObject * convexFromTrans.getOrigin();
     
    521533                                        btCollisionWorld::ConvexResultCallback* m_resultCallback;
    522534                                        btCollisionObject*      m_collisionObject;
    523                                         btTriangleMeshShape*    m_triangleMesh;
     535                                        btConcaveShape* m_triangleMesh;
    524536
    525537                                        BridgeTriangleConvexcastCallback(const btConvexShape* castShape, const btTransform& from,const btTransform& to,
    526                                                 btCollisionWorld::ConvexResultCallback* resultCallback, btCollisionObject* collisionObject,btTriangleMeshShape* triangleMesh, const btTransform& triangleToWorld):
     538                                                btCollisionWorld::ConvexResultCallback* resultCallback, btCollisionObject* collisionObject,btConcaveShape*      triangleMesh, const btTransform& triangleToWorld):
    527539                                                btTriangleConvexcastCallback(castShape, from,to, triangleToWorld, triangleMesh->getMargin()),
    528540                                                        m_resultCallback(resultCallback),
     
    557569                                };
    558570
    559                                 BridgeTriangleConvexcastCallback tccb(castShape, convexFromTrans,convexToTrans,&resultCallback,collisionObject,triangleMesh, colObjWorldTransform);
     571                                BridgeTriangleConvexcastCallback tccb(castShape, convexFromTrans,convexToTrans,&resultCallback,collisionObject,concaveShape, colObjWorldTransform);
    560572                                tccb.m_hitFraction = resultCallback.m_closestHitFraction;
    561573                                btVector3 boxMinLocal, boxMaxLocal;
     
    568580                                rayAabbMinLocal += boxMinLocal;
    569581                                rayAabbMaxLocal += boxMaxLocal;
    570                                 triangleMesh->processAllTriangles(&tccb,rayAabbMinLocal,rayAabbMaxLocal);
     582                                concaveShape->processAllTriangles(&tccb,rayAabbMinLocal,rayAabbMaxLocal);
    571583                        }
    572584                } else {
    573                         //todo: use AABB tree or other BVH acceleration structure!
     585                        ///@todo : use AABB tree or other BVH acceleration structure!
    574586                        if (collisionShape->isCompound())
    575587                        {
     588                                BT_PROFILE("convexSweepCompound");
    576589                                const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(collisionShape);
    577590                                int i=0;
     
    597610}
    598611
    599 void    btCollisionWorld::rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback) const
    600 {
    601 
    602 
    603         btTransform     rayFromTrans,rayToTrans;
    604         rayFromTrans.setIdentity();
    605         rayFromTrans.setOrigin(rayFromWorld);
    606         rayToTrans.setIdentity();
    607 
    608         rayToTrans.setOrigin(rayToWorld);
    609 
    610         /// go over all objects, and if the ray intersects their aabb, do a ray-shape query using convexCaster (CCD)
    611 
    612         int i;
    613         for (i=0;i<m_collisionObjects.size();i++)
     612
     613struct btSingleRayCallback : public btBroadphaseRayCallback
     614{
     615
     616        btVector3       m_rayFromWorld;
     617        btVector3       m_rayToWorld;
     618        btTransform     m_rayFromTrans;
     619        btTransform     m_rayToTrans;
     620        btVector3       m_hitNormal;
     621
     622        const btCollisionWorld* m_world;
     623        btCollisionWorld::RayResultCallback&    m_resultCallback;
     624
     625        btSingleRayCallback(const btVector3& rayFromWorld,const btVector3& rayToWorld,const btCollisionWorld* world,btCollisionWorld::RayResultCallback& resultCallback)
     626        :m_rayFromWorld(rayFromWorld),
     627        m_rayToWorld(rayToWorld),
     628        m_world(world),
     629        m_resultCallback(resultCallback)
     630        {
     631                m_rayFromTrans.setIdentity();
     632                m_rayFromTrans.setOrigin(m_rayFromWorld);
     633                m_rayToTrans.setIdentity();
     634                m_rayToTrans.setOrigin(m_rayToWorld);
     635
     636                btVector3 rayDir = (rayToWorld-rayFromWorld);
     637
     638                rayDir.normalize ();
     639                ///what about division by zero? --> just set rayDirection[i] to INF/1e30
     640                m_rayDirectionInverse[0] = rayDir[0] == btScalar(0.0) ? btScalar(1e30) : btScalar(1.0) / rayDir[0];
     641                m_rayDirectionInverse[1] = rayDir[1] == btScalar(0.0) ? btScalar(1e30) : btScalar(1.0) / rayDir[1];
     642                m_rayDirectionInverse[2] = rayDir[2] == btScalar(0.0) ? btScalar(1e30) : btScalar(1.0) / rayDir[2];
     643                m_signs[0] = m_rayDirectionInverse[0] < 0.0;
     644                m_signs[1] = m_rayDirectionInverse[1] < 0.0;
     645                m_signs[2] = m_rayDirectionInverse[2] < 0.0;
     646
     647                m_lambda_max = rayDir.dot(m_rayToWorld-m_rayFromWorld);
     648
     649        }
     650
     651       
     652
     653        virtual bool    process(const btBroadphaseProxy* proxy)
    614654        {
    615655                ///terminate further ray tests, once the closestHitFraction reached zero
    616                 if (resultCallback.m_closestHitFraction == btScalar(0.f))
    617                         break;
    618 
    619                 btCollisionObject*      collisionObject= m_collisionObjects[i];
     656                if (m_resultCallback.m_closestHitFraction == btScalar(0.f))
     657                        return false;
     658
     659                btCollisionObject*      collisionObject = (btCollisionObject*)proxy->m_clientObject;
     660
    620661                //only perform raycast if filterMask matches
    621                 if(resultCallback.needsCollision(collisionObject->getBroadphaseHandle())) {
     662                if(m_resultCallback.needsCollision(collisionObject->getBroadphaseHandle()))
     663                {
    622664                        //RigidcollisionObject* collisionObject = ctrl->GetRigidcollisionObject();
     665                        //btVector3 collisionObjectAabbMin,collisionObjectAabbMax;
     666                       
     667#ifdef RECALCULATE_AABB
    623668                        btVector3 collisionObjectAabbMin,collisionObjectAabbMax;
    624669                        collisionObject->getCollisionShape()->getAabb(collisionObject->getWorldTransform(),collisionObjectAabbMin,collisionObjectAabbMax);
    625 
    626                         btScalar hitLambda = resultCallback.m_closestHitFraction;
    627                         btVector3 hitNormal;
    628                         if (btRayAabb(rayFromWorld,rayToWorld,collisionObjectAabbMin,collisionObjectAabbMax,hitLambda,hitNormal))
    629                         {
    630                                 rayTestSingle(rayFromTrans,rayToTrans,
     670#else
     671                        //getBroadphase()->getAabb(collisionObject->getBroadphaseHandle(),collisionObjectAabbMin,collisionObjectAabbMax);
     672                        const btVector3& collisionObjectAabbMin = collisionObject->getBroadphaseHandle()->m_aabbMin;
     673                        const btVector3& collisionObjectAabbMax = collisionObject->getBroadphaseHandle()->m_aabbMax;
     674#endif
     675                        //btScalar hitLambda = m_resultCallback.m_closestHitFraction;
     676                        //culling already done by broadphase
     677                        //if (btRayAabb(m_rayFromWorld,m_rayToWorld,collisionObjectAabbMin,collisionObjectAabbMax,hitLambda,m_hitNormal))
     678                        {
     679                                m_world->rayTestSingle(m_rayFromTrans,m_rayToTrans,
    631680                                        collisionObject,
    632681                                                collisionObject->getCollisionShape(),
    633682                                                collisionObject->getWorldTransform(),
    634                                                 resultCallback);
     683                                                m_resultCallback);
    635684                        }
    636685                }
    637 
    638         }
    639 
    640 }
    641 
    642 void    btCollisionWorld::convexSweepTest(const btConvexShape* castShape, const btTransform& convexFromWorld, const btTransform& convexToWorld, ConvexResultCallback& resultCallback) const
    643 {
     686                return true;
     687        }
     688};
     689
     690void    btCollisionWorld::rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback) const
     691{
     692        BT_PROFILE("rayTest");
     693        /// use the broadphase to accelerate the search for objects, based on their aabb
     694        /// and for each object with ray-aabb overlap, perform an exact ray test
     695        btSingleRayCallback rayCB(rayFromWorld,rayToWorld,this,resultCallback);
     696
     697#ifndef USE_BRUTEFORCE_RAYBROADPHASE
     698        m_broadphasePairCache->rayTest(rayFromWorld,rayToWorld,rayCB);
     699#else
     700        for (int i=0;i<this->getNumCollisionObjects();i++)
     701        {
     702                rayCB.process(m_collisionObjects[i]->getBroadphaseHandle());
     703        }       
     704#endif //USE_BRUTEFORCE_RAYBROADPHASE
     705
     706}
     707
     708
     709struct btSingleSweepCallback : public btBroadphaseRayCallback
     710{
     711
     712        btTransform     m_convexFromTrans;
     713        btTransform     m_convexToTrans;
     714        btVector3       m_hitNormal;
     715        const btCollisionWorld* m_world;
     716        btCollisionWorld::ConvexResultCallback& m_resultCallback;
     717        btScalar        m_allowedCcdPenetration;
     718        const btConvexShape* m_castShape;
     719
     720
     721        btSingleSweepCallback(const btConvexShape* castShape, const btTransform& convexFromTrans,const btTransform& convexToTrans,const btCollisionWorld* world,btCollisionWorld::ConvexResultCallback& resultCallback,btScalar allowedPenetration)
     722                :m_convexFromTrans(convexFromTrans),
     723                m_convexToTrans(convexToTrans),
     724                m_world(world),
     725                m_resultCallback(resultCallback),
     726                m_allowedCcdPenetration(allowedPenetration),
     727                m_castShape(castShape)
     728        {
     729                btVector3 unnormalizedRayDir = (m_convexToTrans.getOrigin()-m_convexFromTrans.getOrigin());
     730                btVector3 rayDir = unnormalizedRayDir.normalized();
     731                ///what about division by zero? --> just set rayDirection[i] to INF/1e30
     732                m_rayDirectionInverse[0] = rayDir[0] == btScalar(0.0) ? btScalar(1e30) : btScalar(1.0) / rayDir[0];
     733                m_rayDirectionInverse[1] = rayDir[1] == btScalar(0.0) ? btScalar(1e30) : btScalar(1.0) / rayDir[1];
     734                m_rayDirectionInverse[2] = rayDir[2] == btScalar(0.0) ? btScalar(1e30) : btScalar(1.0) / rayDir[2];
     735                m_signs[0] = m_rayDirectionInverse[0] < 0.0;
     736                m_signs[1] = m_rayDirectionInverse[1] < 0.0;
     737                m_signs[2] = m_rayDirectionInverse[2] < 0.0;
     738
     739                m_lambda_max = rayDir.dot(unnormalizedRayDir);
     740
     741        }
     742
     743        virtual bool    process(const btBroadphaseProxy* proxy)
     744        {
     745                ///terminate further convex sweep tests, once the closestHitFraction reached zero
     746                if (m_resultCallback.m_closestHitFraction == btScalar(0.f))
     747                        return false;
     748
     749                btCollisionObject*      collisionObject = (btCollisionObject*)proxy->m_clientObject;
     750
     751                //only perform raycast if filterMask matches
     752                if(m_resultCallback.needsCollision(collisionObject->getBroadphaseHandle())) {
     753                        //RigidcollisionObject* collisionObject = ctrl->GetRigidcollisionObject();
     754                        m_world->objectQuerySingle(m_castShape, m_convexFromTrans,m_convexToTrans,
     755                                        collisionObject,
     756                                                collisionObject->getCollisionShape(),
     757                                                collisionObject->getWorldTransform(),
     758                                                m_resultCallback,
     759                                                m_allowedCcdPenetration);
     760                }
     761               
     762                return true;
     763        }
     764};
     765
     766
     767
     768void    btCollisionWorld::convexSweepTest(const btConvexShape* castShape, const btTransform& convexFromWorld, const btTransform& convexToWorld, ConvexResultCallback& resultCallback, btScalar allowedCcdPenetration) const
     769{
     770
     771        BT_PROFILE("convexSweepTest");
     772        /// use the broadphase to accelerate the search for objects, based on their aabb
     773        /// and for each object with ray-aabb overlap, perform an exact ray test
     774        /// unfortunately the implementation for rayTest and convexSweepTest duplicated, albeit practically identical
     775
     776       
     777
    644778        btTransform     convexFromTrans,convexToTrans;
    645779        convexFromTrans = convexFromWorld;
     
    650784                btVector3 linVel, angVel;
    651785                btTransformUtil::calculateVelocity (convexFromTrans, convexToTrans, 1.0, linVel, angVel);
     786                btVector3 zeroLinVel;
     787                zeroLinVel.setValue(0,0,0);
    652788                btTransform R;
    653789                R.setIdentity ();
    654790                R.setRotation (convexFromTrans.getRotation());
    655                 castShape->calculateTemporalAabb (R, linVel, angVel, 1.0, castShapeAabbMin, castShapeAabbMax);
    656         }
    657 
     791                castShape->calculateTemporalAabb (R, zeroLinVel, angVel, 1.0, castShapeAabbMin, castShapeAabbMax);
     792        }
     793
     794#ifndef USE_BRUTEFORCE_RAYBROADPHASE
     795
     796        btSingleSweepCallback   convexCB(castShape,convexFromWorld,convexToWorld,this,resultCallback,allowedCcdPenetration);
     797
     798        m_broadphasePairCache->rayTest(convexFromTrans.getOrigin(),convexToTrans.getOrigin(),convexCB,castShapeAabbMin,castShapeAabbMax);
     799
     800#else
    658801        /// go over all objects, and if the ray intersects their aabb + cast shape aabb,
    659802        // do a ray-shape query using convexCaster (CCD)
     
    677820                                                collisionObject->getWorldTransform(),
    678821                                                resultCallback,
    679                                                 getDispatchInfo().m_allowedCcdPenetration);
     822                                                allowedCcdPenetration);
    680823                        }
    681824                }
    682825        }
    683 
    684 }
     826#endif //USE_BRUTEFORCE_RAYBROADPHASE
     827}
  • code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.h

    r2192 r2430  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2006 Erwin Coumans  http://bulletphysics.com/Bullet/
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    2323 * Bullet is a Collision Detection and Rigid Body Dynamics Library. The Library is Open Source and free for commercial use, under the ZLib license ( http://opensource.org/licenses/zlib-license.php ).
    2424 *
    25  * There is the Physics Forum for Feedback and bteral Collision Detection and Physics discussions.
    26  * Please visit http://www.continuousphysics.com/Bullet/phpBB2/index.php
     25 * There is the Physics Forum for feedback and general Collision Detection and Physics discussions.
     26 * Please visit http://www.bulletphysics.com
    2727 *
    2828 * @section install_sec Installation
    2929 *
    3030 * @subsection step1 Step 1: Download
    31  * You can download the Bullet Physics Library from our website: http://www.continuousphysics.com/Bullet/
     31 * You can download the Bullet Physics Library from the Google Code repository: http://code.google.com/p/bullet/downloads/list
    3232 * @subsection step2 Step 2: Building
    3333 * Bullet comes with autogenerated Project Files for Microsoft Visual Studio 6, 7, 7.1 and 8.
    3434 * The main Workspace/Solution is located in Bullet/msvc/8/wksbullet.sln (replace 8 with your version).
    3535 *
    36  * Under other platforms, like Linux or Mac OS-X, Bullet can be build using either using make, cmake, http://www.cmake.org, or jam, http://www.perforce.com/jam/jam.html . cmake can autogenerate Xcode, KDevelop, MSVC and other build systems. just run cmake . in the root of Bullet.
     36 * Under other platforms, like Linux or Mac OS-X, Bullet can be build using either using make, cmake, http://www.cmake.org , or jam, http://www.perforce.com/jam/jam.html . cmake can autogenerate Xcode, KDevelop, MSVC and other build systems. just run cmake . in the root of Bullet.
    3737 * So if you are not using MSVC or cmake, you can run ./autogen.sh ./configure to create both Makefile and Jamfile and then run make or jam.
    3838 * Jam is a build system that can build the library, demos and also autogenerate the MSVC Project Files.
    39  * If you don't have jam installed, you can make jam from the included jam-2.5 sources, or download jam from ftp://ftp.perforce.com/pub/jam/
     39 * If you don't have jam installed, you can make jam from the included jam-2.5 sources, or download jam from ftp://ftp.perforce.com/jam
    4040 *
    4141 * @subsection step3 Step 3: Testing demos
     
    7272#include "LinearMath/btTransform.h"
    7373#include "btCollisionObject.h"
    74 #include "btCollisionDispatcher.h" //for definition of btCollisionObjectArray
     74#include "btCollisionDispatcher.h"
    7575#include "BulletCollision/BroadphaseCollision/btOverlappingPairCache.h"
    7676#include "LinearMath/btAlignedObjectArray.h"
     
    108108        }
    109109
     110        const btBroadphaseInterface*    getBroadphase() const
     111        {
     112                return m_broadphasePairCache;
     113        }
     114
    110115        btBroadphaseInterface*  getBroadphase()
    111116        {
     
    131136        virtual void    updateAabbs();
    132137
     138       
    133139        virtual void    setDebugDrawer(btIDebugDraw*    debugDrawer)
    134140        {
     
    348354        // convexTest performs a swept convex cast on all objects in the btCollisionWorld, and calls the resultCallback
    349355        // This allows for several queries: first hit, all hits, any hit, dependent on the value return by the callback.
    350         void    convexSweepTest (const btConvexShape* castShape, const btTransform& from, const btTransform& to, ConvexResultCallback& resultCallback) const;
     356        void    convexSweepTest (const btConvexShape* castShape, const btTransform& from, const btTransform& to, ConvexResultCallback& resultCallback,  btScalar allowedCcdPenetration = btScalar(0.)) const;
    351357
    352358
  • code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp

    r2192 r2430  
    2222
    2323btCompoundCollisionAlgorithm::btCompoundCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped)
    24 :btCollisionAlgorithm(ci),
     24:btActivatingCollisionAlgorithm(ci,body0,body1),
    2525m_isSwapped(isSwapped),
    2626m_sharedManifold(ci.m_manifold)
  • code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h

    r2192 r2430  
    1717#define COMPOUND_COLLISION_ALGORITHM_H
    1818
    19 #include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
     19#include "btActivatingCollisionAlgorithm.h"
    2020#include "BulletCollision/BroadphaseCollision/btDispatcher.h"
    2121#include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h"
     
    2929
    3030/// btCompoundCollisionAlgorithm  supports collision between CompoundCollisionShapes and other collision shapes
    31 class btCompoundCollisionAlgorithm  : public btCollisionAlgorithm
     31class btCompoundCollisionAlgorithm  : public btActivatingCollisionAlgorithm
    3232{
    3333        btAlignedObjectArray<btCollisionAlgorithm*> m_childCollisionAlgorithms;
  • code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp

    r2192 r2430  
    2828
    2929btConvexConcaveCollisionAlgorithm::btConvexConcaveCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1,bool isSwapped)
    30 : btCollisionAlgorithm(ci),
     30: btActivatingCollisionAlgorithm(ci,body0,body1),
    3131m_isSwapped(isSwapped),
    3232m_btConvexTriangleCallback(ci.m_dispatcher1,body0,body1,isSwapped)
     
    7373{
    7474        m_dispatcher->clearManifold(m_manifoldPtr);
    75 };
     75}
    7676
    7777
     
    9494       
    9595        ///debug drawing of the overlapping triangles
    96         if (m_dispatchInfoPtr && m_dispatchInfoPtr->m_debugDraw && m_dispatchInfoPtr->m_debugDraw->getDebugMode() > 0)
     96        if (m_dispatchInfoPtr && m_dispatchInfoPtr->m_debugDraw && (m_dispatchInfoPtr->m_debugDraw->getDebugMode() &btIDebugDraw::DBG_DrawWireframe ))
    9797        {
    9898                btVector3 color(255,255,0);
  • code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.h

    r2192 r2430  
    1717#define CONVEX_CONCAVE_COLLISION_ALGORITHM_H
    1818
    19 #include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
     19#include "btActivatingCollisionAlgorithm.h"
    2020#include "BulletCollision/BroadphaseCollision/btDispatcher.h"
    2121#include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h"
     
    3535        btVector3       m_aabbMax ;
    3636
     37
    3738        btManifoldResult* m_resultOut;
    38 
    3939        btDispatcher*   m_dispatcher;
    4040        const btDispatcherInfo* m_dispatchInfoPtr;
     
    7171
    7272/// btConvexConcaveCollisionAlgorithm  supports collision between convex shapes and (concave) trianges meshes.
    73 class btConvexConcaveCollisionAlgorithm  : public btCollisionAlgorithm
     73class btConvexConcaveCollisionAlgorithm  : public btActivatingCollisionAlgorithm
    7474{
    7575
     
    7777
    7878        btConvexTriangleCallback m_btConvexTriangleCallback;
     79
    7980
    8081
  • code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp

    r2192 r2430  
    3939#include "BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.h"
    4040
    41 #include "BulletCollision/NarrowPhaseCollision/btGjkEpa.h"
     41#include "BulletCollision/NarrowPhaseCollision/btGjkEpa2.h"
    4242#include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h"
    4343
     
    6161
    6262btConvexConvexAlgorithm::btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver)
    63 : btCollisionAlgorithm(ci),
    64 m_gjkPairDetector(0,0,simplexSolver,pdSolver),
     63: btActivatingCollisionAlgorithm(ci,body0,body1),
     64m_simplexSolver(simplexSolver),
     65m_pdSolver(pdSolver),
    6566m_ownManifold (false),
    6667m_manifoldPtr(mf),
    6768m_lowLevelOfDetail(false)
     69#ifdef USE_SEPDISTANCE_UTIL2
     70,m_sepDistance((static_cast<btConvexShape*>(body0->getCollisionShape()))->getAngularMotionDisc(),
     71                          (static_cast<btConvexShape*>(body1->getCollisionShape()))->getAngularMotionDisc())
     72#endif
    6873{
    6974        (void)body0;
    7075        (void)body1;
    71 
    72 
    7376}
    7477
     
    108111        resultOut->setPersistentManifold(m_manifoldPtr);
    109112
    110 #ifdef USE_BT_GJKEPA
    111         btConvexShape*                          shape0(static_cast<btConvexShape*>(body0->getCollisionShape()));
    112         btConvexShape*                          shape1(static_cast<btConvexShape*>(body1->getCollisionShape()));
    113         const btScalar                          radialmargin(0/*shape0->getMargin()+shape1->getMargin()*/);
    114         btGjkEpaSolver::sResults        results;
    115         if(btGjkEpaSolver::Collide(     shape0,body0->getWorldTransform(),
    116                                                                 shape1,body1->getWorldTransform(),
    117                                                                 radialmargin,results))
    118                 {
    119                 dispatchInfo.m_debugDraw->drawLine(results.witnesses[1],results.witnesses[1]+results.normal,btVector3(255,0,0));
    120                 resultOut->addContactPoint(results.normal,results.witnesses[1],-results.depth);
    121                 }
    122 #else
     113       
    123114
    124115        btConvexShape* min0 = static_cast<btConvexShape*>(body0->getCollisionShape());
    125116        btConvexShape* min1 = static_cast<btConvexShape*>(body1->getCollisionShape());
     117
     118#ifdef USE_SEPDISTANCE_UTIL2
     119        m_sepDistance.updateSeparatingDistance(body0->getWorldTransform(),body1->getWorldTransform());
     120        if (!dispatchInfo.m_useConvexConservativeDistanceUtil || m_sepDistance.getConservativeSeparatingDistance()<=0.f)
     121#endif //USE_SEPDISTANCE_UTIL2
     122
     123        {
     124
    126125       
    127126        btGjkPairDetector::ClosestPointInput input;
    128127
     128        btGjkPairDetector       gjkPairDetector(min0,min1,m_simplexSolver,m_pdSolver);
    129129        //TODO: if (dispatchInfo.m_useContinuous)
    130         m_gjkPairDetector.setMinkowskiA(min0);
    131         m_gjkPairDetector.setMinkowskiB(min1);
    132         input.m_maximumDistanceSquared = min0->getMargin() + min1->getMargin() + m_manifoldPtr->getContactBreakingThreshold();
    133         input.m_maximumDistanceSquared*= input.m_maximumDistanceSquared;
     130        gjkPairDetector.setMinkowskiA(min0);
     131        gjkPairDetector.setMinkowskiB(min1);
     132
     133#ifdef USE_SEPDISTANCE_UTIL2
     134        if (dispatchInfo.m_useConvexConservativeDistanceUtil)
     135        {
     136                input.m_maximumDistanceSquared = 1e30f;
     137        } else
     138#endif //USE_SEPDISTANCE_UTIL2
     139        {
     140                input.m_maximumDistanceSquared = min0->getMargin() + min1->getMargin() + m_manifoldPtr->getContactBreakingThreshold();
     141                input.m_maximumDistanceSquared*= input.m_maximumDistanceSquared;
     142        }
     143
    134144        input.m_stackAlloc = dispatchInfo.m_stackAllocator;
    135 
    136 //      input.m_maximumDistanceSquared = btScalar(1e30);
    137        
    138145        input.m_transformA = body0->getWorldTransform();
    139146        input.m_transformB = body1->getWorldTransform();
    140        
    141         m_gjkPairDetector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw);
    142 #endif
     147
     148        gjkPairDetector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw);
     149
     150        btScalar sepDist = gjkPairDetector.getCachedSeparatingDistance()+dispatchInfo.m_convexConservativeDistanceThreshold;
     151
     152#ifdef USE_SEPDISTANCE_UTIL2
     153        if (dispatchInfo.m_useConvexConservativeDistanceUtil)
     154        {
     155                m_sepDistance.initSeparatingDistance(gjkPairDetector.getCachedSeparatingAxis(),sepDist,body0->getWorldTransform(),body1->getWorldTransform());
     156        }
     157#endif //USE_SEPDISTANCE_UTIL2
     158
     159
     160        }
    143161
    144162        if (m_ownManifold)
  • code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h

    r2192 r2430  
    1717#define CONVEX_CONVEX_ALGORITHM_H
    1818
    19 #include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
     19#include "btActivatingCollisionAlgorithm.h"
    2020#include "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h"
    2121#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h"
     
    2424#include "btCollisionCreateFunc.h"
    2525#include "btCollisionDispatcher.h"
     26#include "LinearMath/btTransformUtil.h" //for btConvexSeparatingDistanceUtil
    2627
    2728class btConvexPenetrationDepthSolver;
    2829
     30///Enabling USE_SEPDISTANCE_UTIL2 requires 100% reliable distance computation. However, when using large size ratios GJK can be imprecise
     31///so the distance is not conservative. In that case, enabling this USE_SEPDISTANCE_UTIL2 would result in failing/missing collisions.
     32///Either improve GJK for large size ratios (testing a 100 units versus a 0.1 unit object) or only enable the util
     33///for certain pairs that have a small size ratio
     34///#define USE_SEPDISTANCE_UTIL2 1
     35
    2936///ConvexConvexAlgorithm collision algorithm implements time of impact, convex closest points and penetration depth calculations.
    30 class btConvexConvexAlgorithm : public btCollisionAlgorithm
     37class btConvexConvexAlgorithm : public btActivatingCollisionAlgorithm
    3138{
    32         btGjkPairDetector m_gjkPairDetector;
    33 public:
     39#ifdef USE_SEPDISTANCE_UTIL2
     40        btConvexSeparatingDistanceUtil  m_sepDistance;
     41#endif
     42        btSimplexSolverInterface*               m_simplexSolver;
     43        btConvexPenetrationDepthSolver* m_pdSolver;
    3444
     45       
    3546        bool    m_ownManifold;
    3647        btPersistentManifold*   m_manifoldPtr;
    3748        bool                    m_lowLevelOfDetail;
     49       
     50        ///cache separating vector to speedup collision detection
    3851       
    3952
  • code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.cpp

    r2192 r2430  
    101101        int maxSize2 = sizeof(btConvexConcaveCollisionAlgorithm);
    102102        int maxSize3 = sizeof(btCompoundCollisionAlgorithm);
    103         int maxSize4 = sizeof(btEmptyAlgorithm);
    104        
     103        int sl = sizeof(btConvexSeparatingDistanceUtil);
     104        sl = sizeof(btGjkPairDetector);
    105105        int     collisionAlgorithmMaxElementSize = btMax(maxSize,maxSize2);
    106106        collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,maxSize3);
    107         collisionAlgorithmMaxElementSize = btMax(collisionAlgorithmMaxElementSize,maxSize4);
    108107
    109108        if (constructionInfo.m_stackAlloc)
  • code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h

    r2192 r2430  
    3434                m_persistentManifoldPool(0),
    3535                m_collisionAlgorithmPool(0),
    36                 m_defaultMaxPersistentManifoldPoolSize(65535),
    37                 m_defaultMaxCollisionAlgorithmPoolSize(65535),
    38                 m_defaultStackAllocatorSize(5*1024*1024)
     36                m_defaultMaxPersistentManifoldPoolSize(4096),
     37                m_defaultMaxCollisionAlgorithmPoolSize(4096),
     38                m_defaultStackAllocatorSize(0)
    3939        {
    4040        }
     
    4545///btCollisionConfiguration allows to configure Bullet collision detection
    4646///stack allocator, pool memory allocators
    47 ///todo: describe the meaning
     47///@todo: describe the meaning
    4848class   btDefaultCollisionConfiguration : public btCollisionConfiguration
    4949{
  • code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btManifoldResult.cpp

    r2192 r2430  
    9494   newPt.m_index1  = m_index1;
    9595       
    96         ///todo, check this for any side effects
     96        ///@todo, check this for any side effects
    9797        if (insertIndex >= 0)
    9898        {
  • code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp

    r2192 r2430  
    144144
    145145
    146 void btSimulationIslandManager::buildIslands(btDispatcher* dispatcher,btCollisionObjectArray& collisionObjects)
     146void btSimulationIslandManager::buildIslands(btDispatcher* dispatcher,btCollisionWorld* collisionWorld)
    147147{
    148148
    149149        BT_PROFILE("islandUnionFindAndQuickSort");
    150150       
     151        btCollisionObjectArray& collisionObjects = collisionWorld->getCollisionObjectArray();
     152
    151153        m_islandmanifold.resize(0);
    152154
     
    239241                                        {
    240242                                                colObj0->setActivationState( WANTS_DEACTIVATION);
     243                                                colObj0->setDeactivationTime(0.f);
    241244                                        }
    242245                                }
     
    263266                 btCollisionObject* colObj1 = static_cast<btCollisionObject*>(manifold->getBody1());
    264267               
    265                  //todo: check sleeping conditions!
     268                 ///@todo: check sleeping conditions!
    266269                 if (((colObj0) && colObj0->getActivationState() != ISLAND_SLEEPING) ||
    267270                        ((colObj1) && colObj1->getActivationState() != ISLAND_SLEEPING))
     
    288291
    289292
    290 //
    291 // todo: this is random access, it can be walked 'cache friendly'!
    292 //
    293 void btSimulationIslandManager::buildAndProcessIslands(btDispatcher* dispatcher,btCollisionObjectArray& collisionObjects, IslandCallback* callback)
    294 {
    295 
    296         buildIslands(dispatcher,collisionObjects);
     293///@todo: this is random access, it can be walked 'cache friendly'!
     294void btSimulationIslandManager::buildAndProcessIslands(btDispatcher* dispatcher,btCollisionWorld* collisionWorld, IslandCallback* callback)
     295{
     296        btCollisionObjectArray& collisionObjects = collisionWorld->getCollisionObjectArray();
     297
     298        buildIslands(dispatcher,collisionWorld);
    297299
    298300        int endIslandIndex=1;
  • code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSimulationIslandManager.h

    r2192 r2430  
    2020#include "btCollisionCreateFunc.h"
    2121#include "LinearMath/btAlignedObjectArray.h"
    22 
     22#include "btCollisionObject.h"
    2323
    2424class btCollisionObject;
     
    6262        };
    6363
    64         void    buildAndProcessIslands(btDispatcher* dispatcher,btCollisionObjectArray& collisionObjects, IslandCallback* callback);
     64        void    buildAndProcessIslands(btDispatcher* dispatcher,btCollisionWorld* collisionWorld, IslandCallback* callback);
    6565
    66         void buildIslands(btDispatcher* dispatcher,btCollisionObjectArray& collisionObjects);
     66        void buildIslands(btDispatcher* dispatcher,btCollisionWorld* colWorld);
    6767
    6868};
  • code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.cpp

    r2192 r2430  
    2222
    2323btSphereBoxCollisionAlgorithm::btSphereBoxCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped)
    24 : btCollisionAlgorithm(ci),
     24: btActivatingCollisionAlgorithm(ci,col0,col1),
    2525m_ownManifold(false),
    2626m_manifoldPtr(mf),
  • code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.h

    r2192 r2430  
    1717#define SPHERE_BOX_COLLISION_ALGORITHM_H
    1818
    19 #include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
     19#include "btActivatingCollisionAlgorithm.h"
    2020#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
    2121#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h"
     
    2727/// btSphereBoxCollisionAlgorithm  provides sphere-box collision detection.
    2828/// Other features are frame-coherency (persistent data) and collision response.
    29 class btSphereBoxCollisionAlgorithm : public btCollisionAlgorithm
     29class btSphereBoxCollisionAlgorithm : public btActivatingCollisionAlgorithm
    3030{
    3131        bool    m_ownManifold;
  • code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.cpp

    r2192 r2430  
    2020
    2121btSphereSphereCollisionAlgorithm::btSphereSphereCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1)
    22 : btCollisionAlgorithm(ci),
     22: btActivatingCollisionAlgorithm(ci,col0,col1),
    2323m_ownManifold(false),
    2424m_manifoldPtr(mf)
  • code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.h

    r2192 r2430  
    1717#define SPHERE_SPHERE_COLLISION_ALGORITHM_H
    1818
    19 #include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
     19#include "btActivatingCollisionAlgorithm.h"
    2020#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
    2121#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h"
     
    2727/// Other features are frame-coherency (persistent data) and collision response.
    2828/// Also provides the most basic sample for custom/user btCollisionAlgorithm
    29 class btSphereSphereCollisionAlgorithm : public btCollisionAlgorithm
     29class btSphereSphereCollisionAlgorithm : public btActivatingCollisionAlgorithm
    3030{
    3131        bool    m_ownManifold;
     
    3636
    3737        btSphereSphereCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci)
    38                 : btCollisionAlgorithm(ci) {}
     38                : btActivatingCollisionAlgorithm(ci) {}
    3939
    4040        virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
  • code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.cpp

    r2192 r2430  
    2323
    2424btSphereTriangleCollisionAlgorithm::btSphereTriangleCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1,bool swapped)
    25 : btCollisionAlgorithm(ci),
     25: btActivatingCollisionAlgorithm(ci,col0,col1),
    2626m_ownManifold(false),
    2727m_manifoldPtr(mf),
     
    5757        /// report a contact. internally this will be kept persistent, and contact reduction is done
    5858        resultOut->setPersistentManifold(m_manifoldPtr);
    59         SphereTriangleDetector detector(sphere,triangle);
     59        SphereTriangleDetector detector(sphere,triangle, m_manifoldPtr->getContactBreakingThreshold());
    6060       
    6161        btDiscreteCollisionDetectorInterface::ClosestPointInput input;
    62         input.m_maximumDistanceSquared = btScalar(1e30);//todo: tighter bounds
     62        input.m_maximumDistanceSquared = btScalar(1e30);///@todo: tighter bounds
    6363        input.m_transformA = sphereObj->getWorldTransform();
    6464        input.m_transformB = triObj->getWorldTransform();
  • code/branches/physics/src/bullet/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.h

    r2192 r2430  
    1717#define SPHERE_TRIANGLE_COLLISION_ALGORITHM_H
    1818
    19 #include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
     19#include "btActivatingCollisionAlgorithm.h"
    2020#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
    2121#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h"
     
    2626/// Other features are frame-coherency (persistent data) and collision response.
    2727/// Also provides the most basic sample for custom/user btCollisionAlgorithm
    28 class btSphereTriangleCollisionAlgorithm : public btCollisionAlgorithm
     28class btSphereTriangleCollisionAlgorithm : public btActivatingCollisionAlgorithm
    2929{
    3030        bool    m_ownManifold;
     
    3636
    3737        btSphereTriangleCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci)
    38                 : btCollisionAlgorithm(ci) {}
     38                : btActivatingCollisionAlgorithm(ci) {}
    3939
    4040        virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
Note: See TracChangeset for help on using the changeset viewer.