Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2964


Ignore:
Timestamp:
May 11, 2009, 1:30:17 PM (15 years ago)
Author:
scheusso
Message:

changed synchronisation of controllable entity steering
not fully tested yet

Location:
code/branches/netp2/src/orxonox/objects/worldentities
Files:
2 edited

Legend:

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

    r2826 r2964  
    7171        this->changedGametype();
    7272
    73         this->server_position_         = Vector3::ZERO;
    74         this->client_position_         = Vector3::ZERO;
    75         this->server_linear_velocity_  = Vector3::ZERO;
    76         this->client_linear_velocity_  = Vector3::ZERO;
    77         this->server_orientation_      = Quaternion::IDENTITY;
    78         this->client_orientation_      = Quaternion::IDENTITY;
    79         this->server_angular_velocity_ = Vector3::ZERO;
    80         this->client_angular_velocity_ = Vector3::ZERO;
     73        this->common_position_         = Vector3::ZERO;
     74//         this->client_position_         = Vector3::ZERO;
     75        this->common_linear_velocity_  = Vector3::ZERO;
     76//         this->client_linear_velocity_  = Vector3::ZERO;
     77        this->common_orientation_      = Quaternion::IDENTITY;
     78//         this->client_orientation_      = Quaternion::IDENTITY;
     79        this->common_angular_velocity_ = Vector3::ZERO;
     80//         this->client_angular_velocity_ = Vector3::ZERO;
    8181
    8282
     
    340340            if (!this->isDynamic())
    341341            {
    342                 if (Core::isMaster())
    343                 {
    344                     this->server_position_ = this->getPosition();
    345                     this->server_orientation_ = this->getOrientation();
    346                     this->server_linear_velocity_ = this->getVelocity();
    347                     this->server_angular_velocity_ = this->getAngularVelocity();
    348                 }
    349                 else if (this->bHasLocalController_)
    350                 {
    351                     this->client_position_ = this->getPosition();
    352                     this->client_orientation_ = this->getOrientation();
    353                     this->client_linear_velocity_ = this->getVelocity();
    354                     this->client_angular_velocity_ = this->getAngularVelocity();
    355                 }
     342//                 if (Core::isMaster())
     343//                 {
     344                    this->common_position_ = this->getPosition();
     345                    this->common_orientation_ = this->getOrientation();
     346                    this->common_linear_velocity_ = this->getVelocity();
     347                    this->common_angular_velocity_ = this->getAngularVelocity();
     348//                 }
     349//                 else if (this->bHasLocalController_)
     350//                 {
     351//                     this->client_position_ = this->getPosition();
     352//                     this->client_orientation_ = this->getOrientation();
     353//                     this->client_linear_velocity_ = this->getVelocity();
     354//                     this->client_angular_velocity_ = this->getAngularVelocity();
     355//                 }
    356356            }
    357357        }
     
    363363        registerVariable(this->hudtemplate_,             variableDirection::toclient);
    364364
    365         registerVariable(this->server_position_,         variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition));
    366         registerVariable(this->server_linear_velocity_,  variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerLinearVelocity));
    367         registerVariable(this->server_orientation_,      variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation));
    368         registerVariable(this->server_angular_velocity_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerAngularVelocity));
    369 
    370         registerVariable(this->server_overwrite_,        variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite));
    371         registerVariable(this->client_overwrite_,        variableDirection::toserver);
    372 
    373         registerVariable(this->client_position_,         variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition));
    374         registerVariable(this->client_linear_velocity_,  variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientLinearVelocity));
    375         registerVariable(this->client_orientation_,      variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation));
    376         registerVariable(this->client_angular_velocity_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientAngularVelocity));
     365//         registerVariable(this->server_position_,         variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition));
     366//         registerVariable(this->server_linear_velocity_,  variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerLinearVelocity));
     367//         registerVariable(this->server_orientation_,      variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation));
     368//         registerVariable(this->server_angular_velocity_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerAngularVelocity));
     369//
     370//         registerVariable(this->server_overwrite_,        variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite));
     371//         registerVariable(this->client_overwrite_,        variableDirection::toserver);
     372//
     373//         registerVariable(this->client_position_,         variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition));
     374//         registerVariable(this->client_linear_velocity_,  variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientLinearVelocity));
     375//         registerVariable(this->client_orientation_,      variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation));
     376//         registerVariable(this->client_angular_velocity_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientAngularVelocity));
     377       
     378        registerVariable(this->common_position_,         variableDirection::serverMaster, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition), true);
     379        registerVariable(this->common_linear_velocity_,  variableDirection::serverMaster, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerLinearVelocity), true);
     380        registerVariable(this->common_orientation_,      variableDirection::serverMaster, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation), true);
     381        registerVariable(this->common_angular_velocity_, variableDirection::serverMaster, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerAngularVelocity), true);
    377382
    378383        registerVariable(this->playerID_,                variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID));
     
    383388    {
    384389        if (!this->bHasLocalController_)
    385             MobileEntity::setPosition(this->server_position_);
     390            MobileEntity::setPosition(this->common_position_);
    386391    }
    387392
     
    389394    {
    390395        if (!this->bHasLocalController_)
    391             MobileEntity::setVelocity(this->server_linear_velocity_);
     396            MobileEntity::setVelocity(this->common_linear_velocity_);
    392397    }
    393398
     
    395400    {
    396401        if (!this->bHasLocalController_)
    397             MobileEntity::setOrientation(this->server_orientation_);
     402            MobileEntity::setOrientation(this->common_orientation_);
    398403    }
    399404
     
    401406    {
    402407        if (!this->bHasLocalController_)
    403             MobileEntity::setAngularVelocity(this->server_angular_velocity_);
     408            MobileEntity::setAngularVelocity(this->common_angular_velocity_);
    404409    }
    405410
     
    408413        if (this->bHasLocalController_)
    409414        {
    410             this->setPosition(this->server_position_);
    411             this->setOrientation(this->server_orientation_);
    412             this->setVelocity(this->server_linear_velocity_);
    413             this->setAngularVelocity(this->server_angular_velocity_);
    414 
    415             this->client_overwrite_ = this->server_overwrite_;
     415//             this->setPosition(this->server_position_);
     416//             this->setOrientation(this->server_orientation_);
     417//             this->setVelocity(this->server_linear_velocity_);
     418//             this->setAngularVelocity(this->server_angular_velocity_);
     419
     420//             this->client_overwrite_ = this->server_overwrite_;
    416421        }
    417422    }
     
    421426        if (this->server_overwrite_ == this->client_overwrite_)
    422427        {
    423             MobileEntity::setPosition(this->client_position_);
    424             this->server_position_ = this->getPosition();
     428//             MobileEntity::setPosition(this->client_position_);
     429//             this->server_position_ = this->getPosition();
    425430        }
    426431    }
     
    430435        if (this->server_overwrite_ == this->client_overwrite_)
    431436        {
    432             MobileEntity::setVelocity(this->client_linear_velocity_);
    433             this->server_linear_velocity_ = this->getVelocity();
     437//             MobileEntity::setVelocity(this->client_linear_velocity_);
     438//             this->server_linear_velocity_ = this->getVelocity();
    434439        }
    435440    }
     
    439444        if (this->server_overwrite_ == this->client_overwrite_)
    440445        {
    441             MobileEntity::setOrientation(this->client_orientation_);
    442             this->server_orientation_ = this->getOrientation();
     446//             MobileEntity::setOrientation(this->client_orientation_);
     447//             this->server_orientation_ = this->getOrientation();
    443448        }
    444449    }
     
    448453        if (this->server_overwrite_ == this->client_overwrite_)
    449454        {
    450             MobileEntity::setAngularVelocity(this->client_angular_velocity_);
    451             this->server_angular_velocity_ = this->getAngularVelocity();
     455//             MobileEntity::setAngularVelocity(this->client_angular_velocity_);
     456//             this->server_angular_velocity_ = this->getAngularVelocity();
    452457        }
    453458    }
     
    455460    void ControllableEntity::setPosition(const Vector3& position)
    456461    {
    457         if (Core::isMaster())
    458         {
     462//         if (Core::isMaster())
     463//         {
    459464            MobileEntity::setPosition(position);
    460             this->server_position_ = this->getPosition();
    461             ++this->server_overwrite_;
    462         }
    463         else if (this->bHasLocalController_)
    464         {
    465             MobileEntity::setPosition(position);
    466             this->client_position_ = this->getPosition();
    467         }
     465            this->common_position_ = this->getPosition();
     466//             ++this->server_overwrite_;
     467//         }
     468//         else if (this->bHasLocalController_)
     469//         {
     470//             MobileEntity::setPosition(position);
     471//             this->client_position_ = this->getPosition();
     472//         }
    468473    }
    469474
    470475    void ControllableEntity::setOrientation(const Quaternion& orientation)
    471476    {
    472         if (Core::isMaster())
    473         {
     477//         if (Core::isMaster())
     478//         {
    474479            MobileEntity::setOrientation(orientation);
    475             this->server_orientation_ = this->getOrientation();
    476             ++this->server_overwrite_;
    477         }
    478         else if (this->bHasLocalController_)
    479         {
    480             MobileEntity::setOrientation(orientation);
    481             this->client_orientation_ = this->getOrientation();
    482         }
     480            this->common_orientation_ = this->getOrientation();
     481//             ++this->server_overwrite_;
     482//         }
     483//         else if (this->bHasLocalController_)
     484//         {
     485//             MobileEntity::setOrientation(orientation);
     486//             this->client_orientation_ = this->getOrientation();
     487//         }
    483488    }
    484489
    485490    void ControllableEntity::setVelocity(const Vector3& velocity)
    486491    {
    487         if (Core::isMaster())
    488         {
     492//         if (Core::isMaster())
     493//         {
    489494            MobileEntity::setVelocity(velocity);
    490             this->server_linear_velocity_ = this->getVelocity();
    491             ++this->server_overwrite_;
    492         }
    493         else if (this->bHasLocalController_)
    494         {
    495             MobileEntity::setVelocity(velocity);
    496             this->client_linear_velocity_ = this->getVelocity();
    497         }
     495            this->common_linear_velocity_ = this->getVelocity();
     496//             ++this->server_overwrite_;
     497//         }
     498//         else if (this->bHasLocalController_)
     499//         {
     500//             MobileEntity::setVelocity(velocity);
     501//             this->client_linear_velocity_ = this->getVelocity();
     502//         }
    498503    }
    499504
    500505    void ControllableEntity::setAngularVelocity(const Vector3& velocity)
    501506    {
    502         if (Core::isMaster())
    503         {
     507//         if (Core::isMaster())
     508//         {
    504509            MobileEntity::setAngularVelocity(velocity);
    505             this->server_angular_velocity_ = this->getAngularVelocity();
    506             ++this->server_overwrite_;
    507         }
    508         else if (this->bHasLocalController_)
    509         {
    510             MobileEntity::setAngularVelocity(velocity);
    511             this->client_angular_velocity_ = this->getAngularVelocity();
    512         }
     510            this->common_angular_velocity_ = this->getAngularVelocity();
     511//             ++this->server_overwrite_;
     512//         }
     513//         else if (this->bHasLocalController_)
     514//         {
     515//             MobileEntity::setAngularVelocity(velocity);
     516//             this->client_angular_velocity_ = this->getAngularVelocity();
     517//         }
    513518    }
    514519
     
    516521    {
    517522        MobileEntity::setWorldTransform(worldTrans);
    518         if (Core::isMaster())
    519         {
    520             this->server_position_ = this->getPosition();
    521             this->server_orientation_ = this->getOrientation();
    522             this->server_linear_velocity_ = this->getVelocity();
    523             this->server_angular_velocity_ = this->getAngularVelocity();
    524         }
    525         else if (this->bHasLocalController_)
    526         {
    527             this->client_position_ = this->getPosition();
    528             this->client_orientation_ = this->getOrientation();
    529             this->client_linear_velocity_ = this->getVelocity();
    530             this->client_angular_velocity_ = this->getAngularVelocity();
    531         }
     523//         if (Core::isMaster())
     524//         {
     525            this->common_position_ = this->getPosition();
     526            this->common_orientation_ = this->getOrientation();
     527            this->common_linear_velocity_ = this->getVelocity();
     528            this->common_angular_velocity_ = this->getAngularVelocity();
     529//         }
     530//         else if (this->bHasLocalController_)
     531//         {
     532//             this->client_position_ = this->getPosition();
     533//             this->client_orientation_ = this->getOrientation();
     534//             this->client_linear_velocity_ = this->getVelocity();
     535//             this->client_angular_velocity_ = this->getAngularVelocity();
     536//         }
    532537    }
    533538}
  • code/branches/netp2/src/orxonox/objects/worldentities/ControllableEntity.h

    r2662 r2964  
    167167            bool bDestroyWhenPlayerLeft_;
    168168
    169             Vector3 server_position_;
    170             Vector3 client_position_;
    171             Vector3 server_linear_velocity_;
    172             Vector3 client_linear_velocity_;
    173             Quaternion server_orientation_;
    174             Quaternion client_orientation_;
    175             Vector3 server_angular_velocity_;
    176             Vector3 client_angular_velocity_;
     169//             Vector3 server_position_;
     170            Vector3 common_position_;
     171//             Vector3 client_position_;
     172//             Vector3 server_linear_velocity_;
     173//             Vector3 client_linear_velocity_;
     174            Vector3 common_linear_velocity_;
     175//             Quaternion server_orientation_;
     176//             Quaternion client_orientation_;
     177            Quaternion common_orientation_;
     178//             Vector3 server_angular_velocity_;
     179//             Vector3 client_angular_velocity_;
     180            Vector3 common_angular_velocity_;
    177181
    178182            PlayerInfo* player_;
Note: See TracChangeset for help on using the changeset viewer.