Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 10, 2008, 12:05:03 AM (17 years ago)
Author:
landauf
Message:

merged revisions 2111-2170 from objecthierarchy branch back to trunk.

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/objects/worldentities/WorldEntity.cc

    r2087 r2171  
    3636#include "core/XMLPort.h"
    3737#include "util/Convert.h"
     38#include "util/Exception.h"
    3839
    3940#include "objects/Scene.h"
     
    4849    const Vector3 WorldEntity::UP    = Vector3::UNIT_Y;
    4950
    50     WorldEntity::WorldEntity(BaseObject* creator) : BaseObject(creator), network::Synchronisable(creator)
     51    WorldEntity::WorldEntity(BaseObject* creator) : BaseObject(creator), Synchronisable(creator)
    5152    {
    5253        RegisterObject(WorldEntity);
    5354
    54         assert(this->getScene());
    55         assert(this->getScene()->getRootSceneNode());
     55        if (!this->getScene() || !this->getScene()->getRootSceneNode())
     56            ThrowException(AbortLoading, "Can't create WorldEntity, no scene or no root-scenenode given.");
    5657
    5758        this->node_ = this->getScene()->getRootSceneNode()->createChildSceneNode();
    5859
    5960        this->parent_ = 0;
    60         this->parentID_ = (unsigned int)-1;
     61        this->parentID_ = OBJECTID_UNKNOWN;
    6162
    6263        this->node_->setPosition(Vector3::ZERO);
     
    9596    void WorldEntity::registerVariables()
    9697    {
    97         REGISTERDATA(this->bActive_,  network::direction::toclient, new network::NetworkCallback<WorldEntity>(this, &WorldEntity::changedActivity));
    98         REGISTERDATA(this->bVisible_, network::direction::toclient, new network::NetworkCallback<WorldEntity>(this, &WorldEntity::changedVisibility));
     98        REGISTERDATA(this->bActive_,  direction::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedActivity));
     99        REGISTERDATA(this->bVisible_, direction::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedVisibility));
    99100
    100         REGISTERDATA(this->getScale3D().x, network::direction::toclient);
    101         REGISTERDATA(this->getScale3D().y, network::direction::toclient);
    102         REGISTERDATA(this->getScale3D().z, network::direction::toclient);
     101        REGISTERDATA(this->getScale3D().x, direction::toclient);
     102        REGISTERDATA(this->getScale3D().y, direction::toclient);
     103        REGISTERDATA(this->getScale3D().z, direction::toclient);
    103104
    104         REGISTERDATA(this->parentID_, network::direction::toclient, new network::NetworkCallback<WorldEntity>(this, &WorldEntity::updateParent));
     105        REGISTERDATA(this->parentID_, direction::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::updateParent));
    105106    }
    106107
    107108    void WorldEntity::updateParent()
    108109    {
    109         WorldEntity* parent = dynamic_cast<WorldEntity*>(Synchronisable::getSynchronisable(this->parentID_));
    110         if (parent)
    111             this->attachToParent(parent);
     110        if (this->parentID_ != OBJECTID_UNKNOWN)
     111        {
     112            WorldEntity* parent = dynamic_cast<WorldEntity*>(Synchronisable::getSynchronisable(this->parentID_));
     113            if (parent)
     114                this->attachToParent(parent);
     115        }
    112116    }
    113117
     
    134138        this->children_.erase(object);
    135139        object->parent_ = 0;
    136         object->parentID_ = (unsigned int)-1;
     140        object->parentID_ = OBJECTID_UNKNOWN;
    137141
    138142//        this->getScene()->getRootSceneNode()->addChild(object->node_);
Note: See TracChangeset for help on using the changeset viewer.