Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 10, 2008, 11:33:58 PM (17 years ago)
Author:
rgrieder
Message:
  • Fixed issues with CollisionShape loading, handling and synchronisation.
  • Added eol-style native to PlaneCollisionShape
  • Unified treatment of configuring btCollisionShapes when parameters change
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/physics/src/orxonox/objects/worldentities/collisionshapes/CompoundCollisionShape.cc

    r2374 r2403  
    4444        RegisterObject(CompoundCollisionShape);
    4545
    46         this->collisionShape_ = 0;
    4746        this->compoundShape_  = new btCompoundShape();
    4847    }
     
    6766        if (this->collisionShape_)
    6867            return this->collisionShape_;
    69         else if (this->childShapes_.size() != 0)
     68        else if (!this->empty())
    7069            return this->compoundShape_;
    7170        else
     
    7574    void CompoundCollisionShape::addChildShape(CollisionShape* shape)
    7675    {
    77         if (!shape || !shape->getCollisionShape())
     76        if (!shape)
    7877            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);
    8279
    83         if (this->childShapes_.size() == 1 && this->childShapes_[0] && !this->childShapes_[0]->hasTransform())
     80        if (shape->getCollisionShape())
    8481        {
    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            }
    9296        }
    9397
Note: See TracChangeset for help on using the changeset viewer.