Index: trunk/src/lib/coord/p_node.cc
===================================================================
--- trunk/src/lib/coord/p_node.cc	(revision 7003)
+++ trunk/src/lib/coord/p_node.cc	(revision 7008)
@@ -42,5 +42,5 @@
  */
 PNode::PNode (PNode* parent, long nodeFlags)
-  : Synchronizeable(), BaseObject()
+    : Synchronizeable(), BaseObject()
 {
   this->setClassID(CL_PARENT_NODE, "PNode");
@@ -88,5 +88,5 @@
       deleteNode = tmp;
       tmp++;
-//      printf("TEST::%s(%s) %s\n", (*deleteNode)->getName(), (*deleteNode)->getClassName(), this->getName());
+      //      printf("TEST::%s(%s) %s\n", (*deleteNode)->getName(), (*deleteNode)->getClassName(), this->getName());
       if ((this->parentMode & PNODE_PROHIBIT_CHILD_DELETE) ||
           ((*deleteNode)->parentMode & PNODE_PROHIBIT_DELETE_WITH_PARENT))
@@ -102,8 +102,8 @@
 
   if (this->parent != NULL)
-   {
-     this->parent->eraseChild(this);
-     this->parent = NULL;
-   }
+  {
+    this->parent->eraseChild(this);
+    this->parent = NULL;
+  }
 
   // remove all other allocated memory.
@@ -127,20 +127,20 @@
 
   LoadParam(root, "rel-coor", this, PNode, setRelCoor)
-      .describe("Sets The relative position of the Node to its parent.");
+  .describe("Sets The relative position of the Node to its parent.");
 
   LoadParam(root, "abs-coor", this, PNode, setAbsCoor)
-      .describe("Sets The absolute Position of the Node.");
+  .describe("Sets The absolute Position of the Node.");
 
   LoadParam(root, "rel-dir", this, PNode, setRelDir)
-      .describe("Sets The relative rotation of the Node to its parent.");
+  .describe("Sets The relative rotation of the Node to its parent.");
 
   LoadParam(root, "abs-dir", this, PNode, setAbsDir)
-      .describe("Sets The absolute rotation of the Node.");
+  .describe("Sets The absolute rotation of the Node.");
 
   LoadParam(root, "parent", this, PNode, setParent)
-      .describe("the Name of the Parent to set for this PNode");
+  .describe("the Name of the Parent to set for this PNode");
 
   LoadParam(root, "parent-mode", this, PNode, setParentMode)
-      .describe("the mode to connect this node to its parent ()");
+  .describe("the mode to connect this node to its parent ()");
 
   // cycling properties
@@ -150,5 +150,5 @@
     {
       LoadParam_CYCLE(element, "child", this, PNode, addChild)
-          .describe("adds a new Child to the current Node.");
+      .describe("adds a new Child to the current Node.");
 
     }
@@ -245,5 +245,5 @@
   if( likely(this->parentMode & PNODE_MOVEMENT))
   {
-      /* if you have set the absolute coordinates this overrides all other changes */
+    /* if you have set the absolute coordinates this overrides all other changes */
     if (likely(this->parent != NULL))
       this->relCoordinate = absCoord - parent->getAbsCoor ();
@@ -260,5 +260,5 @@
 
   this->bRelCoorChanged = true;
-//  this->absCoordinate = absCoord;
+  //  this->absCoordinate = absCoord;
 }
 
@@ -287,5 +287,5 @@
   if( likely(this->parentMode & PNODE_MOVEMENT))
   {
-      /* if you have set the absolute coordinates this overrides all other changes */
+    /* if you have set the absolute coordinates this overrides all other changes */
     if (likely(this->parent != NULL))
       *this->toCoordinate = absCoordSoft - parent->getAbsCoor ();
@@ -404,5 +404,5 @@
     this->relDirection = absDir / this->parent->getAbsDir();
   else
-   this->relDirection = absDir;
+    this->relDirection = absDir;
 
   this->bRelDirChanged = true;
@@ -437,5 +437,5 @@
     *this->toDirection = absDirSoft / this->parent->getAbsDir();
   else
-   *this->toDirection = absDirSoft;
+    *this->toDirection = absDirSoft;
 
   this->bias = bias;
@@ -477,5 +477,5 @@
 {
   if( likely(child->parent != NULL))
-      child->parent->eraseChild(child);
+    child->parent->eraseChild(child);
   if (this->checkIntegrity(child))
   {
@@ -485,13 +485,13 @@
     child->parentCoorChanged();
 
-//     if(this->getUniqueID() == NET_UID_UNASSIGNED)
-//     {
-//       PRINTF(1)("Adding to an UNASSIGNED PNode - looking for next assigned Node\n");
-//       PNode* node = this->seekNextAssignedPNode(this);
-//       if( node == NULL)
-//         PRINTF(1)("    Got NULL - Is this the NULLParent - uid %i\n", this->getUniqueID());
-//       else
-//         PRINTF(1)("    Found next assigned node: %i\n", node->getUniqueID());
-//     }
+    //     if(this->getUniqueID() == NET_UID_UNASSIGNED)
+    //     {
+    //       PRINTF(1)("Adding to an UNASSIGNED PNode - looking for next assigned Node\n");
+    //       PNode* node = this->seekNextAssignedPNode(this);
+    //       if( node == NULL)
+    //         PRINTF(1)("    Got NULL - Is this the NULLParent - uid %i\n", this->getUniqueID());
+    //       else
+    //         PRINTF(1)("    Found next assigned node: %i\n", node->getUniqueID());
+    //     }
   }
   else
@@ -529,6 +529,6 @@
 {
   PNode* childNode = dynamic_cast<PNode*>(ClassList::getObject(childName, CL_PARENT_NODE));
-//  PRINTF(0)("Adding the Child: %s to: %s\n", childName, this->getName());
-//  assert( childNode != NULL );
+  //  PRINTF(0)("Adding the Child: %s to: %s\n", childName, this->getName());
+  //  assert( childNode != NULL );
   if (childNode != NULL)
   {
@@ -547,5 +547,5 @@
 {
   if (child != NULL)
-   child->removeNode();
+    child->removeNode();
 }
 
@@ -652,10 +652,10 @@
   parentNode->addChild(this);
 
- if (this->parentMode & PNODE_ROTATE_MOVEMENT && this->parent != NULL)
-   this->relCoordinate = this->parent->getAbsDir().inverse().apply(tmpV - this->parent->getAbsCoor());
- else
-   this->relCoordinate = tmpV - parentNode->getAbsCoor();
-
- this->relDirection = tmpQ / parentNode->getAbsDir();
+  if (this->parentMode & PNODE_ROTATE_MOVEMENT && this->parent != NULL)
+    this->relCoordinate = this->parent->getAbsDir().inverse().apply(tmpV - this->parent->getAbsCoor());
+  else
+    this->relCoordinate = tmpV - parentNode->getAbsCoor();
+
+  this->relDirection = tmpQ / parentNode->getAbsDir();
 }
 
@@ -759,100 +759,106 @@
     if( likely(this->parent != NULL))
     {
-        // movement for nodes with smoothMove enabled
-        if (unlikely(this->toCoordinate != NULL))
+      // movement for nodes with smoothMove enabled
+      if (unlikely(this->toCoordinate != NULL))
+      {
+        float shiftLen = fabsf(dt)*bias;
+        if (shiftLen >= 1.0)
+          shiftLen = 1.0;
+        Vector moveVect = (*this->toCoordinate - this->relCoordinate) * shiftLen;
+        if (likely(moveVect.len() >= PNODE_ITERATION_DELTA))
         {
-          Vector moveVect = (*this->toCoordinate - this->relCoordinate) *fabsf(dt)*bias;
-          if (likely(moveVect.len() >= PNODE_ITERATION_DELTA))
-          {
-            this->shiftCoor(moveVect);
-          }
-          else
-          {
-            delete this->toCoordinate;
-            this->toCoordinate = NULL;
-            PRINTF(5)("SmoothMove of %s finished\n", this->getName());
-          }
+          this->shiftCoor(moveVect);
         }
-        if (unlikely(this->toDirection != NULL))
+        else
         {
-          //printf("%s::%s %f\n", this->getClassName(), this->getName(), this->toStep );
-          Quaternion rotQuat = Quaternion::quatSlerp(this->relDirection,*this->toDirection, .1);
-          if (this->relDirection.distance(rotQuat) > PNODE_ITERATION_DELTA)
-          {
-            this->relDirection = rotQuat;
-            this->bRelDirChanged;
-          }
-          else
-          {
-            delete this->toDirection;
-            this->toDirection = NULL;
-            PRINTF(5)("SmoothRotate of %s finished\n", this->getName());
-            this->bRelDirChanged;
-          }
+          delete this->toCoordinate;
+          this->toCoordinate = NULL;
+          PRINTF(5)("SmoothMove of %s finished\n", this->getName());
         }
-
-        // MAIN UPDATE /////////////////////////////////////
-        this->lastAbsCoordinate = this->absCoordinate;
-
-        PRINTF(5)("PNode::update - '%s::%s' - (%f, %f, %f)\n", this->getClassName(), this->getName(),
-                      this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z);
-
-
-        if(this->bRelDirChanged && this->parentMode & PNODE_LOCAL_ROTATE )
+      }
+      if (unlikely(this->toDirection != NULL))
+      {
+        float shiftLen = fabsf(dt)*bias;
+        if (shiftLen >= 1.0)
+          shiftLen = 1.0;
+        //printf("%s::%s %f\n", this->getClassName(), this->getName(), this->toStep );
+        Quaternion rotQuat = Quaternion::quatSlerp(this->relDirection,*this->toDirection, shiftLen);
+        if (this->relDirection.distance(rotQuat) > PNODE_ITERATION_DELTA)
         {
-          /* update the current absDirection - remember * means rotation around sth.*/
-          this->prevRelCoordinate = this->relCoordinate;
-          this->absDirection = parent->getAbsDir() * this->relDirection;
+          this->relDirection = rotQuat;
+          this->bRelDirChanged;
         }
-
-        if(likely(this->bRelCoorChanged && this->parentMode & PNODE_MOVEMENT))
+        else
         {
+          delete this->toDirection;
+          this->toDirection = NULL;
+          PRINTF(5)("SmoothRotate of %s finished\n", this->getName());
+          this->bRelDirChanged;
+        }
+      }
+
+      // MAIN UPDATE /////////////////////////////////////
+      this->lastAbsCoordinate = this->absCoordinate;
+
+      PRINTF(5)("PNode::update - '%s::%s' - (%f, %f, %f)\n", this->getClassName(), this->getName(),
+                this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z);
+
+
+      if(this->bRelDirChanged && this->parentMode & PNODE_LOCAL_ROTATE )
+      {
+        /* update the current absDirection - remember * means rotation around sth.*/
+        this->prevRelCoordinate = this->relCoordinate;
+        this->absDirection = parent->getAbsDir() * this->relDirection;
+      }
+
+      if(likely(this->bRelCoorChanged && this->parentMode & PNODE_MOVEMENT))
+      {
         /* update the current absCoordinate */
-          this->prevRelCoordinate = this->relCoordinate;
-          this->absCoordinate = this->parent->getAbsCoor() + this->relCoordinate;
-        }
-        else if( this->parentMode & PNODE_ROTATE_MOVEMENT && (this->bRelCoorChanged || this->bRelDirChanged))
-        {
-          /* update the current absCoordinate */
-          this->prevRelCoordinate = this->relCoordinate;
-          this->absCoordinate = this->parent->getAbsCoor() + parent->getAbsDir().apply(this->relCoordinate);
-        }
-        /////////////////////////////////////////////////
+        this->prevRelCoordinate = this->relCoordinate;
+        this->absCoordinate = this->parent->getAbsCoor() + this->relCoordinate;
       }
-
-  else // Nodes without a Parent are handled faster :: MOST LIKELY THE NULLPARENT
+      else if( this->parentMode & PNODE_ROTATE_MOVEMENT && (this->bRelCoorChanged || this->bRelDirChanged))
+      {
+        /* update the current absCoordinate */
+        this->prevRelCoordinate = this->relCoordinate;
+        this->absCoordinate = this->parent->getAbsCoor() + parent->getAbsDir().apply(this->relCoordinate);
+      }
+      /////////////////////////////////////////////////
+    }
+
+    else // Nodes without a Parent are handled faster :: MOST LIKELY THE NULLPARENT
     {
       PRINTF(4)("update ParentLess Node (%s::%s) - (%f, %f, %f)\n", this->getClassName(), this->getName(),
                 this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z);
-        if (this->bRelCoorChanged)
-        {
-          this->prevRelCoordinate = this->relCoordinate;
-          this->absCoordinate = this->relCoordinate;
-        }
-        if (this->bRelDirChanged)
-        {
-          this->prevRelDirection = this->relDirection;
-          this->absDirection = this->getAbsDir () * this->relDirection;
-        }
+      if (this->bRelCoorChanged)
+      {
+        this->prevRelCoordinate = this->relCoordinate;
+        this->absCoordinate = this->relCoordinate;
+      }
+      if (this->bRelDirChanged)
+      {
+        this->prevRelDirection = this->relDirection;
+        this->absDirection = this->getAbsDir () * this->relDirection;
       }
     }
-
-    if(!this->children.empty() && (this->bActive || this->parentMode & PNODE_UPDATE_CHILDREN_IF_INACTIVE ))
+  }
+
+  if(!this->children.empty() && (this->bActive || this->parentMode & PNODE_UPDATE_CHILDREN_IF_INACTIVE ))
+  {
+    list<PNode*>::iterator child;
+    for (child = this->children.begin(); child != this->children.end(); child ++)
     {
-      list<PNode*>::iterator child;
-      for (child = this->children.begin(); child != this->children.end(); child ++)
-      {
-        /* if this node has changed, make sure, that all children are updated also */
-        if( likely(this->bRelCoorChanged))
-          (*child)->parentCoorChanged ();
-        if( likely(this->bRelDirChanged))
-          (*child)->parentDirChanged ();
-
-        (*child)->updateNode(dt);
-      }
+      /* if this node has changed, make sure, that all children are updated also */
+      if( likely(this->bRelCoorChanged))
+        (*child)->parentCoorChanged ();
+      if( likely(this->bRelDirChanged))
+        (*child)->parentDirChanged ();
+
+      (*child)->updateNode(dt);
     }
-    this->velocity = (this->absCoordinate - this->lastAbsCoordinate) / dt;
-    this->bRelCoorChanged = false;
-    this->bRelDirChanged = false;
+  }
+  this->velocity = (this->absCoordinate - this->lastAbsCoordinate) / dt;
+  this->bRelCoorChanged = false;
+  this->bRelDirChanged = false;
 }
 
@@ -949,5 +955,5 @@
                 this->getAbsCoor ().y,
                 this->getAbsCoor ().z);
