Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 11, 2008, 1:54:35 PM (16 years ago)
Author:
rgrieder
Message:
  • Removed debug output
  • Fixed a bug with parentID_ in CollisionShape
  • Reactivated overwrite mechanism in ControllableEntity
  • Build fix in WE for last commit.
Location:
code/branches/physics/src/orxonox/objects/worldentities
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/branches/physics/src/orxonox/objects/worldentities/ControllableEntity.cc

    r2374 r2407  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      ...
     25 *      Reto Grieder
    2626 *
    2727 */
     
    256256    {
    257257        if (!this->bControlled_)
    258         {
    259             //COUT(0) << "override with server position: " << this << std::endl;
    260258            this->setPosition(this->server_position_);
    261         }
    262259    }
    263260
     
    282279    void ControllableEntity::processOverwrite()
    283280    {
    284         //if (this->bControlled_)
    285         //{
    286         //    COUT(0) << "complete override: " << this << std::endl;
    287         //    this->setPosition(this->server_position_);
    288         //    this->setVelocity(this->server_velocity_);
    289         //    this->setOrientation(this->server_orientation_);
    290 
    291         //    this->client_overwrite_ = this->server_overwrite_;
    292         //}
     281        if (this->bControlled_)
     282        {
     283            this->setPosition(this->server_position_);
     284            this->setOrientation(this->server_orientation_);
     285            this->setVelocity(this->server_linear_velocity_);
     286            this->setAngularVelocity(this->server_angular_velocity_);
     287
     288            this->client_overwrite_ = this->server_overwrite_;
     289        }
    293290    }
    294291
    295292    void ControllableEntity::processClientPosition()
    296293    {
    297         //if (this->server_overwrite_ == this->client_overwrite_)
    298         if (!this->bControlled_)
    299         {
    300             //COUT(0) << "override with client position: " << this << std::endl;
    301 //            COUT(2) << "callback: setting client position" << endl;
     294        if (this->server_overwrite_ == this->client_overwrite_)
     295        {
    302296            this->setPosition(this->client_position_);
    303             //this->server_position_ = this->client_position_;
    304         }
    305         //else
    306         //  COUT(2) << "callback: not setting client position" << endl;
     297            // The call above increments the overwrite. This is not desired to reduce traffic
     298            --this->server_overwrite_;
     299        }
    307300    }
    308301
    309302    void ControllableEntity::processClientLinearVelocity()
    310303    {
    311         if (!this->bControlled_)
    312         //if (this->server_overwrite_ == this->client_overwrite_)
     304        if (this->server_overwrite_ == this->client_overwrite_)
    313305        {
    314306            this->setVelocity(this->client_linear_velocity_);
    315             //this->server_velocity_ = this->client_velocity_;
     307            // The call above increments the overwrite. This is not desired to reduce traffic
     308            --this->server_overwrite_;
    316309        }
    317310    }
     
    319312    void ControllableEntity::processClientOrientation()
    320313    {
    321         if (!this->bControlled_)
    322         //if (this->server_overwrite_ == this->client_overwrite_)
     314        if (this->server_overwrite_ == this->client_overwrite_)
    323315        {
    324316            this->setOrientation(this->client_orientation_);
    325             //this->server_orientation_ = this->client_orientation_;
     317            // The call above increments the overwrite. This is not desired to reduce traffic
     318            --this->server_overwrite_;
    326319        }
    327320    }
     
    329322    void ControllableEntity::processClientAngularVelocity()
    330323    {
    331         if (!this->bControlled_)
    332         //if (this->server_overwrite_ == this->client_overwrite_)
     324        if (this->server_overwrite_ == this->client_overwrite_)
    333325        {
    334326            this->setAngularVelocity(this->client_angular_velocity_);
    335             //this->server_velocity_ = this->client_velocity_;
     327            // The call above increments the overwrite. This is not desired to reduce traffic
     328            --this->server_overwrite_;
    336329        }
    337330    }
     
    342335        {
    343336            this->server_position_ = this->getPosition();
    344             ++this->server_overwrite_;
     337            if (!bContinuous)
     338                ++this->server_overwrite_;
    345339        }
    346340        else if (this->bControlled_)
     
    355349        {
    356350            this->server_orientation_ = this->getOrientation();
    357             ++this->server_overwrite_;
     351            if (!bContinuous)
     352                ++this->server_overwrite_;
    358353        }
    359354        else if (this->bControlled_)
     
    368363        {
    369364            this->server_linear_velocity_ = this->getVelocity();
    370             ++this->server_overwrite_;
     365            if (!bContinuous)
     366                ++this->server_overwrite_;
    371367        }
    372368        else if (this->bControlled_)
     
    381377        {
    382378            this->server_angular_velocity_ = this->getAngularVelocity();
    383             ++this->server_overwrite_;
     379            if (!bContinuous)
     380                ++this->server_overwrite_;
    384381        }
    385382        else if (this->bControlled_)
  • code/branches/physics/src/orxonox/objects/worldentities/ControllableEntity.h

    r2374 r2407  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      ...
     25 *      Reto Grieder
    2626 *
    2727 */
  • code/branches/physics/src/orxonox/objects/worldentities/LinearEntity.cc

    r2374 r2407  
    8080    void LinearEntity::overwritePosition()
    8181    {
    82         //COUT(0) << "Setting position on client: " << this->overwrite_position_ << std::endl;
    8382        this->setPosition(this->overwrite_position_);
    8483    }
     
    8685    void LinearEntity::overwriteOrientation()
    8786    {
    88         //COUT(0) << "Setting orientation on client: " << this->overwrite_orientation_ << std::endl;
    8987        this->setOrientation(this->overwrite_orientation_);
    9088    }
     
    109107    {
    110108        if (!bContinuous)
    111         {
    112             //if (Core::isMaster())
    113             //    COUT(0) << "Setting position on server: " << this->getPosition() << std::endl;
    114109            this->overwrite_position_ = this->getPosition();
    115         }
    116110    }
    117111
     
    119113    {
    120114        if (!bContinuous)
    121         {
    122             //if (Core::isMaster())
    123             //    COUT(0) << "Setting orientation on server: " << this->getOrientation() << std::endl;
    124115            this->overwrite_orientation_ = this->getOrientation();
    125         }
    126116    }
    127117}
  • code/branches/physics/src/orxonox/objects/worldentities/MovableEntity.cc

    r2374 r2407  
    108108        if (this->isDynamic())
    109109        {
    110             //if (this->isPhysicsRunning())
    111             //    return;
    112110            btTransform transf = this->physicalBody_->getWorldTransform();
    113111            transf.setOrigin(btVector3(position.x, position.y, position.z));
     
    115113        }
    116114
    117         //COUT(0) << "setting position: " << position << std::endl;
    118115        this->node_->setPosition(position);
    119116        positionChanged(false);
     
    212209            OrxAssert(relativeTo == Ogre::Node::TS_LOCAL, "Cannot align physical object relative \
    213210                                                          to any other space than TS_LOCAL.");
    214             //btTransform transf = this->physicalBody_->getWorldTransform();
    215             //this->physicalBody_->setWorldTransform(transf);
    216211        }
    217212
     
    227222            OrxAssert(relativeTo == Ogre::Node::TS_LOCAL, "Cannot align physical object relative \
    228223                                                          to any other space than TS_LOCAL.");
    229             //btTransform transf = this->physicalBody_->getWorldTransform();
    230             //this->physicalBody_->setWorldTransform(transf);
    231224        }
    232225
     
    288281        this->node_->setPosition(Vector3(worldTrans.getOrigin().x(), worldTrans.getOrigin().y(), worldTrans.getOrigin().z()));
    289282        this->node_->setOrientation(Quaternion(worldTrans.getRotation().w(), worldTrans.getRotation().x(), worldTrans.getRotation().y(), worldTrans.getRotation().z()));
    290         COUT(0) << "setting world transform: " << omni_cast<std::string>(node_->getPosition()) << std::endl;
    291283        this->linearVelocity_.x = this->physicalBody_->getLinearVelocity().x();
    292284        this->linearVelocity_.y = this->physicalBody_->getLinearVelocity().y();
  • code/branches/physics/src/orxonox/objects/worldentities/MovableEntity.h

    r2374 r2407  
    108108
    109109        private:
    110             virtual void positionChanged       (bool bContinuous) { }
    111             virtual void orientationChanged    (bool bContinuous) { }
     110            virtual void positionChanged       (bool bContinuous) = 0;
     111            virtual void orientationChanged    (bool bContinuous) = 0;
    112112            virtual void linearVelocityChanged (bool bContinuous) { }
    113113            virtual void angularVelocityChanged(bool bContinuous) { }
  • code/branches/physics/src/orxonox/objects/worldentities/WorldEntity.cc

    r2374 r2407  
    4444
    4545#include "objects/Scene.h"
    46 #include "objects/worldentities/collisionshapes/CollisionShape.h"
    47 #include "objects/worldentities/collisionshapes/CompoundCollisionShape.h"
     46#include "objects/collisionshapes/CollisionShape.h"
     47#include "objects/collisionshapes/CompoundCollisionShape.h"
    4848
    4949namespace orxonox
     
    191191                // static to static/kinematic/dynamic --> merge shapes
    192192                this->childMass_ += object->getMass();
    193                 this->attachCollisionShape(object->getCollisionShape());
     193                this->attachCollisionShape(object->getCollisionShape(), true);
    194194                // Remove the btRigidBody from the child object.
    195195                // That also implies that cannot add a physics WE to the child afterwards.
     
    237237    }
    238238
    239     void WorldEntity::attachCollisionShape(CollisionShape* shape)
    240     {
    241         this->collisionShape_->addChildShape(shape);
     239    void WorldEntity::attachCollisionShape(CollisionShape* shape, bool bWorldEntityRoot)
     240    {
     241        this->collisionShape_->addChildShape(shape, bWorldEntityRoot);
    242242
    243243        if (this->physicalBody_)
  • code/branches/physics/src/orxonox/objects/worldentities/WorldEntity.h

    r2374 r2407  
    202202                { return this->mass_; }
    203203
    204             void attachCollisionShape(CollisionShape* shape);
     204            void attachCollisionShape(CollisionShape* shape, bool bWorldEntityRoot = false);
    205205            CollisionShape* getAttachedCollisionShape(unsigned int index) const;
    206206
Note: See TracChangeset for help on using the changeset viewer.