Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3521 in orxonox.OLD for orxonox/trunk/src/lib


Ignore:
Timestamp:
Mar 12, 2005, 8:45:59 PM (20 years ago)
Author:
patrick
Message:

orxonox/trunk: parenting revisited. fixed some bugs some missunderstandings. made it a little more secure to use. still dev

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

Legend:

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

    r3511 r3521  
    2222
    2323#include "p_node.h"
    24 
     24#include "null_parent.h"
    2525
    2626using namespace std;
     
    259259{}
    260260
    261 
    262 
    263261/**
    264262   \brief adds a child and makes this node to a parent
     
    282280void PNode::addChild (PNode* pNode, parentingMode mode)
    283281{
    284   pNode->mode = mode;
    285   pNode->parent = this;
    286   this->children->add (pNode);
     282  if( pNode->parent == NULL )
     283    {
     284      pNode->mode = mode;
     285      pNode->parent = this;
     286      this->children->add (pNode);
     287    }
     288  else
     289    {
     290      PRINTF(1)("PNode::addChild() - this node has already been added - closed Loop MARK \n");
     291    }
    287292}
    288293
     
    295300{
    296301  this->children->remove (pNode);
     302  pNode->parent = NULL;
    297303}
    298304
     
    302308   \param parent the Parent to set
    303309*/
     310/*
    304311void PNode::setParent (PNode* parent)
    305312{
    306313  parent->addChild(this);
    307314}
     315*/
    308316
    309317/**
     
    368376                }
    369377              else
    370                 this->absCoordinate = parent->getAbsCoor () + this->relCoordinate;            /* update the current absCoordinate */
     378                this->absCoordinate = parent->getAbsCoor() + this->relCoordinate;             /* update the current absCoordinate */
    371379            }
    372380        }
    373381     
    374       if( this->mode == ROTATION && this->mode == ALL)
     382      if( this->mode == ROTATION || this->mode == ALL)
    375383        {
    376384          if( this->bAbsDirChanged /*&& this->timeStamp != DataTank::timeStamp*/)
    377385            {
    378386              /* if you have set the absolute coordinates this overrides all other changes */
    379               this->relDirection = this->absDirection - parent->getAbsDir ();
     387              this->relDirection = this->absDirection - parent->getAbsDir();
    380388            }
    381389          else if( this->bRelDirChanged /*&& this->timeStamp != DataTank::timeStamp*/)
    382390            {
    383391              /* update the current absDirection - remember * means rotation around sth.*/
    384               this->absDirection = parent->getAbsDir () * this->relDirection;
     392              this->absDirection = parent->getAbsDir() * this->relDirection;
    385393            }
    386394        }   
    387       // }
    388395  PNode* pn = this->children->enumerate();
    389396  while( pn != NULL)
     
    457464  return this->objectName;
    458465}
     466
  • orxonox/trunk/src/lib/coord/p_node.h

    r3488 r3521  
    6464  void addChild (PNode* pNode, parentingMode mode);
    6565  void removeChild (PNode* pNode);
    66   void setParent (PNode* parent);
     66  //void setParent (PNode* parent);
    6767  void parentCoorChanged ();
    6868  void parentDirChanged ();
     
    7979  void debug ();
    8080
     81 protected:
    8182  float timeStamp;         //!< this the timeStamp of when the abs{Coordinat, Direction} has been calculated
    8283  char* objectName;        //!< The name of the Object
Note: See TracChangeset for help on using the changeset viewer.