Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6078 in orxonox.OLD for trunk/src/lib/coord/p_node.h


Ignore:
Timestamp:
Dec 13, 2005, 2:55:08 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: PNode compiles again
PNode is now handled with the erase function of stl, rather than remove (which is totally the wrong way when iterating through a list and delete elements)

File:
1 edited

Legend:

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

    r6075 r6078  
    4343
    4444  // REPARENTING
    45   PNODE_REPARENT_TO_NULLPARENT         = 0x0010,    //!< Reparents to the NullParent, if the Parent is Removed.
     45  PNODE_REPARENT_TO_NULL               = 0x0010,    //!< Reparents to the Null, if the Parent is Removed. Meaning the Node wont have a parent anymore.
    4646  PNODE_REPARENT_TO_PARENTS_PARENT     = 0x0020,    //!< Reparents the Node to the parents (old) parent it the parent gets removed.
     47  /////////////////////////////////////////////     //  ELSE: Reparents to the NullParent.
    4748  PNODE_REPARENT_DELETE_CHILDREN       = 0x0040,    //!< Deletes the Children of the node when This Node is Removed. (Use with care).
    4849  /// FIXME
     
    5455  PNODE_PROHIBIT_DELETE_WITH_PARENT    = 0x0200,    //!< Prohibits the Node to be deleted if the Parent is. Child will be reparented according to the Repaenting-Rules
    5556  PNODE_REPARENT_CHILDREN_ON_REMOVE    = 0x0400,    //!< Reparents the Children of the Node if the Node gets Removed.
     57  PNODE_REPARENT_ON_PARENTS_REMOVE     = 0x0800,    //!< The Node gets Reparented if its Parent gets removed. Child will be reparented according to the Reparenting-Rules.
    5658
    5759  // VISIBILITY/ACTIVITY
     
    6567//! The default mode of the translation-binding.
    6668#define PNODE_PARENT_MODE_DEFAULT PNODE_ALL | \
    67                                   PNODE_REPARENT_CHILDREN_ON_REMOVE | \
    6869                                  PNODE_REPARENT_KEEP_POSITION
    6970
     
    7273class PNode : virtual public BaseObject {
    7374 public:
    74   PNode (PNode* parent = PNode::getNullParent());
     75  PNode (PNode* parent = PNode::getNullParent(), long nodeFlags = PNODE_PARENT_MODE_DEFAULT);
    7576  virtual ~PNode ();
    7677
    7778  void loadParams(const TiXmlElement* root);
    7879
     80  // ACTIVATION //
    7981  inline void activateNode() { this->bActive = true; };
    8082  inline void deactivateNode() { this->bActive = false; };
    8183  inline bool getNodeActiveState() { return this->bActive; };
    8284
     85  // POSITION //
    8386  void setRelCoor (const Vector& relCoord);
    8487  void setRelCoor (float x, float y, float z);
     
    98101  void shiftCoor (float x, float y, float z) { this->shiftCoor(Vector(x, y, z)); };
    99102
     103  // SPEED //
     104  /** @returns the Speed of the Node */
     105  inline float getSpeed() const { return this->velocity.len(); };
     106  /** @returns the Velocity of the Node */
     107  inline const Vector& getVelocity() const { return this->velocity; };
     108
     109
     110  // ROTATION //
    100111  void setRelDir (const Quaternion& relDir);
    101112  void setRelDir (float x, float y, float z);
     
    124135  inline Vector getAbsDirZ() const { return this->absDirection.apply(Vector(0,0,1)); };
    125136
    126   /** @returns the Speed of the Node */
    127   inline float getSpeed() const { return this->velocity.len(); };
    128   /** @returns the Velocity of the Node */
    129   inline const Vector& getVelocity() const { return this->velocity; };
    130 
    131 
     137
     138  // PARENTING //
    132139  void addChild (PNode* child);
    133140  void addChild (const char* childName);
     
    146153  void setParentSoft(const char* parentName, float bias = 1.0);
    147154
     155  // PARENTING_MODE AND OTHER FLAGS //
    148156  void setParentMode (PARENT_MODE parentMode);
    149157  void setParentMode (const char* parentingMode);
     
    151159  int getParentMode() const { return 0x000f & this->parentMode; };
    152160
    153   void addNodeModeFlags(unsigned short nodeFlags);
    154   void removeNodeModeFlags(unsigned short nodeFlags);
    155 
     161  void addNodeFlags(unsigned short nodeFlags);
     162  void removeNodeFlags(unsigned short nodeFlags);
     163
     164  // NULL_PARENT //
    156165  /** @returns the NullParent, the (main) ROOT of the PNode Tree. If it does not yet exist, it will be created. */
    157   static PNode* getNullParent()  { return (PNode::nullParent != NULL || (PNode::nullParent = new PNode(NULL)) != NULL)? PNode::nullParent : NULL; };
    158 
     166  static PNode* getNullParent()  { return (PNode::nullParent != NULL)? PNode::nullParent : PNode::createNullParent(); };
     167
     168  // UPDATING //
    159169  void updateNode (float dt);
    160170
     171  // DEBUG //
    161172  void countChildNodes(int& nodes) const;
    162173  void debugNode (unsigned int depth = 1, unsigned int level = 0) const;
    163174  void debugDraw(unsigned int depth = 1, float size = 1.0, const Vector& color = Vector(1, 0, 0), unsigned int level = 0) const;
    164175
    165 
    166   // helper functions //
     176  // HELPER_FUNCTIONS //
    167177  static const char* parentingModeToChar(int parentingMode);
    168178  static PARENT_MODE charToParentingMode(const char* parentingMode);
     
    170180
    171181 private:
    172   void init();
    173182  /** tells the child that the parent's Coordinate has changed */
    174183  inline void parentCoorChanged () { this->bRelCoorChanged = true; }
     
    178187  inline Vector getLastAbsCoor() { return this->lastAbsCoordinate; }
    179188
     189  static PNode* createNullParent();
    180190  void reparent();
    181191  bool checkIntegrity(const PNode* checkParent) const;
     192  void eraseChild(PNode* child);
    182193
    183194 private:
Note: See TracChangeset for help on using the changeset viewer.