Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 23, 2011, 11:26:08 PM (13 years ago)
Author:
dafrick
Message:

Some cleanup. Ready for merge.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pickup/src/orxonox/collisionshapes/CompoundCollisionShape.cc

    r8422 r8554  
    261261        CollisionShape::changedScale();
    262262
    263         // Iterate through all attached CollisionShapes.
     263        std::vector<CollisionShape*> shapes;
     264        // Iterate through all attached CollisionShapes and add them to the list of shapes.
     265        for(std::map<CollisionShape*, btCollisionShape*>::iterator it = this->attachedShapes_.begin(); it != this->attachedShapes_.end(); it++)
     266            shapes.push_back(it->first);
     267
     268        // Delete the compound shape and create a new one.
     269        delete this->compoundShape_;
     270        this->compoundShape_ = new btCompoundShape();
     271
     272        // Re-attach all CollisionShapes.
     273        for(std::vector<CollisionShape*>::iterator it = shapes.begin(); it != shapes.end(); it++)
     274        {
     275            CollisionShape* shape = *it;
     276            shape->setScale3D(this->getScale3D());
     277            // Only actually attach if we didn't pick a CompoundCollisionShape with no content.
     278            if (shape->getCollisionShape())
     279            {
     280                btTransform transf(multi_cast<btQuaternion>(shape->getOrientation()), multi_cast<btVector3>(shape->getPosition()));
     281                // Add the btCollisionShape of the CollisionShape as a child shape to the btCompoundShape of the CompoundCollisionShape.
     282                this->compoundShape_->addChildShape(transf, shape->getCollisionShape());
     283            }
     284        }
     285
     286        this->updatePublicShape();
     287
     288        /*
     289        // Iterate through all attached CollisionShapes
    264290        for(std::map<CollisionShape*, btCollisionShape*>::const_iterator it = this->attachedShapes_.begin(); it != this->attachedShapes_.end(); it++)
    265291        {
     
    269295        }
    270296
    271         this->updatePublicShape();
     297        this->updatePublicShape();*/
    272298    }
    273299}
Note: See TracChangeset for help on using the changeset viewer.