Changeset 4929 in orxonox.OLD for orxonox/trunk/src/lib
- Timestamp:
- Jul 21, 2005, 6:07:23 PM (19 years ago)
- Location:
- orxonox/trunk/src/lib/graphics/spatial_separation
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/graphics/spatial_separation/quadtree.cc
r4925 r4929 167 167 int j = (int)(v.z / quadLength); 168 168 169 /* check if object is still inside the terrain */169 /* check if object is still inside the terrain - this check is not complete @todo check all 4 bounds */ 170 170 if( i < this->maxIndex && j < this->maxIndex) 171 171 this->nodes[i + j * this->maxIndex]->includesPoint(position); … … 176 176 177 177 /** 178 * maps a position to a triangle 179 * @param position the position so look for 180 * @return the triangle 181 182 this function will return the quadtree that contains the position 183 */ 184 sTriangleExt* Quadtree::getTriangleFromPosition(const Vector& position) 185 { 186 QuadtreeNode* q = this->getQuadtreeFromPosition(position); 187 return q->getTriangle(position); 188 } 189 190 191 /** 178 192 * draws the debug quadtree boxes around the model 179 193 */ -
orxonox/trunk/src/lib/graphics/spatial_separation/quadtree.h
r4924 r4929 28 28 29 29 QuadtreeNode* getQuadtreeFromPosition(const Vector& position); 30 sTriangleExt* getTriangleFromPosition(const Vector& position); 30 31 31 32 void drawTree() const; -
orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.cc
r4925 r4929 389 389 390 390 391 sTriangleExt* QuadtreeNode::getTriangle(const Vector& position) 392 { 393 394 } 395 396 bool QuadtreeNode::pointInTriangle(const Vector&p, const Vector& a, const Vector& b, const Vector& c) 397 { 398 if( this->sameSide(p, a, b, c) && this->sameSide(p, b, a, c) && sameSide(p, c, a, b)) 399 return true; 400 return false; 401 /* 402 function PointInTriangle(p, a,b,c) 403 if SameSide(p,a, b,c) and SameSide(p,b, a,c) 404 and SameSide(p,c, a,b) then return true 405 else return false 406 */ 407 } 408 409 410 bool QuadtreeNode::sameSide(const Vector& p1, const Vector&p2, const Vector& a, const Vector& b) 411 { 412 Vector cp1 = (b - a).cross(p1 - a); 413 Vector cp2 = (b - a).cross(p2 - a); 414 415 if( unlikely(cp1.dot(cp2) >= 0)) return true; 416 return false; 417 } 418 419 391 420 /** 392 421 * draws all the debug quadtree squares -
orxonox/trunk/src/lib/graphics/spatial_separation/quadtree_node.h
r4923 r4929 37 37 void buildHashTable(QuadtreeNode** nodeList, int* index); 38 38 bool includesPoint(const Vector& v); 39 sTriangleExt* getTriangle(const Vector& position); 39 40 float getHeight(const Vector& position); 40 41 inline Rectangle* getDimension() { return this->pDimension; } … … 51 52 Rectangle* getDimFromModel(); 52 53 54 bool sameSide(const Vector& p1, const Vector&p2, const Vector& a, const Vector& b); 55 bool pointInTriangle(const Vector&p, const Vector& a, const Vector& b, const Vector& c); 53 56 54 57 protected:
Note: See TracChangeset
for help on using the changeset viewer.