Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2469


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
Files:
5 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}
  • code/branches/presentation/src/orxonox/objects/worldentities/MobileEntity.cc

    r2459 r2469  
    5151        this->angularAcceleration_ = Vector3::ZERO;
    5252        this->angularVelocity_     = Vector3::ZERO;
     53
     54        this->registerVariables();
    5355    }
    5456
  • code/branches/presentation/src/orxonox/objects/worldentities/WorldEntity.cc

    r2466 r2469  
    7474        // Note: CompoundCollisionShape is a Synchronisable, but must not be synchronised.
    7575        //       All objects will get attached on the client anyway, so we don't need synchronisation.
    76         this->collisionShape_->suppressSynchronisation();
     76        this->collisionShape_->setWorldEntityParent(this);
    7777        this->collisionType_ = None;
    7878        this->collisionTypeSynchronised_ = None;
     
    459459    void WorldEntity::setScale3D(const Vector3& scale)
    460460    {
    461         if (this->hasPhysics())
     461        if (this->hasPhysics() && scale != Vector3::UNIT_SCALE)
    462462        {
    463463            CCOUT(2) << "Warning: Cannot set the scale of a physical object: Not yet implemented." << std::endl;
Note: See TracChangeset for help on using the changeset viewer.