- Timestamp:
- Dec 2, 2005, 12:17:35 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/collision_detection/src/lib/collision_detection/obb_tree_node.cc
r5868 r5869 18 18 #include "obb_tree_node.h" 19 19 #include "list.h" 20 #include <list> 20 21 #include "obb.h" 21 22 #include "obb_tree.h" … … 373 374 374 375 /* 375 this step is split up in t wo: first there will be made a bounding box which is376 very badly centered. In the sec on step there will be calculated a new center376 this step is split up in three: first there will be made a bounding box which is 377 very badly centered. In the section step there will be calculated a new center 377 378 and a better bounding box. 378 379 */ … … 494 495 495 496 /** 496 \briefthis separates an ob-box in the middle497 * @param box: the box to separate498 499 this will separate the box into to smaller boxes. the separation is done along the middle of the longest axis497 * this separates an ob-box in the middle 498 * @param box: the box to separate 499 * 500 * this will separate the box into to smaller boxes. the separation is done along the middle of the longest axis 500 501 */ 501 502 void OBBTreeNode::forkBox(OBB& box) 502 503 { 504 503 505 /* get the longest axis of the box */ 504 506 float aLength = -1.0f; //!< the length of the longest axis … … 540 542 the points depending on which side they are located 541 543 */ 542 tList<const sVec3D> partition1; //!< the vertex partition 1 543 tList<const sVec3D> partition2; //!< the vertex partition 2 544 std::list<const sVec3D*> partition1; //!< the vertex partition 1 545 std::list<const sVec3D*> partition2; //!< the vertex partition 2 546 547 548 //nameList.push_back("Pumba"); 549 //nameList.push_back("Mogli"); 550 //nameList.push_back("Timon"); 551 552 // std::list<char*>::iterator element; 553 // for (element = nameList.begin(); element != nameList.end(); element++) 554 // { 555 // PRINTF(3)("found name: %s in list\n", (*name)); 556 // } 557 544 558 545 559 … … 555 569 tmpDist = this->separationPlane.distancePoint(box.vertices[i]); 556 570 if( tmpDist > 0.0) 557 partition1. add(&box.vertices[i]); /* positive numbers plus zero */571 partition1.push_back(&box.vertices[i]); /* positive numbers plus zero */ 558 572 else 559 partition2. add(&box.vertices[i]); /* negatice numbers */560 } 561 partition1. add(&box.vertices[vertexIndex]);562 partition2. add(&box.vertices[vertexIndex]);563 564 PRINTF(3)("\npartition1: got %i vertices/ partition 2: got %i vertices\n", partition1. getSize(), partition2.getSize());573 partition2.push_back(&box.vertices[i]); /* negatice numbers */ 574 } 575 partition1.push_back(&box.vertices[vertexIndex]); 576 partition2.push_back(&box.vertices[vertexIndex]); 577 578 PRINTF(3)("\npartition1: got %i vertices/ partition 2: got %i vertices\n", partition1.size(), partition2.size()); 565 579 566 580 567 581 /* now comes the separation into two different sVec3D arrays */ 568 582 tIterator<const sVec3D>* iterator; //!< the iterator to go through the lists 569 const sVec3D* element; //!< the elements570 583 int index; //!< index storage place 571 584 sVec3D* vertList1; //!< the vertex list 1 572 585 sVec3D* vertList2; //!< the vertex list 2 573 574 vertList1 = new sVec3D[partition1.getSize()]; 575 vertList2 = new sVec3D[partition2.getSize()]; 576 577 iterator = partition1.getIterator(); 578 element = iterator->firstElement(); 579 index = 0; 580 while( element != NULL) 581 { 582 vertList1[index][0] = element[0][0]; 583 vertList1[index][1] = element[0][1]; 584 vertList1[index][2] = element[0][2]; 586 std::list<const sVec3D*>::iterator element; //!< the list iterator 587 588 vertList1 = new sVec3D[partition1.size()]; 589 vertList2 = new sVec3D[partition2.size()]; 590 591 592 for(element = partition1.begin(), index = 0; element != partition1.end(); element++, index++) 593 { 594 vertList1[index][0] = (*element)[0][0]; 595 vertList1[index][1] = (*element)[0][1]; 596 vertList1[index][2] = (*element)[0][2]; 585 597 ++index; 586 element = iterator->nextElement(); 587 } 588 delete iterator; 598 } 599 589 600 // PRINTF(0)("\npartition 1:\n"); 590 601 // for(int i = 0; i < partition1.getSize(); ++i) … … 593 604 // } 594 605 595 iterator = partition2.getIterator(); 596 element = iterator->firstElement();597 index = 0;598 while( element != NULL) 599 { 600 vertList2[index][0] = element[0][0];601 vertList2[index][1] = element[0][1];602 vertList2[index][ 2] = element[0][2];603 ++index;604 element = iterator->nextElement();606 607 //for (element = nameList.begin(); element != nameList.end(); element++) 608 // iterator = partition2.getIterator(); 609 // element = iterator->firstElement(); 610 611 for(element = partition2.begin(), index = 0; element != partition2.end(); element++, index++) 612 { 613 vertList2[index][0] = (*element)[0][0]; 614 vertList2[index][1] = (*element)[0][1]; 615 vertList2[index][2] = (*element)[0][2]; 605 616 } 606 617 … … 611 622 delete[] this->tmpVert2; 612 623 this->tmpVert2 = vertList2; 613 this->tmpLen1 = partition1.getSize(); 614 this->tmpLen2 = partition2.getSize(); 615 616 delete iterator; 624 this->tmpLen1 = partition1.size(); 625 this->tmpLen2 = partition2.size(); 626 617 627 618 628 // PRINTF(0)("\npartition 2:\n");
Note: See TracChangeset
for help on using the changeset viewer.