Changeset 5770 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Nov 25, 2005, 12:40:36 AM (19 years ago)
- Location:
- trunk/src/lib
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/coord/null_parent.h
r5039 r5770 19 19 20 20 private: 21 NullParent (const Vector& absCoordinate = Vector( ));21 NullParent (const Vector& absCoordinate = Vector(0.0, 0.0, 0.0)); 22 22 23 23 private: -
trunk/src/lib/coord/p_node.cc
r5769 r5770 85 85 * then deletes the Element. 86 86 */ 87 88 #include "class_list.h" 87 89 PNode::~PNode () 88 90 { 89 91 // remove the Node, delete it's children. 90 tIterator<PNode>* iterator = this->children->getIterator(); 91 PNode* child = iterator->firstElement(); 92 93 while( child != NULL) 94 { 95 delete child; 96 child = iterator->nextElement(); 97 } 98 delete iterator; 99 92 PNode* tmp; 93 while (this->children.size() > 0) 94 { 95 tmp = this->children.front(); 96 this->children.pop_front(); 97 delete tmp; 98 } 100 99 if (this->parent != NULL) 101 { 102 this->parent->children->remove(this); 103 this->parent = NULL; 104 } 105 delete this->children; 100 { 101 this->parent->children.remove(this); 102 this->parent = NULL; 103 } 106 104 107 105 // remove all other allocated memory. … … 121 119 this->setClassID(CL_PARENT_NODE, "PNode"); 122 120 123 this->children = new tList<PNode>();124 121 this->bRelCoorChanged = true; 125 122 this->bRelDirChanged = true; … … 467 464 { 468 465 PRINTF(5)("PNode::addChild() - reparenting node: removing it and adding it again\n"); 469 child->parent->children ->remove(child);466 child->parent->children.remove(child); 470 467 } 471 468 child->parent = this; 472 469 if (unlikely(this != NULL)) 473 this->children ->add(child);470 this->children.push_back(child); 474 471 child->parentCoorChanged(); 475 472 } … … 509 506 void PNode::removeNode() 510 507 { 511 tIterator<PNode>* iterator = this->children->getIterator(); 512 PNode* pn = iterator->firstElement(); 513 514 while( pn != NULL) 515 { 516 NullParent::getInstance()->addChild(pn); 517 pn = iterator->nextElement(); 518 } 519 delete iterator; 508 list<PNode*>::iterator child; 509 for (child = this->children.begin(); child != this->children.end(); child ++) 510 NullParent::getInstance()->addChild(*child); 511 520 512 if (this->parent != NULL) 521 this->parent->children ->remove(this);513 this->parent->children.remove(this); 522 514 } 523 515 … … 686 678 } 687 679 688 if(this->children ->getSize() > 0)680 if(this->children.size() > 0) 689 681 { 690 tIterator<PNode>* iterator = this->children->getIterator(); 691 PNode* pn = iterator->firstElement(); 692 while( pn != NULL) 682 list<PNode*>::iterator child; 683 for (child = this->children.begin(); child != this->children.end(); child ++) 693 684 { 694 685 /* if this node has changed, make sure, that all children are updated also */ 695 686 if( likely(this->bRelCoorChanged)) 696 pn->parentCoorChanged ();687 (*child)->parentCoorChanged (); 697 688 if( likely(this->bRelDirChanged)) 698 pn->parentDirChanged (); 699 700 pn->updateNode(dt); 701 pn = iterator->nextElement(); 689 (*child)->parentDirChanged (); 690 691 (*child)->updateNode(dt); 702 692 } 703 delete iterator;704 693 } 705 694 this->velocity = (this->absCoordinate - this->lastAbsCoordinate) / dt; … … 712 701 { 713 702 nodes++; 714 tIterator<PNode>* it = this->children->getIterator(); 715 PNode* node = it->firstElement(); 716 while(node != NULL) 717 { 718 node->countChildNodes(nodes); 719 node = it->nextElement(); 720 } 721 703 list<PNode*>::const_iterator child; 704 for (child = this->children.begin(); child != this->children.end(); child ++) 705 (*child)->countChildNodes(nodes); 722 706 } 723 707 … … 733 717 for (unsigned int i = 0; i < level; i++) 734 718 PRINT(0)(" |"); 735 if (this->children ->getSize() > 0)719 if (this->children.size() > 0) 736 720 PRINT(0)(" +"); 737 721 else … … 757 741 if (depth >= 2 || depth == 0) 758 742 { 759 tIterator<PNode>* iterator = this->children->getIterator(); 760 //PNode* pn = this->children->enumerate (); 761 PNode* pn = iterator->firstElement(); 762 while( pn != NULL) 743 list<PNode*>::const_iterator child; 744 for (child = this->children.begin(); child != this->children.end(); child ++) 763 745 { 764 746 if (depth == 0) 765 pn->debugNode(0, level + 1);747 (*child)->debugNode(0, level + 1); 766 748 else 767 pn->debugNode(depth - 1, level +1); 768 pn = iterator->nextElement(); 749 (*child)->debugNode(depth - 1, level +1); 769 750 } 770 delete iterator;771 751 } 772 752 } … … 839 819 /* rotate the current color in HSV space around 20 degree */ 840 820 Vector childColor = Color::HSVtoRGB(Color::RGBtoHSV(color)+Vector(20,0,.0)); 841 tIterator<PNode>* iterator = this->children->getIterator(); 842 PNode* pn = iterator->firstElement(); 843 while( pn != NULL) 821 list<PNode*>::const_iterator child; 822 for (child = this->children.begin(); child != this->children.end(); child ++) 844 823 { 845 824 // drawing the Dependency graph … … 852 831 this->getAbsCoor ().z); 853 832 glColor3f(childColor.x, childColor.y, childColor.z); 854 glVertex3f( pn->getAbsCoor ().x,855 pn->getAbsCoor ().y,856 pn->getAbsCoor ().z);833 glVertex3f((*child)->getAbsCoor ().x, 834 (*child)->getAbsCoor ().y, 835 (*child)->getAbsCoor ().z); 857 836 glEnd(); 858 837 } 859 838 /* if we want to draw the children too */ 860 839 if (depth == 0) /* -> all of them */ 861 pn->debugDraw(0, size, childColor, level+1);840 (*child)->debugDraw(0, size, childColor, level+1); 862 841 else /* -> only the Next one */ 863 pn->debugDraw(depth - 1, size, childColor, level +1); 864 pn = iterator->nextElement(); 842 (*child)->debugDraw(depth - 1, size, childColor, level +1); 865 843 } 866 delete iterator;867 844 } 868 845 if (level == 0) -
trunk/src/lib/coord/p_node.h
r5769 r5770 21 21 #include "base_object.h" 22 22 #include "vector.h" 23 #include <list> 23 24 24 25 // FORWARD DECLARATION … … 155 156 156 157 private: 157 bool bRelCoorChanged; //!< If Relative Coordinate has changed since last time we checked158 bool bRelDirChanged; //!< If Relative Direction has changed since last time we checked158 bool bRelCoorChanged; //!< If Relative Coordinate has changed since last time we checked 159 bool bRelDirChanged; //!< If Relative Direction has changed since last time we checked 159 160 160 Vector relCoordinate; //!< coordinates relative to the parent161 Vector absCoordinate; //!< absolute coordinates in the world ( from (0,0,0) )162 Quaternion relDirection; //!< direction relative to the parent163 Quaternion absDirection; //!< absolute direvtion in the world ( from (0,0,1) )161 Vector relCoordinate; //!< coordinates relative to the parent 162 Vector absCoordinate; //!< absolute coordinates in the world ( from (0,0,0) ) 163 Quaternion relDirection; //!< direction relative to the parent 164 Quaternion absDirection; //!< absolute direvtion in the world ( from (0,0,1) ) 164 165 165 Vector prevRelCoordinate; //!< The last Relative Coordinate from the last update-Cycle.166 Vector lastAbsCoordinate; //!< this is used for speedcalculation, it stores the last coordinate167 Quaternion prevRelDirection; //!< The last Relative Direciton from the last update-Cycle.168 // Quaternion lastAbsDirection;166 Vector prevRelCoordinate; //!< The last Relative Coordinate from the last update-Cycle. 167 Vector lastAbsCoordinate; //!< this is used for speedcalculation, it stores the last coordinate 168 Quaternion prevRelDirection; //!< The last Relative Direciton from the last update-Cycle. 169 // Quaternion lastAbsDirection; 169 170 170 Vector velocity; //!< Saves the velocity.171 Vector velocity; //!< Saves the velocity. 171 172 172 Vector* toCoordinate; //!< a position to which to iterate. (This is used in conjunction with setParentSoft.and set*CoorSoft)173 Quaternion* toDirection; //!< a direction to which to iterate. (This is used in conjunction with setParentSoft and set*DirSoft)174 float bias; //!< how fast to iterate to the given position (default is 1)173 Vector* toCoordinate; //!< a position to which to iterate. (This is used in conjunction with setParentSoft.and set*CoorSoft) 174 Quaternion* toDirection; //!< a direction to which to iterate. (This is used in conjunction with setParentSoft and set*DirSoft) 175 float bias; //!< how fast to iterate to the given position (default is 1) 175 176 176 PNode* parent; //!< a pointer to the parent node177 tList<PNode>*children; //!< list of the children of this PNode177 PNode* parent; //!< a pointer to the parent node 178 std::list<PNode*> children; //!< list of the children of this PNode 178 179 179 unsigned int parentMode; //!< the mode of the binding180 unsigned int parentMode; //!< the mode of the binding 180 181 }; 181 182 -
trunk/src/lib/lang/class_list.cc
r5513 r5770 262 262 enumBO = iterator->nextElement(); 263 263 } 264 delete iterator; 265 break; 264 if (likely(tmp->classID == classID)) 265 { 266 delete iterator; 267 break; 268 } 266 269 } 267 270 tmp = tmp->next;
Note: See TracChangeset
for help on using the changeset viewer.