Changeset 5775 in orxonox.OLD for trunk/src/lib
- Timestamp:
- Nov 25, 2005, 1:54:33 AM (19 years ago)
- Location:
- trunk/src/lib/graphics/render2D
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/render2D/element_2d.cc
r5671 r5775 19 19 #include "render_2d.h" 20 20 21 #include "p_node.h" 22 21 23 #include "graphics_engine.h" 22 #include "p_node.h"23 24 #include "load_param.h" 24 25 #include "tinyxml.h" 25 26 #include "class_list.h" 26 #include "list.h" 27 27 28 #include "color.h" 28 29 … … 73 74 { 74 75 // remove the Node, delete it's children. 75 tIterator<Element2D>* iterator = this->children->getIterator(); 76 Element2D* child = iterator->firstElement(); 77 78 while( child != NULL) 79 { 80 delete child; 81 child = iterator->nextElement(); 82 } 83 delete iterator; 76 list<Element2D*>::iterator child; 77 for (child = this->children.begin(); child != this->children.end(); child++) 78 delete *child; 84 79 85 80 if (this->parent != NULL) 86 81 { 87 this->parent->children ->remove(this);82 this->parent->children.remove(this); 88 83 this->parent = NULL; 89 84 } 90 delete this->children;91 85 92 86 // remove all other allocated memory. … … 113 107 this->setParentMode2D(E2D_PARENT_ALL); 114 108 this->parent = NULL; 115 this->children = new tList<Element2D>;116 109 this->absDirection = 0.0; 117 110 this->relDirection = 0.0; … … 517 510 { 518 511 PRINTF(5)("Element2D::addChild() - reparenting node: removing it and adding it again\n"); 519 child->parent->children ->remove(child);512 child->parent->children.remove(child); 520 513 } 521 514 child->parent = this; … … 523 516 { 524 517 // ELEMENT SORTING TO LAYERS // 525 unsigned int childCount = this->children ->getSize();526 tIterator<Element2D>* iterator = this->children->getIterator(); 527 Element2D* elem = iterator->firstElement();528 while (elem != NULL)529 { 530 if ( elem->layer < child->layer)518 unsigned int childCount = this->children.size(); 519 520 list<Element2D*>::iterator elem; 521 for (elem = this->children.begin(); elem != this->children.end(); elem++) 522 { 523 if ((*elem)->layer < child->layer) 531 524 { 532 this->children ->addAtIteratorPosition(child, iterator);525 this->children.insert(elem, child); 533 526 break; 534 527 } 535 elem = iterator->nextElement(); 536 } 537 delete iterator; 538 if (childCount == this->children->getSize()) 539 this->children->add(child); 528 } 529 530 if (childCount == this->children.size()) 531 this->children.push_back(child); 540 532 //////////////////////////////// 541 533 if (unlikely(this->layer > child->getLayer())) … … 579 571 void Element2D::remove2D() 580 572 { 581 tIterator<Element2D>* iterator = this->children->getIterator(); 582 Element2D* pn = iterator->firstElement(); 583 584 while( pn != NULL) 585 { 586 NullElement2D::getInstance()->addChild2D(pn); 587 pn = iterator->nextElement(); 588 } 589 delete iterator; 590 591 delete this->children; 592 this->children = new tList<Element2D>; 573 list<Element2D*>::iterator child; 574 for (child = this->children.begin(); child != this->children.end(); child++) 575 NullElement2D::getInstance()->addChild2D(*child); 576 577 this->children.erase(this->children.begin(), this->children.end()); 593 578 594 579 if (this->parent != NULL) 595 580 { 596 this->parent->children ->remove(this);581 this->parent->children.remove(this); 597 582 this->parent = NULL; 598 583 } … … 802 787 803 788 // UPDATE CHILDREN 804 if(this->children->getSize() > 0) 805 { 806 tIterator<Element2D>* iterator = this->children->getIterator(); 807 Element2D* pn = iterator->firstElement(); 808 while( pn != NULL) 789 if(this->children.size() > 0) 790 { 791 list<Element2D*>::iterator child; 792 for (child = this->children.begin(); child != this->children.end(); child++) 809 793 { 810 794 /* if this node has changed, make sure, that all children are updated also */ 811 795 if( likely(this->bRelCoorChanged)) 812 pn->parentCoorChanged ();796 (*child)->parentCoorChanged (); 813 797 if( likely(this->bRelDirChanged)) 814 pn->parentDirChanged (); 815 816 pn->update2D(dt); 817 pn = iterator->nextElement(); 818 } 819 delete iterator; 798 (*child)->parentDirChanged (); 799 800 (*child)->update2D(dt); 801 } 820 802 } 821 803 … … 836 818 for (unsigned int i = 0; i < level; i++) 837 819 PRINT(0)(" |"); 838 if (this->children ->getSize() > 0)820 if (this->children.size() > 0) 839 821 PRINT(0)(" +"); 840 822 else … … 853 835 if (depth >= 2 || depth == 0) 854 836 { 855 tIterator<Element2D>* iterator = this->children->getIterator(); 856 Element2D* pn = iterator->firstElement(); 857 while( pn != NULL) 837 list<Element2D*>::const_iterator child; 838 for (child = this->children.begin(); child != this->children.end(); child++) 858 839 { 859 840 if (depth == 0) 860 pn->debug(0, level + 1);841 (*child)->debug(0, level + 1); 861 842 else 862 pn->debug(depth - 1, level +1); 863 pn = iterator->nextElement(); 864 } 865 delete iterator; 843 (*child)->debug(depth - 1, level +1); 844 } 866 845 } 867 846 } … … 879 858 if (this->active) 880 859 this->tick(dt); 881 if (this->children->getSize() > 0) 882 { 883 tIterator<Element2D>* tickIT = children->getIterator(); 884 Element2D* tickElem = tickIT->firstElement(); 885 while (tickElem != NULL) 886 { 887 tickElem->tick2D(dt); 888 tickElem = tickIT->nextElement(); 889 } 890 delete tickIT; 860 if (this->children.size() > 0) 861 { 862 list<Element2D*>::iterator child; 863 for (child = this->children.begin(); child != this->children.end(); child++) 864 (*child)->tick2D(dt); 891 865 } 892 866 } … … 900 874 if (this->visible) 901 875 this->draw(); 902 if (this->children->getSize() > 0) 903 { 904 tIterator<Element2D>* drawIT = children->getIterator(); 905 Element2D* drawElem = drawIT->firstElement(); 906 while (drawElem != NULL) 907 { 876 if (this->children.size() > 0) 877 { 878 list<Element2D*>::const_iterator child; 879 for (child = this->children.begin(); child != this->children.end(); child++) 908 880 if (likely(layer >= this->layer)) 909 drawElem->draw2D(layer); 910 drawElem = drawIT->nextElement(); 911 } 912 delete drawIT; 881 (*child)->draw2D(layer); 913 882 } 914 883 } … … 948 917 { 949 918 Vector childColor = Color::HSVtoRGB(Color::RGBtoHSV(color)+Vector(20,0,.0)); 950 tIterator<Element2D>* iterator = this->children->getIterator(); 951 Element2D* pn = iterator->firstElement(); 952 while( pn != NULL) 919 list<Element2D*>::const_iterator child; 920 for (child = this->children.begin(); child != this->children.end(); child++) 953 921 { 954 922 // drawing the Dependency graph … … 961 929 0); 962 930 glColor3f(childColor.x, childColor.y, childColor.z); 963 glVertex3f( pn->getAbsCoor2D ().x,964 pn->getAbsCoor2D ().y,931 glVertex3f((*child)->getAbsCoor2D ().x, 932 (*child)->getAbsCoor2D ().y, 965 933 0); 966 934 glEnd(); 967 935 } 968 936 if (depth == 0) 969 pn->debugDraw2D(0, size, childColor, level+1);937 (*child)->debugDraw2D(0, size, childColor, level+1); 970 938 else 971 pn->debugDraw2D(depth - 1, size, childColor, level +1); 972 pn = iterator->nextElement(); 973 } 974 delete iterator; 939 (*child)->debugDraw2D(depth - 1, size, childColor, level +1); 940 } 975 941 } 976 942 if (level == 0) -
trunk/src/lib/graphics/render2D/element_2d.h
r5417 r5775 10 10 11 11 #include "vector.h" 12 #include <list> 12 13 13 14 // FORWARD DECLARATION 14 15 class PNode; 15 16 class TiXmlElement; 16 template<class T> class tList;17 17 18 18 //!< An enumerator defining the Depth of a 2D-element. … … 171 171 inline Element2D* getParent2D () const { return this->parent; }; 172 172 /** @returns the List of Children of this Element2D */ 173 inline const tList<Element2D>*getChildren2D() const { return this->children; };173 inline const std::list<Element2D*>& getChildren2D() const { return this->children; }; 174 174 175 175 void setParentSoft2D(Element2D* parentNode, float bias = 1.0); … … 234 234 235 235 Element2D* parent; //!< a pointer to the parent node 236 tList<Element2D>*children; //!< list of the children of this Element2D236 std::list<Element2D*> children; //!< list of the children of this Element2D 237 237 238 238 unsigned int parentMode; //!< the mode of the binding
Note: See TracChangeset
for help on using the changeset viewer.