- Timestamp:
- Nov 22, 2005, 2:26:46 AM (19 years ago)
- Location:
- branches/collision_detection/src/lib/collision_detection
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/collision_detection/src/lib/collision_detection/obb.cc
r5120 r5699 29 29 { 30 30 this->setClassID(CL_OBB, "OBB"); 31 this->axis = new Vector[3]; 32 this->halfLength = new float[3]; 31 this->halfLength[0] = this->halfLength[1] = this->halfLength[2] = 0.0f; 33 32 this->bCollided = false; 34 33 } … … 41 40 OBB::~OBB () 42 41 { 43 delete [] this->axis;44 delete [] this->halfLength;45 42 } 46 43 -
branches/collision_detection/src/lib/collision_detection/obb.h
r5039 r5699 21 21 22 22 23 inline Vector* getAxis () const { return this->axis; } 23 inline Vector getAxisX () const { return this->axis[0]; } 24 inline Vector getAxisY () const { return this->axis[1]; } 25 inline Vector getAxisZ () const { return this->axis[2]; } 26 24 27 inline const float* getHalfLength() const { return this->halfLength; } 25 28 … … 31 34 32 35 public: 33 Vector * axis;//!< Axes of oriented box [x,y,z]34 float * halfLength;//!< Half lengths of the box along the axis36 Vector axis[3]; //!< Axes of oriented box [x,y,z] 37 float halfLength[3]; //!< Half lengths of the box along the axis 35 38 float covarianceMatrix[3][3]; //!< the covariance matrix 36 39 -
branches/collision_detection/src/lib/collision_detection/obb_tree_node.cc
r5694 r5699 50 50 this->nodeRight = NULL; 51 51 this->bvElement = NULL; 52 this->tmpVert1 = NULL; 53 this->tmpVert2 = NULL; 52 54 53 55 if( OBBTreeNode::coMat == NULL) … … 93 95 delete this->bvElement; 94 96 this->bvElement = NULL; 97 98 if (this->tmpVert1 != NULL) 99 delete this->tmpVert1; 100 if (this->tmpVert2 != NULL) 101 delete this->tmpVert2; 95 102 } 96 103 … … 426 433 vectors 427 434 */ 428 Vector * axis = new Vector[3]; //!< the references to the obb axis435 Vector axis[3]; //!< the references to the obb axis 429 436 430 437 Matrix covMat( box->covarianceMatrix ); … … 454 461 axis[1].normalize(); 455 462 axis[2].normalize();*/ 456 box->axis = axis; 463 box->axis[0] = axis[0]; 464 box->axis[1] = axis[1]; 465 box->axis[2] = axis[2]; 457 466 458 467 // PRINTF(0)("-- Got Axis\n"); … … 476 485 /* now get the axis length */ 477 486 Line ax[3]; //!< the axis 478 float * halfLength = new float[3];//!< half length of the axis487 float halfLength[3]; //!< half length of the axis 479 488 float tmpLength; //!< tmp save point for the length 480 Plane p0(box->axis[0], *box->center); //!< the axis planes489 Plane p0(box->axis[0], *box->center); //!< the axis planes 481 490 Plane p1(box->axis[1], *box->center); 482 491 Plane p2(box->axis[2], *box->center); … … 561 570 562 571 563 box->halfLength = halfLength; 572 box->halfLength[0] = halfLength[0]; 573 box->halfLength[1] = halfLength[1]; 574 box->halfLength[2] = halfLength[2]; 564 575 PRINTF(3)("-- Written Axis to obb\n"); 565 576 PRINTF(3)("-- Finished Calculating Attributes\n"); … … 620 631 621 632 PRINTF(3)("vertex index: %i, of %i\n", vertexIndex, box->numOfVertices); 622 this->separationPlane = newPlane(box->axis[axisIndex], box->vertices[vertexIndex]); //!< separation plane633 this->separationPlane = Plane(box->axis[axisIndex], box->vertices[vertexIndex]); //!< separation plane 623 634 this->sepPlaneCenter = &box->vertices[vertexIndex]; 624 635 this->longestAxisIndex = axisIndex; … … 627 638 { 628 639 if( i == vertexIndex) continue; 629 tmpDist = this->separationPlane ->distancePoint(box->vertices[i]);640 tmpDist = this->separationPlane.distancePoint(box->vertices[i]); 630 641 if( tmpDist > 0.0) 631 642 partition1.add(&box->vertices[i]); /* positive numbers plus zero */ … … 660 671 element = iterator->nextElement(); 661 672 } 662 673 delete iterator; 663 674 // PRINTF(0)("\npartition 1:\n"); 664 675 // for(int i = 0; i < partition1.getSize(); ++i) … … 679 690 } 680 691 692 if (this->tmpVert1 != NULL) 693 delete[] this->tmpVert1; 681 694 this->tmpVert1 = vertList1; 695 if (this->tmpVert2 != NULL) 696 delete[] this->tmpVert2; 682 697 this->tmpVert2 = vertList2; 683 698 this->tmpLen1 = partition1.getSize(); -
branches/collision_detection/src/lib/collision_detection/obb_tree_node.h
r5693 r5699 66 66 int depth; //!< the depth of the node in the tree 67 67 static OBBTree* obbTree; //!< reference to the obb tree 68 Plane *separationPlane; //!< the separation plane of the obb68 Plane separationPlane; //!< the separation plane of the obb 69 69 const sVec3D* sepPlaneCenter; //!< only needed to draw plane 70 70 int longestAxisIndex; //!< only needed to draw plane
Note: See TracChangeset
for help on using the changeset viewer.