Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 1, 2009, 7:34:44 PM (15 years ago)
Author:
rgrieder
Message:
  • Added WorldEntityCollisionShape to clarify when a CompoundCollisionShape belongs to a WE.
  • Also fixed problems with the synchronisation of the CollisionShape hierarchy.
File:
1 edited

Legend:

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

    r2527 r2562  
    3737#include "tools/BulletConversions.h"
    3838
     39#include "objects/worldentities/WorldEntity.h"
    3940#include "CompoundCollisionShape.h"
    40 #include "objects/worldentities/WorldEntity.h"
     41#include "WorldEntityCollisionShape.h"
    4142
    4243namespace orxonox
     
    8586    void CollisionShape::parentChanged()
    8687    {
    87         CompoundCollisionShape* parent = dynamic_cast<CompoundCollisionShape*>(Synchronisable::getSynchronisable(this->parentID_));
    88         if (parent)
    89             parent->attach(this);
     88        Synchronisable* parent = Synchronisable::getSynchronisable(this->parentID_);
     89        // Parent can either be a WorldEntity or a CompoundCollisionShape. The reason is that the
     90        // internal collision shape (which is compound) of a WE doesn't get synchronised.
     91        CompoundCollisionShape* parentCCS = dynamic_cast<CompoundCollisionShape*>(parent);
     92        if (parentCCS)
     93            parentCCS->attach(this);
     94        else
     95        {
     96            WorldEntity* parentWE = dynamic_cast<WorldEntity*>(parent);
     97            if (parentWE)
     98                parentWE->attachCollisionShape(this);
     99        }
     100    }
     101
     102    bool CollisionShape::notifyBeingAttached(CompoundCollisionShape* newParent)
     103    {
     104        if (this->parent_)
     105            this->parent_->detach(this);
     106
     107        this->parent_ = newParent;
     108
     109        WorldEntityCollisionShape* parentWECCS = dynamic_cast<WorldEntityCollisionShape*>(newParent);
     110        if (parentWECCS)
     111            this->parentID_ = parentWECCS->getWorldEntityOwner()->getObjectID();
     112        else
     113            this->parentID_ = newParent->getObjectID();
     114
     115        return true;
     116    }
     117
     118    void CollisionShape::notifyDetached()
     119    {
     120        this->parent_ = 0;
     121        this->parentID_ = OBJECTID_UNKNOWN;
    90122    }
    91123
Note: See TracChangeset for help on using the changeset viewer.