Changeset 2374 for code/branches/physics/src/orxonox/objects/worldentities/collisionshapes/CompoundCollisionShape.cc
- Timestamp:
- Dec 10, 2008, 1:38:17 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/physics/src/orxonox/objects/worldentities/collisionshapes/CompoundCollisionShape.cc
r2304 r2374 44 44 RegisterObject(CompoundCollisionShape); 45 45 46 this-> bIsCompound_ = true;46 this->collisionShape_ = 0; 47 47 this->compoundShape_ = new btCompoundShape(); 48 this->collisionShape_ = this->compoundShape_;49 48 } 50 49 … … 58 57 { 59 58 SUPER(CompoundCollisionShape, XMLPort, xmlelement, mode); 59 // Attached collision shapes 60 XMLPortObject(CompoundCollisionShape, CollisionShape, "", addChildShape, getChildShape, xmlelement, mode); 61 } 60 62 61 XMLPortObject(CompoundCollisionShape, CollisionShape, "", addChildShape, getChildShape, xmlelement, mode); 63 btCollisionShape* CompoundCollisionShape::getCollisionShape() const 64 { 65 // Note: Returning collisionShape_ means that it's the only one and has no transform. 66 // So we can get rid of the additional overhead with the compound shape. 67 if (this->collisionShape_) 68 return this->collisionShape_; 69 else if (this->childShapes_.size() != 0) 70 return this->compoundShape_; 71 else 72 return 0; 62 73 } 63 74 64 75 void CompoundCollisionShape::addChildShape(CollisionShape* shape) 65 76 { 66 this->childShapes_.push_back(shape); 77 if (!shape || !shape->getCollisionShape()) 78 return; 79 assert(this->compoundShape_); 67 80 btTransform transf(omni_cast<btQuaternion>(shape->getOrientation()), omni_cast<btVector3>(shape->getPosition())); 68 shape->getCollisionShape()->setLocalScaling(shape->getTotalScaling());69 81 this->compoundShape_->addChildShape(transf, shape->getCollisionShape()); 82 83 if (this->childShapes_.size() == 1 && this->childShapes_[0] && !this->childShapes_[0]->hasTransform()) 84 { 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; 92 } 93 94 // network synchro 95 shape->setParent(this, this->getObjectID()); 70 96 } 71 97
Note: See TracChangeset
for help on using the changeset viewer.