Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 21, 2009, 1:18:46 AM (16 years ago)
Author:
scheusso
Message:

reverted changes of ControllableEntity
synchronisation now again with server and client values and overwrites (unidirectional)
problem with bidirectional synchronisation was the combination with bullet (lots of changes of client ships on the server side and thus lag in synchronisation)

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

Legend:

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

    r2990 r3004  
    6666        this->mouseLookSpeed_ = 200;
    6767
    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;
     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;
    7676
    7777
     
    326326            if (!this->isDynamic())
    327327            {
    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 //                 }
     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                }
    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));
    363363       
    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);
    368364
    369365        registerVariable(this->playerID_,                variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID));
     
    373369    {
    374370        if (!this->bHasLocalController_)
    375             MobileEntity::setPosition(this->common_position_);
     371            MobileEntity::setPosition(this->server_position_);
    376372    }
    377373
     
    379375    {
    380376        if (!this->bHasLocalController_)
    381             MobileEntity::setVelocity(this->common_linear_velocity_);
     377            MobileEntity::setVelocity(this->server_linear_velocity_);
    382378    }
    383379
     
    385381    {
    386382        if (!this->bHasLocalController_)
    387             MobileEntity::setOrientation(this->common_orientation_);
     383            MobileEntity::setOrientation(this->server_orientation_);
    388384    }
    389385
     
    391387    {
    392388        if (!this->bHasLocalController_)
    393             MobileEntity::setAngularVelocity(this->common_angular_velocity_);
     389            MobileEntity::setAngularVelocity(this->server_angular_velocity_);
    394390    }
    395391
     
    398394        if (this->bHasLocalController_)
    399395        {
    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_;
     396            this->setPosition(this->server_position_);
     397            this->setOrientation(this->server_orientation_);
     398            this->setVelocity(this->server_linear_velocity_);
     399            this->setAngularVelocity(this->server_angular_velocity_);
     400
     401            this->client_overwrite_ = this->server_overwrite_;
    406402        }
    407403    }
     
    411407        if (this->server_overwrite_ == this->client_overwrite_)
    412408        {
    413 //             MobileEntity::setPosition(this->client_position_);
    414 //             this->server_position_ = this->getPosition();
     409            MobileEntity::setPosition(this->client_position_);
     410            this->server_position_ = this->getPosition();
    415411        }
    416412    }
     
    420416        if (this->server_overwrite_ == this->client_overwrite_)
    421417        {
    422 //             MobileEntity::setVelocity(this->client_linear_velocity_);
    423 //             this->server_linear_velocity_ = this->getVelocity();
     418            MobileEntity::setVelocity(this->client_linear_velocity_);
     419            this->server_linear_velocity_ = this->getVelocity();
    424420        }
    425421    }
     
    429425        if (this->server_overwrite_ == this->client_overwrite_)
    430426        {
    431 //             MobileEntity::setOrientation(this->client_orientation_);
    432 //             this->server_orientation_ = this->getOrientation();
     427            MobileEntity::setOrientation(this->client_orientation_);
     428            this->server_orientation_ = this->getOrientation();
    433429        }
    434430    }
     
    438434        if (this->server_overwrite_ == this->client_overwrite_)
    439435        {
    440 //             MobileEntity::setAngularVelocity(this->client_angular_velocity_);
    441 //             this->server_angular_velocity_ = this->getAngularVelocity();
     436            MobileEntity::setAngularVelocity(this->client_angular_velocity_);
     437            this->server_angular_velocity_ = this->getAngularVelocity();
    442438        }
    443439    }
     
    445441    void ControllableEntity::setPosition(const Vector3& position)
    446442    {
    447 //         if (GameMode::isMaster())
    448 //         {
     443        if (GameMode::isMaster())
     444        {
    449445            MobileEntity::setPosition(position);
    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 //         }
     446            this->server_position_ = this->getPosition();
     447            ++this->server_overwrite_;
     448        }
     449        else if (this->bHasLocalController_)
     450        {
     451            MobileEntity::setPosition(position);
     452            this->client_position_ = this->getPosition();
     453        }
    458454    }
    459455
    460456    void ControllableEntity::setOrientation(const Quaternion& orientation)
    461457    {
    462 //         if (GameMode::isMaster())
    463 //         {
     458        if (GameMode::isMaster())
     459        {
    464460            MobileEntity::setOrientation(orientation);
    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 //         }
     461            this->server_orientation_ = this->getOrientation();
     462            ++this->server_overwrite_;
     463        }
     464        else if (this->bHasLocalController_)
     465        {
     466            MobileEntity::setOrientation(orientation);
     467            this->client_orientation_ = this->getOrientation();
     468        }
    473469    }
    474470
    475471    void ControllableEntity::setVelocity(const Vector3& velocity)
    476472    {
    477 //         if (GameMode::isMaster())
    478 //         {
     473        if (GameMode::isMaster())
     474        {
    479475            MobileEntity::setVelocity(velocity);
    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 //         }
     476            this->server_linear_velocity_ = this->getVelocity();
     477            ++this->server_overwrite_;
     478        }
     479        else if (this->bHasLocalController_)
     480        {
     481            MobileEntity::setVelocity(velocity);
     482            this->client_linear_velocity_ = this->getVelocity();
     483        }
    488484    }
    489485
    490486    void ControllableEntity::setAngularVelocity(const Vector3& velocity)
    491487    {
    492 //         if (GameMode::isMaster())
    493 //         {
     488        if (GameMode::isMaster())
     489        {
    494490            MobileEntity::setAngularVelocity(velocity);
    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 //         }
     491            this->server_angular_velocity_ = this->getAngularVelocity();
     492            ++this->server_overwrite_;
     493        }
     494        else if (this->bHasLocalController_)
     495        {
     496            MobileEntity::setAngularVelocity(velocity);
     497            this->client_angular_velocity_ = this->getAngularVelocity();
     498        }
    503499    }
    504500
     
    506502    {
    507503        MobileEntity::setWorldTransform(worldTrans);
    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 //         }
     504        if (GameMode::isMaster())
     505        {
     506            this->server_position_ = this->getPosition();
     507            this->server_orientation_ = this->getOrientation();
     508            this->server_linear_velocity_ = this->getVelocity();
     509            this->server_angular_velocity_ = this->getAngularVelocity();
     510        }
     511        else if (this->bHasLocalController_)
     512        {
     513            this->client_position_ = this->getPosition();
     514            this->client_orientation_ = this->getOrientation();
     515            this->client_linear_velocity_ = this->getVelocity();
     516            this->client_angular_velocity_ = this->getAngularVelocity();
     517        }
    522518    }
    523519}
  • code/branches/netp3/src/orxonox/objects/worldentities/ControllableEntity.h

    r2990 r3004  
    164164            bool bDestroyWhenPlayerLeft_;
    165165
    166 //             Vector3 server_position_;
    167             Vector3 common_position_;
    168 //             Vector3 client_position_;
    169 //             Vector3 server_linear_velocity_;
    170 //             Vector3 client_linear_velocity_;
    171             Vector3 common_linear_velocity_;
    172 //             Quaternion server_orientation_;
    173 //             Quaternion client_orientation_;
    174             Quaternion common_orientation_;
    175 //             Vector3 server_angular_velocity_;
    176 //             Vector3 client_angular_velocity_;
    177             Vector3 common_angular_velocity_;
     166            Vector3 server_position_;
     167            Vector3 client_position_;
     168            Vector3 server_linear_velocity_;
     169            Vector3 client_linear_velocity_;
     170            Quaternion server_orientation_;
     171            Quaternion client_orientation_;
     172            Vector3 server_angular_velocity_;
     173            Vector3 client_angular_velocity_;
    178174
    179175            PlayerInfo* player_;
Note: See TracChangeset for help on using the changeset viewer.