- Timestamp:
- Mar 31, 2009, 8:05:51 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/bullet/BulletCollision/CollisionShapes/btCompoundShape.cpp
r2662 r2882 23 23 m_collisionMargin(btScalar(0.)), 24 24 m_localScaling(btScalar(1.),btScalar(1.),btScalar(1.)), 25 m_dynamicAabbTree(0) 25 m_dynamicAabbTree(0), 26 m_updateRevision(1) 26 27 { 27 28 m_shapeType = COMPOUND_SHAPE_PROXYTYPE; … … 47 48 void btCompoundShape::addChildShape(const btTransform& localTransform,btCollisionShape* shape) 48 49 { 50 m_updateRevision++; 49 51 //m_childTransforms.push_back(localTransform); 50 52 //m_childShapes.push_back(shape); … … 55 57 child.m_childMargin = shape->getMargin(); 56 58 57 m_children.push_back(child); 58 59 59 60 //extend the local aabbMin/aabbMax 60 61 btVector3 localAabbMin,localAabbMax; … … 75 76 { 76 77 const btDbvtVolume bounds=btDbvtVolume::FromMM(localAabbMin,localAabbMax); 77 int index = m_children.size() -1;78 int index = m_children.size(); 78 79 child.m_node = m_dynamicAabbTree->insert(bounds,(void*)index); 79 80 } 81 82 m_children.push_back(child); 80 83 81 84 } … … 100 103 void btCompoundShape::removeChildShapeByIndex(int childShapeIndex) 101 104 { 105 m_updateRevision++; 102 106 btAssert(childShapeIndex >=0 && childShapeIndex < m_children.size()); 103 107 if (m_dynamicAabbTree) … … 114 118 void btCompoundShape::removeChildShape(btCollisionShape* shape) 115 119 { 120 m_updateRevision++; 116 121 // Find the children containing the shape specified, and remove those children. 117 122 //note: there might be multiple children using the same shape! … … 140 145 // Recalculate the local aabb 141 146 // Brute force, it iterates over all the shapes left. 147 142 148 m_localAabbMin = btVector3(btScalar(1e30),btScalar(1e30),btScalar(1e30)); 143 149 m_localAabbMax = btVector3(btScalar(-1e30),btScalar(-1e30),btScalar(-1e30)); … … 162 168 { 163 169 btVector3 localHalfExtents = btScalar(0.5)*(m_localAabbMax-m_localAabbMin); 170 btVector3 localCenter = btScalar(0.5)*(m_localAabbMax+m_localAabbMin); 171 172 //avoid an illegal AABB when there are no children 173 if (!m_children.size()) 174 { 175 localHalfExtents.setValue(0,0,0); 176 localCenter.setValue(0,0,0); 177 } 164 178 localHalfExtents += btVector3(getMargin(),getMargin(),getMargin()); 165 btVector3 localCenter = btScalar(0.5)*(m_localAabbMax+m_localAabbMin);179 166 180 167 181 btMatrix3x3 abs_b = trans.getBasis().absolute(); … … 174 188 aabbMin = center-extent; 175 189 aabbMax = center+extent; 176 190 177 191 } 178 192
Note: See TracChangeset
for help on using the changeset viewer.