Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9869 in orxonox.OLD for trunk/src/lib/coord


Ignore:
Timestamp:
Oct 3, 2006, 12:19:30 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

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

Legend:

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

    r9656 r9869  
    1919
    2020#include "util/loading/load_param.h"
    21 #include "class_list.h"
    2221
    2322#include "netdefs.h"
     
    3029#include "color.h"
    3130
     31
     32ObjectListDefinition(PNode);
    3233/**
    3334 * @brief standard constructor
     
    3839  : BaseObject(), Synchronizeable()
    3940{
    40   this->setClassID(CL_PARENT_NODE, "PNode");
     41  this->registerObject(this, PNode::_objectList);
    4142
    4243  this->bRelCoorChanged = true;
     
    7980  PRINTF(4)("delete %s::%s\n", this->getClassCName(), this->getCName());
    8081  // remove the Node, delete it's children (if required).
    81   std::list<PNode*>::iterator deleteNode;
    82   unsigned int size;
     82  PNode* last = NULL;
     83  //this->debugNode(0);
     84
    8385  while(!this->children.empty())
    8486  {
    85     deleteNode = this->children.begin();
    86     size = this->children.size();
     87    PNode* deleteNode = this->children.front();
     88    if (deleteNode == last)
     89    {
     90      PRINTF(1)("Node same as last that was tried to be deleted. FORCE reparent to NULL of %p\n", deleteNode);
     91      (deleteNode->setParent( NULL));
     92      continue;
     93    }
    8794    if ((this->parentMode & PNODE_PROHIBIT_CHILD_DELETE) ||
    88         ((*deleteNode)->parentMode & PNODE_PROHIBIT_DELETE_WITH_PARENT))
     95        (deleteNode->parentMode & PNODE_PROHIBIT_DELETE_WITH_PARENT))
    8996    {
    90       if (this == PNode::nullParent && (*deleteNode)->parentMode & PNODE_REPARENT_TO_NULL)
     97      if (this == PNode::nullParent && deleteNode->parentMode & PNODE_REPARENT_TO_NULL)
    9198      {
    9299        PRINTF(4)("%s::%s deletes %s::%s\n",
    93100                  this->getClassCName(), this->getCName(),
    94                   (*deleteNode)->getClassCName(), (*deleteNode)->getCName());
    95         delete (*deleteNode);
     101                  deleteNode->getClassCName(), deleteNode->getCName());
     102        delete deleteNode;
    96103      }
    97104      else
     
    99106        PRINTF(4)("%s::%s reparents %s::%s\n",
    100107                  this->getClassCName(), this->getCName(),
    101                   (*deleteNode)->getClassCName(), (*deleteNode)->getCName());
    102         (*deleteNode)->reparent();
     108                  deleteNode->getClassCName(), deleteNode->getCName());
     109        deleteNode->reparent();
    103110      }
    104111    }
     
    107114      PRINTF(4)("%s::%s deletes PNode: %s::%s\n",
    108115                this->getClassCName(), this->getCName(),
    109                 (*deleteNode)->getClassCName(), (*deleteNode)->getCName());
    110       delete (*deleteNode);
     116                deleteNode->getClassCName(), deleteNode->getCName());
     117      delete deleteNode;
    111118    }
     119    last = deleteNode;
    112120  }
    113121
     
    541549void PNode::addChild (const std::string& childName)
    542550{
    543   PNode* childNode = dynamic_cast<PNode*>(ClassList::getObject(childName, CL_PARENT_NODE));
     551  PNode* childNode = PNode::objectList().getObject(childName);
    544552  //  PRINTF(0)("Adding the Child: %s to: %s\n", childName, this->getName());
    545553  //  assert( childNode != NULL );
     
    625633void PNode::setParent (const std::string& parentName)
    626634{
    627   PNode* parentNode = dynamic_cast<PNode*>(ClassList::getObject(parentName, CL_PARENT_NODE));
     635  PNode* parentNode = PNode::objectList().getObject(parentName);
    628636  if (parentNode != NULL)
    629637    parentNode->addChild(this);
     
    681689void PNode::setParentSoft(const std::string& parentName, float bias)
    682690{
    683   PNode* parentNode = dynamic_cast<PNode*>(ClassList::getObject(parentName, CL_PARENT_NODE));
     691  PNode* parentNode = PNode::objectList().getObject(parentName);
    684692  if (parentNode != NULL)
    685693    this->setParentSoft(parentNode, bias);
     
    730738  if (likely(PNode::nullParent == NULL))
    731739  {
    732     PNode::nullParent = new PNode(NULL, PNODE_PARENT_MODE_DEFAULT | PNODE_REPARENT_TO_NULL);
    733     PNode::nullParent->setClassID(CL_NULL_PARENT, "NullParent");
     740    PNode::nullParent = new NullParent();
     741    //PNode::nullParent->registerObject(, CL_NULL_PARENT);
    734742    PNode::nullParent->setName("NullParent");
    735743    PNode::nullParent->setSynchronized(true);
     
    915923  int childNodeCount = 0;
    916924  this->countChildNodes(childNodeCount);
    917 
     925  printf("%p:", this);
    918926  PRINT(0)("PNode(%s::%s) - absCoord: (%0.2f, %0.2f, %0.2f), relCoord(%0.2f, %0.2f, %0.2f), direction(%0.2f, %0.2f, %0.2f) - %s - %d childs\n",
    919927           this->getClassCName(),
     
    11061114}
    11071115
    1108 
     1116ObjectListDefinition(NullParent);
     1117
     1118NullParent::NullParent()
     1119  : PNode(NULL, PNODE_PARENT_MODE_DEFAULT | PNODE_REPARENT_TO_NULL)
     1120{
     1121  this->registerObject(this, NullParent::_objectList);
     1122}
  • trunk/src/lib/coord/p_node.h

    r9406 r9869  
    5050  PNODE_REPARENT_DELETE_CHILDREN       = 0x0040,    //!< Deletes the Children of the node when This Node is Removed. (Use with care).
    5151  /// FIXME
    52    PNODE_REPARENT_KEEP_POSITION         = 0x0080,    //!< Tries to keep the Position if the Node is reparented.
     52  PNODE_REPARENT_KEEP_POSITION         = 0x0080,    //!< Tries to keep the Position if the Node is reparented.
    5353
    5454
     
    7373
    7474//! Patent Node is a Engine to calculate the position of an Object in respect to the position of its parent.
    75 class PNode : virtual public BaseObject, virtual public Synchronizeable {
    76  public:
     75class PNode : virtual public BaseObject, virtual public Synchronizeable
     76{
     77  ObjectListDeclaration(PNode);
     78
     79public:
    7780  PNode (PNode* parent = PNode::getNullParent(), long nodeFlags = PNODE_PARENT_MODE_DEFAULT);
    7881  virtual ~PNode ();
     
    9598  inline const Vector& getRelCoor () const { return this->prevRelCoordinate; };
    9699  /** @returns the Relative Coordinate Destination */
    97   inline const Vector& getRelCoorSoft2D() const { return (this->toCoordinate)? *this->toCoordinate : this->relCoordinate; };
     100inline const Vector& getRelCoorSoft2D() const { return (this->toCoordinate)? *this->toCoordinate : this->relCoordinate; };
    98101  void setAbsCoor (const Vector& absCoord);
    99102  void setAbsCoor (float x, float y, float z);
     
    130133  inline const Quaternion& getRelDir () const { return this->prevRelDirection; };
    131134  /** @returns the Relative Directional Destination */
    132   inline const Quaternion& getRelDirSoft2D() const { return (this->toDirection)? *this->toDirection : this->relDirection; };
     135inline const Quaternion& getRelDirSoft2D() const { return (this->toDirection)? *this->toDirection : this->relDirection; };
    133136  /** @returns a Vector pointing into the relative Direction */
    134137  inline Vector getRelDirV() const { return this->prevRelDirection.apply(Vector(0,1,0)); };
     
    178181  void removeNodeFlags(unsigned short nodeFlags);
    179182
    180   // NULL_PARENT //
    181183  /** @returns the NullParent, the (main) ROOT of the PNode Tree. If it does not yet exist, it will be created. */
    182   static PNode* getNullParent()  { return (PNode::nullParent != NULL)? PNode::nullParent : PNode::createNullParent(); };
     184static PNode* getNullParent()  { return (PNode::nullParent != NULL) ? PNode::nullParent : PNode::createNullParent(); };
    183185
    184186  // UPDATING //
     
    195197  float distance(const PNode* node) const { return (this->getAbsCoor() - node->getAbsCoor()).len(); };
    196198
    197  private:
     199private:
    198200  /** tells the child that the parent's Coordinate has changed */
    199201  inline void parentCoorChanged () { this->bRelCoorChanged = true; }
    200202  /** tells the child that the parent's Direction has changed */
    201203  inline void parentDirChanged () { this->bRelDirChanged = true; }
    202  public:
     204public:
    203205  /** @returns the last calculated coordinate */
    204206  inline Vector getLastAbsCoor() { return this->lastAbsCoordinate; }
    205  private:
     207private:
    206208  static PNode* createNullParent();
    207209  void reparent();
     
    209211  void eraseChild(PNode* child);
    210212
    211  private:
     213private:
    212214  bool               bRelCoorChanged;    //!< If Relative Coordinate has changed since last time we checked
    213215  bool               bRelDirChanged;     //!< If Relative Direction has changed since last time we checked
     
    221223  Vector             lastAbsCoordinate;  //!< this is used for speedcalculation, it stores the last coordinate
    222224  Quaternion         prevRelDirection;   //!< The last Relative Direciton from the last update-Cycle.
    223 //  Quaternion         lastAbsDirection;
     225  //  Quaternion         lastAbsDirection;
    224226
    225227  Vector             velocity;           //!< Saves the velocity.
     
    238240  static PNode*      nullParent;         //!< The ROOT of the main PNode Tree.
    239241
    240   private:
    241     float coorx;
    242     float coory;
    243     float coorz;
    244 
    245     float rotw;
    246     float rotx;
    247     float roty;
    248     float rotz;
    249 
    250   private:
    251     int relCoordinate_handle;
    252     int relDirection_handle;
    253     Vector relCoordinate_write;
    254     Quaternion relDirection_write;
    255 
    256   public:
    257     virtual void varChangeHandler( std::list<int> & id );
     242private:
     243  float coorx;
     244  float coory;
     245  float coorz;
     246
     247  float rotw;
     248  float rotx;
     249  float roty;
     250  float rotz;
     251
     252private:
     253  int relCoordinate_handle;
     254  int relDirection_handle;
     255  Vector relCoordinate_write;
     256  Quaternion relDirection_write;
     257
     258public:
     259  virtual void varChangeHandler( std::list<int> & id );
    258260};
    259261
     262// NULL_PARENT //
     263class NullParent : public PNode
     264{
     265  ObjectListDeclaration(NullParent);
     266  friend class PNode;
     267  NullParent();
     268};
     269
     270
    260271#endif /* _P_NODE_H */
Note: See TracChangeset for help on using the changeset viewer.