Changeset 4968 in orxonox.OLD for orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.cc
- Timestamp:
- Jul 29, 2005, 12:20:03 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.cc
r4957 r4968 134 134 if( this->nodeD != NULL) 135 135 delete this->nodeD; 136 137 if( this->pTriangles) 138 delete [] this->pTriangles; 139 140 if( this->pDimension) 141 delete this->pDimension; 136 142 } 137 143 … … 374 380 * @returns true if the vector is included 375 381 */ 376 bool QuadtreeNode::includesPoint(const Vector& v) 382 bool QuadtreeNode::includesPoint(const Vector& v) const 377 383 { 378 384 Vector center = *this->pDimension->getCenter(); … … 381 387 if( v.x > center.x - ax && v.x < center.x + ax && 382 388 v.z > center.z - ax && v.z < center.z + ax ) 383 {384 this->bDraw = true;385 389 return true; 386 }387 390 return false; 388 391 } … … 396 399 397 400 for( int i = 0; i < this->numTriangles; ++i) 401 { 402 a = *(sVec3D*)&this->pVertices[this->pTriangles[i]->indexToVertices[0]]; 403 b = *(sVec3D*)&this->pVertices[this->pTriangles[i]->indexToVertices[1]]; 404 c = *(sVec3D*)&this->pVertices[this->pTriangles[i]->indexToVertices[2]]; 405 406 if( unlikely(this->pointInTriangle(position, a, b, c))) 398 407 { 408 tri = this->pTriangles[i]; 409 break; 410 } 411 } 412 413 /* calculate height out of the data collected above */ 414 415 } 416 417 418 /** 419 * get triangles that includes the position 420 * @param position the position that is going to be checked 421 * @returns the triangle in which the position is included, NULL if there is no such triangle 422 423 There is some random behaviour if there are more than one triangle at the same y 424 coordinate. At the moment the function just takes the first triangle, that included the 425 vector 426 */ 427 sTriangleExt* QuadtreeNode::getTriangle(const Vector& position) const 428 { 429 Vector a, b, c; 430 PRINTF(0)("Get Triangle, %i\n", this->numTriangles); 431 432 for( int i = 0; i < numTriangles; ++i) 433 { 434 399 435 a = *(sVec3D*)&this->pVertices[this->pTriangles[i]->indexToVertices[0]]; 400 436 b = *(sVec3D*)&this->pVertices[this->pTriangles[i]->indexToVertices[1]]; … … 402 438 403 439 if( unlikely(this->pointInTriangle(position, a, b, c))) 404 {405 tri = this->pTriangles[i];406 break;407 }408 }409 410 /* calculate height out of the data collected above */411 412 }413 414 415 /**416 * get triangles that includes the position417 * @param position the position that is going to be checked418 * @returns the triangle in which the position is included, NULL if there is no such triangle419 420 There is some random behaviour if there are more than one triangle at the same y421 coordinate. At the moment the function just takes the first triangle, that included the422 vector423 */424 sTriangleExt* QuadtreeNode::getTriangle(const Vector& position) const425 {426 Vector a, b, c;427 428 for( int i = 0; i < this->numTriangles; ++i)429 {430 a = *(sVec3D*)&this->pVertices[this->pTriangles[i]->indexToVertices[0]];431 b = *(sVec3D*)&this->pVertices[this->pTriangles[i]->indexToVertices[1]];432 c = *(sVec3D*)&this->pVertices[this->pTriangles[i]->indexToVertices[2]];433 434 if( unlikely(this->pointInTriangle(position, a, b, c)))435 440 return this->pTriangles[i]; 441 436 442 } 437 443 return NULL; … … 446 452 * @param rectangle edge c 447 453 * @returns true if the point is inside 448 */454 */ 449 455 bool QuadtreeNode::pointInTriangle(const Vector&p, const Vector& a, const Vector& b, const Vector& c) const 450 456 { 457 458 PRINTF(0)("p: (%f, %f, %f)\n", p.x, p.y, p.z); 459 PRINTF(0)("a: (%f, %f, %f)\n", a.x, a.y, a.z); 460 PRINTF(0)("b: (%f, %f, %f)\n", b.x, b.y, b.z); 461 PRINTF(0)("c: (%f, %f, %f)\n", c.x, c.y, c.z); 462 451 463 if( this->sameSide(p, a, b, c) && this->sameSide(p, b, a, c) && sameSide(p, c, a, b)) 452 464 return true; … … 461 473 * @param begining point of the line 462 474 * @param end of the line 463 */475 */ 464 476 bool QuadtreeNode::sameSide(const Vector& p1, const Vector&p2, const Vector& a, const Vector& b) const 465 477 { … … 509 521 void QuadtreeNode::draw() const 510 522 { 511 if( likely(! bDraw))523 if( likely(!this->bDraw)) 512 524 return; 525 513 526 Vector t1 = *this->pDimension->getCenter(); 514 527 float ax = this->pDimension->getAxis(); … … 524 537 525 538 glEnd(); 526 527 } 539 }
Note: See TracChangeset
for help on using the changeset viewer.