Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 3, 2011, 5:07:42 AM (14 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/CollisionShapes
Files:
2 added
40 edited

Legend:

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

    r8351 r8393  
    1414*/
    1515
    16 #ifndef OBB_BOX_2D_SHAPE_H
    17 #define OBB_BOX_2D_SHAPE_H
     16#ifndef BT_OBB_BOX_2D_SHAPE_H
     17#define BT_OBB_BOX_2D_SHAPE_H
    1818
    1919#include "BulletCollision/CollisionShapes/btPolyhedralConvexShape.h"
     
    359359};
    360360
    361 #endif //OBB_BOX_2D_SHAPE_H
    362 
    363 
     361#endif //BT_OBB_BOX_2D_SHAPE_H
     362
     363
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btBoxShape.h

    r8351 r8393  
    1414*/
    1515
    16 #ifndef OBB_BOX_MINKOWSKI_H
    17 #define OBB_BOX_MINKOWSKI_H
     16#ifndef BT_OBB_BOX_MINKOWSKI_H
     17#define BT_OBB_BOX_MINKOWSKI_H
    1818
    1919#include "btPolyhedralConvexShape.h"
     
    146146        virtual void getVertex(int i,btVector3& vtx) const
    147147        {
    148                 btVector3 halfExtents = getHalfExtentsWithoutMargin();
     148                btVector3 halfExtents = getHalfExtentsWithMargin();
    149149
    150150                vtx = btVector3(
     
    314314
    315315
    316 #endif //OBB_BOX_MINKOWSKI_H
    317 
    318 
     316#endif //BT_OBB_BOX_MINKOWSKI_H
     317
     318
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp

    r8351 r8393  
    278278
    279279                        unsigned int* gfxbase = (unsigned int*)(indexbase+nodeTriangleIndex*indexstride);
    280                         btAssert(indicestype==PHY_INTEGER||indicestype==PHY_SHORT);
     280                        btAssert(indicestype==PHY_INTEGER||indicestype==PHY_SHORT||indicestype==PHY_UCHAR);
    281281       
    282282                        const btVector3& meshScaling = m_meshInterface->getScaling();
     
    284284                        {
    285285                               
    286                                 int graphicsindex = indicestype==PHY_SHORT?((unsigned short*)gfxbase)[j]:gfxbase[j];
     286                                int graphicsindex = indicestype==PHY_SHORT?((unsigned short*)gfxbase)[j]:indicestype==PHY_INTEGER?gfxbase[j]:((unsigned char*)gfxbase)[j];
    287287
    288288
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h

    r8351 r8393  
    1414*/
    1515
    16 #ifndef BVH_TRIANGLE_MESH_SHAPE_H
    17 #define BVH_TRIANGLE_MESH_SHAPE_H
     16#ifndef BT_BVH_TRIANGLE_MESH_SHAPE_H
     17#define BT_BVH_TRIANGLE_MESH_SHAPE_H
    1818
    1919#include "btTriangleMeshShape.h"
     
    4040        BT_DECLARE_ALIGNED_ALLOCATOR();
    4141
    42         btBvhTriangleMeshShape() : btTriangleMeshShape(0),m_bvh(0),m_triangleInfoMap(0),m_ownsBvh(false) {m_shapeType = TRIANGLE_MESH_SHAPE_PROXYTYPE;};
     42       
    4343        btBvhTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true);
    4444
     
    137137
    138138
    139 #endif //BVH_TRIANGLE_MESH_SHAPE_H
     139#endif //BT_BVH_TRIANGLE_MESH_SHAPE_H
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btCollisionMargin.h

    r8351 r8393  
    1414*/
    1515
    16 #ifndef COLLISION_MARGIN_H
    17 #define COLLISION_MARGIN_H
     16#ifndef BT_COLLISION_MARGIN_H
     17#define BT_COLLISION_MARGIN_H
    1818
    1919//used by Gjk and some other algorithms
     
    2323
    2424
    25 #endif //COLLISION_MARGIN_H
     25#endif //BT_COLLISION_MARGIN_H
    2626
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btCollisionShape.h

    r8351 r8393  
    1414*/
    1515
    16 #ifndef COLLISION_SHAPE_H
    17 #define COLLISION_SHAPE_H
     16#ifndef BT_COLLISION_SHAPE_H
     17#define BT_COLLISION_SHAPE_H
    1818
    1919#include "LinearMath/btTransform.h"
     
    147147
    148148
    149 #endif //COLLISION_SHAPE_H
     149#endif //BT_COLLISION_SHAPE_H
    150150
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btCompoundShape.cpp

    r8351 r8393  
    8686}
    8787
    88 void    btCompoundShape::updateChildTransform(int childIndex, const btTransform& newChildTransform)
     88void    btCompoundShape::updateChildTransform(int childIndex, const btTransform& newChildTransform,bool shouldRecalculateLocalAabb)
    8989{
    9090        m_children[childIndex].m_transform = newChildTransform;
     
    100100        }
    101101
    102         recalculateLocalAabb();
     102        if (shouldRecalculateLocalAabb)
     103        {
     104                recalculateLocalAabb();
     105        }
    103106}
    104107
     
    284287                m_children[i].m_childShape->setLocalScaling(childScale);
    285288                childTrans.setOrigin((childTrans.getOrigin())*scaling);
    286                 updateChildTransform(i, childTrans);
    287                 recalculateLocalAabb();
    288         }
     289                updateChildTransform(i, childTrans,false);
     290        }
     291       
    289292        m_localScaling = scaling;
     293        recalculateLocalAabb();
     294
    290295}
    291296
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btCompoundShape.h

    r8351 r8393  
    1414*/
    1515
    16 #ifndef COMPOUND_SHAPE_H
    17 #define COMPOUND_SHAPE_H
     16#ifndef BT_COMPOUND_SHAPE_H
     17#define BT_COMPOUND_SHAPE_H
    1818
    1919#include "btCollisionShape.h"
     
    107107
    108108        ///set a new transform for a child, and update internal data structures (local aabb and dynamic tree)
    109         void    updateChildTransform(int childIndex, const btTransform& newChildTransform);
     109        void    updateChildTransform(int childIndex, const btTransform& newChildTransform, bool shouldRecalculateLocalAabb = true);
    110110
    111111
     
    144144        }
    145145
    146 
    147         btDbvt*                                                 getDynamicAabbTree()
     146        const btDbvt*   getDynamicAabbTree() const
     147        {
     148                return m_dynamicAabbTree;
     149        }
     150       
     151        btDbvt* getDynamicAabbTree()
    148152        {
    149153                return m_dynamicAabbTree;
     
    206210
    207211
    208 #endif //COMPOUND_SHAPE_H
     212#endif //BT_COMPOUND_SHAPE_H
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btConcaveShape.h

    r8351 r8393  
    1414*/
    1515
    16 #ifndef CONCAVE_SHAPE_H
    17 #define CONCAVE_SHAPE_H
     16#ifndef BT_CONCAVE_SHAPE_H
     17#define BT_CONCAVE_SHAPE_H
    1818
    1919#include "btCollisionShape.h"
     
    5858};
    5959
    60 #endif //CONCAVE_SHAPE_H
     60#endif //BT_CONCAVE_SHAPE_H
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btConeShape.cpp

    r8351 r8393  
    132132
    133133
     134void    btConeShape::setLocalScaling(const btVector3& scaling)
     135{
     136        int axis = m_coneIndices[1];
     137        int r1 = m_coneIndices[0];
     138        int r2 = m_coneIndices[2];
     139        m_height *= scaling[axis] / m_localScaling[axis];
     140        m_radius *= (scaling[r1] / m_localScaling[r1] + scaling[r2] / m_localScaling[r2]) / 2;
     141        m_sinAngle = (m_radius / btSqrt(m_radius * m_radius + m_height * m_height));
     142        btConvexInternalShape::setLocalScaling(scaling);
     143}
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btConeShape.h

    r8351 r8393  
    1414*/
    1515
    16 #ifndef CONE_MINKOWSKI_H
    17 #define CONE_MINKOWSKI_H
     16#ifndef BT_CONE_MINKOWSKI_H
     17#define BT_CONE_MINKOWSKI_H
    1818
    1919#include "btConvexInternalShape.h"
     
    8282                        return m_coneIndices[1];
    8383                }
     84
     85        virtual void    setLocalScaling(const btVector3& scaling);
     86
    8487};
    8588
     
    97100                btConeShapeZ(btScalar radius,btScalar height);
    98101};
    99 #endif //CONE_MINKOWSKI_H
     102#endif //BT_CONE_MINKOWSKI_H
    100103
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btConvex2dShape.h

    r8351 r8393  
    2020#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
    2121
    22 ///The btConvex2dShape allows to use arbitrary convex shapes are 2d convex shapes, with the Z component assumed to be 0.
     22///The btConvex2dShape allows to use arbitrary convex shapes as 2d convex shapes, with the Z component assumed to be 0.
    2323///For 2d boxes, the btBox2dShape is recommended.
    2424class btConvex2dShape : public btConvexShape
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btConvexHullShape.h

    r8351 r8393  
    1414*/
    1515
    16 #ifndef CONVEX_HULL_SHAPE_H
    17 #define CONVEX_HULL_SHAPE_H
     16#ifndef BT_CONVEX_HULL_SHAPE_H
     17#define BT_CONVEX_HULL_SHAPE_H
    1818
    1919#include "btPolyhedralConvexShape.h"
     
    117117
    118118
    119 #endif //CONVEX_HULL_SHAPE_H
     119#endif //BT_CONVEX_HULL_SHAPE_H
    120120
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btConvexShape.h

    r8351 r8393  
    1414*/
    1515
    16 #ifndef CONVEX_SHAPE_INTERFACE1
    17 #define CONVEX_SHAPE_INTERFACE1
     16#ifndef BT_CONVEX_SHAPE_INTERFACE1
     17#define BT_CONVEX_SHAPE_INTERFACE1
    1818
    1919#include "btCollisionShape.h"
     
    8080
    8181
    82 #endif //CONVEX_SHAPE_INTERFACE1
     82#endif //BT_CONVEX_SHAPE_INTERFACE1
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h

    r8351 r8393  
    13133. This notice may not be removed or altered from any source distribution.
    1414*/
    15 #ifndef CONVEX_TRIANGLEMESH_SHAPE_H
    16 #define CONVEX_TRIANGLEMESH_SHAPE_H
     15#ifndef BT_CONVEX_TRIANGLEMESH_SHAPE_H
     16#define BT_CONVEX_TRIANGLEMESH_SHAPE_H
    1717
    1818
     
    7070
    7171
    72 #endif //CONVEX_TRIANGLEMESH_SHAPE_H
     72#endif //BT_CONVEX_TRIANGLEMESH_SHAPE_H
    7373
    7474
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btCylinderShape.cpp

    r8351 r8393  
    4848void    btCylinderShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const
    4949{
    50         //approximation of box shape, todo: implement cylinder shape inertia before people notice ;-)
     50
     51//Until Bullet 2.77 a box approximation was used, so uncomment this if you need backwards compatibility
     52//#define USE_BOX_INERTIA_APPROXIMATION 1
     53#ifndef USE_BOX_INERTIA_APPROXIMATION
     54
     55        /*
     56        cylinder is defined as following:
     57        *
     58        * - principle axis aligned along y by default, radius in x, z-value not used
     59        * - for btCylinderShapeX: principle axis aligned along x, radius in y direction, z-value not used
     60        * - for btCylinderShapeZ: principle axis aligned along z, radius in x direction, y-value not used
     61        *
     62        */
     63
     64        btScalar radius2;       // square of cylinder radius
     65        btScalar height2;       // square of cylinder height
     66        btVector3 halfExtents = getHalfExtentsWithMargin();     // get cylinder dimension
     67        btScalar div12 = mass / 12.f;
     68        btScalar div4 = mass / 4.f;
     69        btScalar div2 = mass / 2.f;
     70        int idxRadius, idxHeight;
     71
     72        switch (m_upAxis)       // get indices of radius and height of cylinder
     73        {
     74                case 0:         // cylinder is aligned along x
     75                        idxRadius = 1;
     76                        idxHeight = 0;
     77                        break;
     78                case 2:         // cylinder is aligned along z
     79                        idxRadius = 0;
     80                        idxHeight = 2;
     81                        break;
     82                default:        // cylinder is aligned along y
     83                        idxRadius = 0;
     84                        idxHeight = 1;
     85        }
     86
     87        // calculate squares
     88        radius2 = halfExtents[idxRadius] * halfExtents[idxRadius];
     89        height2 = btScalar(4.) * halfExtents[idxHeight] * halfExtents[idxHeight];
     90
     91        // calculate tensor terms
     92        btScalar t1 = div12 * height2 + div4 * radius2;
     93        btScalar t2 = div2 * radius2;
     94
     95        switch (m_upAxis)       // set diagonal elements of inertia tensor
     96        {
     97                case 0:         // cylinder is aligned along x
     98                        inertia.setValue(t2,t1,t1);
     99                        break;
     100                case 2:         // cylinder is aligned along z
     101                        inertia.setValue(t1,t1,t2);
     102                        break;
     103                default:        // cylinder is aligned along y
     104                        inertia.setValue(t1,t2,t1);
     105        }
     106#else //USE_BOX_INERTIA_APPROXIMATION
     107        //approximation of box shape
    51108        btVector3 halfExtents = getHalfExtentsWithMargin();
    52109
     
    58115                                        mass/(btScalar(12.0)) * (lx*lx + lz*lz),
    59116                                        mass/(btScalar(12.0)) * (lx*lx + ly*ly));
    60 
     117#endif //USE_BOX_INERTIA_APPROXIMATION
    61118}
    62119
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btCylinderShape.h

    r8351 r8393  
    1414*/
    1515
    16 #ifndef CYLINDER_MINKOWSKI_H
    17 #define CYLINDER_MINKOWSKI_H
     16#ifndef BT_CYLINDER_MINKOWSKI_H
     17#define BT_CYLINDER_MINKOWSKI_H
    1818
    1919#include "btBoxShape.h"
     
    197197
    198198
    199 #endif //CYLINDER_MINKOWSKI_H
    200 
     199#endif //BT_CYLINDER_MINKOWSKI_H
     200
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btEmptyShape.h

    r8351 r8393  
    1414*/
    1515
    16 #ifndef EMPTY_SHAPE_H
    17 #define EMPTY_SHAPE_H
     16#ifndef BT_EMPTY_SHAPE_H
     17#define BT_EMPTY_SHAPE_H
    1818
    1919#include "btConcaveShape.h"
     
    6868
    6969
    70 #endif //EMPTY_SHAPE_H
     70#endif //BT_EMPTY_SHAPE_H
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h

    r8351 r8393  
    1414*/
    1515
    16 #ifndef HEIGHTFIELD_TERRAIN_SHAPE_H
    17 #define HEIGHTFIELD_TERRAIN_SHAPE_H
     16#ifndef BT_HEIGHTFIELD_TERRAIN_SHAPE_H
     17#define BT_HEIGHTFIELD_TERRAIN_SHAPE_H
    1818
    1919#include "btConcaveShape.h"
     
    159159};
    160160
    161 #endif //HEIGHTFIELD_TERRAIN_SHAPE_H
     161#endif //BT_HEIGHTFIELD_TERRAIN_SHAPE_H
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btMaterial.h

    r8351 r8393  
    1616/// This file was created by Alex Silverman
    1717
    18 #ifndef MATERIAL_H
    19 #define MATERIAL_H
     18#ifndef BT_MATERIAL_H
     19#define BT_MATERIAL_H
    2020
    2121// Material class to be used by btMultimaterialTriangleMeshShape to store triangle properties
     
    3232};
    3333
    34 #endif // MATERIAL_H
     34#endif // BT_MATERIAL_H
    3535
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btMinkowskiSumShape.h

    r8351 r8393  
    1414*/
    1515
    16 #ifndef MINKOWSKI_SUM_SHAPE_H
    17 #define MINKOWSKI_SUM_SHAPE_H
     16#ifndef BT_MINKOWSKI_SUM_SHAPE_H
     17#define BT_MINKOWSKI_SUM_SHAPE_H
    1818
    1919#include "btConvexInternalShape.h"
     
    5858};
    5959
    60 #endif //MINKOWSKI_SUM_SHAPE_H
     60#endif //BT_MINKOWSKI_SUM_SHAPE_H
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btMultiSphereShape.h

    r8351 r8393  
    1414*/
    1515
    16 #ifndef MULTI_SPHERE_MINKOWSKI_H
    17 #define MULTI_SPHERE_MINKOWSKI_H
     16#ifndef BT_MULTI_SPHERE_MINKOWSKI_H
     17#define BT_MULTI_SPHERE_MINKOWSKI_H
    1818
    1919#include "btConvexInternalShape.h"
     
    9797
    9898
    99 #endif //MULTI_SPHERE_MINKOWSKI_H
     99#endif //BT_MULTI_SPHERE_MINKOWSKI_H
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h

    r8351 r8393  
    1616/// This file was created by Alex Silverman
    1717
    18 #ifndef BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H
    19 #define BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H
     18#ifndef BT_BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H
     19#define BT_BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H
    2020
    2121#include "btBvhTriangleMeshShape.h"
     
    3232        BT_DECLARE_ALIGNED_ALLOCATOR();
    3333
    34     btMultimaterialTriangleMeshShape(): btBvhTriangleMeshShape() {m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;}
    3534    btMultimaterialTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true):
    3635        btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, buildBvh)
     
    119118;
    120119
    121 #endif //BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H
     120#endif //BT_BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btOptimizedBvh.h

    r8351 r8393  
    1616///Contains contributions from Disney Studio's
    1717
    18 #ifndef OPTIMIZED_BVH_H
    19 #define OPTIMIZED_BVH_H
     18#ifndef BT_OPTIMIZED_BVH_H
     19#define BT_OPTIMIZED_BVH_H
    2020
    2121#include "BulletCollision/BroadphaseCollision/btQuantizedBvh.h"
     
    6161
    6262
    63 #endif //OPTIMIZED_BVH_H
     63#endif //BT_OPTIMIZED_BVH_H
    6464
    6565
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp

    r8351 r8393  
    1515
    1616#include "BulletCollision/CollisionShapes/btPolyhedralConvexShape.h"
    17 
    18 btPolyhedralConvexShape::btPolyhedralConvexShape() :btConvexInternalShape()
    19 {
    20 
     17#include "btConvexPolyhedron.h"
     18#include "LinearMath/btConvexHullComputer.h"
     19#include <new>
     20
     21btPolyhedralConvexShape::btPolyhedralConvexShape() :btConvexInternalShape(),
     22m_polyhedron(0)
     23{
     24
     25}
     26
     27btPolyhedralConvexShape::~btPolyhedralConvexShape()
     28{
     29        if (m_polyhedron)
     30        {
     31                btAlignedFree(m_polyhedron);
     32        }
     33}
     34
     35bool    btPolyhedralConvexShape::initializePolyhedralFeatures()
     36{
     37        if (m_polyhedron)
     38                btAlignedFree(m_polyhedron);
     39       
     40        void* mem = btAlignedAlloc(sizeof(btConvexPolyhedron),16);
     41        m_polyhedron = new (mem) btConvexPolyhedron;
     42
     43        btAlignedObjectArray<btVector3> tmpVertices;
     44        for (int i=0;i<getNumVertices();i++)
     45        {
     46                btVector3& newVertex = tmpVertices.expand();
     47                getVertex(i,newVertex);
     48        }
     49
     50        btConvexHullComputer conv;
     51        conv.compute(&tmpVertices[0].getX(), sizeof(btVector3),tmpVertices.size(),0.f,0.f);
     52
     53       
     54
     55        btAlignedObjectArray<btVector3> faceNormals;
     56        int numFaces = conv.faces.size();
     57        faceNormals.resize(numFaces);
     58        btConvexHullComputer* convexUtil = &conv;
     59
     60       
     61       
     62        m_polyhedron->m_faces.resize(numFaces);
     63        int numVertices = convexUtil->vertices.size();
     64        m_polyhedron->m_vertices.resize(numVertices);
     65        for (int p=0;p<numVertices;p++)
     66        {
     67                m_polyhedron->m_vertices[p] = convexUtil->vertices[p];
     68        }
     69
     70        for (int i=0;i<numFaces;i++)
     71        {
     72                int face = convexUtil->faces[i];
     73                //printf("face=%d\n",face);
     74                const btConvexHullComputer::Edge*  firstEdge = &convexUtil->edges[face];
     75                const btConvexHullComputer::Edge*  edge = firstEdge;
     76
     77                btVector3 edges[3];
     78                int numEdges = 0;
     79                //compute face normals
     80
     81                btScalar maxCross2 = 0.f;
     82                int chosenEdge = -1;
     83
     84                do
     85                {
     86                       
     87                        int src = edge->getSourceVertex();
     88                        m_polyhedron->m_faces[i].m_indices.push_back(src);
     89                        int targ = edge->getTargetVertex();
     90                        btVector3 wa = convexUtil->vertices[src];
     91
     92                        btVector3 wb = convexUtil->vertices[targ];
     93                        btVector3 newEdge = wb-wa;
     94                        newEdge.normalize();
     95                        if (numEdges<2)
     96                                edges[numEdges++] = newEdge;
     97
     98                        edge = edge->getNextEdgeOfFace();
     99                } while (edge!=firstEdge);
     100
     101                btScalar planeEq = 1e30f;
     102
     103               
     104                if (numEdges==2)
     105                {
     106                        faceNormals[i] = edges[0].cross(edges[1]);
     107                        faceNormals[i].normalize();
     108                        m_polyhedron->m_faces[i].m_plane[0] = -faceNormals[i].getX();
     109                        m_polyhedron->m_faces[i].m_plane[1] = -faceNormals[i].getY();
     110                        m_polyhedron->m_faces[i].m_plane[2] = -faceNormals[i].getZ();
     111                        m_polyhedron->m_faces[i].m_plane[3] = planeEq;
     112
     113                }
     114                else
     115                {
     116                        btAssert(0);//degenerate?
     117                        faceNormals[i].setZero();
     118                }
     119
     120                for (int v=0;v<m_polyhedron->m_faces[i].m_indices.size();v++)
     121                {
     122                        btScalar eq = m_polyhedron->m_vertices[m_polyhedron->m_faces[i].m_indices[v]].dot(faceNormals[i]);
     123                        if (planeEq>eq)
     124                        {
     125                                planeEq=eq;
     126                        }
     127                }
     128                m_polyhedron->m_faces[i].m_plane[3] = planeEq;
     129        }
     130
     131
     132        if (m_polyhedron->m_faces.size() && conv.vertices.size())
     133        {
     134
     135                for (int f=0;f<m_polyhedron->m_faces.size();f++)
     136                {
     137                       
     138                        btVector3 planeNormal(m_polyhedron->m_faces[f].m_plane[0],m_polyhedron->m_faces[f].m_plane[1],m_polyhedron->m_faces[f].m_plane[2]);
     139                        btScalar planeEq = m_polyhedron->m_faces[f].m_plane[3];
     140
     141                        btVector3 supVec = localGetSupportingVertex(-planeNormal);
     142
     143                        if (supVec.dot(planeNormal)<planeEq)
     144                        {
     145                                m_polyhedron->m_faces[f].m_plane[0] *= -1;
     146                                m_polyhedron->m_faces[f].m_plane[1] *= -1;
     147                                m_polyhedron->m_faces[f].m_plane[2] *= -1;
     148                                m_polyhedron->m_faces[f].m_plane[3] *= -1;
     149                                int numVerts = m_polyhedron->m_faces[f].m_indices.size();
     150                                for (int v=0;v<numVerts/2;v++)
     151                                {
     152                                        btSwap(m_polyhedron->m_faces[f].m_indices[v],m_polyhedron->m_faces[f].m_indices[numVerts-1-v]);
     153                                }
     154                        }
     155                }
     156        }
     157
     158       
     159
     160        m_polyhedron->initialize();
     161
     162        return true;
    21163}
    22164
     
    192334}
    193335
     336
     337
     338
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btPolyhedralConvexShape.h

    r8351 r8393  
    1414*/
    1515
    16 #ifndef BU_SHAPE
    17 #define BU_SHAPE
     16#ifndef BT_POLYHEDRAL_CONVEX_SHAPE_H
     17#define BT_POLYHEDRAL_CONVEX_SHAPE_H
    1818
    1919#include "LinearMath/btMatrix3x3.h"
    2020#include "btConvexInternalShape.h"
     21class btConvexPolyhedron;
    2122
    2223
     
    2425class btPolyhedralConvexShape : public btConvexInternalShape
    2526{
     27       
    2628
    2729protected:
    2830       
     31        btConvexPolyhedron* m_polyhedron;
     32
    2933public:
    3034
    3135        btPolyhedralConvexShape();
     36
     37        virtual ~btPolyhedralConvexShape();
     38
     39        ///optional method mainly used to generate multiple contact points by clipping polyhedral features (faces/edges)
     40        virtual bool    initializePolyhedralFeatures();
     41
     42        const btConvexPolyhedron*       getConvexPolyhedron() const
     43        {
     44                return m_polyhedron;
     45        }
    3246
    3347        //brute force implementations
     
    96110};
    97111
    98 #endif //BU_SHAPE
     112#endif //BT_POLYHEDRAL_CONVEX_SHAPE_H
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp

    r8351 r8393  
    6363        scaledAabbMin[1] = m_localScaling.getY() >= 0. ? aabbMin[1] * invLocalScaling[1] : aabbMax[1] * invLocalScaling[1];
    6464        scaledAabbMin[2] = m_localScaling.getZ() >= 0. ? aabbMin[2] * invLocalScaling[2] : aabbMax[2] * invLocalScaling[2];
     65        scaledAabbMin[3] = 0.f;
    6566       
    6667        scaledAabbMax[0] = m_localScaling.getX() <= 0. ? aabbMin[0] * invLocalScaling[0] : aabbMax[0] * invLocalScaling[0];
    6768        scaledAabbMax[1] = m_localScaling.getY() <= 0. ? aabbMin[1] * invLocalScaling[1] : aabbMax[1] * invLocalScaling[1];
    6869        scaledAabbMax[2] = m_localScaling.getZ() <= 0. ? aabbMin[2] * invLocalScaling[2] : aabbMax[2] * invLocalScaling[2];
     70        scaledAabbMax[3] = 0.f;
    6971       
    7072       
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h

    r8351 r8393  
    1414*/
    1515
    16 #ifndef SCALED_BVH_TRIANGLE_MESH_SHAPE_H
    17 #define SCALED_BVH_TRIANGLE_MESH_SHAPE_H
     16#ifndef BT_SCALED_BVH_TRIANGLE_MESH_SHAPE_H
     17#define BT_SCALED_BVH_TRIANGLE_MESH_SHAPE_H
    1818
    1919#include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h"
     
    5858        virtual const char*     getName()const {return "SCALEDBVHTRIANGLEMESH";}
    5959
     60        virtual int     calculateSerializeBufferSize() const;
     61
     62        ///fills the dataBuffer and returns the struct name (and 0 on failure)
     63        virtual const char*     serialize(void* dataBuffer, btSerializer* serializer) const;
     64
    6065};
    6166
    62 #endif //BVH_TRIANGLE_MESH_SHAPE_H
     67///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
     68struct  btScaledTriangleMeshShapeData
     69{
     70        btTriangleMeshShapeData m_trimeshShapeData;
     71
     72        btVector3FloatData      m_localScaling;
     73};
     74
     75
     76SIMD_FORCE_INLINE       int     btScaledBvhTriangleMeshShape::calculateSerializeBufferSize() const
     77{
     78        return sizeof(btScaledTriangleMeshShapeData);
     79}
     80
     81
     82///fills the dataBuffer and returns the struct name (and 0 on failure)
     83SIMD_FORCE_INLINE       const char*     btScaledBvhTriangleMeshShape::serialize(void* dataBuffer, btSerializer* serializer) const
     84{
     85        btScaledTriangleMeshShapeData* scaledMeshData = (btScaledTriangleMeshShapeData*) dataBuffer;
     86        m_bvhTriMeshShape->serialize(&scaledMeshData->m_trimeshShapeData,serializer);
     87        scaledMeshData->m_trimeshShapeData.m_collisionShapeData.m_shapeType = SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE;
     88        m_localScaling.serializeFloat(scaledMeshData->m_localScaling);
     89        return "btScaledTriangleMeshShapeData";
     90}
     91
     92
     93#endif //BT_SCALED_BVH_TRIANGLE_MESH_SHAPE_H
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btShapeHull.h

    r8351 r8393  
    1616///btShapeHull implemented by John McCutchan.
    1717
    18 #ifndef _SHAPE_HULL_H
    19 #define _SHAPE_HULL_H
     18#ifndef BT_SHAPE_HULL_H
     19#define BT_SHAPE_HULL_H
    2020
    2121#include "LinearMath/btAlignedObjectArray.h"
     
    5757};
    5858
    59 #endif //_SHAPE_HULL_H
     59#endif //BT_SHAPE_HULL_H
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btSphereShape.h

    r8351 r8393  
    13133. This notice may not be removed or altered from any source distribution.
    1414*/
    15 #ifndef SPHERE_MINKOWSKI_H
    16 #define SPHERE_MINKOWSKI_H
     15#ifndef BT_SPHERE_MINKOWSKI_H
     16#define BT_SPHERE_MINKOWSKI_H
    1717
    1818#include "btConvexInternalShape.h"
     
    7171
    7272
    73 #endif //SPHERE_MINKOWSKI_H
     73#endif //BT_SPHERE_MINKOWSKI_H
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btStaticPlaneShape.h

    r8351 r8393  
    1414*/
    1515
    16 #ifndef STATIC_PLANE_SHAPE_H
    17 #define STATIC_PLANE_SHAPE_H
     16#ifndef BT_STATIC_PLANE_SHAPE_H
     17#define BT_STATIC_PLANE_SHAPE_H
    1818
    1919#include "btConcaveShape.h"
     
    9898
    9999
    100 #endif //STATIC_PLANE_SHAPE_H
     100#endif //BT_STATIC_PLANE_SHAPE_H
    101101
    102102
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btStridingMeshInterface.cpp

    r8351 r8393  
    8989                                         break;
    9090                                 }
     91                        case PHY_UCHAR:
     92                                 {
     93                                         for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
     94                                         {
     95                                                 unsigned char* tri_indices= (unsigned char*)(indexbase+gfxindex*indexstride);
     96                                                 graphicsbase = (float*)(vertexbase+tri_indices[0]*stride);
     97                                                 triangle[0].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ());
     98                                                 graphicsbase = (float*)(vertexbase+tri_indices[1]*stride);
     99                                                 triangle[1].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),    graphicsbase[2]*meshScaling.getZ());
     100                                                 graphicsbase = (float*)(vertexbase+tri_indices[2]*stride);
     101                                                 triangle[2].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),    graphicsbase[2]*meshScaling.getZ());
     102                                                 callback->internalProcessTriangleIndex(triangle,part,gfxindex);
     103                                         }
     104                                         break;
     105                                 }
    91106                         default:
    92107                                 btAssert((gfxindextype == PHY_INTEGER) || (gfxindextype == PHY_SHORT));
     
    121136                                                {
    122137                                                        unsigned short int* tri_indices= (unsigned short int*)(indexbase+gfxindex*indexstride);
     138                                                        graphicsbase = (double*)(vertexbase+tri_indices[0]*stride);
     139                                                        triangle[0].setValue((btScalar)graphicsbase[0]*meshScaling.getX(),(btScalar)graphicsbase[1]*meshScaling.getY(),(btScalar)graphicsbase[2]*meshScaling.getZ());
     140                                                        graphicsbase = (double*)(vertexbase+tri_indices[1]*stride);
     141                                                        triangle[1].setValue((btScalar)graphicsbase[0]*meshScaling.getX(),(btScalar)graphicsbase[1]*meshScaling.getY(),  (btScalar)graphicsbase[2]*meshScaling.getZ());
     142                                                        graphicsbase = (double*)(vertexbase+tri_indices[2]*stride);
     143                                                        triangle[2].setValue((btScalar)graphicsbase[0]*meshScaling.getX(),(btScalar)graphicsbase[1]*meshScaling.getY(),  (btScalar)graphicsbase[2]*meshScaling.getZ());
     144                                                        callback->internalProcessTriangleIndex(triangle,part,gfxindex);
     145                                                }
     146                                                break;
     147                                        }
     148                                case PHY_UCHAR:
     149                                        {
     150                                                for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
     151                                                {
     152                                                        unsigned char* tri_indices= (unsigned char*)(indexbase+gfxindex*indexstride);
    123153                                                        graphicsbase = (double*)(vertexbase+tri_indices[0]*stride);
    124154                                                        triangle[0].setValue((btScalar)graphicsbase[0]*meshScaling.getX(),(btScalar)graphicsbase[1]*meshScaling.getY(),(btScalar)graphicsbase[2]*meshScaling.getZ());
     
    267297                                        break;
    268298                                }
     299                                case PHY_UCHAR:
     300                                {
     301                                        if (numtriangles)
     302                                        {
     303                                                btChunk* chunk = serializer->allocate(sizeof(btCharIndexTripletData),numtriangles);
     304                                                btCharIndexTripletData* tmpIndices = (btCharIndexTripletData*)chunk->m_oldPtr;
     305                                                memPtr->m_3indices8 = (btCharIndexTripletData*) serializer->getUniquePointer(tmpIndices);
     306                                                for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
     307                                                {
     308                                                        unsigned char* tri_indices= (unsigned char*)(indexbase+gfxindex*indexstride);
     309                                                        tmpIndices[gfxindex].m_values[0] = tri_indices[0];
     310                                                        tmpIndices[gfxindex].m_values[1] = tri_indices[1];
     311                                                        tmpIndices[gfxindex].m_values[2] = tri_indices[2];
     312                                                }
     313                                                serializer->finalizeChunk(chunk,"btCharIndexTripletData",BT_ARRAY_CODE,(void*)chunk->m_oldPtr);
     314                                        }
     315                                        break;
     316                                }
    269317                        default:
    270318                                {
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btStridingMeshInterface.h

    r8351 r8393  
    1414*/
    1515
    16 #ifndef STRIDING_MESHINTERFACE_H
    17 #define STRIDING_MESHINTERFACE_H
     16#ifndef BT_STRIDING_MESHINTERFACE_H
     17#define BT_STRIDING_MESHINTERFACE_H
    1818
    1919#include "LinearMath/btVector3.h"
     
    117117};
    118118
     119struct  btCharIndexTripletData
     120{
     121        unsigned char m_values[3];
     122        char    m_pad;
     123};
     124
     125
    119126///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
    120127struct  btMeshPartData
     
    125132        btIntIndexData                          *m_indices32;
    126133        btShortIntIndexTripletData      *m_3indices16;
     134        btCharIndexTripletData          *m_3indices8;
    127135
    128136        btShortIntIndexData                     *m_indices16;//backwards compatibility
     
    152160
    153161
    154 #endif //STRIDING_MESHINTERFACE_H
     162#endif //BT_STRIDING_MESHINTERFACE_H
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btTetrahedronShape.h

    r8351 r8393  
    1414*/
    1515
    16 #ifndef BU_SIMPLEX_1TO4_SHAPE
    17 #define BU_SIMPLEX_1TO4_SHAPE
     16#ifndef BT_SIMPLEX_1TO4_SHAPE
     17#define BT_SIMPLEX_1TO4_SHAPE
    1818
    1919
     
    7272};
    7373
    74 #endif //BU_SIMPLEX_1TO4_SHAPE
     74#endif //BT_SIMPLEX_1TO4_SHAPE
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btTriangleCallback.h

    r8351 r8393  
    1414*/
    1515
    16 #ifndef TRIANGLE_CALLBACK_H
    17 #define TRIANGLE_CALLBACK_H
     16#ifndef BT_TRIANGLE_CALLBACK_H
     17#define BT_TRIANGLE_CALLBACK_H
    1818
    1919#include "LinearMath/btVector3.h"
     
    4040
    4141
    42 #endif //TRIANGLE_CALLBACK_H
     42#endif //BT_TRIANGLE_CALLBACK_H
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btTriangleInfoMap.h

    r8351 r8393  
    6262        btScalar        m_equalVertexThreshold; ///used to compute connectivity: if the distance between two vertices is smaller than m_equalVertexThreshold, they are considered to be 'shared'
    6363        btScalar        m_edgeDistanceThreshold; ///used to determine edge contacts: if the closest distance between a contact point and an edge is smaller than this distance threshold it is considered to "hit the edge"
     64        btScalar        m_maxEdgeAngleThreshold; //ignore edges that connect triangles at an angle larger than this m_maxEdgeAngleThreshold
    6465        btScalar        m_zeroAreaThreshold; ///used to determine if a triangle is degenerate (length squared of cross product of 2 triangle edges < threshold)
    6566       
     
    7273                m_edgeDistanceThreshold = btScalar(0.1);
    7374                m_zeroAreaThreshold = btScalar(0.0001)*btScalar(0.0001);
     75                m_maxEdgeAngleThreshold = SIMD_2_PI;
    7476        }
    7577        virtual ~btTriangleInfoMap() {}
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btTriangleMesh.h

    r8351 r8393  
    1414*/
    1515
    16 #ifndef TRIANGLE_MESH_H
    17 #define TRIANGLE_MESH_H
     16#ifndef BT_TRIANGLE_MESH_H
     17#define BT_TRIANGLE_MESH_H
    1818
    1919#include "btTriangleIndexVertexArray.h"
     
    6666};
    6767
    68 #endif //TRIANGLE_MESH_H
     68#endif //BT_TRIANGLE_MESH_H
    6969
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btTriangleMeshShape.h

    r8351 r8393  
    1414*/
    1515
    16 #ifndef TRIANGLE_MESH_SHAPE_H
    17 #define TRIANGLE_MESH_SHAPE_H
     16#ifndef BT_TRIANGLE_MESH_SHAPE_H
     17#define BT_TRIANGLE_MESH_SHAPE_H
    1818
    1919#include "btConcaveShape.h"
     
    8787
    8888
    89 #endif //TRIANGLE_MESH_SHAPE_H
     89#endif //BT_TRIANGLE_MESH_SHAPE_H
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btTriangleShape.h

    r8351 r8393  
    1414*/
    1515
    16 #ifndef OBB_TRIANGLE_MINKOWSKI_H
    17 #define OBB_TRIANGLE_MINKOWSKI_H
     16#ifndef BT_OBB_TRIANGLE_MINKOWSKI_H
     17#define BT_OBB_TRIANGLE_MINKOWSKI_H
    1818
    1919#include "btConvexShape.h"
     
    179179};
    180180
    181 #endif //OBB_TRIANGLE_MINKOWSKI_H
     181#endif //BT_OBB_TRIANGLE_MINKOWSKI_H
    182182
  • code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btUniformScalingShape.cpp

    r8351 r8393  
    6565
    6666        ///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version
    67 void btUniformScalingShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
     67void btUniformScalingShape::getAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax) const
    6868{
    69         m_childConvexShape->getAabb(t,aabbMin,aabbMax);
    70         btVector3 aabbCenter = (aabbMax+aabbMin)*btScalar(0.5);
    71         btVector3 scaledAabbHalfExtends = (aabbMax-aabbMin)*btScalar(0.5)*m_uniformScalingFactor;
    72 
    73         aabbMin = aabbCenter - scaledAabbHalfExtends;
    74         aabbMax = aabbCenter + scaledAabbHalfExtends;
     69        getAabbSlow(trans,aabbMin,aabbMax);
    7570
    7671}
     
    7873void btUniformScalingShape::getAabbSlow(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
    7974{
    80         m_childConvexShape->getAabbSlow(t,aabbMin,aabbMax);
    81         btVector3 aabbCenter = (aabbMax+aabbMin)*btScalar(0.5);
    82         btVector3 scaledAabbHalfExtends = (aabbMax-aabbMin)*btScalar(0.5)*m_uniformScalingFactor;
     75#if 1
     76        btVector3 _directions[] =
     77        {
     78                btVector3( 1.,  0.,  0.),
     79                btVector3( 0.,  1.,  0.),
     80                btVector3( 0.,  0.,  1.),
     81                btVector3( -1., 0.,  0.),
     82                btVector3( 0., -1.,  0.),
     83                btVector3( 0.,  0., -1.)
     84        };
     85       
     86        btVector3 _supporting[] =
     87        {
     88                btVector3( 0., 0., 0.),
     89                btVector3( 0., 0., 0.),
     90                btVector3( 0., 0., 0.),
     91                btVector3( 0., 0., 0.),
     92                btVector3( 0., 0., 0.),
     93                btVector3( 0., 0., 0.)
     94        };
    8395
    84         aabbMin = aabbCenter - scaledAabbHalfExtends;
    85         aabbMax = aabbCenter + scaledAabbHalfExtends;
     96        for (int i=0;i<6;i++)
     97        {
     98                _directions[i] = _directions[i]*t.getBasis();
     99        }
     100       
     101        batchedUnitVectorGetSupportingVertexWithoutMargin(_directions, _supporting, 6);
     102       
     103        btVector3 aabbMin1(0,0,0),aabbMax1(0,0,0);
     104
     105        for ( int i = 0; i < 3; ++i )
     106        {
     107                aabbMax1[i] = t(_supporting[i])[i];
     108                aabbMin1[i] = t(_supporting[i + 3])[i];
     109        }
     110        btVector3 marginVec(getMargin(),getMargin(),getMargin());
     111        aabbMin = aabbMin1-marginVec;
     112        aabbMax = aabbMax1+marginVec;
     113       
     114#else
     115
     116        btScalar margin = getMargin();
     117        for (int i=0;i<3;i++)
     118        {
     119                btVector3 vec(btScalar(0.),btScalar(0.),btScalar(0.));
     120                vec[i] = btScalar(1.);
     121                btVector3 sv = localGetSupportingVertex(vec*t.getBasis());
     122                btVector3 tmp = t(sv);
     123                aabbMax[i] = tmp[i]+margin;
     124                vec[i] = btScalar(-1.);
     125                sv = localGetSupportingVertex(vec*t.getBasis());
     126                tmp = t(sv);
     127                aabbMin[i] = tmp[i]-margin;
     128        }
     129
     130#endif
    86131}
    87132
Note: See TracChangeset for help on using the changeset viewer.