Changeset 9869 in orxonox.OLD for trunk/src/lib/coord/p_node.cc
- Timestamp:
- Oct 3, 2006, 12:19:30 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/coord/p_node.cc
r9656 r9869 19 19 20 20 #include "util/loading/load_param.h" 21 #include "class_list.h"22 21 23 22 #include "netdefs.h" … … 30 29 #include "color.h" 31 30 31 32 ObjectListDefinition(PNode); 32 33 /** 33 34 * @brief standard constructor … … 38 39 : BaseObject(), Synchronizeable() 39 40 { 40 this-> setClassID(CL_PARENT_NODE, "PNode");41 this->registerObject(this, PNode::_objectList); 41 42 42 43 this->bRelCoorChanged = true; … … 79 80 PRINTF(4)("delete %s::%s\n", this->getClassCName(), this->getCName()); 80 81 // 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 83 85 while(!this->children.empty()) 84 86 { 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 } 87 94 if ((this->parentMode & PNODE_PROHIBIT_CHILD_DELETE) || 88 ( (*deleteNode)->parentMode & PNODE_PROHIBIT_DELETE_WITH_PARENT))95 (deleteNode->parentMode & PNODE_PROHIBIT_DELETE_WITH_PARENT)) 89 96 { 90 if (this == PNode::nullParent && (*deleteNode)->parentMode & PNODE_REPARENT_TO_NULL)97 if (this == PNode::nullParent && deleteNode->parentMode & PNODE_REPARENT_TO_NULL) 91 98 { 92 99 PRINTF(4)("%s::%s deletes %s::%s\n", 93 100 this->getClassCName(), this->getCName(), 94 (*deleteNode)->getClassCName(), (*deleteNode)->getCName());95 delete (*deleteNode);101 deleteNode->getClassCName(), deleteNode->getCName()); 102 delete deleteNode; 96 103 } 97 104 else … … 99 106 PRINTF(4)("%s::%s reparents %s::%s\n", 100 107 this->getClassCName(), this->getCName(), 101 (*deleteNode)->getClassCName(), (*deleteNode)->getCName());102 (*deleteNode)->reparent();108 deleteNode->getClassCName(), deleteNode->getCName()); 109 deleteNode->reparent(); 103 110 } 104 111 } … … 107 114 PRINTF(4)("%s::%s deletes PNode: %s::%s\n", 108 115 this->getClassCName(), this->getCName(), 109 (*deleteNode)->getClassCName(), (*deleteNode)->getCName());110 delete (*deleteNode);116 deleteNode->getClassCName(), deleteNode->getCName()); 117 delete deleteNode; 111 118 } 119 last = deleteNode; 112 120 } 113 121 … … 541 549 void PNode::addChild (const std::string& childName) 542 550 { 543 PNode* childNode = dynamic_cast<PNode*>(ClassList::getObject(childName, CL_PARENT_NODE));551 PNode* childNode = PNode::objectList().getObject(childName); 544 552 // PRINTF(0)("Adding the Child: %s to: %s\n", childName, this->getName()); 545 553 // assert( childNode != NULL ); … … 625 633 void PNode::setParent (const std::string& parentName) 626 634 { 627 PNode* parentNode = dynamic_cast<PNode*>(ClassList::getObject(parentName, CL_PARENT_NODE));635 PNode* parentNode = PNode::objectList().getObject(parentName); 628 636 if (parentNode != NULL) 629 637 parentNode->addChild(this); … … 681 689 void PNode::setParentSoft(const std::string& parentName, float bias) 682 690 { 683 PNode* parentNode = dynamic_cast<PNode*>(ClassList::getObject(parentName, CL_PARENT_NODE));691 PNode* parentNode = PNode::objectList().getObject(parentName); 684 692 if (parentNode != NULL) 685 693 this->setParentSoft(parentNode, bias); … … 730 738 if (likely(PNode::nullParent == NULL)) 731 739 { 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); 734 742 PNode::nullParent->setName("NullParent"); 735 743 PNode::nullParent->setSynchronized(true); … … 915 923 int childNodeCount = 0; 916 924 this->countChildNodes(childNodeCount); 917 925 printf("%p:", this); 918 926 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", 919 927 this->getClassCName(), … … 1106 1114 } 1107 1115 1108 1116 ObjectListDefinition(NullParent); 1117 1118 NullParent::NullParent() 1119 : PNode(NULL, PNODE_PARENT_MODE_DEFAULT | PNODE_REPARENT_TO_NULL) 1120 { 1121 this->registerObject(this, NullParent::_objectList); 1122 }
Note: See TracChangeset
for help on using the changeset viewer.