Changeset 2908 for code/branches/questsystem5/src/bullet/BulletCollision/CollisionShapes/btCompoundShape.cpp
- Timestamp:
- Apr 8, 2009, 12:58:47 AM (16 years ago)
- Location:
- code/branches/questsystem5
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/questsystem5
- Property svn:mergeinfo changed
-
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
Note: See TracChangeset
for help on using the changeset viewer.