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/BulletDynamics/Dynamics
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/external/bullet/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.cpp

    r8351 r8393  
    3636#include "BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h"
    3737#include "BulletDynamics/ConstraintSolver/btSliderConstraint.h"
     38#include "BulletDynamics/ConstraintSolver/btContactConstraint.h"
     39
    3840
    3941#include "LinearMath/btIDebugDraw.h"
     
    4648
    4749#include "LinearMath/btSerializer.h"
     50
     51#if 0
     52btAlignedObjectArray<btVector3> debugContacts;
     53btAlignedObjectArray<btVector3> debugNormals;
     54int startHit=2;
     55int firstHit=startHit;
     56#endif
    4857
    4958
     
    315324        dispatchInfo.m_debugDraw = getDebugDrawer();
    316325
     326
    317327        ///perform collision detection
    318328        performDiscreteCollisionDetection();
     329
     330        if (getDispatchInfo().m_useContinuous)
     331                addSpeculativeContacts(timeStep);
     332
    319333
    320334        calculateSimulationIslands();
     
    746760class btClosestNotMeConvexResultCallback : public btCollisionWorld::ClosestConvexResultCallback
    747761{
     762public:
     763
    748764        btCollisionObject* m_me;
    749765        btScalar m_allowedPenetration;
    750766        btOverlappingPairCache* m_pairCache;
    751767        btDispatcher* m_dispatcher;
    752 
    753768
    754769public:
     
    798813                if (m_dispatcher->needsResponse(m_me,otherObj))
    799814                {
     815#if 0
    800816                        ///don't do CCD when there are already contact points (touching contact/penetration)
    801817                        btAlignedObjectArray<btPersistentManifold*> manifoldArray;
     
    815831                                }
    816832                        }
    817                 }
    818                 return true;
     833#endif
     834                        return true;
     835                }
     836
     837                return false;
    819838        }
    820839
     
    825844int gNumClampedCcdMotions=0;
    826845
    827 //#include "stdio.h"
    828846void    btDiscreteDynamicsWorld::integrateTransforms(btScalar timeStep)
    829847{
     
    837855                if (body->isActive() && (!body->isStaticOrKinematicObject()))
    838856                {
     857
     858                        body->predictIntegratedTransform(timeStep, predictedTrans);
     859                       
     860                        btScalar squareMotion = (predictedTrans.getOrigin()-body->getWorldTransform().getOrigin()).length2();
     861
     862                       
     863
     864                        if (getDispatchInfo().m_useContinuous && body->getCcdSquareMotionThreshold() && body->getCcdSquareMotionThreshold() < squareMotion)
     865                        {
     866                                BT_PROFILE("CCD motion clamping");
     867                                if (body->getCollisionShape()->isConvex())
     868                                {
     869                                        gNumClampedCcdMotions++;
     870#ifdef USE_STATIC_ONLY
     871                                        class StaticOnlyCallback : public btClosestNotMeConvexResultCallback
     872                                        {
     873                                        public:
     874
     875                                                StaticOnlyCallback (btCollisionObject* me,const btVector3& fromA,const btVector3& toA,btOverlappingPairCache* pairCache,btDispatcher* dispatcher) :
     876                                                  btClosestNotMeConvexResultCallback(me,fromA,toA,pairCache,dispatcher)
     877                                                {
     878                                                }
     879
     880                                                virtual bool needsCollision(btBroadphaseProxy* proxy0) const
     881                                                {
     882                                                        btCollisionObject* otherObj = (btCollisionObject*) proxy0->m_clientObject;
     883                                                        if (!otherObj->isStaticOrKinematicObject())
     884                                                                return false;
     885                                                        return btClosestNotMeConvexResultCallback::needsCollision(proxy0);
     886                                                }
     887                                        };
     888
     889                                        StaticOnlyCallback sweepResults(body,body->getWorldTransform().getOrigin(),predictedTrans.getOrigin(),getBroadphase()->getOverlappingPairCache(),getDispatcher());
     890#else
     891                                        btClosestNotMeConvexResultCallback sweepResults(body,body->getWorldTransform().getOrigin(),predictedTrans.getOrigin(),getBroadphase()->getOverlappingPairCache(),getDispatcher());
     892#endif
     893                                        //btConvexShape* convexShape = static_cast<btConvexShape*>(body->getCollisionShape());
     894                                        btSphereShape tmpSphere(body->getCcdSweptSphereRadius());//btConvexShape* convexShape = static_cast<btConvexShape*>(body->getCollisionShape());
     895                                        sweepResults.m_allowedPenetration=getDispatchInfo().m_allowedCcdPenetration;
     896
     897                                        sweepResults.m_collisionFilterGroup = body->getBroadphaseProxy()->m_collisionFilterGroup;
     898                                        sweepResults.m_collisionFilterMask  = body->getBroadphaseProxy()->m_collisionFilterMask;
     899                                        btTransform modifiedPredictedTrans = predictedTrans;
     900                                        modifiedPredictedTrans.setBasis(body->getWorldTransform().getBasis());
     901
     902                                        convexSweepTest(&tmpSphere,body->getWorldTransform(),modifiedPredictedTrans,sweepResults);
     903                                        if (sweepResults.hasHit() && (sweepResults.m_closestHitFraction < 1.f))
     904                                        {
     905                                               
     906                                                //printf("clamped integration to hit fraction = %f\n",fraction);
     907                                                body->setHitFraction(sweepResults.m_closestHitFraction);
     908                                                body->predictIntegratedTransform(timeStep*body->getHitFraction(), predictedTrans);
     909                                                body->setHitFraction(0.f);
     910                                                body->proceedToTransform( predictedTrans);
     911
     912#if 0
     913                                                btVector3 linVel = body->getLinearVelocity();
     914
     915                                                btScalar maxSpeed = body->getCcdMotionThreshold()/getSolverInfo().m_timeStep;
     916                                                btScalar maxSpeedSqr = maxSpeed*maxSpeed;
     917                                                if (linVel.length2()>maxSpeedSqr)
     918                                                {
     919                                                        linVel.normalize();
     920                                                        linVel*= maxSpeed;
     921                                                        body->setLinearVelocity(linVel);
     922                                                        btScalar ms2 = body->getLinearVelocity().length2();
     923                                                        body->predictIntegratedTransform(timeStep, predictedTrans);
     924
     925                                                        btScalar sm2 = (predictedTrans.getOrigin()-body->getWorldTransform().getOrigin()).length2();
     926                                                        btScalar smt = body->getCcdSquareMotionThreshold();
     927                                                        printf("sm2=%f\n",sm2);
     928                                                }
     929#else
     930                                                //response  between two dynamic objects without friction, assuming 0 penetration depth
     931                                                btScalar appliedImpulse = 0.f;
     932                                                btScalar depth = 0.f;
     933                                                appliedImpulse = resolveSingleCollision(body,sweepResults.m_hitCollisionObject,sweepResults.m_hitPointWorld,sweepResults.m_hitNormalWorld,getSolverInfo(), depth);
     934                                               
     935
     936#endif
     937
     938                                        continue;
     939                                        }
     940                                }
     941                        }
     942                       
     943
     944                        body->proceedToTransform( predictedTrans);
     945                }
     946        }
     947}
     948
     949void    btDiscreteDynamicsWorld::addSpeculativeContacts(btScalar timeStep)
     950{
     951        BT_PROFILE("addSpeculativeContacts");
     952        btTransform predictedTrans;
     953        for ( int i=0;i<m_nonStaticRigidBodies.size();i++)
     954        {
     955                btRigidBody* body = m_nonStaticRigidBodies[i];
     956                body->setHitFraction(1.f);
     957
     958                if (body->isActive() && (!body->isStaticOrKinematicObject()))
     959                {
    839960                        body->predictIntegratedTransform(timeStep, predictedTrans);
    840961                        btScalar squareMotion = (predictedTrans.getOrigin()-body->getWorldTransform().getOrigin()).length2();
     
    842963                        if (body->getCcdSquareMotionThreshold() && body->getCcdSquareMotionThreshold() < squareMotion)
    843964                        {
    844                                 BT_PROFILE("CCD motion clamping");
     965                                BT_PROFILE("search speculative contacts");
    845966                                if (body->getCollisionShape()->isConvex())
    846967                                {
     
    853974                                        sweepResults.m_collisionFilterGroup = body->getBroadphaseProxy()->m_collisionFilterGroup;
    854975                                        sweepResults.m_collisionFilterMask  = body->getBroadphaseProxy()->m_collisionFilterMask;
    855 
    856                                         convexSweepTest(&tmpSphere,body->getWorldTransform(),predictedTrans,sweepResults);
     976                                        btTransform modifiedPredictedTrans;
     977                                        modifiedPredictedTrans = predictedTrans;
     978                                        modifiedPredictedTrans.setBasis(body->getWorldTransform().getBasis());
     979
     980                                        convexSweepTest(&tmpSphere,body->getWorldTransform(),modifiedPredictedTrans,sweepResults);
    857981                                        if (sweepResults.hasHit() && (sweepResults.m_closestHitFraction < 1.f))
    858982                                        {
    859                                                 body->setHitFraction(sweepResults.m_closestHitFraction);
    860                                                 body->predictIntegratedTransform(timeStep*body->getHitFraction(), predictedTrans);
    861                                                 body->setHitFraction(0.f);
    862 //                                                      printf("clamped integration to hit fraction = %f\n",fraction);
     983                                                btBroadphaseProxy* proxy0 = body->getBroadphaseHandle();
     984                                                btBroadphaseProxy* proxy1 = sweepResults.m_hitCollisionObject->getBroadphaseHandle();
     985                                                btBroadphasePair* pair = sweepResults.m_pairCache->findPair(proxy0,proxy1);
     986                                                if (pair)
     987                                                {
     988                                                        if (pair->m_algorithm)
     989                                                        {
     990                                                                btManifoldArray contacts;
     991                                                                pair->m_algorithm->getAllContactManifolds(contacts);
     992                                                                if (contacts.size())
     993                                                                {
     994                                                                        btManifoldResult result(body,sweepResults.m_hitCollisionObject);
     995                                                                        result.setPersistentManifold(contacts[0]);
     996
     997                                                                        btVector3 vec = (modifiedPredictedTrans.getOrigin()-body->getWorldTransform().getOrigin());
     998                                                                        vec*=sweepResults.m_closestHitFraction;
     999                                                                       
     1000                                                                        btScalar lenSqr = vec.length2();
     1001                                                                        btScalar depth = 0.f;
     1002                                                                        btVector3 pointWorld = sweepResults.m_hitPointWorld;
     1003                                                                        if (lenSqr>SIMD_EPSILON)
     1004                                                                        {
     1005                                                                                depth = btSqrt(lenSqr);
     1006                                                                                pointWorld -= vec;
     1007                                                                                vec /= depth;
     1008                                                                        }
     1009
     1010                                                                        if (contacts[0]->getBody0()==body)
     1011                                                                        {
     1012                                                                                result.addContactPoint(sweepResults.m_hitNormalWorld,pointWorld,depth);
     1013#if 0
     1014                                                                                debugContacts.push_back(sweepResults.m_hitPointWorld);//sweepResults.m_hitPointWorld);
     1015                                                                                debugNormals.push_back(sweepResults.m_hitNormalWorld);
     1016#endif
     1017                                                                        } else
     1018                                                                        {
     1019                                                                                //swapped
     1020                                                                                result.addContactPoint(-sweepResults.m_hitNormalWorld,pointWorld,depth);
     1021                                                                                //sweepResults.m_hitPointWorld,depth);
     1022                                                                               
     1023#if 0
     1024                                                                                if (1)//firstHit==1)
     1025                                                                                {
     1026                                                                                        firstHit=0;
     1027                                                                                        debugNormals.push_back(sweepResults.m_hitNormalWorld);
     1028                                                                                        debugContacts.push_back(pointWorld);//sweepResults.m_hitPointWorld);
     1029                                                                                        debugNormals.push_back(sweepResults.m_hitNormalWorld);
     1030                                                                                        debugContacts.push_back(sweepResults.m_hitPointWorld);
     1031                                                                                }
     1032                                                                                firstHit--;
     1033#endif
     1034                                                                        }
     1035                                                                }
     1036
     1037                                                        } else
     1038                                                        {
     1039                                                                //no algorithm, use dispatcher to create one
     1040
     1041                                                        }
     1042
     1043
     1044                                                } else
     1045                                                {
     1046                                                        //add an overlapping pair
     1047                                                        //printf("pair missing\n");
     1048
     1049                                                }
    8631050                                        }
    8641051                                }
    8651052                        }
    8661053                       
    867                         body->proceedToTransform( predictedTrans);
    8681054                }
    8691055        }
     
    10101196                        }
    10111197                        break;
     1198                case D6_SPRING_CONSTRAINT_TYPE:
    10121199                case D6_CONSTRAINT_TYPE:
    10131200                        {
  • code/trunk/src/external/bullet/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h

    r8351 r8393  
    6363        virtual void    integrateTransforms(btScalar timeStep);
    6464               
     65        virtual void    addSpeculativeContacts(btScalar timeStep);
     66
    6567        virtual void    calculateSimulationIslands();
    6668
  • code/trunk/src/external/bullet/BulletDynamics/Dynamics/btDynamicsWorld.h

    r8351 r8393  
    3333        BT_SIMPLE_DYNAMICS_WORLD=1,
    3434        BT_DISCRETE_DYNAMICS_WORLD=2,
    35         BT_CONTINUOUS_DYNAMICS_WORLD=3
     35        BT_CONTINUOUS_DYNAMICS_WORLD=3,
     36        BT_SOFT_RIGID_DYNAMICS_WORLD=4
    3637};
    3738
     
    8687
    8788                virtual void    addRigidBody(btRigidBody* body) = 0;
     89
     90                virtual void    addRigidBody(btRigidBody* body, short group, short mask) = 0;
    8891
    8992                virtual void    removeRigidBody(btRigidBody* body) = 0;
  • code/trunk/src/external/bullet/BulletDynamics/Dynamics/btRigidBody.cpp

    r8351 r8393  
    5252        m_totalForce.setValue(btScalar(0.0), btScalar(0.0), btScalar(0.0));
    5353        m_totalTorque.setValue(btScalar(0.0), btScalar(0.0), btScalar(0.0)),
    54         m_linearDamping = btScalar(0.);
    55         m_angularDamping = btScalar(0.5);
     54    setDamping(constructionInfo.m_linearDamping, constructionInfo.m_angularDamping);
     55
    5656        m_linearSleepingThreshold = constructionInfo.m_linearSleepingThreshold;
    5757        m_angularSleepingThreshold = constructionInfo.m_angularSleepingThreshold;
     
    8585       
    8686        setMassProps(constructionInfo.m_mass, constructionInfo.m_localInertia);
    87     setDamping(constructionInfo.m_linearDamping, constructionInfo.m_angularDamping);
    8887        updateInertiaTensor();
    8988
  • code/trunk/src/external/bullet/BulletDynamics/Dynamics/btRigidBody.h

    r8351 r8393  
    1414*/
    1515
    16 #ifndef RIGIDBODY_H
    17 #define RIGIDBODY_H
     16#ifndef BT_RIGIDBODY_H
     17#define BT_RIGIDBODY_H
    1818
    1919#include "LinearMath/btAlignedObjectArray.h"
     
    9090       
    9191        int                             m_debugBodyId;
    92 
     92       
    9393
    9494protected:
     
    271271        }
    272272
    273         const btVector3& getTotalForce()
     273        const btVector3& getTotalForce() const
    274274        {
    275275                return m_totalForce;
    276276        };
    277277
    278         const btVector3& getTotalTorque()
     278        const btVector3& getTotalTorque() const
    279279        {
    280280                return m_totalTorque;
     
    505505        }
    506506
    507         int getNumConstraintRefs()
     507        int getNumConstraintRefs() const
    508508        {
    509509                return m_constraintRefs.size();
     
    618618
    619619        void    internalWritebackVelocity(btScalar timeStep);
     620
    620621       
    621622
     
    687688
    688689
    689 #endif
    690 
     690#endif //BT_RIGIDBODY_H
     691
  • code/trunk/src/external/bullet/BulletDynamics/Dynamics/btSimpleDynamicsWorld.cpp

    r8351 r8393  
    7979                infoGlobal.m_timeStep = timeStep;
    8080                m_constraintSolver->prepareSolve(0,numManifolds);
    81                 m_constraintSolver->solveGroup(0,0,manifoldPtr, numManifolds,0,0,infoGlobal,m_debugDrawer, m_stackAlloc,m_dispatcher1);
     81                m_constraintSolver->solveGroup(&getCollisionObjectArray()[0],getNumCollisionObjects(),manifoldPtr, numManifolds,0,0,infoGlobal,m_debugDrawer, m_stackAlloc,m_dispatcher1);
    8282                m_constraintSolver->allSolved(infoGlobal,m_debugDrawer, m_stackAlloc);
    8383        }
     
    155155        }
    156156}
     157
     158void    btSimpleDynamicsWorld::addRigidBody(btRigidBody* body, short group, short mask)
     159{
     160        body->setGravity(m_gravity);
     161
     162        if (body->getCollisionShape())
     163        {
     164                addCollisionObject(body,group,mask);
     165        }
     166}
     167
     168
     169void    btSimpleDynamicsWorld::debugDrawWorld()
     170{
     171
     172}
     173                               
     174void    btSimpleDynamicsWorld::addAction(btActionInterface* action)
     175{
     176
     177}
     178
     179void    btSimpleDynamicsWorld::removeAction(btActionInterface* action)
     180{
     181
     182}
     183
    157184
    158185void    btSimpleDynamicsWorld::updateAabbs()
  • code/trunk/src/external/bullet/BulletDynamics/Dynamics/btSimpleDynamicsWorld.h

    r8351 r8393  
    5757        virtual void    addRigidBody(btRigidBody* body);
    5858
     59        virtual void    addRigidBody(btRigidBody* body, short group, short mask);
     60
    5961        virtual void    removeRigidBody(btRigidBody* body);
     62
     63        virtual void    debugDrawWorld();
     64                               
     65        virtual void    addAction(btActionInterface* action);
     66
     67        virtual void    removeAction(btActionInterface* action);
    6068
    6169        ///removeCollisionObject will first check if it is a rigid body, if so call removeRigidBody otherwise call btCollisionWorld::removeCollisionObject
Note: See TracChangeset for help on using the changeset viewer.