- Timestamp:
- May 3, 2011, 5:07:42 AM (14 years ago)
- Location:
- code/trunk/src/external/bullet/BulletCollision/CollisionShapes
- Files:
-
- 2 added
- 40 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btBox2dShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef OBB_BOX_2D_SHAPE_H17 #define OBB_BOX_2D_SHAPE_H16 #ifndef BT_OBB_BOX_2D_SHAPE_H 17 #define BT_OBB_BOX_2D_SHAPE_H 18 18 19 19 #include "BulletCollision/CollisionShapes/btPolyhedralConvexShape.h" … … 359 359 }; 360 360 361 #endif // OBB_BOX_2D_SHAPE_H362 363 361 #endif //BT_OBB_BOX_2D_SHAPE_H 362 363 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btBoxShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef OBB_BOX_MINKOWSKI_H17 #define OBB_BOX_MINKOWSKI_H16 #ifndef BT_OBB_BOX_MINKOWSKI_H 17 #define BT_OBB_BOX_MINKOWSKI_H 18 18 19 19 #include "btPolyhedralConvexShape.h" … … 146 146 virtual void getVertex(int i,btVector3& vtx) const 147 147 { 148 btVector3 halfExtents = getHalfExtentsWith outMargin();148 btVector3 halfExtents = getHalfExtentsWithMargin(); 149 149 150 150 vtx = btVector3( … … 314 314 315 315 316 #endif // OBB_BOX_MINKOWSKI_H317 318 316 #endif //BT_OBB_BOX_MINKOWSKI_H 317 318 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.cpp
r8351 r8393 278 278 279 279 unsigned int* gfxbase = (unsigned int*)(indexbase+nodeTriangleIndex*indexstride); 280 btAssert(indicestype==PHY_INTEGER||indicestype==PHY_SHORT );280 btAssert(indicestype==PHY_INTEGER||indicestype==PHY_SHORT||indicestype==PHY_UCHAR); 281 281 282 282 const btVector3& meshScaling = m_meshInterface->getScaling(); … … 284 284 { 285 285 286 int graphicsindex = indicestype==PHY_SHORT?((unsigned short*)gfxbase)[j]: gfxbase[j];286 int graphicsindex = indicestype==PHY_SHORT?((unsigned short*)gfxbase)[j]:indicestype==PHY_INTEGER?gfxbase[j]:((unsigned char*)gfxbase)[j]; 287 287 288 288 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef B VH_TRIANGLE_MESH_SHAPE_H17 #define B VH_TRIANGLE_MESH_SHAPE_H16 #ifndef BT_BVH_TRIANGLE_MESH_SHAPE_H 17 #define BT_BVH_TRIANGLE_MESH_SHAPE_H 18 18 19 19 #include "btTriangleMeshShape.h" … … 40 40 BT_DECLARE_ALIGNED_ALLOCATOR(); 41 41 42 btBvhTriangleMeshShape() : btTriangleMeshShape(0),m_bvh(0),m_triangleInfoMap(0),m_ownsBvh(false) {m_shapeType = TRIANGLE_MESH_SHAPE_PROXYTYPE;};42 43 43 btBvhTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true); 44 44 … … 137 137 138 138 139 #endif //B VH_TRIANGLE_MESH_SHAPE_H139 #endif //BT_BVH_TRIANGLE_MESH_SHAPE_H -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btCollisionMargin.h
r8351 r8393 14 14 */ 15 15 16 #ifndef COLLISION_MARGIN_H17 #define COLLISION_MARGIN_H16 #ifndef BT_COLLISION_MARGIN_H 17 #define BT_COLLISION_MARGIN_H 18 18 19 19 //used by Gjk and some other algorithms … … 23 23 24 24 25 #endif // COLLISION_MARGIN_H25 #endif //BT_COLLISION_MARGIN_H 26 26 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btCollisionShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef COLLISION_SHAPE_H17 #define COLLISION_SHAPE_H16 #ifndef BT_COLLISION_SHAPE_H 17 #define BT_COLLISION_SHAPE_H 18 18 19 19 #include "LinearMath/btTransform.h" … … 147 147 148 148 149 #endif // COLLISION_SHAPE_H149 #endif //BT_COLLISION_SHAPE_H 150 150 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btCompoundShape.cpp
r8351 r8393 86 86 } 87 87 88 void btCompoundShape::updateChildTransform(int childIndex, const btTransform& newChildTransform )88 void btCompoundShape::updateChildTransform(int childIndex, const btTransform& newChildTransform,bool shouldRecalculateLocalAabb) 89 89 { 90 90 m_children[childIndex].m_transform = newChildTransform; … … 100 100 } 101 101 102 recalculateLocalAabb(); 102 if (shouldRecalculateLocalAabb) 103 { 104 recalculateLocalAabb(); 105 } 103 106 } 104 107 … … 284 287 m_children[i].m_childShape->setLocalScaling(childScale); 285 288 childTrans.setOrigin((childTrans.getOrigin())*scaling); 286 updateChildTransform(i, childTrans );287 recalculateLocalAabb();288 }289 updateChildTransform(i, childTrans,false); 290 } 291 289 292 m_localScaling = scaling; 293 recalculateLocalAabb(); 294 290 295 } 291 296 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btCompoundShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef COMPOUND_SHAPE_H17 #define COMPOUND_SHAPE_H16 #ifndef BT_COMPOUND_SHAPE_H 17 #define BT_COMPOUND_SHAPE_H 18 18 19 19 #include "btCollisionShape.h" … … 107 107 108 108 ///set a new transform for a child, and update internal data structures (local aabb and dynamic tree) 109 void updateChildTransform(int childIndex, const btTransform& newChildTransform );109 void updateChildTransform(int childIndex, const btTransform& newChildTransform, bool shouldRecalculateLocalAabb = true); 110 110 111 111 … … 144 144 } 145 145 146 147 btDbvt* getDynamicAabbTree() 146 const btDbvt* getDynamicAabbTree() const 147 { 148 return m_dynamicAabbTree; 149 } 150 151 btDbvt* getDynamicAabbTree() 148 152 { 149 153 return m_dynamicAabbTree; … … 206 210 207 211 208 #endif // COMPOUND_SHAPE_H212 #endif //BT_COMPOUND_SHAPE_H -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btConcaveShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef CONCAVE_SHAPE_H17 #define CONCAVE_SHAPE_H16 #ifndef BT_CONCAVE_SHAPE_H 17 #define BT_CONCAVE_SHAPE_H 18 18 19 19 #include "btCollisionShape.h" … … 58 58 }; 59 59 60 #endif // CONCAVE_SHAPE_H60 #endif //BT_CONCAVE_SHAPE_H -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btConeShape.cpp
r8351 r8393 132 132 133 133 134 void btConeShape::setLocalScaling(const btVector3& scaling) 135 { 136 int axis = m_coneIndices[1]; 137 int r1 = m_coneIndices[0]; 138 int r2 = m_coneIndices[2]; 139 m_height *= scaling[axis] / m_localScaling[axis]; 140 m_radius *= (scaling[r1] / m_localScaling[r1] + scaling[r2] / m_localScaling[r2]) / 2; 141 m_sinAngle = (m_radius / btSqrt(m_radius * m_radius + m_height * m_height)); 142 btConvexInternalShape::setLocalScaling(scaling); 143 } -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btConeShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef CONE_MINKOWSKI_H17 #define CONE_MINKOWSKI_H16 #ifndef BT_CONE_MINKOWSKI_H 17 #define BT_CONE_MINKOWSKI_H 18 18 19 19 #include "btConvexInternalShape.h" … … 82 82 return m_coneIndices[1]; 83 83 } 84 85 virtual void setLocalScaling(const btVector3& scaling); 86 84 87 }; 85 88 … … 97 100 btConeShapeZ(btScalar radius,btScalar height); 98 101 }; 99 #endif // CONE_MINKOWSKI_H102 #endif //BT_CONE_MINKOWSKI_H 100 103 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btConvex2dShape.h
r8351 r8393 20 20 #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types 21 21 22 ///The btConvex2dShape allows to use arbitrary convex shapes a re2d convex shapes, with the Z component assumed to be 0.22 ///The btConvex2dShape allows to use arbitrary convex shapes as 2d convex shapes, with the Z component assumed to be 0. 23 23 ///For 2d boxes, the btBox2dShape is recommended. 24 24 class btConvex2dShape : public btConvexShape -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btConvexHullShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef CONVEX_HULL_SHAPE_H17 #define CONVEX_HULL_SHAPE_H16 #ifndef BT_CONVEX_HULL_SHAPE_H 17 #define BT_CONVEX_HULL_SHAPE_H 18 18 19 19 #include "btPolyhedralConvexShape.h" … … 117 117 118 118 119 #endif // CONVEX_HULL_SHAPE_H119 #endif //BT_CONVEX_HULL_SHAPE_H 120 120 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btConvexShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef CONVEX_SHAPE_INTERFACE117 #define CONVEX_SHAPE_INTERFACE116 #ifndef BT_CONVEX_SHAPE_INTERFACE1 17 #define BT_CONVEX_SHAPE_INTERFACE1 18 18 19 19 #include "btCollisionShape.h" … … 80 80 81 81 82 #endif // CONVEX_SHAPE_INTERFACE182 #endif //BT_CONVEX_SHAPE_INTERFACE1 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h
r8351 r8393 13 13 3. This notice may not be removed or altered from any source distribution. 14 14 */ 15 #ifndef CONVEX_TRIANGLEMESH_SHAPE_H16 #define CONVEX_TRIANGLEMESH_SHAPE_H15 #ifndef BT_CONVEX_TRIANGLEMESH_SHAPE_H 16 #define BT_CONVEX_TRIANGLEMESH_SHAPE_H 17 17 18 18 … … 70 70 71 71 72 #endif // CONVEX_TRIANGLEMESH_SHAPE_H72 #endif //BT_CONVEX_TRIANGLEMESH_SHAPE_H 73 73 74 74 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btCylinderShape.cpp
r8351 r8393 48 48 void btCylinderShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const 49 49 { 50 //approximation of box shape, todo: implement cylinder shape inertia before people notice ;-) 50 51 //Until Bullet 2.77 a box approximation was used, so uncomment this if you need backwards compatibility 52 //#define USE_BOX_INERTIA_APPROXIMATION 1 53 #ifndef USE_BOX_INERTIA_APPROXIMATION 54 55 /* 56 cylinder is defined as following: 57 * 58 * - principle axis aligned along y by default, radius in x, z-value not used 59 * - for btCylinderShapeX: principle axis aligned along x, radius in y direction, z-value not used 60 * - for btCylinderShapeZ: principle axis aligned along z, radius in x direction, y-value not used 61 * 62 */ 63 64 btScalar radius2; // square of cylinder radius 65 btScalar height2; // square of cylinder height 66 btVector3 halfExtents = getHalfExtentsWithMargin(); // get cylinder dimension 67 btScalar div12 = mass / 12.f; 68 btScalar div4 = mass / 4.f; 69 btScalar div2 = mass / 2.f; 70 int idxRadius, idxHeight; 71 72 switch (m_upAxis) // get indices of radius and height of cylinder 73 { 74 case 0: // cylinder is aligned along x 75 idxRadius = 1; 76 idxHeight = 0; 77 break; 78 case 2: // cylinder is aligned along z 79 idxRadius = 0; 80 idxHeight = 2; 81 break; 82 default: // cylinder is aligned along y 83 idxRadius = 0; 84 idxHeight = 1; 85 } 86 87 // calculate squares 88 radius2 = halfExtents[idxRadius] * halfExtents[idxRadius]; 89 height2 = btScalar(4.) * halfExtents[idxHeight] * halfExtents[idxHeight]; 90 91 // calculate tensor terms 92 btScalar t1 = div12 * height2 + div4 * radius2; 93 btScalar t2 = div2 * radius2; 94 95 switch (m_upAxis) // set diagonal elements of inertia tensor 96 { 97 case 0: // cylinder is aligned along x 98 inertia.setValue(t2,t1,t1); 99 break; 100 case 2: // cylinder is aligned along z 101 inertia.setValue(t1,t1,t2); 102 break; 103 default: // cylinder is aligned along y 104 inertia.setValue(t1,t2,t1); 105 } 106 #else //USE_BOX_INERTIA_APPROXIMATION 107 //approximation of box shape 51 108 btVector3 halfExtents = getHalfExtentsWithMargin(); 52 109 … … 58 115 mass/(btScalar(12.0)) * (lx*lx + lz*lz), 59 116 mass/(btScalar(12.0)) * (lx*lx + ly*ly)); 60 117 #endif //USE_BOX_INERTIA_APPROXIMATION 61 118 } 62 119 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btCylinderShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef CYLINDER_MINKOWSKI_H17 #define CYLINDER_MINKOWSKI_H16 #ifndef BT_CYLINDER_MINKOWSKI_H 17 #define BT_CYLINDER_MINKOWSKI_H 18 18 19 19 #include "btBoxShape.h" … … 197 197 198 198 199 #endif // CYLINDER_MINKOWSKI_H200 199 #endif //BT_CYLINDER_MINKOWSKI_H 200 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btEmptyShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef EMPTY_SHAPE_H17 #define EMPTY_SHAPE_H16 #ifndef BT_EMPTY_SHAPE_H 17 #define BT_EMPTY_SHAPE_H 18 18 19 19 #include "btConcaveShape.h" … … 68 68 69 69 70 #endif // EMPTY_SHAPE_H70 #endif //BT_EMPTY_SHAPE_H -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef HEIGHTFIELD_TERRAIN_SHAPE_H17 #define HEIGHTFIELD_TERRAIN_SHAPE_H16 #ifndef BT_HEIGHTFIELD_TERRAIN_SHAPE_H 17 #define BT_HEIGHTFIELD_TERRAIN_SHAPE_H 18 18 19 19 #include "btConcaveShape.h" … … 159 159 }; 160 160 161 #endif // HEIGHTFIELD_TERRAIN_SHAPE_H161 #endif //BT_HEIGHTFIELD_TERRAIN_SHAPE_H -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btMaterial.h
r8351 r8393 16 16 /// This file was created by Alex Silverman 17 17 18 #ifndef MATERIAL_H19 #define MATERIAL_H18 #ifndef BT_MATERIAL_H 19 #define BT_MATERIAL_H 20 20 21 21 // Material class to be used by btMultimaterialTriangleMeshShape to store triangle properties … … 32 32 }; 33 33 34 #endif // MATERIAL_H34 #endif // BT_MATERIAL_H 35 35 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btMinkowskiSumShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef MINKOWSKI_SUM_SHAPE_H17 #define MINKOWSKI_SUM_SHAPE_H16 #ifndef BT_MINKOWSKI_SUM_SHAPE_H 17 #define BT_MINKOWSKI_SUM_SHAPE_H 18 18 19 19 #include "btConvexInternalShape.h" … … 58 58 }; 59 59 60 #endif // MINKOWSKI_SUM_SHAPE_H60 #endif //BT_MINKOWSKI_SUM_SHAPE_H -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btMultiSphereShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef MULTI_SPHERE_MINKOWSKI_H17 #define MULTI_SPHERE_MINKOWSKI_H16 #ifndef BT_MULTI_SPHERE_MINKOWSKI_H 17 #define BT_MULTI_SPHERE_MINKOWSKI_H 18 18 19 19 #include "btConvexInternalShape.h" … … 97 97 98 98 99 #endif // MULTI_SPHERE_MINKOWSKI_H99 #endif //BT_MULTI_SPHERE_MINKOWSKI_H -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h
r8351 r8393 16 16 /// This file was created by Alex Silverman 17 17 18 #ifndef B VH_TRIANGLE_MATERIAL_MESH_SHAPE_H19 #define B VH_TRIANGLE_MATERIAL_MESH_SHAPE_H18 #ifndef BT_BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H 19 #define BT_BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H 20 20 21 21 #include "btBvhTriangleMeshShape.h" … … 32 32 BT_DECLARE_ALIGNED_ALLOCATOR(); 33 33 34 btMultimaterialTriangleMeshShape(): btBvhTriangleMeshShape() {m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;}35 34 btMultimaterialTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true): 36 35 btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, buildBvh) … … 119 118 ; 120 119 121 #endif //B VH_TRIANGLE_MATERIAL_MESH_SHAPE_H120 #endif //BT_BVH_TRIANGLE_MATERIAL_MESH_SHAPE_H -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btOptimizedBvh.h
r8351 r8393 16 16 ///Contains contributions from Disney Studio's 17 17 18 #ifndef OPTIMIZED_BVH_H19 #define OPTIMIZED_BVH_H18 #ifndef BT_OPTIMIZED_BVH_H 19 #define BT_OPTIMIZED_BVH_H 20 20 21 21 #include "BulletCollision/BroadphaseCollision/btQuantizedBvh.h" … … 61 61 62 62 63 #endif // OPTIMIZED_BVH_H63 #endif //BT_OPTIMIZED_BVH_H 64 64 65 65 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
r8351 r8393 15 15 16 16 #include "BulletCollision/CollisionShapes/btPolyhedralConvexShape.h" 17 18 btPolyhedralConvexShape::btPolyhedralConvexShape() :btConvexInternalShape() 19 { 20 17 #include "btConvexPolyhedron.h" 18 #include "LinearMath/btConvexHullComputer.h" 19 #include <new> 20 21 btPolyhedralConvexShape::btPolyhedralConvexShape() :btConvexInternalShape(), 22 m_polyhedron(0) 23 { 24 25 } 26 27 btPolyhedralConvexShape::~btPolyhedralConvexShape() 28 { 29 if (m_polyhedron) 30 { 31 btAlignedFree(m_polyhedron); 32 } 33 } 34 35 bool btPolyhedralConvexShape::initializePolyhedralFeatures() 36 { 37 if (m_polyhedron) 38 btAlignedFree(m_polyhedron); 39 40 void* mem = btAlignedAlloc(sizeof(btConvexPolyhedron),16); 41 m_polyhedron = new (mem) btConvexPolyhedron; 42 43 btAlignedObjectArray<btVector3> tmpVertices; 44 for (int i=0;i<getNumVertices();i++) 45 { 46 btVector3& newVertex = tmpVertices.expand(); 47 getVertex(i,newVertex); 48 } 49 50 btConvexHullComputer conv; 51 conv.compute(&tmpVertices[0].getX(), sizeof(btVector3),tmpVertices.size(),0.f,0.f); 52 53 54 55 btAlignedObjectArray<btVector3> faceNormals; 56 int numFaces = conv.faces.size(); 57 faceNormals.resize(numFaces); 58 btConvexHullComputer* convexUtil = &conv; 59 60 61 62 m_polyhedron->m_faces.resize(numFaces); 63 int numVertices = convexUtil->vertices.size(); 64 m_polyhedron->m_vertices.resize(numVertices); 65 for (int p=0;p<numVertices;p++) 66 { 67 m_polyhedron->m_vertices[p] = convexUtil->vertices[p]; 68 } 69 70 for (int i=0;i<numFaces;i++) 71 { 72 int face = convexUtil->faces[i]; 73 //printf("face=%d\n",face); 74 const btConvexHullComputer::Edge* firstEdge = &convexUtil->edges[face]; 75 const btConvexHullComputer::Edge* edge = firstEdge; 76 77 btVector3 edges[3]; 78 int numEdges = 0; 79 //compute face normals 80 81 btScalar maxCross2 = 0.f; 82 int chosenEdge = -1; 83 84 do 85 { 86 87 int src = edge->getSourceVertex(); 88 m_polyhedron->m_faces[i].m_indices.push_back(src); 89 int targ = edge->getTargetVertex(); 90 btVector3 wa = convexUtil->vertices[src]; 91 92 btVector3 wb = convexUtil->vertices[targ]; 93 btVector3 newEdge = wb-wa; 94 newEdge.normalize(); 95 if (numEdges<2) 96 edges[numEdges++] = newEdge; 97 98 edge = edge->getNextEdgeOfFace(); 99 } while (edge!=firstEdge); 100 101 btScalar planeEq = 1e30f; 102 103 104 if (numEdges==2) 105 { 106 faceNormals[i] = edges[0].cross(edges[1]); 107 faceNormals[i].normalize(); 108 m_polyhedron->m_faces[i].m_plane[0] = -faceNormals[i].getX(); 109 m_polyhedron->m_faces[i].m_plane[1] = -faceNormals[i].getY(); 110 m_polyhedron->m_faces[i].m_plane[2] = -faceNormals[i].getZ(); 111 m_polyhedron->m_faces[i].m_plane[3] = planeEq; 112 113 } 114 else 115 { 116 btAssert(0);//degenerate? 117 faceNormals[i].setZero(); 118 } 119 120 for (int v=0;v<m_polyhedron->m_faces[i].m_indices.size();v++) 121 { 122 btScalar eq = m_polyhedron->m_vertices[m_polyhedron->m_faces[i].m_indices[v]].dot(faceNormals[i]); 123 if (planeEq>eq) 124 { 125 planeEq=eq; 126 } 127 } 128 m_polyhedron->m_faces[i].m_plane[3] = planeEq; 129 } 130 131 132 if (m_polyhedron->m_faces.size() && conv.vertices.size()) 133 { 134 135 for (int f=0;f<m_polyhedron->m_faces.size();f++) 136 { 137 138 btVector3 planeNormal(m_polyhedron->m_faces[f].m_plane[0],m_polyhedron->m_faces[f].m_plane[1],m_polyhedron->m_faces[f].m_plane[2]); 139 btScalar planeEq = m_polyhedron->m_faces[f].m_plane[3]; 140 141 btVector3 supVec = localGetSupportingVertex(-planeNormal); 142 143 if (supVec.dot(planeNormal)<planeEq) 144 { 145 m_polyhedron->m_faces[f].m_plane[0] *= -1; 146 m_polyhedron->m_faces[f].m_plane[1] *= -1; 147 m_polyhedron->m_faces[f].m_plane[2] *= -1; 148 m_polyhedron->m_faces[f].m_plane[3] *= -1; 149 int numVerts = m_polyhedron->m_faces[f].m_indices.size(); 150 for (int v=0;v<numVerts/2;v++) 151 { 152 btSwap(m_polyhedron->m_faces[f].m_indices[v],m_polyhedron->m_faces[f].m_indices[numVerts-1-v]); 153 } 154 } 155 } 156 } 157 158 159 160 m_polyhedron->initialize(); 161 162 return true; 21 163 } 22 164 … … 192 334 } 193 335 336 337 338 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btPolyhedralConvexShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef B U_SHAPE17 #define B U_SHAPE16 #ifndef BT_POLYHEDRAL_CONVEX_SHAPE_H 17 #define BT_POLYHEDRAL_CONVEX_SHAPE_H 18 18 19 19 #include "LinearMath/btMatrix3x3.h" 20 20 #include "btConvexInternalShape.h" 21 class btConvexPolyhedron; 21 22 22 23 … … 24 25 class btPolyhedralConvexShape : public btConvexInternalShape 25 26 { 27 26 28 27 29 protected: 28 30 31 btConvexPolyhedron* m_polyhedron; 32 29 33 public: 30 34 31 35 btPolyhedralConvexShape(); 36 37 virtual ~btPolyhedralConvexShape(); 38 39 ///optional method mainly used to generate multiple contact points by clipping polyhedral features (faces/edges) 40 virtual bool initializePolyhedralFeatures(); 41 42 const btConvexPolyhedron* getConvexPolyhedron() const 43 { 44 return m_polyhedron; 45 } 32 46 33 47 //brute force implementations … … 96 110 }; 97 111 98 #endif //B U_SHAPE112 #endif //BT_POLYHEDRAL_CONVEX_SHAPE_H -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp
r8351 r8393 63 63 scaledAabbMin[1] = m_localScaling.getY() >= 0. ? aabbMin[1] * invLocalScaling[1] : aabbMax[1] * invLocalScaling[1]; 64 64 scaledAabbMin[2] = m_localScaling.getZ() >= 0. ? aabbMin[2] * invLocalScaling[2] : aabbMax[2] * invLocalScaling[2]; 65 scaledAabbMin[3] = 0.f; 65 66 66 67 scaledAabbMax[0] = m_localScaling.getX() <= 0. ? aabbMin[0] * invLocalScaling[0] : aabbMax[0] * invLocalScaling[0]; 67 68 scaledAabbMax[1] = m_localScaling.getY() <= 0. ? aabbMin[1] * invLocalScaling[1] : aabbMax[1] * invLocalScaling[1]; 68 69 scaledAabbMax[2] = m_localScaling.getZ() <= 0. ? aabbMin[2] * invLocalScaling[2] : aabbMax[2] * invLocalScaling[2]; 70 scaledAabbMax[3] = 0.f; 69 71 70 72 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef SCALED_BVH_TRIANGLE_MESH_SHAPE_H17 #define SCALED_BVH_TRIANGLE_MESH_SHAPE_H16 #ifndef BT_SCALED_BVH_TRIANGLE_MESH_SHAPE_H 17 #define BT_SCALED_BVH_TRIANGLE_MESH_SHAPE_H 18 18 19 19 #include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h" … … 58 58 virtual const char* getName()const {return "SCALEDBVHTRIANGLEMESH";} 59 59 60 virtual int calculateSerializeBufferSize() const; 61 62 ///fills the dataBuffer and returns the struct name (and 0 on failure) 63 virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const; 64 60 65 }; 61 66 62 #endif //BVH_TRIANGLE_MESH_SHAPE_H 67 ///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 68 struct btScaledTriangleMeshShapeData 69 { 70 btTriangleMeshShapeData m_trimeshShapeData; 71 72 btVector3FloatData m_localScaling; 73 }; 74 75 76 SIMD_FORCE_INLINE int btScaledBvhTriangleMeshShape::calculateSerializeBufferSize() const 77 { 78 return sizeof(btScaledTriangleMeshShapeData); 79 } 80 81 82 ///fills the dataBuffer and returns the struct name (and 0 on failure) 83 SIMD_FORCE_INLINE const char* btScaledBvhTriangleMeshShape::serialize(void* dataBuffer, btSerializer* serializer) const 84 { 85 btScaledTriangleMeshShapeData* scaledMeshData = (btScaledTriangleMeshShapeData*) dataBuffer; 86 m_bvhTriMeshShape->serialize(&scaledMeshData->m_trimeshShapeData,serializer); 87 scaledMeshData->m_trimeshShapeData.m_collisionShapeData.m_shapeType = SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE; 88 m_localScaling.serializeFloat(scaledMeshData->m_localScaling); 89 return "btScaledTriangleMeshShapeData"; 90 } 91 92 93 #endif //BT_SCALED_BVH_TRIANGLE_MESH_SHAPE_H -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btShapeHull.h
r8351 r8393 16 16 ///btShapeHull implemented by John McCutchan. 17 17 18 #ifndef _SHAPE_HULL_H19 #define _SHAPE_HULL_H18 #ifndef BT_SHAPE_HULL_H 19 #define BT_SHAPE_HULL_H 20 20 21 21 #include "LinearMath/btAlignedObjectArray.h" … … 57 57 }; 58 58 59 #endif // _SHAPE_HULL_H59 #endif //BT_SHAPE_HULL_H -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btSphereShape.h
r8351 r8393 13 13 3. This notice may not be removed or altered from any source distribution. 14 14 */ 15 #ifndef SPHERE_MINKOWSKI_H16 #define SPHERE_MINKOWSKI_H15 #ifndef BT_SPHERE_MINKOWSKI_H 16 #define BT_SPHERE_MINKOWSKI_H 17 17 18 18 #include "btConvexInternalShape.h" … … 71 71 72 72 73 #endif // SPHERE_MINKOWSKI_H73 #endif //BT_SPHERE_MINKOWSKI_H -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btStaticPlaneShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef STATIC_PLANE_SHAPE_H17 #define STATIC_PLANE_SHAPE_H16 #ifndef BT_STATIC_PLANE_SHAPE_H 17 #define BT_STATIC_PLANE_SHAPE_H 18 18 19 19 #include "btConcaveShape.h" … … 98 98 99 99 100 #endif // STATIC_PLANE_SHAPE_H100 #endif //BT_STATIC_PLANE_SHAPE_H 101 101 102 102 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btStridingMeshInterface.cpp
r8351 r8393 89 89 break; 90 90 } 91 case PHY_UCHAR: 92 { 93 for (gfxindex=0;gfxindex<numtriangles;gfxindex++) 94 { 95 unsigned char* tri_indices= (unsigned char*)(indexbase+gfxindex*indexstride); 96 graphicsbase = (float*)(vertexbase+tri_indices[0]*stride); 97 triangle[0].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ()); 98 graphicsbase = (float*)(vertexbase+tri_indices[1]*stride); 99 triangle[1].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(), graphicsbase[2]*meshScaling.getZ()); 100 graphicsbase = (float*)(vertexbase+tri_indices[2]*stride); 101 triangle[2].setValue(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(), graphicsbase[2]*meshScaling.getZ()); 102 callback->internalProcessTriangleIndex(triangle,part,gfxindex); 103 } 104 break; 105 } 91 106 default: 92 107 btAssert((gfxindextype == PHY_INTEGER) || (gfxindextype == PHY_SHORT)); … … 121 136 { 122 137 unsigned short int* tri_indices= (unsigned short int*)(indexbase+gfxindex*indexstride); 138 graphicsbase = (double*)(vertexbase+tri_indices[0]*stride); 139 triangle[0].setValue((btScalar)graphicsbase[0]*meshScaling.getX(),(btScalar)graphicsbase[1]*meshScaling.getY(),(btScalar)graphicsbase[2]*meshScaling.getZ()); 140 graphicsbase = (double*)(vertexbase+tri_indices[1]*stride); 141 triangle[1].setValue((btScalar)graphicsbase[0]*meshScaling.getX(),(btScalar)graphicsbase[1]*meshScaling.getY(), (btScalar)graphicsbase[2]*meshScaling.getZ()); 142 graphicsbase = (double*)(vertexbase+tri_indices[2]*stride); 143 triangle[2].setValue((btScalar)graphicsbase[0]*meshScaling.getX(),(btScalar)graphicsbase[1]*meshScaling.getY(), (btScalar)graphicsbase[2]*meshScaling.getZ()); 144 callback->internalProcessTriangleIndex(triangle,part,gfxindex); 145 } 146 break; 147 } 148 case PHY_UCHAR: 149 { 150 for (gfxindex=0;gfxindex<numtriangles;gfxindex++) 151 { 152 unsigned char* tri_indices= (unsigned char*)(indexbase+gfxindex*indexstride); 123 153 graphicsbase = (double*)(vertexbase+tri_indices[0]*stride); 124 154 triangle[0].setValue((btScalar)graphicsbase[0]*meshScaling.getX(),(btScalar)graphicsbase[1]*meshScaling.getY(),(btScalar)graphicsbase[2]*meshScaling.getZ()); … … 267 297 break; 268 298 } 299 case PHY_UCHAR: 300 { 301 if (numtriangles) 302 { 303 btChunk* chunk = serializer->allocate(sizeof(btCharIndexTripletData),numtriangles); 304 btCharIndexTripletData* tmpIndices = (btCharIndexTripletData*)chunk->m_oldPtr; 305 memPtr->m_3indices8 = (btCharIndexTripletData*) serializer->getUniquePointer(tmpIndices); 306 for (gfxindex=0;gfxindex<numtriangles;gfxindex++) 307 { 308 unsigned char* tri_indices= (unsigned char*)(indexbase+gfxindex*indexstride); 309 tmpIndices[gfxindex].m_values[0] = tri_indices[0]; 310 tmpIndices[gfxindex].m_values[1] = tri_indices[1]; 311 tmpIndices[gfxindex].m_values[2] = tri_indices[2]; 312 } 313 serializer->finalizeChunk(chunk,"btCharIndexTripletData",BT_ARRAY_CODE,(void*)chunk->m_oldPtr); 314 } 315 break; 316 } 269 317 default: 270 318 { -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btStridingMeshInterface.h
r8351 r8393 14 14 */ 15 15 16 #ifndef STRIDING_MESHINTERFACE_H17 #define STRIDING_MESHINTERFACE_H16 #ifndef BT_STRIDING_MESHINTERFACE_H 17 #define BT_STRIDING_MESHINTERFACE_H 18 18 19 19 #include "LinearMath/btVector3.h" … … 117 117 }; 118 118 119 struct btCharIndexTripletData 120 { 121 unsigned char m_values[3]; 122 char m_pad; 123 }; 124 125 119 126 ///do not change those serialization structures, it requires an updated sBulletDNAstr/sBulletDNAstr64 120 127 struct btMeshPartData … … 125 132 btIntIndexData *m_indices32; 126 133 btShortIntIndexTripletData *m_3indices16; 134 btCharIndexTripletData *m_3indices8; 127 135 128 136 btShortIntIndexData *m_indices16;//backwards compatibility … … 152 160 153 161 154 #endif // STRIDING_MESHINTERFACE_H162 #endif //BT_STRIDING_MESHINTERFACE_H -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btTetrahedronShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef B U_SIMPLEX_1TO4_SHAPE17 #define B U_SIMPLEX_1TO4_SHAPE16 #ifndef BT_SIMPLEX_1TO4_SHAPE 17 #define BT_SIMPLEX_1TO4_SHAPE 18 18 19 19 … … 72 72 }; 73 73 74 #endif //B U_SIMPLEX_1TO4_SHAPE74 #endif //BT_SIMPLEX_1TO4_SHAPE -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btTriangleCallback.h
r8351 r8393 14 14 */ 15 15 16 #ifndef TRIANGLE_CALLBACK_H17 #define TRIANGLE_CALLBACK_H16 #ifndef BT_TRIANGLE_CALLBACK_H 17 #define BT_TRIANGLE_CALLBACK_H 18 18 19 19 #include "LinearMath/btVector3.h" … … 40 40 41 41 42 #endif // TRIANGLE_CALLBACK_H42 #endif //BT_TRIANGLE_CALLBACK_H -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btTriangleInfoMap.h
r8351 r8393 62 62 btScalar m_equalVertexThreshold; ///used to compute connectivity: if the distance between two vertices is smaller than m_equalVertexThreshold, they are considered to be 'shared' 63 63 btScalar m_edgeDistanceThreshold; ///used to determine edge contacts: if the closest distance between a contact point and an edge is smaller than this distance threshold it is considered to "hit the edge" 64 btScalar m_maxEdgeAngleThreshold; //ignore edges that connect triangles at an angle larger than this m_maxEdgeAngleThreshold 64 65 btScalar m_zeroAreaThreshold; ///used to determine if a triangle is degenerate (length squared of cross product of 2 triangle edges < threshold) 65 66 … … 72 73 m_edgeDistanceThreshold = btScalar(0.1); 73 74 m_zeroAreaThreshold = btScalar(0.0001)*btScalar(0.0001); 75 m_maxEdgeAngleThreshold = SIMD_2_PI; 74 76 } 75 77 virtual ~btTriangleInfoMap() {} -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btTriangleMesh.h
r8351 r8393 14 14 */ 15 15 16 #ifndef TRIANGLE_MESH_H17 #define TRIANGLE_MESH_H16 #ifndef BT_TRIANGLE_MESH_H 17 #define BT_TRIANGLE_MESH_H 18 18 19 19 #include "btTriangleIndexVertexArray.h" … … 66 66 }; 67 67 68 #endif // TRIANGLE_MESH_H68 #endif //BT_TRIANGLE_MESH_H 69 69 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btTriangleMeshShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef TRIANGLE_MESH_SHAPE_H17 #define TRIANGLE_MESH_SHAPE_H16 #ifndef BT_TRIANGLE_MESH_SHAPE_H 17 #define BT_TRIANGLE_MESH_SHAPE_H 18 18 19 19 #include "btConcaveShape.h" … … 87 87 88 88 89 #endif // TRIANGLE_MESH_SHAPE_H89 #endif //BT_TRIANGLE_MESH_SHAPE_H -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btTriangleShape.h
r8351 r8393 14 14 */ 15 15 16 #ifndef OBB_TRIANGLE_MINKOWSKI_H17 #define OBB_TRIANGLE_MINKOWSKI_H16 #ifndef BT_OBB_TRIANGLE_MINKOWSKI_H 17 #define BT_OBB_TRIANGLE_MINKOWSKI_H 18 18 19 19 #include "btConvexShape.h" … … 179 179 }; 180 180 181 #endif // OBB_TRIANGLE_MINKOWSKI_H181 #endif //BT_OBB_TRIANGLE_MINKOWSKI_H 182 182 -
code/trunk/src/external/bullet/BulletCollision/CollisionShapes/btUniformScalingShape.cpp
r8351 r8393 65 65 66 66 ///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version 67 void btUniformScalingShape::getAabb(const btTransform& t ,btVector3& aabbMin,btVector3& aabbMax) const67 void btUniformScalingShape::getAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax) const 68 68 { 69 m_childConvexShape->getAabb(t,aabbMin,aabbMax); 70 btVector3 aabbCenter = (aabbMax+aabbMin)*btScalar(0.5); 71 btVector3 scaledAabbHalfExtends = (aabbMax-aabbMin)*btScalar(0.5)*m_uniformScalingFactor; 72 73 aabbMin = aabbCenter - scaledAabbHalfExtends; 74 aabbMax = aabbCenter + scaledAabbHalfExtends; 69 getAabbSlow(trans,aabbMin,aabbMax); 75 70 76 71 } … … 78 73 void btUniformScalingShape::getAabbSlow(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const 79 74 { 80 m_childConvexShape->getAabbSlow(t,aabbMin,aabbMax); 81 btVector3 aabbCenter = (aabbMax+aabbMin)*btScalar(0.5); 82 btVector3 scaledAabbHalfExtends = (aabbMax-aabbMin)*btScalar(0.5)*m_uniformScalingFactor; 75 #if 1 76 btVector3 _directions[] = 77 { 78 btVector3( 1., 0., 0.), 79 btVector3( 0., 1., 0.), 80 btVector3( 0., 0., 1.), 81 btVector3( -1., 0., 0.), 82 btVector3( 0., -1., 0.), 83 btVector3( 0., 0., -1.) 84 }; 85 86 btVector3 _supporting[] = 87 { 88 btVector3( 0., 0., 0.), 89 btVector3( 0., 0., 0.), 90 btVector3( 0., 0., 0.), 91 btVector3( 0., 0., 0.), 92 btVector3( 0., 0., 0.), 93 btVector3( 0., 0., 0.) 94 }; 83 95 84 aabbMin = aabbCenter - scaledAabbHalfExtends; 85 aabbMax = aabbCenter + scaledAabbHalfExtends; 96 for (int i=0;i<6;i++) 97 { 98 _directions[i] = _directions[i]*t.getBasis(); 99 } 100 101 batchedUnitVectorGetSupportingVertexWithoutMargin(_directions, _supporting, 6); 102 103 btVector3 aabbMin1(0,0,0),aabbMax1(0,0,0); 104 105 for ( int i = 0; i < 3; ++i ) 106 { 107 aabbMax1[i] = t(_supporting[i])[i]; 108 aabbMin1[i] = t(_supporting[i + 3])[i]; 109 } 110 btVector3 marginVec(getMargin(),getMargin(),getMargin()); 111 aabbMin = aabbMin1-marginVec; 112 aabbMax = aabbMax1+marginVec; 113 114 #else 115 116 btScalar margin = getMargin(); 117 for (int i=0;i<3;i++) 118 { 119 btVector3 vec(btScalar(0.),btScalar(0.),btScalar(0.)); 120 vec[i] = btScalar(1.); 121 btVector3 sv = localGetSupportingVertex(vec*t.getBasis()); 122 btVector3 tmp = t(sv); 123 aabbMax[i] = tmp[i]+margin; 124 vec[i] = btScalar(-1.); 125 sv = localGetSupportingVertex(vec*t.getBasis()); 126 tmp = t(sv); 127 aabbMin[i] = tmp[i]-margin; 128 } 129 130 #endif 86 131 } 87 132
Note: See TracChangeset
for help on using the changeset viewer.