Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 3, 2011, 5:07:42 AM (13 years ago)
Author:
rgrieder
Message:

Updated Bullet from v2.77 to v2.78.
(I'm not going to make a branch for that since the update from 2.74 to 2.77 hasn't been tested that much either).

You will HAVE to do a complete RECOMPILE! I tested with MSVC and MinGW and they both threw linker errors at me.

Location:
code/trunk/src/external/bullet/BulletCollision/CollisionDispatch
Files:
30 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/SphereTriangleDetector.cpp

    r8351 r8393  
    5858}
    5959
    60 #define MAX_OVERLAP btScalar(0.)
    61 
    6260
    6361
     
    9492}
    9593
    96 ///combined discrete/continuous sphere-triangle
    9794bool SphereTriangleDetector::collide(const btVector3& sphereCenter,btVector3 &point, btVector3& resultNormal, btScalar& depth, btScalar &timeOfImpact, btScalar contactBreakingThreshold)
    9895{
    9996
    10097        const btVector3* vertices = &m_triangle->getVertexPtr(0);
    101         const btVector3& c = sphereCenter;
    102         btScalar r = m_sphere->getRadius();
    103 
    104         btVector3 delta (0,0,0);
     98       
     99        btScalar radius = m_sphere->getRadius();
     100        btScalar radiusWithThreshold = radius + contactBreakingThreshold;
    105101
    106102        btVector3 normal = (vertices[1]-vertices[0]).cross(vertices[2]-vertices[0]);
    107103        normal.normalize();
    108         btVector3 p1ToCentre = c - vertices[0];
     104        btVector3 p1ToCentre = sphereCenter - vertices[0];
    109105        btScalar distanceFromPlane = p1ToCentre.dot(normal);
    110106
     
    112108        {
    113109                //triangle facing the other way
    114        
    115110                distanceFromPlane *= btScalar(-1.);
    116111                normal *= btScalar(-1.);
    117112        }
    118113
    119         btScalar contactMargin = contactBreakingThreshold;
    120         bool isInsideContactPlane = distanceFromPlane < r + contactMargin;
    121         bool isInsideShellPlane = distanceFromPlane < r;
    122        
    123         btScalar deltaDotNormal = delta.dot(normal);
    124         if (!isInsideShellPlane && deltaDotNormal >= btScalar(0.0))
    125                 return false;
    126 
     114        bool isInsideContactPlane = distanceFromPlane < radiusWithThreshold;
     115       
    127116        // Check for contact / intersection
    128117        bool hasContact = false;
    129118        btVector3 contactPoint;
    130119        if (isInsideContactPlane) {
    131                 if (facecontains(c,vertices,normal)) {
     120                if (facecontains(sphereCenter,vertices,normal)) {
    132121                        // Inside the contact wedge - touches a point on the shell plane
    133122                        hasContact = true;
    134                         contactPoint = c - normal*distanceFromPlane;
     123                        contactPoint = sphereCenter - normal*distanceFromPlane;
    135124                } else {
    136125                        // Could be inside one of the contact capsules
    137                         btScalar contactCapsuleRadiusSqr = (r + contactMargin) * (r + contactMargin);
     126                        btScalar contactCapsuleRadiusSqr = radiusWithThreshold*radiusWithThreshold;
    138127                        btVector3 nearestOnEdge;
    139128                        for (int i = 0; i < m_triangle->getNumEdges(); i++) {
     
    144133                                m_triangle->getEdge(i,pa,pb);
    145134
    146                                 btScalar distanceSqr = SegmentSqrDistance(pa,pb,c, nearestOnEdge);
     135                                btScalar distanceSqr = SegmentSqrDistance(pa,pb,sphereCenter, nearestOnEdge);
    147136                                if (distanceSqr < contactCapsuleRadiusSqr) {
    148137                                        // Yep, we're inside a capsule
     
    156145
    157146        if (hasContact) {
    158                 btVector3 contactToCentre = c - contactPoint;
     147                btVector3 contactToCentre = sphereCenter - contactPoint;
    159148                btScalar distanceSqr = contactToCentre.length2();
    160                 if (distanceSqr < (r - MAX_OVERLAP)*(r - MAX_OVERLAP)) {
    161                         btScalar distance = btSqrt(distanceSqr);
    162                         resultNormal = contactToCentre;
    163                         resultNormal.normalize();
    164                         point = contactPoint;
    165                         depth = -(r-distance);
     149
     150                if (distanceSqr < radiusWithThreshold*radiusWithThreshold)
     151                {
     152                        if (distanceSqr>SIMD_EPSILON)
     153                        {
     154                                btScalar distance = btSqrt(distanceSqr);
     155                                resultNormal = contactToCentre;
     156                                resultNormal.normalize();
     157                                point = contactPoint;
     158                                depth = -(radius-distance);
     159                        } else
     160                        {
     161                                btScalar distance = 0.f;
     162                                resultNormal = normal;
     163                                point = contactPoint;
     164                                depth = -radius;
     165                        }
    166166                        return true;
    167167                }
    168 
    169                 if (delta.dot(contactToCentre) >= btScalar(0.0))
    170                         return false;
    171                
    172                 // Moving towards the contact point -> collision
    173                 point = contactPoint;
    174                 timeOfImpact = btScalar(0.0);
    175                 return true;
    176168        }
    177169       
  • code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/SphereTriangleDetector.h

    r8351 r8393  
    1414*/
    1515
    16 #ifndef SPHERE_TRIANGLE_DETECTOR_H
    17 #define SPHERE_TRIANGLE_DETECTOR_H
     16#ifndef BT_SPHERE_TRIANGLE_DETECTOR_H
     17#define BT_SPHERE_TRIANGLE_DETECTOR_H
    1818
    1919#include "BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h"
     
    4848       
    4949};
    50 #endif //SPHERE_TRIANGLE_DETECTOR_H
     50#endif //BT_SPHERE_TRIANGLE_DETECTOR_H
    5151
  • code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btBox2dBox2dCollisionAlgorithm.h

    r8351 r8393  
    1414*/
    1515
    16 #ifndef BOX_2D_BOX_2D__COLLISION_ALGORITHM_H
    17 #define BOX_2D_BOX_2D__COLLISION_ALGORITHM_H
     16#ifndef BT_BOX_2D_BOX_2D__COLLISION_ALGORITHM_H
     17#define BT_BOX_2D_BOX_2D__COLLISION_ALGORITHM_H
    1818
    1919#include "BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.h"
     
    6363};
    6464
    65 #endif //BOX_2D_BOX_2D__COLLISION_ALGORITHM_H
     65#endif //BT_BOX_2D_BOX_2D__COLLISION_ALGORITHM_H
    6666
  • code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btBoxBoxCollisionAlgorithm.h

    r5781 r8393  
    1414*/
    1515
    16 #ifndef BOX_BOX__COLLISION_ALGORITHM_H
    17 #define BOX_BOX__COLLISION_ALGORITHM_H
     16#ifndef BT_BOX_BOX__COLLISION_ALGORITHM_H
     17#define BT_BOX_BOX__COLLISION_ALGORITHM_H
    1818
    1919#include "btActivatingCollisionAlgorithm.h"
     
    6363};
    6464
    65 #endif //BOX_BOX__COLLISION_ALGORITHM_H
     65#endif //BT_BOX_BOX__COLLISION_ALGORITHM_H
    6666
  • code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btBoxBoxDetector.h

    r5781 r8393  
    17173. This notice may not be removed or altered from any source distribution.
    1818*/
    19 #ifndef BOX_BOX_DETECTOR_H
    20 #define BOX_BOX_DETECTOR_H
     19#ifndef BT_BOX_BOX_DETECTOR_H
     20#define BT_BOX_BOX_DETECTOR_H
    2121
    2222
  • code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btCollisionConfiguration.h

    r5781 r8393  
    1616#ifndef BT_COLLISION_CONFIGURATION
    1717#define BT_COLLISION_CONFIGURATION
     18
    1819struct btCollisionAlgorithmCreateFunc;
    1920
  • code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btCollisionCreateFunc.h

    r5781 r8393  
    1414*/
    1515
    16 #ifndef COLLISION_CREATE_FUNC
    17 #define COLLISION_CREATE_FUNC
     16#ifndef BT_COLLISION_CREATE_FUNC
     17#define BT_COLLISION_CREATE_FUNC
    1818
    1919#include "LinearMath/btAlignedObjectArray.h"
     
    4242        }
    4343};
    44 #endif //COLLISION_CREATE_FUNC
     44#endif //BT_COLLISION_CREATE_FUNC
    4545
  • code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btCollisionDispatcher.cpp

    r8351 r8393  
    9393        } else
    9494        {
    95                 mem = btAlignedAlloc(sizeof(btPersistentManifold),16);
    96 
     95                //we got a pool memory overflow, by default we fallback to dynamically allocate memory. If we require a contiguous contact pool then assert.
     96                if ((m_dispatcherFlags&CD_DISABLE_CONTACTPOOL_DYNAMIC_ALLOCATION)==0)
     97                {
     98                        mem = btAlignedAlloc(sizeof(btPersistentManifold),16);
     99                } else
     100                {
     101                        btAssert(0);
     102                        //make sure to increase the m_defaultMaxPersistentManifoldPoolSize in the btDefaultCollisionConstructionInfo/btDefaultCollisionConfiguration
     103                        return 0;
     104                }
    97105        }
    98106        btPersistentManifold* manifold = new(mem) btPersistentManifold (body0,body1,0,contactBreakingThreshold,contactProcessingThreshold);
     
    173181        {
    174182                //broadphase filtering already deals with this
    175                 if ((body0->isStaticObject() || body0->isKinematicObject()) &&
    176                         (body1->isStaticObject() || body1->isKinematicObject()))
     183                if (body0->isStaticOrKinematicObject() && body1->isStaticOrKinematicObject())
    177184                {
    178185                        m_dispatcherFlags |= btCollisionDispatcher::CD_STATIC_STATIC_REPORTED;
  • code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btCollisionDispatcher.h

    r8351 r8393  
    1414*/
    1515
    16 #ifndef COLLISION__DISPATCHER_H
    17 #define COLLISION__DISPATCHER_H
     16#ifndef BT_COLLISION__DISPATCHER_H
     17#define BT_COLLISION__DISPATCHER_H
    1818
    1919#include "BulletCollision/BroadphaseCollision/btDispatcher.h"
     
    4343class btCollisionDispatcher : public btDispatcher
    4444{
     45
     46protected:
     47
    4548        int             m_dispatcherFlags;
    46        
     49
    4750        btAlignedObjectArray<btPersistentManifold*>     m_manifoldsPtr;
    4851
     
    6568        {
    6669                CD_STATIC_STATIC_REPORTED = 1,
    67                 CD_USE_RELATIVE_CONTACT_BREAKING_THRESHOLD = 2
     70                CD_USE_RELATIVE_CONTACT_BREAKING_THRESHOLD = 2,
     71                CD_DISABLE_CONTACTPOOL_DYNAMIC_ALLOCATION = 4
    6872        };
    6973
     
    7579        void    setDispatcherFlags(int flags)
    7680        {
    77         (void) flags;
    78                 m_dispatcherFlags = 0;
     81                m_dispatcherFlags = flags;
    7982        }
    8083
     
    154157        }
    155158
     159        virtual btPoolAllocator*        getInternalManifoldPool()
     160        {
     161                return m_persistentManifoldPoolAllocator;
     162        }
     163
     164        virtual const btPoolAllocator*  getInternalManifoldPool() const
     165        {
     166                return m_persistentManifoldPoolAllocator;
     167        }
     168
    156169};
    157170
    158 #endif //COLLISION__DISPATCHER_H
     171#endif //BT_COLLISION__DISPATCHER_H
    159172
  • code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btCollisionObject.h

    r8351 r8393  
    1414*/
    1515
    16 #ifndef COLLISION_OBJECT_H
    17 #define COLLISION_OBJECT_H
     16#ifndef BT_COLLISION_OBJECT_H
     17#define BT_COLLISION_OBJECT_H
    1818
    1919#include "LinearMath/btTransform.h"
     
    522522
    523523
    524 #endif //COLLISION_OBJECT_H
     524#endif //BT_COLLISION_OBJECT_H
  • code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.cpp

    r8351 r8393  
    2929#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
    3030#include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h"
     31#include "BulletCollision/BroadphaseCollision/btDbvt.h"
    3132#include "LinearMath/btAabbUtil2.h"
    3233#include "LinearMath/btQuickprof.h"
    3334#include "LinearMath/btStackAlloc.h"
    3435#include "LinearMath/btSerializer.h"
     36#include "BulletCollision/CollisionShapes/btConvexPolyhedron.h"
     37
     38//#define DISABLE_DBVT_COMPOUNDSHAPE_RAYCAST_ACCELERATION
     39
    3540
    3641//#define USE_BRUTEFORCE_RAYBROADPHASE 1
     
    151156        maxAabb += contactThreshold;
    152157
     158        if(getDispatchInfo().m_useContinuous && colObj->getInternalType()==btCollisionObject::CO_RIGID_BODY)
     159        {
     160                btVector3 minAabb2,maxAabb2;
     161                colObj->getCollisionShape()->getAabb(colObj->getInterpolationWorldTransform(),minAabb2,maxAabb2);
     162                minAabb2 -= contactThreshold;
     163                maxAabb2 += contactThreshold;
     164                minAabb.setMin(minAabb2);
     165                maxAabb.setMax(maxAabb2);
     166        }
     167
    153168        btBroadphaseInterface* bp = (btBroadphaseInterface*)m_broadphasePairCache;
    154169
     
    421436                } else {
    422437                        //                      BT_PROFILE("rayTestCompound");
    423                         ///@todo: use AABB tree or other BVH acceleration structure, see btDbvt
    424438                        if (collisionShape->isCompound())
    425439                        {
     440                                struct LocalInfoAdder2 : public RayResultCallback
     441                                {
     442                                        RayResultCallback* m_userCallback;
     443                                        int m_i;
     444                                       
     445                                        LocalInfoAdder2 (int i, RayResultCallback *user)
     446                                                : m_userCallback(user), m_i(i)
     447                                        {
     448                                                m_closestHitFraction = m_userCallback->m_closestHitFraction;
     449                                        }
     450                                        virtual bool needsCollision(btBroadphaseProxy* p) const
     451                                        {
     452                                                return m_userCallback->needsCollision(p);
     453                                        }
     454
     455                                        virtual btScalar addSingleResult (btCollisionWorld::LocalRayResult &r, bool b)
     456                                        {
     457                                                btCollisionWorld::LocalShapeInfo shapeInfo;
     458                                                shapeInfo.m_shapePart = -1;
     459                                                shapeInfo.m_triangleIndex = m_i;
     460                                                if (r.m_localShapeInfo == NULL)
     461                                                        r.m_localShapeInfo = &shapeInfo;
     462
     463                                                const btScalar result = m_userCallback->addSingleResult(r, b);
     464                                                m_closestHitFraction = m_userCallback->m_closestHitFraction;
     465                                                return result;
     466                                        }
     467                                };
     468                               
     469                                struct RayTester : btDbvt::ICollide
     470                                {
     471                                        btCollisionObject* m_collisionObject;
     472                                        const btCompoundShape* m_compoundShape;
     473                                        const btTransform& m_colObjWorldTransform;
     474                                        const btTransform& m_rayFromTrans;
     475                                        const btTransform& m_rayToTrans;
     476                                        RayResultCallback& m_resultCallback;
     477                                       
     478                                        RayTester(btCollisionObject* collisionObject,
     479                                                        const btCompoundShape* compoundShape,
     480                                                        const btTransform& colObjWorldTransform,
     481                                                        const btTransform& rayFromTrans,
     482                                                        const btTransform& rayToTrans,
     483                                                        RayResultCallback& resultCallback):
     484                                                m_collisionObject(collisionObject),
     485                                                m_compoundShape(compoundShape),
     486                                                m_colObjWorldTransform(colObjWorldTransform),
     487                                                m_rayFromTrans(rayFromTrans),
     488                                                m_rayToTrans(rayToTrans),
     489                                                m_resultCallback(resultCallback)
     490                                        {
     491                                               
     492                                        }
     493                                       
     494                                        void Process(int i)
     495                                        {
     496                                                const btCollisionShape* childCollisionShape = m_compoundShape->getChildShape(i);
     497                                                const btTransform& childTrans = m_compoundShape->getChildTransform(i);
     498                                                btTransform childWorldTrans = m_colObjWorldTransform * childTrans;
     499                                               
     500                                                // replace collision shape so that callback can determine the triangle
     501                                                btCollisionShape* saveCollisionShape = m_collisionObject->getCollisionShape();
     502                                                m_collisionObject->internalSetTemporaryCollisionShape((btCollisionShape*)childCollisionShape);
     503
     504                                                LocalInfoAdder2 my_cb(i, &m_resultCallback);
     505
     506                                                rayTestSingle(
     507                                                        m_rayFromTrans,
     508                                                        m_rayToTrans,
     509                                                        m_collisionObject,
     510                                                        childCollisionShape,
     511                                                        childWorldTrans,
     512                                                        my_cb);
     513                                               
     514                                                // restore
     515                                                m_collisionObject->internalSetTemporaryCollisionShape(saveCollisionShape);
     516                                        }
     517                                       
     518                                        void Process(const btDbvtNode* leaf)
     519                                        {
     520                                                Process(leaf->dataAsInt);
     521                                        }
     522                                };
     523                               
    426524                                const btCompoundShape* compoundShape = static_cast<const btCompoundShape*>(collisionShape);
    427                                 int i=0;
    428                                 for (i=0;i<compoundShape->getNumChildShapes();i++)
    429                                 {
    430                                         btTransform childTrans = compoundShape->getChildTransform(i);
    431                                         const btCollisionShape* childCollisionShape = compoundShape->getChildShape(i);
    432                                         btTransform childWorldTrans = colObjWorldTransform * childTrans;
    433                                         // replace collision shape so that callback can determine the triangle
    434                                         btCollisionShape* saveCollisionShape = collisionObject->getCollisionShape();
    435                                         collisionObject->internalSetTemporaryCollisionShape((btCollisionShape*)childCollisionShape);
    436                     struct LocalInfoAdder2 : public RayResultCallback {
    437                                                 RayResultCallback* m_userCallback;
    438                                                 int m_i;
    439                         LocalInfoAdder2 (int i, RayResultCallback *user)
    440                                                         : m_userCallback(user),
    441                                                         m_i(i)
    442                                                 {
    443                                                         m_closestHitFraction = m_userCallback->m_closestHitFraction;
    444                                                 }
    445                                                 virtual btScalar addSingleResult (btCollisionWorld::LocalRayResult &r, bool b)
    446                             {
    447                                     btCollisionWorld::LocalShapeInfo    shapeInfo;
    448                                     shapeInfo.m_shapePart = -1;
    449                                     shapeInfo.m_triangleIndex = m_i;
    450                                     if (r.m_localShapeInfo == NULL)
    451                                         r.m_localShapeInfo = &shapeInfo;
    452 
    453                                                                         const btScalar result = m_userCallback->addSingleResult(r, b);
    454                                                                         m_closestHitFraction = m_userCallback->m_closestHitFraction;
    455                                                                         return result;
    456                             }
    457                     };
    458 
    459                     LocalInfoAdder2 my_cb(i, &resultCallback);
    460 
    461                                         rayTestSingle(rayFromTrans,rayToTrans,
    462                                                 collisionObject,
    463                                                 childCollisionShape,
    464                                                 childWorldTrans,
    465                                                 my_cb);
    466                                         // restore
    467                                         collisionObject->internalSetTemporaryCollisionShape(saveCollisionShape);
     525                                const btDbvt* dbvt = compoundShape->getDynamicAabbTree();
     526
     527
     528                                RayTester rayCB(
     529                                        collisionObject,
     530                                        compoundShape,
     531                                        colObjWorldTransform,
     532                                        rayFromTrans,
     533                                        rayToTrans,
     534                                        resultCallback);
     535#ifndef DISABLE_DBVT_COMPOUNDSHAPE_RAYCAST_ACCELERATION
     536                                if (dbvt)
     537                                {
     538                                        btVector3 localRayFrom = colObjWorldTransform.inverseTimes(rayFromTrans).getOrigin();
     539                                        btVector3 localRayTo = colObjWorldTransform.inverseTimes(rayToTrans).getOrigin();
     540                                        btDbvt::rayTest(dbvt->m_root, localRayFrom , localRayTo, rayCB);
     541                                }
     542                                else
     543#endif //DISABLE_DBVT_COMPOUNDSHAPE_RAYCAST_ACCELERATION
     544                                {
     545                                        for (int i = 0, n = compoundShape->getNumChildShapes(); i < n; ++i)
     546                                        {
     547                                                rayCB.Process(i);
     548                                        }       
    468549                                }
    469550                        }
     
    577658                                BridgeTriangleConvexcastCallback tccb(castShape, convexFromTrans,convexToTrans,&resultCallback,collisionObject,triangleMesh, colObjWorldTransform);
    578659                                tccb.m_hitFraction = resultCallback.m_closestHitFraction;
     660                                tccb.m_allowedPenetration = allowedPenetration;
    579661                                btVector3 boxMinLocal, boxMaxLocal;
    580662                                castShape->getAabb(rotationXform, boxMinLocal, boxMaxLocal);
     
    582664                        } else
    583665                        {
    584                                 //BT_PROFILE("convexSweepConcave");
    585                                 btConcaveShape* concaveShape = (btConcaveShape*)collisionShape;
    586                                 btTransform worldTocollisionObject = colObjWorldTransform.inverse();
    587                                 btVector3 convexFromLocal = worldTocollisionObject * convexFromTrans.getOrigin();
    588                                 btVector3 convexToLocal = worldTocollisionObject * convexToTrans.getOrigin();
    589                                 // rotation of box in local mesh space = MeshRotation^-1 * ConvexToRotation
    590                                 btTransform rotationXform = btTransform(worldTocollisionObject.getBasis() * convexToTrans.getBasis());
    591 
    592                                 //ConvexCast::CastResult
    593                                 struct BridgeTriangleConvexcastCallback : public btTriangleConvexcastCallback
    594                                 {
    595                                         btCollisionWorld::ConvexResultCallback* m_resultCallback;
    596                                         btCollisionObject*      m_collisionObject;
    597                                         btConcaveShape* m_triangleMesh;
    598 
    599                                         BridgeTriangleConvexcastCallback(const btConvexShape* castShape, const btTransform& from,const btTransform& to,
    600                                                 btCollisionWorld::ConvexResultCallback* resultCallback, btCollisionObject* collisionObject,btConcaveShape*      triangleMesh, const btTransform& triangleToWorld):
    601                                         btTriangleConvexcastCallback(castShape, from,to, triangleToWorld, triangleMesh->getMargin()),
    602                                                 m_resultCallback(resultCallback),
    603                                                 m_collisionObject(collisionObject),
    604                                                 m_triangleMesh(triangleMesh)
    605                                         {
     666                                if (collisionShape->getShapeType()==STATIC_PLANE_PROXYTYPE)
     667                                {
     668                                        btConvexCast::CastResult castResult;
     669                                        castResult.m_allowedPenetration = allowedPenetration;
     670                                        castResult.m_fraction = resultCallback.m_closestHitFraction;
     671                                        btStaticPlaneShape* planeShape = (btStaticPlaneShape*) collisionShape;
     672                                        btContinuousConvexCollision convexCaster1(castShape,planeShape);
     673                                        btConvexCast* castPtr = &convexCaster1;
     674
     675                                        if (castPtr->calcTimeOfImpact(convexFromTrans,convexToTrans,colObjWorldTransform,colObjWorldTransform,castResult))
     676                                        {
     677                                                //add hit
     678                                                if (castResult.m_normal.length2() > btScalar(0.0001))
     679                                                {
     680                                                        if (castResult.m_fraction < resultCallback.m_closestHitFraction)
     681                                                        {
     682                                                                castResult.m_normal.normalize();
     683                                                                btCollisionWorld::LocalConvexResult localConvexResult
     684                                                                        (
     685                                                                        collisionObject,
     686                                                                        0,
     687                                                                        castResult.m_normal,
     688                                                                        castResult.m_hitPoint,
     689                                                                        castResult.m_fraction
     690                                                                        );
     691
     692                                                                bool normalInWorldSpace = true;
     693                                                                resultCallback.addSingleResult(localConvexResult, normalInWorldSpace);
     694                                                        }
     695                                                }
    606696                                        }
    607697
    608 
    609                                         virtual btScalar reportHit(const btVector3& hitNormalLocal, const btVector3& hitPointLocal, btScalar hitFraction, int partId, int triangleIndex )
    610                                         {
    611                                                 btCollisionWorld::LocalShapeInfo        shapeInfo;
    612                                                 shapeInfo.m_shapePart = partId;
    613                                                 shapeInfo.m_triangleIndex = triangleIndex;
    614                                                 if (hitFraction <= m_resultCallback->m_closestHitFraction)
     698                                } else
     699                                {
     700                                        //BT_PROFILE("convexSweepConcave");
     701                                        btConcaveShape* concaveShape = (btConcaveShape*)collisionShape;
     702                                        btTransform worldTocollisionObject = colObjWorldTransform.inverse();
     703                                        btVector3 convexFromLocal = worldTocollisionObject * convexFromTrans.getOrigin();
     704                                        btVector3 convexToLocal = worldTocollisionObject * convexToTrans.getOrigin();
     705                                        // rotation of box in local mesh space = MeshRotation^-1 * ConvexToRotation
     706                                        btTransform rotationXform = btTransform(worldTocollisionObject.getBasis() * convexToTrans.getBasis());
     707
     708                                        //ConvexCast::CastResult
     709                                        struct BridgeTriangleConvexcastCallback : public btTriangleConvexcastCallback
     710                                        {
     711                                                btCollisionWorld::ConvexResultCallback* m_resultCallback;
     712                                                btCollisionObject*      m_collisionObject;
     713                                                btConcaveShape* m_triangleMesh;
     714
     715                                                BridgeTriangleConvexcastCallback(const btConvexShape* castShape, const btTransform& from,const btTransform& to,
     716                                                        btCollisionWorld::ConvexResultCallback* resultCallback, btCollisionObject* collisionObject,btConcaveShape*      triangleMesh, const btTransform& triangleToWorld):
     717                                                btTriangleConvexcastCallback(castShape, from,to, triangleToWorld, triangleMesh->getMargin()),
     718                                                        m_resultCallback(resultCallback),
     719                                                        m_collisionObject(collisionObject),
     720                                                        m_triangleMesh(triangleMesh)
    615721                                                {
    616 
    617                                                         btCollisionWorld::LocalConvexResult convexResult
    618                                                                 (m_collisionObject,
    619                                                                 &shapeInfo,
    620                                                                 hitNormalLocal,
    621                                                                 hitPointLocal,
    622                                                                 hitFraction);
    623 
    624                                                         bool    normalInWorldSpace = false;
    625 
    626                                                         return m_resultCallback->addSingleResult(convexResult,normalInWorldSpace);
    627722                                                }
    628                                                 return hitFraction;
    629                                         }
    630 
    631                                 };
    632 
    633                                 BridgeTriangleConvexcastCallback tccb(castShape, convexFromTrans,convexToTrans,&resultCallback,collisionObject,concaveShape, colObjWorldTransform);
    634                                 tccb.m_hitFraction = resultCallback.m_closestHitFraction;
    635                                 btVector3 boxMinLocal, boxMaxLocal;
    636                                 castShape->getAabb(rotationXform, boxMinLocal, boxMaxLocal);
    637 
    638                                 btVector3 rayAabbMinLocal = convexFromLocal;
    639                                 rayAabbMinLocal.setMin(convexToLocal);
    640                                 btVector3 rayAabbMaxLocal = convexFromLocal;
    641                                 rayAabbMaxLocal.setMax(convexToLocal);
    642                                 rayAabbMinLocal += boxMinLocal;
    643                                 rayAabbMaxLocal += boxMaxLocal;
    644                                 concaveShape->processAllTriangles(&tccb,rayAabbMinLocal,rayAabbMaxLocal);
     723
     724
     725                                                virtual btScalar reportHit(const btVector3& hitNormalLocal, const btVector3& hitPointLocal, btScalar hitFraction, int partId, int triangleIndex )
     726                                                {
     727                                                        btCollisionWorld::LocalShapeInfo        shapeInfo;
     728                                                        shapeInfo.m_shapePart = partId;
     729                                                        shapeInfo.m_triangleIndex = triangleIndex;
     730                                                        if (hitFraction <= m_resultCallback->m_closestHitFraction)
     731                                                        {
     732
     733                                                                btCollisionWorld::LocalConvexResult convexResult
     734                                                                        (m_collisionObject,
     735                                                                        &shapeInfo,
     736                                                                        hitNormalLocal,
     737                                                                        hitPointLocal,
     738                                                                        hitFraction);
     739
     740                                                                bool    normalInWorldSpace = false;
     741
     742                                                                return m_resultCallback->addSingleResult(convexResult,normalInWorldSpace);
     743                                                        }
     744                                                        return hitFraction;
     745                                                }
     746
     747                                        };
     748
     749                                        BridgeTriangleConvexcastCallback tccb(castShape, convexFromTrans,convexToTrans,&resultCallback,collisionObject,concaveShape, colObjWorldTransform);
     750                                        tccb.m_hitFraction = resultCallback.m_closestHitFraction;
     751                                        tccb.m_allowedPenetration = allowedPenetration;
     752                                        btVector3 boxMinLocal, boxMaxLocal;
     753                                        castShape->getAabb(rotationXform, boxMinLocal, boxMaxLocal);
     754
     755                                        btVector3 rayAabbMinLocal = convexFromLocal;
     756                                        rayAabbMinLocal.setMin(convexToLocal);
     757                                        btVector3 rayAabbMaxLocal = convexFromLocal;
     758                                        rayAabbMaxLocal.setMax(convexToLocal);
     759                                        rayAabbMinLocal += boxMinLocal;
     760                                        rayAabbMaxLocal += boxMaxLocal;
     761                                        concaveShape->processAllTriangles(&tccb,rayAabbMinLocal,rayAabbMaxLocal);
     762                                }
    645763                        }
    646764                } else {
     
    667785                                                        {
    668786                                                                m_closestHitFraction = m_userCallback->m_closestHitFraction;
     787                                                        }
     788                                                        virtual bool needsCollision(btBroadphaseProxy* p) const
     789                                                        {
     790                                                                return m_userCallback->needsCollision(p);
    669791                                                        }
    670792                            virtual btScalar addSingleResult (btCollisionWorld::LocalConvexResult&      r,      bool b)
     
    11521274
    11531275                                int upAxis = capsuleShape->getUpAxis();
    1154 
    1155 
    1156                                 btVector3 capStart(0.f,0.f,0.f);
    1157                                 capStart[upAxis] = -halfHeight;
    1158 
    1159                                 btVector3 capEnd(0.f,0.f,0.f);
    1160                                 capEnd[upAxis] = halfHeight;
    1161 
    1162                                 // Draw the ends
    1163                                 {
    1164 
    1165                                         btTransform childTransform = worldTransform;
    1166                                         childTransform.getOrigin() = worldTransform * capStart;
    1167                                         getDebugDrawer()->drawSphere(radius, childTransform, color);
    1168                                 }
    1169 
    1170                                 {
    1171                                         btTransform childTransform = worldTransform;
    1172                                         childTransform.getOrigin() = worldTransform * capEnd;
    1173                                         getDebugDrawer()->drawSphere(radius, childTransform, color);
    1174                                 }
    1175 
    1176                                 // Draw some additional lines
    1177                                 btVector3 start = worldTransform.getOrigin();
    1178 
    1179 
    1180                                 capStart[(upAxis+1)%3] = radius;
    1181                                 capEnd[(upAxis+1)%3] = radius;
    1182                                 getDebugDrawer()->drawLine(start+worldTransform.getBasis() * capStart,start+worldTransform.getBasis() * capEnd, color);
    1183                                 capStart[(upAxis+1)%3] = -radius;
    1184                                 capEnd[(upAxis+1)%3] = -radius;
    1185                                 getDebugDrawer()->drawLine(start+worldTransform.getBasis() * capStart,start+worldTransform.getBasis() * capEnd, color);
    1186 
    1187                                 capStart[(upAxis+1)%3] = 0.f;
    1188                                 capEnd[(upAxis+1)%3] = 0.f;
    1189 
    1190                                 capStart[(upAxis+2)%3] = radius;
    1191                                 capEnd[(upAxis+2)%3] = radius;
    1192                                 getDebugDrawer()->drawLine(start+worldTransform.getBasis() * capStart,start+worldTransform.getBasis() * capEnd, color);
    1193                                 capStart[(upAxis+2)%3] = -radius;
    1194                                 capEnd[(upAxis+2)%3] = -radius;
    1195                                 getDebugDrawer()->drawLine(start+worldTransform.getBasis() * capStart,start+worldTransform.getBasis() * capEnd, color);
    1196 
    1197 
     1276                                getDebugDrawer()->drawCapsule(radius, halfHeight, upAxis, worldTransform, color);
    11981277                                break;
    11991278                        }
     
    12031282                                btScalar radius = coneShape->getRadius();//+coneShape->getMargin();
    12041283                                btScalar height = coneShape->getHeight();//+coneShape->getMargin();
    1205                                 btVector3 start = worldTransform.getOrigin();
    12061284
    12071285                                int upAxis= coneShape->getConeUpIndex();
    1208 
    1209 
    1210                                 btVector3       offsetHeight(0,0,0);
    1211                                 offsetHeight[upAxis] = height * btScalar(0.5);
    1212                                 btVector3       offsetRadius(0,0,0);
    1213                                 offsetRadius[(upAxis+1)%3] = radius;
    1214                                 btVector3       offset2Radius(0,0,0);
    1215                                 offset2Radius[(upAxis+2)%3] = radius;
    1216 
    1217                                 getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight),start+worldTransform.getBasis() * (-offsetHeight+offsetRadius),color);
    1218                                 getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight),start+worldTransform.getBasis() * (-offsetHeight-offsetRadius),color);
    1219                                 getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight),start+worldTransform.getBasis() * (-offsetHeight+offset2Radius),color);
    1220                                 getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight),start+worldTransform.getBasis() * (-offsetHeight-offset2Radius),color);
    1221 
    1222                                 // Drawing the base of the cone
    1223                                 btVector3 yaxis(0,0,0);
    1224                                 yaxis[upAxis] = btScalar(1.0);
    1225                                 btVector3 xaxis(0,0,0);
    1226                                 xaxis[(upAxis+1)%3] = btScalar(1.0);
    1227                                 getDebugDrawer()->drawArc(start-worldTransform.getBasis()*(offsetHeight),worldTransform.getBasis()*yaxis,worldTransform.getBasis()*xaxis,radius,radius,0,SIMD_2_PI,color,false,10.0);
    1228                 break;
     1286                                getDebugDrawer()->drawCone(radius, height, upAxis, worldTransform, color);
     1287                                break;
    12291288
    12301289                        }
     
    12351294                                btScalar radius = cylinder->getRadius();
    12361295                                btScalar halfHeight = cylinder->getHalfExtentsWithMargin()[upAxis];
    1237                                 btVector3 start = worldTransform.getOrigin();
    1238                                 btVector3       offsetHeight(0,0,0);
    1239                                 offsetHeight[upAxis] = halfHeight;
    1240                                 btVector3       offsetRadius(0,0,0);
    1241                                 offsetRadius[(upAxis+1)%3] = radius;
    1242                                 getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight+offsetRadius),start+worldTransform.getBasis() * (-offsetHeight+offsetRadius),color);
    1243                                 getDebugDrawer()->drawLine(start+worldTransform.getBasis() * (offsetHeight-offsetRadius),start+worldTransform.getBasis() * (-offsetHeight-offsetRadius),color);
    1244 
    1245                                 // Drawing top and bottom caps of the cylinder
    1246                                 btVector3 yaxis(0,0,0);
    1247                                 yaxis[upAxis] = btScalar(1.0);
    1248                                 btVector3 xaxis(0,0,0);
    1249                                 xaxis[(upAxis+1)%3] = btScalar(1.0);
    1250                                 getDebugDrawer()->drawArc(start-worldTransform.getBasis()*(offsetHeight),worldTransform.getBasis()*yaxis,worldTransform.getBasis()*xaxis,radius,radius,0,SIMD_2_PI,color,false,btScalar(10.0));
    1251                                 getDebugDrawer()->drawArc(start+worldTransform.getBasis()*(offsetHeight),worldTransform.getBasis()*yaxis,worldTransform.getBasis()*xaxis,radius,radius,0,SIMD_2_PI,color,false,btScalar(10.0));
     1296                                getDebugDrawer()->drawCylinder(radius, halfHeight, upAxis, worldTransform, color);
    12521297                                break;
    12531298                        }
     
    12581303                                btScalar planeConst = staticPlaneShape->getPlaneConstant();
    12591304                                const btVector3& planeNormal = staticPlaneShape->getPlaneNormal();
    1260                                 btVector3 planeOrigin = planeNormal * planeConst;
    1261                                 btVector3 vec0,vec1;
    1262                                 btPlaneSpace1(planeNormal,vec0,vec1);
    1263                                 btScalar vecLen = 100.f;
    1264                                 btVector3 pt0 = planeOrigin + vec0*vecLen;
    1265                                 btVector3 pt1 = planeOrigin - vec0*vecLen;
    1266                                 btVector3 pt2 = planeOrigin + vec1*vecLen;
    1267                                 btVector3 pt3 = planeOrigin - vec1*vecLen;
    1268                                 getDebugDrawer()->drawLine(worldTransform*pt0,worldTransform*pt1,color);
    1269                                 getDebugDrawer()->drawLine(worldTransform*pt2,worldTransform*pt3,color);
     1305                                getDebugDrawer()->drawPlane(planeNormal, planeConst,worldTransform, color);
    12701306                                break;
    12711307
     
    13051341
    13061342                                        int i;
    1307                                         for (i=0;i<polyshape->getNumEdges();i++)
    1308                                         {
    1309                                                 btVector3 a,b;
    1310                                                 polyshape->getEdge(i,a,b);
    1311                                                 btVector3 wa = worldTransform * a;
    1312                                                 btVector3 wb = worldTransform * b;
    1313                                                 getDebugDrawer()->drawLine(wa,wb,color);
    1314 
     1343                                        if (polyshape->getConvexPolyhedron())
     1344                                        {
     1345                                                const btConvexPolyhedron* poly = polyshape->getConvexPolyhedron();
     1346                                                for (i=0;i<poly->m_faces.size();i++)
     1347                                                {
     1348                                                        btVector3 centroid(0,0,0);
     1349                                                        int numVerts = poly->m_faces[i].m_indices.size();
     1350                                                        if (numVerts)
     1351                                                        {
     1352                                                                int lastV = poly->m_faces[i].m_indices[numVerts-1];
     1353                                                                for (int v=0;v<poly->m_faces[i].m_indices.size();v++)
     1354                                                                {
     1355                                                                        int curVert = poly->m_faces[i].m_indices[v];
     1356                                                                        centroid+=poly->m_vertices[curVert];
     1357                                                                        getDebugDrawer()->drawLine(worldTransform*poly->m_vertices[lastV],worldTransform*poly->m_vertices[curVert],color);
     1358                                                                        lastV = curVert;
     1359                                                                }
     1360                                                        }
     1361                                                        centroid*= 1./btScalar(numVerts);
     1362
     1363                                                        btVector3 normalColor(1,1,0);
     1364                                                        btVector3 faceNormal(poly->m_faces[i].m_plane[0],poly->m_faces[i].m_plane[1],poly->m_faces[i].m_plane[2]);
     1365                                                        getDebugDrawer()->drawLine(worldTransform*centroid,worldTransform*(centroid+faceNormal),normalColor);
     1366                                                       
     1367                                                       
     1368                                                }
     1369
     1370                                               
     1371                                        } else
     1372                                        {
     1373                                                for (i=0;i<polyshape->getNumEdges();i++)
     1374                                                {
     1375                                                        btVector3 a,b;
     1376                                                        polyshape->getEdge(i,a,b);
     1377                                                        btVector3 wa = worldTransform * a;
     1378                                                        btVector3 wb = worldTransform * b;
     1379                                                        getDebugDrawer()->drawLine(wa,wb,color);
     1380                                                }
    13151381                                        }
    13161382
     
    13811447                                        btVector3 colorvec(1,0,0);
    13821448                                        colObj->getCollisionShape()->getAabb(colObj->getWorldTransform(), minAabb,maxAabb);
     1449                                        btVector3 contactThreshold(gContactBreakingThreshold,gContactBreakingThreshold,gContactBreakingThreshold);
     1450                                        minAabb -= contactThreshold;
     1451                                        maxAabb += contactThreshold;
     1452
     1453                                        btVector3 minAabb2,maxAabb2;
     1454
     1455                                        if(colObj->getInternalType()==btCollisionObject::CO_RIGID_BODY)
     1456                                        {
     1457                                                colObj->getCollisionShape()->getAabb(colObj->getInterpolationWorldTransform(),minAabb2,maxAabb2);
     1458                                                minAabb2 -= contactThreshold;
     1459                                                maxAabb2 += contactThreshold;
     1460                                                minAabb.setMin(minAabb2);
     1461                                                maxAabb.setMax(maxAabb2);
     1462                                        }
     1463
    13831464                                        m_debugDrawer->drawAabb(minAabb,maxAabb,colorvec);
    13841465                                }
  • code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.h

    r8351 r8393  
    6363 
    6464
    65 #ifndef COLLISION_WORLD_H
    66 #define COLLISION_WORLD_H
     65#ifndef BT_COLLISION_WORLD_H
     66#define BT_COLLISION_WORLD_H
    6767
    6868class btStackAlloc;
     
    507507
    508508
    509 #endif //COLLISION_WORLD_H
     509#endif //BT_COLLISION_WORLD_H
  • code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.cpp

    r8351 r8393  
    235235                                        }
    236236                                }
    237                                 manifoldArray.clear();
     237                                manifoldArray.resize(0);
    238238                        }
    239239                }
  • code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btCompoundCollisionAlgorithm.h

    r5781 r8393  
    1414*/
    1515
    16 #ifndef COMPOUND_COLLISION_ALGORITHM_H
    17 #define COMPOUND_COLLISION_ALGORITHM_H
     16#ifndef BT_COMPOUND_COLLISION_ALGORITHM_H
     17#define BT_COMPOUND_COLLISION_ALGORITHM_H
    1818
    1919#include "btActivatingCollisionAlgorithm.h"
     
    8484};
    8585
    86 #endif //COMPOUND_COLLISION_ALGORITHM_H
     86#endif //BT_COMPOUND_COLLISION_ALGORITHM_H
  • code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btConvex2dConvex2dAlgorithm.h

    r8351 r8393  
    1414*/
    1515
    16 #ifndef CONVEX_2D_CONVEX_2D_ALGORITHM_H
    17 #define CONVEX_2D_CONVEX_2D_ALGORITHM_H
     16#ifndef BT_CONVEX_2D_CONVEX_2D_ALGORITHM_H
     17#define BT_CONVEX_2D_CONVEX_2D_ALGORITHM_H
    1818
    1919#include "BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.h"
     
    9393};
    9494
    95 #endif //CONVEX_2D_CONVEX_2D_ALGORITHM_H
     95#endif //BT_CONVEX_2D_CONVEX_2D_ALGORITHM_H
  • code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.cpp

    r8351 r8393  
    9292
    9393
    94        
     94#if 0   
    9595        ///debug drawing of the overlapping triangles
    9696        if (m_dispatchInfoPtr && m_dispatchInfoPtr->m_debugDraw && (m_dispatchInfoPtr->m_debugDraw->getDebugMode() &btIDebugDraw::DBG_DrawWireframe ))
     
    101101                m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[1]),tr(triangle[2]),color);
    102102                m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[2]),tr(triangle[0]),color);
    103 
    104                 //btVector3 center = triangle[0] + triangle[1]+triangle[2];
    105                 //center *= btScalar(0.333333);
    106                 //m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[0]),tr(center),color);
    107                 //m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[1]),tr(center),color);
    108                 //m_dispatchInfoPtr->m_debugDraw->drawLine(tr(triangle[2]),tr(center),color);
    109 
    110         }
    111 
    112 
    113         //btCollisionObject* colObj = static_cast<btCollisionObject*>(m_convexProxy->m_clientObject);
     103        }
     104#endif
    114105       
    115106        if (m_convexBody->getCollisionShape()->isConvex())
     
    120111                btCollisionShape* tmpShape = ob->getCollisionShape();
    121112                ob->internalSetTemporaryCollisionShape( &tm );
    122                
     113
    123114                btCollisionAlgorithm* colAlgo = ci.m_dispatcher1->findAlgorithm(m_convexBody,m_triBody,m_manifoldPtr);
    124115
  • code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btConvexConcaveCollisionAlgorithm.h

    r5781 r8393  
    1414*/
    1515
    16 #ifndef CONVEX_CONCAVE_COLLISION_ALGORITHM_H
    17 #define CONVEX_CONCAVE_COLLISION_ALGORITHM_H
     16#ifndef BT_CONVEX_CONCAVE_COLLISION_ALGORITHM_H
     17#define BT_CONVEX_CONCAVE_COLLISION_ALGORITHM_H
    1818
    1919#include "btActivatingCollisionAlgorithm.h"
     
    114114};
    115115
    116 #endif //CONVEX_CONCAVE_COLLISION_ALGORITHM_H
     116#endif //BT_CONVEX_CONCAVE_COLLISION_ALGORITHM_H
  • code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.cpp

    r8351 r8393  
    2727#include "BulletCollision/CollisionShapes/btConvexShape.h"
    2828#include "BulletCollision/CollisionShapes/btCapsuleShape.h"
     29#include "BulletCollision/CollisionShapes/btTriangleShape.h"
     30
    2931
    3032
     
    4951#include "BulletCollision/NarrowPhaseCollision/btGjkEpa2.h"
    5052#include "BulletCollision/NarrowPhaseCollision/btGjkEpaPenetrationDepthSolver.h"
    51 
     53#include "BulletCollision/NarrowPhaseCollision/btPolyhedralContactClipping.h"
    5254
    5355
     
    332334
    333335
     336
     337
    334338#ifdef USE_SEPDISTANCE_UTIL2
    335339        if (dispatchInfo.m_useConvexConservativeDistanceUtil)
     
    358362#endif //USE_SEPDISTANCE_UTIL2
    359363        {
    360                 if (dispatchInfo.m_convexMaxDistanceUseCPT)
    361                 {
    362                         input.m_maximumDistanceSquared = min0->getMargin() + min1->getMargin() + m_manifoldPtr->getContactProcessingThreshold();
    363                 } else
    364                 {
    365                         input.m_maximumDistanceSquared = min0->getMargin() + min1->getMargin() + m_manifoldPtr->getContactBreakingThreshold();
    366                 }
     364                //if (dispatchInfo.m_convexMaxDistanceUseCPT)
     365                //{
     366                //      input.m_maximumDistanceSquared = min0->getMargin() + min1->getMargin() + m_manifoldPtr->getContactProcessingThreshold();
     367                //} else
     368                //{
     369                input.m_maximumDistanceSquared = min0->getMargin() + min1->getMargin() + m_manifoldPtr->getContactBreakingThreshold();
     370//              }
     371
    367372                input.m_maximumDistanceSquared*= input.m_maximumDistanceSquared;
    368373        }
     
    372377        input.m_transformB = body1->getWorldTransform();
    373378
    374         gjkPairDetector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw);
     379
    375380
    376381       
     
    389394        }
    390395#endif //USE_SEPDISTANCE_UTIL2
     396
     397        if (min0->isPolyhedral() && min1->isPolyhedral())
     398        {
     399
     400
     401                struct btDummyResult : public btDiscreteCollisionDetectorInterface::Result
     402                {
     403                        virtual void setShapeIdentifiersA(int partId0,int index0){}
     404                        virtual void setShapeIdentifiersB(int partId1,int index1){}
     405                        virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth)
     406                        {
     407                        }
     408                };
     409               
     410                btDummyResult dummy;
     411
     412
     413                btPolyhedralConvexShape* polyhedronA = (btPolyhedralConvexShape*) min0;
     414                btPolyhedralConvexShape* polyhedronB = (btPolyhedralConvexShape*) min1;
     415                if (polyhedronA->getConvexPolyhedron() && polyhedronB->getConvexPolyhedron())
     416                {
     417
     418
     419                        gjkPairDetector.getClosestPoints(input,dummy,dispatchInfo.m_debugDraw);
     420                       
     421
     422                        btScalar threshold = m_manifoldPtr->getContactBreakingThreshold();
     423
     424                        btScalar minDist = 0.f;
     425                        btVector3 sepNormalWorldSpace;
     426                        bool foundSepAxis  = true;
     427
     428                        if (dispatchInfo.m_enableSatConvex)
     429                        {
     430                                foundSepAxis = btPolyhedralContactClipping::findSeparatingAxis(
     431                                        *polyhedronA->getConvexPolyhedron(), *polyhedronB->getConvexPolyhedron(),
     432                                        body0->getWorldTransform(),
     433                                        body1->getWorldTransform(),
     434                                        sepNormalWorldSpace);
     435                        } else
     436                        {
     437                                sepNormalWorldSpace = gjkPairDetector.getCachedSeparatingAxis().normalized();
     438                                minDist = gjkPairDetector.getCachedSeparatingDistance();
     439                        }
     440                        if (foundSepAxis)
     441                        {
     442//                              printf("sepNormalWorldSpace=%f,%f,%f\n",sepNormalWorldSpace.getX(),sepNormalWorldSpace.getY(),sepNormalWorldSpace.getZ());
     443
     444                                btPolyhedralContactClipping::clipHullAgainstHull(sepNormalWorldSpace, *polyhedronA->getConvexPolyhedron(), *polyhedronB->getConvexPolyhedron(),
     445                                        body0->getWorldTransform(),
     446                                        body1->getWorldTransform(), minDist-threshold, threshold, *resultOut);
     447                               
     448                        }
     449                        if (m_ownManifold)
     450                        {
     451                                resultOut->refreshContactPoints();
     452                        }
     453                        return;
     454
     455                } else
     456                {
     457                        //we can also deal with convex versus triangle (without connectivity data)
     458                        if (polyhedronA->getConvexPolyhedron() && polyhedronB->getShapeType()==TRIANGLE_SHAPE_PROXYTYPE)
     459                        {
     460                                gjkPairDetector.getClosestPoints(input,dummy,dispatchInfo.m_debugDraw);
     461               
     462                                btVector3 sepNormalWorldSpace = gjkPairDetector.getCachedSeparatingAxis().normalized();
     463
     464                                btVertexArray vertices;
     465                                btTriangleShape* tri = (btTriangleShape*)polyhedronB;
     466                                vertices.push_back(     body1->getWorldTransform()*tri->m_vertices1[0]);
     467                                vertices.push_back(     body1->getWorldTransform()*tri->m_vertices1[1]);
     468                                vertices.push_back(     body1->getWorldTransform()*tri->m_vertices1[2]);
     469
     470                                btScalar threshold = m_manifoldPtr->getContactBreakingThreshold();
     471                                btScalar minDist = gjkPairDetector.getCachedSeparatingDistance();
     472                                btPolyhedralContactClipping::clipFaceAgainstHull(sepNormalWorldSpace, *polyhedronA->getConvexPolyhedron(),
     473                                        body0->getWorldTransform(), vertices, minDist-threshold, threshold, *resultOut);
     474                               
     475                               
     476                                if (m_ownManifold)
     477                                {
     478                                        resultOut->refreshContactPoints();
     479                                }
     480                               
     481                                return;
     482                        }
     483                       
     484                }
     485
     486
     487        }
     488       
     489        gjkPairDetector.getClosestPoints(input,*resultOut,dispatchInfo.m_debugDraw);
    391490
    392491        //now perform 'm_numPerturbationIterations' collision queries with the perturbated collision objects
  • code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btConvexConvexAlgorithm.h

    r8351 r8393  
    1414*/
    1515
    16 #ifndef CONVEX_CONVEX_ALGORITHM_H
    17 #define CONVEX_CONVEX_ALGORITHM_H
     16#ifndef BT_CONVEX_CONVEX_ALGORITHM_H
     17#define BT_CONVEX_CONVEX_ALGORITHM_H
    1818
    1919#include "btActivatingCollisionAlgorithm.h"
     
    107107};
    108108
    109 #endif //CONVEX_CONVEX_ALGORITHM_H
     109#endif //BT_CONVEX_CONVEX_ALGORITHM_H
  • code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btConvexPlaneCollisionAlgorithm.h

    r8351 r8393  
    1414*/
    1515
    16 #ifndef CONVEX_PLANE_COLLISION_ALGORITHM_H
    17 #define CONVEX_PLANE_COLLISION_ALGORITHM_H
     16#ifndef BT_CONVEX_PLANE_COLLISION_ALGORITHM_H
     17#define BT_CONVEX_PLANE_COLLISION_ALGORITHM_H
    1818
    1919#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
     
    8181};
    8282
    83 #endif //CONVEX_PLANE_COLLISION_ALGORITHM_H
     83#endif //BT_CONVEX_PLANE_COLLISION_ALGORITHM_H
    8484
  • code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.h

    r5781 r8393  
    1414*/
    1515
    16 #ifndef EMPTY_ALGORITH
    17 #define EMPTY_ALGORITH
     16#ifndef BT_EMPTY_ALGORITH
     17#define BT_EMPTY_ALGORITH
    1818#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
    1919#include "btCollisionCreateFunc.h"
     
    5252} ATTRIBUTE_ALIGNED(16);
    5353
    54 #endif //EMPTY_ALGORITH
     54#endif //BT_EMPTY_ALGORITH
  • code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btInternalEdgeUtility.cpp

    r8351 r8393  
    22
    33#include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h"
     4#include "BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h"
    45#include "BulletCollision/CollisionShapes/btTriangleShape.h"
    56#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
     
    910
    1011//#define DEBUG_INTERNAL_EDGE
    11 
    1212
    1313#ifdef DEBUG_INTERNAL_EDGE
     
    457457                return;
    458458
    459         btBvhTriangleMeshShape* trimesh = (btBvhTriangleMeshShape*)colObj0->getRootCollisionShape();
    460         btTriangleInfoMap* triangleInfoMapPtr = (btTriangleInfoMap*) trimesh->getTriangleInfoMap();
     459        btBvhTriangleMeshShape* trimesh = 0;
     460       
     461        if( colObj0->getRootCollisionShape()->getShapeType() == SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE )
     462           trimesh = ((btScaledBvhTriangleMeshShape*)colObj0->getRootCollisionShape())->getChildShape();
     463   else   
     464           trimesh = (btBvhTriangleMeshShape*)colObj0->getRootCollisionShape();
     465           
     466        btTriangleInfoMap* triangleInfoMapPtr = (btTriangleInfoMap*) trimesh->getTriangleInfoMap();
    461467        if (!triangleInfoMapPtr)
    462468                return;
     
    502508        btVector3 localContactNormalOnB = colObj0->getWorldTransform().getBasis().transpose() * cp.m_normalWorldOnB;
    503509        localContactNormalOnB.normalize();//is this necessary?
    504 
    505         if ((info->m_edgeV0V1Angle)< SIMD_2_PI)
     510       
     511        // Get closest edge
     512        int      bestedge=-1;
     513        float    disttobestedge=BT_LARGE_FLOAT;
     514        //
     515        // Edge 0 -> 1
     516        if (btFabs(info->m_edgeV0V1Angle)< triangleInfoMapPtr->m_maxEdgeAngleThreshold)
     517        {       
     518           btVector3 nearest;
     519           btNearestPointInLineSegment( cp.m_localPointB, v0, v1, nearest );
     520           float     len=(contact-nearest).length();
     521           //
     522           if( len < disttobestedge )
     523           {
     524              bestedge=0;
     525              disttobestedge=len;
     526      }       
     527   }       
     528        // Edge 1 -> 2
     529        if (btFabs(info->m_edgeV1V2Angle)< triangleInfoMapPtr->m_maxEdgeAngleThreshold)
     530        {       
     531           btVector3 nearest;
     532           btNearestPointInLineSegment( cp.m_localPointB, v1, v2, nearest );
     533           float     len=(contact-nearest).length();
     534           //
     535           if( len < disttobestedge )
     536           {
     537              bestedge=1;
     538              disttobestedge=len;
     539      }       
     540   }       
     541        // Edge 2 -> 0
     542        if (btFabs(info->m_edgeV2V0Angle)< triangleInfoMapPtr->m_maxEdgeAngleThreshold)
     543        {       
     544           btVector3 nearest;
     545           btNearestPointInLineSegment( cp.m_localPointB, v2, v0, nearest );
     546           float     len=(contact-nearest).length();
     547           //
     548           if( len < disttobestedge )
     549           {
     550              bestedge=2;
     551              disttobestedge=len;
     552      }       
     553   }           
     554       
     555#ifdef BT_INTERNAL_EDGE_DEBUG_DRAW
     556   btVector3 upfix=tri_normal * btVector3(0.1f,0.1f,0.1f);
     557   btDebugDrawLine(tr * v0 + upfix, tr * v1 + upfix, red );
     558#endif   
     559        if (btFabs(info->m_edgeV0V1Angle)< triangleInfoMapPtr->m_maxEdgeAngleThreshold)
    506560        {
    507561#ifdef BT_INTERNAL_EDGE_DEBUG_DRAW
     
    510564                btScalar len = (contact-nearest).length();
    511565                if(len<triangleInfoMapPtr->m_edgeDistanceThreshold)
     566                if( bestedge==0 )
    512567                {
    513568                        btVector3 edge(v0-v1);
     
    578633#endif //BT_INTERNAL_EDGE_DEBUG_DRAW
    579634
    580         if ((info->m_edgeV1V2Angle)< SIMD_2_PI)
     635#ifdef BT_INTERNAL_EDGE_DEBUG_DRAW
     636   btDebugDrawLine(tr * v1 + upfix, tr * v2 + upfix , green );
     637#endif   
     638
     639        if (btFabs(info->m_edgeV1V2Angle)< triangleInfoMapPtr->m_maxEdgeAngleThreshold)
    581640        {
    582641#ifdef BT_INTERNAL_EDGE_DEBUG_DRAW
     
    588647                btScalar len = (contact-nearest).length();
    589648                if(len<triangleInfoMapPtr->m_edgeDistanceThreshold)
     649                if( bestedge==1 )
    590650                {
    591651                        isNearEdge = true;
     
    659719        btDebugDrawLine(tr*nearest,tr*cp.m_localPointB,blue);
    660720#endif //BT_INTERNAL_EDGE_DEBUG_DRAW
    661 
    662         if ((info->m_edgeV2V0Angle)< SIMD_2_PI)
     721#ifdef BT_INTERNAL_EDGE_DEBUG_DRAW
     722   btDebugDrawLine(tr * v2 + upfix, tr * v0 + upfix , blue );
     723#endif   
     724
     725        if (btFabs(info->m_edgeV2V0Angle)< triangleInfoMapPtr->m_maxEdgeAngleThreshold)
    663726        {
    664727
     
    669732                btScalar len = (contact-nearest).length();
    670733                if(len<triangleInfoMapPtr->m_edgeDistanceThreshold)
     734                if( bestedge==2 )
    671735                {
    672736                        isNearEdge = true;
     
    760824                        } else
    761825                        {
     826                                btVector3 newNormal = tri_normal *frontFacing;
     827                                //if the tri_normal is pointing opposite direction as the current local contact normal, skip it
     828                                btScalar d = newNormal.dot(localContactNormalOnB) ;
     829                                if (d< 0)
     830                                {
     831                                        return;
     832                                }
    762833                                //modify the normal to be the triangle normal (or backfacing normal)
    763                                 cp.m_normalWorldOnB = colObj0->getWorldTransform().getBasis() *(tri_normal *frontFacing);
    764                         }
    765                        
    766                        
     834                                cp.m_normalWorldOnB = colObj0->getWorldTransform().getBasis() *newNormal;
     835                        }
     836                                               
    767837                        // Reproject collision point along normal.
    768838                        cp.m_positionWorldOnB = cp.m_positionWorldOnA - cp.m_normalWorldOnB * cp.m_distance1;
  • code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btManifoldResult.cpp

    r8351 r8393  
    6464        btAssert(m_manifoldPtr);
    6565        //order in manifold needs to match
    66        
    67         if (depth > m_manifoldPtr->getContactBreakingThreshold())
     66
     67//      if (depth > m_manifoldPtr->getContactBreakingThreshold())
     68        if (depth > m_manifoldPtr->getContactProcessingThreshold())
    6869                return;
    6970
  • code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btManifoldResult.h

    r8351 r8393  
    1515
    1616
    17 #ifndef MANIFOLD_RESULT_H
    18 #define MANIFOLD_RESULT_H
     17#ifndef BT_MANIFOLD_RESULT_H
     18#define BT_MANIFOLD_RESULT_H
    1919
    2020class btCollisionObject;
     
    126126};
    127127
    128 #endif //MANIFOLD_RESULT_H
     128#endif //BT_MANIFOLD_RESULT_H
  • code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btSimulationIslandManager.cpp

    r8351 r8393  
    393393
    394394
    395                            bool islandSleeping = false;
     395                           bool islandSleeping = true;
    396396                       
    397397                                        for (endIslandIndex = startIslandIndex;(endIslandIndex<numElem) && (getUnionFind().getElement(endIslandIndex).m_id == islandId);endIslandIndex++)
     
    400400                                                        btCollisionObject* colObj0 = collisionObjects[i];
    401401                                                        m_islandBodies.push_back(colObj0);
    402                                                         if (!colObj0->isActive())
    403                                                                         islandSleeping = true;
     402                                                        if (colObj0->isActive())
     403                                                                        islandSleeping = false;
    404404                                        }
    405405                       
  • code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btSimulationIslandManager.h

    r5781 r8393  
    1414*/
    1515
    16 #ifndef SIMULATION_ISLAND_MANAGER_H
    17 #define SIMULATION_ISLAND_MANAGER_H
     16#ifndef BT_SIMULATION_ISLAND_MANAGER_H
     17#define BT_SIMULATION_ISLAND_MANAGER_H
    1818
    1919#include "BulletCollision/CollisionDispatch/btUnionFind.h"
     
    7878};
    7979
    80 #endif //SIMULATION_ISLAND_MANAGER_H
     80#endif //BT_SIMULATION_ISLAND_MANAGER_H
    8181
  • code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btSphereBoxCollisionAlgorithm.h

    r5781 r8393  
    1414*/
    1515
    16 #ifndef SPHERE_BOX_COLLISION_ALGORITHM_H
    17 #define SPHERE_BOX_COLLISION_ALGORITHM_H
     16#ifndef BT_SPHERE_BOX_COLLISION_ALGORITHM_H
     17#define BT_SPHERE_BOX_COLLISION_ALGORITHM_H
    1818
    1919#include "btActivatingCollisionAlgorithm.h"
     
    7272};
    7373
    74 #endif //SPHERE_BOX_COLLISION_ALGORITHM_H
     74#endif //BT_SPHERE_BOX_COLLISION_ALGORITHM_H
    7575
  • code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btSphereSphereCollisionAlgorithm.h

    r5781 r8393  
    1414*/
    1515
    16 #ifndef SPHERE_SPHERE_COLLISION_ALGORITHM_H
    17 #define SPHERE_SPHERE_COLLISION_ALGORITHM_H
     16#ifndef BT_SPHERE_SPHERE_COLLISION_ALGORITHM_H
     17#define BT_SPHERE_SPHERE_COLLISION_ALGORITHM_H
    1818
    1919#include "btActivatingCollisionAlgorithm.h"
     
    6363};
    6464
    65 #endif //SPHERE_SPHERE_COLLISION_ALGORITHM_H
     65#endif //BT_SPHERE_SPHERE_COLLISION_ALGORITHM_H
    6666
  • code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btSphereTriangleCollisionAlgorithm.h

    r5781 r8393  
    1414*/
    1515
    16 #ifndef SPHERE_TRIANGLE_COLLISION_ALGORITHM_H
    17 #define SPHERE_TRIANGLE_COLLISION_ALGORITHM_H
     16#ifndef BT_SPHERE_TRIANGLE_COLLISION_ALGORITHM_H
     17#define BT_SPHERE_TRIANGLE_COLLISION_ALGORITHM_H
    1818
    1919#include "btActivatingCollisionAlgorithm.h"
     
    6666};
    6767
    68 #endif //SPHERE_TRIANGLE_COLLISION_ALGORITHM_H
     68#endif //BT_SPHERE_TRIANGLE_COLLISION_ALGORITHM_H
    6969
  • code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btUnionFind.h

    r8351 r8393  
    1414*/
    1515
    16 #ifndef UNION_FIND_H
    17 #define UNION_FIND_H
     16#ifndef BT_UNION_FIND_H
     17#define BT_UNION_FIND_H
    1818
    1919#include "LinearMath/btAlignedObjectArray.h"
     
    127127
    128128
    129 #endif //UNION_FIND_H
     129#endif //BT_UNION_FIND_H
Note: See TracChangeset for help on using the changeset viewer.