[Orxonox-commit 422] r3004 - branches/netp3/src/orxonox/objects/worldentities

scheusso at orxonox.net scheusso at orxonox.net
Thu May 21 01:18:46 CEST 2009


Author: scheusso
Date: 2009-05-21 01:18:46 +0200 (Thu, 21 May 2009)
New Revision: 3004

Modified:
   branches/netp3/src/orxonox/objects/worldentities/ControllableEntity.cc
   branches/netp3/src/orxonox/objects/worldentities/ControllableEntity.h
Log:
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)


Modified: branches/netp3/src/orxonox/objects/worldentities/ControllableEntity.cc
===================================================================
--- branches/netp3/src/orxonox/objects/worldentities/ControllableEntity.cc	2009-05-20 22:55:44 UTC (rev 3003)
+++ branches/netp3/src/orxonox/objects/worldentities/ControllableEntity.cc	2009-05-20 23:18:46 UTC (rev 3004)
@@ -65,14 +65,14 @@
         this->bMouseLook_ = false;
         this->mouseLookSpeed_ = 200;
 
-        this->common_position_         = Vector3::ZERO;
-//         this->client_position_         = Vector3::ZERO;
-        this->common_linear_velocity_  = Vector3::ZERO;
-//         this->client_linear_velocity_  = Vector3::ZERO;
-        this->common_orientation_      = Quaternion::IDENTITY;
-//         this->client_orientation_      = Quaternion::IDENTITY;
-        this->common_angular_velocity_ = Vector3::ZERO;
-//         this->client_angular_velocity_ = Vector3::ZERO;
+        this->server_position_         = Vector3::ZERO;
+        this->client_position_         = Vector3::ZERO;
+        this->server_linear_velocity_  = Vector3::ZERO;
+        this->client_linear_velocity_  = Vector3::ZERO;
+        this->server_orientation_      = Quaternion::IDENTITY;
+        this->client_orientation_      = Quaternion::IDENTITY;
+        this->server_angular_velocity_ = Vector3::ZERO;
+        this->client_angular_velocity_ = Vector3::ZERO;
 
 
         this->setConfigValues();
@@ -325,20 +325,20 @@
             // Check whether Bullet doesn't do the physics for us
             if (!this->isDynamic())
             {
-//                 if (GameMode::isMaster())
-//                 {
-                    this->common_position_ = this->getPosition();
-                    this->common_orientation_ = this->getOrientation();
-                    this->common_linear_velocity_ = this->getVelocity();
-                    this->common_angular_velocity_ = this->getAngularVelocity();
-//                 }
-//                 else if (this->bHasLocalController_)
-//                 {
-//                     this->client_position_ = this->getPosition();
-//                     this->client_orientation_ = this->getOrientation();
-//                     this->client_linear_velocity_ = this->getVelocity();
-//                     this->client_angular_velocity_ = this->getAngularVelocity();
-//                 }
+                if (GameMode::isMaster())
+                {
+                    this->server_position_ = this->getPosition();
+                    this->server_orientation_ = this->getOrientation();
+                    this->server_linear_velocity_ = this->getVelocity();
+                    this->server_angular_velocity_ = this->getAngularVelocity();
+                }
+                else if (this->bHasLocalController_)
+                {
+                    this->client_position_ = this->getPosition();
+                    this->client_orientation_ = this->getOrientation();
+                    this->client_linear_velocity_ = this->getVelocity();
+                    this->client_angular_velocity_ = this->getAngularVelocity();
+                }
             }
         }
     }
@@ -348,23 +348,19 @@
         registerVariable(this->cameraPositionTemplate_,  variableDirection::toclient);
         registerVariable(this->hudtemplate_,             variableDirection::toclient);
 
-//         registerVariable(this->server_position_,         variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition));
-//         registerVariable(this->server_linear_velocity_,  variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerLinearVelocity));
-//         registerVariable(this->server_orientation_,      variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation));
-//         registerVariable(this->server_angular_velocity_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerAngularVelocity));
-// 
-//         registerVariable(this->server_overwrite_,        variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite));
-//         registerVariable(this->client_overwrite_,        variableDirection::toserver);
-// 
-//         registerVariable(this->client_position_,         variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition));
-//         registerVariable(this->client_linear_velocity_,  variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientLinearVelocity));
-//         registerVariable(this->client_orientation_,      variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation));
-//         registerVariable(this->client_angular_velocity_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientAngularVelocity));
+        registerVariable(this->server_position_,         variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition));
+        registerVariable(this->server_linear_velocity_,  variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerLinearVelocity));
+        registerVariable(this->server_orientation_,      variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation));
+        registerVariable(this->server_angular_velocity_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerAngularVelocity));
+
+        registerVariable(this->server_overwrite_,        variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite));
+        registerVariable(this->client_overwrite_,        variableDirection::toserver);
+
+        registerVariable(this->client_position_,         variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition));
+        registerVariable(this->client_linear_velocity_,  variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientLinearVelocity));
+        registerVariable(this->client_orientation_,      variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation));
+        registerVariable(this->client_angular_velocity_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientAngularVelocity));
         
