Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 12, 2005, 2:27:48 AM (19 years ago)
Author:
bensch
Message:

orxonox/branches/trackManager: constructed a simple pathChooser-module, with Method-function pointer… really fancy stuff

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/trackManager/src/track_manager.cc

    r3498 r3514  
    4747  this->curve = NULL;
    4848  this->children = NULL;
     49  this->condFunc = &TrackElement::random;
    4950}
    5051
     
    110111}
    111112
     113int TrackElement::lowest(void* nothing)
     114{
     115  return 0;
     116}
     117
     118int TrackElement::highest(void* nothing)
     119{
     120  return this->childCount-1;
     121}
     122
     123int TrackElement::random(void* nothing)
     124{
     125  if (this->childCount == 0)
     126    return 0;
     127  else
     128    {
     129      int i = (int)floor ((float)rand()/(float)RAND_MAX * (float)this->childCount);
     130      if (i >= this->childCount)
     131        return this->childCount-1;
     132      else
     133        return i;
     134    }
     135}
    112136
    113137
     
    530554      && this->currentTrackElem->children)
    531555    {
    532       if (this->currentTrackElem->jumpTime > 0) 
     556      if (this->currentTrackElem->jumpTime > 0)
    533557        this->jumpTo(this->localTime + this->currentTrackElem->jumpTime);
    534       this->currentTrackElem = this->currentTrackElem->children[0];
     558      this->currentTrackElem = this->currentTrackElem->children[this->choosePath(this->currentTrackElem)];
    535559    }
    536560  if (this->bindSlave)
     
    559583/**
    560584   \brief a Function that decides which Path we should follow.
    561    \param graphID The Path to choose.
     585   \param trackElem The Path to choose.
    562586   
    563587*/
    564 void TrackManager::choosePath(int graphID)
    565 {
    566 
     588int TrackManager::choosePath(TrackElement* trackElem)
     589{
     590  return (trackElem->*(trackElem->condFunc))(NULL);
    567591}
    568592
Note: See TracChangeset for help on using the changeset viewer.