Changeset 4705 in orxonox.OLD for orxonox/trunk/src/lib
- Timestamp:
- Jun 26, 2005, 4:54:43 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/collision_detection/obb_tree_node.cc
r4704 r4705 365 365 axis[1].x = eigvMat[1][2]; axis[1].y = eigvMat[2][2]; axis[1].z = eigvMat[3][2]; 366 366 axis[2].x = eigvMat[1][3]; axis[2].y = eigvMat[2][3]; axis[2].z = eigvMat[3][3]; 367 axis[0].normalize(); 368 axis[1].normalize(); 369 axis[2].normalize(); 367 370 box->axis = axis; 368 371 … … 607 610 void OBBTreeNode::collideWith(BVTreeNode* treeNode, PNode* nodeA, PNode* nodeB) 608 611 { 609 PRINTF( 0)("collideWith\n");612 PRINTF(3)("collideWith\n"); 610 613 /* if the obb overlap, make subtests: check which node is realy overlaping */ 611 PRINT( 0)("Checking OBB %i vs %i: ", this->getIndex(), treeNode->getIndex());614 PRINT(3)("Checking OBB %i vs %i: ", this->getIndex(), treeNode->getIndex()); 612 615 if( this->overlapTest(this->bvElement, ((OBBTreeNode*)treeNode)->bvElement, nodeA, nodeB)) 613 616 { … … 615 618 if( likely( this->nodeLeft != NULL)) 616 619 { 617 PRINT( 0)("Checking OBB %i vs %i: ", this->nodeLeft->getIndex(), treeNode->getIndex());620 PRINT(3)("Checking OBB %i vs %i: ", this->nodeLeft->getIndex(), treeNode->getIndex()); 618 621 if( this->overlapTest(this->nodeLeft->bvElement, ((OBBTreeNode*)treeNode)->bvElement, nodeA, nodeB)) 619 622 { … … 625 628 if( likely( this->nodeRight != NULL)) 626 629 { 627 PRINT( 0)("Checking OBB %i vs %i: ", this->nodeRight->getIndex(), treeNode->getIndex());630 PRINT(3)("Checking OBB %i vs %i: ", this->nodeRight->getIndex(), treeNode->getIndex()); 628 631 if(this->overlapTest(this->nodeRight->bvElement, ((OBBTreeNode*)treeNode)->bvElement, nodeA, nodeB)) 629 632 { … … 639 642 bool OBBTreeNode::overlapTest(OBB* boxA, OBB* boxB, PNode* nodeA, PNode* nodeB) 640 643 { 641 642 643 644 644 /* first check all axis */ 645 645 Vector t = nodeA->getAbsCoor() + *boxA->center - ( nodeB->getAbsCoor() + *boxB->center); … … 650 650 /* All 3 axis of the object A */ 651 651 for( int j = 0; j < 3; ++j) 652 { 653 rA = 0.0f; 654 rB = 0.0f; 655 l = boxA->axis[j]; 656 657 rA += fabs(boxA->halfLength[0] * boxA->axis[0].dot(l)); 658 rA += fabs(boxA->halfLength[1] * boxA->axis[1].dot(l)); 659 rA += fabs(boxA->halfLength[2] * boxA->axis[2].dot(l)); 660 661 rB += fabs(boxB->halfLength[0] * boxB->axis[0].dot(l)); 662 rB += fabs(boxB->halfLength[1] * boxB->axis[1].dot(l)); 663 rB += fabs(boxB->halfLength[2] * boxB->axis[2].dot(l)); 664 665 PRINTF(3)("s = %f, rA+rB = %f\n", fabs(t.dot(l)), rA+rB); 666 667 if( (rA + rB) < fabs(t.dot(l))) 668 { 669 PRINT(3)("keine Kollision\n"); 670 return false; 671 } 672 } 673 674 /* All 3 axis of the object B */ 675 for( int j = 0; j < 3; ++j) 676 { 677 rA = 0.0f; 678 rB = 0.0f; 679 l = boxB->axis[j]; 680 681 rA += fabs(boxA->halfLength[0] * boxA->axis[0].dot(l)); 682 rA += fabs(boxA->halfLength[1] * boxA->axis[1].dot(l)); 683 rA += fabs(boxA->halfLength[2] * boxA->axis[2].dot(l)); 684 685 rB += fabs(boxB->halfLength[0] * boxB->axis[0].dot(l)); 686 rB += fabs(boxB->halfLength[1] * boxB->axis[1].dot(l)); 687 rB += fabs(boxB->halfLength[2] * boxB->axis[2].dot(l)); 688 689 PRINTF(3)("s = %f, rA+rB = %f\n", fabs(t.dot(l)), rA+rB); 690 691 if( (rA + rB) < fabs(t.dot(l))) 692 { 693 PRINT(3)("keine Kollision\n"); 694 return false; 695 } 696 } 697 698 699 /* Now check for all face cross products */ 700 701 for( int j = 0; j < 3; ++j) 702 { 703 for(int k = 0; k < 3; ++k ) 652 704 { 653 705 rA = 0.0f; 654 706 rB = 0.0f; 655 l = boxA->axis[j]; 656 657 /* \todo unroll all loops */ 658 for(int i = 0; i < 3; ++i) 659 rA += fabs(boxA->halfLength[i] * boxA->axis[i].dot(l)); 660 for(int i = 0; i < 3; ++i) 661 rB += fabs(boxB->halfLength[i] * boxB->axis[i].dot(l)); 662 707 l = boxA->axis[j].cross(boxB->axis[k]); 708 709 rA += fabs(boxA->halfLength[0] * boxA->axis[0].dot(l)); 710 rA += fabs(boxA->halfLength[1] * boxA->axis[1].dot(l)); 711 rA += fabs(boxA->halfLength[2] * boxA->axis[2].dot(l)); 712 713 rB += fabs(boxB->halfLength[0] * boxB->axis[0].dot(l)); 714 rB += fabs(boxB->halfLength[1] * boxB->axis[1].dot(l)); 715 rB += fabs(boxB->halfLength[2] * boxB->axis[2].dot(l)); 663 716 664 717 PRINTF(3)("s = %f, rA+rB = %f\n", fabs(t.dot(l)), rA+rB); … … 666 719 if( (rA + rB) < fabs(t.dot(l))) 667 720 { 668 PRINT(0)("keine Kollision\n"); 669 PRINTF(3)(" - Keine Kollision in der Bahnfohstrasse! Passagiere der Linien 6, 14 sind gebeten zu fliegen!\n"); 721 PRINT(3)("keine Kollision\n"); 670 722 return false; 671 723 } 672 724 } 673 674 /* All 3 axis of the object B */ 675 for( int j = 0; j < 3; ++j) 676 { 677 rA = 0.0f; 678 rB = 0.0f; 679 l = boxB->axis[j]; 680 681 for(int i = 0; i < 3; ++i) 682 rA += fabs(boxA->halfLength[i] * boxA->axis[i].dot(l)); 683 for(int i = 0; i < 3; ++i) 684 rB += fabs(boxB->halfLength[i] * boxB->axis[i].dot(l)); 685 686 687 PRINTF(3)("s = %f, rA+rB = %f\n", fabs(t.dot(l)), rA+rB); 688 689 if( (rA + rB) < fabs(t.dot(l))) 690 { 691 PRINT(0)("keine Kollision\n"); 692 PRINTF(3)(" - Keine Kollision in der Bahnfohstrasse! Passagiere der Linien 6, 14 sind gebeten zu fliegen!\n"); 693 return false; 694 } 695 } 696 697 698 /* Now check for all face cross products */ 699 700 for( int j = 0; j < 3; ++j) 701 { 702 for(int k = 0; k < 3; ++k ) 703 { 704 rA = 0.0f; 705 rB = 0.0f; 706 l = boxA->axis[j].cross(boxB->axis[k]); 707 708 for(int i = 0; i < 3; ++i) 709 rA += fabs(boxA->halfLength[i] * boxA->axis[i].dot(l)); 710 for(int i = 0; i < 3; ++i) 711 rB += fabs(boxB->halfLength[i] * boxB->axis[i].dot(l)); 712 713 714 PRINTF(3)("s = %f, rA+rB = %f\n", fabs(t.dot(l)), rA+rB); 715 716 if( (rA + rB) < fabs(t.dot(l))) 717 { 718 PRINT(0)("keine Kollision\n"); 719 PRINTF(3)(" - Keine Kollision in der Bahnfohstrasse! Passagiere der Linien 6, 14 sind gebeten zu fliegen!\n"); 720 return false; 721 } 722 } 723 } 724 725 726 727 728 boxA->bCollided = true; /* use this ONLY!!!! for drawing operations */ 729 boxB->bCollided = true; 730 PRINT(0)("Kollision!\n"); 731 return true; 725 } 726 727 728 boxA->bCollided = true; /* use this ONLY(!!!!) for drawing operations */ 729 boxB->bCollided = true; 730 PRINT(3)("Kollision!\n"); 731 return true; 732 732 } 733 733
Note: See TracChangeset
for help on using the changeset viewer.