- Timestamp:
- Feb 27, 2011, 7:43:24 AM (14 years ago)
- Location:
- code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes
- Files:
-
- 5 added
- 69 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btBoxShape.cpp
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 13 13 3. This notice may not be removed or altered from any source distribution. 14 14 */ 15 16 15 #include "btBoxShape.h" 17 16 -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btBoxShape.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 42 42 const btVector3& getHalfExtentsWithoutMargin() const 43 43 { 44 return m_implicitShapeDimensions;// changed in Bullet 2.63: assume the scaling and margin are included44 return m_implicitShapeDimensions;//scaling is included, margin is not 45 45 } 46 46 … … 313 313 }; 314 314 315 315 316 #endif //OBB_BOX_MINKOWSKI_H 316 317 -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 18 18 #include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h" 19 19 #include "BulletCollision/CollisionShapes/btOptimizedBvh.h" 20 #include "LinearMath/btSerializer.h" 20 21 21 22 ///Bvh Concave triangle mesh is a static-triangle mesh shape with Bounding Volume Hierarchy optimization. … … 24 25 :btTriangleMeshShape(meshInterface), 25 26 m_bvh(0), 27 m_triangleInfoMap(0), 26 28 m_useQuantizedAabbCompression(useQuantizedAabbCompression), 27 29 m_ownsBvh(false) … … 31 33 #ifndef DISABLE_BVH 32 34 33 btVector3 bvhAabbMin,bvhAabbMax;34 if(meshInterface->hasPremadeAabb())35 {36 meshInterface->getPremadeAabb(&bvhAabbMin, &bvhAabbMax);37 }38 else39 {40 meshInterface->calculateAabbBruteForce(bvhAabbMin,bvhAabbMax);41 }42 43 35 if (buildBvh) 44 36 { 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(); 49 38 } 50 39 … … 56 45 :btTriangleMeshShape(meshInterface), 57 46 m_bvh(0), 47 m_triangleInfoMap(0), 58 48 m_useQuantizedAabbCompression(useQuantizedAabbCompression), 59 49 m_ownsBvh(false) … … 344 334 { 345 335 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(); 357 337 } 338 } 339 340 void 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; 358 353 } 359 354 … … 373 368 374 369 370 371 ///fills the dataBuffer and returns the struct name (and 0 on failure) 372 const 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 442 void 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 453 void 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/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 20 20 #include "btOptimizedBvh.h" 21 21 #include "LinearMath/btAlignedAllocator.h" 22 22 #include "btTriangleInfoMap.h" 23 23 24 24 ///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. … … 30 30 31 31 btOptimizedBvh* m_bvh; 32 btTriangleInfoMap* m_triangleInfoMap; 33 32 34 bool m_useQuantizedAabbCompression; 33 35 bool m_ownsBvh; … … 38 40 BT_DECLARE_ALIGNED_ALLOCATOR(); 39 41 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;}; 41 43 btBvhTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true); 42 44 … … 74 76 } 75 77 78 void setOptimizedBvh(btOptimizedBvh* bvh, const btVector3& localScaling=btVector3(1,1,1)); 76 79 77 void setOptimizedBvh(btOptimizedBvh* bvh, const btVector3& localScaling=btVector3(1,1,1));80 void buildOptimizedBvh(); 78 81 79 82 bool usesQuantizedAabbCompression() const … … 81 84 return m_useQuantizedAabbCompression; 82 85 } 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 114 struct 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 132 SIMD_FORCE_INLINE int btBvhTriangleMeshShape::calculateSerializeBufferSize() const 133 { 134 return sizeof(btTriangleMeshShapeData); 83 135 } 84 ; 136 137 85 138 86 139 #endif //BVH_TRIANGLE_MESH_SHAPE_H -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btCapsuleShape.cpp
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 33 33 btVector3 supVec(0,0,0); 34 34 35 btScalar maxDot(btScalar(- 1e30));35 btScalar maxDot(btScalar(-BT_LARGE_FLOAT)); 36 36 37 37 btVector3 vec = vec0; … … 89 89 for (int j=0;j<numVectors;j++) 90 90 { 91 btScalar maxDot(btScalar(- 1e30));91 btScalar maxDot(btScalar(-BT_LARGE_FLOAT)); 92 92 const btVector3& vec = vectors[j]; 93 93 -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btCapsuleShape.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 44 44 virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const; 45 45 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 46 58 virtual void getAabb (const btTransform& t, btVector3& aabbMin, btVector3& aabbMax) const 47 59 { … … 77 89 return m_implicitShapeDimensions[m_upAxis]; 78 90 } 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 79 109 80 110 }; … … 114 144 }; 115 145 146 ///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 147 struct btCapsuleShapeData 148 { 149 btConvexInternalShapeData m_convexInternalShapeData; 116 150 151 int m_upAxis; 152 153 char m_padding[4]; 154 }; 155 156 SIMD_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) 162 SIMD_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 } 117 172 118 173 #endif //BT_CAPSULE_SHAPE_H -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btCollisionMargin.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btCollisionShape.cpp
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 13 13 3. This notice may not be removed or altered from any source distribution. 14 14 */ 15 16 15 #include "BulletCollision/CollisionShapes/btCollisionShape.h" 17 18 19 btScalar gContactThresholdFactor=btScalar(0.02); 20 16 #include "LinearMath/btSerializer.h" 21 17 22 18 /* … … 46 42 } 47 43 48 btScalar btCollisionShape::getContactBreakingThreshold() const 44 45 btScalar btCollisionShape::getContactBreakingThreshold(btScalar defaultContactThreshold) const 49 46 { 50 return getAngularMotionDisc() * gContactThresholdFactor;47 return getAngularMotionDisc() * defaultContactThreshold; 51 48 } 49 52 50 btScalar btCollisionShape::getAngularMotionDisc() const 53 51 { … … 97 95 temporalAabbMax += angularMotion3d; 98 96 } 97 98 ///fills the dataBuffer and returns the struct name (and 0 on failure) 99 const 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 113 void 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/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btCollisionShape.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 21 21 #include "LinearMath/btMatrix3x3.h" 22 22 #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" //for the shape types 23 class btSerializer; 24 23 25 24 26 ///The btCollisionShape class provides an interface for collision shapes that can be shared among btCollisionObjects. … … 47 49 virtual btScalar getAngularMotionDisc() const; 48 50 49 virtual btScalar getContactBreakingThreshold( ) const;51 virtual btScalar getContactBreakingThreshold(btScalar defaultContactThresholdFactor) const; 50 52 51 53 … … 54 56 void calculateTemporalAabb(const btTransform& curTrans,const btVector3& linvel,const btVector3& angvel,btScalar timeStep, btVector3& temporalAabbMin,btVector3& temporalAabbMax) const; 55 57 56 #ifndef __SPU__ 58 57 59 58 60 SIMD_FORCE_INLINE bool isPolyhedral() const … … 61 63 } 62 64 65 SIMD_FORCE_INLINE bool isConvex2d() const 66 { 67 return btBroadphaseProxy::isConvex2d(getShapeType()); 68 } 69 63 70 SIMD_FORCE_INLINE bool isConvex() const 64 71 { 65 72 return btBroadphaseProxy::isConvex(getShapeType()); 73 } 74 SIMD_FORCE_INLINE bool isNonMoving() const 75 { 76 return btBroadphaseProxy::isNonMoving(getShapeType()); 66 77 } 67 78 SIMD_FORCE_INLINE bool isConcave() const … … 74 85 } 75 86 87 SIMD_FORCE_INLINE bool isSoftBody() const 88 { 89 return btBroadphaseProxy::isSoftBody(getShapeType()); 90 } 91 76 92 ///isInfinite is used to catch simulation error (aabb check) 77 93 SIMD_FORCE_INLINE bool isInfinite() const … … 80 96 } 81 97 82 98 #ifndef __SPU__ 83 99 virtual void setLocalScaling(const btVector3& scaling) =0; 84 100 virtual const btVector3& getLocalScaling() const =0; … … 107 123 } 108 124 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 109 132 }; 133 134 ///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 135 struct btCollisionShapeData 136 { 137 char *m_name; 138 int m_shapeType; 139 char m_padding[4]; 140 }; 141 142 SIMD_FORCE_INLINE int btCollisionShape::calculateSerializeBufferSize() const 143 { 144 return sizeof(btCollisionShapeData); 145 } 146 147 110 148 111 149 #endif //COLLISION_SHAPE_H -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btCompoundShape.cpp
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 17 17 #include "btCollisionShape.h" 18 18 #include "BulletCollision/BroadphaseCollision/btDbvt.h" 19 #include "LinearMath/btSerializer.h" 19 20 20 21 btCompoundShape::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)), 23 m_localAabbMax(btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT),btScalar(-BT_LARGE_FLOAT)), 24 m_dynamicAabbTree(0), 25 m_updateRevision(1), 23 26 m_collisionMargin(btScalar(0.)), 24 m_localScaling(btScalar(1.),btScalar(1.),btScalar(1.)), 25 m_dynamicAabbTree(0), 26 m_updateRevision(1) 27 m_localScaling(btScalar(1.),btScalar(1.),btScalar(1.)) 27 28 { 28 29 m_shapeType = COMPOUND_SHAPE_PROXYTYPE; … … 52 53 //m_childShapes.push_back(shape); 53 54 btCompoundShapeChild child; 55 child.m_node = 0; 54 56 child.m_transform = localTransform; 55 57 child.m_childShape = shape; … … 94 96 m_children[childIndex].m_childShape->getAabb(newChildTransform,localAabbMin,localAabbMax); 95 97 ATTRIBUTE_ALIGNED16(btDbvtVolume) bounds=btDbvtVolume::FromMM(localAabbMin,localAabbMax); 96 int index = m_children.size()-1;98 //int index = m_children.size()-1; 97 99 m_dynamicAabbTree->update(m_children[childIndex].m_node,bounds); 98 100 } … … 110 112 } 111 113 m_children.swap(childShapeIndex,m_children.size()-1); 114 if (m_dynamicAabbTree) 115 m_children[childShapeIndex].m_node->dataAsInt = childShapeIndex; 112 116 m_children.pop_back(); 113 117 … … 125 129 if(m_children[i].m_childShape == shape) 126 130 { 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); 135 132 } 136 133 } … … 146 143 // Brute force, it iterates over all the shapes left. 147 144 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)); 150 147 151 148 //extend the local aabbMin/aabbMax … … 224 221 for (k = 0; k < n; k++) 225 222 { 223 btAssert(masses[k]>0); 226 224 center += m_children[k].m_transform.getOrigin() * masses[k]; 227 225 totalMass += masses[k]; 228 226 } 227 228 btAssert(totalMass>0); 229 229 230 center /= totalMass; 230 231 principal.setOrigin(center); … … 272 273 273 274 275 void 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 293 void 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) 317 const 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/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btCompoundShape.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 63 63 int m_updateRevision; 64 64 65 btScalar m_collisionMargin; 66 67 protected: 68 btVector3 m_localScaling; 69 65 70 public: 66 71 BT_DECLARE_ALIGNED_ALLOCATOR(); … … 117 122 virtual void recalculateLocalAabb(); 118 123 119 virtual void setLocalScaling(const btVector3& scaling) 120 { 121 m_localScaling = scaling; 122 } 124 virtual void setLocalScaling(const btVector3& scaling); 125 123 126 virtual const btVector3& getLocalScaling() const 124 127 { … … 141 144 } 142 145 143 //this is optional, but should make collision queries faster, by culling non-overlapping nodes144 void createAabbTreeFromChildren();145 146 146 147 btDbvt* getDynamicAabbTree() … … 148 149 return m_dynamicAabbTree; 149 150 } 151 152 void createAabbTreeFromChildren(); 150 153 151 154 ///computes the exact moment of inertia and the transform from the coordinate system defined by the principal axes of the moment of inertia … … 161 164 } 162 165 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 175 struct 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 184 struct 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 197 SIMD_FORCE_INLINE int btCompoundShape::calculateSerializeBufferSize() const 198 { 199 return sizeof(btCompoundShapeData); 200 } 201 202 203 204 169 205 170 206 -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btConcaveShape.cpp
r5781 r7983 1 2 1 /* 3 2 Bullet Continuous Collision Detection and Physics Library 4 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 5 4 6 5 This software is provided 'as-is', without any express or implied warranty. -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btConcaveShape.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btConeShape.cpp
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btConeShape.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btConvexHullShape.cpp
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 13 13 3. This notice may not be removed or altered from any source distribution. 14 14 */ 15 15 16 #include "btConvexHullShape.h" 16 17 #include "BulletCollision/CollisionShapes/btCollisionMargin.h" 17 18 18 19 #include "LinearMath/btQuaternion.h" 19 20 21 22 btConvexHullShape ::btConvexHullShape (const btScalar* points,int numPoints,int stride) : btPolyhedralConvexShape () 20 #include "LinearMath/btSerializer.h" 21 22 btConvexHullShape ::btConvexHullShape (const btScalar* points,int numPoints,int stride) : btPolyhedralConvexAabbCachingShape () 23 23 { 24 24 m_shapeType = CONVEX_HULL_SHAPE_PROXYTYPE; 25 25 m_unscaledPoints.resize(numPoints); 26 26 27 unsigned char* points BaseAddress = (unsigned char*)points;27 unsigned char* pointsAddress = (unsigned char*)points; 28 28 29 29 for (int i=0;i<numPoints;i++) 30 30 { 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; 33 34 } 34 35 … … 52 53 } 53 54 54 btVector3 btConvexHullShape::localGetSupportingVertexWithoutMargin(const btVector3& vec 0)const55 btVector3 btConvexHullShape::localGetSupportingVertexWithoutMargin(const btVector3& vec)const 55 56 { 56 57 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); 70 59 71 60 for (int i=0;i<m_unscaledPoints.size();i++) … … 90 79 for (int i=0;i<numVectors;i++) 91 80 { 92 supportVerticesOut[i][3] = btScalar(- 1e30);81 supportVerticesOut[i][3] = btScalar(-BT_LARGE_FLOAT); 93 82 } 94 83 } … … 186 175 } 187 176 177 ///fills the dataBuffer and returns the struct name (and 0 on failure) 178 const 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/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btConvexHullShape.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 21 21 #include "LinearMath/btAlignedObjectArray.h" 22 22 23 23 24 ///The btConvexHullShape implements an implicit convex hull of an array of vertices. 24 25 ///Bullet provides a general and fast collision detector for convex shapes based on GJK and EPA using localGetSupportingVertex. 25 ATTRIBUTE_ALIGNED16(class) btConvexHullShape : public btPolyhedralConvex Shape26 ATTRIBUTE_ALIGNED16(class) btConvexHullShape : public btPolyhedralConvexAabbCachingShape 26 27 { 27 28 btAlignedObjectArray<btVector3> m_unscaledPoints; … … 89 90 virtual void setLocalScaling(const btVector3& scaling); 90 91 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 91 97 }; 98 99 ///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 100 struct 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 113 SIMD_FORCE_INLINE int btConvexHullShape::calculateSerializeBufferSize() const 114 { 115 return sizeof(btConvexHullShapeData); 116 } 92 117 93 118 -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btConvexInternalShape.cpp
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 35 35 void btConvexInternalShape::getAabbSlow(const btTransform& trans,btVector3&minAabb,btVector3&maxAabb) const 36 36 { 37 37 #ifndef __SPU__ 38 //use localGetSupportingVertexWithoutMargin? 38 39 btScalar margin = getMargin(); 39 40 for (int i=0;i<3;i++) … … 50 51 minAabb[i] = tmp[i]-margin; 51 52 } 53 #endif 52 54 } 53 55 … … 80 82 81 83 84 btConvexInternalAabbCachingShape::btConvexInternalAabbCachingShape() 85 : btConvexInternalShape(), 86 m_localAabbMin(1,1,1), 87 m_localAabbMax(-1,-1,-1), 88 m_isLocalAabbValid(false) 89 { 90 } 91 92 93 void btConvexInternalAabbCachingShape::getAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax) const 94 { 95 getNonvirtualAabb(trans,aabbMin,aabbMax,getMargin()); 96 } 97 98 void btConvexInternalAabbCachingShape::setLocalScaling(const btVector3& scaling) 99 { 100 btConvexInternalShape::setLocalScaling(scaling); 101 recalcLocalAabb(); 102 } 103 104 105 void 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/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btConvexInternalShape.h
r5781 r7983 1 /* 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 5 This software is provided 'as-is', without any express or implied warranty. 6 In 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, 9 subject to the following restrictions: 10 11 1. 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. 12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 13 3. This notice may not be removed or altered from any source distribution. 14 */ 1 15 2 16 #ifndef BT_CONVEX_INTERNAL_SHAPE_H … … 4 18 5 19 #include "btConvexShape.h" 20 #include "LinearMath/btAabbUtil2.h" 21 6 22 7 23 ///The btConvexInternalShape is an internal base class, shared by most convex shape implementations. … … 36 52 { 37 53 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; 38 63 } 39 64 … … 86 111 } 87 112 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; 88 117 89 118 90 119 }; 91 120 121 ///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 122 struct 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 138 SIMD_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) 144 SIMD_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 160 class btConvexInternalAabbCachingShape : public btConvexInternalShape 161 { 162 btVector3 m_localAabbMin; 163 btVector3 m_localAabbMax; 164 bool m_isLocalAabbValid; 165 166 protected: 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 192 public: 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 }; 92 201 93 202 #endif //BT_CONVEX_INTERNAL_SHAPE_H -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btConvexPointCloudShape.cpp
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 13 13 3. This notice may not be removed or altered from any source distribution. 14 14 */ 15 15 16 #include "btConvexPointCloudShape.h" 16 17 #include "BulletCollision/CollisionShapes/btCollisionMargin.h" … … 28 29 { 29 30 btVector3 supVec(btScalar(0.),btScalar(0.),btScalar(0.)); 30 btScalar newDot,maxDot = btScalar(- 1e30);31 btScalar newDot,maxDot = btScalar(-BT_LARGE_FLOAT); 31 32 32 33 btVector3 vec = vec0; … … 63 64 for (int i=0;i<numVectors;i++) 64 65 { 65 supportVerticesOut[i][3] = btScalar(- 1e30);66 supportVerticesOut[i][3] = btScalar(-BT_LARGE_FLOAT); 66 67 } 67 68 } -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btConvexPointCloudShape.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 22 22 23 23 ///The btConvexPointCloudShape implements an implicit convex hull of an array of vertices. 24 ATTRIBUTE_ALIGNED16(class) btConvexPointCloudShape : public btPolyhedralConvex Shape24 ATTRIBUTE_ALIGNED16(class) btConvexPointCloudShape : public btPolyhedralConvexAabbCachingShape 25 25 { 26 26 btVector3* m_unscaledPoints; … … 29 29 public: 30 30 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 } 31 39 32 40 btConvexPointCloudShape(btVector3* points,int numPoints, const btVector3& localScaling,bool computeAabb = true) … … 41 49 } 42 50 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)) 44 52 { 45 53 m_unscaledPoints = points; 46 54 m_numPoints = numPoints; 55 m_localScaling = localScaling; 47 56 48 57 if (computeAabb) -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btConvexShape.cpp
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 22 22 #include "btConvexPointCloudShape.h" 23 23 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> 27 static 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 24 36 btConvexShape::btConvexShape () 25 37 { … … 33 45 34 46 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 47 static 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; 51 97 52 98 for (int i=0;i<numPoints;i++) 53 99 { 54 btVector3 vtx = points[i] * localScaling; 55 56 newDot = vec.dot(vtx); 100 101 newDot = vec.dot(points[i]); 57 102 if (newDot > maxDot) 58 103 { 59 104 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__ 64 112 } 65 113 … … 161 209 btVector3 supVec(0,0,0); 162 210 163 btScalar maxDot(btScalar(- 1e30));211 btScalar maxDot(btScalar(-BT_LARGE_FLOAT)); 164 212 165 213 btVector3 vec = vec0; … … 293 341 return btScalar(0.0f); 294 342 } 295 343 #ifndef __SPU__ 296 344 void btConvexShape::getAabbNonVirtual (const btTransform& t, btVector3& aabbMin, btVector3& aabbMax) const 297 345 { … … 361 409 case CONVEX_HULL_SHAPE_PROXYTYPE: 362 410 { 363 btPolyhedralConvex Shape* convexHullShape = (btPolyhedralConvexShape*)this;411 btPolyhedralConvexAabbCachingShape* convexHullShape = (btPolyhedralConvexAabbCachingShape*)this; 364 412 btScalar margin = convexHullShape->getMarginNonVirtual(); 365 413 convexHullShape->getNonvirtualAabb (t, aabbMin, aabbMax, margin); … … 378 426 btAssert (0); 379 427 } 428 429 #endif //__SPU__ -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btConvexShape.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.cpp
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 13 13 3. This notice may not be removed or altered from any source distribution. 14 14 */ 15 15 16 #include "btConvexTriangleMeshShape.h" 16 17 #include "BulletCollision/CollisionShapes/btCollisionMargin.h" … … 21 22 22 23 btConvexTriangleMeshShape ::btConvexTriangleMeshShape (btStridingMeshInterface* meshInterface, bool calcAabb) 23 : btPolyhedralConvex Shape(), m_stridingMesh(meshInterface)24 : btPolyhedralConvexAabbCachingShape(), m_stridingMesh(meshInterface) 24 25 { 25 26 m_shapeType = CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE; … … 44 45 LocalSupportVertexCallback(const btVector3& supportVecLocal) 45 46 : m_supportVertexLocal(btScalar(0.),btScalar(0.),btScalar(0.)), 46 m_maxDot(btScalar(- 1e30)),47 m_maxDot(btScalar(-BT_LARGE_FLOAT)), 47 48 m_supportVecLocal(supportVecLocal) 48 49 { … … 92 93 93 94 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)); 95 96 m_stridingMesh->InternalProcessAllTriangles(&supportCallback,-aabbMax,aabbMax); 96 97 supVec = supportCallback.GetSupportVertexLocal(); … … 105 106 for (int i=0;i<numVectors;i++) 106 107 { 107 supportVerticesOut[i][3] = btScalar(- 1e30);108 supportVerticesOut[i][3] = btScalar(-BT_LARGE_FLOAT); 108 109 } 109 110 } … … 116 117 const btVector3& vec = vectors[j]; 117 118 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)); 119 120 m_stridingMesh->InternalProcessAllTriangles(&supportCallback,-aabbMax,aabbMax); 120 121 supportVerticesOut[j] = supportCallback.GetSupportVertexLocal(); … … 298 299 299 300 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)); 301 302 m_stridingMesh->InternalProcessAllTriangles(¢erCallback, -aabbMax, aabbMax); 302 303 btVector3 center = centerCallback.getCenter(); -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h
r5781 r7983 1 /* 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 5 This software is provided 'as-is', without any express or implied warranty. 6 In 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, 9 subject to the following restrictions: 10 11 1. 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. 12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 13 3. This notice may not be removed or altered from any source distribution. 14 */ 1 15 #ifndef CONVEX_TRIANGLEMESH_SHAPE_H 2 16 #define CONVEX_TRIANGLEMESH_SHAPE_H … … 9 23 /// The btConvexTriangleMeshShape is a convex hull of a triangle mesh, but the performance is not as good as btConvexHullShape. 10 24 /// 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 btPolyhedralConvex Shape25 class btConvexTriangleMeshShape : public btPolyhedralConvexAabbCachingShape 12 26 { 13 27 -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btCylinderShape.cpp
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 13 13 3. This notice may not be removed or altered from any source distribution. 14 14 */ 15 15 16 #include "btCylinderShape.h" 16 17 17 18 btCylinderShape::btCylinderShape (const btVector3& halfExtents) 18 :bt BoxShape(halfExtents),19 :btConvexInternalShape(), 19 20 m_upAxis(1) 20 21 { 22 btVector3 margin(getMargin(),getMargin(),getMargin()); 23 m_implicitShapeDimensions = (halfExtents * m_localScaling) - margin; 21 24 m_shapeType = CYLINDER_SHAPE_PROXYTYPE; 22 recalcLocalAabb();23 25 } 24 26 … … 28 30 { 29 31 m_upAxis = 0; 30 recalcLocalAabb(); 32 31 33 } 32 34 … … 36 38 { 37 39 m_upAxis = 2; 38 recalcLocalAabb(); 40 39 41 } 40 42 41 43 void btCylinderShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const 42 44 { 43 //skip the box 'getAabb' 44 btPolyhedralConvexShape::getAabb(t,aabbMin,aabbMax); 45 btTransformAabb(getHalfExtentsWithoutMargin(),getMargin(),t,aabbMin,aabbMax); 46 } 47 48 void 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 45 61 } 46 62 -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btCylinderShape.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 22 22 23 23 /// 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 bt BoxShape24 class btCylinderShape : public btConvexInternalShape 25 25 26 26 { … … 31 31 32 32 public: 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 33 47 btCylinderShape (const btVector3& halfExtents); 34 48 35 ///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version36 49 void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const; 37 50 51 virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const; 52 38 53 virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const; 39 54 40 55 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 } 41 68 42 69 virtual btVector3 localGetSupportingVertex(const btVector3& vec) const … … 74 101 } 75 102 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 76 115 //debugging 77 116 virtual const char* getName()const … … 80 119 } 81 120 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; 83 125 84 126 }; … … 113 155 virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const; 114 156 115 virtual int getUpAxis() const116 {117 return 2;118 }119 157 //debugging 120 158 virtual const char* getName()const … … 130 168 }; 131 169 170 ///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 171 struct btCylinderShapeData 172 { 173 btConvexInternalShapeData m_convexInternalShapeData; 174 175 int m_upAxis; 176 177 char m_padding[4]; 178 }; 179 180 SIMD_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) 186 SIMD_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 132 198 133 199 #endif //CYLINDER_MINKOWSKI_H -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btEmptyShape.cpp
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btEmptyShape.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btMaterial.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 8 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 33 33 34 34 #endif // MATERIAL_H 35 -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 13 13 3. This notice may not be removed or altered from any source distribution. 14 14 */ 15 15 16 16 17 #include "btMinkowskiSumShape.h" -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btMinkowskiSumShape.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btMultiSphereShape.cpp
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 14 14 */ 15 15 16 17 16 18 #include "btMultiSphereShape.h" 17 19 #include "BulletCollision/CollisionShapes/btCollisionMargin.h" 18 20 #include "LinearMath/btQuaternion.h" 21 #include "LinearMath/btSerializer.h" 19 22 20 btMultiSphereShape::btMultiSphereShape (const btVector3 & inertiaHalfExtents,const btVector3* positions,const btScalar* radi,int numSpheres)21 :btConvexInternal Shape (), m_inertiaHalfExtents(inertiaHalfExtents)23 btMultiSphereShape::btMultiSphereShape (const btVector3* positions,const btScalar* radi,int numSpheres) 24 :btConvexInternalAabbCachingShape () 22 25 { 23 26 m_shapeType = MULTI_SPHERE_SHAPE_PROXYTYPE; 24 btScalar startMargin = btScalar(1e30);27 //btScalar startMargin = btScalar(BT_LARGE_FLOAT); 25 28 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++) 28 32 { 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 33 36 } 34 setMargin(startMargin); 37 38 recalcLocalAabb(); 35 39 36 40 } 37 38 39 41 40 42 … … 44 46 btVector3 supVec(0,0,0); 45 47 46 btScalar maxDot(btScalar(- 1e30));48 btScalar maxDot(btScalar(-BT_LARGE_FLOAT)); 47 49 48 50 … … 61 63 btScalar newDot; 62 64 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(); 65 68 66 for (i=0;i< m_numSpheres;i++)69 for (i=0;i<numSpheres;i++) 67 70 { 68 71 vtx = (*pos) +vec*m_localScaling*(*rad) - vec * getMargin(); … … 86 89 for (int j=0;j<numVectors;j++) 87 90 { 88 btScalar maxDot(btScalar(- 1e30));91 btScalar maxDot(btScalar(-BT_LARGE_FLOAT)); 89 92 90 93 const btVector3& vec = vectors[j]; … … 93 96 btScalar newDot; 94 97 95 const btVector3* pos = &m_localPosition s[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++) 99 102 { 100 103 vtx = (*pos) +vec*m_localScaling*(*rad) - vec * getMargin(); … … 122 125 //as an approximation, take the inertia of the box that bounds the spheres 123 126 124 bt Transform ident;125 ident.setIdentity();126 // btVector3 aabbMin,aabbMax;127 btVector3 localAabbMin,localAabbMax; 128 getCachedLocalAabb(localAabbMin,localAabbMax); 129 btVector3 halfExtents = (localAabbMax-localAabbMin)*btScalar(0.5); 127 130 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()); 129 134 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)); 145 138 146 139 } 147 140 148 141 142 ///fills the dataBuffer and returns the struct name (and 0 on failure) 143 const char* btMultiSphereShape::serialize(void* dataBuffer, btSerializer* serializer) const 144 { 145 btMultiSphereShapeData* shapeData = (btMultiSphereShapeData*) dataBuffer; 146 btConvexInternalShape::serialize(&shapeData->m_convexInternalShapeData, serializer); 149 147 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/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btMultiSphereShape.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 19 19 #include "btConvexInternalShape.h" 20 20 #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" 36 23 37 24 38 25 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 28 class btMultiSphereShape : public btConvexInternalAabbCachingShape 29 { 30 31 btAlignedObjectArray<btVector3> m_localPositionArray; 32 btAlignedObjectArray<btScalar> m_radiArray; 33 39 34 public: 40 btMultiSphereShape (const btVector3 & inertiaHalfExtents,const btVector3* positions,const btScalar* radi,int numSpheres);35 btMultiSphereShape (const btVector3* positions,const btScalar* radi,int numSpheres); 41 36 42 37 ///CollisionShape Interface … … 50 45 int getSphereCount() const 51 46 { 52 return m_ numSpheres;47 return m_localPositionArray.size(); 53 48 } 54 49 55 50 const btVector3& getSpherePosition(int index) const 56 51 { 57 return m_localPosition s[index];52 return m_localPositionArray[index]; 58 53 } 59 54 60 55 btScalar getSphereRadius(int index) const 61 56 { 62 return m_radi [index];57 return m_radiArray[index]; 63 58 } 64 59 … … 69 64 } 70 65 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 71 72 }; 72 73 73 74 75 struct btPositionAndRadius 76 { 77 btVector3FloatData m_pos; 78 float m_radius; 79 }; 80 81 struct btMultiSphereShapeData 82 { 83 btConvexInternalShapeData m_convexInternalShapeData; 84 85 btPositionAndRadius *m_localPositionArrayPtr; 86 int m_localPositionArraySize; 87 char m_padding[4]; 88 }; 89 90 91 92 SIMD_FORCE_INLINE int btMultiSphereShape::calculateSerializeBufferSize() const 93 { 94 return sizeof(btMultiSphereShapeData); 95 } 96 97 98 74 99 #endif //MULTI_SPHERE_MINKOWSKI_H -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.cpp
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 8 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 8 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 38 38 m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE; 39 39 40 btVector3 m_triangle[3];41 40 const unsigned char *vertexbase; 42 41 int numverts; … … 72 71 m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE; 73 72 74 btVector3 m_triangle[3];75 73 const unsigned char *vertexbase; 76 74 int numverts; -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btOptimizedBvh.cpp
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 14 14 */ 15 15 16 16 17 #include "btOptimizedBvh.h" 17 18 #include "btStridingMeshInterface.h" … … 56 57 btOptimizedBvhNode node; 57 58 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)); 60 61 aabbMin.setMin(triangle[0]); 61 62 aabbMax.setMax(triangle[0]); … … 104 105 btQuantizedBvhNode node; 105 106 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)); 108 109 aabbMin.setMin(triangle[0]); 109 110 aabbMax.setMax(triangle[0]); … … 168 169 NodeTriangleCallback callback(m_leafNodes); 169 170 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)); 172 173 173 174 triangles->InternalProcessAllTriangles(&callback,aabbMin,aabbMax); … … 337 338 338 339 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)); 341 342 aabbMin.setMin(triangleVerts[0]); 342 343 aabbMax.setMax(triangleVerts[0]); -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btOptimizedBvh.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 13 13 3. This notice may not be removed or altered from any source distribution. 14 14 */ 15 16 ///Contains contributions from Disney Studio's 15 17 16 18 #ifndef OPTIMIZED_BVH_H … … 46 48 47 49 /// 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 49 51 { 50 52 return btQuantizedBvh::serialize(o_alignedDataBuffer,i_dataBufferSize,i_swapEndian); -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 16 16 #include "BulletCollision/CollisionShapes/btPolyhedralConvexShape.h" 17 17 18 btPolyhedralConvexShape::btPolyhedralConvexShape() :btConvexInternalShape(), 19 m_localAabbMin(1,1,1), 20 m_localAabbMax(-1,-1,-1), 21 m_isLocalAabbValid(false), 22 m_optionalHull(0) 18 btPolyhedralConvexShape::btPolyhedralConvexShape() :btConvexInternalShape() 23 19 { 24 20 … … 28 24 btVector3 btPolyhedralConvexShape::localGetSupportingVertexWithoutMargin(const btVector3& vec0)const 29 25 { 26 27 28 btVector3 supVec(0,0,0); 29 #ifndef __SPU__ 30 30 int i; 31 btVector3 supVec(0,0,0); 32 33 btScalar maxDot(btScalar(-1e30)); 31 btScalar maxDot(btScalar(-BT_LARGE_FLOAT)); 34 32 35 33 btVector3 vec = vec0; … … 58 56 } 59 57 58 59 #endif //__SPU__ 60 60 return supVec; 61 } 61 62 62 } 63 63 64 64 65 void btPolyhedralConvexShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const 65 66 { 67 #ifndef __SPU__ 66 68 int i; 67 69 … … 71 73 for (i=0;i<numVectors;i++) 72 74 { 73 supportVerticesOut[i][3] = btScalar(- 1e30);75 supportVerticesOut[i][3] = btScalar(-BT_LARGE_FLOAT); 74 76 } 75 77 … … 91 93 } 92 94 } 95 #endif //__SPU__ 93 96 } 94 97 … … 97 100 void btPolyhedralConvexShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const 98 101 { 102 #ifndef __SPU__ 99 103 //not yet, return box inertia 100 104 … … 116 120 117 121 inertia = scaledmass * (btVector3(y2+z2,x2+z2,x2+y2)); 118 122 #endif //__SPU__ 119 123 } 120 124 121 125 122 126 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) 127 void btPolyhedralConvexAabbCachingShape::setLocalScaling(const btVector3& scaling) 131 128 { 132 129 btConvexInternalShape::setLocalScaling(scaling); … … 134 131 } 135 132 136 void btPolyhedralConvexShape::recalcLocalAabb() 133 btPolyhedralConvexAabbCachingShape::btPolyhedralConvexAabbCachingShape() 134 :btPolyhedralConvexShape(), 135 m_localAabbMin(1,1,1), 136 m_localAabbMax(-1,-1,-1), 137 m_isLocalAabbValid(false) 138 { 139 } 140 141 void btPolyhedralConvexAabbCachingShape::getAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax) const 142 { 143 getNonvirtualAabb(trans,aabbMin,aabbMax,getMargin()); 144 } 145 146 void btPolyhedralConvexAabbCachingShape::recalcLocalAabb() 137 147 { 138 148 m_isLocalAabbValid = true; … … 182 192 } 183 193 184 185 -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btPolyhedralConvexShape.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 18 18 19 19 #include "LinearMath/btMatrix3x3.h" 20 #include "LinearMath/btAabbUtil2.h"21 20 #include "btConvexInternalShape.h" 22 21 … … 27 26 28 27 protected: 29 btVector3 m_localAabbMin; 30 btVector3 m_localAabbMax; 31 bool m_isLocalAabbValid; 32 28 33 29 public: 34 30 … … 39 35 virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const; 40 36 virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const; 41 42 37 43 38 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 ; 44 48 49 virtual bool isInside(const btVector3& pt,btScalar tolerance) const = 0; 50 51 }; 52 53 54 ///The btPolyhedralConvexAabbCachingShape adds aabb caching to the btPolyhedralConvexShape 55 class btPolyhedralConvexAabbCachingShape : public btPolyhedralConvexShape 56 { 57 58 btVector3 m_localAabbMin; 59 btVector3 m_localAabbMax; 60 bool m_isLocalAabbValid; 61 62 protected: 45 63 46 64 void setCachedLocalAabb (const btVector3& aabbMin, const btVector3& aabbMax) … … 58 76 } 59 77 78 public: 79 80 btPolyhedralConvexAabbCachingShape(); 81 60 82 inline void getNonvirtualAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax, btScalar margin) const 61 83 { … … 66 88 } 67 89 68 90 virtual void setLocalScaling(const btVector3& scaling); 91 69 92 virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const; 70 93 71 virtual void setLocalScaling(const btVector3& scaling);72 73 94 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.cpp86 class Hull* m_optionalHull;87 95 88 96 }; -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 8 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 13 13 3. This notice may not be removed or altered from any source distribution. 14 14 */ 15 15 16 16 17 #include "btScaledBvhTriangleMeshShape.h" -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 8 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btShapeHull.cpp
r5781 r7983 1 1 /* 2 btbtShapeHull implemented by John McCutchan.3 4 2 Bullet Continuous Collision Detection and Physics Library 5 Copyright (c) 2003-200 8 Erwin Coumans http://bulletphysics.com3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 6 4 7 5 This software is provided 'as-is', without any express or implied warranty. 8 6 In 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, 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, 11 9 subject to the following restrictions: 12 10 … … 16 14 */ 17 15 16 //btShapeHull was implemented by John McCutchan. 17 18 18 19 #include "btShapeHull.h" 19 20 #include "LinearMath/btConvexHull.h" 20 21 21 22 #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 };68 23 69 24 btShapeHull::btShapeHull (const btConvexShape* shape) … … 93 48 btVector3 norm; 94 49 m_shape->getPreferredPenetrationDirection(i,norm); 95 btUnitSpherePoints[numSampleDirections] = norm;50 getUnitSpherePoints()[numSampleDirections] = norm; 96 51 numSampleDirections++; 97 52 } … … 103 58 for (i = 0; i < numSampleDirections; i++) 104 59 { 105 supportPoints[i] = m_shape->localGetSupportingVertex( btUnitSpherePoints[i]);60 supportPoints[i] = m_shape->localGetSupportingVertex(getUnitSpherePoints()[i]); 106 61 } 107 62 … … 163 118 } 164 119 120 121 btVector3* 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/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btShapeHull.h
r5781 r7983 1 1 /* 2 btShapeHull implemented by John McCutchan.3 4 2 Bullet Continuous Collision Detection and Physics Library 5 Copyright (c) 2003-200 8 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 6 4 7 5 This software is provided 'as-is', without any express or implied warranty. 8 6 In 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, 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, 11 9 subject to the following restrictions: 12 10 … … 15 13 3. This notice may not be removed or altered from any source distribution. 16 14 */ 15 16 ///btShapeHull implemented by John McCutchan. 17 17 18 18 #ifndef _SHAPE_HULL_H … … 28 28 class btShapeHull 29 29 { 30 protected: 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 30 39 public: 31 40 btShapeHull (const btConvexShape* shape); … … 46 55 return &m_indices[0]; 47 56 } 48 49 protected:50 btAlignedObjectArray<btVector3> m_vertices;51 btAlignedObjectArray<unsigned int> m_indices;52 unsigned int m_numIndices;53 const btConvexShape* m_shape;54 57 }; 55 58 -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btSphereShape.cpp
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btSphereShape.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 13 13 3. This notice may not be removed or altered from any source distribution. 14 14 */ 15 16 15 #ifndef SPHERE_MINKOWSKI_H 17 16 #define SPHERE_MINKOWSKI_H -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btStaticPlaneShape.cpp
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 39 39 (void)t; 40 40 /* 41 btVector3 infvec (btScalar( 1e30),btScalar(1e30),btScalar(1e30));41 btVector3 infvec (btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT)); 42 42 43 43 btVector3 center = m_planeNormal*m_planeConstant; … … 48 48 */ 49 49 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)); 52 52 53 53 } -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btStaticPlaneShape.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 21 21 22 22 ///The btStaticPlaneShape simulates an infinite non-moving (static) collision plane. 23 classbtStaticPlaneShape : public btConcaveShape23 ATTRIBUTE_ALIGNED16(class) btStaticPlaneShape : public btConcaveShape 24 24 { 25 25 protected: … … 59 59 virtual const char* getName()const {return "STATICPLANE";} 60 60 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 61 66 62 67 }; 63 68 69 ///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 70 struct 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 81 SIMD_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) 87 SIMD_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 64 100 #endif //STATIC_PLANE_SHAPE_H 101 102 103 -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btStridingMeshInterface.cpp
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 15 15 16 16 #include "btStridingMeshInterface.h" 17 #include "LinearMath/btSerializer.h" 17 18 18 19 btStridingMeshInterface::~btStridingMeshInterface() … … 36 37 int gfxindex; 37 38 btVector3 triangle[3]; 38 btScalar* graphicsbase;39 39 40 40 btVector3 meshScaling = getScaling(); … … 46 46 numtotalphysicsverts+=numtriangles*3; //upper bound 47 47 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) 49 53 { 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: 51 98 { 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)); 77 135 } 78 136 break; 79 137 } 80 138 default: 81 btAssert(( gfxindextype == PHY_INTEGER) || (gfxindextype == PHY_SHORT));139 btAssert((type == PHY_FLOAT) || (type == PHY_DOUBLE)); 82 140 } 83 141 … … 96 154 AabbCalculationCallback() 97 155 { 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)); 100 158 } 101 159 … … 114 172 }; 115 173 116 174 //first calculate the total aabb for all triangles 117 175 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)); 120 178 InternalProcessAllTriangles(&aabbCallback,aabbMin,aabbMax); 121 179 … … 123 181 aabbMax = aabbCallback.m_aabbMax; 124 182 } 183 184 185 186 ///fills the dataBuffer and returns the struct name (and 0 on failure) 187 const 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/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btStridingMeshInterface.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 20 20 #include "btTriangleCallback.h" 21 21 #include "btConcaveShape.h" 22 23 22 24 23 25 … … 90 92 } 91 93 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 93 99 94 100 }; 95 101 102 struct btIntIndexData 103 { 104 int m_value; 105 }; 106 107 struct btShortIntIndexData 108 { 109 short m_value; 110 char m_pad[2]; 111 }; 112 113 struct 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 120 struct 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 136 struct btStridingMeshInterfaceData 137 { 138 btMeshPartData *m_meshPartsPtr; 139 btVector3FloatData m_scaling; 140 int m_numMeshParts; 141 char m_padding[4]; 142 }; 143 144 145 146 147 SIMD_FORCE_INLINE int btStridingMeshInterface::calculateSerializeBufferSize() const 148 { 149 return sizeof(btStridingMeshInterfaceData); 150 } 151 152 153 96 154 #endif //STRIDING_MESHINTERFACE_H -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btTetrahedronShape.cpp
r5781 r7983 1 2 1 /* 3 2 Bullet Continuous Collision Detection and Physics Library 4 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 5 4 6 5 This software is provided 'as-is', without any express or implied warranty. … … 14 13 3. This notice may not be removed or altered from any source distribution. 15 14 */ 15 16 16 #include "btTetrahedronShape.h" 17 17 #include "LinearMath/btMatrix3x3.h" 18 18 19 btBU_Simplex1to4::btBU_Simplex1to4() : btPolyhedralConvex Shape (),20 m_numVertices(0) 21 { 22 m_shapeType = TETRAHEDRAL_SHAPE_PROXYTYPE; 23 } 24 25 btBU_Simplex1to4::btBU_Simplex1to4(const btVector3& pt0) : btPolyhedralConvex Shape (),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) : btPolyhedralConvex Shape (),19 btBU_Simplex1to4::btBU_Simplex1to4() : btPolyhedralConvexAabbCachingShape (), 20 m_numVertices(0) 21 { 22 m_shapeType = TETRAHEDRAL_SHAPE_PROXYTYPE; 23 } 24 25 btBU_Simplex1to4::btBU_Simplex1to4(const btVector3& pt0) : btPolyhedralConvexAabbCachingShape (), 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) : btPolyhedralConvexAabbCachingShape (), 33 33 m_numVertices(0) 34 34 { … … 38 38 } 39 39 40 btBU_Simplex1to4::btBU_Simplex1to4(const btVector3& pt0,const btVector3& pt1,const btVector3& pt2) : btPolyhedralConvex Shape (),40 btBU_Simplex1to4::btBU_Simplex1to4(const btVector3& pt0,const btVector3& pt1,const btVector3& pt2) : btPolyhedralConvexAabbCachingShape (), 41 41 m_numVertices(0) 42 42 { … … 47 47 } 48 48 49 btBU_Simplex1to4::btBU_Simplex1to4(const btVector3& pt0,const btVector3& pt1,const btVector3& pt2,const btVector3& pt3) : btPolyhedralConvex Shape (),49 btBU_Simplex1to4::btBU_Simplex1to4(const btVector3& pt0,const btVector3& pt1,const btVector3& pt2,const btVector3& pt3) : btPolyhedralConvexAabbCachingShape (), 50 50 m_numVertices(0) 51 51 { … … 58 58 59 59 60 void 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 60 79 61 80 … … 64 83 { 65 84 m_vertices[m_numVertices++] = pt; 66 67 85 recalcLocalAabb(); 68 86 } -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btTetrahedronShape.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 23 23 24 24 ///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 btPolyhedralConvex Shape25 class btBU_Simplex1to4 : public btPolyhedralConvexAabbCachingShape 26 26 { 27 27 protected: … … 44 44 } 45 45 46 46 virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const; 47 47 48 48 void addVertex(const btVector3& pt); -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btTriangleBuffer.cpp
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btTriangleBuffer.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btTriangleCallback.cpp
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btTriangleCallback.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. 6 6 In 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, 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, 9 9 subject to the following restrictions: 10 10 … … 45 45 numverts = mesh.m_numVertices; 46 46 (*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 52 50 vertexStride = mesh.m_vertexStride; 53 51 … … 65 63 numverts = mesh.m_numVertices; 66 64 (*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 72 68 vertexStride = mesh.m_vertexStride; 73 69 -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 28 28 BT_DECLARE_ALIGNED_ALLOCATOR(); 29 29 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 } 40 56 } 41 57 ; -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.cpp
r5781 r7983 1 2 1 /* 3 2 Bullet Continuous Collision Detection and Physics Library 4 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 5 4 6 5 This software is provided 'as-is', without any express or implied warranty. 7 6 In 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, 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, 10 9 subject to the following restrictions: 11 10 -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btTriangleMesh.cpp
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 13 13 3. This notice may not be removed or altered from any source distribution. 14 14 */ 15 15 16 16 17 #include "btTriangleMesh.h" -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btTriangleMesh.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 13 13 3. This notice may not be removed or altered from any source distribution. 14 14 */ 15 16 15 17 16 #ifndef TRIANGLE_MESH_H … … 42 41 btTriangleMesh (bool use32bitIndices=true,bool use4componentVertices=true); 43 42 44 int findOrAddVertex(const btVector3& vertex, bool removeDuplicateVertices);45 void addIndex(int index);46 47 43 bool getUse32bitIndices() const 48 44 { … … 63 59 virtual void preallocateIndices(int numindices){(void) numindices;} 64 60 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); 65 65 66 66 }; -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btTriangleMeshShape.cpp
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 92 92 93 93 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)) 95 95 96 96 { … … 200 200 SupportVertexCallback supportCallback(vec,ident); 201 201 202 btVector3 aabbMax(btScalar( 1e30),btScalar(1e30),btScalar(1e30));202 btVector3 aabbMax(btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT),btScalar(BT_LARGE_FLOAT)); 203 203 204 204 processAllTriangles(&supportCallback,-aabbMax,aabbMax); … … 208 208 return supportVertex; 209 209 } 210 211 -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btTriangleMeshShape.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 80 80 virtual const char* getName()const {return "TRIANGLEMESH";} 81 81 82 82 83 83 84 }; 84 85 86 87 88 85 89 #endif //TRIANGLE_MESH_SHAPE_H -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btTriangleShape.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. … … 20 20 #include "btBoxShape.h" 21 21 22 classbtTriangleShape : public btPolyhedralConvexShape22 ATTRIBUTE_ALIGNED16(class) btTriangleShape : public btPolyhedralConvexShape 23 23 { 24 24 … … 31 31 { 32 32 return 3; 33 } 34 35 btVector3& getVertexPtr(int index) 36 { 37 return m_vertices1[index]; 33 38 } 34 39 … … 78 83 } 79 84 80 85 btTriangleShape() : btPolyhedralConvexShape () 86 { 87 m_shapeType = TRIANGLE_SHAPE_PROXYTYPE; 88 } 81 89 82 90 btTriangleShape(const btVector3& p0,const btVector3& p1,const btVector3& p2) : btPolyhedralConvexShape () -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btUniformScalingShape.cpp
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 7 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty. -
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btUniformScalingShape.h
r5781 r7983 1 1 /* 2 2 Bullet Continuous Collision Detection and Physics Library 3 Copyright (c) 2003-200 6 Erwin Coumans http://continuousphysics.com/Bullet/3 Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org 4 4 5 5 This software is provided 'as-is', without any express or implied warranty.
Note: See TracChangeset
for help on using the changeset viewer.