Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3800 in orxonox.OLD


Ignore:
Timestamp:
Apr 13, 2005, 6:23:17 PM (19 years ago)
Author:
patrick
Message:

orxonox/trunk: defined macro for likely function, PNode now uses this branche prediction mechanism

Location:
orxonox/trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/defs/stdincl.h

    r3608 r3800  
    2929#include "debug.h"
    3030
     31
     32/* performance tweaking stuff */
     33#ifdef __unix__
     34 #include <glib-2.0/glib/gmacros.h>
     35 #define __LIKELY_IF(condition)  if( G_LIKELY(condition))
     36 #define __UNLIKELY_IF(condition) if( G_UNLIKELY(condition))
     37#else
     38 #define __LIKELY_IF(condition)  if( condition)
     39 #define __UNLIKELY_IF(condition) if( condition)
     40#endif
     41
    3142#endif /* _STDINCL_H */
  • orxonox/trunk/src/lib/coord/p_node.cc

    r3799 r3800  
    2929#include "null_parent.h"
    3030
    31 #ifdef __unix__
    32  #include <glib-2.0/glib/gmacros.h>
    33 #endif
    34 
    3531//#include "vector.h"
    3632//#include "quaternion.h"
     
    6460
    6561  *this->absCoordinate = *absCoordinate;
    66 #ifdef __unix__
    67   if ( G_UNLIKELY(parent != NULL))
    68 #else
    69   if ( parent != NULL)
    70 #endif
    71     {
    72       *this->relCoordinate = *this->absCoordinate - parent->getAbsCoor ();
    73       parent->addChild (this);
    74     }
     62
     63  __LIKELY_IF(parent != NULL)
     64  {
     65    *this->relCoordinate = *this->absCoordinate - parent->getAbsCoor ();
     66    parent->addChild (this);
     67  }
    7568  else
    7669    this->relCoordinate = new Vector(0,0,0);
     
    252245void PNode::shiftCoor (Vector* shift)
    253246{
    254 #ifdef __unix__
    255   if( G_UNLIKELY(this->bAbsCoorChanged))
    256 #else
    257   if( this->bAbsCoorChanged)
    258 #endif
     247
     248  __UNLIKELY_IF( this->bAbsCoorChanged)
    259249    {
    260250      *this->absCoordinate = *this->absCoordinate + *shift;
     
    291281void PNode::shiftCoor (Vector shift)
    292282{
    293 #ifdef __unix__
    294   if( G_UNLIKELY(this->bAbsCoorChanged))
    295 #else
    296   if( this->bAbsCoorChanged)
    297 #endif
     283
     284  __UNLIKELY_IF( this->bAbsCoorChanged)
    298285    {
    299286      *this->absCoordinate = *this->absCoordinate + shift;
     
    437424float PNode::getSpeed()
    438425{
    439 #ifdef __unix__
    440   if( G_UNLIKELY(this->time == 0))
    441 #else
    442   if(this->time == 0)
    443 #endif
     426  __UNLIKELY_IF( this->time == 0)
    444427    return 1000;
    445428  Vector diff;
     
    471454void PNode::addChild (PNode* pNode, int parentingMode)
    472455{
    473   if( pNode->parent != NULL )
     456
     457  __UNLIKELY_IF( pNode->parent != NULL)
    474458    {
    475459      PRINTF(3)("PNode::addChild() - reparenting node: removing it and adding it again\n");
     
    585569  this->time = dt;
    586570  PRINTF(4)("PNode::update - %s - (%f, %f, %f)\n", this->objectName, this->absCoordinate->x, this->absCoordinate->y, this->absCoordinate->z);
    587   if(this->mode & PNODE_MOVEMENT )
    588     {
    589       if( this->bAbsCoorChanged /*&& this->timeStamp != DataTank::timeStamp*/)
     571
     572
     573  __LIKELY_IF( this->mode & PNODE_MOVEMENT)
     574    {
     575      __UNLIKELY_IF(this->bAbsCoorChanged /*&& this->timeStamp != DataTank::timeStamp*/)
    590576        {
    591577          /* if you have set the absolute coordinates this overrides all other changes */
    592578          *this->relCoordinate = *this->absCoordinate - parent->getAbsCoor ();
    593579        }
    594       else if( this->bRelCoorChanged /*&& this->timeStamp != DataTank::timeStamp*/)
     580      __LIKELY_IF(this->bRelCoorChanged /*&& this->timeStamp != DataTank::timeStamp*/)
     581
    595582        {
    596583          /*this is bad style... must be deleted later - just for testing*/
    597           if( this->parent == NULL)
     584
     585          /*
     586          __UNLIKELY_IF( this->parent == NULL)
    598587            {
    599588              *this->absCoordinate = *this->relCoordinate;
    600589            }
    601           else
    602             *this->absCoordinate = parent->getAbsCoor() + *this->relCoordinate;       /* update the current absCoordinate */
     590            else */
     591          *this->absCoordinate = parent->getAbsCoor() + *this->relCoordinate;         /* update the current absCoordinate */
    603592        }
    604593    }
     
    606595  if( this->mode & PNODE_LOCAL_ROTATE)
    607596    {
    608       if( this->bAbsDirChanged /*&& this->timeStamp != DataTank::timeStamp*/)
     597      __UNLIKELY_IF( this->bAbsDirChanged /*&& this->timeStamp != DataTank::timeStamp*/)
    609598        {
    610599          /* if you have set the absolute coordinates this overrides all other changes */
    611600          *this->relDirection = *this->absDirection - parent->getAbsDir();
    612601        }
    613       else if( this->bRelDirChanged /*&& this->timeStamp != DataTank::timeStamp*/)
     602      else __LIKELY_IF( this->bRelDirChanged /*&& this->timeStamp != DataTank::timeStamp*/)
    614603        {
    615604          /* update the current absDirection - remember * means rotation around sth.*/
     
    620609  if( this->mode & PNODE_ROTATE_MOVEMENT)
    621610    {
    622       if( this->bAbsCoorChanged /*&& this->timeStamp != DataTank::timeStamp*/)
     611      __UNLIKELY_IF( this->bAbsCoorChanged /*&& this->timeStamp != DataTank::timeStamp*/)
    623612        {
    624613          /* if you have set the absolute coordinates this overrides all other changes */
    625614          *this->relCoordinate = *this->absCoordinate - parent->getAbsCoor ();
    626615        }
    627       else if( this->bRelCoorChanged /*&& this->timeStamp != DataTank::timeStamp*/)
     616      else __LIKELY_IF( this->bRelCoorChanged /*&& this->timeStamp != DataTank::timeStamp*/)
    628617        {
    629618          /*this is bad style... must be deleted later - just for testing*/
    630           if( this->parent == NULL)
     619          /*if( this->parent == NULL)
    631620            *this->absCoordinate = *this->relCoordinate;
    632           else
    633             *this->absCoordinate = parent->getAbsCoor() + parent->getAbsDir().apply(*this->relCoordinate);            /* update the current absCoordinate */
     621            else*/
     622          *this->absCoordinate = parent->getAbsCoor() + parent->getAbsDir().apply(*this->relCoordinate);              /* update the current absCoordinate */
    634623        }
    635624    }
     
    642631    {
    643632      /* if this node has changed, make sure, that all children are updated also */
    644       if( this->bRelCoorChanged || this->bAbsCoorChanged)
     633      __LIKELY_IF( this->bRelCoorChanged || this->bAbsCoorChanged)
    645634        pn->parentCoorChanged ();
    646       if( this->bRelDirChanged || this->bAbsDirChanged)
     635      __LIKELY_IF( this->bRelDirChanged || this->bAbsDirChanged)
    647636        pn->parentDirChanged ();
    648637
Note: See TracChangeset for help on using the changeset viewer.