Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 15, 2008, 7:57:48 PM (16 years ago)
Author:
rgrieder
Message:

Resolved the issue with the collision shape synchronisation.

Location:
code/branches/presentation/src/orxonox/objects/collisionshapes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation/src/orxonox/objects/collisionshapes/CollisionShape.cc

    r2459 r2469  
    3838
    3939#include "CompoundCollisionShape.h"
     40#include "objects/worldentities/WorldEntity.h"
    4041
    4142namespace orxonox
     
    5556        this->orientation_ = Quaternion::IDENTITY;
    5657        this->scale_ = Vector3::UNIT_SCALE;
     58
     59        this->registerVariables();
    5760    }
    5861
     
    8184    void CollisionShape::parentChanged()
    8285    {
    83         CompoundCollisionShape* parent = dynamic_cast<CompoundCollisionShape*>(Synchronisable::getSynchronisable(this->parentID_));
    84         if (parent)
    85             parent->addChildShape(this);
     86        Synchronisable* synchronisable = Synchronisable::getSynchronisable(this->parentID_);
     87        CompoundCollisionShape* CCSparent = dynamic_cast<CompoundCollisionShape*>(synchronisable);
     88        if (CCSparent)
     89            CCSparent->addChildShape(this);
     90        else
     91        {
     92            WorldEntity* WEparent = dynamic_cast<WorldEntity*>(synchronisable);
     93            if (WEparent)
     94                WEparent->attachCollisionShape(this);
     95        }
    8696    }
    8797
  • code/branches/presentation/src/orxonox/objects/collisionshapes/CompoundCollisionShape.cc

    r2463 r2469  
    4747
    4848        this->compoundShape_  = new btCompoundShape();
     49        this->worldEntityParent_ = 0;
    4950    }
    5051
     
    6667    }
    6768
     69    void CompoundCollisionShape::setWorldEntityParent(WorldEntity* parent)
     70    {
     71        // suppress synchronisation
     72        this->setObjectMode(0x0);
     73
     74        this->worldEntityParent_ = parent;
     75    }
     76
    6877    void CompoundCollisionShape::addChildShape(CollisionShape* shape)
    6978    {
     
    8796
    8897        // network synchro
    89         shape->setParent(this, this->getObjectID());
     98        if (this->worldEntityParent_)
     99        {
     100            // This compound collision shape belongs to a WE and doesn't get synchronised
     101            // So set our parent to be the WE
     102            shape->setParent(this, this->worldEntityParent_->getObjectID());
     103        }
     104        else
     105            shape->setParent(this, this->getObjectID());
    90106    }
    91107
     
    176192        if (this->parent_)
    177193            this->parent_->updateChildShape(this);
    178         else
    179         {
    180             // We can do this, because the CompoundCollisionShape of a WorldEntity always belongs to it,
    181             // as long as its lifetime.
    182             WorldEntity* parent = dynamic_cast<WorldEntity*>(this->getCreator());
    183             if (parent)
    184                 parent->notifyCollisionShapeChanged();
    185         }
     194        else if (this->worldEntityParent_)
     195            this->worldEntityParent_->notifyCollisionShapeChanged();
    186196    }
    187197
  • code/branches/presentation/src/orxonox/objects/collisionshapes/CompoundCollisionShape.h

    r2465 r2469  
    5252            void updateChildShape(CollisionShape* shape);
    5353
    54             inline void suppressSynchronisation()
    55                 { this->setObjectMode(0x0); }
     54            void setWorldEntityParent(WorldEntity* parent);
    5655
    5756        protected:
     
    6362            btCompoundShape* compoundShape_;
    6463            std::map<CollisionShape*, btCollisionShape*> childShapes_;
     64            WorldEntity* worldEntityParent_;
    6565    };
    6666}
Note: See TracChangeset for help on using the changeset viewer.