-        registerVariable(this->common_position_,         variableDirection::serverMaster, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition), true);
-        registerVariable(this->common_linear_velocity_,  variableDirection::serverMaster, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerLinearVelocity), true);
-        registerVariable(this->common_orientation_,      variableDirection::serverMaster, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation), true);
-        registerVariable(this->common_angular_velocity_, variableDirection::serverMaster, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerAngularVelocity), true);
 
         registerVariable(this->playerID_,                variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID));
     }
@@ -372,37 +368,37 @@
     void ControllableEntity::processServerPosition()
     {
         if (!this->bHasLocalController_)
-            MobileEntity::setPosition(this->common_position_);
+            MobileEntity::setPosition(this->server_position_);
     }
 
     void ControllableEntity::processServerLinearVelocity()
     {
         if (!this->bHasLocalController_)
-            MobileEntity::setVelocity(this->common_linear_velocity_);
+            MobileEntity::setVelocity(this->server_linear_velocity_);
     }
 
     void ControllableEntity::processServerOrientation()
     {
         if (!this->bHasLocalController_)
-            MobileEntity::setOrientation(this->common_orientation_);
+            MobileEntity::setOrientation(this->server_orientation_);
     }
 
     void ControllableEntity::processServerAngularVelocity()
     {
         if (!this->bHasLocalController_)
-            MobileEntity::setAngularVelocity(this->common_angular_velocity_);
+            MobileEntity::setAngularVelocity(this->server_angular_velocity_);
     }
 
     void ControllableEntity::processOverwrite()
     {
         if (this->bHasLocalController_)
         {
-//             this->setPosition(this->server_position_);
-//             this->setOrientation(this->server_orientation_);
-//             this->setVelocity(this->server_linear_velocity_);
-//             this->setAngularVelocity(this->server_angular_velocity_);
+            this->setPosition(this->server_position_);
+            this->setOrientation(this->server_orientation_);
+            this->setVelocity(this->server_linear_velocity_);
+            this->setAngularVelocity(this->server_angular_velocity_);
 
-//             this->client_overwrite_ = this->server_overwrite_;
+            this->client_overwrite_ = this->server_overwrite_;
         }
     }
 
@@ -410,8 +406,8 @@
     {
         if (this->server_overwrite_ == this->client_overwrite_)
         {
-//             MobileEntity::setPosition(this->client_position_);
-//             this->server_position_ = this->getPosition();
+            MobileEntity::setPosition(this->client_position_);
+            this->server_position_ = this->getPosition();
         }
     }
 
@@ -419,8 +415,8 @@
     {
         if (this->server_overwrite_ == this->client_overwrite_)
         {
-//             MobileEntity::setVelocity(this->client_linear_velocity_);
-//             this->server_linear_velocity_ = this->getVelocity();
+            MobileEntity::setVelocity(this->client_linear_velocity_);
+            this->server_linear_velocity_ = this->getVelocity();
         }
     }
 
@@ -428,8 +424,8 @@
     {
         if (this->server_overwrite_ == this->client_overwrite_)
         {
-//             MobileEntity::setOrientation(this->client_orientation_);
-//             this->server_orientation_ = this->getOrientation();
+            MobileEntity::setOrientation(this->client_orientation_);
+            this->server_orientation_ = this->getOrientation();
         }
     }
 
