Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 31, 2009, 8:05:51 PM (15 years ago)
Author:
rgrieder
Message:

Update from Bullet 2.73 to 2.74.

Location:
code/trunk/src/bullet/BulletCollision/CollisionShapes
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/bullet/BulletCollision/CollisionShapes/btBoxShape.h

    r2662 r2882  
    162162                {
    163163                case 0:
    164                         plane.setValue(btScalar(1.),btScalar(0.),btScalar(0.));
    165                         plane[3] = -halfExtents.x();
     164                        plane.setValue(btScalar(1.),btScalar(0.),btScalar(0.),-halfExtents.x());
    166165                        break;
    167166                case 1:
    168                         plane.setValue(btScalar(-1.),btScalar(0.),btScalar(0.));
    169                         plane[3] = -halfExtents.x();
     167                        plane.setValue(btScalar(-1.),btScalar(0.),btScalar(0.),-halfExtents.x());
    170168                        break;
    171169                case 2:
    172                         plane.setValue(btScalar(0.),btScalar(1.),btScalar(0.));
    173                         plane[3] = -halfExtents.y();
     170                        plane.setValue(btScalar(0.),btScalar(1.),btScalar(0.),-halfExtents.y());
    174171                        break;
    175172                case 3:
    176                         plane.setValue(btScalar(0.),btScalar(-1.),btScalar(0.));
    177                         plane[3] = -halfExtents.y();
     173                        plane.setValue(btScalar(0.),btScalar(-1.),btScalar(0.),-halfExtents.y());
    178174                        break;
    179175                case 4:
    180                         plane.setValue(btScalar(0.),btScalar(0.),btScalar(1.));
    181                         plane[3] = -halfExtents.z();
     176                        plane.setValue(btScalar(0.),btScalar(0.),btScalar(1.),-halfExtents.z());
    182177                        break;
    183178                case 5:
    184                         plane.setValue(btScalar(0.),btScalar(0.),btScalar(-1.));
    185                         plane[3] = -halfExtents.z();
     179                        plane.setValue(btScalar(0.),btScalar(0.),btScalar(-1.),-halfExtents.z());
    186180                        break;
    187181                default:
    188                         assert(0);
     182                        btAssert(0);
    189183                }
    190184        }
     
    313307                        break;
    314308                default:
    315                         assert(0);
     309                        btAssert(0);
    316310                }
    317311        }
  • code/trunk/src/bullet/BulletCollision/CollisionShapes/btCollisionShape.cpp

    r2662 r2882  
    1515
    1616#include "BulletCollision/CollisionShapes/btCollisionShape.h"
     17
     18
     19btScalar gContactThresholdFactor=btScalar(0.02);
    1720
    1821
     
    4548btScalar        btCollisionShape::getContactBreakingThreshold() const
    4649{
    47         ///@todo make this 0.1 configurable
    48         return getAngularMotionDisc() * btScalar(0.1);
     50        return getAngularMotionDisc() * gContactThresholdFactor;
    4951}
    5052btScalar        btCollisionShape::getAngularMotionDisc() const
  • code/trunk/src/bullet/BulletCollision/CollisionShapes/btCompoundShape.cpp

    r2662 r2882  
    2323m_collisionMargin(btScalar(0.)),
    2424m_localScaling(btScalar(1.),btScalar(1.),btScalar(1.)),
    25 m_dynamicAabbTree(0)
     25m_dynamicAabbTree(0),
     26m_updateRevision(1)
    2627{
    2728        m_shapeType = COMPOUND_SHAPE_PROXYTYPE;
     
    4748void    btCompoundShape::addChildShape(const btTransform& localTransform,btCollisionShape* shape)
    4849{
     50        m_updateRevision++;
    4951        //m_childTransforms.push_back(localTransform);
    5052        //m_childShapes.push_back(shape);
     
    5557        child.m_childMargin = shape->getMargin();
    5658
    57         m_children.push_back(child);
    58 
     59       
    5960        //extend the local aabbMin/aabbMax
    6061        btVector3 localAabbMin,localAabbMax;
     
    7576        {
    7677                const btDbvtVolume      bounds=btDbvtVolume::FromMM(localAabbMin,localAabbMax);
    77                 int index = m_children.size()-1;
     78                int index = m_children.size();
    7879                child.m_node = m_dynamicAabbTree->insert(bounds,(void*)index);
    7980        }
     81
     82        m_children.push_back(child);
    8083
    8184}
     
    100103void btCompoundShape::removeChildShapeByIndex(int childShapeIndex)
    101104{
     105        m_updateRevision++;
    102106        btAssert(childShapeIndex >=0 && childShapeIndex < m_children.size());
    103107        if (m_dynamicAabbTree)
     
    114118void btCompoundShape::removeChildShape(btCollisionShape* shape)
    115119{
     120        m_updateRevision++;
    116121        // Find the children containing the shape specified, and remove those children.
    117122        //note: there might be multiple children using the same shape!
     
    140145        // Recalculate the local aabb
    141146        // Brute force, it iterates over all the shapes left.
     147
    142148        m_localAabbMin = btVector3(btScalar(1e30),btScalar(1e30),btScalar(1e30));
    143149        m_localAabbMax = btVector3(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30));
     
    162168{
    163169        btVector3 localHalfExtents = btScalar(0.5)*(m_localAabbMax-m_localAabbMin);
     170        btVector3 localCenter = btScalar(0.5)*(m_localAabbMax+m_localAabbMin);
     171       
     172        //avoid an illegal AABB when there are no children
     173        if (!m_children.size())
     174        {
     175                localHalfExtents.setValue(0,0,0);
     176                localCenter.setValue(0,0,0);
     177        }
    164178        localHalfExtents += btVector3(getMargin(),getMargin(),getMargin());
    165         btVector3 localCenter = btScalar(0.5)*(m_localAabbMax+m_localAabbMin);
     179               
    166180
    167181        btMatrix3x3 abs_b = trans.getBasis().absolute(); 
     
    174188        aabbMin = center-extent;
    175189        aabbMax = center+extent;
    176 
     190       
    177191}
    178192
  • code/trunk/src/bullet/BulletCollision/CollisionShapes/btCompoundShape.h

    r2662 r2882  
    5959
    6060        btDbvt*                                                 m_dynamicAabbTree;
     61
     62        ///increment m_updateRevision when adding/removing/replacing child shapes, so that some caches can be updated
     63        int                                                             m_updateRevision;
    6164
    6265public:
     
    153156        void calculatePrincipalAxisTransform(btScalar* masses, btTransform& principal, btVector3& inertia) const;
    154157
     158        int     getUpdateRevision() const
     159        {
     160                return m_updateRevision;
     161        }
    155162
    156163private:
  • code/trunk/src/bullet/BulletCollision/CollisionShapes/btConeShape.cpp

    r2662 r2882  
    6161                break;
    6262        default:
    63                 assert(0);
     63                btAssert(0);
    6464        };
    6565}
  • code/trunk/src/bullet/BulletCollision/CollisionShapes/btConvexHullShape.cpp

    r2662 r2882  
    182182bool btConvexHullShape::isInside(const btVector3& ,btScalar ) const
    183183{
    184         assert(0);
     184        btAssert(0);
    185185        return false;
    186186}
  • code/trunk/src/bullet/BulletCollision/CollisionShapes/btConvexPointCloudShape.cpp

    r2662 r2882  
    151151bool btConvexPointCloudShape::isInside(const btVector3& ,btScalar ) const
    152152{
    153         assert(0);
     153        btAssert(0);
    154154        return false;
    155155}
  • code/trunk/src/bullet/BulletCollision/CollisionShapes/btConvexShape.cpp

    r2662 r2882  
    155155
    156156                btCapsuleShape* capsuleShape = (btCapsuleShape*)this;
    157                 btVector3 halfExtents = capsuleShape->getImplicitShapeDimensions();
    158157                btScalar halfHeight = capsuleShape->getHalfHeight();
    159158                int capsuleUpAxis = capsuleShape->getUpAxis();
     
    302301        {
    303302                btSphereShape* sphereShape = (btSphereShape*)this;
    304                 float radius = sphereShape->getImplicitShapeDimensions().getX();// * convexShape->getLocalScaling().getX();
    305                 float margin = radius + sphereShape->getMarginNonVirtual();
     303                btScalar radius = sphereShape->getImplicitShapeDimensions().getX();// * convexShape->getLocalScaling().getX();
     304                btScalar margin = radius + sphereShape->getMarginNonVirtual();
    306305                const btVector3& center = t.getOrigin();
    307306                btVector3 extent(margin,margin,margin);
     
    315314        {
    316315                btBoxShape* convexShape = (btBoxShape*)this;
    317                 float margin=convexShape->getMarginNonVirtual();
     316                btScalar margin=convexShape->getMarginNonVirtual();
    318317                btVector3 halfExtents = convexShape->getImplicitShapeDimensions();
    319318                halfExtents += btVector3(margin,margin,margin);
  • code/trunk/src/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp

    r2662 r2882  
    145145}
    146146
    147 btScalar        btHeightfieldTerrainShape::getHeightFieldValue(int x,int y) const
     147
     148/// This returns the "raw" (user's initial) height, not the actual height.
     149/// The actual height needs to be adjusted to be relative to the center
     150///   of the heightfield's AABB.
     151btScalar
     152btHeightfieldTerrainShape::getRawHeightFieldValue(int x,int y) const
    148153{
    149154        btScalar val = 0.f;
     
    182187
    183188
    184 
     189/// this returns the vertex in bullet-local coordinates
    185190void    btHeightfieldTerrainShape::getVertex(int x,int y,btVector3& vertex) const
    186191{
    187 
    188192        btAssert(x>=0);
    189193        btAssert(y>=0);
     
    191195        btAssert(y<m_heightStickLength);
    192196
    193 
    194         btScalar        height = getHeightFieldValue(x,y);
     197        btScalar        height = getRawHeightFieldValue(x,y);
    195198
    196199        switch (m_upAxis)
     
    199202                {
    200203                vertex.setValue(
    201                         height,
     204                        height - m_localOrigin.getX(),
    202205                        (-m_width/btScalar(2.0)) + x,
    203206                        (-m_length/btScalar(2.0) ) + y
     
    209212                        vertex.setValue(
    210213                        (-m_width/btScalar(2.0)) + x,
    211                         height,
     214                        height - m_localOrigin.getY(),
    212215                        (-m_length/btScalar(2.0)) + y
    213216                        );
     
    219222                        (-m_width/btScalar(2.0)) + x,
    220223                        (-m_length/btScalar(2.0)) + y,
    221                         height
     224                        height - m_localOrigin.getZ()
    222225                        );
    223226                        break;
     
    231234
    232235        vertex*=m_localScaling;
    233        
    234236}
    235237
     
    239241getQuantized
    240242(
    241 float x
     243btScalar x
    242244)
    243245{
  • code/trunk/src/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h

    r2662 r2882  
    3030  center (as determined by width and length and height, with each
    3131  axis multiplied by the localScaling).
     32
     33  \b NOTE: be careful with coordinates.  If you have a heightfield with a local
     34  min height of -100m, and a max height of +500m, you may be tempted to place it
     35  at the origin (0,0) and expect the heights in world coordinates to be
     36  -100 to +500 meters.
     37  Actually, the heights will be -300 to +300m, because bullet will re-center
     38  the heightfield based on its AABB (which is determined by the min/max
     39  heights).  So keep in mind that once you create a btHeightfieldTerrainShape
     40  object, the heights will be adjusted relative to the center of the AABB.  This
     41  is different to the behavior of many rendering engines, but is useful for
     42  physics engines.
    3243
    3344  Most (but not all) rendering and heightfield libraries assume upAxis = 1
     
    89100        btVector3       m_localScaling;
    90101
    91         virtual btScalar        getHeightFieldValue(int x,int y) const;
     102        virtual btScalar        getRawHeightFieldValue(int x,int y) const;
    92103        void            quantizeWithClamp(int* out, const btVector3& point,int isMax) const;
    93104        void            getVertex(int x,int y,btVector3& vertex) const;
  • code/trunk/src/bullet/BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp

    r2662 r2882  
    2929btVector3 btMinkowskiSumShape::localGetSupportingVertexWithoutMargin(const btVector3& vec)const
    3030{
    31         btVector3 supVertexA = m_transA(m_shapeA->localGetSupportingVertexWithoutMargin(-vec*m_transA.getBasis()));
    32         btVector3 supVertexB = m_transB(m_shapeB->localGetSupportingVertexWithoutMargin(vec*m_transB.getBasis()));
     31        btVector3 supVertexA = m_transA(m_shapeA->localGetSupportingVertexWithoutMargin(vec*m_transA.getBasis()));
     32        btVector3 supVertexB = m_transB(m_shapeB->localGetSupportingVertexWithoutMargin(-vec*m_transB.getBasis()));
    3333        return  supVertexA - supVertexB;
    3434}
  • code/trunk/src/bullet/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h

    r2662 r2882  
    3232        BT_DECLARE_ALIGNED_ALLOCATOR();
    3333
    34     btMultimaterialTriangleMeshShape(): btBvhTriangleMeshShape() {}
     34    btMultimaterialTriangleMeshShape(): btBvhTriangleMeshShape() {m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;}
    3535    btMultimaterialTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true):
    3636        btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, buildBvh)
    3737        {
     38            m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;
     39
    3840            btVector3 m_triangle[3];
    3941            const unsigned char *vertexbase;
     
    6870        btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, bvhAabbMin, bvhAabbMax, buildBvh)
    6971        {
     72            m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;
     73
    7074            btVector3 m_triangle[3];
    7175            const unsigned char *vertexbase;
     
    108112*/
    109113    }
    110         virtual int     getShapeType() const
    111         {
    112                 return MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;
    113         }
    114        
    115114        //debugging
    116115        virtual const char*     getName()const {return "MULTIMATERIALTRIANGLEMESH";}
  • code/trunk/src/bullet/BulletCollision/CollisionShapes/btSphereShape.h

    r2662 r2882  
    4848        btScalar        getRadius() const { return m_implicitShapeDimensions.getX() * m_localScaling.getX();}
    4949
     50        void    setUnscaledRadius(btScalar      radius)
     51        {
     52                m_implicitShapeDimensions.setX(radius);
     53                btConvexInternalShape::setMargin(radius);
     54        }
     55
    5056        //debugging
    5157        virtual const char*     getName()const {return "SPHERE";}
  • code/trunk/src/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp

    r2662 r2882  
    8383}
    8484
    85 void    btTriangleIndexVertexArray::setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax )
     85
     86void    btTriangleIndexVertexArray::setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax ) const
    8687{
    8788        m_aabbMin = aabbMin;
     
    9697}
    9798
     99
  • code/trunk/src/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h

    r2662 r2882  
    5353        IndexedMeshArray        m_indexedMeshes;
    5454        int m_pad[2];
    55         int m_hasAabb; // using int instead of bool to maintain alignment
    56         btVector3 m_aabbMin;
    57         btVector3 m_aabbMax;
     55        mutable int m_hasAabb; // using int instead of bool to maintain alignment
     56        mutable btVector3 m_aabbMin;
     57        mutable btVector3 m_aabbMax;
    5858
    5959public:
     
    107107
    108108        virtual bool    hasPremadeAabb() const;
    109         virtual void    setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax );
     109        virtual void    setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax ) const;
    110110        virtual void    getPremadeAabb(btVector3* aabbMin, btVector3* aabbMax ) const;
    111111
  • code/trunk/src/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.cpp

    r2662 r2882  
     1
    12/*
    23Bullet Continuous Collision Detection and Physics Library
  • code/trunk/src/bullet/BulletCollision/CollisionShapes/btTriangleMesh.cpp

    r2662 r2882  
    3636        {
    3737                m_indexedMeshes[0].m_numTriangles = m_32bitIndices.size()/3;
    38                 m_indexedMeshes[0].m_triangleIndexBase = (unsigned char*) &m_32bitIndices[0];
     38                m_indexedMeshes[0].m_triangleIndexBase = 0;
    3939                m_indexedMeshes[0].m_indexType = PHY_INTEGER;
    4040                m_indexedMeshes[0].m_triangleIndexStride = 3*sizeof(int);
     
    4242        {
    4343                m_indexedMeshes[0].m_numTriangles = m_16bitIndices.size()/3;
    44                 m_indexedMeshes[0].m_triangleIndexBase = (unsigned char*) &m_16bitIndices[0];
     44                m_indexedMeshes[0].m_triangleIndexBase = 0;
    4545                m_indexedMeshes[0].m_indexType = PHY_SHORT;
    4646                m_indexedMeshes[0].m_triangleIndexStride = 3*sizeof(short int);
     
    5050        {
    5151                m_indexedMeshes[0].m_numVertices = m_4componentVertices.size();
    52                 m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_4componentVertices[0];
     52                m_indexedMeshes[0].m_vertexBase = 0;
    5353                m_indexedMeshes[0].m_vertexStride = sizeof(btVector3);
    5454        } else
    5555        {
    5656                m_indexedMeshes[0].m_numVertices = m_3componentVertices.size()/3;
    57                 m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_3componentVertices[0];
     57                m_indexedMeshes[0].m_vertexBase = 0;
    5858                m_indexedMeshes[0].m_vertexStride = 3*sizeof(btScalar);
    5959        }
     
    112112                        }
    113113        }
    114                 m_3componentVertices.push_back(vertex.getX());
    115                 m_3componentVertices.push_back(vertex.getY());
    116                 m_3componentVertices.push_back(vertex.getZ());
     114                m_3componentVertices.push_back((float)vertex.getX());
     115                m_3componentVertices.push_back((float)vertex.getY());
     116                m_3componentVertices.push_back((float)vertex.getZ());
    117117                m_indexedMeshes[0].m_numVertices++;
    118118                m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_3componentVertices[0];
  • code/trunk/src/bullet/BulletCollision/CollisionShapes/btTriangleMeshShape.h

    r2662 r2882  
    4141        virtual btVector3       localGetSupportingVertexWithoutMargin(const btVector3& vec)const
    4242        {
    43                 assert(0);
     43                btAssert(0);
    4444                return localGetSupportingVertex(vec);
    4545        }
Note: See TracChangeset for help on using the changeset viewer.