Changeset 3594 in orxonox.OLD for orxonox/trunk/src
- Timestamp:
- Mar 17, 2005, 5:27:36 PM (20 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/defs/debug.h
r3592 r3594 52 52 53 53 #define DEBUG_MODULE_IMPORTER 0 54 #define DEBUG_MODULE_TRACK_MANAGER 054 #define DEBUG_MODULE_TRACK_MANAGER 3 55 55 #define DEBUG_MODULE_LIGHT 0 56 56 #define DEBUG_MODULE_PLAYER 0 -
orxonox/trunk/src/track_manager.cc
r3593 r3594 65 65 if ((!this->isJoined &&this->childCount > 0) || (this->isJoined && this->mainJoin)) 66 66 { 67 for (int i=0; i < this->childCount; i++) 68 delete this->children[i]; 67 TrackElement* enumElem = children->enumerate(); 68 while (enumElem) 69 { 70 delete enumElem; 71 enumElem = children->nextElement(); 72 } 69 73 delete this->children; 70 74 } … … 85 89 // search on. 86 90 if (this->childCount > 0) 87 for (int i=0; i < this->childCount; i++) 88 { 89 TrackElement* tmpElem; 90 if ((tmpElem = this->children[i]->findByID(trackID))) 91 return tmpElem; 92 } 93 else return NULL; 91 { 92 TrackElement* enumElem = this->children->enumerate(); 93 TrackElement* tmpElem; 94 while (enumElem) 95 { 96 if ((tmpElem = enumElem->findByID(trackID))) 97 return tmpElem; 98 enumElem = this->children->nextElement(); 99 } 100 } 101 else 102 return NULL; 94 103 } 95 104 … … 106 115 else 107 116 { 108 for (int i = 0; i < this->childCount; i++) 109 if(!this->children[i]->backLoopCheck(trackElem)) 110 return false; 117 TrackElement* enumElem = this->children->enumerate(); 118 while (enumElem) 119 { 120 if(!enumElem->backLoopCheck(trackElem)) 121 return false; 122 enumElem = this->children->nextElement(); 123 } 111 124 112 125 return true; 113 126 } 127 } 128 129 /** 130 \param childNumber which child to return 131 \returns the n-the children (starting at 0) 132 */ 133 TrackElement* TrackElement::getChild(int childCount) 134 { 135 if (this->childCount == 0) 136 return NULL; 137 if (childCount > this->childCount) 138 childCount = this->childCount; 139 140 TrackElement* enumElem = this->children->enumerate(); 141 for (int i = 0; i < childCount; i++) 142 enumElem = this->children->nextElement(); 143 return enumElem; 114 144 } 115 145 … … 155 185 PRINT(0)(" has no child\n"); 156 186 else if (this->childCount == 1) 157 PRINT(0)(" has 1 child: =%d=\n", this-> children[0]->ID);187 PRINT(0)(" has 1 child: =%d=\n", this->getChild(0)->ID); 158 188 else if (this->childCount > 1) 159 189 { 160 190 PRINT(0)(" has %d children: ", this->childCount); 161 for(int i = 0; i < this->childCount; i++) 162 PRINT(0)("=%d= ", this->children[i]->ID); 191 TrackElement* enumElem = this->children->enumerate(); 192 while (enumElem) 193 { 194 PRINT(0)("=%d= ", enumElem->ID); 195 enumElem = this->children->nextElement(); 196 } 163 197 PRINT(0)("\n"); 164 198 } … … 246 280 Vector nodeRelCoord = tmpNode->getRelCoor(); 247 281 float minDist = 100000000; 248 int nodeNumber = 0; 249 for (int i = 0; i < this->childCount; i++) 250 { 251 float dist = (nodeRelCoord - this->children[i]->curve->getNode(4)).len(); 282 int childNumber = 0; 283 int i = 0; 284 285 TrackElement* enumElem = this->children->enumerate(); 286 while (enumElem) 287 { 288 float dist = (nodeRelCoord - enumElem->curve->getNode(4)).len(); 252 289 if (dist < minDist) 253 290 { 254 291 minDist = dist; 255 nodeNumber = i; 256 } 257 } 258 PRINTF(4)("PathDecision with nearest algorithm: %d\n", nodeNumber); 259 return nodeNumber; 292 childNumber = i; 293 } 294 i++; 295 enumElem = this->children->nextElement(); 296 } 297 298 PRINTF(4)("PathDecision with nearest algorithm: %d\n", childNumber); 299 return childNumber; 260 300 } 261 301 … … 270 310 TrackManager::TrackManager(void) 271 311 { 272 this->setClassName 312 this->setClassName("TrackManager"); 273 313 274 singletonRef = this;314 TrackManager::singletonRef = this; 275 315 276 316 PRINTF(3)("Initializing the TrackManager\n"); … … 281 321 this->maxTime = 0; 282 322 this->trackElemCount = 1; 283 this-> bindSlave = this->trackNode = new TrackNode();323 this->setBindSlave(this->trackNode = new TrackNode()); 284 324 } 285 325 … … 292 332 PRINTF(3)("Destruct TrackManager\n"); 293 333 294 PRINTF( 3)("Deleting all the TrackElements\n");334 PRINTF(4)("Deleting all the TrackElements\n"); 295 335 delete this->firstTrackElem; 296 336 297 337 // we do not have a TrackManager anymore 298 singletonRef = NULL;338 TrackManager::singletonRef = NULL; 299 339 } 300 340 … … 309 349 TrackManager* TrackManager::getInstance(void) 310 350 { 311 if (! singletonRef)312 singletonRef = new TrackManager();313 return singletonRef;351 if (!TrackManager::singletonRef) 352 TrackManager::singletonRef = new TrackManager(); 353 return TrackManager::singletonRef; 314 354 } 315 355 … … 322 362 this->currentTrackElem->childCount = childCount; 323 363 this->currentTrackElem->mainJoin = true; 324 this->currentTrackElem->children = new TrackElement*[childCount]; 325 for (int i=0; i<childCount; i++) 326 { 327 this->currentTrackElem->children[i] = new TrackElement(); 328 this->currentTrackElem->children[i]->ID = ++trackElemCount; 329 this->currentTrackElem->children[i]->startingTime = this->currentTrackElem->endTime + this->currentTrackElem->jumpTime; 330 this->addPoint(this->currentTrackElem->curve->getNode(this->currentTrackElem->curve->getNodeCount()), this->currentTrackElem->children[i]); 364 this->currentTrackElem->children = new tList<TrackElement>(); 365 for (int i = 0; i < childCount; i++) 366 { 367 TrackElement* newElem = new TrackElement(); 368 this->currentTrackElem->children->add(newElem); 369 newElem->ID = ++trackElemCount; 370 newElem->startingTime = this->currentTrackElem->endTime + this->currentTrackElem->jumpTime; 371 this->addPoint(this->currentTrackElem->curve->getNode(this->currentTrackElem->curve->getNodeCount()), this->currentTrackElem->getChild(i)); 331 372 } 332 373 if (childCount == 1) 333 this->currentTrackElem-> children[0]->setName(this->currentTrackElem->getName());374 this->currentTrackElem->getChild(0)->setName(this->currentTrackElem->getName()); 334 375 } 335 376 … … 356 397 this->currentTrackElem = tmpElem; 357 398 else 358 printf("TrackElement not Found, leaving unchanged\n");359 printf("now Working on %d\n", this->currentTrackElem->ID);399 PRINTF(2)("TrackElement not Found, leaving unchanged\n"); 400 PRINTF(4)("now Working on %d\n", this->currentTrackElem->ID); 360 401 361 402 } … … 428 469 int TrackManager::addHotPoint(Vector newPoint) 429 470 { 430 printf("setting up a HotPoint\n");471 PRINTF(4)("setting up a HotPoint\n"); 431 472 if (this->currentTrackElem->isFresh) 432 473 { … … 439 480 this->currentTrackElem->nodeCount++; 440 481 this->initChildren(1); 441 this->currentTrackElem = this->currentTrackElem-> children[0];482 this->currentTrackElem = this->currentTrackElem->getChild(0); 442 483 } 443 484 … … 451 492 int TrackManager::setSavePoint(void) 452 493 { 453 printf("setting up a SavePoint.\n");494 PRINTF(4)("setting up a SavePoint.\n"); 454 495 if (this->currentTrackElem->isFork || this->currentTrackElem->isSavePoint) 455 return this->currentTrackElem->children[1]->ID; 496 { 497 PRINTF(2)("%d is already finished \n", currentTrackElem->ID); 498 return this->currentTrackElem->getChild(0)->ID; 499 } 456 500 this->currentTrackElem->isSavePoint = true; 457 501 this->currentTrackElem->isHotPoint = true; 458 502 459 503 this->initChildren(1); 460 this->currentTrackElem = this->currentTrackElem-> children[0];504 this->currentTrackElem = this->currentTrackElem->getChild(0); 461 505 } 462 506 … … 493 537 void TrackManager::forkV(unsigned int count, int* trackIDs) 494 538 { 495 printf("Forking with %d children\n", count);539 PRINTF(4)("Forking with %d children\n", count); 496 540 if (this->currentTrackElem->isSavePoint) 497 541 return; … … 521 565 { 522 566 TrackElement* tmpElem = this->findTrackElementByID(groupID); 523 524 switch (cond) 525 { 526 case LOWEST: 527 tmpElem->condFunc = &TrackElement::lowest; 528 break; 529 case HIGHEST: 530 tmpElem->condFunc = &TrackElement::highest; 531 break; 532 case RANDOM: 533 tmpElem->condFunc = &TrackElement::random; 534 break; 535 case LEFTRIGHT: 536 tmpElem->condFunc = &TrackElement::leftRight; 537 break; 538 case NEAREST: 539 tmpElem->condFunc = &TrackElement::nearest; 540 break; 541 case ENEMYKILLED: 542 break; 543 } 544 tmpElem->subject=subject; 567 if (!tmpElem->isFork) 568 { 569 PRINTF(2)("%d is not a Fork, and no condition can be set in this case\n", tmpElem->ID); 570 return; 571 } 572 else 573 { 574 switch (cond) 575 { 576 case LOWEST: 577 tmpElem->condFunc = &TrackElement::lowest; 578 break; 579 case HIGHEST: 580 tmpElem->condFunc = &TrackElement::highest; 581 break; 582 case RANDOM: 583 tmpElem->condFunc = &TrackElement::random; 584 break; 585 case LEFTRIGHT: 586 tmpElem->condFunc = &TrackElement::leftRight; 587 break; 588 case NEAREST: 589 tmpElem->condFunc = &TrackElement::nearest; 590 break; 591 case ENEMYKILLED: 592 break; 593 } 594 tmpElem->subject=subject; 595 } 545 596 } 546 597 … … 576 627 void TrackManager::joinV(unsigned int count, int* trackIDs) 577 628 { 578 printf("Joining %d tracks and merging to Track %d\n", count, trackIDs[0]);629 PRINTF(3)("Joining %d tracks and merging to Track %d\n", count, trackIDs[0]); 579 630 580 631 // checking if there is a back-loop-connection and ERROR if it is. 581 632 TrackElement* tmpTrackElem = this->findTrackElementByID(trackIDs[0]); 582 633 if (!tmpTrackElem->backLoopCheck(tmpTrackElem)) 583 PRINTF( 1)("Backloop connection detected at joining trackElements\n");634 PRINTF(2)("Backloop connection detected at joining trackElements\n"); 584 635 585 636 // chanching work-on to temporary value. going back at the end. … … 631 682 } 632 683 if(firstJoint->childCount > 0) 633 for(int i = 0; i < firstJoint->childCount; i++) 634 { 635 printf("Setting startingTime of %d to %f.\n", firstJoint->children[i]->ID, tmpLatestTime); 636 firstJoint->children[i]->startingTime = tmpLatestTime; 637 firstJoint->children[i]->endTime = tmpLatestTime+firstJoint->children[i]->duration; 638 } 639 684 { 685 TrackElement* enumElem = firstJoint->children->enumerate(); 686 while (enumElem) 687 { 688 PRINTF(4)("Setting startingTime of %d to %f.\n", enumElem->ID, tmpLatestTime); 689 enumElem->startingTime = tmpLatestTime; 690 enumElem->endTime = tmpLatestTime + enumElem->duration; 691 692 enumElem = firstJoint->children->nextElement(); 693 } 694 } 640 695 // returning to the TrackElement we were working on. 641 696 this->workOn(tmpCurrentWorkingID); … … 652 707 { 653 708 TrackElement* tmpElem = findTrackElementByID(i); 654 if (tmpElem->childCount>0 && tmpElem->mainJoin) 655 { 656 for (int j = 0; j < tmpElem->childCount; j++) 709 if (tmpElem->childCount > 0 && tmpElem->mainJoin) 710 { 711 712 TrackElement* enumElem = tmpElem->children->enumerate(); 713 while (enumElem) 657 714 { 658 715 659 716 // c1-continuity 660 tmpElem->children[j]->curve->addNode(tmpElem->children[j]->curve->getNode(0) +661 (( tmpElem->children[j]->curve->getNode(0) -717 enumElem->curve->addNode(enumElem->curve->getNode(0) + 718 ((enumElem->curve->getNode(0) - 662 719 tmpElem->curve->getNode(tmpElem->curve->getNodeCount()-1)) 663 720 ),2); 664 tmpElem->children[j]->nodeCount++;721 enumElem->nodeCount++; 665 722 // c2-continuity 666 tmpElem->children[j]->curve->addNode((tmpElem->curve->getNode(tmpElem->curve->getNodeCount())-723 enumElem->curve->addNode((tmpElem->curve->getNode(tmpElem->curve->getNodeCount())- 667 724 tmpElem->curve->getNode(tmpElem->curve->getNodeCount()-1)) * 4 + 668 725 tmpElem->curve->getNode(tmpElem->curve->getNodeCount()-2), 3); 669 tmpElem->children[j]->nodeCount++;670 printf("accelerations: %d-in: count: %d, %f, %f, %f\n %d-out: count: %d %f, %f, %f\n",726 enumElem->nodeCount++; 727 PRINTF(5)("accelerations: %d-in: count: %d, %f, %f, %f\n %d-out: count: %d %f, %f, %f\n", 671 728 tmpElem->ID, tmpElem->nodeCount, 672 729 tmpElem->curve->calcAcc(0.999).x, tmpElem->curve->calcAcc(0.999).y, tmpElem->curve->calcAcc(0.999).z, 673 tmpElem->children[j]->ID, tmpElem->children[j]->nodeCount, 674 tmpElem->children[j]->curve->calcAcc(0).x, tmpElem->children[j]->curve->calcAcc(0).y, tmpElem->children[j]->curve->calcAcc(0).z); 730 enumElem->ID, enumElem->nodeCount, 731 enumElem->curve->calcAcc(0).x, enumElem->curve->calcAcc(0).y, enumElem->curve->calcAcc(0).z); 732 733 enumElem = tmpElem->children->nextElement(); 675 734 } 735 736 676 737 } 677 738 } … … 720 781 // jump to the next TrackElement and also set the history of the new Element to the old one. 721 782 TrackElement* tmpHistoryElem = this->currentTrackElem; 722 this->currentTrackElem = this->currentTrackElem-> children[this->choosePath(this->currentTrackElem)];783 this->currentTrackElem = this->currentTrackElem->getChild(this->choosePath(this->currentTrackElem)); 723 784 this->currentTrackElem->history = tmpHistoryElem; 724 785 } -
orxonox/trunk/src/track_manager.h
r3593 r3594 38 38 bool backLoopCheck(TrackElement* trackElem); 39 39 40 TrackElement* getChild(int childNumber); 41 void setName(const char* name); 42 char* getName(void) const; 43 40 44 // atributes 41 45 bool isFresh; //!< If no Points where added until now … … 53 57 Curve* curve; //!< The Curve of this TrackElement 54 58 int childCount; //!< The number of Children This TrackElement has. 55 TrackElement** children; //!< A TrackElement can have a Tree of following TrackElements.59 tList<TrackElement>* children; //!< A TrackElement can have a Tree of following TrackElements. 56 60 57 void setName(const char* name);58 char* getName(void) const;59 61 60 62 // runtime
Note: See TracChangeset
for help on using the changeset viewer.