Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 13, 2008, 9:38:30 PM (15 years ago)
Author:
rgrieder
Message:

Changed the way setPosition, setVelocity, setOrientation and setAngularVelocity is handled in MobileEntity and upwards.
This allows to introduce a lost feature: Position of an enemy ship on the client can't be set anymore at all (local changes were allowed before).

File:
1 edited

Legend:

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

    r2408 r2427  
    230230        if (this->isActive())
    231231        {
     232            // Check whether Bullet doesn't do the physics for us
     233            if (!this->isDynamic())
     234            {
     235                if (Core::isMaster())
     236                {
     237                    this->server_position_ = this->getPosition();
     238                    this->server_orientation_ = this->getOrientation();
     239                    this->server_linear_velocity_ = this->getVelocity();
     240                    this->server_angular_velocity_ = this->getAngularVelocity();
     241                }
     242                else if (this->bControlled_)
     243                {
     244                    this->client_position_ = this->getPosition();
     245                    this->client_orientation_ = this->getOrientation();
     246                    this->client_linear_velocity_ = this->getVelocity();
     247                    this->client_angular_velocity_ = this->getAngularVelocity();
     248                }
     249            }
    232250        }
    233251    }
     
    330348    }
    331349
    332     void ControllableEntity::positionChanged(bool bContinuous)
     350    void ControllableEntity::setPosition(const Vector3& position)
    333351    {
    334352        if (Core::isMaster())
    335353        {
     354            MobileEntity::setPosition(position);
    336355            this->server_position_ = this->getPosition();
    337             if (!bContinuous)
    338                 ++this->server_overwrite_;
     356            ++this->server_overwrite_;
    339357        }
    340358        else if (this->bControlled_)
    341359        {
     360            MobileEntity::setPosition(position);
    342361            this->client_position_ = this->getPosition();
    343362        }
    344363    }
    345364
    346     void ControllableEntity::orientationChanged(bool bContinuous)
     365    void ControllableEntity::setOrientation(const Quaternion& orientation)
    347366    {
    348367        if (Core::isMaster())
    349368        {
     369            MobileEntity::setOrientation(orientation);
    350370            this->server_orientation_ = this->getOrientation();
    351             if (!bContinuous)
    352                 ++this->server_overwrite_;
     371            ++this->server_overwrite_;
    353372        }
    354373        else if (this->bControlled_)
    355374        {
     375            MobileEntity::setOrientation(orientation);
    356376            this->client_orientation_ = this->getOrientation();
    357377        }
    358378    }
    359379
    360     void ControllableEntity::linearVelocityChanged(bool bContinuous)
     380    void ControllableEntity::setVelocity(const Vector3& velocity)
    361381    {
    362382        if (Core::isMaster())
    363383        {
     384            MobileEntity::setVelocity(velocity);
    364385            this->server_linear_velocity_ = this->getVelocity();
    365             if (!bContinuous)
    366                 ++this->server_overwrite_;
     386            ++this->server_overwrite_;
    367387        }
    368388        else if (this->bControlled_)
    369389        {
     390            MobileEntity::setVelocity(velocity);
    370391            this->client_linear_velocity_ = this->getVelocity();
    371392        }
    372393    }
    373394
    374     void ControllableEntity::angularVelocityChanged(bool bContinuous)
     395    void ControllableEntity::setAngularVelocity(const Vector3& velocity)
    375396    {
    376397        if (Core::isMaster())
    377398        {
     399            MobileEntity::setAngularVelocity(velocity);
    378400            this->server_angular_velocity_ = this->getAngularVelocity();
    379             if (!bContinuous)
    380                 ++this->server_overwrite_;
     401            ++this->server_overwrite_;
    381402        }
    382403        else if (this->bControlled_)
    383404        {
     405            MobileEntity::setAngularVelocity(velocity);
    384406            this->client_angular_velocity_ = this->getAngularVelocity();
    385407        }
    386408    }
     409
     410    void ControllableEntity::setWorldTransform(const btTransform& worldTrans)
     411    {
     412        MobileEntity::setWorldTransform(worldTrans);
     413        if (Core::isMaster())
     414        {
     415            this->server_position_ = this->getPosition();
     416            this->server_orientation_ = this->getOrientation();
     417            this->server_linear_velocity_ = this->getVelocity();
     418            this->server_angular_velocity_ = this->getAngularVelocity();
     419        }
     420        else if (this->bControlled_)
     421        {
     422            this->client_position_ = this->getPosition();
     423            this->client_orientation_ = this->getOrientation();
     424            this->client_linear_velocity_ = this->getVelocity();
     425            this->client_angular_velocity_ = this->getAngularVelocity();
     426        }
     427    }
    387428}
Note: See TracChangeset for help on using the changeset viewer.