Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 19, 2009, 9:35:10 PM (15 years ago)
Author:
scheusso
Message:

merged netp2 → netp3

Location:
code/branches/netp3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/netp3

  • code/branches/netp3/src/orxonox/objects/worldentities/ControllableEntity.cc

    r2973 r2990  
    6666        this->mouseLookSpeed_ = 200;
    6767
    68         this->server_position_         = Vector3::ZERO;
    69         this->client_position_         = Vector3::ZERO;
    70         this->server_linear_velocity_  = Vector3::ZERO;
    71         this->client_linear_velocity_  = Vector3::ZERO;
    72         this->server_orientation_      = Quaternion::IDENTITY;
    73         this->client_orientation_      = Quaternion::IDENTITY;
    74         this->server_angular_velocity_ = Vector3::ZERO;
    75         this->client_angular_velocity_ = Vector3::ZERO;
     68        this->common_position_         = Vector3::ZERO;
     69//         this->client_position_         = Vector3::ZERO;
     70        this->common_linear_velocity_  = Vector3::ZERO;
     71//         this->client_linear_velocity_  = Vector3::ZERO;
     72        this->common_orientation_      = Quaternion::IDENTITY;
     73//         this->client_orientation_      = Quaternion::IDENTITY;
     74        this->common_angular_velocity_ = Vector3::ZERO;
     75//         this->client_angular_velocity_ = Vector3::ZERO;
    7676
    7777
     
    326326            if (!this->isDynamic())
    327327            {
    328                 if (GameMode::isMaster())
    329                 {
    330                     this->server_position_ = this->getPosition();
    331                     this->server_orientation_ = this->getOrientation();
    332                     this->server_linear_velocity_ = this->getVelocity();
    333                     this->server_angular_velocity_ = this->getAngularVelocity();
    334                 }
    335                 else if (this->bHasLocalController_)
    336                 {
    337                     this->client_position_ = this->getPosition();
    338                     this->client_orientation_ = this->getOrientation();
    339                     this->client_linear_velocity_ = this->getVelocity();
    340                     this->client_angular_velocity_ = this->getAngularVelocity();
    341                 }
     328//                 if (GameMode::isMaster())
     329//                 {
     330                    this->common_position_ = this->getPosition();
     331                    this->common_orientation_ = this->getOrientation();
     332                    this->common_linear_velocity_ = this->getVelocity();
     333                    this->common_angular_velocity_ = this->getAngularVelocity();
     334//                 }
     335//                 else if (this->bHasLocalController_)
     336//                 {
     337//                     this->client_position_ = this->getPosition();
     338//                     this->client_orientation_ = this->getOrientation();
     339//                     this->client_linear_velocity_ = this->getVelocity();
     340//                     this->client_angular_velocity_ = this->getAngularVelocity();
     341//                 }
    342342            }
    343343        }
     
    349349        registerVariable(this->hudtemplate_,             variableDirection::toclient);
    350350
    351         registerVariable(this->server_position_,         variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition));
    352         registerVariable(this->server_linear_velocity_,  variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerLinearVelocity));
    353         registerVariable(this->server_orientation_,      variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation));
    354         registerVariable(this->server_angular_velocity_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerAngularVelocity));
    355 
    356         registerVariable(this->server_overwrite_,        variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite));
    357         registerVariable(this->client_overwrite_,        variableDirection::toserver);
    358 
    359         registerVariable(this->client_position_,         variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition));
    360         registerVariable(this->client_linear_velocity_,  variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientLinearVelocity));
    361         registerVariable(this->client_orientation_,      variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation));
    362         registerVariable(this->client_angular_velocity_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientAngularVelocity));
     351//         registerVariable(this->server_position_,         variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition));
     352//         registerVariable(this->server_linear_velocity_,  variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerLinearVelocity));
     353//         registerVariable(this->server_orientation_,      variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation));
     354//         registerVariable(this->server_angular_velocity_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerAngularVelocity));
     355//
     356//         registerVariable(this->server_overwrite_,        variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite));
     357//         registerVariable(this->client_overwrite_,        variableDirection::toserver);
     358//
     359//         registerVariable(this->client_position_,         variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition));
     360//         registerVariable(this->client_linear_velocity_,  variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientLinearVelocity));
     361//         registerVariable(this->client_orientation_,      variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation));
     362//         registerVariable(this->client_angular_velocity_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientAngularVelocity));
     363       
     364        registerVariable(this->common_position_,         variableDirection::serverMaster, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition), true);
     365        registerVariable(this->common_linear_velocity_,  variableDirection::serverMaster, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerLinearVelocity), true);
     366        registerVariable(this->common_orientation_,      variableDirection::serverMaster, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation), true);
     367        registerVariable(this->common_angular_velocity_, variableDirection::serverMaster, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerAngularVelocity), true);
    363368
    364369        registerVariable(this->playerID_,                variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID));
     
    368373    {
    369374        if (!this->bHasLocalController_)
    370             MobileEntity::setPosition(this->server_position_);
     375            MobileEntity::setPosition(this->common_position_);
    371376    }
    372377
     
    374379    {
    375380        if (!this->bHasLocalController_)
    376             MobileEntity::setVelocity(this->server_linear_velocity_);
     381            MobileEntity::setVelocity(this->common_linear_velocity_);
    377382    }
    378383
     
    380385    {
    381386        if (!this->bHasLocalController_)
    382             MobileEntity::setOrientation(this->server_orientation_);
     387            MobileEntity::setOrientation(this->common_orientation_);
    383388    }
    384389
     
    386391    {
    387392        if (!this->bHasLocalController_)
    388             MobileEntity::setAngularVelocity(this->server_angular_velocity_);
     393            MobileEntity::setAngularVelocity(this->common_angular_velocity_);
    389394    }
    390395
     
    393398        if (this->bHasLocalController_)
    394399        {
    395             this->setPosition(this->server_position_);
    396             this->setOrientation(this->server_orientation_);
    397             this->setVelocity(this->server_linear_velocity_);
    398             this->setAngularVelocity(this->server_angular_velocity_);
    399 
    400             this->client_overwrite_ = this->server_overwrite_;
     400//             this->setPosition(this->server_position_);
     401//             this->setOrientation(this->server_orientation_);
     402//             this->setVelocity(this->server_linear_velocity_);
     403//             this->setAngularVelocity(this->server_angular_velocity_);
     404
     405//             this->client_overwrite_ = this->server_overwrite_;
    401406        }
    402407    }
     
    406411        if (this->server_overwrite_ == this->client_overwrite_)
    407412        {
    408             MobileEntity::setPosition(this->client_position_);
    409             this->server_position_ = this->getPosition();
     413//             MobileEntity::setPosition(this->client_position_);
     414//             this->server_position_ = this->getPosition();
    410415        }
    411416    }
     
    415420        if (this->server_overwrite_ == this->client_overwrite_)
    416421        {
    417             MobileEntity::setVelocity(this->client_linear_velocity_);
    418             this->server_linear_velocity_ = this->getVelocity();
     422//             MobileEntity::setVelocity(this->client_linear_velocity_);
     423//             this->server_linear_velocity_ = this->getVelocity();
    419424        }
    420425    }
     
    424429        if (this->server_overwrite_ == this->client_overwrite_)
    425430        {
    426             MobileEntity::setOrientation(this->client_orientation_);
    427             this->server_orientation_ = this->getOrientation();
     431//             MobileEntity::setOrientation(this->client_orientation_);
     432//             this->server_orientation_ = this->getOrientation();
    428433        }
    429434    }
     
    433438        if (this->server_overwrite_ == this->client_overwrite_)
    434439        {
    435             MobileEntity::setAngularVelocity(this->client_angular_velocity_);
    436             this->server_angular_velocity_ = this->getAngularVelocity();
     440//             MobileEntity::setAngularVelocity(this->client_angular_velocity_);
     441//             this->server_angular_velocity_ = this->getAngularVelocity();
    437442        }
    438443    }
     
    440445    void ControllableEntity::setPosition(const Vector3& position)
    441446    {
    442         if (GameMode::isMaster())
    443         {
     447//         if (GameMode::isMaster())
     448//         {
    444449            MobileEntity::setPosition(position);
    445             this->server_position_ = this->getPosition();
    446             ++this->server_overwrite_;
    447         }
    448         else if (this->bHasLocalController_)
    449         {
    450             MobileEntity::setPosition(position);
    451             this->client_position_ = this->getPosition();
    452         }
     450            this->common_position_ = this->getPosition();
     451//             ++this->server_overwrite_;
     452//         }
     453//         else if (this->bHasLocalController_)
     454//         {
     455//             MobileEntity::setPosition(position);
     456//             this->client_position_ = this->getPosition();
     457//         }
    453458    }
    454459
    455460    void ControllableEntity::setOrientation(const Quaternion& orientation)
    456461    {
    457         if (GameMode::isMaster())
    458         {
     462//         if (GameMode::isMaster())
     463//         {
    459464            MobileEntity::setOrientation(orientation);
    460             this->server_orientation_ = this->getOrientation();
    461             ++this->server_overwrite_;
    462         }
    463         else if (this->bHasLocalController_)
    464         {
    465             MobileEntity::setOrientation(orientation);
    466             this->client_orientation_ = this->getOrientation();
    467         }
     465            this->common_orientation_ = this->getOrientation();
     466//             ++this->server_overwrite_;
     467//         }
     468//         else if (this->bHasLocalController_)
     469//         {
     470//             MobileEntity::setOrientation(orientation);
     471//             this->client_orientation_ = this->getOrientation();
     472//         }
    468473    }
    469474
    470475    void ControllableEntity::setVelocity(const Vector3& velocity)
    471476    {
    472         if (GameMode::isMaster())
    473         {
     477//         if (GameMode::isMaster())
     478//         {
    474479            MobileEntity::setVelocity(velocity);
    475             this->server_linear_velocity_ = this->getVelocity();
    476             ++this->server_overwrite_;
    477         }
    478         else if (this->bHasLocalController_)
    479         {
    480             MobileEntity::setVelocity(velocity);
    481             this->client_linear_velocity_ = this->getVelocity();
    482         }
     480            this->common_linear_velocity_ = this->getVelocity();
     481//             ++this->server_overwrite_;
     482//         }
     483//         else if (this->bHasLocalController_)
     484//         {
     485//             MobileEntity::setVelocity(velocity);
     486//             this->client_linear_velocity_ = this->getVelocity();
     487//         }
    483488    }
    484489
    485490    void ControllableEntity::setAngularVelocity(const Vector3& velocity)
    486491    {
    487         if (GameMode::isMaster())
    488         {
     492//         if (GameMode::isMaster())
     493//         {
    489494            MobileEntity::setAngularVelocity(velocity);
    490             this->server_angular_velocity_ = this->getAngularVelocity();
    491             ++this->server_overwrite_;
    492         }
    493         else if (this->bHasLocalController_)
    494         {
    495             MobileEntity::setAngularVelocity(velocity);
    496             this->client_angular_velocity_ = this->getAngularVelocity();
    497         }
     495            this->common_angular_velocity_ = this->getAngularVelocity();
     496//             ++this->server_overwrite_;
     497//         }
     498//         else if (this->bHasLocalController_)
     499//         {
     500//             MobileEntity::setAngularVelocity(velocity);
     501//             this->client_angular_velocity_ = this->getAngularVelocity();
     502//         }
    498503    }
    499504
     
    501506    {
    502507        MobileEntity::setWorldTransform(worldTrans);
    503         if (GameMode::isMaster())
    504         {
    505             this->server_position_ = this->getPosition();
    506             this->server_orientation_ = this->getOrientation();
    507             this->server_linear_velocity_ = this->getVelocity();
    508             this->server_angular_velocity_ = this->getAngularVelocity();
    509         }
    510         else if (this->bHasLocalController_)
    511         {
    512             this->client_position_ = this->getPosition();
    513             this->client_orientation_ = this->getOrientation();
    514             this->client_linear_velocity_ = this->getVelocity();
    515             this->client_angular_velocity_ = this->getAngularVelocity();
    516         }
     508//         if (GameMode::isMaster())
     509//         {
     510            this->common_position_ = this->getPosition();
     511            this->common_orientation_ = this->getOrientation();
     512            this->common_linear_velocity_ = this->getVelocity();
     513            this->common_angular_velocity_ = this->getAngularVelocity();
     514//         }
     515//         else if (this->bHasLocalController_)
     516//         {
     517//             this->client_position_ = this->getPosition();
     518//             this->client_orientation_ = this->getOrientation();
     519//             this->client_linear_velocity_ = this->getVelocity();
     520//             this->client_angular_velocity_ = this->getAngularVelocity();
     521//         }
    517522    }
    518523}
Note: See TracChangeset for help on using the changeset viewer.