Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 8, 2009, 12:58:47 AM (16 years ago)
Author:
dafrick
Message:

Reverted to revision 2906 (because I'm too stupid to merge correctly, 2nd try will follow shortly. ;))

Location:
code/branches/questsystem5
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • code/branches/questsystem5

  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btBoxShape.h

    r2907 r2908  
    162162                {
    163163                case 0:
    164                         plane.setValue(btScalar(1.),btScalar(0.),btScalar(0.),-halfExtents.x());
     164                        plane.setValue(btScalar(1.),btScalar(0.),btScalar(0.));
     165                        plane[3] = -halfExtents.x();
    165166                        break;
    166167                case 1:
    167                         plane.setValue(btScalar(-1.),btScalar(0.),btScalar(0.),-halfExtents.x());
     168                        plane.setValue(btScalar(-1.),btScalar(0.),btScalar(0.));
     169                        plane[3] = -halfExtents.x();
    168170                        break;
    169171                case 2:
    170                         plane.setValue(btScalar(0.),btScalar(1.),btScalar(0.),-halfExtents.y());
     172                        plane.setValue(btScalar(0.),btScalar(1.),btScalar(0.));
     173                        plane[3] = -halfExtents.y();
    171174                        break;
    172175                case 3:
    173                         plane.setValue(btScalar(0.),btScalar(-1.),btScalar(0.),-halfExtents.y());
     176                        plane.setValue(btScalar(0.),btScalar(-1.),btScalar(0.));
     177                        plane[3] = -halfExtents.y();
    174178                        break;
    175179                case 4:
    176                         plane.setValue(btScalar(0.),btScalar(0.),btScalar(1.),-halfExtents.z());
     180                        plane.setValue(btScalar(0.),btScalar(0.),btScalar(1.));
     181                        plane[3] = -halfExtents.z();
    177182                        break;
    178183                case 5:
    179                         plane.setValue(btScalar(0.),btScalar(0.),btScalar(-1.),-halfExtents.z());
     184                        plane.setValue(btScalar(0.),btScalar(0.),btScalar(-1.));
     185                        plane[3] = -halfExtents.z();
    180186                        break;
    181187                default:
    182                         btAssert(0);
     188                        assert(0);
    183189                }
    184190        }
     
    307313                        break;
    308314                default:
    309                         btAssert(0);
     315                        assert(0);
    310316                }
    311317        }
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btCollisionShape.cpp

    r2907 r2908  
    1515
    1616#include "BulletCollision/CollisionShapes/btCollisionShape.h"
    17 
    18 
    19 btScalar gContactThresholdFactor=btScalar(0.02);
    2017
    2118
     
    4845btScalar        btCollisionShape::getContactBreakingThreshold() const
    4946{
    50         return getAngularMotionDisc() * gContactThresholdFactor;
     47        ///@todo make this 0.1 configurable
     48        return getAngularMotionDisc() * btScalar(0.1);
    5149}
    5250btScalar        btCollisionShape::getAngularMotionDisc() const
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btCompoundShape.cpp

    r2907 r2908  
    2323m_collisionMargin(btScalar(0.)),
    2424m_localScaling(btScalar(1.),btScalar(1.),btScalar(1.)),
    25 m_dynamicAabbTree(0),
    26 m_updateRevision(1)
     25m_dynamicAabbTree(0)
    2726{
    2827        m_shapeType = COMPOUND_SHAPE_PROXYTYPE;
     
    4847void    btCompoundShape::addChildShape(const btTransform& localTransform,btCollisionShape* shape)
    4948{
    50         m_updateRevision++;
    5149        //m_childTransforms.push_back(localTransform);
    5250        //m_childShapes.push_back(shape);
     
    5755        child.m_childMargin = shape->getMargin();
    5856
    59        
     57        m_children.push_back(child);
     58
    6059        //extend the local aabbMin/aabbMax
    6160        btVector3 localAabbMin,localAabbMax;
     
    7675        {
    7776                const btDbvtVolume      bounds=btDbvtVolume::FromMM(localAabbMin,localAabbMax);
    78                 int index = m_children.size();
     77                int index = m_children.size()-1;
    7978                child.m_node = m_dynamicAabbTree->insert(bounds,(void*)index);
    8079        }
    81 
    82         m_children.push_back(child);
    8380
    8481}
     
    103100void btCompoundShape::removeChildShapeByIndex(int childShapeIndex)
    104101{
    105         m_updateRevision++;
    106102        btAssert(childShapeIndex >=0 && childShapeIndex < m_children.size());
    107103        if (m_dynamicAabbTree)
     
    118114void btCompoundShape::removeChildShape(btCollisionShape* shape)
    119115{
    120         m_updateRevision++;
    121116        // Find the children containing the shape specified, and remove those children.
    122117        //note: there might be multiple children using the same shape!
     
    145140        // Recalculate the local aabb
    146141        // Brute force, it iterates over all the shapes left.
    147 
    148142        m_localAabbMin = btVector3(btScalar(1e30),btScalar(1e30),btScalar(1e30));
    149143        m_localAabbMax = btVector3(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30));
     
    168162{
    169163        btVector3 localHalfExtents = btScalar(0.5)*(m_localAabbMax-m_localAabbMin);
     164        localHalfExtents += btVector3(getMargin(),getMargin(),getMargin());
    170165        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         }
    178         localHalfExtents += btVector3(getMargin(),getMargin(),getMargin());
    179                
    180166
    181167        btMatrix3x3 abs_b = trans.getBasis().absolute(); 
     
    188174        aabbMin = center-extent;
    189175        aabbMax = center+extent;
    190        
     176
    191177}
    192178
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btCompoundShape.h

    r2907 r2908  
    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;
    6461
    6562public:
     
    156153        void calculatePrincipalAxisTransform(btScalar* masses, btTransform& principal, btVector3& inertia) const;
    157154
    158         int     getUpdateRevision() const
    159         {
    160                 return m_updateRevision;
    161         }
    162155
    163156private:
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btConeShape.cpp

    r2907 r2908  
    6161                break;
    6262        default:
    63                 btAssert(0);
     63                assert(0);
    6464        };
    6565}
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btConvexHullShape.cpp

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

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

    r2907 r2908  
    155155
    156156                btCapsuleShape* capsuleShape = (btCapsuleShape*)this;
     157                btVector3 halfExtents = capsuleShape->getImplicitShapeDimensions();
    157158                btScalar halfHeight = capsuleShape->getHalfHeight();
    158159                int capsuleUpAxis = capsuleShape->getUpAxis();
     
    301302        {
    302303                btSphereShape* sphereShape = (btSphereShape*)this;
    303                 btScalar radius = sphereShape->getImplicitShapeDimensions().getX();// * convexShape->getLocalScaling().getX();
    304                 btScalar margin = radius + sphereShape->getMarginNonVirtual();
     304                float radius = sphereShape->getImplicitShapeDimensions().getX();// * convexShape->getLocalScaling().getX();
     305                float margin = radius + sphereShape->getMarginNonVirtual();
    305306                const btVector3& center = t.getOrigin();
    306307                btVector3 extent(margin,margin,margin);
     
    314315        {
    315316                btBoxShape* convexShape = (btBoxShape*)this;
    316                 btScalar margin=convexShape->getMarginNonVirtual();
     317                float margin=convexShape->getMarginNonVirtual();
    317318                btVector3 halfExtents = convexShape->getImplicitShapeDimensions();
    318319                halfExtents += btVector3(margin,margin,margin);
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp

    r2907 r2908  
    145145}
    146146
    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.
    151 btScalar
    152 btHeightfieldTerrainShape::getRawHeightFieldValue(int x,int y) const
     147btScalar        btHeightfieldTerrainShape::getHeightFieldValue(int x,int y) const
    153148{
    154149        btScalar val = 0.f;
     
    187182
    188183
    189 /// this returns the vertex in bullet-local coordinates
     184
    190185void    btHeightfieldTerrainShape::getVertex(int x,int y,btVector3& vertex) const
    191186{
     187
    192188        btAssert(x>=0);
    193189        btAssert(y>=0);
     
    195191        btAssert(y<m_heightStickLength);
    196192
    197         btScalar        height = getRawHeightFieldValue(x,y);
     193
     194        btScalar        height = getHeightFieldValue(x,y);
    198195
    199196        switch (m_upAxis)
     
    202199                {
    203200                vertex.setValue(
    204                         height - m_localOrigin.getX(),
     201                        height,
    205202                        (-m_width/btScalar(2.0)) + x,
    206203                        (-m_length/btScalar(2.0) ) + y
     
    212209                        vertex.setValue(
    213210                        (-m_width/btScalar(2.0)) + x,
    214                         height - m_localOrigin.getY(),
     211                        height,
    215212                        (-m_length/btScalar(2.0)) + y
    216213                        );
     
    222219                        (-m_width/btScalar(2.0)) + x,
    223220                        (-m_length/btScalar(2.0)) + y,
    224                         height - m_localOrigin.getZ()
     221                        height
    225222                        );
    226223                        break;
     
    234231
    235232        vertex*=m_localScaling;
     233       
    236234}
    237235
     
    241239getQuantized
    242240(
    243 btScalar x
     241float x
    244242)
    245243{
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h

    r2907 r2908  
    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.
    4332
    4433  Most (but not all) rendering and heightfield libraries assume upAxis = 1
     
    10089        btVector3       m_localScaling;
    10190
    102         virtual btScalar        getRawHeightFieldValue(int x,int y) const;
     91        virtual btScalar        getHeightFieldValue(int x,int y) const;
    10392        void            quantizeWithClamp(int* out, const btVector3& point,int isMax) const;
    10493        void            getVertex(int x,int y,btVector3& vertex) const;
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp

    r2907 r2908  
    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/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h

    r2907 r2908  
    3232        BT_DECLARE_ALIGNED_ALLOCATOR();
    3333
    34     btMultimaterialTriangleMeshShape(): btBvhTriangleMeshShape() {m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;}
     34    btMultimaterialTriangleMeshShape(): btBvhTriangleMeshShape() {}
    3535    btMultimaterialTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true):
    3636        btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, buildBvh)
    3737        {
    38             m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;
    39 
    4038            btVector3 m_triangle[3];
    4139            const unsigned char *vertexbase;
     
    7068        btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, bvhAabbMin, bvhAabbMax, buildBvh)
    7169        {
    72             m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;
    73 
    7470            btVector3 m_triangle[3];
    7571            const unsigned char *vertexbase;
     
    112108*/
    113109    }
     110        virtual int     getShapeType() const
     111        {
     112                return MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;
     113        }
     114       
    114115        //debugging
    115116        virtual const char*     getName()const {return "MULTIMATERIALTRIANGLEMESH";}
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btSphereShape.h

    r2907 r2908  
    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 
    5650        //debugging
    5751        virtual const char*     getName()const {return "SPHERE";}
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp

    r2907 r2908  
    8383}
    8484
    85 
    86 void    btTriangleIndexVertexArray::setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax ) const
     85void    btTriangleIndexVertexArray::setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax )
    8786{
    8887        m_aabbMin = aabbMin;
     
    9796}
    9897
    99 
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h

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

    r2907 r2908  
    1 
    21/*
    32Bullet Continuous Collision Detection and Physics Library
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btTriangleMesh.cpp

    r2907 r2908  
    3636        {
    3737                m_indexedMeshes[0].m_numTriangles = m_32bitIndices.size()/3;
    38                 m_indexedMeshes[0].m_triangleIndexBase = 0;
     38                m_indexedMeshes[0].m_triangleIndexBase = (unsigned char*) &m_32bitIndices[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 = 0;
     44                m_indexedMeshes[0].m_triangleIndexBase = (unsigned char*) &m_16bitIndices[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 = 0;
     52                m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_4componentVertices[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 = 0;
     57                m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_3componentVertices[0];
    5858                m_indexedMeshes[0].m_vertexStride = 3*sizeof(btScalar);
    5959        }
     
    112112                        }
    113113        }
    114                 m_3componentVertices.push_back((float)vertex.getX());
    115                 m_3componentVertices.push_back((float)vertex.getY());
    116                 m_3componentVertices.push_back((float)vertex.getZ());
     114                m_3componentVertices.push_back(vertex.getX());
     115                m_3componentVertices.push_back(vertex.getY());
     116                m_3componentVertices.push_back(vertex.getZ());
    117117                m_indexedMeshes[0].m_numVertices++;
    118118                m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_3componentVertices[0];
  • code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btTriangleMeshShape.h

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