-//  this->getAbsDir ().matrix (matrix);
+  //  this->getAbsDir ().matrix (matrix);
 
   /* rotate */
@@ -993,11 +999,11 @@
     {
       // drawing the Dependency graph
-     if (this != PNode::getNullParent())
+      if (this != PNode::getNullParent())
       {
-       glBegin(GL_LINES);
-       glColor3f(color.x, color.y, color.z);
-       glVertex3f(this->getAbsCoor ().x,
-                  this->getAbsCoor ().y,
-                  this->getAbsCoor ().z);
+        glBegin(GL_LINES);
+        glColor3f(color.x, color.y, color.z);
+        glVertex3f(this->getAbsCoor ().x,
+                   this->getAbsCoor ().y,
+                   this->getAbsCoor ().z);
         glColor3f(childColor.x, childColor.y, childColor.z);
         glVertex3f((*child)->getAbsCoor ().x,
@@ -1074,17 +1080,17 @@
   SYNCHELP_READ_FKT( BaseObject::writeState, NWT_PN_BO_WRITESTATE );
 
-//   char * parentName = NULL;
-//   SYNCHELP_READ_STRINGM( parentName );
-//
-//   if ( strcmp(parentName, "")==0 )
-//   {
-//     setParent( (char*)NULL );
-//   }
-//   else
-//   {
-//     setParent( parentName );
-//   }
-//
-//  delete[] parentName;
+  //   char * parentName = NULL;
+  //   SYNCHELP_READ_STRINGM( parentName );
+  //
+  //   if ( strcmp(parentName, "")==0 )
+  //   {
+  //     setParent( (char*)NULL );
+  //   }
+  //   else
+  //   {
+  //     setParent( parentName );
+  //   }
+  //
+  //  delete[] parentName;
 
   int parentMode;
@@ -1106,19 +1112,19 @@
   this->setRelDir( Quaternion( Vector(f2, f3, f4), f1 ) );
 
-//   int n;
-//   char * childName;
-//
-//   PRINTF(0)("JKLO %d %d %d %d\n", data[__synchelp_read_i], data[__synchelp_read_i+1], data[__synchelp_read_i+2], data[__synchelp_read_i+3]);
-//   SYNCHELP_READ_INT( n );
-//   PRINTF(0)("read %s:n=%d\n", this->getName(), n);
-//
-//   for (int i = 0; i<n; i++)
-//   {
-//     SYNCHELP_READ_STRINGM( childName );
-//     PRINTF(0)("RCVD CHILD = %s\n", childName);
-//     addChild( childName );
-//     delete childName;
-//     childName = NULL;
-//   }
+  //   int n;
+  //   char * childName;
+  //
+  //   PRINTF(0)("JKLO %d %d %d %d\n", data[__synchelp_read_i], data[__synchelp_read_i+1], data[__synchelp_read_i+2], data[__synchelp_read_i+3]);
+  //   SYNCHELP_READ_INT( n );
+  //   PRINTF(0)("read %s:n=%d\n", this->getName(), n);
+  //
+  //   for (int i = 0; i<n; i++)
+  //   {
+  //     SYNCHELP_READ_STRINGM( childName );
+  //     PRINTF(0)("RCVD CHILD = %s\n", childName);
+  //     addChild( childName );
+  //     delete childName;
+  //     childName = NULL;
+  //   }
 
   return SYNCHELP_READ_N;
@@ -1137,12 +1143,12 @@
   SYNCHELP_WRITE_FKT( BaseObject::readState, NWT_PN_BO_WRITESTATE );
 
-//   if ( this->parent )
-//   {
-//     SYNCHELP_WRITE_STRING( parent->getName() );
-//   }
-//   else
-//   {
-//     SYNCHELP_WRITE_STRING( "" );
-//   }
+  //   if ( this->parent )
+  //   {
+  //     SYNCHELP_WRITE_STRING( parent->getName() );
+  //   }
+  //   else
+  //   {
+  //     SYNCHELP_WRITE_STRING( "" );
+  //   }
 
   SYNCHELP_WRITE_INT( this->parentMode, NWT_PN_PARENTMODE );
@@ -1157,25 +1163,25 @@
   SYNCHELP_WRITE_FLOAT( this->relDirection.v.z, NWT_PN_ROTZ );
 
-//   int n = children.size();
-//   //check if camera is in children
-//   for (std::list<PNode*>::const_iterator it = children.begin(); it!=children.end(); it++)
-//   {
-//     if ( (*it)->isA(CL_CAMERA) )
-//       n--;
-//   }
-//   PRINTF(0)("write %s:n=%d\n", this->getName(), n);
-//   SYNCHELP_WRITE_INT( n );
-//   PRINTF(0)("ASDF %d %d %d %d\n", data[__synchelp_write_i-4], data[__synchelp_write_i-3], data[__synchelp_write_i-2], data[__synchelp_write_i-1]);
-//
-//
-//   for (std::list<PNode*>::const_iterator it = children.begin(); it!=children.end(); it++)
-//   {
-//     //dont add camera because there is only one camera attached to local player
-//     if ( !(*it)->isA(CL_CAMERA) )
-//     {
-//       PRINTF(0)("SENDING CHILD: %s\n", (*it)->getName());
-//       SYNCHELP_WRITE_STRING( (*it)->getName() );
-//     }
-//   }
+  //   int n = children.size();
+  //   //check if camera is in children
+  //   for (std::list<PNode*>::const_iterator it = children.begin(); it!=children.end(); it++)
+  //   {
+  //     if ( (*it)->isA(CL_CAMERA) )
+  //       n--;
+  //   }
+  //   PRINTF(0)("write %s:n=%d\n", this->getName(), n);
+  //   SYNCHELP_WRITE_INT( n );
+  //   PRINTF(0)("ASDF %d %d %d %d\n", data[__synchelp_write_i-4], data[__synchelp_write_i-3], data[__synchelp_write_i-2], data[__synchelp_write_i-1]);
+  //
+  //
+  //   for (std::list<PNode*>::const_iterator it = children.begin(); it!=children.end(); it++)
+  //   {
+  //     //dont add camera because there is only one camera attached to local player
+  //     if ( !(*it)->isA(CL_CAMERA) )
+  //     {
+  //       PRINTF(0)("SENDING CHILD: %s\n", (*it)->getName());
+  //       SYNCHELP_WRITE_STRING( (*it)->getName() );
+  //     }
+  //   }
 
   return SYNCHELP_WRITE_N;
