Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/kicklib/src/external/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.h

    r5781 r7983  
    2323 * Bullet is a Collision Detection and Rigid Body Dynamics Library. The Library is Open Source and free for commercial use, under the ZLib license ( http://opensource.org/licenses/zlib-license.php ).
    2424 *
     25 * The main documentation is Bullet_User_Manual.pdf, included in the source code distribution.
    2526 * There is the Physics Forum for feedback and general Collision Detection and Physics discussions.
    2627 * Please visit http://www.bulletphysics.com
     
    3031 * @subsection step1 Step 1: Download
    3132 * You can download the Bullet Physics Library from the Google Code repository: http://code.google.com/p/bullet/downloads/list
     33 *
    3234 * @subsection step2 Step 2: Building
    33  * Bullet comes with autogenerated Project Files for Microsoft Visual Studio 6, 7, 7.1 and 8.
    34  * The main Workspace/Solution is located in Bullet/msvc/8/wksbullet.sln (replace 8 with your version).
    35  *
    36  * Under other platforms, like Linux or Mac OS-X, Bullet can be build using either using make, cmake, http://www.cmake.org , or jam, http://www.perforce.com/jam/jam.html . cmake can autogenerate Xcode, KDevelop, MSVC and other build systems. just run cmake . in the root of Bullet.
    37  * So if you are not using MSVC or cmake, you can run ./autogen.sh ./configure to create both Makefile and Jamfile and then run make or jam.
    38  * Jam is a build system that can build the library, demos and also autogenerate the MSVC Project Files.
    39  * If you don't have jam installed, you can make jam from the included jam-2.5 sources, or download jam from ftp://ftp.perforce.com/jam
     35 * Bullet main build system for all platforms is cmake, you can download http://www.cmake.org
     36 * cmake can autogenerate projectfiles for Microsoft Visual Studio, Apple Xcode, KDevelop and Unix Makefiles.
     37 * The easiest is to run the CMake cmake-gui graphical user interface and choose the options and generate projectfiles.
     38 * You can also use cmake in the command-line. Here are some examples for various platforms:
     39 * cmake . -G "Visual Studio 9 2008"
     40 * cmake . -G Xcode
     41 * cmake . -G "Unix Makefiles"
     42 * Although cmake is recommended, you can also use autotools for UNIX: ./autogen.sh ./configure to create a Makefile and then run make.
    4043 *
    4144 * @subsection step3 Step 3: Testing demos
     
    5457 *
    5558 * @section copyright Copyright
    56  * Copyright (C) 2005-2008 Erwin Coumans, some contributions Copyright Gino van den Bergen, Christer Ericson, Simon Hobbs, Ricardo Padrela, F Richter(res), Stephane Redon
    57  * Special thanks to all visitors of the Bullet Physics forum, and in particular above contributors, John McCutchan, Nathanael Presson, Dave Eberle, Dirk Gregorius, Erin Catto, Dave Eberle, Adam Moravanszky,
    58  * Pierre Terdiman, Kenny Erleben, Russell Smith, Oliver Strunk, Jan Paul van Waveren, Marten Svanfeldt.
     59 * For up-to-data information and copyright and contributors list check out the Bullet_User_Manual.pdf
    5960 *
    6061 */
    61 
    62 
    6362 
    6463 
     
    7170class btConvexShape;
    7271class btBroadphaseInterface;
     72class btSerializer;
     73
    7374#include "LinearMath/btVector3.h"
    7475#include "LinearMath/btTransform.h"
     
    8283{
    8384
    84 
    8585       
    8686protected:
    8787
    8888        btAlignedObjectArray<btCollisionObject*>        m_collisionObjects;
    89 
    9089       
    9190        btDispatcher*   m_dispatcher1;
     
    9998        btIDebugDraw*   m_debugDrawer;
    10099
    101 
    102        
     100        ///m_forceUpdateAllAabbs can be set to false as an optimization to only update active object AABBs
     101        ///it is true by default, because it is error-prone (setting the position of static objects wouldn't update their AABB)
     102        bool m_forceUpdateAllAabbs;
     103
     104        void    serializeCollisionObjects(btSerializer* serializer);
     105
    103106public:
    104107
     
    142145
    143146        virtual void    updateAabbs();
    144 
    145147       
    146148        virtual void    setDebugDrawer(btIDebugDraw*    debugDrawer)
     
    153155                return m_debugDrawer;
    154156        }
     157
     158        virtual void    debugDrawWorld();
     159
     160        virtual void debugDrawObject(const btTransform& worldTransform, const btCollisionShape* shape, const btVector3& color);
    155161
    156162
     
    161167                int     m_shapePart;
    162168                int     m_triangleIndex;
    163 
    164169               
    165170                //const btCollisionShape*       m_shapeTemp;
     
    239244                btVector3       m_hitNormalWorld;
    240245                btVector3       m_hitPointWorld;
    241 
    242246                       
    243247                virtual btScalar        addSingleResult(LocalRayResult& rayResult,bool normalInWorldSpace)
     
    245249                        //caller already does the filter on the m_closestHitFraction
    246250                        btAssert(rayResult.m_hitFraction <= m_closestHitFraction);
    247 
    248251                       
    249252                        m_closestHitFraction = rayResult.m_hitFraction;
     
    262265        };
    263266
     267        struct  AllHitsRayResultCallback : public RayResultCallback
     268        {
     269                AllHitsRayResultCallback(const btVector3&       rayFromWorld,const btVector3&   rayToWorld)
     270                :m_rayFromWorld(rayFromWorld),
     271                m_rayToWorld(rayToWorld)
     272                {
     273                }
     274
     275                btAlignedObjectArray<btCollisionObject*>                m_collisionObjects;
     276
     277                btVector3       m_rayFromWorld;//used to calculate hitPointWorld from hitFraction
     278                btVector3       m_rayToWorld;
     279
     280                btAlignedObjectArray<btVector3> m_hitNormalWorld;
     281                btAlignedObjectArray<btVector3> m_hitPointWorld;
     282                btAlignedObjectArray<btScalar> m_hitFractions;
     283                       
     284                virtual btScalar        addSingleResult(LocalRayResult& rayResult,bool normalInWorldSpace)
     285                {
     286                        m_collisionObject = rayResult.m_collisionObject;
     287                        m_collisionObjects.push_back(rayResult.m_collisionObject);
     288                        btVector3 hitNormalWorld;
     289                        if (normalInWorldSpace)
     290                        {
     291                                hitNormalWorld = rayResult.m_hitNormalLocal;
     292                        } else
     293                        {
     294                                ///need to transform normal into worldspace
     295                                hitNormalWorld = m_collisionObject->getWorldTransform().getBasis()*rayResult.m_hitNormalLocal;
     296                        }
     297                        m_hitNormalWorld.push_back(hitNormalWorld);
     298                        btVector3 hitPointWorld;
     299                        hitPointWorld.setInterpolate3(m_rayFromWorld,m_rayToWorld,rayResult.m_hitFraction);
     300                        m_hitPointWorld.push_back(hitPointWorld);
     301                        m_hitFractions.push_back(rayResult.m_hitFraction);
     302                        return m_closestHitFraction;
     303                }
     304        };
     305
    264306
    265307        struct LocalConvexResult
     
    292334                short int       m_collisionFilterGroup;
    293335                short int       m_collisionFilterMask;
    294 
    295336               
    296337                ConvexResultCallback()
     
    304345                {
    305346                }
    306 
    307347               
    308348                bool    hasHit() const
     
    310350                        return (m_closestHitFraction < btScalar(1.));
    311351                }
    312 
    313352
    314353               
     
    339378                btVector3       m_hitPointWorld;
    340379                btCollisionObject*      m_hitCollisionObject;
    341 
    342380               
    343381                virtual btScalar        addSingleResult(LocalConvexResult& convexResult,bool normalInWorldSpace)
     
    345383//caller already does the filter on the m_closestHitFraction
    346384                        btAssert(convexResult.m_hitFraction <= m_closestHitFraction);
    347 
    348385                                               
    349386                        m_closestHitFraction = convexResult.m_hitFraction;
     
    362399        };
    363400
     401        ///ContactResultCallback is used to report contact points
     402        struct  ContactResultCallback
     403        {
     404                short int       m_collisionFilterGroup;
     405                short int       m_collisionFilterMask;
     406               
     407                ContactResultCallback()
     408                        :m_collisionFilterGroup(btBroadphaseProxy::DefaultFilter),
     409                        m_collisionFilterMask(btBroadphaseProxy::AllFilter)
     410                {
     411                }
     412
     413                virtual ~ContactResultCallback()
     414                {
     415                }
     416               
     417                virtual bool needsCollision(btBroadphaseProxy* proxy0) const
     418                {
     419                        bool collides = (proxy0->m_collisionFilterGroup & m_collisionFilterMask) != 0;
     420                        collides = collides && (m_collisionFilterGroup & proxy0->m_collisionFilterMask);
     421                        return collides;
     422                }
     423
     424                virtual btScalar        addSingleResult(btManifoldPoint& cp,    const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1) = 0;
     425        };
     426
     427
     428
    364429        int     getNumCollisionObjects() const
    365430        {
     
    369434        /// rayTest performs a raycast on all objects in the btCollisionWorld, and calls the resultCallback
    370435        /// This allows for several queries: first hit, all hits, any hit, dependent on the value returned by the callback.
    371         void    rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback) const;
    372 
    373         // convexTest performs a swept convex cast on all objects in the btCollisionWorld, and calls the resultCallback
    374         // This allows for several queries: first hit, all hits, any hit, dependent on the value return by the callback.
     436        virtual void rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback) const;
     437
     438        /// convexTest performs a swept convex cast on all objects in the btCollisionWorld, and calls the resultCallback
     439        /// This allows for several queries: first hit, all hits, any hit, dependent on the value return by the callback.
    375440        void    convexSweepTest (const btConvexShape* castShape, const btTransform& from, const btTransform& to, ConvexResultCallback& resultCallback,  btScalar allowedCcdPenetration = btScalar(0.)) const;
     441
     442        ///contactTest performs a discrete collision test between colObj against all objects in the btCollisionWorld, and calls the resultCallback.
     443        ///it reports one or more contact points for every overlapping object (including the one with deepest penetration)
     444        void    contactTest(btCollisionObject* colObj, ContactResultCallback& resultCallback);
     445
     446        ///contactTest performs a discrete collision test between two collision objects and calls the resultCallback if overlap if detected.
     447        ///it reports one or more contact points (including the one with deepest penetration)
     448        void    contactPairTest(btCollisionObject* colObjA, btCollisionObject* colObjB, ContactResultCallback& resultCallback);
    376449
    377450
     
    392465                                          ConvexResultCallback& resultCallback, btScalar        allowedPenetration);
    393466
    394         void    addCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup=btBroadphaseProxy::DefaultFilter,short int collisionFilterMask=btBroadphaseProxy::AllFilter);
     467        virtual void    addCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup=btBroadphaseProxy::DefaultFilter,short int collisionFilterMask=btBroadphaseProxy::AllFilter);
    395468
    396469        btCollisionObjectArray& getCollisionObjectArray()
     
    405478
    406479
    407         void    removeCollisionObject(btCollisionObject* collisionObject);
     480        virtual void    removeCollisionObject(btCollisionObject* collisionObject);
    408481
    409482        virtual void    performDiscreteCollisionDetection();
     
    418491                return m_dispatchInfo;
    419492        }
     493       
     494        bool    getForceUpdateAllAabbs() const
     495        {
     496                return m_forceUpdateAllAabbs;
     497        }
     498        void setForceUpdateAllAabbs( bool forceUpdateAllAabbs)
     499        {
     500                m_forceUpdateAllAabbs = forceUpdateAllAabbs;
     501        }
     502
     503        ///Preliminary serialization test for Bullet 2.76. Loading those files requires a separate parser (Bullet/Demos/SerializeDemo)
     504        virtual void    serialize(btSerializer* serializer);
    420505
    421506};
Note: See TracChangeset for help on using the changeset viewer.