Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 10, 2008, 1:38:17 PM (17 years ago)
Author:
rgrieder
Message:

Trying to synchronise phyiscs over the network.

  • Removed derivation of CollisionShape from WorldEntity (BaseObject instead).
File:
1 edited

Legend:

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

    r2304 r2374  
    4444        RegisterObject(CompoundCollisionShape);
    4545
    46         this->bIsCompound_    = true;
     46        this->collisionShape_ = 0;
    4747        this->compoundShape_  = new btCompoundShape();
    48         this->collisionShape_ = this->compoundShape_;
    4948    }
    5049
     
    5857    {
    5958        SUPER(CompoundCollisionShape, XMLPort, xmlelement, mode);
     59        // Attached collision shapes
     60        XMLPortObject(CompoundCollisionShape, CollisionShape, "", addChildShape, getChildShape, xmlelement, mode);
     61    }
    6062
    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;
    6273    }
    6374
    6475    void CompoundCollisionShape::addChildShape(CollisionShape* shape)
    6576    {
    66         this->childShapes_.push_back(shape);
     77        if (!shape || !shape->getCollisionShape())
     78            return;
     79        assert(this->compoundShape_);
    6780        btTransform transf(omni_cast<btQuaternion>(shape->getOrientation()), omni_cast<btVector3>(shape->getPosition()));
    68         shape->getCollisionShape()->setLocalScaling(shape->getTotalScaling());
    6981        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());
    7096    }
    7197
Note: See TracChangeset for help on using the changeset viewer.