Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 21, 2011, 6:58:23 PM (13 years ago)
Author:
rgrieder
Message:

Merged revisions 7978 - 8096 from kicklib to kicklib2.

Location:
code/branches/kicklib2
Files:
70 edited
5 copied

Legend:

Unmodified
Added
Removed
  • code/branches/kicklib2

  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btBoxShape.cpp

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    13133. This notice may not be removed or altered from any source distribution.
    1414*/
    15 
    1615#include "btBoxShape.h"
    1716
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btBoxShape.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    4242        const btVector3& getHalfExtentsWithoutMargin() const
    4343        {
    44                 return m_implicitShapeDimensions;//changed in Bullet 2.63: assume the scaling and margin are included
     44                return m_implicitShapeDimensions;//scaling is included, margin is not
    4545        }
    4646       
     
    313313};
    314314
     315
    315316#endif //OBB_BOX_MINKOWSKI_H
    316317
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    1818#include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h"
    1919#include "BulletCollision/CollisionShapes/btOptimizedBvh.h"
     20#include "LinearMath/btSerializer.h"
    2021
    2122///Bvh Concave triangle mesh is a static-triangle mesh shape with Bounding Volume Hierarchy optimization.
     
    2425:btTriangleMeshShape(meshInterface),
    2526m_bvh(0),
     27m_triangleInfoMap(0),
    2628m_useQuantizedAabbCompression(useQuantizedAabbCompression),
    2729m_ownsBvh(false)
     
    3133#ifndef DISABLE_BVH
    3234
    33         btVector3 bvhAabbMin,bvhAabbMax;
    34         if(meshInterface->hasPremadeAabb())
    35         {
    36                 meshInterface->getPremadeAabb(&bvhAabbMin, &bvhAabbMax);
    37         }
    38         else
    39         {
    40                 meshInterface->calculateAabbBruteForce(bvhAabbMin,bvhAabbMax);
    41         }
    42        
    4335        if (buildBvh)
    4436        {
    45                 void* mem = btAlignedAlloc(sizeof(btOptimizedBvh),16);
    46                 m_bvh = new (mem) btOptimizedBvh();
    47                 m_bvh->build(meshInterface,m_useQuantizedAabbCompression,bvhAabbMin,bvhAabbMax);
    48                 m_ownsBvh = true;
     37                buildOptimizedBvh();
    4938        }
    5039
     
    5645:btTriangleMeshShape(meshInterface),
    5746m_bvh(0),
     47m_triangleInfoMap(0),
    5848m_useQuantizedAabbCompression(useQuantizedAabbCompression),
    5949m_ownsBvh(false)
     
    344334   {
    345335      btTriangleMeshShape::setLocalScaling(scaling);
    346       if (m_ownsBvh)
    347       {
    348          m_bvh->~btOptimizedBvh();
    349          btAlignedFree(m_bvh);
    350       }
    351       ///m_localAabbMin/m_localAabbMax is already re-calculated in btTriangleMeshShape. We could just scale aabb, but this needs some more work
    352       void* mem = btAlignedAlloc(sizeof(btOptimizedBvh),16);
    353       m_bvh = new(mem) btOptimizedBvh();
    354       //rebuild the bvh...
    355       m_bvh->build(m_meshInterface,m_useQuantizedAabbCompression,m_localAabbMin,m_localAabbMax);
    356       m_ownsBvh = true;
     336          buildOptimizedBvh();
    357337   }
     338}
     339
     340void   btBvhTriangleMeshShape::buildOptimizedBvh()
     341{
     342        if (m_ownsBvh)
     343        {
     344                m_bvh->~btOptimizedBvh();
     345                btAlignedFree(m_bvh);
     346        }
     347        ///m_localAabbMin/m_localAabbMax is already re-calculated in btTriangleMeshShape. We could just scale aabb, but this needs some more work
     348        void* mem = btAlignedAlloc(sizeof(btOptimizedBvh),16);
     349        m_bvh = new(mem) btOptimizedBvh();
     350        //rebuild the bvh...
     351        m_bvh->build(m_meshInterface,m_useQuantizedAabbCompression,m_localAabbMin,m_localAabbMax);
     352        m_ownsBvh = true;
    358353}
    359354
     
    373368
    374369
     370
     371///fills the dataBuffer and returns the struct name (and 0 on failure)
     372const char*     btBvhTriangleMeshShape::serialize(void* dataBuffer, btSerializer* serializer) const
     373{
     374        btTriangleMeshShapeData* trimeshData = (btTriangleMeshShapeData*) dataBuffer;
     375
     376        btCollisionShape::serialize(&trimeshData->m_collisionShapeData,serializer);
     377
     378        m_meshInterface->serialize(&trimeshData->m_meshInterface, serializer);
     379
     380        trimeshData->m_collisionMargin = float(m_collisionMargin);
     381
     382       
     383
     384        if (m_bvh && !(serializer->getSerializationFlags()&BT_SERIALIZE_NO_BVH))
     385        {
     386                void* chunk = serializer->findPointer(m_bvh);
     387                if (chunk)
     388                {
     389#ifdef BT_USE_DOUBLE_PRECISION
     390                        trimeshData->m_quantizedDoubleBvh = (btQuantizedBvhData*)chunk;
     391                        trimeshData->m_quantizedFloatBvh = 0;
     392#else
     393                        trimeshData->m_quantizedFloatBvh  = (btQuantizedBvhData*)chunk;
     394                        trimeshData->m_quantizedDoubleBvh= 0;
     395#endif //BT_USE_DOUBLE_PRECISION
     396                } else
     397                {
     398
     399#ifdef BT_USE_DOUBLE_PRECISION
     400                        trimeshData->m_quantizedDoubleBvh = (btQuantizedBvhData*)serializer->getUniquePointer(m_bvh);
     401                        trimeshData->m_quantizedFloatBvh = 0;
     402#else
     403                        trimeshData->m_quantizedFloatBvh  = (btQuantizedBvhData*)serializer->getUniquePointer(m_bvh);
     404                        trimeshData->m_quantizedDoubleBvh= 0;
     405#endif //BT_USE_DOUBLE_PRECISION
     406       
     407                        int sz = m_bvh->calculateSerializeBufferSizeNew();
     408                        btChunk* chunk = serializer->allocate(sz,1);
     409                        const char* structType = m_bvh->serialize(chunk->m_oldPtr, serializer);
     410                        serializer->finalizeChunk(chunk,structType,BT_QUANTIZED_BVH_CODE,m_bvh);
     411                }
     412        } else
     413        {
     414                trimeshData->m_quantizedFloatBvh = 0;
     415                trimeshData->m_quantizedDoubleBvh = 0;
     416        }
     417
     418       
     419
     420        if (m_triangleInfoMap && !(serializer->getSerializationFlags()&BT_SERIALIZE_NO_TRIANGLEINFOMAP))
     421        {
     422                void* chunk = serializer->findPointer(m_triangleInfoMap);
     423                if (chunk)
     424                {
     425                        trimeshData->m_triangleInfoMap = (btTriangleInfoMapData*)chunk;
     426                } else
     427                {
     428                        trimeshData->m_triangleInfoMap = (btTriangleInfoMapData*)serializer->getUniquePointer(m_triangleInfoMap);
     429                        int sz = m_triangleInfoMap->calculateSerializeBufferSize();
     430                        btChunk* chunk = serializer->allocate(sz,1);
     431                        const char* structType = m_triangleInfoMap->serialize(chunk->m_oldPtr, serializer);
     432                        serializer->finalizeChunk(chunk,structType,BT_TRIANLGE_INFO_MAP,m_triangleInfoMap);
     433                }
     434        } else
     435        {
     436                trimeshData->m_triangleInfoMap = 0;
     437        }
     438
     439        return "btTriangleMeshShapeData";
     440}
     441
     442void    btBvhTriangleMeshShape::serializeSingleBvh(btSerializer* serializer) const
     443{
     444        if (m_bvh)
     445        {
     446                int len = m_bvh->calculateSerializeBufferSizeNew(); //make sure not to use calculateSerializeBufferSize because it is used for in-place
     447                btChunk* chunk = serializer->allocate(len,1);
     448                const char* structType = m_bvh->serialize(chunk->m_oldPtr, serializer);
     449                serializer->finalizeChunk(chunk,structType,BT_QUANTIZED_BVH_CODE,(void*)m_bvh);
     450        }
     451}
     452
     453void    btBvhTriangleMeshShape::serializeSingleTriangleInfoMap(btSerializer* serializer) const
     454{
     455        if (m_triangleInfoMap)
     456        {
     457                int len = m_triangleInfoMap->calculateSerializeBufferSize();
     458                btChunk* chunk = serializer->allocate(len,1);
     459                const char* structType = m_triangleInfoMap->serialize(chunk->m_oldPtr, serializer);
     460                serializer->finalizeChunk(chunk,structType,BT_TRIANLGE_INFO_MAP,(void*)m_triangleInfoMap);
     461        }
     462}
     463
     464
     465
     466
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    2020#include "btOptimizedBvh.h"
    2121#include "LinearMath/btAlignedAllocator.h"
    22 
     22#include "btTriangleInfoMap.h"
    2323
    2424///The btBvhTriangleMeshShape is a static-triangle mesh shape with several optimizations, such as bounding volume hierarchy and cache friendly traversal for PlayStation 3 Cell SPU. It is recommended to enable useQuantizedAabbCompression for better memory usage.
     
    3030
    3131        btOptimizedBvh* m_bvh;
     32        btTriangleInfoMap*      m_triangleInfoMap;
     33
    3234        bool m_useQuantizedAabbCompression;
    3335        bool m_ownsBvh;
     
    3840        BT_DECLARE_ALIGNED_ALLOCATOR();
    3941
    40         btBvhTriangleMeshShape() : btTriangleMeshShape(0),m_bvh(0),m_ownsBvh(false) {m_shapeType = TRIANGLE_MESH_SHAPE_PROXYTYPE;};
     42        btBvhTriangleMeshShape() : btTriangleMeshShape(0),m_bvh(0),m_triangleInfoMap(0),m_ownsBvh(false) {m_shapeType = TRIANGLE_MESH_SHAPE_PROXYTYPE;};
    4143        btBvhTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true);
    4244
     
    7476        }
    7577
     78        void    setOptimizedBvh(btOptimizedBvh* bvh, const btVector3& localScaling=btVector3(1,1,1));
    7679
    77         void    setOptimizedBvh(btOptimizedBvh* bvh, const btVector3& localScaling=btVector3(1,1,1));
     80        void    buildOptimizedBvh();
    7881
    7982        bool    usesQuantizedAabbCompression() const
     
    8184                return  m_useQuantizedAabbCompression;
    8285        }
     86
     87        void    setTriangleInfoMap(btTriangleInfoMap* triangleInfoMap)
     88        {
     89                m_triangleInfoMap = triangleInfoMap;
     90        }
     91
     92        const btTriangleInfoMap*        getTriangleInfoMap() const
     93        {
     94                return m_triangleInfoMap;
     95        }
     96       
     97        btTriangleInfoMap*      getTriangleInfoMap()
     98        {
     99                return m_triangleInfoMap;
     100        }
     101
     102        virtual int     calculateSerializeBufferSize() const;
     103
     104        ///fills the dataBuffer and returns the struct name (and 0 on failure)
     105        virtual const char*     serialize(void* dataBuffer, btSerializer* serializer) const;
     106
     107        virtual void    serializeSingleBvh(btSerializer* serializer) const;
     108
     109        virtual void    serializeSingleTriangleInfoMap(btSerializer* serializer) const;
     110
     111};
     112
     113///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
     114struct  btTriangleMeshShapeData
     115{
     116        btCollisionShapeData    m_collisionShapeData;
     117
     118        btStridingMeshInterfaceData m_meshInterface;
     119
     120        btQuantizedBvhFloatData         *m_quantizedFloatBvh;
     121        btQuantizedBvhDoubleData        *m_quantizedDoubleBvh;
     122
     123        btTriangleInfoMapData   *m_triangleInfoMap;
     124       
     125        float   m_collisionMargin;
     126
     127        char m_pad3[4];
     128       
     129};
     130
     131
     132SIMD_FORCE_INLINE       int     btBvhTriangleMeshShape::calculateSerializeBufferSize() const
     133{
     134        return sizeof(btTriangleMeshShapeData);
    83135}
    84 ;
     136
     137
    85138
    86139#endif //BVH_TRIANGLE_MESH_SHAPE_H
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btCapsuleShape.cpp

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    3333        btVector3 supVec(0,0,0);
    3434
    35         btScalar maxDot(btScalar(-1e30));
     35        btScalar maxDot(btScalar(-BT_LARGE_FLOAT));
    3636
    3737        btVector3 vec = vec0;
     
    8989        for (int j=0;j<numVectors;j++)
    9090        {
    91                 btScalar maxDot(btScalar(-1e30));
     91                btScalar maxDot(btScalar(-BT_LARGE_FLOAT));
    9292                const btVector3& vec = vectors[j];
    9393
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btCapsuleShape.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    4444        virtual void    batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
    4545       
     46        virtual void setMargin(btScalar collisionMargin)
     47        {
     48                //correct the m_implicitShapeDimensions for the margin
     49                btVector3 oldMargin(getMargin(),getMargin(),getMargin());
     50                btVector3 implicitShapeDimensionsWithMargin = m_implicitShapeDimensions+oldMargin;
     51               
     52                btConvexInternalShape::setMargin(collisionMargin);
     53                btVector3 newMargin(getMargin(),getMargin(),getMargin());
     54                m_implicitShapeDimensions = implicitShapeDimensionsWithMargin - newMargin;
     55
     56        }
     57
    4658        virtual void getAabb (const btTransform& t, btVector3& aabbMin, btVector3& aabbMax) const
    4759        {
     
    7789                return m_implicitShapeDimensions[m_upAxis];
    7890        }
     91
     92        virtual void    setLocalScaling(const btVector3& scaling)
     93        {
     94                btVector3 oldMargin(getMargin(),getMargin(),getMargin());
     95                btVector3 implicitShapeDimensionsWithMargin = m_implicitShapeDimensions+oldMargin;
     96                btVector3 unScaledImplicitShapeDimensionsWithMargin = implicitShapeDimensionsWithMargin / m_localScaling;
     97
     98                btConvexInternalShape::setLocalScaling(scaling);
     99
     100                m_implicitShapeDimensions = (unScaledImplicitShapeDimensionsWithMargin * m_localScaling) - oldMargin;
     101
     102        }
     103
     104        virtual int     calculateSerializeBufferSize() const;
     105
     106        ///fills the dataBuffer and returns the struct name (and 0 on failure)
     107        virtual const char*     serialize(void* dataBuffer, btSerializer* serializer) const;
     108
    79109
    80110};
     
    114144};
    115145
     146///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
     147struct  btCapsuleShapeData
     148{
     149        btConvexInternalShapeData       m_convexInternalShapeData;
    116150
     151        int     m_upAxis;
     152
     153        char    m_padding[4];
     154};
     155
     156SIMD_FORCE_INLINE       int     btCapsuleShape::calculateSerializeBufferSize() const
     157{
     158        return sizeof(btCapsuleShapeData);
     159}
     160
     161        ///fills the dataBuffer and returns the struct name (and 0 on failure)
     162SIMD_FORCE_INLINE       const char*     btCapsuleShape::serialize(void* dataBuffer, btSerializer* serializer) const
     163{
     164        btCapsuleShapeData* shapeData = (btCapsuleShapeData*) dataBuffer;
     165       
     166        btConvexInternalShape::serialize(&shapeData->m_convexInternalShapeData,serializer);
     167
     168        shapeData->m_upAxis = m_upAxis;
     169       
     170        return "btCapsuleShapeData";
     171}
    117172
    118173#endif //BT_CAPSULE_SHAPE_H
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btCollisionMargin.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btCollisionShape.cpp

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    13133. This notice may not be removed or altered from any source distribution.
    1414*/
    15 
    1615#include "BulletCollision/CollisionShapes/btCollisionShape.h"
    17 
    18 
    19 btScalar gContactThresholdFactor=btScalar(0.02);
    20 
     16#include "LinearMath/btSerializer.h"
    2117
    2218/*
     
    4642}
    4743
    48 btScalar        btCollisionShape::getContactBreakingThreshold() const
     44
     45btScalar        btCollisionShape::getContactBreakingThreshold(btScalar defaultContactThreshold) const
    4946{
    50         return getAngularMotionDisc() * gContactThresholdFactor;
     47        return getAngularMotionDisc() * defaultContactThreshold;
    5148}
     49
    5250btScalar        btCollisionShape::getAngularMotionDisc() const
    5351{
     
    9795        temporalAabbMax += angularMotion3d;
    9896}
     97
     98///fills the dataBuffer and returns the struct name (and 0 on failure)
     99const char*     btCollisionShape::serialize(void* dataBuffer, btSerializer* serializer) const
     100{
     101        btCollisionShapeData* shapeData = (btCollisionShapeData*) dataBuffer;
     102        char* name = (char*) serializer->findNameForPointer(this);
     103        shapeData->m_name = (char*)serializer->getUniquePointer(name);
     104        if (shapeData->m_name)
     105        {
     106                serializer->serializeName(name);
     107        }
     108        shapeData->m_shapeType = m_shapeType;
     109        //shapeData->m_padding//??
     110        return "btCollisionShapeData";
     111}
     112
     113void    btCollisionShape::serializeSingleShape(btSerializer* serializer) const
     114{
     115        int len = calculateSerializeBufferSize();
     116        btChunk* chunk = serializer->allocate(len,1);
     117        const char* structType = serialize(chunk->m_oldPtr, serializer);
     118        serializer->finalizeChunk(chunk,structType,BT_SHAPE_CODE,(void*)this);
     119}
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btCollisionShape.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    2121#include "LinearMath/btMatrix3x3.h"
    2222#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" //for the shape types
     23class btSerializer;
     24
    2325
    2426///The btCollisionShape class provides an interface for collision shapes that can be shared among btCollisionObjects.
     
    4749        virtual btScalar        getAngularMotionDisc() const;
    4850
    49         virtual btScalar        getContactBreakingThreshold() const;
     51        virtual btScalar        getContactBreakingThreshold(btScalar defaultContactThresholdFactor) const;
    5052
    5153
     
    5456        void calculateTemporalAabb(const btTransform& curTrans,const btVector3& linvel,const btVector3& angvel,btScalar timeStep, btVector3& temporalAabbMin,btVector3& temporalAabbMax) const;
    5557
    56 #ifndef __SPU__
     58
    5759
    5860        SIMD_FORCE_INLINE bool  isPolyhedral() const
     
    6163        }
    6264
     65        SIMD_FORCE_INLINE bool  isConvex2d() const
     66        {
     67                return btBroadphaseProxy::isConvex2d(getShapeType());
     68        }
     69
    6370        SIMD_FORCE_INLINE bool  isConvex() const
    6471        {
    6572                return btBroadphaseProxy::isConvex(getShapeType());
     73        }
     74        SIMD_FORCE_INLINE bool  isNonMoving() const
     75        {
     76                return btBroadphaseProxy::isNonMoving(getShapeType());
    6677        }
    6778        SIMD_FORCE_INLINE bool  isConcave() const
     
    7485        }
    7586
     87        SIMD_FORCE_INLINE bool  isSoftBody() const
     88        {
     89                return btBroadphaseProxy::isSoftBody(getShapeType());
     90        }
     91
    7692        ///isInfinite is used to catch simulation error (aabb check)
    7793        SIMD_FORCE_INLINE bool isInfinite() const
     
    8096        }
    8197
    82        
     98#ifndef __SPU__
    8399        virtual void    setLocalScaling(const btVector3& scaling) =0;
    84100        virtual const btVector3& getLocalScaling() const =0;
     
    107123        }
    108124
     125        virtual int     calculateSerializeBufferSize() const;
     126
     127        ///fills the dataBuffer and returns the struct name (and 0 on failure)
     128        virtual const char*     serialize(void* dataBuffer, btSerializer* serializer) const;
     129
     130        virtual void    serializeSingleShape(btSerializer* serializer) const;
     131
    109132};     
     133
     134///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
     135struct  btCollisionShapeData
     136{
     137        char    *m_name;
     138        int             m_shapeType;
     139        char    m_padding[4];
     140};
     141
     142SIMD_FORCE_INLINE       int     btCollisionShape::calculateSerializeBufferSize() const
     143{
     144        return sizeof(btCollisionShapeData);
     145}
     146
     147
    110148
    111149#endif //COLLISION_SHAPE_H
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btCompoundShape.cpp

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    1717#include "btCollisionShape.h"
    1818#include "BulletCollision/BroadphaseCollision/btDbvt.h"
     19#include "LinearMath/btSerializer.h"
    1920
    2021btCompoundShape::btCompoundShape(bool enableDynamicAabbTree)
    21 : m_localAabbMin(btScalar(1e30),btScalar(1e30),btScalar(1e30)),
    22 m_localAabbMax(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30)),
     22: m_localAabbMin(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT)),
     23m_localAabbMax(btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT)),
     24m_dynamicAabbTree(0),
     25m_updateRevision(1),
    2326m_collisionMargin(btScalar(0.)),
    24 m_localScaling(btScalar(1.),btScalar(1.),btScalar(1.)),
    25 m_dynamicAabbTree(0),
    26 m_updateRevision(1)
     27m_localScaling(btScalar(1.),btScalar(1.),btScalar(1.))
    2728{
    2829        m_shapeType = COMPOUND_SHAPE_PROXYTYPE;
     
    5253        //m_childShapes.push_back(shape);
    5354        btCompoundShapeChild child;
     55        child.m_node = 0;
    5456        child.m_transform = localTransform;
    5557        child.m_childShape = shape;
     
    9496                m_children[childIndex].m_childShape->getAabb(newChildTransform,localAabbMin,localAabbMax);
    9597                ATTRIBUTE_ALIGNED16(btDbvtVolume)       bounds=btDbvtVolume::FromMM(localAabbMin,localAabbMax);
    96                 int index = m_children.size()-1;
     98                //int index = m_children.size()-1;
    9799                m_dynamicAabbTree->update(m_children[childIndex].m_node,bounds);
    98100        }
     
    110112        }
    111113        m_children.swap(childShapeIndex,m_children.size()-1);
     114    if (m_dynamicAabbTree)
     115                m_children[childShapeIndex].m_node->dataAsInt = childShapeIndex;
    112116        m_children.pop_back();
    113117
     
    125129                if(m_children[i].m_childShape == shape)
    126130                {
    127                         m_children.swap(i,m_children.size()-1);
    128                         m_children.pop_back();
    129                         //remove it from the m_dynamicAabbTree too
    130                         //@todo: this leads to problems due to caching in the btCompoundCollisionAlgorithm
    131                         //so effectively, removeChildShape is broken at the moment
    132                         //m_dynamicAabbTree->remove(m_aabbProxies[i]);
    133                         //m_aabbProxies.swap(i,m_children.size()-1);
    134                         //m_aabbProxies.pop_back();
     131                        removeChildShapeByIndex(i);
    135132                }
    136133        }
     
    146143        // Brute force, it iterates over all the shapes left.
    147144
    148         m_localAabbMin = btVector3(btScalar(1e30),btScalar(1e30),btScalar(1e30));
    149         m_localAabbMax = btVector3(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30));
     145        m_localAabbMin = btVector3(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT));
     146        m_localAabbMax = btVector3(btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT));
    150147
    151148        //extend the local aabbMin/aabbMax
     
    224221        for (k = 0; k < n; k++)
    225222        {
     223                btAssert(masses[k]>0);
    226224                center += m_children[k].m_transform.getOrigin() * masses[k];
    227225                totalMass += masses[k];
    228226        }
     227
     228        btAssert(totalMass>0);
     229
    229230        center /= totalMass;
    230231        principal.setOrigin(center);
     
    272273
    273274
     275void btCompoundShape::setLocalScaling(const btVector3& scaling)
     276{
     277
     278        for(int i = 0; i < m_children.size(); i++)
     279        {
     280                btTransform childTrans = getChildTransform(i);
     281                btVector3 childScale = m_children[i].m_childShape->getLocalScaling();
     282//              childScale = childScale * (childTrans.getBasis() * scaling);
     283                childScale = childScale * scaling / m_localScaling;
     284                m_children[i].m_childShape->setLocalScaling(childScale);
     285                childTrans.setOrigin((childTrans.getOrigin())*scaling);
     286                updateChildTransform(i, childTrans);
     287                recalculateLocalAabb();
     288        }
     289        m_localScaling = scaling;
     290}
     291
     292
     293void btCompoundShape::createAabbTreeFromChildren()
     294{
     295    if ( !m_dynamicAabbTree )
     296    {
     297        void* mem = btAlignedAlloc(sizeof(btDbvt),16);
     298        m_dynamicAabbTree = new(mem) btDbvt();
     299        btAssert(mem==m_dynamicAabbTree);
     300
     301        for ( int index = 0; index < m_children.size(); index++ )
     302        {
     303            btCompoundShapeChild &child = m_children[index];
     304
     305            //extend the local aabbMin/aabbMax
     306            btVector3 localAabbMin,localAabbMax;
     307            child.m_childShape->getAabb(child.m_transform,localAabbMin,localAabbMax);
     308
     309            const btDbvtVolume  bounds=btDbvtVolume::FromMM(localAabbMin,localAabbMax);
     310            child.m_node = m_dynamicAabbTree->insert(bounds,(void*)index);
     311        }
     312    }
     313}
     314
     315
     316///fills the dataBuffer and returns the struct name (and 0 on failure)
     317const char*     btCompoundShape::serialize(void* dataBuffer, btSerializer* serializer) const
     318{
     319
     320        btCompoundShapeData* shapeData = (btCompoundShapeData*) dataBuffer;
     321        btCollisionShape::serialize(&shapeData->m_collisionShapeData, serializer);
     322
     323        shapeData->m_collisionMargin = float(m_collisionMargin);
     324        shapeData->m_numChildShapes = m_children.size();
     325        shapeData->m_childShapePtr = 0;
     326        if (shapeData->m_numChildShapes)
     327        {
     328                btChunk* chunk = serializer->allocate(sizeof(btCompoundShapeChildData),shapeData->m_numChildShapes);
     329                btCompoundShapeChildData* memPtr = (btCompoundShapeChildData*)chunk->m_oldPtr;
     330                shapeData->m_childShapePtr = (btCompoundShapeChildData*)serializer->getUniquePointer(memPtr);
     331
     332                for (int i=0;i<shapeData->m_numChildShapes;i++,memPtr++)
     333                {
     334                        memPtr->m_childMargin = float(m_children[i].m_childMargin);
     335                        memPtr->m_childShape = (btCollisionShapeData*)serializer->getUniquePointer(m_children[i].m_childShape);
     336                        //don't serialize shapes that already have been serialized
     337                        if (!serializer->findPointer(m_children[i].m_childShape))
     338                        {
     339                                btChunk* chunk = serializer->allocate(m_children[i].m_childShape->calculateSerializeBufferSize(),1);
     340                                const char* structType = m_children[i].m_childShape->serialize(chunk->m_oldPtr,serializer);
     341                                serializer->finalizeChunk(chunk,structType,BT_SHAPE_CODE,m_children[i].m_childShape);
     342                        }
     343
     344                        memPtr->m_childShapeType = m_children[i].m_childShapeType;
     345                        m_children[i].m_transform.serializeFloat(memPtr->m_transform);
     346                }
     347                serializer->finalizeChunk(chunk,"btCompoundShapeChildData",BT_ARRAY_CODE,chunk->m_oldPtr);
     348        }
     349        return "btCompoundShapeData";
     350}
     351
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btCompoundShape.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    6363        int                                                             m_updateRevision;
    6464
     65        btScalar        m_collisionMargin;
     66
     67protected:
     68        btVector3       m_localScaling;
     69
    6570public:
    6671        BT_DECLARE_ALIGNED_ALLOCATOR();
     
    117122        virtual void recalculateLocalAabb();
    118123
    119         virtual void    setLocalScaling(const btVector3& scaling)
    120         {
    121                 m_localScaling = scaling;
    122         }
     124        virtual void    setLocalScaling(const btVector3& scaling);
     125
    123126        virtual const btVector3& getLocalScaling() const
    124127        {
     
    141144        }
    142145
    143         //this is optional, but should make collision queries faster, by culling non-overlapping nodes
    144         void    createAabbTreeFromChildren();
    145146
    146147        btDbvt*                                                 getDynamicAabbTree()
     
    148149                return m_dynamicAabbTree;
    149150        }
     151
     152        void createAabbTreeFromChildren();
    150153
    151154        ///computes the exact moment of inertia and the transform from the coordinate system defined by the principal axes of the moment of inertia
     
    161164        }
    162165
    163 private:
    164         btScalar        m_collisionMargin;
    165 protected:
    166         btVector3       m_localScaling;
    167 
    168 };
     166        virtual int     calculateSerializeBufferSize() const;
     167
     168        ///fills the dataBuffer and returns the struct name (and 0 on failure)
     169        virtual const char*     serialize(void* dataBuffer, btSerializer* serializer) const;
     170
     171
     172};
     173
     174///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
     175struct btCompoundShapeChildData
     176{
     177        btTransformFloatData    m_transform;
     178        btCollisionShapeData    *m_childShape;
     179        int                                             m_childShapeType;
     180        float                                   m_childMargin;
     181};
     182
     183///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
     184struct  btCompoundShapeData
     185{
     186        btCollisionShapeData            m_collisionShapeData;
     187
     188        btCompoundShapeChildData        *m_childShapePtr;
     189
     190        int                                                     m_numChildShapes;
     191
     192        float   m_collisionMargin;
     193
     194};
     195
     196
     197SIMD_FORCE_INLINE       int     btCompoundShape::calculateSerializeBufferSize() const
     198{
     199        return sizeof(btCompoundShapeData);
     200}
     201
     202
     203
     204
    169205
    170206
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btConcaveShape.cpp

    r5781 r8284  
    1 
    21/*
    32Bullet Continuous Collision Detection and Physics Library
    4 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    54
    65This software is provided 'as-is', without any express or implied warranty.
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btConcaveShape.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btConeShape.cpp

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btConeShape.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btConvexHullShape.cpp

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    13133. This notice may not be removed or altered from any source distribution.
    1414*/
     15
    1516#include "btConvexHullShape.h"
    1617#include "BulletCollision/CollisionShapes/btCollisionMargin.h"
    1718
    1819#include "LinearMath/btQuaternion.h"
    19 
    20 
    21 
    22 btConvexHullShape ::btConvexHullShape (const btScalar* points,int numPoints,int stride) : btPolyhedralConvexShape ()
     20#include "LinearMath/btSerializer.h"
     21
     22btConvexHullShape ::btConvexHullShape (const btScalar* points,int numPoints,int stride) : btPolyhedralConvexAabbCachingShape ()
    2323{
    2424        m_shapeType = CONVEX_HULL_SHAPE_PROXYTYPE;
    2525        m_unscaledPoints.resize(numPoints);
    2626
    27         unsigned char* pointsBaseAddress = (unsigned char*)points;
     27        unsigned char* pointsAddress = (unsigned char*)points;
    2828
    2929        for (int i=0;i<numPoints;i++)
    3030        {
    31                 btVector3* point = (btVector3*)(pointsBaseAddress + i*stride);
    32                 m_unscaledPoints[i] = point[0];
     31                btScalar* point = (btScalar*)pointsAddress;
     32                m_unscaledPoints[i] = btVector3(point[0], point[1], point[2]);
     33                pointsAddress += stride;
    3334        }
    3435
     
    5253}
    5354
    54 btVector3       btConvexHullShape::localGetSupportingVertexWithoutMargin(const btVector3& vec0)const
     55btVector3       btConvexHullShape::localGetSupportingVertexWithoutMargin(const btVector3& vec)const
    5556{
    5657        btVector3 supVec(btScalar(0.),btScalar(0.),btScalar(0.));
    57         btScalar newDot,maxDot = btScalar(-1e30);
    58 
    59         btVector3 vec = vec0;
    60         btScalar lenSqr = vec.length2();
    61         if (lenSqr < btScalar(0.0001))
    62         {
    63                 vec.setValue(1,0,0);
    64         } else
    65         {
    66                 btScalar rlen = btScalar(1.) / btSqrt(lenSqr );
    67                 vec *= rlen;
    68         }
    69 
     58        btScalar newDot,maxDot = btScalar(-BT_LARGE_FLOAT);
    7059
    7160        for (int i=0;i<m_unscaledPoints.size();i++)
     
    9079                for (int i=0;i<numVectors;i++)
    9180                {
    92                         supportVerticesOut[i][3] = btScalar(-1e30);
     81                        supportVerticesOut[i][3] = btScalar(-BT_LARGE_FLOAT);
    9382                }
    9483        }
     
    186175}
    187176
     177///fills the dataBuffer and returns the struct name (and 0 on failure)
     178const char*     btConvexHullShape::serialize(void* dataBuffer, btSerializer* serializer) const
     179{
     180        //int szc = sizeof(btConvexHullShapeData);
     181        btConvexHullShapeData* shapeData = (btConvexHullShapeData*) dataBuffer;
     182        btConvexInternalShape::serialize(&shapeData->m_convexInternalShapeData, serializer);
     183
     184        int numElem = m_unscaledPoints.size();
     185        shapeData->m_numUnscaledPoints = numElem;
     186#ifdef BT_USE_DOUBLE_PRECISION
     187        shapeData->m_unscaledPointsFloatPtr = 0;
     188        shapeData->m_unscaledPointsDoublePtr = numElem ? (btVector3Data*)serializer->getUniquePointer((void*)&m_unscaledPoints[0]):  0;
     189#else
     190        shapeData->m_unscaledPointsFloatPtr = numElem ? (btVector3Data*)serializer->getUniquePointer((void*)&m_unscaledPoints[0]):  0;
     191        shapeData->m_unscaledPointsDoublePtr = 0;
     192#endif
     193       
     194        if (numElem)
     195        {
     196                int sz = sizeof(btVector3Data);
     197        //      int sz2 = sizeof(btVector3DoubleData);
     198        //      int sz3 = sizeof(btVector3FloatData);
     199                btChunk* chunk = serializer->allocate(sz,numElem);
     200                btVector3Data* memPtr = (btVector3Data*)chunk->m_oldPtr;
     201                for (int i=0;i<numElem;i++,memPtr++)
     202                {
     203                        m_unscaledPoints[i].serialize(*memPtr);
     204                }
     205                serializer->finalizeChunk(chunk,btVector3DataName,BT_ARRAY_CODE,(void*)&m_unscaledPoints[0]);
     206        }
     207       
     208        return "btConvexHullShapeData";
     209}
     210
     211
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btConvexHullShape.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    2121#include "LinearMath/btAlignedObjectArray.h"
    2222
     23
    2324///The btConvexHullShape implements an implicit convex hull of an array of vertices.
    2425///Bullet provides a general and fast collision detector for convex shapes based on GJK and EPA using localGetSupportingVertex.
    25 ATTRIBUTE_ALIGNED16(class) btConvexHullShape : public btPolyhedralConvexShape
     26ATTRIBUTE_ALIGNED16(class) btConvexHullShape : public btPolyhedralConvexAabbCachingShape
    2627{
    2728        btAlignedObjectArray<btVector3> m_unscaledPoints;
     
    8990        virtual void    setLocalScaling(const btVector3& scaling);
    9091
     92        virtual int     calculateSerializeBufferSize() const;
     93
     94        ///fills the dataBuffer and returns the struct name (and 0 on failure)
     95        virtual const char*     serialize(void* dataBuffer, btSerializer* serializer) const;
     96
    9197};
     98
     99///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
     100struct  btConvexHullShapeData
     101{
     102        btConvexInternalShapeData       m_convexInternalShapeData;
     103
     104        btVector3FloatData      *m_unscaledPointsFloatPtr;
     105        btVector3DoubleData     *m_unscaledPointsDoublePtr;
     106
     107        int             m_numUnscaledPoints;
     108        char m_padding3[4];
     109
     110};
     111
     112
     113SIMD_FORCE_INLINE       int     btConvexHullShape::calculateSerializeBufferSize() const
     114{
     115        return sizeof(btConvexHullShapeData);
     116}
    92117
    93118
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btConvexInternalShape.cpp

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    3535void    btConvexInternalShape::getAabbSlow(const btTransform& trans,btVector3&minAabb,btVector3&maxAabb) const
    3636{
    37 
     37#ifndef __SPU__
     38        //use localGetSupportingVertexWithoutMargin?
    3839        btScalar margin = getMargin();
    3940        for (int i=0;i<3;i++)
     
    5051                minAabb[i] = tmp[i]-margin;
    5152        }
     53#endif
    5254}
    5355
     
    8082
    8183
     84btConvexInternalAabbCachingShape::btConvexInternalAabbCachingShape()
     85        :       btConvexInternalShape(),
     86m_localAabbMin(1,1,1),
     87m_localAabbMax(-1,-1,-1),
     88m_isLocalAabbValid(false)
     89{
     90}
     91
     92
     93void btConvexInternalAabbCachingShape::getAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax) const
     94{
     95        getNonvirtualAabb(trans,aabbMin,aabbMax,getMargin());
     96}
     97
     98void    btConvexInternalAabbCachingShape::setLocalScaling(const btVector3& scaling)
     99{
     100        btConvexInternalShape::setLocalScaling(scaling);
     101        recalcLocalAabb();
     102}
     103
     104
     105void    btConvexInternalAabbCachingShape::recalcLocalAabb()
     106{
     107        m_isLocalAabbValid = true;
     108       
     109        #if 1
     110        static const btVector3 _directions[] =
     111        {
     112                btVector3( 1.,  0.,  0.),
     113                btVector3( 0.,  1.,  0.),
     114                btVector3( 0.,  0.,  1.),
     115                btVector3( -1., 0.,  0.),
     116                btVector3( 0., -1.,  0.),
     117                btVector3( 0.,  0., -1.)
     118        };
     119       
     120        btVector3 _supporting[] =
     121        {
     122                btVector3( 0., 0., 0.),
     123                btVector3( 0., 0., 0.),
     124                btVector3( 0., 0., 0.),
     125                btVector3( 0., 0., 0.),
     126                btVector3( 0., 0., 0.),
     127                btVector3( 0., 0., 0.)
     128        };
     129       
     130        batchedUnitVectorGetSupportingVertexWithoutMargin(_directions, _supporting, 6);
     131       
     132        for ( int i = 0; i < 3; ++i )
     133        {
     134                m_localAabbMax[i] = _supporting[i][i] + m_collisionMargin;
     135                m_localAabbMin[i] = _supporting[i + 3][i] - m_collisionMargin;
     136        }
     137       
     138        #else
     139
     140        for (int i=0;i<3;i++)
     141        {
     142                btVector3 vec(btScalar(0.),btScalar(0.),btScalar(0.));
     143                vec[i] = btScalar(1.);
     144                btVector3 tmp = localGetSupportingVertex(vec);
     145                m_localAabbMax[i] = tmp[i]+m_collisionMargin;
     146                vec[i] = btScalar(-1.);
     147                tmp = localGetSupportingVertex(vec);
     148                m_localAabbMin[i] = tmp[i]-m_collisionMargin;
     149        }
     150        #endif
     151}
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btConvexInternalShape.h

    r5781 r8284  
     1/*
     2Bullet Continuous Collision Detection and Physics Library
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
     4
     5This software is provided 'as-is', without any express or implied warranty.
     6In no event will the authors be held liable for any damages arising from the use of this software.
     7Permission is granted to anyone to use this software for any purpose,
     8including commercial applications, and to alter it and redistribute it freely,
     9subject to the following restrictions:
     10
     111. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
     122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
     133. This notice may not be removed or altered from any source distribution.
     14*/
    115
    216#ifndef BT_CONVEX_INTERNAL_SHAPE_H
     
    418
    519#include "btConvexShape.h"
     20#include "LinearMath/btAabbUtil2.h"
     21
    622
    723///The btConvexInternalShape is an internal base class, shared by most convex shape implementations.
     
    3652        {
    3753                return m_implicitShapeDimensions;
     54        }
     55
     56        ///warning: use setImplicitShapeDimensions with care
     57        ///changing a collision shape while the body is in the world is not recommended,
     58        ///it is best to remove the body from the world, then make the change, and re-add it
     59        ///alternatively flush the contact points, see documentation for 'cleanProxyFromPairs'
     60        void    setImplicitShapeDimensions(const btVector3& dimensions)
     61        {
     62                m_implicitShapeDimensions = dimensions;
    3863        }
    3964
     
    86111        }
    87112
     113        virtual int     calculateSerializeBufferSize() const;
     114
     115        ///fills the dataBuffer and returns the struct name (and 0 on failure)
     116        virtual const char*     serialize(void* dataBuffer, btSerializer* serializer) const;
    88117
    89118       
    90119};
    91120
     121///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
     122struct  btConvexInternalShapeData
     123{
     124        btCollisionShapeData    m_collisionShapeData;
     125
     126        btVector3FloatData      m_localScaling;
     127
     128        btVector3FloatData      m_implicitShapeDimensions;
     129       
     130        float                   m_collisionMargin;
     131
     132        int     m_padding;
     133
     134};
     135
     136
     137
     138SIMD_FORCE_INLINE       int     btConvexInternalShape::calculateSerializeBufferSize() const
     139{
     140        return sizeof(btConvexInternalShapeData);
     141}
     142
     143///fills the dataBuffer and returns the struct name (and 0 on failure)
     144SIMD_FORCE_INLINE       const char*     btConvexInternalShape::serialize(void* dataBuffer, btSerializer* serializer) const
     145{
     146        btConvexInternalShapeData* shapeData = (btConvexInternalShapeData*) dataBuffer;
     147        btCollisionShape::serialize(&shapeData->m_collisionShapeData, serializer);
     148
     149        m_implicitShapeDimensions.serializeFloat(shapeData->m_implicitShapeDimensions);
     150        m_localScaling.serializeFloat(shapeData->m_localScaling);
     151        shapeData->m_collisionMargin = float(m_collisionMargin);
     152
     153        return "btConvexInternalShapeData";
     154}
     155
     156
     157
     158
     159///btConvexInternalAabbCachingShape adds local aabb caching for convex shapes, to avoid expensive bounding box calculations
     160class btConvexInternalAabbCachingShape : public btConvexInternalShape
     161{
     162        btVector3       m_localAabbMin;
     163        btVector3       m_localAabbMax;
     164        bool            m_isLocalAabbValid;
     165       
     166protected:
     167                                       
     168        btConvexInternalAabbCachingShape();
     169       
     170        void setCachedLocalAabb (const btVector3& aabbMin, const btVector3& aabbMax)
     171        {
     172                m_isLocalAabbValid = true;
     173                m_localAabbMin = aabbMin;
     174                m_localAabbMax = aabbMax;
     175        }
     176
     177        inline void getCachedLocalAabb (btVector3& aabbMin, btVector3& aabbMax) const
     178        {
     179                btAssert(m_isLocalAabbValid);
     180                aabbMin = m_localAabbMin;
     181                aabbMax = m_localAabbMax;
     182        }
     183
     184        inline void getNonvirtualAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax, btScalar margin) const
     185        {
     186
     187                //lazy evaluation of local aabb
     188                btAssert(m_isLocalAabbValid);
     189                btTransformAabb(m_localAabbMin,m_localAabbMax,margin,trans,aabbMin,aabbMax);
     190        }
     191               
     192public:
     193               
     194        virtual void    setLocalScaling(const btVector3& scaling);
     195
     196        virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
     197
     198        void    recalcLocalAabb();
     199
     200};
    92201
    93202#endif //BT_CONVEX_INTERNAL_SHAPE_H
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btConvexPointCloudShape.cpp

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    13133. This notice may not be removed or altered from any source distribution.
    1414*/
     15
    1516#include "btConvexPointCloudShape.h"
    1617#include "BulletCollision/CollisionShapes/btCollisionMargin.h"
     
    2829{
    2930        btVector3 supVec(btScalar(0.),btScalar(0.),btScalar(0.));
    30         btScalar newDot,maxDot = btScalar(-1e30);
     31        btScalar newDot,maxDot = btScalar(-BT_LARGE_FLOAT);
    3132
    3233        btVector3 vec = vec0;
     
    6364                for (int i=0;i<numVectors;i++)
    6465                {
    65                         supportVerticesOut[i][3] = btScalar(-1e30);
     66                        supportVerticesOut[i][3] = btScalar(-BT_LARGE_FLOAT);
    6667                }
    6768        }
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btConvexPointCloudShape.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    2222
    2323///The btConvexPointCloudShape implements an implicit convex hull of an array of vertices.
    24 ATTRIBUTE_ALIGNED16(class) btConvexPointCloudShape : public btPolyhedralConvexShape
     24ATTRIBUTE_ALIGNED16(class) btConvexPointCloudShape : public btPolyhedralConvexAabbCachingShape
    2525{
    2626        btVector3* m_unscaledPoints;
     
    2929public:
    3030        BT_DECLARE_ALIGNED_ALLOCATOR();
     31
     32        btConvexPointCloudShape()
     33        {
     34                m_localScaling.setValue(1.f,1.f,1.f);
     35                m_shapeType = CONVEX_POINT_CLOUD_SHAPE_PROXYTYPE;
     36                m_unscaledPoints = 0;
     37                m_numPoints = 0;
     38        }
    3139
    3240        btConvexPointCloudShape(btVector3* points,int numPoints, const btVector3& localScaling,bool computeAabb = true)
     
    4149        }
    4250
    43         void setPoints (btVector3* points, int numPoints, bool computeAabb = true)
     51        void setPoints (btVector3* points, int numPoints, bool computeAabb = true,const btVector3& localScaling=btVector3(1.f,1.f,1.f))
    4452        {
    4553                m_unscaledPoints = points;
    4654                m_numPoints = numPoints;
     55                m_localScaling = localScaling;
    4756
    4857                if (computeAabb)
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btConvexShape.cpp

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    2222#include "btConvexPointCloudShape.h"
    2323
     24///not supported on IBM SDK, until we fix the alignment of btVector3
     25#if defined (__CELLOS_LV2__) && defined (__SPU__)
     26#include <spu_intrinsics.h>
     27static inline vec_float4 vec_dot3( vec_float4 vec0, vec_float4 vec1 )
     28{
     29    vec_float4 result;
     30    result = spu_mul( vec0, vec1 );
     31    result = spu_madd( spu_rlqwbyte( vec0, 4 ), spu_rlqwbyte( vec1, 4 ), result );
     32    return spu_madd( spu_rlqwbyte( vec0, 8 ), spu_rlqwbyte( vec1, 8 ), result );
     33}
     34#endif //__SPU__
     35
    2436btConvexShape::btConvexShape ()
    2537{
     
    3345
    3446
    35 static btVector3 convexHullSupport (const btVector3& localDir, const btVector3* points, int numPoints, const btVector3& localScaling)
    36 {
    37         btVector3 supVec(btScalar(0.),btScalar(0.),btScalar(0.));
    38         btScalar newDot,maxDot = btScalar(-1e30);
    39 
    40         btVector3 vec0(localDir.getX(),localDir.getY(),localDir.getZ());
    41         btVector3 vec = vec0;
    42         btScalar lenSqr = vec.length2();
    43         if (lenSqr < btScalar(0.0001))
    44         {
    45                 vec.setValue(1,0,0);
    46         } else {
    47                 btScalar rlen = btScalar(1.) / btSqrt(lenSqr );
    48                 vec *= rlen;
    49         }
    50 
     47static btVector3 convexHullSupport (const btVector3& localDirOrg, const btVector3* points, int numPoints, const btVector3& localScaling)
     48{       
     49
     50        btVector3 vec = localDirOrg * localScaling;
     51
     52#if defined (__CELLOS_LV2__) && defined (__SPU__)
     53
     54        btVector3 localDir = vec;
     55
     56        vec_float4 v_distMax = {-FLT_MAX,0,0,0};
     57        vec_int4 v_idxMax = {-999,0,0,0};
     58        int v=0;
     59        int numverts = numPoints;
     60
     61        for(;v<(int)numverts-4;v+=4) {
     62                vec_float4 p0 = vec_dot3(points[v  ].get128(),localDir.get128());
     63                vec_float4 p1 = vec_dot3(points[v+1].get128(),localDir.get128());
     64                vec_float4 p2 = vec_dot3(points[v+2].get128(),localDir.get128());
     65                vec_float4 p3 = vec_dot3(points[v+3].get128(),localDir.get128());
     66                const vec_int4 i0 = {v  ,0,0,0};
     67                const vec_int4 i1 = {v+1,0,0,0};
     68                const vec_int4 i2 = {v+2,0,0,0};
     69                const vec_int4 i3 = {v+3,0,0,0};
     70                vec_uint4  retGt01 = spu_cmpgt(p0,p1);
     71                vec_float4 pmax01 = spu_sel(p1,p0,retGt01);
     72                vec_int4   imax01 = spu_sel(i1,i0,retGt01);
     73                vec_uint4  retGt23 = spu_cmpgt(p2,p3);
     74                vec_float4 pmax23 = spu_sel(p3,p2,retGt23);
     75                vec_int4   imax23 = spu_sel(i3,i2,retGt23);
     76                vec_uint4  retGt0123 = spu_cmpgt(pmax01,pmax23);
     77                vec_float4 pmax0123 = spu_sel(pmax23,pmax01,retGt0123);
     78                vec_int4   imax0123 = spu_sel(imax23,imax01,retGt0123);
     79                vec_uint4  retGtMax = spu_cmpgt(v_distMax,pmax0123);
     80                v_distMax = spu_sel(pmax0123,v_distMax,retGtMax);
     81                v_idxMax = spu_sel(imax0123,v_idxMax,retGtMax);
     82        }
     83        for(;v<(int)numverts;v++) {
     84                vec_float4 p = vec_dot3(points[v].get128(),localDir.get128());
     85                const vec_int4 i = {v,0,0,0};
     86                vec_uint4  retGtMax = spu_cmpgt(v_distMax,p);
     87                v_distMax = spu_sel(p,v_distMax,retGtMax);
     88                v_idxMax = spu_sel(i,v_idxMax,retGtMax);
     89        }
     90        int ptIndex = spu_extract(v_idxMax,0);
     91        const btVector3& supVec= points[ptIndex] * localScaling;
     92        return supVec;
     93#else
     94
     95        btScalar newDot,maxDot = btScalar(-BT_LARGE_FLOAT);
     96        int ptIndex = -1;
    5197
    5298        for (int i=0;i<numPoints;i++)
    5399        {
    54                 btVector3 vtx = points[i] * localScaling;
    55 
    56                 newDot = vec.dot(vtx);
     100
     101                newDot = vec.dot(points[i]);
    57102                if (newDot > maxDot)
    58103                {
    59104                        maxDot = newDot;
    60                         supVec = vtx;
    61                 }
    62         }
    63         return btVector3(supVec.getX(),supVec.getY(),supVec.getZ());
     105                        ptIndex = i;
     106                }
     107        }
     108        btAssert(ptIndex >= 0);
     109        btVector3 supVec = points[ptIndex] * localScaling;
     110        return supVec;
     111#endif //__SPU__
    64112}
    65113
     
    161209                btVector3 supVec(0,0,0);
    162210
    163                 btScalar maxDot(btScalar(-1e30));
     211                btScalar maxDot(btScalar(-BT_LARGE_FLOAT));
    164212
    165213                btVector3 vec = vec0;
     
    293341        return btScalar(0.0f);
    294342}
    295 
     343#ifndef __SPU__
    296344void btConvexShape::getAabbNonVirtual (const btTransform& t, btVector3& aabbMin, btVector3& aabbMax) const
    297345{
     
    361409        case CONVEX_HULL_SHAPE_PROXYTYPE:
    362410        {
    363                 btPolyhedralConvexShape* convexHullShape = (btPolyhedralConvexShape*)this;
     411                btPolyhedralConvexAabbCachingShape* convexHullShape = (btPolyhedralConvexAabbCachingShape*)this;
    364412                btScalar margin = convexHullShape->getMarginNonVirtual();
    365413                convexHullShape->getNonvirtualAabb (t, aabbMin, aabbMax, margin);
     
    378426        btAssert (0);
    379427}
     428
     429#endif //__SPU__
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btConvexShape.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.cpp

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    13133. This notice may not be removed or altered from any source distribution.
    1414*/
     15
    1516#include "btConvexTriangleMeshShape.h"
    1617#include "BulletCollision/CollisionShapes/btCollisionMargin.h"
     
    2122
    2223btConvexTriangleMeshShape ::btConvexTriangleMeshShape (btStridingMeshInterface* meshInterface, bool calcAabb)
    23 : btPolyhedralConvexShape(), m_stridingMesh(meshInterface)
     24: btPolyhedralConvexAabbCachingShape(), m_stridingMesh(meshInterface)
    2425{
    2526        m_shapeType = CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE;
     
    4445        LocalSupportVertexCallback(const btVector3& supportVecLocal)
    4546                : m_supportVertexLocal(btScalar(0.),btScalar(0.),btScalar(0.)),
    46                 m_maxDot(btScalar(-1e30)),
     47                m_maxDot(btScalar(-BT_LARGE_FLOAT)),
    4748                m_supportVecLocal(supportVecLocal)
    4849        {
     
    9293
    9394        LocalSupportVertexCallback      supportCallback(vec);
    94         btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
     95        btVector3 aabbMax(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT));
    9596        m_stridingMesh->InternalProcessAllTriangles(&supportCallback,-aabbMax,aabbMax);
    9697        supVec = supportCallback.GetSupportVertexLocal();
     
    105106                for (int i=0;i<numVectors;i++)
    106107                {
    107                         supportVerticesOut[i][3] = btScalar(-1e30);
     108                        supportVerticesOut[i][3] = btScalar(-BT_LARGE_FLOAT);
    108109                }
    109110        }
     
    116117                const btVector3& vec = vectors[j];
    117118                LocalSupportVertexCallback      supportCallback(vec);
    118                 btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
     119                btVector3 aabbMax(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT));
    119120                m_stridingMesh->InternalProcessAllTriangles(&supportCallback,-aabbMax,aabbMax);
    120121                supportVerticesOut[j] = supportCallback.GetSupportVertexLocal();
     
    298299
    299300   CenterCallback centerCallback;
    300    btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
     301   btVector3 aabbMax(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT));
    301302   m_stridingMesh->InternalProcessAllTriangles(&centerCallback, -aabbMax, aabbMax);
    302303   btVector3 center = centerCallback.getCenter();
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h

    r5781 r8284  
     1/*
     2Bullet Continuous Collision Detection and Physics Library
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
     4
     5This software is provided 'as-is', without any express or implied warranty.
     6In no event will the authors be held liable for any damages arising from the use of this software.
     7Permission is granted to anyone to use this software for any purpose,
     8including commercial applications, and to alter it and redistribute it freely,
     9subject to the following restrictions:
     10
     111. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
     122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
     133. This notice may not be removed or altered from any source distribution.
     14*/
    115#ifndef CONVEX_TRIANGLEMESH_SHAPE_H
    216#define CONVEX_TRIANGLEMESH_SHAPE_H
     
    923/// The btConvexTriangleMeshShape is a convex hull of a triangle mesh, but the performance is not as good as btConvexHullShape.
    1024/// A small benefit of this class is that it uses the btStridingMeshInterface, so you can avoid the duplication of the triangle mesh data. Nevertheless, most users should use the much better performing btConvexHullShape instead.
    11 class btConvexTriangleMeshShape : public btPolyhedralConvexShape
     25class btConvexTriangleMeshShape : public btPolyhedralConvexAabbCachingShape
    1226{
    1327
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btCylinderShape.cpp

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    13133. This notice may not be removed or altered from any source distribution.
    1414*/
     15
    1516#include "btCylinderShape.h"
    1617
    1718btCylinderShape::btCylinderShape (const btVector3& halfExtents)
    18 :btBoxShape(halfExtents),
     19:btConvexInternalShape(),
    1920m_upAxis(1)
    2021{
     22        btVector3 margin(getMargin(),getMargin(),getMargin());
     23        m_implicitShapeDimensions = (halfExtents * m_localScaling) - margin;
    2124        m_shapeType = CYLINDER_SHAPE_PROXYTYPE;
    22         recalcLocalAabb();
    2325}
    2426
     
    2830{
    2931        m_upAxis = 0;
    30         recalcLocalAabb();
     32
    3133}
    3234
     
    3638{
    3739        m_upAxis = 2;
    38         recalcLocalAabb();
     40
    3941}
    4042
    4143void btCylinderShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
    4244{
    43         //skip the box 'getAabb'
    44         btPolyhedralConvexShape::getAabb(t,aabbMin,aabbMax);
     45        btTransformAabb(getHalfExtentsWithoutMargin(),getMargin(),t,aabbMin,aabbMax);
     46}
     47
     48void    btCylinderShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const
     49{
     50        //approximation of box shape, todo: implement cylinder shape inertia before people notice ;-)
     51        btVector3 halfExtents = getHalfExtentsWithMargin();
     52
     53        btScalar lx=btScalar(2.)*(halfExtents.x());
     54        btScalar ly=btScalar(2.)*(halfExtents.y());
     55        btScalar lz=btScalar(2.)*(halfExtents.z());
     56
     57        inertia.setValue(mass/(btScalar(12.0)) * (ly*ly + lz*lz),
     58                                        mass/(btScalar(12.0)) * (lx*lx + lz*lz),
     59                                        mass/(btScalar(12.0)) * (lx*lx + ly*ly));
     60
    4561}
    4662
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btCylinderShape.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    2222
    2323/// The btCylinderShape class implements a cylinder shape primitive, centered around the origin. Its central axis aligned with the Y axis. btCylinderShapeX is aligned with the X axis and btCylinderShapeZ around the Z axis.
    24 class btCylinderShape : public btBoxShape
     24class btCylinderShape : public btConvexInternalShape
    2525
    2626{
     
    3131
    3232public:
     33
     34        btVector3 getHalfExtentsWithMargin() const
     35        {
     36                btVector3 halfExtents = getHalfExtentsWithoutMargin();
     37                btVector3 margin(getMargin(),getMargin(),getMargin());
     38                halfExtents += margin;
     39                return halfExtents;
     40        }
     41       
     42        const btVector3& getHalfExtentsWithoutMargin() const
     43        {
     44                return m_implicitShapeDimensions;//changed in Bullet 2.63: assume the scaling and margin are included
     45        }
     46
    3347        btCylinderShape (const btVector3& halfExtents);
    3448       
    35         ///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version
    3649        void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
    3750
     51        virtual void    calculateLocalInertia(btScalar mass,btVector3& inertia) const;
     52
    3853        virtual btVector3       localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
    3954
    4055        virtual void    batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
     56
     57        virtual void setMargin(btScalar collisionMargin)
     58        {
     59                //correct the m_implicitShapeDimensions for the margin
     60                btVector3 oldMargin(getMargin(),getMargin(),getMargin());
     61                btVector3 implicitShapeDimensionsWithMargin = m_implicitShapeDimensions+oldMargin;
     62               
     63                btConvexInternalShape::setMargin(collisionMargin);
     64                btVector3 newMargin(getMargin(),getMargin(),getMargin());
     65                m_implicitShapeDimensions = implicitShapeDimensionsWithMargin - newMargin;
     66
     67        }
    4168
    4269        virtual btVector3       localGetSupportingVertex(const btVector3& vec) const
     
    74101        }
    75102
     103        virtual void    setLocalScaling(const btVector3& scaling)
     104        {
     105                btVector3 oldMargin(getMargin(),getMargin(),getMargin());
     106                btVector3 implicitShapeDimensionsWithMargin = m_implicitShapeDimensions+oldMargin;
     107                btVector3 unScaledImplicitShapeDimensionsWithMargin = implicitShapeDimensionsWithMargin / m_localScaling;
     108
     109                btConvexInternalShape::setLocalScaling(scaling);
     110
     111                m_implicitShapeDimensions = (unScaledImplicitShapeDimensionsWithMargin * m_localScaling) - oldMargin;
     112
     113        }
     114
    76115        //debugging
    77116        virtual const char*     getName()const
     
    80119        }
    81120
    82 
     121        virtual int     calculateSerializeBufferSize() const;
     122
     123        ///fills the dataBuffer and returns the struct name (and 0 on failure)
     124        virtual const char*     serialize(void* dataBuffer, btSerializer* serializer) const;
    83125
    84126};
     
    113155        virtual void    batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
    114156
    115         virtual int     getUpAxis() const
    116         {
    117                 return 2;
    118         }
    119157                //debugging
    120158        virtual const char*     getName()const
     
    130168};
    131169
     170///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
     171struct  btCylinderShapeData
     172{
     173        btConvexInternalShapeData       m_convexInternalShapeData;
     174
     175        int     m_upAxis;
     176
     177        char    m_padding[4];
     178};
     179
     180SIMD_FORCE_INLINE       int     btCylinderShape::calculateSerializeBufferSize() const
     181{
     182        return sizeof(btCylinderShapeData);
     183}
     184
     185        ///fills the dataBuffer and returns the struct name (and 0 on failure)
     186SIMD_FORCE_INLINE       const char*     btCylinderShape::serialize(void* dataBuffer, btSerializer* serializer) const
     187{
     188        btCylinderShapeData* shapeData = (btCylinderShapeData*) dataBuffer;
     189       
     190        btConvexInternalShape::serialize(&shapeData->m_convexInternalShapeData,serializer);
     191
     192        shapeData->m_upAxis = m_upAxis;
     193       
     194        return "btCylinderShapeData";
     195}
     196
     197
    132198
    133199#endif //CYLINDER_MINKOWSKI_H
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btEmptyShape.cpp

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btEmptyShape.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btMaterial.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2008 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    3333
    3434#endif // MATERIAL_H
     35
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    13133. This notice may not be removed or altered from any source distribution.
    1414*/
     15
    1516
    1617#include "btMinkowskiSumShape.h"
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btMinkowskiSumShape.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btMultiSphereShape.cpp

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    1414*/
    1515
     16
     17
    1618#include "btMultiSphereShape.h"
    1719#include "BulletCollision/CollisionShapes/btCollisionMargin.h"
    1820#include "LinearMath/btQuaternion.h"
     21#include "LinearMath/btSerializer.h"
    1922
    20 btMultiSphereShape::btMultiSphereShape (const btVector3& inertiaHalfExtents,const btVector3* positions,const btScalar* radi,int numSpheres)
    21 :btConvexInternalShape (), m_inertiaHalfExtents(inertiaHalfExtents)
     23btMultiSphereShape::btMultiSphereShape (const btVector3* positions,const btScalar* radi,int numSpheres)
     24:btConvexInternalAabbCachingShape ()
    2225{
    2326        m_shapeType = MULTI_SPHERE_SHAPE_PROXYTYPE;
    24         btScalar startMargin = btScalar(1e30);
     27        //btScalar startMargin = btScalar(BT_LARGE_FLOAT);
    2528
    26         m_numSpheres = numSpheres;
    27         for (int i=0;i<m_numSpheres;i++)
     29        m_localPositionArray.resize(numSpheres);
     30        m_radiArray.resize(numSpheres);
     31        for (int i=0;i<numSpheres;i++)
    2832        {
    29                 m_localPositions[i] = positions[i];
    30                 m_radi[i] = radi[i];
    31                 if (radi[i] < startMargin)
    32                         startMargin = radi[i];
     33                m_localPositionArray[i] = positions[i];
     34                m_radiArray[i] = radi[i];
     35               
    3336        }
    34         setMargin(startMargin);
     37
     38        recalcLocalAabb();
    3539
    3640}
    37 
    38 
    3941
    4042 
     
    4446        btVector3 supVec(0,0,0);
    4547
    46         btScalar maxDot(btScalar(-1e30));
     48        btScalar maxDot(btScalar(-BT_LARGE_FLOAT));
    4749
    4850
     
    6163        btScalar newDot;
    6264
    63         const btVector3* pos = &m_localPositions[0];
    64         const btScalar* rad = &m_radi[0];
     65        const btVector3* pos = &m_localPositionArray[0];
     66        const btScalar* rad = &m_radiArray[0];
     67        int numSpheres = m_localPositionArray.size();
    6568
    66         for (i=0;i<m_numSpheres;i++)
     69        for (i=0;i<numSpheres;i++)
    6770        {
    6871                vtx = (*pos) +vec*m_localScaling*(*rad) - vec * getMargin();
     
    8689        for (int j=0;j<numVectors;j++)
    8790        {
    88                 btScalar maxDot(btScalar(-1e30));
     91                btScalar maxDot(btScalar(-BT_LARGE_FLOAT));
    8992
    9093                const btVector3& vec = vectors[j];
     
    9396                btScalar newDot;
    9497
    95                 const btVector3* pos = &m_localPositions[0];
    96                 const btScalar* rad = &m_radi[0];
    97 
    98                 for (int i=0;i<m_numSpheres;i++)
     98                const btVector3* pos = &m_localPositionArray[0];
     99                const btScalar* rad = &m_radiArray[0];
     100                int numSpheres = m_localPositionArray.size();
     101                for (int i=0;i<numSpheres;i++)
    99102                {
    100103                        vtx = (*pos) +vec*m_localScaling*(*rad) - vec * getMargin();
     
    122125        //as an approximation, take the inertia of the box that bounds the spheres
    123126
    124         btTransform ident;
    125         ident.setIdentity();
    126 //      btVector3 aabbMin,aabbMax;
     127        btVector3 localAabbMin,localAabbMax;
     128        getCachedLocalAabb(localAabbMin,localAabbMax);
     129        btVector3 halfExtents = (localAabbMax-localAabbMin)*btScalar(0.5);
    127130
    128 //      getAabb(ident,aabbMin,aabbMax);
     131        btScalar lx=btScalar(2.)*(halfExtents.x());
     132        btScalar ly=btScalar(2.)*(halfExtents.y());
     133        btScalar lz=btScalar(2.)*(halfExtents.z());
    129134
    130         btVector3 halfExtents = m_inertiaHalfExtents;//(aabbMax - aabbMin)* btScalar(0.5);
    131 
    132         btScalar margin = CONVEX_DISTANCE_MARGIN;
    133 
    134         btScalar lx=btScalar(2.)*(halfExtents[0]+margin);
    135         btScalar ly=btScalar(2.)*(halfExtents[1]+margin);
    136         btScalar lz=btScalar(2.)*(halfExtents[2]+margin);
    137         const btScalar x2 = lx*lx;
    138         const btScalar y2 = ly*ly;
    139         const btScalar z2 = lz*lz;
    140         const btScalar scaledmass = mass * btScalar(.08333333);
    141 
    142         inertia[0] = scaledmass * (y2+z2);
    143         inertia[1] = scaledmass * (x2+z2);
    144         inertia[2] = scaledmass * (x2+y2);
     135        inertia.setValue(mass/(btScalar(12.0)) * (ly*ly + lz*lz),
     136                                        mass/(btScalar(12.0)) * (lx*lx + lz*lz),
     137                                        mass/(btScalar(12.0)) * (lx*lx + ly*ly));
    145138
    146139}
    147140
    148141
     142///fills the dataBuffer and returns the struct name (and 0 on failure)
     143const char*     btMultiSphereShape::serialize(void* dataBuffer, btSerializer* serializer) const
     144{
     145        btMultiSphereShapeData* shapeData = (btMultiSphereShapeData*) dataBuffer;
     146        btConvexInternalShape::serialize(&shapeData->m_convexInternalShapeData, serializer);
    149147
     148        int numElem = m_localPositionArray.size();
     149        shapeData->m_localPositionArrayPtr = numElem ? (btPositionAndRadius*)serializer->getUniquePointer((void*)&m_localPositionArray[0]):  0;
     150       
     151        shapeData->m_localPositionArraySize = numElem;
     152        if (numElem)
     153        {
     154                btChunk* chunk = serializer->allocate(sizeof(btPositionAndRadius),numElem);
     155                btPositionAndRadius* memPtr = (btPositionAndRadius*)chunk->m_oldPtr;
     156                for (int i=0;i<numElem;i++,memPtr++)
     157                {
     158                        m_localPositionArray[i].serializeFloat(memPtr->m_pos);
     159                        memPtr->m_radius = float(m_radiArray[i]);
     160                }
     161                serializer->finalizeChunk(chunk,"btPositionAndRadius",BT_ARRAY_CODE,(void*)&m_localPositionArray[0]);
     162        }
     163       
     164        return "btMultiSphereShapeData";
     165}
     166
     167
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btMultiSphereShape.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    1919#include "btConvexInternalShape.h"
    2020#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
    21 
    22 #define MAX_NUM_SPHERES 5
    23 
    24 ///The btMultiSphereShape represents the convex hull of a collection of spheres. You can create special capsules or other smooth volumes.
    25 ///It is possible to animate the spheres for deformation.
    26 class btMultiSphereShape : public btConvexInternalShape
    27 
    28 {
    29        
    30         btVector3 m_localPositions[MAX_NUM_SPHERES];
    31         btScalar  m_radi[MAX_NUM_SPHERES];
    32         btVector3       m_inertiaHalfExtents;
    33 
    34         int m_numSpheres;
    35        
     21#include "LinearMath/btAlignedObjectArray.h"
     22#include "LinearMath/btAabbUtil2.h"
    3623
    3724
    3825
     26///The btMultiSphereShape represents the convex hull of a collection of spheres. You can create special capsules or other smooth volumes.
     27///It is possible to animate the spheres for deformation, but call 'recalcLocalAabb' after changing any sphere position/radius
     28class btMultiSphereShape : public btConvexInternalAabbCachingShape
     29{
     30       
     31        btAlignedObjectArray<btVector3> m_localPositionArray;
     32        btAlignedObjectArray<btScalar>  m_radiArray;
     33       
    3934public:
    40         btMultiSphereShape (const btVector3& inertiaHalfExtents,const btVector3* positions,const btScalar* radi,int numSpheres);
     35        btMultiSphereShape (const btVector3* positions,const btScalar* radi,int numSpheres);
    4136
    4237        ///CollisionShape Interface
     
    5045        int     getSphereCount() const
    5146        {
    52                 return m_numSpheres;
     47                return m_localPositionArray.size();
    5348        }
    5449
    5550        const btVector3&        getSpherePosition(int index) const
    5651        {
    57                 return m_localPositions[index];
     52                return m_localPositionArray[index];
    5853        }
    5954
    6055        btScalar        getSphereRadius(int index) const
    6156        {
    62                 return m_radi[index];
     57                return m_radiArray[index];
    6358        }
    6459
     
    6964        }
    7065
     66        virtual int     calculateSerializeBufferSize() const;
     67
     68        ///fills the dataBuffer and returns the struct name (and 0 on failure)
     69        virtual const char*     serialize(void* dataBuffer, btSerializer* serializer) const;
     70
     71
    7172};
    7273
    7374
     75struct  btPositionAndRadius
     76{
     77        btVector3FloatData      m_pos;
     78        float           m_radius;
     79};
     80
     81struct  btMultiSphereShapeData
     82{
     83        btConvexInternalShapeData       m_convexInternalShapeData;
     84
     85        btPositionAndRadius     *m_localPositionArrayPtr;
     86        int                             m_localPositionArraySize;
     87        char    m_padding[4];
     88};
     89
     90
     91
     92SIMD_FORCE_INLINE       int     btMultiSphereShape::calculateSerializeBufferSize() const
     93{
     94        return sizeof(btMultiSphereShapeData);
     95}
     96
     97
     98
    7499#endif //MULTI_SPHERE_MINKOWSKI_H
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.cpp

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2008 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2008 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    3838            m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;
    3939
    40             btVector3 m_triangle[3];
    4140            const unsigned char *vertexbase;
    4241            int numverts;
     
    7271            m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;
    7372
    74             btVector3 m_triangle[3];
    7573            const unsigned char *vertexbase;
    7674            int numverts;
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btOptimizedBvh.cpp

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    1414*/
    1515
     16
    1617#include "btOptimizedBvh.h"
    1718#include "btStridingMeshInterface.h"
     
    5657                        btOptimizedBvhNode node;
    5758                        btVector3       aabbMin,aabbMax;
    58                         aabbMin.setValue(btScalar(1e30),btScalar(1e30),btScalar(1e30));
    59                         aabbMax.setValue(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30));
     59                        aabbMin.setValue(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT));
     60                        aabbMax.setValue(btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT));
    6061                        aabbMin.setMin(triangle[0]);
    6162                        aabbMax.setMax(triangle[0]);
     
    104105                        btQuantizedBvhNode node;
    105106                        btVector3       aabbMin,aabbMax;
    106                         aabbMin.setValue(btScalar(1e30),btScalar(1e30),btScalar(1e30));
    107                         aabbMax.setValue(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30));
     107                        aabbMin.setValue(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT));
     108                        aabbMax.setValue(btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT));
    108109                        aabbMin.setMin(triangle[0]);
    109110                        aabbMax.setMax(triangle[0]);
     
    168169                NodeTriangleCallback    callback(m_leafNodes);
    169170
    170                 btVector3 aabbMin(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30));
    171                 btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
     171                btVector3 aabbMin(btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT));
     172                btVector3 aabbMax(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT));
    172173
    173174                triangles->InternalProcessAllTriangles(&callback,aabbMin,aabbMax);
     
    337338
    338339                               
    339                                 aabbMin.setValue(btScalar(1e30),btScalar(1e30),btScalar(1e30));
    340                                 aabbMax.setValue(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30));
     340                                aabbMin.setValue(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT));
     341                                aabbMax.setValue(btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT));
    341342                                aabbMin.setMin(triangleVerts[0]);
    342343                                aabbMax.setMax(triangleVerts[0]);
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btOptimizedBvh.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    13133. This notice may not be removed or altered from any source distribution.
    1414*/
     15
     16///Contains contributions from Disney Studio's
    1517
    1618#ifndef OPTIMIZED_BVH_H
     
    4648
    4749        /// Data buffer MUST be 16 byte aligned
    48         virtual bool serialize(void *o_alignedDataBuffer, unsigned i_dataBufferSize, bool i_swapEndian)
     50        virtual bool serializeInPlace(void *o_alignedDataBuffer, unsigned i_dataBufferSize, bool i_swapEndian) const
    4951        {
    5052                return btQuantizedBvh::serialize(o_alignedDataBuffer,i_dataBufferSize,i_swapEndian);
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    1616#include "BulletCollision/CollisionShapes/btPolyhedralConvexShape.h"
    1717
    18 btPolyhedralConvexShape::btPolyhedralConvexShape() :btConvexInternalShape(),
    19 m_localAabbMin(1,1,1),
    20 m_localAabbMax(-1,-1,-1),
    21 m_isLocalAabbValid(false),
    22 m_optionalHull(0)
     18btPolyhedralConvexShape::btPolyhedralConvexShape() :btConvexInternalShape()
    2319{
    2420
     
    2824btVector3       btPolyhedralConvexShape::localGetSupportingVertexWithoutMargin(const btVector3& vec0)const
    2925{
     26
     27
     28        btVector3 supVec(0,0,0);
     29#ifndef __SPU__
    3030        int i;
    31         btVector3 supVec(0,0,0);
    32 
    33         btScalar maxDot(btScalar(-1e30));
     31        btScalar maxDot(btScalar(-BT_LARGE_FLOAT));
    3432
    3533        btVector3 vec = vec0;
     
    5856        }
    5957
     58       
     59#endif //__SPU__
    6060        return supVec;
     61}
    6162
    62 }
     63
    6364
    6465void    btPolyhedralConvexShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
    6566{
     67#ifndef __SPU__
    6668        int i;
    6769
     
    7173        for (i=0;i<numVectors;i++)
    7274        {
    73                 supportVerticesOut[i][3] = btScalar(-1e30);
     75                supportVerticesOut[i][3] = btScalar(-BT_LARGE_FLOAT);
    7476        }
    7577
     
    9193                }
    9294        }
     95#endif //__SPU__
    9396}
    9497
     
    97100void    btPolyhedralConvexShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const
    98101{
     102#ifndef __SPU__
    99103        //not yet, return box inertia
    100104
     
    116120
    117121        inertia = scaledmass * (btVector3(y2+z2,x2+z2,x2+y2));
    118 
     122#endif //__SPU__
    119123}
    120124
    121125
    122126
    123 void btPolyhedralConvexShape::getAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax) const
    124 {
    125         getNonvirtualAabb(trans,aabbMin,aabbMax,getMargin());
    126 }
    127 
    128 
    129 
    130 void    btPolyhedralConvexShape::setLocalScaling(const btVector3& scaling)
     127void    btPolyhedralConvexAabbCachingShape::setLocalScaling(const btVector3& scaling)
    131128{
    132129        btConvexInternalShape::setLocalScaling(scaling);
     
    134131}
    135132
    136 void    btPolyhedralConvexShape::recalcLocalAabb()
     133btPolyhedralConvexAabbCachingShape::btPolyhedralConvexAabbCachingShape()
     134:btPolyhedralConvexShape(),
     135m_localAabbMin(1,1,1),
     136m_localAabbMax(-1,-1,-1),
     137m_isLocalAabbValid(false)
     138{
     139}
     140
     141void btPolyhedralConvexAabbCachingShape::getAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax) const
     142{
     143        getNonvirtualAabb(trans,aabbMin,aabbMax,getMargin());
     144}
     145
     146void    btPolyhedralConvexAabbCachingShape::recalcLocalAabb()
    137147{
    138148        m_isLocalAabbValid = true;
     
    182192}
    183193
    184 
    185 
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btPolyhedralConvexShape.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    1818
    1919#include "LinearMath/btMatrix3x3.h"
    20 #include "LinearMath/btAabbUtil2.h"
    2120#include "btConvexInternalShape.h"
    2221
     
    2726
    2827protected:
    29         btVector3       m_localAabbMin;
    30         btVector3       m_localAabbMax;
    31         bool            m_isLocalAabbValid;
    32 
     28       
    3329public:
    3430
     
    3935        virtual btVector3       localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
    4036        virtual void    batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
    41 
    4237       
    4338        virtual void    calculateLocalInertia(btScalar mass,btVector3& inertia) const;
     39       
     40       
     41        virtual int     getNumVertices() const = 0 ;
     42        virtual int getNumEdges() const = 0;
     43        virtual void getEdge(int i,btVector3& pa,btVector3& pb) const = 0;
     44        virtual void getVertex(int i,btVector3& vtx) const = 0;
     45        virtual int     getNumPlanes() const = 0;
     46        virtual void getPlane(btVector3& planeNormal,btVector3& planeSupport,int i ) const = 0;
     47//      virtual int getIndex(int i) const = 0 ;
    4448
     49        virtual bool isInside(const btVector3& pt,btScalar tolerance) const = 0;
     50       
     51};
     52
     53
     54///The btPolyhedralConvexAabbCachingShape adds aabb caching to the btPolyhedralConvexShape
     55class btPolyhedralConvexAabbCachingShape : public btPolyhedralConvexShape
     56{
     57
     58        btVector3       m_localAabbMin;
     59        btVector3       m_localAabbMax;
     60        bool            m_isLocalAabbValid;
     61               
     62protected:
    4563
    4664        void setCachedLocalAabb (const btVector3& aabbMin, const btVector3& aabbMax)
     
    5876        }
    5977
     78public:
     79
     80        btPolyhedralConvexAabbCachingShape();
     81       
    6082        inline void getNonvirtualAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax, btScalar margin) const
    6183        {
     
    6688        }
    6789
    68        
     90        virtual void    setLocalScaling(const btVector3& scaling);
     91
    6992        virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
    7093
    71         virtual void    setLocalScaling(const btVector3& scaling);
    72 
    7394        void    recalcLocalAabb();
    74 
    75         virtual int     getNumVertices() const = 0 ;
    76         virtual int getNumEdges() const = 0;
    77         virtual void getEdge(int i,btVector3& pa,btVector3& pb) const = 0;
    78         virtual void getVertex(int i,btVector3& vtx) const = 0;
    79         virtual int     getNumPlanes() const = 0;
    80         virtual void getPlane(btVector3& planeNormal,btVector3& planeSupport,int i ) const = 0;
    81 //      virtual int getIndex(int i) const = 0 ;
    82 
    83         virtual bool isInside(const btVector3& pt,btScalar tolerance) const = 0;
    84        
    85         /// optional Hull is for optional Separating Axis Test Hull collision detection, see Hull.cpp
    86         class   Hull*   m_optionalHull;
    8795
    8896};
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2008 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    13133. This notice may not be removed or altered from any source distribution.
    1414*/
     15
    1516
    1617#include "btScaledBvhTriangleMeshShape.h"
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2008 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btShapeHull.cpp

    r5781 r8284  
    11/*
    2 btbtShapeHull implemented by John McCutchan.
    3 
    42Bullet Continuous Collision Detection and Physics Library
    5 Copyright (c) 2003-2008 Erwin Coumans  http://bulletphysics.com
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    64
    75This software is provided 'as-is', without any express or implied warranty.
    86In no event will the authors be held liable for any damages arising from the use of this software.
    9 Permission is granted to anyone to use this software for any purpose,
    10 including commercial applications, and to alter it and redistribute it freely,
     7Permission is granted to anyone to use this software for any purpose, 
     8including commercial applications, and to alter it and redistribute it freely, 
    119subject to the following restrictions:
    1210
     
    1614*/
    1715
     16//btShapeHull was implemented by John McCutchan.
     17
     18
    1819#include "btShapeHull.h"
    1920#include "LinearMath/btConvexHull.h"
    2021
    2122#define NUM_UNITSPHERE_POINTS 42
    22 
    23 static btVector3 btUnitSpherePoints[NUM_UNITSPHERE_POINTS+MAX_PREFERRED_PENETRATION_DIRECTIONS*2] =
    24 {
    25         btVector3(btScalar(0.000000) , btScalar(-0.000000),btScalar(-1.000000)),
    26         btVector3(btScalar(0.723608) , btScalar(-0.525725),btScalar(-0.447219)),
    27         btVector3(btScalar(-0.276388) , btScalar(-0.850649),btScalar(-0.447219)),
    28         btVector3(btScalar(-0.894426) , btScalar(-0.000000),btScalar(-0.447216)),
    29         btVector3(btScalar(-0.276388) , btScalar(0.850649),btScalar(-0.447220)),
    30         btVector3(btScalar(0.723608) , btScalar(0.525725),btScalar(-0.447219)),
    31         btVector3(btScalar(0.276388) , btScalar(-0.850649),btScalar(0.447220)),
    32         btVector3(btScalar(-0.723608) , btScalar(-0.525725),btScalar(0.447219)),
    33         btVector3(btScalar(-0.723608) , btScalar(0.525725),btScalar(0.447219)),
    34         btVector3(btScalar(0.276388) , btScalar(0.850649),btScalar(0.447219)),
    35         btVector3(btScalar(0.894426) , btScalar(0.000000),btScalar(0.447216)),
    36         btVector3(btScalar(-0.000000) , btScalar(0.000000),btScalar(1.000000)),
    37         btVector3(btScalar(0.425323) , btScalar(-0.309011),btScalar(-0.850654)),
    38         btVector3(btScalar(-0.162456) , btScalar(-0.499995),btScalar(-0.850654)),
    39         btVector3(btScalar(0.262869) , btScalar(-0.809012),btScalar(-0.525738)),
    40         btVector3(btScalar(0.425323) , btScalar(0.309011),btScalar(-0.850654)),
    41         btVector3(btScalar(0.850648) , btScalar(-0.000000),btScalar(-0.525736)),
    42         btVector3(btScalar(-0.525730) , btScalar(-0.000000),btScalar(-0.850652)),
    43         btVector3(btScalar(-0.688190) , btScalar(-0.499997),btScalar(-0.525736)),
    44         btVector3(btScalar(-0.162456) , btScalar(0.499995),btScalar(-0.850654)),
    45         btVector3(btScalar(-0.688190) , btScalar(0.499997),btScalar(-0.525736)),
    46         btVector3(btScalar(0.262869) , btScalar(0.809012),btScalar(-0.525738)),
    47         btVector3(btScalar(0.951058) , btScalar(0.309013),btScalar(0.000000)),
    48         btVector3(btScalar(0.951058) , btScalar(-0.309013),btScalar(0.000000)),
    49         btVector3(btScalar(0.587786) , btScalar(-0.809017),btScalar(0.000000)),
    50         btVector3(btScalar(0.000000) , btScalar(-1.000000),btScalar(0.000000)),
    51         btVector3(btScalar(-0.587786) , btScalar(-0.809017),btScalar(0.000000)),
    52         btVector3(btScalar(-0.951058) , btScalar(-0.309013),btScalar(-0.000000)),
    53         btVector3(btScalar(-0.951058) , btScalar(0.309013),btScalar(-0.000000)),
    54         btVector3(btScalar(-0.587786) , btScalar(0.809017),btScalar(-0.000000)),
    55         btVector3(btScalar(-0.000000) , btScalar(1.000000),btScalar(-0.000000)),
    56         btVector3(btScalar(0.587786) , btScalar(0.809017),btScalar(-0.000000)),
    57         btVector3(btScalar(0.688190) , btScalar(-0.499997),btScalar(0.525736)),
    58         btVector3(btScalar(-0.262869) , btScalar(-0.809012),btScalar(0.525738)),
    59         btVector3(btScalar(-0.850648) , btScalar(0.000000),btScalar(0.525736)),
    60         btVector3(btScalar(-0.262869) , btScalar(0.809012),btScalar(0.525738)),
    61         btVector3(btScalar(0.688190) , btScalar(0.499997),btScalar(0.525736)),
    62         btVector3(btScalar(0.525730) , btScalar(0.000000),btScalar(0.850652)),
    63         btVector3(btScalar(0.162456) , btScalar(-0.499995),btScalar(0.850654)),
    64         btVector3(btScalar(-0.425323) , btScalar(-0.309011),btScalar(0.850654)),
    65         btVector3(btScalar(-0.425323) , btScalar(0.309011),btScalar(0.850654)),
    66         btVector3(btScalar(0.162456) , btScalar(0.499995),btScalar(0.850654))
    67 };
    6823
    6924btShapeHull::btShapeHull (const btConvexShape* shape)
     
    9348                                btVector3 norm;
    9449                                m_shape->getPreferredPenetrationDirection(i,norm);
    95                                 btUnitSpherePoints[numSampleDirections] = norm;
     50                                getUnitSpherePoints()[numSampleDirections] = norm;
    9651                                numSampleDirections++;
    9752                        }
     
    10358        for (i = 0; i < numSampleDirections; i++)
    10459        {
    105                 supportPoints[i] = m_shape->localGetSupportingVertex(btUnitSpherePoints[i]);
     60                supportPoints[i] = m_shape->localGetSupportingVertex(getUnitSpherePoints()[i]);
    10661        }
    10762
     
    163118}
    164119
     120
     121btVector3* btShapeHull::getUnitSpherePoints()
     122{
     123        static btVector3 sUnitSpherePoints[NUM_UNITSPHERE_POINTS+MAX_PREFERRED_PENETRATION_DIRECTIONS*2] =
     124        {
     125                btVector3(btScalar(0.000000) , btScalar(-0.000000),btScalar(-1.000000)),
     126                btVector3(btScalar(0.723608) , btScalar(-0.525725),btScalar(-0.447219)),
     127                btVector3(btScalar(-0.276388) , btScalar(-0.850649),btScalar(-0.447219)),
     128                btVector3(btScalar(-0.894426) , btScalar(-0.000000),btScalar(-0.447216)),
     129                btVector3(btScalar(-0.276388) , btScalar(0.850649),btScalar(-0.447220)),
     130                btVector3(btScalar(0.723608) , btScalar(0.525725),btScalar(-0.447219)),
     131                btVector3(btScalar(0.276388) , btScalar(-0.850649),btScalar(0.447220)),
     132                btVector3(btScalar(-0.723608) , btScalar(-0.525725),btScalar(0.447219)),
     133                btVector3(btScalar(-0.723608) , btScalar(0.525725),btScalar(0.447219)),
     134                btVector3(btScalar(0.276388) , btScalar(0.850649),btScalar(0.447219)),
     135                btVector3(btScalar(0.894426) , btScalar(0.000000),btScalar(0.447216)),
     136                btVector3(btScalar(-0.000000) , btScalar(0.000000),btScalar(1.000000)),
     137                btVector3(btScalar(0.425323) , btScalar(-0.309011),btScalar(-0.850654)),
     138                btVector3(btScalar(-0.162456) , btScalar(-0.499995),btScalar(-0.850654)),
     139                btVector3(btScalar(0.262869) , btScalar(-0.809012),btScalar(-0.525738)),
     140                btVector3(btScalar(0.425323) , btScalar(0.309011),btScalar(-0.850654)),
     141                btVector3(btScalar(0.850648) , btScalar(-0.000000),btScalar(-0.525736)),
     142                btVector3(btScalar(-0.525730) , btScalar(-0.000000),btScalar(-0.850652)),
     143                btVector3(btScalar(-0.688190) , btScalar(-0.499997),btScalar(-0.525736)),
     144                btVector3(btScalar(-0.162456) , btScalar(0.499995),btScalar(-0.850654)),
     145                btVector3(btScalar(-0.688190) , btScalar(0.499997),btScalar(-0.525736)),
     146                btVector3(btScalar(0.262869) , btScalar(0.809012),btScalar(-0.525738)),
     147                btVector3(btScalar(0.951058) , btScalar(0.309013),btScalar(0.000000)),
     148                btVector3(btScalar(0.951058) , btScalar(-0.309013),btScalar(0.000000)),
     149                btVector3(btScalar(0.587786) , btScalar(-0.809017),btScalar(0.000000)),
     150                btVector3(btScalar(0.000000) , btScalar(-1.000000),btScalar(0.000000)),
     151                btVector3(btScalar(-0.587786) , btScalar(-0.809017),btScalar(0.000000)),
     152                btVector3(btScalar(-0.951058) , btScalar(-0.309013),btScalar(-0.000000)),
     153                btVector3(btScalar(-0.951058) , btScalar(0.309013),btScalar(-0.000000)),
     154                btVector3(btScalar(-0.587786) , btScalar(0.809017),btScalar(-0.000000)),
     155                btVector3(btScalar(-0.000000) , btScalar(1.000000),btScalar(-0.000000)),
     156                btVector3(btScalar(0.587786) , btScalar(0.809017),btScalar(-0.000000)),
     157                btVector3(btScalar(0.688190) , btScalar(-0.499997),btScalar(0.525736)),
     158                btVector3(btScalar(-0.262869) , btScalar(-0.809012),btScalar(0.525738)),
     159                btVector3(btScalar(-0.850648) , btScalar(0.000000),btScalar(0.525736)),
     160                btVector3(btScalar(-0.262869) , btScalar(0.809012),btScalar(0.525738)),
     161                btVector3(btScalar(0.688190) , btScalar(0.499997),btScalar(0.525736)),
     162                btVector3(btScalar(0.525730) , btScalar(0.000000),btScalar(0.850652)),
     163                btVector3(btScalar(0.162456) , btScalar(-0.499995),btScalar(0.850654)),
     164                btVector3(btScalar(-0.425323) , btScalar(-0.309011),btScalar(0.850654)),
     165                btVector3(btScalar(-0.425323) , btScalar(0.309011),btScalar(0.850654)),
     166                btVector3(btScalar(0.162456) , btScalar(0.499995),btScalar(0.850654))
     167        };
     168        return sUnitSpherePoints;
     169}
     170
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btShapeHull.h

    r5781 r8284  
    11/*
    2 btShapeHull implemented by John McCutchan.
    3 
    42Bullet Continuous Collision Detection and Physics Library
    5 Copyright (c) 2003-2008 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    64
    75This software is provided 'as-is', without any express or implied warranty.
    86In no event will the authors be held liable for any damages arising from the use of this software.
    9 Permission is granted to anyone to use this software for any purpose,
    10 including commercial applications, and to alter it and redistribute it freely,
     7Permission is granted to anyone to use this software for any purpose, 
     8including commercial applications, and to alter it and redistribute it freely, 
    119subject to the following restrictions:
    1210
     
    15133. This notice may not be removed or altered from any source distribution.
    1614*/
     15
     16///btShapeHull implemented by John McCutchan.
    1717
    1818#ifndef _SHAPE_HULL_H
     
    2828class btShapeHull
    2929{
     30protected:
     31
     32        btAlignedObjectArray<btVector3> m_vertices;
     33        btAlignedObjectArray<unsigned int> m_indices;
     34        unsigned int m_numIndices;
     35        const btConvexShape* m_shape;
     36
     37        static btVector3* getUnitSpherePoints();
     38
    3039public:
    3140        btShapeHull (const btConvexShape* shape);
     
    4655                return &m_indices[0];
    4756        }
    48 
    49 protected:
    50         btAlignedObjectArray<btVector3> m_vertices;
    51         btAlignedObjectArray<unsigned int> m_indices;
    52         unsigned int m_numIndices;
    53         const btConvexShape* m_shape;
    5457};
    5558
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btSphereShape.cpp

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btSphereShape.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    13133. This notice may not be removed or altered from any source distribution.
    1414*/
    15 
    1615#ifndef SPHERE_MINKOWSKI_H
    1716#define SPHERE_MINKOWSKI_H
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btStaticPlaneShape.cpp

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    3939        (void)t;
    4040        /*
    41         btVector3 infvec (btScalar(1e30),btScalar(1e30),btScalar(1e30));
     41        btVector3 infvec (btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT));
    4242
    4343        btVector3 center = m_planeNormal*m_planeConstant;
     
    4848        */
    4949
    50         aabbMin.setValue(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30));
    51         aabbMax.setValue(btScalar(1e30),btScalar(1e30),btScalar(1e30));
     50        aabbMin.setValue(btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT));
     51        aabbMax.setValue(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT));
    5252
    5353}
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btStaticPlaneShape.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    2121
    2222///The btStaticPlaneShape simulates an infinite non-moving (static) collision plane.
    23 class btStaticPlaneShape : public btConcaveShape
     23ATTRIBUTE_ALIGNED16(class) btStaticPlaneShape : public btConcaveShape
    2424{
    2525protected:
     
    5959        virtual const char*     getName()const {return "STATICPLANE";}
    6060
     61        virtual int     calculateSerializeBufferSize() const;
     62
     63        ///fills the dataBuffer and returns the struct name (and 0 on failure)
     64        virtual const char*     serialize(void* dataBuffer, btSerializer* serializer) const;
     65
    6166
    6267};
    6368
     69///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
     70struct  btStaticPlaneShapeData
     71{
     72        btCollisionShapeData    m_collisionShapeData;
     73
     74        btVector3FloatData      m_localScaling;
     75        btVector3FloatData      m_planeNormal;
     76        float                   m_planeConstant;
     77        char    m_pad[4];
     78};
     79
     80
     81SIMD_FORCE_INLINE       int     btStaticPlaneShape::calculateSerializeBufferSize() const
     82{
     83        return sizeof(btStaticPlaneShapeData);
     84}
     85
     86///fills the dataBuffer and returns the struct name (and 0 on failure)
     87SIMD_FORCE_INLINE       const char*     btStaticPlaneShape::serialize(void* dataBuffer, btSerializer* serializer) const
     88{
     89        btStaticPlaneShapeData* planeData = (btStaticPlaneShapeData*) dataBuffer;
     90        btCollisionShape::serialize(&planeData->m_collisionShapeData,serializer);
     91
     92        m_localScaling.serializeFloat(planeData->m_localScaling);
     93        m_planeNormal.serializeFloat(planeData->m_planeNormal);
     94        planeData->m_planeConstant = float(m_planeConstant);
     95               
     96        return "btStaticPlaneShapeData";
     97}
     98
     99
    64100#endif //STATIC_PLANE_SHAPE_H
     101
     102
     103
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btStridingMeshInterface.cpp

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    1515
    1616#include "btStridingMeshInterface.h"
     17#include "LinearMath/btSerializer.h"
    1718
    1819btStridingMeshInterface::~btStridingMeshInterface()
     
    3637        int gfxindex;
    3738        btVector3 triangle[3];
    38         btScalar* graphicsbase;
    3939
    4040        btVector3 meshScaling = getScaling();
     
    4646                numtotalphysicsverts+=numtriangles*3; //upper bound
    4747
    48                 switch (gfxindextype)
     48                ///unlike that developers want to pass in double-precision meshes in single-precision Bullet build
     49                ///so disable this feature by default
     50                ///see patch http://code.google.com/p/bullet/issues/detail?id=213
     51
     52                switch (type)
    4953                {
    50                 case PHY_INTEGER:
     54                case PHY_FLOAT:
     55                 {
     56
     57                         float* graphicsbase;
     58
     59                         switch (gfxindextype)
     60                         {
     61                         case PHY_INTEGER:
     62                                 {
     63                                         for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
     64                                         {
     65                                                 unsigned int* tri_indices= (unsigned int*)(indexbase+gfxindex*indexstride);
     66                                                 graphicsbase = (float*)(vertexbase+tri_indices[0]*stride);
     67                                                 triangle[0].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ());
     68                                                 graphicsbase = (float*)(vertexbase+tri_indices[1]*stride);
     69                                                 triangle[1].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),    graphicsbase[2]*meshScaling.getZ());
     70                                                 graphicsbase = (float*)(vertexbase+tri_indices[2]*stride);
     71                                                 triangle[2].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),    graphicsbase[2]*meshScaling.getZ());
     72                                                 callback->internalProcessTriangleIndex(triangle,part,gfxindex);
     73                                         }
     74                                         break;
     75                                 }
     76                         case PHY_SHORT:
     77                                 {
     78                                         for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
     79                                         {
     80                                                 unsigned short int* tri_indices= (unsigned short int*)(indexbase+gfxindex*indexstride);
     81                                                 graphicsbase = (float*)(vertexbase+tri_indices[0]*stride);
     82                                                 triangle[0].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ());
     83                                                 graphicsbase = (float*)(vertexbase+tri_indices[1]*stride);
     84                                                 triangle[1].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),    graphicsbase[2]*meshScaling.getZ());
     85                                                 graphicsbase = (float*)(vertexbase+tri_indices[2]*stride);
     86                                                 triangle[2].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),    graphicsbase[2]*meshScaling.getZ());
     87                                                 callback->internalProcessTriangleIndex(triangle,part,gfxindex);
     88                                         }
     89                                         break;
     90                                 }
     91                         default:
     92                                 btAssert((gfxindextype == PHY_INTEGER) || (gfxindextype == PHY_SHORT));
     93                         }
     94                         break;
     95                 }
     96
     97                case PHY_DOUBLE:
    5198                        {
    52                                 for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
    53                                 {
    54                                         unsigned int* tri_indices= (unsigned int*)(indexbase+gfxindex*indexstride);
    55                                         graphicsbase = (btScalar*)(vertexbase+tri_indices[0]*stride);
    56                                         triangle[0].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ());
    57                                         graphicsbase = (btScalar*)(vertexbase+tri_indices[1]*stride);
    58                                         triangle[1].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),     graphicsbase[2]*meshScaling.getZ());
    59                                         graphicsbase = (btScalar*)(vertexbase+tri_indices[2]*stride);
    60                                         triangle[2].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),     graphicsbase[2]*meshScaling.getZ());
    61                                         callback->internalProcessTriangleIndex(triangle,part,gfxindex);
    62                                 }
    63                                 break;
    64                         }
    65                 case PHY_SHORT:
    66                         {
    67                                 for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
    68                                 {
    69                                         unsigned short int* tri_indices= (unsigned short int*)(indexbase+gfxindex*indexstride);
    70                                         graphicsbase = (btScalar*)(vertexbase+tri_indices[0]*stride);
    71                                         triangle[0].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ());
    72                                         graphicsbase = (btScalar*)(vertexbase+tri_indices[1]*stride);
    73                                         triangle[1].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),     graphicsbase[2]*meshScaling.getZ());
    74                                         graphicsbase = (btScalar*)(vertexbase+tri_indices[2]*stride);
    75                                         triangle[2].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),     graphicsbase[2]*meshScaling.getZ());
    76                                         callback->internalProcessTriangleIndex(triangle,part,gfxindex);
     99                                double* graphicsbase;
     100
     101                                switch (gfxindextype)
     102                                {
     103                                case PHY_INTEGER:
     104                                        {
     105                                                for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
     106                                                {
     107                                                        unsigned int* tri_indices= (unsigned int*)(indexbase+gfxindex*indexstride);
     108                                                        graphicsbase = (double*)(vertexbase+tri_indices[0]*stride);
     109                                                        triangle[0].setValue((btScalar)graphicsbase[0]*meshScaling.getX(),(btScalar)graphicsbase[1]*meshScaling.getY(),(btScalar)graphicsbase[2]*meshScaling.getZ());
     110                                                        graphicsbase = (double*)(vertexbase+tri_indices[1]*stride);
     111                                                        triangle[1].setValue((btScalar)graphicsbase[0]*meshScaling.getX(),(btScalar)graphicsbase[1]*meshScaling.getY(),  (btScalar)graphicsbase[2]*meshScaling.getZ());
     112                                                        graphicsbase = (double*)(vertexbase+tri_indices[2]*stride);
     113                                                        triangle[2].setValue((btScalar)graphicsbase[0]*meshScaling.getX(),(btScalar)graphicsbase[1]*meshScaling.getY(),  (btScalar)graphicsbase[2]*meshScaling.getZ());
     114                                                        callback->internalProcessTriangleIndex(triangle,part,gfxindex);
     115                                                }
     116                                                break;
     117                                        }
     118                                case PHY_SHORT:
     119                                        {
     120                                                for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
     121                                                {
     122                                                        unsigned short int* tri_indices= (unsigned short int*)(indexbase+gfxindex*indexstride);
     123                                                        graphicsbase = (double*)(vertexbase+tri_indices[0]*stride);
     124                                                        triangle[0].setValue((btScalar)graphicsbase[0]*meshScaling.getX(),(btScalar)graphicsbase[1]*meshScaling.getY(),(btScalar)graphicsbase[2]*meshScaling.getZ());
     125                                                        graphicsbase = (double*)(vertexbase+tri_indices[1]*stride);
     126                                                        triangle[1].setValue((btScalar)graphicsbase[0]*meshScaling.getX(),(btScalar)graphicsbase[1]*meshScaling.getY(),  (btScalar)graphicsbase[2]*meshScaling.getZ());
     127                                                        graphicsbase = (double*)(vertexbase+tri_indices[2]*stride);
     128                                                        triangle[2].setValue((btScalar)graphicsbase[0]*meshScaling.getX(),(btScalar)graphicsbase[1]*meshScaling.getY(),  (btScalar)graphicsbase[2]*meshScaling.getZ());
     129                                                        callback->internalProcessTriangleIndex(triangle,part,gfxindex);
     130                                                }
     131                                                break;
     132                                        }
     133                                default:
     134                                        btAssert((gfxindextype == PHY_INTEGER) || (gfxindextype == PHY_SHORT));
    77135                                }
    78136                                break;
    79137                        }
    80138                default:
    81                         btAssert((gfxindextype == PHY_INTEGER) || (gfxindextype == PHY_SHORT));
     139                        btAssert((type == PHY_FLOAT) || (type == PHY_DOUBLE));
    82140                }
    83141
     
    96154                AabbCalculationCallback()
    97155                {
    98                         m_aabbMin.setValue(btScalar(1e30),btScalar(1e30),btScalar(1e30));
    99                         m_aabbMax.setValue(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30));
     156                        m_aabbMin.setValue(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT));
     157                        m_aabbMax.setValue(btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT));
    100158                }
    101159
     
    114172        };
    115173
    116                 //first calculate the total aabb for all triangles
     174        //first calculate the total aabb for all triangles
    117175        AabbCalculationCallback aabbCallback;
    118         aabbMin.setValue(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30));
    119         aabbMax.setValue(btScalar(1e30),btScalar(1e30),btScalar(1e30));
     176        aabbMin.setValue(btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT));
     177        aabbMax.setValue(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT));
    120178        InternalProcessAllTriangles(&aabbCallback,aabbMin,aabbMax);
    121179
     
    123181        aabbMax = aabbCallback.m_aabbMax;
    124182}
     183
     184
     185
     186///fills the dataBuffer and returns the struct name (and 0 on failure)
     187const char*     btStridingMeshInterface::serialize(void* dataBuffer, btSerializer* serializer) const
     188{
     189        btStridingMeshInterfaceData* trimeshData = (btStridingMeshInterfaceData*) dataBuffer;
     190
     191        trimeshData->m_numMeshParts = getNumSubParts();
     192
     193        //void* uniquePtr = 0;
     194
     195        trimeshData->m_meshPartsPtr = 0;
     196
     197        if (trimeshData->m_numMeshParts)
     198        {
     199                btChunk* chunk = serializer->allocate(sizeof(btMeshPartData),trimeshData->m_numMeshParts);
     200                btMeshPartData* memPtr = (btMeshPartData*)chunk->m_oldPtr;
     201                trimeshData->m_meshPartsPtr = (btMeshPartData *)serializer->getUniquePointer(memPtr);
     202
     203
     204        //      int numtotalphysicsverts = 0;
     205                int part,graphicssubparts = getNumSubParts();
     206                const unsigned char * vertexbase;
     207                const unsigned char * indexbase;
     208                int indexstride;
     209                PHY_ScalarType type;
     210                PHY_ScalarType gfxindextype;
     211                int stride,numverts,numtriangles;
     212                int gfxindex;
     213        //      btVector3 triangle[3];
     214
     215                btVector3 meshScaling = getScaling();
     216
     217                ///if the number of parts is big, the performance might drop due to the innerloop switch on indextype
     218                for (part=0;part<graphicssubparts ;part++,memPtr++)
     219                {
     220                        getLockedReadOnlyVertexIndexBase(&vertexbase,numverts,type,stride,&indexbase,indexstride,numtriangles,gfxindextype,part);
     221                        memPtr->m_numTriangles = numtriangles;//indices = 3*numtriangles
     222                        memPtr->m_numVertices = numverts;
     223                        memPtr->m_indices16 = 0;
     224                        memPtr->m_indices32 = 0;
     225                        memPtr->m_3indices16 = 0;
     226                        memPtr->m_vertices3f = 0;
     227                        memPtr->m_vertices3d = 0;
     228
     229                        switch (gfxindextype)
     230                        {
     231                        case PHY_INTEGER:
     232                                {
     233                                        int numindices = numtriangles*3;
     234                               
     235                                        if (numindices)
     236                                        {
     237                                                btChunk* chunk = serializer->allocate(sizeof(btIntIndexData),numindices);
     238                                                btIntIndexData* tmpIndices = (btIntIndexData*)chunk->m_oldPtr;
     239                                                memPtr->m_indices32 = (btIntIndexData*)serializer->getUniquePointer(tmpIndices);
     240                                                for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
     241                                                {
     242                                                        unsigned int* tri_indices= (unsigned int*)(indexbase+gfxindex*indexstride);
     243                                                        tmpIndices[gfxindex*3].m_value = tri_indices[0];
     244                                                        tmpIndices[gfxindex*3+1].m_value = tri_indices[1];
     245                                                        tmpIndices[gfxindex*3+2].m_value = tri_indices[2];
     246                                                }
     247                                                serializer->finalizeChunk(chunk,"btIntIndexData",BT_ARRAY_CODE,(void*)chunk->m_oldPtr);
     248                                        }
     249                                        break;
     250                                }
     251                        case PHY_SHORT:
     252                                {
     253                                        if (numtriangles)
     254                                        {
     255                                                btChunk* chunk = serializer->allocate(sizeof(btShortIntIndexTripletData),numtriangles);
     256                                                btShortIntIndexTripletData* tmpIndices = (btShortIntIndexTripletData*)chunk->m_oldPtr;
     257                                                memPtr->m_3indices16 = (btShortIntIndexTripletData*) serializer->getUniquePointer(tmpIndices);
     258                                                for (gfxindex=0;gfxindex<numtriangles;gfxindex++)
     259                                                {
     260                                                        unsigned short int* tri_indices= (unsigned short int*)(indexbase+gfxindex*indexstride);
     261                                                        tmpIndices[gfxindex].m_values[0] = tri_indices[0];
     262                                                        tmpIndices[gfxindex].m_values[1] = tri_indices[1];
     263                                                        tmpIndices[gfxindex].m_values[2] = tri_indices[2];
     264                                                }
     265                                                serializer->finalizeChunk(chunk,"btShortIntIndexTripletData",BT_ARRAY_CODE,(void*)chunk->m_oldPtr);
     266                                        }
     267                                        break;
     268                                }
     269                        default:
     270                                {
     271                                        btAssert(0);
     272                                        //unknown index type
     273                                }
     274                        }
     275
     276                        switch (type)
     277                        {
     278                        case PHY_FLOAT:
     279                         {
     280                                 float* graphicsbase;
     281
     282                                 if (numverts)
     283                                 {
     284                                         btChunk* chunk = serializer->allocate(sizeof(btVector3FloatData),numverts);
     285                                         btVector3FloatData* tmpVertices = (btVector3FloatData*) chunk->m_oldPtr;
     286                                         memPtr->m_vertices3f = (btVector3FloatData *)serializer->getUniquePointer(tmpVertices);
     287                                         for (int i=0;i<numverts;i++)
     288                                         {
     289                                                 graphicsbase = (float*)(vertexbase+i*stride);
     290                                                 tmpVertices[i].m_floats[0] = graphicsbase[0];
     291                                                 tmpVertices[i].m_floats[1] = graphicsbase[1];
     292                                                 tmpVertices[i].m_floats[2] = graphicsbase[2];
     293                                         }
     294                                         serializer->finalizeChunk(chunk,"btVector3FloatData",BT_ARRAY_CODE,(void*)chunk->m_oldPtr);
     295                                 }
     296                                 break;
     297                                }
     298
     299                        case PHY_DOUBLE:
     300                                {
     301                                        if (numverts)
     302                                        {
     303                                                btChunk* chunk = serializer->allocate(sizeof(btVector3DoubleData),numverts);
     304                                                btVector3DoubleData* tmpVertices = (btVector3DoubleData*) chunk->m_oldPtr;
     305                                                memPtr->m_vertices3d = (btVector3DoubleData *) serializer->getUniquePointer(tmpVertices);
     306                                                for (int i=0;i<numverts;i++)
     307                                         {
     308                                                 double* graphicsbase = (double*)(vertexbase+i*stride);//for now convert to float, might leave it at double
     309                                                 tmpVertices[i].m_floats[0] = graphicsbase[0];
     310                                                 tmpVertices[i].m_floats[1] = graphicsbase[1];
     311                                                 tmpVertices[i].m_floats[2] = graphicsbase[2];
     312                                         }
     313                                                serializer->finalizeChunk(chunk,"btVector3DoubleData",BT_ARRAY_CODE,(void*)chunk->m_oldPtr);
     314                                        }
     315                                        break;
     316                                }
     317
     318                        default:
     319                                btAssert((type == PHY_FLOAT) || (type == PHY_DOUBLE));
     320                        }
     321
     322                        unLockReadOnlyVertexBase(part);
     323                }
     324
     325                serializer->finalizeChunk(chunk,"btMeshPartData",BT_ARRAY_CODE,chunk->m_oldPtr);
     326        }
     327
     328
     329        m_scaling.serializeFloat(trimeshData->m_scaling);
     330        return "btStridingMeshInterfaceData";
     331}
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btStridingMeshInterface.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    2020#include "btTriangleCallback.h"
    2121#include "btConcaveShape.h"
     22
     23
    2224
    2325
     
    9092                }
    9193
    92        
     94                virtual int     calculateSerializeBufferSize() const;
     95
     96                ///fills the dataBuffer and returns the struct name (and 0 on failure)
     97                virtual const char*     serialize(void* dataBuffer, btSerializer* serializer) const;
     98
    9399
    94100};
    95101
     102struct  btIntIndexData
     103{
     104        int     m_value;
     105};
     106
     107struct  btShortIntIndexData
     108{
     109        short m_value;
     110        char m_pad[2];
     111};
     112
     113struct  btShortIntIndexTripletData
     114{
     115        short   m_values[3];
     116        char    m_pad[2];
     117};
     118
     119///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
     120struct  btMeshPartData
     121{
     122        btVector3FloatData                      *m_vertices3f;
     123        btVector3DoubleData                     *m_vertices3d;
     124
     125        btIntIndexData                          *m_indices32;
     126        btShortIntIndexTripletData      *m_3indices16;
     127
     128        btShortIntIndexData                     *m_indices16;//backwards compatibility
     129
     130        int                     m_numTriangles;//length of m_indices = m_numTriangles
     131        int                     m_numVertices;
     132};
     133
     134
     135///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64
     136struct  btStridingMeshInterfaceData
     137{
     138        btMeshPartData  *m_meshPartsPtr;
     139        btVector3FloatData      m_scaling;
     140        int     m_numMeshParts;
     141        char m_padding[4];
     142};
     143
     144
     145
     146
     147SIMD_FORCE_INLINE       int     btStridingMeshInterface::calculateSerializeBufferSize() const
     148{
     149        return sizeof(btStridingMeshInterfaceData);
     150}
     151
     152
     153
    96154#endif //STRIDING_MESHINTERFACE_H
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btTetrahedronShape.cpp

    r5781 r8284  
    1 
    21/*
    32Bullet Continuous Collision Detection and Physics Library
    4 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    54
    65This software is provided 'as-is', without any express or implied warranty.
     
    14133. This notice may not be removed or altered from any source distribution.
    1514*/
     15
    1616#include "btTetrahedronShape.h"
    1717#include "LinearMath/btMatrix3x3.h"
    1818
    19 btBU_Simplex1to4::btBU_Simplex1to4() : btPolyhedralConvexShape (),
    20 m_numVertices(0)
    21 {
    22         m_shapeType = TETRAHEDRAL_SHAPE_PROXYTYPE;
    23 }
    24 
    25 btBU_Simplex1to4::btBU_Simplex1to4(const btVector3& pt0) : btPolyhedralConvexShape (),
    26 m_numVertices(0)
    27 {
    28         m_shapeType = TETRAHEDRAL_SHAPE_PROXYTYPE;
    29         addVertex(pt0);
    30 }
    31 
    32 btBU_Simplex1to4::btBU_Simplex1to4(const btVector3& pt0,const btVector3& pt1) : btPolyhedralConvexShape (),
     19btBU_Simplex1to4::btBU_Simplex1to4() : btPolyhedralConvexAabbCachingShape (),
     20m_numVertices(0)
     21{
     22        m_shapeType = TETRAHEDRAL_SHAPE_PROXYTYPE;
     23}
     24
     25btBU_Simplex1to4::btBU_Simplex1to4(const btVector3& pt0) : btPolyhedralConvexAabbCachingShape (),
     26m_numVertices(0)
     27{
     28        m_shapeType = TETRAHEDRAL_SHAPE_PROXYTYPE;
     29        addVertex(pt0);
     30}
     31
     32btBU_Simplex1to4::btBU_Simplex1to4(const btVector3& pt0,const btVector3& pt1) : btPolyhedralConvexAabbCachingShape (),
    3333m_numVertices(0)
    3434{
     
    3838}
    3939
    40 btBU_Simplex1to4::btBU_Simplex1to4(const btVector3& pt0,const btVector3& pt1,const btVector3& pt2) : btPolyhedralConvexShape (),
     40btBU_Simplex1to4::btBU_Simplex1to4(const btVector3& pt0,const btVector3& pt1,const btVector3& pt2) : btPolyhedralConvexAabbCachingShape (),
    4141m_numVertices(0)
    4242{
     
    4747}
    4848
    49 btBU_Simplex1to4::btBU_Simplex1to4(const btVector3& pt0,const btVector3& pt1,const btVector3& pt2,const btVector3& pt3) : btPolyhedralConvexShape (),
     49btBU_Simplex1to4::btBU_Simplex1to4(const btVector3& pt0,const btVector3& pt1,const btVector3& pt2,const btVector3& pt3) : btPolyhedralConvexAabbCachingShape (),
    5050m_numVertices(0)
    5151{
     
    5858
    5959
     60void btBU_Simplex1to4::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
     61{
     62#if 1
     63        btPolyhedralConvexAabbCachingShape::getAabb(t,aabbMin,aabbMax);
     64#else
     65        aabbMin.setValue(BT_LARGE_FLOAT,BT_LARGE_FLOAT,BT_LARGE_FLOAT);
     66        aabbMax.setValue(-BT_LARGE_FLOAT,-BT_LARGE_FLOAT,-BT_LARGE_FLOAT);
     67
     68        //just transform the vertices in worldspace, and take their AABB
     69        for (int i=0;i<m_numVertices;i++)
     70        {
     71                btVector3 worldVertex = t(m_vertices[i]);
     72                aabbMin.setMin(worldVertex);
     73                aabbMax.setMax(worldVertex);
     74        }
     75#endif
     76}
     77
     78
    6079
    6180
     
    6483{
    6584        m_vertices[m_numVertices++] = pt;
    66 
    6785        recalcLocalAabb();
    6886}
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btTetrahedronShape.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    2323
    2424///The btBU_Simplex1to4 implements tetrahedron, triangle, line, vertex collision shapes. In most cases it is better to use btConvexHullShape instead.
    25 class btBU_Simplex1to4 : public btPolyhedralConvexShape
     25class btBU_Simplex1to4 : public btPolyhedralConvexAabbCachingShape
    2626{
    2727protected:
     
    4444        }
    4545       
    46 
     46        virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
    4747
    4848        void addVertex(const btVector3& pt);
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btTriangleBuffer.cpp

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btTriangleBuffer.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btTriangleCallback.cpp

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btTriangleCallback.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
    66In no event will the authors be held liable for any damages arising from the use of this software.
    7 Permission is granted to anyone to use this software for any purpose,
    8 including commercial applications, and to alter it and redistribute it freely,
     7Permission is granted to anyone to use this software for any purpose, 
     8including commercial applications, and to alter it and redistribute it freely, 
    99subject to the following restrictions:
    1010
     
    4545        numverts = mesh.m_numVertices;
    4646        (*vertexbase) = (unsigned char *) mesh.m_vertexBase;
    47         #ifdef BT_USE_DOUBLE_PRECISION
    48         type = PHY_DOUBLE;
    49         #else
    50         type = PHY_FLOAT;
    51         #endif
     47
     48   type = mesh.m_vertexType;
     49
    5250        vertexStride = mesh.m_vertexStride;
    5351
     
    6563        numverts = mesh.m_numVertices;
    6664        (*vertexbase) = (const unsigned char *)mesh.m_vertexBase;
    67         #ifdef BT_USE_DOUBLE_PRECISION
    68         type = PHY_DOUBLE;
    69         #else
    70         type = PHY_FLOAT;
    71         #endif
     65
     66   type = mesh.m_vertexType;
     67   
    7268        vertexStride = mesh.m_vertexStride;
    7369
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    2828        BT_DECLARE_ALIGNED_ALLOCATOR();
    2929
    30         int                     m_numTriangles;
    31         const unsigned char *           m_triangleIndexBase;
    32         int                     m_triangleIndexStride;
    33         int                     m_numVertices;
    34         const unsigned char *           m_vertexBase;
    35         int                     m_vertexStride;
    36         // The index type is set when adding an indexed mesh to the
    37         // btTriangleIndexVertexArray, do not set it manually
    38         PHY_ScalarType          m_indexType;
    39         int                     pad;
     30   int                     m_numTriangles;
     31   const unsigned char *   m_triangleIndexBase;
     32   int                     m_triangleIndexStride;
     33   int                     m_numVertices;
     34   const unsigned char *   m_vertexBase;
     35   int                     m_vertexStride;
     36
     37   // The index type is set when adding an indexed mesh to the
     38   // btTriangleIndexVertexArray, do not set it manually
     39   PHY_ScalarType m_indexType;
     40
     41   // The vertex type has a default type similar to Bullet's precision mode (float or double)
     42   // but can be set manually if you for example run Bullet with double precision but have
     43   // mesh data in single precision..
     44   PHY_ScalarType m_vertexType;
     45
     46
     47   btIndexedMesh()
     48           :m_indexType(PHY_INTEGER),
     49#ifdef BT_USE_DOUBLE_PRECISION
     50      m_vertexType(PHY_DOUBLE)
     51#else // BT_USE_DOUBLE_PRECISION
     52      m_vertexType(PHY_FLOAT)
     53#endif // BT_USE_DOUBLE_PRECISION
     54      {
     55      }
    4056}
    4157;
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.cpp

    r5781 r8284  
    1 
    21/*
    32Bullet Continuous Collision Detection and Physics Library
    4 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    54
    65This software is provided 'as-is', without any express or implied warranty.
    76In no event will the authors be held liable for any damages arising from the use of this software.
    8 Permission is granted to anyone to use this software for any purpose,
    9 including commercial applications, and to alter it and redistribute it freely,
     7Permission is granted to anyone to use this software for any purpose, 
     8including commercial applications, and to alter it and redistribute it freely, 
    109subject to the following restrictions:
    1110
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btTriangleMesh.cpp

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    13133. This notice may not be removed or altered from any source distribution.
    1414*/
     15
    1516
    1617#include "btTriangleMesh.h"
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btTriangleMesh.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    13133. This notice may not be removed or altered from any source distribution.
    1414*/
    15 
    1615
    1716#ifndef TRIANGLE_MESH_H
     
    4241                btTriangleMesh (bool use32bitIndices=true,bool use4componentVertices=true);
    4342
    44                 int             findOrAddVertex(const btVector3& vertex, bool removeDuplicateVertices);
    45                 void    addIndex(int index);
    46 
    4743                bool    getUse32bitIndices() const
    4844                {
     
    6359                virtual void    preallocateIndices(int numindices){(void) numindices;}
    6460
     61                ///findOrAddVertex is an internal method, use addTriangle instead
     62                int             findOrAddVertex(const btVector3& vertex, bool removeDuplicateVertices);
     63                ///addIndex is an internal method, use addTriangle instead
     64                void    addIndex(int index);
    6565               
    6666};
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btTriangleMeshShape.cpp

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    9292
    9393        SupportVertexCallback(const btVector3& supportVecWorld,const btTransform& trans)
    94                 : m_supportVertexLocal(btScalar(0.),btScalar(0.),btScalar(0.)), m_worldTrans(trans) ,m_maxDot(btScalar(-1e30))
     94                : m_supportVertexLocal(btScalar(0.),btScalar(0.),btScalar(0.)), m_worldTrans(trans) ,m_maxDot(btScalar(-BT_LARGE_FLOAT))
    9595               
    9696        {
     
    200200        SupportVertexCallback supportCallback(vec,ident);
    201201
    202         btVector3 aabbMax(btScalar(1e30),btScalar(1e30),btScalar(1e30));
     202        btVector3 aabbMax(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT));
    203203       
    204204        processAllTriangles(&supportCallback,-aabbMax,aabbMax);
     
    208208        return supportVertex;
    209209}
     210
     211
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btTriangleMeshShape.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    8080        virtual const char*     getName()const {return "TRIANGLEMESH";}
    8181
     82       
    8283
    8384};
    8485
     86
     87
     88
    8589#endif //TRIANGLE_MESH_SHAPE_H
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btTriangleShape.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
     
    2020#include "btBoxShape.h"
    2121
    22 class btTriangleShape : public btPolyhedralConvexShape
     22ATTRIBUTE_ALIGNED16(class) btTriangleShape : public btPolyhedralConvexShape
    2323{
    2424
     
    3131        {
    3232                return 3;
     33        }
     34
     35        btVector3& getVertexPtr(int index)
     36        {
     37                return m_vertices1[index];
    3338        }
    3439
     
    7883        }
    7984
    80 
     85        btTriangleShape() : btPolyhedralConvexShape ()
     86    {
     87                m_shapeType = TRIANGLE_SHAPE_PROXYTYPE;
     88        }
    8189
    8290        btTriangleShape(const btVector3& p0,const btVector3& p1,const btVector3& p2) : btPolyhedralConvexShape ()
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btUniformScalingShape.cpp

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2007 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
  • code/branches/kicklib2/src/external/bullet/BulletCollision/CollisionShapes/btUniformScalingShape.h

    r5781 r8284  
    11/*
    22Bullet Continuous Collision Detection and Physics Library
    3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
     3Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
    44
    55This software is provided 'as-is', without any express or implied warranty.
Note: See TracChangeset for help on using the changeset viewer.