Changeset 2403 for code/branches/physics/src/orxonox/objects/worldentities/collisionshapes/CompoundCollisionShape.cc
- Timestamp:
- Dec 10, 2008, 11:33:58 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/physics/src/orxonox/objects/worldentities/collisionshapes/CompoundCollisionShape.cc
r2374 r2403 44 44 RegisterObject(CompoundCollisionShape); 45 45 46 this->collisionShape_ = 0;47 46 this->compoundShape_ = new btCompoundShape(); 48 47 } … … 67 66 if (this->collisionShape_) 68 67 return this->collisionShape_; 69 else if ( this->childShapes_.size() != 0)68 else if (!this->empty()) 70 69 return this->compoundShape_; 71 70 else … … 75 74 void CompoundCollisionShape::addChildShape(CollisionShape* shape) 76 75 { 77 if (!shape || !shape->getCollisionShape())76 if (!shape) 78 77 return; 79 assert(this->compoundShape_); 80 btTransform transf(omni_cast<btQuaternion>(shape->getOrientation()), omni_cast<btVector3>(shape->getPosition())); 81 this->compoundShape_->addChildShape(transf, shape->getCollisionShape()); 78 this->childShapes_.push_back(shape); 82 79 83 if ( this->childShapes_.size() == 1 && this->childShapes_[0] && !this->childShapes_[0]->hasTransform())80 if (shape->getCollisionShape()) 84 81 { 85 // --> Only shape to be added, no transform; add it directly 86 this->collisionShape_ = shape->getCollisionShape(); 87 } 88 else 89 { 90 // Make sure we use the compound shape 91 this->collisionShape_ = 0; 82 // Only actually attach if we didn't pick a CompoundCollisionShape with no content 83 btTransform transf(omni_cast<btQuaternion>(shape->getOrientation()), omni_cast<btVector3>(shape->getPosition())); 84 this->compoundShape_->addChildShape(transf, shape->getCollisionShape()); 85 86 if (this->childShapes_.size() == 1 && !this->childShapes_[0]->hasTransform()) 87 { 88 // --> Only shape to be added, no transform; add it directly 89 this->collisionShape_ = shape->getCollisionShape(); 90 } 91 else 92 { 93 // Make sure we use the compound shape when returning the btCollisionShape 94 this->collisionShape_ = 0; 95 } 92 96 } 93 97
Note: See TracChangeset
for help on using the changeset viewer.