Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 13, 2008, 4:14:36 PM (15 years ago)
Author:
rgrieder
Message:
  • Added detach functions to CollisionShapes
  • Added update functions across the CollisionShape hierarchy so that when you change the radius of a sphere, everything up to the WE gets updated.
  • Setting the btCollisionShape at run time doesn't work after all, fixed that (you can still do it, just a question of internals)
  • Improved network synchronisation
  • new WE function: addedToPhysicalWorld() to check whether we can still perform operations that are disallowed at run time (esp. StaticEntity)

Conclusively, I can say that right now, all operations considering physics should be handled automatically, bugs not withstanding.

File:
1 edited

Legend:

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

    r2403 r2423  
    7676    void CollisionShape::registerVariables()
    7777    {
    78         REGISTERDATA(this->parentID_, network::direction::toclient, new network::NetworkCallback<CollisionShape>(this, &CollisionShape::updateParent));
     78        REGISTERDATA(this->parentID_, network::direction::toclient, new network::NetworkCallback<CollisionShape>(this, &CollisionShape::parentChanged));
     79    }
     80
     81    void CollisionShape::parentChanged()
     82    {
     83        CompoundCollisionShape* parent = dynamic_cast<CompoundCollisionShape*>(Synchronisable::getSynchronisable(this->parentID_));
     84        if (parent)
     85            parent->addChildShape(this);
    7986    }
    8087
    8188    void CollisionShape::updateParent()
    8289    {
    83         CompoundCollisionShape* parent = dynamic_cast<CompoundCollisionShape*>(Synchronisable::getSynchronisable(this->parentID_));
    84         if (parent)
    85             parent->addChildShape(this);
     90        if (this->parent_)
     91            this->parent_->updateChildShape(this);
    8692    }
    8793
     
    95101    {
    96102        ThrowException(NotImplemented, "Cannot set the scale of a collision shape: Not yet implemented.");
     103        this->updateParent();
    97104    }
    98105
     
    100107    {
    101108        ThrowException(NotImplemented, "Cannot set the scale of a collision shape: Not yet implemented.");
     109        this->updateParent();
     110    }
     111
     112    btVector3 CollisionShape::getLocalInertia(btScalar mass) const
     113    {
     114        btVector3 inertia(0, 0, 0);
     115        if (this->collisionShape_)
     116            this->collisionShape_->calculateLocalInertia(mass, inertia);
     117        return inertia;
    102118    }
    103119}
Note: See TracChangeset for help on using the changeset viewer.