@@ -437,87 +433,87 @@
     {
         if (this->server_overwrite_ == this->client_overwrite_)
         {
-//             MobileEntity::setAngularVelocity(this->client_angular_velocity_);
-//             this->server_angular_velocity_ = this->getAngularVelocity();
+            MobileEntity::setAngularVelocity(this->client_angular_velocity_);
+            this->server_angular_velocity_ = this->getAngularVelocity();
         }
     }
 
     void ControllableEntity::setPosition(const Vector3& position)
     {
-//         if (GameMode::isMaster())
-//         {
+        if (GameMode::isMaster())
+        {
             MobileEntity::setPosition(position);
-            this->common_position_ = this->getPosition();
-//             ++this->server_overwrite_;
-//         }
-//         else if (this->bHasLocalController_)
-//         {
-//             MobileEntity::setPosition(position);
-//             this->client_position_ = this->getPosition();
-//         }
+            this->server_position_ = this->getPosition();
+            ++this->server_overwrite_;
+        }
+        else if (this->bHasLocalController_)
+        {
+            MobileEntity::setPosition(position);
+            this->client_position_ = this->getPosition();
+        }
     }
 
     void ControllableEntity::setOrientation(const Quaternion& orientation)
     {
-//         if (GameMode::isMaster())
-//         {
+        if (GameMode::isMaster())
+        {
             MobileEntity::setOrientation(orientation);
-            this->common_orientation_ = this->getOrientation();
-//             ++this->server_overwrite_;
-//         }
-//         else if (this->bHasLocalController_)
-//         {
-//             MobileEntity::setOrientation(orientation);
-//             this->client_orientation_ = this->getOrientation();
-//         }
+            this->server_orientation_ = this->getOrientation();
+            ++this->server_overwrite_;
+        }
+        else if (this->bHasLocalController_)
+        {
+            MobileEntity::setOrientation(orientation);
+            this->client_orientation_ = this->getOrientation();
+        }
     }
 
     void ControllableEntity::setVelocity(const Vector3& velocity)
     {
-//         if (GameMode::isMaster())
-//         {
+        if (GameMode::isMaster())
+        {
             MobileEntity::setVelocity(velocity);
-            this->common_linear_velocity_ = this->getVelocity();
-//             ++this->server_overwrite_;
-//         }
-//         else if (this->bHasLocalController_)
-//         {
-//             MobileEntity::setVelocity(velocity);
-//             this->client_linear_velocity_ = this->getVelocity();
-//         }
+            this->server_linear_velocity_ = this->getVelocity();
+            ++this->server_overwrite_;
+        }
+        else if (this->bHasLocalController_)
+        {
+            MobileEntity::setVelocity(velocity);
+            this->client_linear_velocity_ = this->getVelocity();
+        }
     }
 
     void ControllableEntity::setAngularVelocity(const Vector3& velocity)
     {
-//         if (GameMode::isMaster())
-//         {
+        if (GameMode::isMaster())
+        {
             MobileEntity::setAngularVelocity(velocity);
-            this->common_angular_velocity_ = this->getAngularVelocity();
-//             ++this->server_overwrite_;
-//         }
-//         else if (this->bHasLocalController_)
-//         {
-//             MobileEntity::setAngularVelocity(velocity);
-//             this->client_angular_velocity_ = this->getAngularVelocity();
-//         }
+            this->server_angular_velocity_ = this->getAngularVelocity();
+            ++this->server_overwrite_;
+        }
+        else if (this->bHasLocalController_)
+        {
+            MobileEntity::setAngularVelocity(velocity);
+            this->client_angular_velocity_ = this->getAngularVelocity();
+        }
     }
 
     void ControllableEntity::setWorldTransform(const btTransform& worldTrans)
     {
         MobileEntity::setWorldTransform(worldTrans);
-//         if (GameMode::isMaster())
-//         {
-            this->common_position_ = this->getPosition();
-            this->common_orientation_ = this->getOrientation();
-            this->common_linear_velocity_ = this->getVelocity();
-            this->common_angular_velocity_ = this->getAngularVelocity();
-//         }
-//         else if (this->bHasLocalController_)
-//         {
-//             this->client_position_ = this->getPosition();
-//             this->client_orientation_ = this->getOrientation();
-//             this->client_linear_velocity_ = this->getVelocity();
-//             this->client_angular_velocity_ = this->getAngularVelocity();
-//         }
+        if (GameMode::isMaster())
+        {
+            this->server_position_ = this->getPosition();
+            this->server_orientation_ = this->getOrientation();
+            this->server_linear_velocity_ = this->getVelocity();
+            this->server_angular_velocity_ = this->getAngularVelocity();
+        }
+        else if (this->bHasLocalController_)
+        {
+            this->client_position_ = this->getPosition();
+            this->client_orientation_ = this->getOrientation();
+            this->client_linear_velocity_ = this->getVelocity();
+            this->client_angular_velocity_ = this->getAngularVelocity();
+        }
     }
 }

Modified: branches/netp3/src/orxonox/objects/worldentities/ControllableEntity.h
===================================================================
--- branches/netp3/src/orxonox/objects/worldentities/ControllableEntity.h	2009-05-20 22:55:44 UTC (rev 3003)
+++ branches/netp3/src/orxonox/objects/worldentities/ControllableEntity.h	2009-05-20 23:18:46 UTC (rev 3004)
@@ -163,18 +163,14 @@
             bool bHasHumanController_;
             bool bDestroyWhenPlayerLeft_;
 
-//             Vector3 server_position_;
-            Vector3 common_position_;
-//             Vector3 client_position_;
-//             Vector3 server_linear_velocity_;
-//             Vector3 client_linear_velocity_;
-            Vector3 common_linear_velocity_;
-//             Quaternion server_orientation_;
-//             Quaternion client_orientation_;
-            Quaternion common_orientation_;
-//             Vector3 server_angular_velocity_;
-//             Vector3 client_angular_velocity_;
-            Vector3 common_angular_velocity_;
+            Vector3 server_position_;
+            Vector3 client_position_;
+            Vector3 server_linear_velocity_;
+            Vector3 client_linear_velocity_;
+            Quaternion server_orientation_;
+            Quaternion client_orientation_;
+            Vector3 server_angular_velocity_;
+            Vector3 client_angular_velocity_;
 
             PlayerInfo* player_;
             unsigned int playerID_;




More information about the Orxonox-commit mailing list