Changeset 7983 for code/branches/kicklib/src/external/bullet/BulletCollision/CollisionShapes/btCylinderShape.cpp
- Timestamp:
- Feb 27, 2011, 7:43:24 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.