- Timestamp:
- Apr 8, 2009, 12:58:47 AM (16 years ago)
- Location:
- code/branches/questsystem5
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/questsystem5
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btBoxShape.h
r2907 r2908 162 162 { 163 163 case 0: 164 plane.setValue(btScalar(1.),btScalar(0.),btScalar(0.),-halfExtents.x()); 164 plane.setValue(btScalar(1.),btScalar(0.),btScalar(0.)); 165 plane[3] = -halfExtents.x(); 165 166 break; 166 167 case 1: 167 plane.setValue(btScalar(-1.),btScalar(0.),btScalar(0.),-halfExtents.x()); 168 plane.setValue(btScalar(-1.),btScalar(0.),btScalar(0.)); 169 plane[3] = -halfExtents.x(); 168 170 break; 169 171 case 2: 170 plane.setValue(btScalar(0.),btScalar(1.),btScalar(0.),-halfExtents.y()); 172 plane.setValue(btScalar(0.),btScalar(1.),btScalar(0.)); 173 plane[3] = -halfExtents.y(); 171 174 break; 172 175 case 3: 173 plane.setValue(btScalar(0.),btScalar(-1.),btScalar(0.),-halfExtents.y()); 176 plane.setValue(btScalar(0.),btScalar(-1.),btScalar(0.)); 177 plane[3] = -halfExtents.y(); 174 178 break; 175 179 case 4: 176 plane.setValue(btScalar(0.),btScalar(0.),btScalar(1.),-halfExtents.z()); 180 plane.setValue(btScalar(0.),btScalar(0.),btScalar(1.)); 181 plane[3] = -halfExtents.z(); 177 182 break; 178 183 case 5: 179 plane.setValue(btScalar(0.),btScalar(0.),btScalar(-1.),-halfExtents.z()); 184 plane.setValue(btScalar(0.),btScalar(0.),btScalar(-1.)); 185 plane[3] = -halfExtents.z(); 180 186 break; 181 187 default: 182 btAssert(0);188 assert(0); 183 189 } 184 190 } … … 307 313 break; 308 314 default: 309 btAssert(0);315 assert(0); 310 316 } 311 317 } -
code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btCollisionShape.cpp
r2907 r2908 15 15 16 16 #include "BulletCollision/CollisionShapes/btCollisionShape.h" 17 18 19 btScalar gContactThresholdFactor=btScalar(0.02);20 17 21 18 … … 48 45 btScalar btCollisionShape::getContactBreakingThreshold() const 49 46 { 50 return getAngularMotionDisc() * gContactThresholdFactor; 47 ///@todo make this 0.1 configurable 48 return getAngularMotionDisc() * btScalar(0.1); 51 49 } 52 50 btScalar btCollisionShape::getAngularMotionDisc() const -
code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btCompoundShape.cpp
r2907 r2908 23 23 m_collisionMargin(btScalar(0.)), 24 24 m_localScaling(btScalar(1.),btScalar(1.),btScalar(1.)), 25 m_dynamicAabbTree(0), 26 m_updateRevision(1) 25 m_dynamicAabbTree(0) 27 26 { 28 27 m_shapeType = COMPOUND_SHAPE_PROXYTYPE; … … 48 47 void btCompoundShape::addChildShape(const btTransform& localTransform,btCollisionShape* shape) 49 48 { 50 m_updateRevision++;51 49 //m_childTransforms.push_back(localTransform); 52 50 //m_childShapes.push_back(shape); … … 57 55 child.m_childMargin = shape->getMargin(); 58 56 59 57 m_children.push_back(child); 58 60 59 //extend the local aabbMin/aabbMax 61 60 btVector3 localAabbMin,localAabbMax; … … 76 75 { 77 76 const btDbvtVolume bounds=btDbvtVolume::FromMM(localAabbMin,localAabbMax); 78 int index = m_children.size() ;77 int index = m_children.size()-1; 79 78 child.m_node = m_dynamicAabbTree->insert(bounds,(void*)index); 80 79 } 81 82 m_children.push_back(child);83 80 84 81 } … … 103 100 void btCompoundShape::removeChildShapeByIndex(int childShapeIndex) 104 101 { 105 m_updateRevision++;106 102 btAssert(childShapeIndex >=0 && childShapeIndex < m_children.size()); 107 103 if (m_dynamicAabbTree) … … 118 114 void btCompoundShape::removeChildShape(btCollisionShape* shape) 119 115 { 120 m_updateRevision++;121 116 // Find the children containing the shape specified, and remove those children. 122 117 //note: there might be multiple children using the same shape! … … 145 140 // Recalculate the local aabb 146 141 // Brute force, it iterates over all the shapes left. 147 148 142 m_localAabbMin = btVector3(btScalar(1e30),btScalar(1e30),btScalar(1e30)); 149 143 m_localAabbMax = btVector3(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30)); … … 168 162 { 169 163 btVector3 localHalfExtents = btScalar(0.5)*(m_localAabbMax-m_localAabbMin); 164 localHalfExtents += btVector3(getMargin(),getMargin(),getMargin()); 170 165 btVector3 localCenter = btScalar(0.5)*(m_localAabbMax+m_localAabbMin); 171 172 //avoid an illegal AABB when there are no children173 if (!m_children.size())174 {175 localHalfExtents.setValue(0,0,0);176 localCenter.setValue(0,0,0);177 }178 localHalfExtents += btVector3(getMargin(),getMargin(),getMargin());179 180 166 181 167 btMatrix3x3 abs_b = trans.getBasis().absolute(); … … 188 174 aabbMin = center-extent; 189 175 aabbMax = center+extent; 190 176 191 177 } 192 178 -
code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btCompoundShape.h
r2907 r2908 59 59 60 60 btDbvt* m_dynamicAabbTree; 61 62 ///increment m_updateRevision when adding/removing/replacing child shapes, so that some caches can be updated63 int m_updateRevision;64 61 65 62 public: … … 156 153 void calculatePrincipalAxisTransform(btScalar* masses, btTransform& principal, btVector3& inertia) const; 157 154 158 int getUpdateRevision() const159 {160 return m_updateRevision;161 }162 155 163 156 private: -
code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btConeShape.cpp
r2907 r2908 61 61 break; 62 62 default: 63 btAssert(0);63 assert(0); 64 64 }; 65 65 } -
code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btConvexHullShape.cpp
r2907 r2908 182 182 bool btConvexHullShape::isInside(const btVector3& ,btScalar ) const 183 183 { 184 btAssert(0);184 assert(0); 185 185 return false; 186 186 } -
code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btConvexPointCloudShape.cpp
r2907 r2908 151 151 bool btConvexPointCloudShape::isInside(const btVector3& ,btScalar ) const 152 152 { 153 btAssert(0);153 assert(0); 154 154 return false; 155 155 } -
code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btConvexShape.cpp
r2907 r2908 155 155 156 156 btCapsuleShape* capsuleShape = (btCapsuleShape*)this; 157 btVector3 halfExtents = capsuleShape->getImplicitShapeDimensions(); 157 158 btScalar halfHeight = capsuleShape->getHalfHeight(); 158 159 int capsuleUpAxis = capsuleShape->getUpAxis(); … … 301 302 { 302 303 btSphereShape* sphereShape = (btSphereShape*)this; 303 btScalarradius = sphereShape->getImplicitShapeDimensions().getX();// * convexShape->getLocalScaling().getX();304 btScalarmargin = radius + sphereShape->getMarginNonVirtual();304 float radius = sphereShape->getImplicitShapeDimensions().getX();// * convexShape->getLocalScaling().getX(); 305 float margin = radius + sphereShape->getMarginNonVirtual(); 305 306 const btVector3& center = t.getOrigin(); 306 307 btVector3 extent(margin,margin,margin); … … 314 315 { 315 316 btBoxShape* convexShape = (btBoxShape*)this; 316 btScalarmargin=convexShape->getMarginNonVirtual();317 float margin=convexShape->getMarginNonVirtual(); 317 318 btVector3 halfExtents = convexShape->getImplicitShapeDimensions(); 318 319 halfExtents += btVector3(margin,margin,margin); -
code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp
r2907 r2908 145 145 } 146 146 147 148 /// This returns the "raw" (user's initial) height, not the actual height. 149 /// The actual height needs to be adjusted to be relative to the center 150 /// of the heightfield's AABB. 151 btScalar 152 btHeightfieldTerrainShape::getRawHeightFieldValue(int x,int y) const 147 btScalar btHeightfieldTerrainShape::getHeightFieldValue(int x,int y) const 153 148 { 154 149 btScalar val = 0.f; … … 187 182 188 183 189 /// this returns the vertex in bullet-local coordinates 184 190 185 void btHeightfieldTerrainShape::getVertex(int x,int y,btVector3& vertex) const 191 186 { 187 192 188 btAssert(x>=0); 193 189 btAssert(y>=0); … … 195 191 btAssert(y<m_heightStickLength); 196 192 197 btScalar height = getRawHeightFieldValue(x,y); 193 194 btScalar height = getHeightFieldValue(x,y); 198 195 199 196 switch (m_upAxis) … … 202 199 { 203 200 vertex.setValue( 204 height - m_localOrigin.getX(),201 height, 205 202 (-m_width/btScalar(2.0)) + x, 206 203 (-m_length/btScalar(2.0) ) + y … … 212 209 vertex.setValue( 213 210 (-m_width/btScalar(2.0)) + x, 214 height - m_localOrigin.getY(),211 height, 215 212 (-m_length/btScalar(2.0)) + y 216 213 ); … … 222 219 (-m_width/btScalar(2.0)) + x, 223 220 (-m_length/btScalar(2.0)) + y, 224 height - m_localOrigin.getZ()221 height 225 222 ); 226 223 break; … … 234 231 235 232 vertex*=m_localScaling; 233 236 234 } 237 235 … … 241 239 getQuantized 242 240 ( 243 btScalarx241 float x 244 242 ) 245 243 { -
code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h
r2907 r2908 30 30 center (as determined by width and length and height, with each 31 31 axis multiplied by the localScaling). 32 33 \b NOTE: be careful with coordinates. If you have a heightfield with a local34 min height of -100m, and a max height of +500m, you may be tempted to place it35 at the origin (0,0) and expect the heights in world coordinates to be36 -100 to +500 meters.37 Actually, the heights will be -300 to +300m, because bullet will re-center38 the heightfield based on its AABB (which is determined by the min/max39 heights). So keep in mind that once you create a btHeightfieldTerrainShape40 object, the heights will be adjusted relative to the center of the AABB. This41 is different to the behavior of many rendering engines, but is useful for42 physics engines.43 32 44 33 Most (but not all) rendering and heightfield libraries assume upAxis = 1 … … 100 89 btVector3 m_localScaling; 101 90 102 virtual btScalar get RawHeightFieldValue(int x,int y) const;91 virtual btScalar getHeightFieldValue(int x,int y) const; 103 92 void quantizeWithClamp(int* out, const btVector3& point,int isMax) const; 104 93 void getVertex(int x,int y,btVector3& vertex) const; -
code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp
r2907 r2908 29 29 btVector3 btMinkowskiSumShape::localGetSupportingVertexWithoutMargin(const btVector3& vec)const 30 30 { 31 btVector3 supVertexA = m_transA(m_shapeA->localGetSupportingVertexWithoutMargin( vec*m_transA.getBasis()));32 btVector3 supVertexB = m_transB(m_shapeB->localGetSupportingVertexWithoutMargin( -vec*m_transB.getBasis()));31 btVector3 supVertexA = m_transA(m_shapeA->localGetSupportingVertexWithoutMargin(-vec*m_transA.getBasis())); 32 btVector3 supVertexB = m_transB(m_shapeB->localGetSupportingVertexWithoutMargin(vec*m_transB.getBasis())); 33 33 return supVertexA - supVertexB; 34 34 } -
code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h
r2907 r2908 32 32 BT_DECLARE_ALIGNED_ALLOCATOR(); 33 33 34 btMultimaterialTriangleMeshShape(): btBvhTriangleMeshShape() { m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;}34 btMultimaterialTriangleMeshShape(): btBvhTriangleMeshShape() {} 35 35 btMultimaterialTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true): 36 36 btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, buildBvh) 37 37 { 38 m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;39 40 38 btVector3 m_triangle[3]; 41 39 const unsigned char *vertexbase; … … 70 68 btBvhTriangleMeshShape(meshInterface, useQuantizedAabbCompression, bvhAabbMin, bvhAabbMax, buildBvh) 71 69 { 72 m_shapeType = MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE;73 74 70 btVector3 m_triangle[3]; 75 71 const unsigned char *vertexbase; … … 112 108 */ 113 109 } 110 virtual int getShapeType() const 111 { 112 return MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE; 113 } 114 114 115 //debugging 115 116 virtual const char* getName()const {return "MULTIMATERIALTRIANGLEMESH";} -
code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btSphereShape.h
r2907 r2908 48 48 btScalar getRadius() const { return m_implicitShapeDimensions.getX() * m_localScaling.getX();} 49 49 50 void setUnscaledRadius(btScalar radius)51 {52 m_implicitShapeDimensions.setX(radius);53 btConvexInternalShape::setMargin(radius);54 }55 56 50 //debugging 57 51 virtual const char* getName()const {return "SPHERE";} -
code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.cpp
r2907 r2908 83 83 } 84 84 85 86 void btTriangleIndexVertexArray::setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax ) const 85 void btTriangleIndexVertexArray::setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax ) 87 86 { 88 87 m_aabbMin = aabbMin; … … 97 96 } 98 97 99 -
code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexArray.h
r2907 r2908 53 53 IndexedMeshArray m_indexedMeshes; 54 54 int m_pad[2]; 55 mutableint m_hasAabb; // using int instead of bool to maintain alignment56 mutablebtVector3 m_aabbMin;57 mutablebtVector3 m_aabbMax;55 int m_hasAabb; // using int instead of bool to maintain alignment 56 btVector3 m_aabbMin; 57 btVector3 m_aabbMax; 58 58 59 59 public: … … 107 107 108 108 virtual bool hasPremadeAabb() const; 109 virtual void setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax ) const;109 virtual void setPremadeAabb(const btVector3& aabbMin, const btVector3& aabbMax ); 110 110 virtual void getPremadeAabb(btVector3* aabbMin, btVector3* aabbMax ) const; 111 111 -
code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.cpp
r2907 r2908 1 2 1 /* 3 2 Bullet Continuous Collision Detection and Physics Library -
code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btTriangleMesh.cpp
r2907 r2908 36 36 { 37 37 m_indexedMeshes[0].m_numTriangles = m_32bitIndices.size()/3; 38 m_indexedMeshes[0].m_triangleIndexBase = 0;38 m_indexedMeshes[0].m_triangleIndexBase = (unsigned char*) &m_32bitIndices[0]; 39 39 m_indexedMeshes[0].m_indexType = PHY_INTEGER; 40 40 m_indexedMeshes[0].m_triangleIndexStride = 3*sizeof(int); … … 42 42 { 43 43 m_indexedMeshes[0].m_numTriangles = m_16bitIndices.size()/3; 44 m_indexedMeshes[0].m_triangleIndexBase = 0;44 m_indexedMeshes[0].m_triangleIndexBase = (unsigned char*) &m_16bitIndices[0]; 45 45 m_indexedMeshes[0].m_indexType = PHY_SHORT; 46 46 m_indexedMeshes[0].m_triangleIndexStride = 3*sizeof(short int); … … 50 50 { 51 51 m_indexedMeshes[0].m_numVertices = m_4componentVertices.size(); 52 m_indexedMeshes[0].m_vertexBase = 0;52 m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_4componentVertices[0]; 53 53 m_indexedMeshes[0].m_vertexStride = sizeof(btVector3); 54 54 } else 55 55 { 56 56 m_indexedMeshes[0].m_numVertices = m_3componentVertices.size()/3; 57 m_indexedMeshes[0].m_vertexBase = 0;57 m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_3componentVertices[0]; 58 58 m_indexedMeshes[0].m_vertexStride = 3*sizeof(btScalar); 59 59 } … … 112 112 } 113 113 } 114 m_3componentVertices.push_back( (float)vertex.getX());115 m_3componentVertices.push_back( (float)vertex.getY());116 m_3componentVertices.push_back( (float)vertex.getZ());114 m_3componentVertices.push_back(vertex.getX()); 115 m_3componentVertices.push_back(vertex.getY()); 116 m_3componentVertices.push_back(vertex.getZ()); 117 117 m_indexedMeshes[0].m_numVertices++; 118 118 m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_3componentVertices[0]; -
code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btTriangleMeshShape.h
r2907 r2908 41 41 virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const 42 42 { 43 btAssert(0);43 assert(0); 44 44 return localGetSupportingVertex(vec); 45 45 }
Note: See TracChangeset
for help on using the changeset viewer.