Changeset 5251 in orxonox.OLD for trunk/src/lib/graphics/render2D
- Timestamp:
- Sep 25, 2005, 1:13:19 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
r5215 r5251 36 36 /** 37 37 * standard constructor 38 * @ todo this constructor is not jet implemented - do it39 */38 * @param parent the Parent of this node (default NULL) 39 */ 40 40 Element2D::Element2D (Element2D* parent) 41 41 { … … 48 48 /** 49 49 * standard deconstructor 50 */50 */ 51 51 Element2D::~Element2D () 52 52 { … … 54 54 Render2D::getInstance()->unregisterElement2D(this); 55 55 56 if (this->parent) 57 this->parent->removeChild2D(this); 58 else 59 { 60 tIterator<Element2D>* iterator = this->children->getIterator(); 61 Element2D* pn = iterator->firstElement(); 62 while( pn != NULL) 63 { 64 delete pn; 65 pn = iterator->nextElement(); 66 } 67 delete iterator; 68 /* this deletes all children in the list */ 69 } 56 this->remove2D(); 57 // else 58 // { 59 // tIterator<Element2D>* iterator = this->children->getIterator(); 60 // Element2D* pn = iterator->firstElement(); 61 // while( pn != NULL) 62 // { 63 // delete pn; 64 // pn = iterator->nextElement(); 65 // } 66 // delete iterator; 67 // /* this deletes all children in the list */ 68 // } 70 69 delete this->children; 71 70 … … 90 89 this->bindNode = NULL; 91 90 91 // PNODE-stuff 92 this->children = new tList<Element2D>; 92 93 this->setParentMode2D(E2D_PARENT_ALL); 93 this->parent = NULL; 94 this->children = new tList<Element2D>; 94 if (NullElement2D::isInstanciated()) 95 { 96 this->parent = NullElement2D::getInstance(); 97 NullElement2D::getInstance()->children->add(this); 98 NullElement2D::getInstance()->debug(0); 99 } 100 else 101 this->parent = NULL; 95 102 this->absDirection = 0.0; 96 103 this->relDirection = 0.0; … … 442 449 if( likely(child->parent != NULL)) 443 450 { 444 PRINTF(4)("Element2D::addChild() - reparenting node: removing it and adding it again\n");445 451 child->parent->children->remove(child); 446 452 } … … 505 511 void Element2D::setParent2D (Element2D* parent) 506 512 { 507 parent->addChild2D(this); 513 if (parent != NULL) 514 parent->addChild2D(this); 508 515 } 509 516 … … 517 524 if (parentNode != NULL) 518 525 parentNode->addChild2D(this); 519 520 526 } 521 527 -
trunk/src/lib/graphics/render2D/element_2d.h
r5215 r5251 218 218 public: 219 219 /** @returns a Pointer to the only object of this Class */ 220 inline static NullElement2D* getInstance() { if (!singletonRef) singletonRef = new NullElement2D(); return singletonRef; }; 220 inline static NullElement2D* getInstance() { if (!NullElement2D::singletonRef) NullElement2D::singletonRef = new NullElement2D(); return NullElement2D::singletonRef; }; 221 inline static bool isInstanciated() { return (likely(NullElement2D::singletonRef != NULL))?true:false; }; 221 222 virtual ~NullElement2D (); 222 223
Note: See TracChangeset
for help on using the changeset viewer.