- Timestamp:
- Jul 29, 2005, 12:20:03 AM (19 years ago)
- Location:
- orxonox/trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/collision_detection/cd_engine.cc
r4924 r4968 19 19 #include "obb_tree.h" 20 20 #include "debug.h" 21 #include "abstract_model.h"22 21 #include "list.h" 23 22 23 #include "abstract_model.h" 24 24 #include "world_entity.h" 25 25 #include "terrain.h" … … 104 104 { 105 105 Quadtree* q = this->terrain->ssp->getQuadtree(); 106 q->getQuadtreeFromPosition(this->player->getAbsCoor()); 106 107 QuadtreeNode* n = q->getQuadtreeFromPosition(this->player->getAbsCoor()); 108 109 //sTriangleExt* tri = q->getTriangleFromPosition(this->player->getAbsCoor()); 107 110 } 108 111 -
orxonox/trunk/src/lib/graphics/spatial_separation/quadtree.cc
r4956 r4968 168 168 169 169 /* check if object is still inside the terrain - this check is not complete @todo check all 4 bounds */ 170 if( i < this->maxIndex && j < this->maxIndex) 171 this->nodes[i + j * this->maxIndex]->includesPoint(position); 172 else 173 PRINTF(5)("Object has left terrain\n"); 170 if( i < this->maxIndex && j < this->maxIndex && i >= 0 && j >= 0) 171 return this->nodes[i + j * this->maxIndex]; 172 173 174 PRINTF(4)("Object has left terrain\n"); 175 return NULL; 174 176 } 175 177 … … 185 187 { 186 188 QuadtreeNode* q = this->getQuadtreeFromPosition(position); 187 return q->getTriangle(position); 189 190 if( likely(q != NULL)) 191 return q->getTriangle(position - *this->offset); 192 return NULL; 188 193 } 189 194 -
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 } -
orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.h
r4956 r4968 38 38 inline Rectangle* getDimension() { return this->pDimension; } 39 39 40 bool includesPoint(const Vector& v) ;40 bool includesPoint(const Vector& v) const; 41 41 sTriangleExt* getTriangle(const Vector& position) const; 42 42 float getHeight(const Vector& position) const; … … 63 63 QuadtreeNode* nodeC; //!< reference to the node C 64 64 QuadtreeNode* nodeD; //!< reference to the node D 65 QuadtreeNode** nodes; //!< reference to the quadtree nodes 65 QuadtreeNode** nodes; //!< reference to the quadtree nodes (nodeA, nodeB, nodeC, nodeD=[0..3]) 66 66 67 67 -
orxonox/trunk/src/lib/graphics/spatial_separation/spatial_separation.cc
r4923 r4968 61 61 SpatialSeparation::~SpatialSeparation () 62 62 { 63 if( this->quadtree) 64 delete this->quadtree; 63 65 } 64 66 -
orxonox/trunk/src/story_entities/world.cc
r4967 r4968 963 963 964 964 SoundEngine::getInstance()->update(); 965 //music->update();965 // music->update(); 966 966 } 967 967
Note: See TracChangeset
for help on using the changeset viewer.