Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2421


Ignore:
Timestamp:
Dec 13, 2008, 2:37:53 PM (15 years ago)
Author:
rgrieder
Message:

Added resynchronisation timer in MovableEntity to ensure the right position on the client if we only synchronise the velocity.

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

Legend:

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

    r2408 r2421  
    3838{
    3939    static const float MAX_RESYNCHRONIZE_TIME = 3.0f;
     40    static const float CONTINUOUS_SYNCHRONIZATION_TIME = 10.0f;
    4041
    4142    CreateFactory(MovableEntity);
     
    4849        this->overwrite_orientation_ = Quaternion::IDENTITY;
    4950
     51        // Resynchronise every few seconds because we only work with velocities (no positions)
     52        continuousResynchroTimer_ = new Timer<MovableEntity>(CONTINUOUS_SYNCHRONIZATION_TIME + rnd(-1, 1),
     53                true, this, createExecutor(createFunctor(&MovableEntity::resynchronize)), false);
     54
    5055        this->registerVariables();
    5156    }
     
    5358    MovableEntity::~MovableEntity()
    5459    {
     60        if (this->isInitialized())
     61            delete this->continuousResynchroTimer_;
    5562    }
    5663
     
    9097    void MovableEntity::clientConnected(unsigned int clientID)
    9198    {
    92         resynchronize();
    93         new Timer<MovableEntity>(rnd() * MAX_RESYNCHRONIZE_TIME, true, this, createExecutor(createFunctor(&MovableEntity::resynchronize)), false);
     99        new Timer<MovableEntity>(rnd() * MAX_RESYNCHRONIZE_TIME, false, this, createExecutor(createFunctor(&MovableEntity::resynchronize)), true);
    94100    }
    95101
  • code/branches/physics/src/orxonox/objects/worldentities/MovableEntity.h

    r2408 r2421  
    6565            Vector3 overwrite_position_;
    6666            Quaternion overwrite_orientation_;
     67            Timer<MovableEntity>* continuousResynchroTimer_;
    6768    };
    6869}
Note: See TracChangeset for help on using the changeset viewer.