Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 25, 2005, 2:25:27 PM (20 years ago)
Author:
bensch
Message:

orxonox/branches/particleEngine: little patch for the pNode System. now all Vectors are passed as const Vector& … and are also handled as vectors and not pointers internally

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/particleEngine/src/lib/coord/p_node.cc

    r3938 r3957  
    6060  this->init(parent);
    6161
    62   *this->absCoordinate = absCoordinate;
     62  this->absCoordinate = absCoordinate;
    6363
    6464  if (likely(parent != NULL))
    6565  {
    66     *this->relCoordinate = *this->absCoordinate - parent->getAbsCoor ();
     66    this->relCoordinate = this->absCoordinate - parent->getAbsCoor();
    6767    parent->addChild (this);
    6868  }
    69   else
    70     this->relCoordinate = new Vector();
    7169}
    7270
     
    8987  delete []this->objectName;
    9088
    91   delete this->relCoordinate;
    92   delete this->absCoordinate;
    93   delete this->relDirection;
    94   delete this->absDirection;
    95   delete this->lastAbsCoordinate;
    96   delete this->diffCoordinate;
    9789}
    9890
     
    108100  this->objectName = NULL;
    109101  this->time = 1.0; /* set time to 1 to make divisions by zero impossible */
    110 
    111   this->absCoordinate = new Vector();
    112   this->relCoordinate = new Vector();
    113   this->absDirection = new Quaternion();
    114   this->relDirection = new Quaternion();
    115   this->lastAbsCoordinate = new Vector();
    116   this->diffCoordinate = new Vector();
    117102}
    118103
     
    158143{
    159144  this->bRelCoorChanged = true;
    160   *this->relCoordinate = relCoord;
     145  this->relCoordinate = relCoord;
    161146}
    162147
     
    182167{
    183168  this->bAbsCoorChanged = true;
    184   *this->absCoordinate = absCoord;
     169  this->absCoordinate = absCoord;
    185170}
    186171
     
    211196  if( unlikely(this->bAbsCoorChanged))
    212197    {
    213       *this->absCoordinate = *this->absCoordinate + shift;
     198      this->absCoordinate = this->absCoordinate + shift;
    214199    }
    215200  else
    216201    {
    217       *this->relCoordinate = *this->relCoordinate + shift;
     202      this->relCoordinate = this->relCoordinate + shift;
    218203      this->bRelCoorChanged = true;
    219204    }
     
    241226{
    242227  this->bRelCoorChanged = true;
    243   *this->relDirection = relDir;
     228  this->relDirection = relDir;
    244229}
    245230
     
    264249{
    265250  this->bAbsDirChanged = true;
    266   *this->absDirection = absDir;
     251  this->absDirection = absDir;
    267252}
    268253
     
    293278{
    294279  this->bRelDirChanged = true;
    295   *this->relDirection = *this->relDirection * shift;
     280  this->relDirection = this->relDirection * shift;
    296281}
    297282
     
    303288float PNode::getSpeed() const
    304289{
    305   *this->diffCoordinate = *this->absCoordinate - *this->lastAbsCoordinate;
    306   return this->diffCoordinate->len() / this->time;
     290  return (this->absCoordinate - this->lastAbsCoordinate).len() / this->time;
    307291}
    308292
     
    312296Vector PNode::getVelocity() const
    313297{
    314   return (*this->absCoordinate - *this->lastAbsCoordinate) / this->time;
     298  return (this->absCoordinate - this->lastAbsCoordinate) / this->time;
    315299}
    316300
     
    439423void PNode::update (float dt)
    440424{
    441   *this->lastAbsCoordinate = *this->absCoordinate;
     425  this->lastAbsCoordinate = this->absCoordinate;
    442426  this->time = dt;
    443   PRINTF(4)("PNode::update - %s - (%f, %f, %f)\n", this->objectName, this->absCoordinate->x, this->absCoordinate->y, this->absCoordinate->z);
     427  PRINTF(4)("PNode::update - %s - (%f, %f, %f)\n", this->objectName, this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z);
    444428
    445429
     
    449433        {
    450434          /* if you have set the absolute coordinates this overrides all other changes */
    451           *this->relCoordinate = *this->absCoordinate - parent->getAbsCoor ();
     435          this->relCoordinate = this->absCoordinate - parent->getAbsCoor ();
    452436        }
    453437      if( likely(this->bRelCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/)
     
    462446            }
    463447            else */
    464           *this->absCoordinate = parent->getAbsCoor() + *this->relCoordinate;         /* update the current absCoordinate */
     448          this->absCoordinate = parent->getAbsCoor() + this->relCoordinate;           /* update the current absCoordinate */
    465449        }
    466450    }
     
    471455        {
    472456          /* if you have set the absolute coordinates this overrides all other changes */
    473           *this->relDirection = *this->absDirection - parent->getAbsDir();
     457          this->relDirection = this->absDirection - parent->getAbsDir();
    474458        }
    475459      else if( likely(this->bRelDirChanged) /*&& this->timeStamp != DataTank::timeStamp*/)
    476460        {
    477461          /* update the current absDirection - remember * means rotation around sth.*/
    478           *this->absDirection = parent->getAbsDir() * *this->relDirection;
     462          this->absDirection = parent->getAbsDir() * this->relDirection;
    479463        }
    480464    }
     
    485469        {
    486470          /* if you have set the absolute coordinates this overrides all other changes */
    487           *this->relCoordinate = *this->absCoordinate - parent->getAbsCoor ();
     471          this->relCoordinate = this->absCoordinate - parent->getAbsCoor ();
    488472        }
    489473      else if( likely(this->bRelCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/)
     
    493477            *this->absCoordinate = *this->relCoordinate;
    494478            else*/
    495           *this->absCoordinate = parent->getAbsCoor() + parent->getAbsDir().apply(*this->relCoordinate);              /* update the current absCoordinate */
     479          this->absCoordinate = parent->getAbsCoor() + parent->getAbsDir().apply(this->relCoordinate);        /* update the current absCoordinate */
    496480        }
    497481    }
     
    547531{
    548532  PRINTF(2)("PNode::debug() - absCoord: (%f, %f, %f)\n",
    549          this->absCoordinate->x,
    550          this->absCoordinate->y,
    551          this->absCoordinate->z);
     533         this->absCoordinate.x,
     534         this->absCoordinate.y,
     535         this->absCoordinate.z);
    552536}
    553537
     
    558542  for debug purposes realy usefull, not used to work properly
    559543*/
    560 void PNode::setName (char* newName)
     544void PNode::setName (const char* newName)
    561545{
    562546  this->objectName = new char[strlen(newName)+1];
     
    568552  \brief gets the name of the node
    569553*/
    570 char* PNode::getName ()
     554const char* PNode::getName ()
    571555{
    572556  return this->objectName;
Note: See TracChangeset for help on using the changeset viewer.