Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3802 in orxonox.OLD


Ignore:
Timestamp:
Apr 13, 2005, 7:20:38 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: some more performance tweaks on PNode: making arguments const, functions also if possible. regrouping code to speedup perfomance

Location:
orxonox/trunk/src/lib/coord
Files:
2 edited

Legend:

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

    r3800 r3802  
    117117  this->relDirection = new Quaternion();
    118118  this->lastAbsCoordinate = new Vector();
     119  this->diffCoordinate = new Vector();
    119120}
    120121
     
    147148   change it unless you realy know what you are doing.
    148149*/
    149 Vector* PNode::getRelCoor ()
     150Vector* PNode::getRelCoor () const
    150151{
    151152  //Vector r = *this->relCoordinate; /* return a copy, so it can't be modified */
     
    188189   \returns absolute coordinates from (0,0,0)
    189190*/
    190 Vector PNode::getAbsCoor ()
     191Vector PNode::getAbsCoor () const
    191192{
    192193  return *this->absCoordinate;
     
    299300   \returns relative direction to its parent
    300301*/
    301 Quaternion PNode::getRelDir ()
     302Quaternion PNode::getRelDir () const
    302303{
    303304  return *this->relDirection;
     
    331332   \returns absolute coordinates
    332333*/
    333 Quaternion PNode::getAbsDir ()
     334Quaternion PNode::getAbsDir () const
    334335{
    335336  return *this->absDirection;
     
    390391   \todo implement this
    391392*/
    392 void PNode::shiftDir (Quaternion* shift)
    393 {}
     393void PNode::shiftDir (const Quaternion& shift)
     394{
     395  this->bRelDirChanged = true;
     396  *this->relDirection = *this->relDirection * shift;
     397}
    394398
    395399
     
    422426   \brief this calculates the current movement speed of the node
    423427*/
    424 float PNode::getSpeed()
     428float PNode::getSpeed() const
    425429{
    426430  __UNLIKELY_IF( this->time == 0)
    427431    return 1000;
    428   Vector diff;
    429   diff = *this->absCoordinate - *this->lastAbsCoordinate;
    430   float x = diff.len();
    431   return x / this->time;
    432 }
    433 
    434 
    435 /**
    436    \brief adds a child and makes this node to a parent
    437    \param pNode child reference
    438 
    439    use this to add a child to this node.
    440 */
    441 void PNode::addChild (PNode* pNode)
    442 {
    443   this->addChild(pNode, DEFAULT_MODE);
     432  *this->diffCoordinate = *this->absCoordinate - *this->lastAbsCoordinate;
     433  return this->diffCoordinate->len() / this->time;
    444434}
    445435
  • orxonox/trunk/src/lib/coord/p_node.h

    r3683 r3802  
    5757
    5858
    59   Vector* getRelCoor ();
     59  Vector* getRelCoor () const;
    6060  void setRelCoor (Vector* relCoord);
    6161  void setRelCoor (Vector relCoord);
    62   Vector getAbsCoor ();
     62  Vector getAbsCoor () const;
    6363  void setAbsCoor (Vector* absCoord);
    6464  void setAbsCoor (Vector absCoord);
     
    6767  //void shiftCoor (Vector shift);
    6868
    69   Quaternion getRelDir ();
     69  Quaternion getRelDir () const;
    7070  void setRelDir (Quaternion* relDir);
    7171  void setRelDir (Quaternion relDir);
    72   Quaternion getAbsDir ();
     72  Quaternion getAbsDir () const;
    7373  void setAbsDir (Quaternion* absDir);
    7474  void setAbsDir (Quaternion absDir);
    75   void shiftDir (Quaternion* shift);
     75  void shiftDir (const Quaternion& shift);
    7676  void shiftDir (Quaternion shift);
    7777
    78   float getSpeed();
     78  float getSpeed() const;
    7979
    80   void addChild (PNode* pNode);
    81   void addChild (PNode* pNode, int parentingMode);
     80  void addChild (PNode* pNode, int parentingMode = DEFAULT_MODE);
    8281  void removeChild (PNode* pNode);
    8382  void remove();
     
    118117
    119118  Vector* lastAbsCoordinate; //!< this is used for speedcalculation, it stores the last coordinate
     119  Vector* diffCoordinate;    //!< this is stored here for performance reasons, difference to the last vector
    120120  float time;                //!< time since last update
    121121};
Note: See TracChangeset for help on using the changeset viewer.